rustc_attr_parsing/attributes/non_exhaustive.rs
1use rustc_hir::Target;
2use rustc_hir::attrs::AttributeKind;
3use rustc_span::{Span, Symbol, sym};
4
5use crate::attributes::{NoArgsAttributeParser, OnDuplicate};
6use crate::context::MaybeWarn::{Allow, Warn};
7use crate::context::{AllowedTargets, Stage};
8pub(crate) struct NonExhaustiveParser;
9
10impl<S: Stage> NoArgsAttributeParser<S> for NonExhaustiveParser {
11 const PATH: &[Symbol] = &[sym::non_exhaustive];
12 const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
13 const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
14 Allow(Target::Enum),
15 Allow(Target::Struct),
16 Allow(Target::Variant),
17 Warn(Target::Field),
18 Warn(Target::Arm),
19 Warn(Target::MacroDef),
20 ]);
21 const CREATE: fn(Span) -> AttributeKind = AttributeKind::NonExhaustive;
22}