rustc_attr_parsing/attributes/
lint_helpers.rs1use 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 RustcShouldNotBeCalledOnConstItems;
42impl<S: Stage> NoArgsAttributeParser<S> for RustcShouldNotBeCalledOnConstItems {
43 const PATH: &[Symbol] = &[sym::rustc_should_not_be_called_on_const_items];
44 const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
45 const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
46 Allow(Target::Method(MethodKind::Inherent)),
47 Allow(Target::Method(MethodKind::TraitImpl)),
48 ]);
49 const CREATE: fn(Span) -> AttributeKind = AttributeKind::RustcShouldNotBeCalledOnConstItems;
50}
51
52pub(crate) struct AutomaticallyDerivedParser;
53impl<S: Stage> NoArgsAttributeParser<S> for AutomaticallyDerivedParser {
54 const PATH: &[Symbol] = &[sym::automatically_derived];
55 const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
56 const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowListWarnRest(&[
57 Allow(Target::Impl { of_trait: true }),
58 Error(Target::Crate),
59 Error(Target::WherePredicate),
60 ]);
61 const CREATE: fn(Span) -> AttributeKind = AttributeKind::AutomaticallyDerived;
62}