rustc_attr_parsing/attributes/
rustc_allocator.rs1use rustc_feature::AttributeStability;
2
3use super::prelude::*;
4
5pub(crate) struct RustcAllocatorParser;
6
7impl NoArgsAttributeParser for RustcAllocatorParser {
8 const PATH: &[Symbol] = &[sym::rustc_allocator];
9 const ALLOWED_TARGETS: AllowedTargets =
10 AllowedTargets::AllowList(&[Allow(Target::Fn), Allow(Target::ForeignFn)]);
11 const STABILITY: AttributeStability = AttributeStability::Unstable {
gate_name: rustc_span::sym::rustc_attrs,
gate_check: rustc_feature::Features::rustc_attrs,
notes: &[],
}unstable!(rustc_attrs);
12 const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcAllocator;
13}
14
15pub(crate) struct RustcAllocatorZeroedParser;
16
17impl NoArgsAttributeParser for RustcAllocatorZeroedParser {
18 const PATH: &[Symbol] = &[sym::rustc_allocator_zeroed];
19 const ALLOWED_TARGETS: AllowedTargets =
20 AllowedTargets::AllowList(&[Allow(Target::Fn), Allow(Target::ForeignFn)]);
21 const STABILITY: AttributeStability = AttributeStability::Unstable {
gate_name: rustc_span::sym::rustc_attrs,
gate_check: rustc_feature::Features::rustc_attrs,
notes: &[],
}unstable!(rustc_attrs);
22 const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcAllocatorZeroed;
23}
24
25pub(crate) struct RustcAllocatorZeroedVariantParser;
26
27impl SingleAttributeParser for RustcAllocatorZeroedVariantParser {
28 const PATH: &[Symbol] = &[sym::rustc_allocator_zeroed_variant];
29 const ALLOWED_TARGETS: AllowedTargets =
30 AllowedTargets::AllowList(&[Allow(Target::Fn), Allow(Target::ForeignFn)]);
31 const TEMPLATE: AttributeTemplate = ::rustc_feature::AttributeTemplate {
word: false,
list: None,
one_of: &[],
name_value_str: Some(&["function"]),
docs: None,
}template!(NameValueStr: "function");
32 const STABILITY: AttributeStability = AttributeStability::Unstable {
gate_name: rustc_span::sym::rustc_attrs,
gate_check: rustc_feature::Features::rustc_attrs,
notes: &[],
}unstable!(rustc_attrs);
33 fn convert(cx: &mut AcceptContext<'_, '_>, args: &ArgParser) -> Option<AttributeKind> {
34 let nv = cx.expect_name_value(args, cx.attr_span, None)?;
35 let name = cx.expect_string_literal(nv)?;
36
37 Some(AttributeKind::RustcAllocatorZeroedVariant { name })
38 }
39}
40
41pub(crate) struct RustcDeallocatorParser;
42
43impl NoArgsAttributeParser for RustcDeallocatorParser {
44 const PATH: &[Symbol] = &[sym::rustc_deallocator];
45 const ALLOWED_TARGETS: AllowedTargets =
46 AllowedTargets::AllowList(&[Allow(Target::Fn), Allow(Target::ForeignFn)]);
47 const STABILITY: AttributeStability = AttributeStability::Unstable {
gate_name: rustc_span::sym::rustc_attrs,
gate_check: rustc_feature::Features::rustc_attrs,
notes: &[],
}unstable!(rustc_attrs);
48 const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcDeallocator;
49}
50
51pub(crate) struct RustcReallocatorParser;
52
53impl NoArgsAttributeParser for RustcReallocatorParser {
54 const PATH: &[Symbol] = &[sym::rustc_reallocator];
55 const ALLOWED_TARGETS: AllowedTargets =
56 AllowedTargets::AllowList(&[Allow(Target::Fn), Allow(Target::ForeignFn)]);
57 const STABILITY: AttributeStability = AttributeStability::Unstable {
gate_name: rustc_span::sym::rustc_attrs,
gate_check: rustc_feature::Features::rustc_attrs,
notes: &[],
}unstable!(rustc_attrs);
58 const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcReallocator;
59}