rustc_attr_parsing/attributes/lint_helpers.rs
1use super::prelude::*;
2
3pub(crate) struct AsPtrParser;
4impl<S: Stage> NoArgsAttributeParser<S> for AsPtrParser {
5 const PATH: &[Symbol] = &[sym::rustc_as_ptr];
6 const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
7 const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
8 Allow(Target::Fn),
9 Allow(Target::Method(MethodKind::Inherent)),
10 Allow(Target::Method(MethodKind::Trait { body: false })),
11 Allow(Target::Method(MethodKind::Trait { body: true })),
12 Allow(Target::Method(MethodKind::TraitImpl)),
13 ]);
14 const CREATE: fn(Span) -> AttributeKind = AttributeKind::AsPtr;
15}
16
17pub(crate) struct PubTransparentParser;
18impl<S: Stage> NoArgsAttributeParser<S> for PubTransparentParser {
19 const PATH: &[Symbol] = &[sym::rustc_pub_transparent];
20 const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
21 const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
22 Allow(Target::Struct),
23 Allow(Target::Enum),
24 Allow(Target::Union),
25 ]);
26 const CREATE: fn(Span) -> AttributeKind = AttributeKind::PubTransparent;
27}
28
29pub(crate) struct PassByValueParser;
30impl<S: Stage> NoArgsAttributeParser<S> for PassByValueParser {
31 const PATH: &[Symbol] = &[sym::rustc_pass_by_value];
32 const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
33 const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
34 Allow(Target::Struct),
35 Allow(Target::Enum),
36 Allow(Target::TyAlias),
37 ]);
38 const CREATE: fn(Span) -> AttributeKind = AttributeKind::PassByValue;
39}
40
41pub(crate) struct AutomaticallyDerivedParser;
42impl<S: Stage> NoArgsAttributeParser<S> for AutomaticallyDerivedParser {
43 const PATH: &[Symbol] = &[sym::automatically_derived];
44 const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
45 const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowListWarnRest(&[
46 Allow(Target::Impl { of_trait: true }),
47 Error(Target::Crate),
48 Error(Target::WherePredicate),
49 ]);
50 const CREATE: fn(Span) -> AttributeKind = AttributeKind::AutomaticallyDerived;
51}