rustc_attr_parsing/attributes/
non_exhaustive.rs1use rustc_feature::AttributeStability;
2use rustc_hir::Target;
3use rustc_hir::attrs::AttributeKind;
4use rustc_span::{Span, Symbol, sym};
5
6use crate::attributes::{NoArgsAttributeParser, OnDuplicate};
7use crate::target_checking::AllowedTargets;
8use crate::target_checking::Policy::{Allow, Warn};
9
10pub(crate) struct NonExhaustiveParser;
11
12impl NoArgsAttributeParser for NonExhaustiveParser {
13 const PATH: &[Symbol] = &[sym::non_exhaustive];
14 const ON_DUPLICATE: OnDuplicate = OnDuplicate::Warn;
15 const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
16 Allow(Target::Enum),
17 Allow(Target::Struct),
18 Allow(Target::Variant),
19 Warn(Target::Field),
20 Warn(Target::Arm),
21 Warn(Target::MacroDef),
22 Warn(Target::MacroCall),
23 ]);
24 const STABILITY: AttributeStability = AttributeStability::Stable;
25 const CREATE: fn(Span) -> AttributeKind = AttributeKind::NonExhaustive;
26}