Port #![compiler_builtins] to the attribute parser.
This commit is contained in:
parent
daa90b96dd
commit
8c4e48e9b5
7 changed files with 20 additions and 6 deletions
|
|
@ -665,3 +665,12 @@ impl<S: Stage> NoArgsAttributeParser<S> for NeedsAllocatorParser {
|
|||
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Crate)]);
|
||||
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::NeedsAllocator;
|
||||
}
|
||||
|
||||
pub(crate) struct CompilerBuiltinsParser;
|
||||
|
||||
impl<S: Stage> NoArgsAttributeParser<S> for CompilerBuiltinsParser {
|
||||
const PATH: &[Symbol] = &[sym::compiler_builtins];
|
||||
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
|
||||
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Crate)]);
|
||||
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::CompilerBuiltins;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,8 +40,9 @@ use crate::attributes::dummy::DummyParser;
|
|||
use crate::attributes::inline::{InlineParser, RustcForceInlineParser};
|
||||
use crate::attributes::instruction_set::InstructionSetParser;
|
||||
use crate::attributes::link_attrs::{
|
||||
ExportStableParser, FfiConstParser, FfiPureParser, LinkNameParser, LinkOrdinalParser,
|
||||
LinkParser, LinkSectionParser, LinkageParser, NeedsAllocatorParser, StdInternalSymbolParser,
|
||||
CompilerBuiltinsParser, ExportStableParser, FfiConstParser, FfiPureParser, LinkNameParser,
|
||||
LinkOrdinalParser, LinkParser, LinkSectionParser, LinkageParser, NeedsAllocatorParser,
|
||||
StdInternalSymbolParser,
|
||||
};
|
||||
use crate::attributes::lint_helpers::{
|
||||
AsPtrParser, AutomaticallyDerivedParser, PassByValueParser, PubTransparentParser,
|
||||
|
|
@ -251,6 +252,7 @@ attribute_parsers!(
|
|||
Single<WithoutArgs<AutomaticallyDerivedParser>>,
|
||||
Single<WithoutArgs<CoinductiveParser>>,
|
||||
Single<WithoutArgs<ColdParser>>,
|
||||
Single<WithoutArgs<CompilerBuiltinsParser>>,
|
||||
Single<WithoutArgs<ConstContinueParser>>,
|
||||
Single<WithoutArgs<ConstStabilityIndirectParser>>,
|
||||
Single<WithoutArgs<CoroutineParser>>,
|
||||
|
|
|
|||
|
|
@ -687,6 +687,9 @@ pub enum AttributeKind {
|
|||
/// Represents `#[collapse_debuginfo]`.
|
||||
CollapseDebugInfo(CollapseMacroDebuginfo),
|
||||
|
||||
/// Represents `#[compiler_builtins]`.
|
||||
CompilerBuiltins,
|
||||
|
||||
/// Represents `#[rustc_confusables]`.
|
||||
Confusables {
|
||||
symbols: ThinVec<Symbol>,
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ impl AttributeKind {
|
|||
Coinductive(..) => No,
|
||||
Cold(..) => No,
|
||||
CollapseDebugInfo(..) => Yes,
|
||||
CompilerBuiltins => No,
|
||||
Confusables { .. } => Yes,
|
||||
ConstContinue(..) => No,
|
||||
ConstStability { .. } => Yes,
|
||||
|
|
|
|||
|
|
@ -741,7 +741,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
|||
externally_implementable_items,
|
||||
proc_macro_data,
|
||||
debugger_visualizers,
|
||||
compiler_builtins: ast::attr::contains_name(attrs, sym::compiler_builtins),
|
||||
compiler_builtins: find_attr!(attrs, AttributeKind::CompilerBuiltins),
|
||||
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),
|
||||
|
|
|
|||
|
|
@ -3562,7 +3562,7 @@ pub fn provide(providers: &mut Providers) {
|
|||
providers.is_panic_runtime =
|
||||
|tcx, LocalCrate| contains_name(tcx.hir_krate_attrs(), sym::panic_runtime);
|
||||
providers.is_compiler_builtins =
|
||||
|tcx, LocalCrate| contains_name(tcx.hir_krate_attrs(), sym::compiler_builtins);
|
||||
|tcx, LocalCrate| find_attr!(tcx.hir_krate_attrs(), AttributeKind::CompilerBuiltins);
|
||||
providers.has_panic_handler = |tcx, LocalCrate| {
|
||||
// We want to check if the panic handler was defined in this crate
|
||||
tcx.lang_items().panic_impl().is_some_and(|did| did.is_local())
|
||||
|
|
|
|||
|
|
@ -299,6 +299,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
|
|||
| AttributeKind::NoCore { .. }
|
||||
| AttributeKind::NoStd { .. }
|
||||
| AttributeKind::NoMain
|
||||
| AttributeKind::CompilerBuiltins
|
||||
| AttributeKind::ObjcClass { .. }
|
||||
| AttributeKind::ObjcSelector { .. }
|
||||
| AttributeKind::RustcCoherenceIsCore(..)
|
||||
|
|
@ -397,10 +398,8 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
|
|||
| sym::rustc_no_implicit_bounds
|
||||
| sym::test_runner
|
||||
| sym::reexport_test_harness_main
|
||||
| sym::no_main
|
||||
| sym::no_builtins
|
||||
| sym::crate_type
|
||||
| sym::compiler_builtins
|
||||
| sym::profiler_runtime
|
||||
| sym::needs_panic_runtime
|
||||
| sym::panic_runtime
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue