Port #[prelude_import] to the attribute parser

This commit is contained in:
Oscar Bray 2026-02-12 17:43:04 +00:00
parent 7ad4e69ad5
commit 8526aa5361
5 changed files with 15 additions and 1 deletions

View file

@ -1211,3 +1211,12 @@ impl<S: Stage> SingleAttributeParser<S> for RustcReservationImplParser {
Some(AttributeKind::RustcReservationImpl(cx.attr_span, value_str))
}
}
pub(crate) struct PreludeImportParser;
impl<S: Stage> NoArgsAttributeParser<S> for PreludeImportParser {
const PATH: &[Symbol] = &[sym::prelude_import];
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Use)]);
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::PreludeImport;
}

View file

@ -258,6 +258,7 @@ attribute_parsers!(
Single<WithoutArgs<PassByValueParser>>,
Single<WithoutArgs<PinV2Parser>>,
Single<WithoutArgs<PointeeParser>>,
Single<WithoutArgs<PreludeImportParser>>,
Single<WithoutArgs<ProcMacroAttributeParser>>,
Single<WithoutArgs<ProcMacroParser>>,
Single<WithoutArgs<ProfilerRuntimeParser>>,

View file

@ -1053,6 +1053,9 @@ pub enum AttributeKind {
/// Represents `#[pointee]`
Pointee(Span),
/// Represents `#[prelude_import]`
PreludeImport,
/// Represents `#[proc_macro]`
ProcMacro(Span),

View file

@ -82,6 +82,7 @@ impl AttributeKind {
PatternComplexityLimit { .. } => No,
PinV2(..) => Yes,
Pointee(..) => No,
PreludeImport => No,
ProcMacro(..) => No,
ProcMacroAttribute(..) => No,
ProcMacroDerive { .. } => No,

View file

@ -282,6 +282,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
| AttributeKind::PatternComplexityLimit { .. }
| AttributeKind::PinV2(..)
| AttributeKind::Pointee(..)
| AttributeKind::PreludeImport
| AttributeKind::ProfilerRuntime
| AttributeKind::RecursionLimit { .. }
| AttributeKind::ReexportTestHarnessMain(..)
@ -394,7 +395,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
// need to be fixed
| sym::deprecated_safe // FIXME(deprecated_safe)
// internal
| sym::prelude_import
| sym::panic_handler
| sym::lang
| sym::default_lib_allocator