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::Stage;
7use crate::target_checking::AllowedTargets;
8use crate::target_checking::Policy::{Allow, Warn};
9
10pub(crate) struct NonExhaustiveParser;
11
12impl<S: Stage> NoArgsAttributeParser<S> for NonExhaustiveParser {
13    const PATH: &[Symbol] = &[sym::non_exhaustive];
14    const ON_DUPLICATE: OnDuplicate<S> = 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 CREATE: fn(Span) -> AttributeKind = AttributeKind::NonExhaustive;
25}