Skip to main content

rustc_attr_parsing/attributes/
must_not_suspend.rs

1use super::prelude::*;
2
3pub(crate) struct MustNotSuspendParser;
4
5impl SingleAttributeParser 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<'_, '_>, args: &ArgParser) -> Option<AttributeKind> {
16        let reason = match args {
17            ArgParser::NameValue(reason) => cx.expect_string_literal(reason),
18            ArgParser::NoArgs => None,
19            ArgParser::List(list) => {
20                cx.adcx().expected_nv_or_no_args(list.span);
21                return None;
22            }
23        };
24
25        Some(AttributeKind::MustNotSupend { reason })
26    }
27}