Skip to main content

rustc_attr_parsing/attributes/
must_not_suspend.rs

1use 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 ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
8    const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
9        Allow(Target::Struct),
10        Allow(Target::Enum),
11        Allow(Target::Union),
12        Allow(Target::Trait),
13    ]);
14    const TEMPLATE: AttributeTemplate = ::rustc_feature::AttributeTemplate {
    word: true,
    list: Some(&["count"]),
    one_of: &[],
    name_value_str: None,
    docs: None,
}template!(Word, List: &["count"]);
15
16    fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option<AttributeKind> {
17        let reason = match args {
18            ArgParser::NameValue(reason) => match reason.value_as_str() {
19                Some(val) => Some(val),
20                None => {
21                    cx.expected_nv_or_no_args(reason.value_span);
22                    return None;
23                }
24            },
25            ArgParser::NoArgs => None,
26            ArgParser::List(list) => {
27                cx.expected_nv_or_no_args(list.span);
28                return None;
29            }
30        };
31
32        Some(AttributeKind::MustNotSupend { reason })
33    }
34}