Skip to main content

rustc_attr_parsing/attributes/
semantics.rs

1use rustc_feature::AttributeStability;
2use rustc_hir::target::GenericParamKind;
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 = AttributeStability::Unstable {
    gate_name: rustc_span::sym::dropck_eyepatch,
    gate_check: rustc_feature::Features::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 ON_DUPLICATE: OnDuplicate = OnDuplicate::Error;
23    const ALLOWED_TARGETS: AllowedTargets<'_> = AllowedTargets::AllowList(&[
24        Allow(Target::Method(MethodKind::Inherent)),
25        Allow(Target::Fn),
26    ]);
27    const STABILITY: AttributeStability = AttributeStability::Unstable {
    gate_name: rustc_span::sym::rustc_attrs,
    gate_check: rustc_feature::Features::rustc_attrs,
    notes: &[],
}unstable!(rustc_attrs);
28    const CREATE: fn(Span) -> AttributeKind = AttributeKind::RustcComptime;
29}