Skip to content

Commit 8526aa5

Browse files
committed
Port #[prelude_import] to the attribute parser
1 parent 7ad4e69 commit 8526aa5

5 files changed

Lines changed: 15 additions & 1 deletion

File tree

compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,3 +1211,12 @@ impl<S: Stage> SingleAttributeParser<S> for RustcReservationImplParser {
12111211
Some(AttributeKind::RustcReservationImpl(cx.attr_span, value_str))
12121212
}
12131213
}
1214+
1215+
pub(crate) struct PreludeImportParser;
1216+
1217+
impl<S: Stage> NoArgsAttributeParser<S> for PreludeImportParser {
1218+
const PATH: &[Symbol] = &[sym::prelude_import];
1219+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
1220+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Use)]);
1221+
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::PreludeImport;
1222+
}

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ attribute_parsers!(
258258
Single<WithoutArgs<PassByValueParser>>,
259259
Single<WithoutArgs<PinV2Parser>>,
260260
Single<WithoutArgs<PointeeParser>>,
261+
Single<WithoutArgs<PreludeImportParser>>,
261262
Single<WithoutArgs<ProcMacroAttributeParser>>,
262263
Single<WithoutArgs<ProcMacroParser>>,
263264
Single<WithoutArgs<ProfilerRuntimeParser>>,

compiler/rustc_hir/src/attrs/data_structures.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,6 +1053,9 @@ pub enum AttributeKind {
10531053
/// Represents `#[pointee]`
10541054
Pointee(Span),
10551055

1056+
/// Represents `#[prelude_import]`
1057+
PreludeImport,
1058+
10561059
/// Represents `#[proc_macro]`
10571060
ProcMacro(Span),
10581061

compiler/rustc_hir/src/attrs/encode_cross_crate.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ impl AttributeKind {
8282
PatternComplexityLimit { .. } => No,
8383
PinV2(..) => Yes,
8484
Pointee(..) => No,
85+
PreludeImport => No,
8586
ProcMacro(..) => No,
8687
ProcMacroAttribute(..) => No,
8788
ProcMacroDerive { .. } => No,

compiler/rustc_passes/src/check_attr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
282282
| AttributeKind::PatternComplexityLimit { .. }
283283
| AttributeKind::PinV2(..)
284284
| AttributeKind::Pointee(..)
285+
| AttributeKind::PreludeImport
285286
| AttributeKind::ProfilerRuntime
286287
| AttributeKind::RecursionLimit { .. }
287288
| AttributeKind::ReexportTestHarnessMain(..)
@@ -394,7 +395,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
394395
// need to be fixed
395396
| sym::deprecated_safe // FIXME(deprecated_safe)
396397
// internal
397-
| sym::prelude_import
398398
| sym::panic_handler
399399
| sym::lang
400400
| sym::default_lib_allocator

0 commit comments

Comments
 (0)