Skip to main content

rustc_attr_parsing/attributes/
semantics.rs

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