rustc_attr_parsing/attributes/
must_not_suspend.rs1use super::prelude::*;
2
3pub(crate) struct MustNotSuspendParser;
4
5impl<S: Stage> SingleAttributeParser<S> for MustNotSuspendParser {
6 const PATH: &[rustc_span::Symbol] = &[sym::must_not_suspend];
7 const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
8 Allow(Target::Struct),
9 Allow(Target::Enum),
10 Allow(Target::Union),
11 Allow(Target::Trait),
12 ]);
13 const TEMPLATE: AttributeTemplate = ::rustc_feature::AttributeTemplate {
word: true,
list: Some(&["count"]),
one_of: &[],
name_value_str: None,
docs: None,
}template!(Word, List: &["count"]);
14
15 fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option<AttributeKind> {
16 let reason = match args {
17 ArgParser::NameValue(reason) => match reason.value_as_str() {
18 Some(val) => Some(val),
19 None => {
20 cx.adcx().expected_nv_or_no_args(reason.value_span);
21 return None;
22 }
23 },
24 ArgParser::NoArgs => None,
25 ArgParser::List(list) => {
26 cx.adcx().expected_nv_or_no_args(list.span);
27 return None;
28 }
29 };
30
31 Some(AttributeKind::MustNotSupend { reason })
32 }
33}