Skip to content

Commit 22ae6b0

Browse files
committed
Port rustc_intrinsic_const_stable_indirect to the new attribute parser
1 parent 71ef7ba commit 22ae6b0

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
@@ -506,3 +506,12 @@ impl<S: Stage> NoArgsAttributeParser<S> for RustcIntrinsicParser {
506506
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Fn)]);
507507
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcIntrinsic;
508508
}
509+
510+
pub(crate) struct RustcIntrinsicConstStableIndirectParser;
511+
512+
impl<S: Stage> NoArgsAttributeParser<S> for RustcIntrinsicConstStableIndirectParser {
513+
const PATH: &'static [Symbol] = &[sym::rustc_intrinsic_const_stable_indirect];
514+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
515+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Fn)]);
516+
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcIntrinsicConstStableIndirect;
517+
}

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ attribute_parsers!(
257257
Single<WithoutArgs<RustcHasIncoherentInherentImplsParser>>,
258258
Single<WithoutArgs<RustcHiddenTypeOfOpaquesParser>>,
259259
Single<WithoutArgs<RustcIntrinsicParser>>,
260+
Single<WithoutArgs<RustcIntrinsicConstStableIndirectParser>>,
260261
Single<WithoutArgs<RustcLintOptTyParser>>,
261262
Single<WithoutArgs<RustcLintQueryInstabilityParser>>,
262263
Single<WithoutArgs<RustcLintUntrackedQueryInformationParser>>,

compiler/rustc_hir/src/attrs/data_structures.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,6 +1080,9 @@ pub enum AttributeKind {
10801080
/// Represents `#[rustc_intrinsic]`
10811081
RustcIntrinsic,
10821082

1083+
/// Represents `#[rustc_intrinsic_const_stable_indirect]`
1084+
RustcIntrinsicConstStableIndirect,
1085+
10831086
/// Represents `#[rustc_layout]`
10841087
RustcLayout(ThinVec<RustcLayoutType>),
10851088

compiler/rustc_hir/src/attrs/encode_cross_crate.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ impl AttributeKind {
113113
RustcHasIncoherentInherentImpls => Yes,
114114
RustcHiddenTypeOfOpaques => No,
115115
RustcIntrinsic => Yes,
116+
RustcIntrinsicConstStableIndirect => No,
116117
RustcLayout(..) => No,
117118
RustcLayoutScalarValidRangeEnd(..) => Yes,
118119
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
@@ -308,6 +308,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
308308
| AttributeKind::RustcHasIncoherentInherentImpls
309309
| AttributeKind::RustcHiddenTypeOfOpaques
310310
| AttributeKind::RustcIntrinsic
311+
| AttributeKind::RustcIntrinsicConstStableIndirect
311312
| AttributeKind::RustcLayout(..)
312313
| AttributeKind::RustcLayoutScalarValidRangeEnd(..)
313314
| 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)