Skip to content

Commit be8c29c

Browse files
authored
Rollup merge of #146647 - jdonszelmann:move-coherence-is-core, r=urgau
Move `#[rustc_coherence_is_core]` to the `crate_level` file I implemented this one without realizing it already was since it was (in my opinion) in the wrong file and implemented in a batch of all non-crate-level attributes. This commit just cleans it up slightly and moves it. Should be trivial r? `@oli-obk`
2 parents 9303a92 + 205189c commit be8c29c

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};
@@ -206,7 +206,6 @@ attribute_parsers!(
206206
Single<WithoutArgs<AllowInternalUnsafeParser>>,
207207
Single<WithoutArgs<AsPtrParser>>,
208208
Single<WithoutArgs<AutomaticallyDerivedParser>>,
209-
Single<WithoutArgs<CoherenceIsCoreParser>>,
210209
Single<WithoutArgs<CoinductiveParser>>,
211210
Single<WithoutArgs<ColdParser>>,
212211
Single<WithoutArgs<ConstContinueParser>>,
@@ -234,6 +233,7 @@ attribute_parsers!(
234233
Single<WithoutArgs<ProcMacroAttributeParser>>,
235234
Single<WithoutArgs<ProcMacroParser>>,
236235
Single<WithoutArgs<PubTransparentParser>>,
236+
Single<WithoutArgs<RustcCoherenceIsCoreParser>>,
237237
Single<WithoutArgs<SpecializationTraitParser>>,
238238
Single<WithoutArgs<StdInternalSymbolParser>>,
239239
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

@@ -639,6 +636,9 @@ pub enum AttributeKind {
639636
/// Represents `#[rustc_builtin_macro]`.
640637
RustcBuiltinMacro { builtin_name: Option<Symbol>, helper_attrs: ThinVec<Symbol>, span: Span },
641638

639+
/// Represents `#[rustc_coherence_is_core]`
640+
RustcCoherenceIsCore(Span),
641+
642642
/// Represents `#[rustc_layout_scalar_valid_range_end]`.
643643
RustcLayoutScalarValidRangeEnd(Box<u128>, Span),
644644

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,
@@ -84,6 +83,7 @@ impl AttributeKind {
8483
RecursionLimit { .. } => No,
8584
Repr { .. } => No,
8685
RustcBuiltinMacro { .. } => Yes,
86+
RustcCoherenceIsCore(..) => No,
8787
RustcLayoutScalarValidRangeEnd(..) => Yes,
8888
RustcLayoutScalarValidRangeStart(..) => Yes,
8989
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 { .. }
@@ -278,6 +277,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
278277
| AttributeKind::NoStd { .. }
279278
| AttributeKind::ObjcClass { .. }
280279
| AttributeKind::ObjcSelector { .. }
280+
| AttributeKind::RustcCoherenceIsCore(..)
281281
) => { /* do nothing */ }
282282
Attribute::Unparsed(attr_item) => {
283283
style = Some(attr_item.style);

0 commit comments

Comments
 (0)