Skip to content

Commit c42a581

Browse files
committed
Port rustc_intrinsic_const_stable_indirect to the new attribute parser
1 parent 9249e9f commit c42a581

6 files changed

Lines changed: 20 additions & 2 deletions

File tree

compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,7 @@ impl<S: Stage> CombineAttributeParser<S> for RustcMirParser {
490490
.collect()
491491
}
492492
}
493+
493494
pub(crate) struct RustcNonConstTraitMethodParser;
494495

495496
impl<S: Stage> NoArgsAttributeParser<S> for RustcNonConstTraitMethodParser {
@@ -819,3 +820,12 @@ impl<S: Stage> NoArgsAttributeParser<S> for RustcIntrinsicParser {
819820
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Fn)]);
820821
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcIntrinsic;
821822
}
823+
824+
pub(crate) struct RustcIntrinsicConstStableIndirectParser;
825+
826+
impl<S: Stage> NoArgsAttributeParser<S> for RustcIntrinsicConstStableIndirectParser {
827+
const PATH: &'static [Symbol] = &[sym::rustc_intrinsic_const_stable_indirect];
828+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
829+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Fn)]);
830+
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcIntrinsicConstStableIndirect;
831+
}

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ attribute_parsers!(
264264
Single<WithoutArgs<RustcEffectiveVisibilityParser>>,
265265
Single<WithoutArgs<RustcHasIncoherentInherentImplsParser>>,
266266
Single<WithoutArgs<RustcHiddenTypeOfOpaquesParser>>,
267+
Single<WithoutArgs<RustcIntrinsicConstStableIndirectParser>>,
267268
Single<WithoutArgs<RustcIntrinsicParser>>,
268269
Single<WithoutArgs<RustcLintOptTyParser>>,
269270
Single<WithoutArgs<RustcLintQueryInstabilityParser>>,

compiler/rustc_hir/src/attrs/data_structures.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,6 +1123,9 @@ pub enum AttributeKind {
11231123
/// Represents `#[rustc_intrinsic]`
11241124
RustcIntrinsic,
11251125

1126+
/// Represents `#[rustc_intrinsic_const_stable_indirect]`
1127+
RustcIntrinsicConstStableIndirect,
1128+
11261129
/// Represents `#[rustc_layout]`
11271130
RustcLayout(ThinVec<RustcLayoutType>),
11281131

compiler/rustc_hir/src/attrs/encode_cross_crate.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ impl AttributeKind {
119119
RustcHiddenTypeOfOpaques => No,
120120
RustcIfThisChanged(..) => No,
121121
RustcIntrinsic => Yes,
122+
RustcIntrinsicConstStableIndirect => No,
122123
RustcLayout(..) => No,
123124
RustcLayoutScalarValidRangeEnd(..) => Yes,
124125
RustcLayoutScalarValidRangeStart(..) => Yes,

compiler/rustc_middle/src/ty/util.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1691,7 +1691,10 @@ pub fn intrinsic_raw(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<ty::Intrinsi
16911691
Some(ty::IntrinsicDef {
16921692
name: tcx.item_name(def_id),
16931693
must_be_overridden,
1694-
const_stable: tcx.has_attr(def_id, sym::rustc_intrinsic_const_stable_indirect),
1694+
const_stable: find_attr!(
1695+
tcx.get_all_attrs(def_id),
1696+
AttributeKind::RustcIntrinsicConstStableIndirect
1697+
),
16951698
})
16961699
} else {
16971700
None

compiler/rustc_passes/src/check_attr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
314314
| AttributeKind::RustcHiddenTypeOfOpaques
315315
| AttributeKind::RustcIfThisChanged(..)
316316
| AttributeKind::RustcIntrinsic
317+
| AttributeKind::RustcIntrinsicConstStableIndirect
317318
| AttributeKind::RustcLayout(..)
318319
| AttributeKind::RustcLayoutScalarValidRangeEnd(..)
319320
| AttributeKind::RustcLayoutScalarValidRangeStart(..)
@@ -387,7 +388,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
387388
| sym::rustc_insignificant_dtor
388389
| sym::rustc_nonnull_optimization_guaranteed
389390
| sym::rustc_inherit_overflow_checks
390-
| sym::rustc_intrinsic_const_stable_indirect
391391
| sym::rustc_trivial_field_reads
392392
| sym::rustc_on_unimplemented
393393
| sym::rustc_do_not_const_check

0 commit comments

Comments
 (0)