Skip to content

Commit 37e8d50

Browse files
committed
Port rustc_intrinsic_const_stable_indirect to the new attribute parser
1 parent bc4c68f commit 37e8d50

6 files changed

Lines changed: 19 additions & 2 deletions

File tree

compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -730,3 +730,12 @@ impl<S: Stage> NoArgsAttributeParser<S> for RustcIntrinsicParser {
730730
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Fn)]);
731731
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcIntrinsic;
732732
}
733+
734+
pub(crate) struct RustcIntrinsicConstStableIndirectParser;
735+
736+
impl<S: Stage> NoArgsAttributeParser<S> for RustcIntrinsicConstStableIndirectParser {
737+
const PATH: &'static [Symbol] = &[sym::rustc_intrinsic_const_stable_indirect];
738+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
739+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Fn)]);
740+
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcIntrinsicConstStableIndirect;
741+
}

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ attribute_parsers!(
260260
Single<WithoutArgs<RustcDumpVtableParser>>,
261261
Single<WithoutArgs<RustcHasIncoherentInherentImplsParser>>,
262262
Single<WithoutArgs<RustcHiddenTypeOfOpaquesParser>>,
263+
Single<WithoutArgs<RustcIntrinsicConstStableIndirectParser>>,
263264
Single<WithoutArgs<RustcIntrinsicParser>>,
264265
Single<WithoutArgs<RustcLintOptTyParser>>,
265266
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
@@ -1106,6 +1106,9 @@ pub enum AttributeKind {
11061106
/// Represents `#[rustc_intrinsic]`
11071107
RustcIntrinsic,
11081108

1109+
/// Represents `#[rustc_intrinsic_const_stable_indirect]`
1110+
RustcIntrinsicConstStableIndirect,
1111+
11091112
/// Represents `#[rustc_layout]`
11101113
RustcLayout(ThinVec<RustcLayoutType>),
11111114

compiler/rustc_hir/src/attrs/encode_cross_crate.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ impl AttributeKind {
116116
RustcHiddenTypeOfOpaques => No,
117117
RustcIfThisChanged(..) => No,
118118
RustcIntrinsic => Yes,
119+
RustcIntrinsicConstStableIndirect => No,
119120
RustcLayout(..) => No,
120121
RustcLayoutScalarValidRangeEnd(..) => Yes,
121122
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
@@ -311,6 +311,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
311311
| AttributeKind::RustcHiddenTypeOfOpaques
312312
| AttributeKind::RustcIfThisChanged(..)
313313
| AttributeKind::RustcIntrinsic
314+
| AttributeKind::RustcIntrinsicConstStableIndirect
314315
| AttributeKind::RustcLayout(..)
315316
| AttributeKind::RustcLayoutScalarValidRangeEnd(..)
316317
| AttributeKind::RustcLayoutScalarValidRangeStart(..)
@@ -383,7 +384,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
383384
| sym::rustc_insignificant_dtor
384385
| sym::rustc_nonnull_optimization_guaranteed
385386
| sym::rustc_inherit_overflow_checks
386-
| sym::rustc_intrinsic_const_stable_indirect
387387
| sym::rustc_trivial_field_reads
388388
| sym::rustc_on_unimplemented
389389
| sym::rustc_do_not_const_check

0 commit comments

Comments
 (0)