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