Skip to content

Commit 087c014

Browse files
committed
Port rustc_intrinsic_const_stable_indirect to the new attribute parser
1 parent 1d45191 commit 087c014

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 {
@@ -771,3 +772,12 @@ impl<S: Stage> NoArgsAttributeParser<S> for RustcIntrinsicParser {
771772
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Fn)]);
772773
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcIntrinsic;
773774
}
775+
776+
pub(crate) struct RustcIntrinsicConstStableIndirectParser;
777+
778+
impl<S: Stage> NoArgsAttributeParser<S> for RustcIntrinsicConstStableIndirectParser {
779+
const PATH: &'static [Symbol] = &[sym::rustc_intrinsic_const_stable_indirect];
780+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
781+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Fn)]);
782+
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcIntrinsicConstStableIndirect;
783+
}

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ attribute_parsers!(
262262
Single<WithoutArgs<RustcEffectiveVisibilityParser>>,
263263
Single<WithoutArgs<RustcHasIncoherentInherentImplsParser>>,
264264
Single<WithoutArgs<RustcHiddenTypeOfOpaquesParser>>,
265+
Single<WithoutArgs<RustcIntrinsicConstStableIndirectParser>>,
265266
Single<WithoutArgs<RustcIntrinsicParser>>,
266267
Single<WithoutArgs<RustcLintOptTyParser>>,
267268
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
@@ -1120,6 +1120,9 @@ pub enum AttributeKind {
11201120
/// Represents `#[rustc_intrinsic]`
11211121
RustcIntrinsic,
11221122

1123+
/// Represents `#[rustc_intrinsic_const_stable_indirect]`
1124+
RustcIntrinsicConstStableIndirect,
1125+
11231126
/// Represents `#[rustc_layout]`
11241127
RustcLayout(ThinVec<RustcLayoutType>),
11251128

compiler/rustc_hir/src/attrs/encode_cross_crate.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ impl AttributeKind {
118118
RustcHiddenTypeOfOpaques => No,
119119
RustcIfThisChanged(..) => No,
120120
RustcIntrinsic => Yes,
121+
RustcIntrinsicConstStableIndirect => No,
121122
RustcLayout(..) => No,
122123
RustcLayoutScalarValidRangeEnd(..) => Yes,
123124
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
@@ -313,6 +313,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
313313
| AttributeKind::RustcHiddenTypeOfOpaques
314314
| AttributeKind::RustcIfThisChanged(..)
315315
| AttributeKind::RustcIntrinsic
316+
| AttributeKind::RustcIntrinsicConstStableIndirect
316317
| AttributeKind::RustcLayout(..)
317318
| AttributeKind::RustcLayoutScalarValidRangeEnd(..)
318319
| AttributeKind::RustcLayoutScalarValidRangeStart(..)
@@ -385,7 +386,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
385386
| sym::rustc_insignificant_dtor
386387
| sym::rustc_nonnull_optimization_guaranteed
387388
| sym::rustc_inherit_overflow_checks
388-
| sym::rustc_intrinsic_const_stable_indirect
389389
| sym::rustc_trivial_field_reads
390390
| sym::rustc_on_unimplemented
391391
| sym::rustc_do_not_const_check

0 commit comments

Comments
 (0)