rewrite #[naked] parser

This commit is contained in:
Jana Dönszelmann
2025-06-13 01:36:52 +02:00
parent 22be76b7e2
commit 82cbc3a35e
10 changed files with 44 additions and 16 deletions

View File

@@ -51,12 +51,29 @@ impl<S: Stage> SingleAttributeParser<S> for ColdParser {
if !args.no_args() {
cx.expected_no_args(args.span().unwrap_or(cx.attr_span));
return None;
};
}
Some(AttributeKind::Cold(cx.attr_span))
}
}
pub(crate) struct NakedParser;
impl<S: Stage> SingleAttributeParser<S> for NakedParser {
const PATH: &[rustc_span::Symbol] = &[sym::naked];
const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepLast;
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
const TEMPLATE: AttributeTemplate = template!(Word);
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser<'_>) -> Option<AttributeKind> {
if !args.no_args() {
cx.expected_no_args(args.span().unwrap_or(cx.attr_span));
return None;
}
Some(AttributeKind::Naked(cx.attr_span))
}
}
pub(crate) struct NoMangleParser;
impl<S: Stage> SingleAttributeParser<S> for NoMangleParser {