Skip to main content

rustc_attr_parsing/attributes/
semantics.rs

1use rustc_feature::AttributeStability;
2
3use super::prelude::*;
4
5pub(crate) struct MayDangleParser;
6impl NoArgsAttributeParser for MayDangleParser {
7    const PATH: &[Symbol] = &[sym::may_dangle];
8    const ALLOWED_TARGETS: AllowedTargets<'_> =
9        AllowedTargets::AllowList(&[Allow(Target::TypeParam), Allow(Target::LifetimeParam)]);
10    const STABILITY: AttributeStability = {
    _ = rustc_feature::Features::dropck_eyepatch;
    AttributeStability::Unstable {
        gate_name: rustc_span::sym::dropck_eyepatch,
        notes: &[],
    }
}unstable!(dropck_eyepatch);
11    const CREATE: fn(span: Span) -> AttributeKind = AttributeKind::MayDangle;
12}
13
14pub(crate) struct ComptimeParser;
15impl NoArgsAttributeParser for ComptimeParser {
16    const PATH: &[Symbol] = &[sym::rustc_comptime];
17    const ALLOWED_TARGETS: AllowedTargets<'_> = AllowedTargets::AllowList(&[
18        Allow(Target::Method(MethodKind::Inherent)),
19        Allow(Target::Fn),
20        Allow(Target::Impl { of_trait: false }),
21    ]);
22    const STABILITY: AttributeStability = {
    _ = rustc_feature::Features::rustc_attrs;
    AttributeStability::Unstable {
        gate_name: rustc_span::sym::rustc_attrs,
        notes: &[],
    }
}unstable!(rustc_attrs);
23    const CREATE: fn(Span) -> AttributeKind = AttributeKind::RustcComptime;
24}
25
26pub(crate) struct AlwaysGcaParser;
27impl NoArgsAttributeParser for AlwaysGcaParser {
28    const PATH: &[Symbol] = &[sym::rustc_always_gca];
29    const ALLOWED_TARGETS: AllowedTargets<'_> =
30        AllowedTargets::AllowList(&[Allow(Target::AssocConst(AssocCtxt::Trait))]);
31    const STABILITY: AttributeStability = {
    _ = rustc_feature::Features::min_generic_const_args;
    AttributeStability::Unstable {
        gate_name: rustc_span::sym::min_generic_const_args,
        notes: &[],
    }
}unstable!(min_generic_const_args);
32    const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::AlwaysGca;
33}