Skip to main content

rustc_attr_parsing/attributes/
must_not_suspend.rs

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