Skip to content

Commit b262cae

Browse files
committed
port #[no_core] to the new attribute parsing infrastructure
1 parent 7ad23f4 commit b262cae

File tree

5 files changed

+20
-2
lines changed

5 files changed

+20
-2
lines changed

compiler/rustc_attr_parsing/src/attributes/crate_level.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,3 +176,15 @@ impl<S: Stage> SingleAttributeParser<S> for PatternComplexityLimitParser {
176176
})
177177
}
178178
}
179+
180+
pub(crate) struct NoCoreParser;
181+
182+
impl<S: Stage> NoArgsAttributeParser<S> for NoCoreParser {
183+
const PATH: &[Symbol] = &[sym::no_core];
184+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
185+
// FIXME: recursion limit is allowed on all targets and ignored,
186+
// even though it should only be valid on crates of course
187+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(ALL_TARGETS);
188+
const CREATE: fn(Span) -> AttributeKind = AttributeKind::NoCore;
189+
const TYPE: AttributeType = AttributeType::CrateLevel;
190+
}

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ use crate::attributes::codegen_attrs::{
2525
};
2626
use crate::attributes::confusables::ConfusablesParser;
2727
use crate::attributes::crate_level::{
28-
CrateNameParser, MoveSizeLimitParser, PatternComplexityLimitParser, RecursionLimitParser,
29-
TypeLengthLimitParser,
28+
CrateNameParser, MoveSizeLimitParser, NoCoreParser, PatternComplexityLimitParser,
29+
RecursionLimitParser, TypeLengthLimitParser,
3030
};
3131
use crate::attributes::deprecation::DeprecationParser;
3232
use crate::attributes::dummy::DummyParser;
@@ -222,6 +222,7 @@ attribute_parsers!(
222222
Single<WithoutArgs<MacroEscapeParser>>,
223223
Single<WithoutArgs<MarkerParser>>,
224224
Single<WithoutArgs<MayDangleParser>>,
225+
Single<WithoutArgs<NoCoreParser>>,
225226
Single<WithoutArgs<NoImplicitPreludeParser>>,
226227
Single<WithoutArgs<NoMangleParser>>,
227228
Single<WithoutArgs<NonExhaustiveParser>>,

compiler/rustc_hir/src/attrs/data_structures.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,9 @@ pub enum AttributeKind {
579579
/// Represents `#[naked]`
580580
Naked(Span),
581581

582+
/// Represents `#[no_core]`
583+
NoCore(Span),
584+
582585
/// Represents `#[no_implicit_prelude]`
583586
NoImplicitPrelude(Span),
584587

compiler/rustc_hir/src/attrs/encode_cross_crate.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ impl AttributeKind {
6464
MoveSizeLimit { .. } => No,
6565
MustUse { .. } => Yes,
6666
Naked(..) => No,
67+
NoCore(..) => No,
6768
NoImplicitPrelude(..) => No,
6869
NoMangle(..) => Yes, // Needed for rustdoc
6970
NonExhaustive(..) => Yes, // Needed for rustdoc

compiler/rustc_passes/src/check_attr.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
274274
| AttributeKind::MoveSizeLimit { .. }
275275
| AttributeKind::TypeLengthLimit { .. }
276276
| AttributeKind::PatternComplexityLimit { .. }
277+
| AttributeKind::NoCore { .. }
277278
) => { /* do nothing */ }
278279
Attribute::Unparsed(attr_item) => {
279280
style = Some(attr_item.style);

0 commit comments

Comments
 (0)