Skip to content

Commit dfbaf7e

Browse files
committed
port #[rustc_coherence_is_core] to the new attribute parsing infrastructure
1 parent f3fd3ef commit dfbaf7e

File tree

7 files changed

+21
-20
lines changed

7 files changed

+21
-20
lines changed

compiler/rustc_attr_parsing/src/attributes/crate_level.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,12 @@ impl<S: Stage> NoArgsAttributeParser<S> for NoStdParser {
174174
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::CrateLevel;
175175
const CREATE: fn(Span) -> AttributeKind = AttributeKind::NoStd;
176176
}
177+
178+
pub(crate) struct RustcCoherenceIsCoreParser;
179+
180+
impl<S: Stage> NoArgsAttributeParser<S> for RustcCoherenceIsCoreParser {
181+
const PATH: &[Symbol] = &[sym::rustc_coherence_is_core];
182+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
183+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::CrateLevel;
184+
const CREATE: fn(Span) -> AttributeKind = AttributeKind::RustcCoherenceIsCore;
185+
}

compiler/rustc_attr_parsing/src/attributes/traits.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,14 +149,6 @@ impl<S: Stage> NoArgsAttributeParser<S> for AllowIncoherentImplParser {
149149
const CREATE: fn(Span) -> AttributeKind = AttributeKind::AllowIncoherentImpl;
150150
}
151151

152-
pub(crate) struct CoherenceIsCoreParser;
153-
impl<S: Stage> NoArgsAttributeParser<S> for CoherenceIsCoreParser {
154-
const PATH: &[Symbol] = &[sym::rustc_coherence_is_core];
155-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
156-
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::CrateLevel;
157-
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::CoherenceIsCore;
158-
}
159-
160152
pub(crate) struct FundamentalParser;
161153
impl<S: Stage> NoArgsAttributeParser<S> for FundamentalParser {
162154
const PATH: &[Symbol] = &[sym::fundamental];

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use crate::attributes::codegen_attrs::{
2626
use crate::attributes::confusables::ConfusablesParser;
2727
use crate::attributes::crate_level::{
2828
CrateNameParser, MoveSizeLimitParser, NoCoreParser, NoStdParser, PatternComplexityLimitParser,
29-
RecursionLimitParser, TypeLengthLimitParser,
29+
RecursionLimitParser, RustcCoherenceIsCoreParser, TypeLengthLimitParser,
3030
};
3131
use crate::attributes::deprecation::DeprecationParser;
3232
use crate::attributes::dummy::DummyParser;
@@ -61,10 +61,10 @@ use crate::attributes::stability::{
6161
};
6262
use crate::attributes::test_attrs::{IgnoreParser, ShouldPanicParser};
6363
use crate::attributes::traits::{
64-
AllowIncoherentImplParser, CoherenceIsCoreParser, CoinductiveParser, ConstTraitParser,
65-
DenyExplicitImplParser, DoNotImplementViaObjectParser, FundamentalParser, MarkerParser,
66-
ParenSugarParser, PointeeParser, SkipDuringMethodDispatchParser, SpecializationTraitParser,
67-
TypeConstParser, UnsafeSpecializationMarkerParser,
64+
AllowIncoherentImplParser, CoinductiveParser, ConstTraitParser, DenyExplicitImplParser,
65+
DoNotImplementViaObjectParser, FundamentalParser, MarkerParser, ParenSugarParser,
66+
PointeeParser, SkipDuringMethodDispatchParser, SpecializationTraitParser, TypeConstParser,
67+
UnsafeSpecializationMarkerParser,
6868
};
6969
use crate::attributes::transparency::TransparencyParser;
7070
use crate::attributes::{AttributeParser as _, Combine, Single, WithoutArgs};
@@ -204,7 +204,6 @@ attribute_parsers!(
204204
Single<WithoutArgs<AllowInternalUnsafeParser>>,
205205
Single<WithoutArgs<AsPtrParser>>,
206206
Single<WithoutArgs<AutomaticallyDerivedParser>>,
207-
Single<WithoutArgs<CoherenceIsCoreParser>>,
208207
Single<WithoutArgs<CoinductiveParser>>,
209208
Single<WithoutArgs<ColdParser>>,
210209
Single<WithoutArgs<ConstContinueParser>>,
@@ -232,6 +231,7 @@ attribute_parsers!(
232231
Single<WithoutArgs<ProcMacroAttributeParser>>,
233232
Single<WithoutArgs<ProcMacroParser>>,
234233
Single<WithoutArgs<PubTransparentParser>>,
234+
Single<WithoutArgs<RustcCoherenceIsCoreParser>>,
235235
Single<WithoutArgs<SpecializationTraitParser>>,
236236
Single<WithoutArgs<StdInternalSymbolParser>>,
237237
Single<WithoutArgs<TrackCallerParser>>,

compiler/rustc_hir/src/attrs/data_structures.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -444,9 +444,6 @@ pub enum AttributeKind {
444444
span: Span,
445445
},
446446

447-
/// Represents `#[rustc_coherence_is_core]`.
448-
CoherenceIsCore,
449-
450447
/// Represents `#[rustc_coinductive]`.
451448
Coinductive(Span),
452449

@@ -633,6 +630,9 @@ pub enum AttributeKind {
633630
/// Represents `#[rustc_builtin_macro]`.
634631
RustcBuiltinMacro { builtin_name: Option<Symbol>, helper_attrs: ThinVec<Symbol>, span: Span },
635632

633+
/// Represents `#[rustc_coherence_is_core]`
634+
RustcCoherenceIsCore(Span),
635+
636636
/// Represents `#[rustc_layout_scalar_valid_range_end]`.
637637
RustcLayoutScalarValidRangeEnd(Box<u128>, Span),
638638

compiler/rustc_hir/src/attrs/encode_cross_crate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ impl AttributeKind {
2626
AsPtr(..) => Yes,
2727
AutomaticallyDerived(..) => Yes,
2828
BodyStability { .. } => No,
29-
CoherenceIsCore => No,
3029
Coinductive(..) => No,
3130
Cold(..) => No,
3231
Confusables { .. } => Yes,
@@ -82,6 +81,7 @@ impl AttributeKind {
8281
RecursionLimit { .. } => No,
8382
Repr { .. } => No,
8483
RustcBuiltinMacro { .. } => Yes,
84+
RustcCoherenceIsCore(..) => No,
8585
RustcLayoutScalarValidRangeEnd(..) => Yes,
8686
RustcLayoutScalarValidRangeStart(..) => Yes,
8787
RustcObjectLifetimeDefault => No,

compiler/rustc_middle/src/hir/map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ impl<'tcx> TyCtxt<'tcx> {
370370
}
371371

372372
pub fn hir_rustc_coherence_is_core(self) -> bool {
373-
find_attr!(self.hir_krate_attrs(), AttributeKind::CoherenceIsCore)
373+
find_attr!(self.hir_krate_attrs(), AttributeKind::RustcCoherenceIsCore(..))
374374
}
375375

376376
pub fn hir_get_module(self, module: LocalModDefId) -> (&'tcx Mod<'tcx>, Span, HirId) {

compiler/rustc_passes/src/check_attr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
246246
| AttributeKind::Repr { .. }
247247
| AttributeKind::Cold(..)
248248
| AttributeKind::ExportName { .. }
249-
| AttributeKind::CoherenceIsCore
250249
| AttributeKind::Fundamental
251250
| AttributeKind::Optimize(..)
252251
| AttributeKind::LinkSection { .. }
@@ -276,6 +275,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
276275
| AttributeKind::PatternComplexityLimit { .. }
277276
| AttributeKind::NoCore { .. }
278277
| AttributeKind::NoStd { .. }
278+
| AttributeKind::RustcCoherenceIsCore(..)
279279
) => { /* do nothing */ }
280280
Attribute::Unparsed(attr_item) => {
281281
style = Some(attr_item.style);

0 commit comments

Comments
 (0)