Skip to content

Commit 467053f

Browse files
Rollup merge of #151992 - crazazy:main, r=JonathanBrouwer
Port `#[rustc_hidden_type_of_opaque]` to attribute parser
2 parents 22b2913 + 82a530c commit 467053f

File tree

6 files changed

+23
-10
lines changed

6 files changed

+23
-10
lines changed

compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,14 @@ impl<S: Stage> NoArgsAttributeParser<S> for RustcHasIncoherentInherentImplsParse
307307
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcHasIncoherentInherentImpls;
308308
}
309309

310+
pub(crate) struct RustcHiddenTypeOfOpaquesParser;
311+
312+
impl<S: Stage> NoArgsAttributeParser<S> for RustcHiddenTypeOfOpaquesParser {
313+
const PATH: &[Symbol] = &[sym::rustc_hidden_type_of_opaques];
314+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
315+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Crate)]);
316+
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcHiddenTypeOfOpaques;
317+
}
310318
pub(crate) struct RustcNounwindParser;
311319

312320
impl<S: Stage> NoArgsAttributeParser<S> for RustcNounwindParser {

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,14 @@ use crate::attributes::rustc_dump::{
7575
RustcDumpVtable,
7676
};
7777
use crate::attributes::rustc_internal::{
78-
RustcHasIncoherentInherentImplsParser, RustcLayoutParser, RustcLayoutScalarValidRangeEndParser,
79-
RustcLayoutScalarValidRangeStartParser, RustcLegacyConstGenericsParser,
80-
RustcLintOptDenyFieldAccessParser, RustcLintOptTyParser, RustcLintQueryInstabilityParser,
81-
RustcLintUntrackedQueryInformationParser, RustcMainParser, RustcMustImplementOneOfParser,
82-
RustcNeverReturnsNullPointerParser, RustcNoImplicitAutorefsParser,
83-
RustcNonConstTraitMethodParser, RustcNounwindParser, RustcObjectLifetimeDefaultParser,
84-
RustcOffloadKernelParser, RustcScalableVectorParser, RustcSimdMonomorphizeLaneLimitParser,
78+
RustcHasIncoherentInherentImplsParser, RustcHiddenTypeOfOpaquesParser, RustcLayoutParser,
79+
RustcLayoutScalarValidRangeEndParser, RustcLayoutScalarValidRangeStartParser,
80+
RustcLegacyConstGenericsParser, RustcLintOptDenyFieldAccessParser, RustcLintOptTyParser,
81+
RustcLintQueryInstabilityParser, RustcLintUntrackedQueryInformationParser, RustcMainParser,
82+
RustcMustImplementOneOfParser, RustcNeverReturnsNullPointerParser,
83+
RustcNoImplicitAutorefsParser, RustcNonConstTraitMethodParser, RustcNounwindParser,
84+
RustcObjectLifetimeDefaultParser, RustcOffloadKernelParser, RustcScalableVectorParser,
85+
RustcSimdMonomorphizeLaneLimitParser,
8586
};
8687
use crate::attributes::semantics::MayDangleParser;
8788
use crate::attributes::stability::{
@@ -299,6 +300,7 @@ attribute_parsers!(
299300
Single<WithoutArgs<RustcDumpUserArgs>>,
300301
Single<WithoutArgs<RustcDumpVtable>>,
301302
Single<WithoutArgs<RustcHasIncoherentInherentImplsParser>>,
303+
Single<WithoutArgs<RustcHiddenTypeOfOpaquesParser>>,
302304
Single<WithoutArgs<RustcLintOptTyParser>>,
303305
Single<WithoutArgs<RustcLintQueryInstabilityParser>>,
304306
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
@@ -1057,6 +1057,9 @@ pub enum AttributeKind {
10571057
/// Represents `#[rustc_has_incoherent_inherent_impls]`
10581058
RustcHasIncoherentInherentImpls,
10591059

1060+
/// Represents `#[rustc_hidden_type_of_opaques]`
1061+
RustcHiddenTypeOfOpaques,
1062+
10601063
/// Represents `#[rustc_layout]`
10611064
RustcLayout(ThinVec<RustcLayoutType>),
10621065

compiler/rustc_hir/src/attrs/encode_cross_crate.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ impl AttributeKind {
111111
RustcDumpVtable(..) => No,
112112
RustcDynIncompatibleTrait(..) => No,
113113
RustcHasIncoherentInherentImpls => Yes,
114+
RustcHiddenTypeOfOpaques => No,
114115
RustcLayout(..) => No,
115116
RustcLayoutScalarValidRangeEnd(..) => Yes,
116117
RustcLayoutScalarValidRangeStart(..) => Yes,

compiler/rustc_hir_analysis/src/collect/dump.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ use rustc_middle::ty::{self, TyCtxt, TypeVisitableExt};
77
use rustc_span::sym;
88

99
pub(crate) fn opaque_hidden_types(tcx: TyCtxt<'_>) {
10-
if !tcx.has_attr(CRATE_DEF_ID, sym::rustc_hidden_type_of_opaques) {
10+
if !find_attr!(tcx.get_all_attrs(CRATE_DEF_ID), AttributeKind::RustcHiddenTypeOfOpaques) {
1111
return;
1212
}
13-
1413
for id in tcx.hir_crate_items(()).opaques() {
1514
if let hir::OpaqueTyOrigin::FnReturn { parent: fn_def_id, .. }
1615
| hir::OpaqueTyOrigin::AsyncFn { parent: fn_def_id, .. } =

compiler/rustc_passes/src/check_attr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
299299
| AttributeKind::RustcDumpVtable(..)
300300
| AttributeKind::RustcDynIncompatibleTrait(..)
301301
| AttributeKind::RustcHasIncoherentInherentImpls
302+
| AttributeKind::RustcHiddenTypeOfOpaques
302303
| AttributeKind::RustcLayout(..)
303304
| AttributeKind::RustcLayoutScalarValidRangeEnd(..)
304305
| AttributeKind::RustcLayoutScalarValidRangeStart(..)
@@ -390,7 +391,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
390391
| sym::rustc_capture_analysis
391392
| sym::rustc_regions
392393
| sym::rustc_strict_coherence
393-
| sym::rustc_hidden_type_of_opaques
394394
| sym::rustc_mir
395395
| sym::rustc_effective_visibility
396396
| sym::rustc_outlives

0 commit comments

Comments
 (0)