forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlint_helpers.rs
More file actions
58 lines (53 loc) · 2.38 KB
/
lint_helpers.rs
File metadata and controls
58 lines (53 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
use super::prelude::*;
pub(crate) struct RustcAsPtrParser;
impl NoArgsAttributeParser for RustcAsPtrParser {
const PATH: &[Symbol] = &[sym::rustc_as_ptr];
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
Allow(Target::Fn),
Allow(Target::Method(MethodKind::Inherent)),
Allow(Target::Method(MethodKind::Trait { body: false })),
Allow(Target::Method(MethodKind::Trait { body: true })),
Allow(Target::Method(MethodKind::TraitImpl)),
]);
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcAsPtr;
}
pub(crate) struct RustcPubTransparentParser;
impl NoArgsAttributeParser for RustcPubTransparentParser {
const PATH: &[Symbol] = &[sym::rustc_pub_transparent];
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
Allow(Target::Struct),
Allow(Target::Enum),
Allow(Target::Union),
]);
const CREATE: fn(Span) -> AttributeKind = AttributeKind::RustcPubTransparent;
}
pub(crate) struct RustcPassByValueParser;
impl NoArgsAttributeParser for RustcPassByValueParser {
const PATH: &[Symbol] = &[sym::rustc_pass_by_value];
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
Allow(Target::Struct),
Allow(Target::Enum),
Allow(Target::TyAlias),
]);
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcPassByValue;
}
pub(crate) struct RustcShouldNotBeCalledOnConstItemsParser;
impl NoArgsAttributeParser for RustcShouldNotBeCalledOnConstItemsParser {
const PATH: &[Symbol] = &[sym::rustc_should_not_be_called_on_const_items];
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
Allow(Target::Method(MethodKind::Inherent)),
Allow(Target::Method(MethodKind::TraitImpl)),
]);
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcShouldNotBeCalledOnConstItems;
}
pub(crate) struct AutomaticallyDerivedParser;
impl NoArgsAttributeParser for AutomaticallyDerivedParser {
const PATH: &[Symbol] = &[sym::automatically_derived];
const ON_DUPLICATE: OnDuplicate = OnDuplicate::Warn;
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowListWarnRest(&[
Allow(Target::Impl { of_trait: true }),
Error(Target::Crate),
Error(Target::WherePredicate),
]);
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::AutomaticallyDerived;
}