mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-30 14:52:56 +03:00
Port #[needs_allocator] to attribute parser
This commit is contained in:
@@ -658,3 +658,12 @@ fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option<Attrib
|
||||
Some(AttributeKind::Linkage(linkage, cx.attr_span))
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) struct NeedsAllocatorParser;
|
||||
|
||||
impl<S: Stage> NoArgsAttributeParser<S> for NeedsAllocatorParser {
|
||||
const PATH: &[Symbol] = &[sym::needs_allocator];
|
||||
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
|
||||
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Crate)]);
|
||||
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::NeedsAllocator;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
use crate::attributes::instruction_set::InstructionSetParser;
|
||||
use crate::attributes::link_attrs::{
|
||||
ExportStableParser, FfiConstParser, FfiPureParser, LinkNameParser, LinkOrdinalParser,
|
||||
LinkParser, LinkSectionParser, LinkageParser, StdInternalSymbolParser,
|
||||
LinkParser, LinkSectionParser, LinkageParser, NeedsAllocatorParser, StdInternalSymbolParser,
|
||||
};
|
||||
use crate::attributes::lint_helpers::{
|
||||
AsPtrParser, AutomaticallyDerivedParser, PassByValueParser, PubTransparentParser,
|
||||
@@ -259,6 +259,7 @@ mod late {
|
||||
Single<WithoutArgs<MacroEscapeParser>>,
|
||||
Single<WithoutArgs<MarkerParser>>,
|
||||
Single<WithoutArgs<MayDangleParser>>,
|
||||
Single<WithoutArgs<NeedsAllocatorParser>>,
|
||||
Single<WithoutArgs<NoCoreParser>>,
|
||||
Single<WithoutArgs<NoImplicitPreludeParser>>,
|
||||
Single<WithoutArgs<NoLinkParser>>,
|
||||
|
||||
@@ -840,6 +840,9 @@ pub enum AttributeKind {
|
||||
/// Represents `#[naked]`
|
||||
Naked(Span),
|
||||
|
||||
/// Represents `#[needs_allocator]`
|
||||
NeedsAllocator,
|
||||
|
||||
/// Represents `#[no_core]`
|
||||
NoCore(Span),
|
||||
|
||||
|
||||
@@ -75,6 +75,7 @@ pub fn encode_cross_crate(&self) -> EncodeCrossCrate {
|
||||
MustNotSupend { .. } => Yes,
|
||||
MustUse { .. } => Yes,
|
||||
Naked(..) => No,
|
||||
NeedsAllocator => No,
|
||||
NoCore(..) => No,
|
||||
NoImplicitPrelude(..) => No,
|
||||
NoLink => No,
|
||||
|
||||
@@ -742,7 +742,7 @@ macro_rules! stat {
|
||||
proc_macro_data,
|
||||
debugger_visualizers,
|
||||
compiler_builtins: ast::attr::contains_name(attrs, sym::compiler_builtins),
|
||||
needs_allocator: ast::attr::contains_name(attrs, sym::needs_allocator),
|
||||
needs_allocator: find_attr!(attrs, AttributeKind::NeedsAllocator),
|
||||
needs_panic_runtime: ast::attr::contains_name(attrs, sym::needs_panic_runtime),
|
||||
no_builtins: ast::attr::contains_name(attrs, sym::no_builtins),
|
||||
panic_runtime: ast::attr::contains_name(attrs, sym::panic_runtime),
|
||||
|
||||
@@ -315,6 +315,7 @@ fn check_attributes(
|
||||
| AttributeKind::RustcDumpPredicates
|
||||
| AttributeKind::RustcDumpDefParents
|
||||
| AttributeKind::RustcDumpVtable(..)
|
||||
| AttributeKind::NeedsAllocator
|
||||
) => { /* do nothing */ }
|
||||
Attribute::Unparsed(attr_item) => {
|
||||
style = Some(attr_item.style);
|
||||
@@ -346,7 +347,6 @@ fn check_attributes(
|
||||
| sym::prelude_import
|
||||
| sym::panic_handler
|
||||
| sym::lang
|
||||
| sym::needs_allocator
|
||||
| sym::default_lib_allocator
|
||||
| sym::rustc_diagnostic_item
|
||||
| sym::rustc_no_mir_inline
|
||||
|
||||
Reference in New Issue
Block a user