Port #[rustc_dump_predicates]

This commit is contained in:
Jonathan Brouwer 2026-01-12 19:54:54 +01:00
parent a4c34b421c
commit abcbf72bab
No known key found for this signature in database
GPG key ID: F13E55D38C971DEF
6 changed files with 24 additions and 3 deletions

View file

@ -34,6 +34,21 @@ impl<S: Stage> NoArgsAttributeParser<S> for RustcDumpItemBounds {
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcDumpItemBounds;
}
pub(crate) struct RustcDumpPredicates;
impl<S: Stage> NoArgsAttributeParser<S> for RustcDumpPredicates {
const PATH: &[Symbol] = &[sym::rustc_dump_predicates];
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
Allow(Target::Struct),
Allow(Target::Enum),
Allow(Target::Union),
Allow(Target::Trait),
Allow(Target::AssocTy),
]);
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcDumpPredicates;
}
pub(crate) struct RustcDumpVtable;
impl<S: Stage> NoArgsAttributeParser<S> for RustcDumpVtable {

View file

@ -64,7 +64,8 @@ use crate::attributes::proc_macro_attrs::{
use crate::attributes::prototype::CustomMirParser;
use crate::attributes::repr::{AlignParser, AlignStaticParser, ReprParser};
use crate::attributes::rustc_dump::{
RustcDumpDefParents, RustcDumpItemBounds, RustcDumpUserArgs, RustcDumpVtable,
RustcDumpDefParents, RustcDumpItemBounds, RustcDumpPredicates, RustcDumpUserArgs,
RustcDumpVtable,
};
use crate::attributes::rustc_internal::{
RustcHasIncoherentInherentImplsParser, RustcLayoutScalarValidRangeEndParser,
@ -272,6 +273,7 @@ attribute_parsers!(
Single<WithoutArgs<RustcCoherenceIsCoreParser>>,
Single<WithoutArgs<RustcDumpDefParents>>,
Single<WithoutArgs<RustcDumpItemBounds>>,
Single<WithoutArgs<RustcDumpPredicates>>,
Single<WithoutArgs<RustcDumpUserArgs>>,
Single<WithoutArgs<RustcDumpVtable>>,
Single<WithoutArgs<RustcHasIncoherentInherentImplsParser>>,

View file

@ -912,6 +912,9 @@ pub enum AttributeKind {
/// Represents `#[rustc_dump_item_bounds]`
RustcDumpItemBounds,
/// Represents `#[rustc_dump_predicates]`
RustcDumpPredicates,
/// Represents `#[rustc_dump_user_args]`
RustcDumpUserArgs,

View file

@ -99,6 +99,7 @@ impl AttributeKind {
RustcCoherenceIsCore(..) => No,
RustcDumpDefParents => No,
RustcDumpItemBounds => No,
RustcDumpPredicates => No,
RustcDumpUserArgs => No,
RustcDumpVtable(..) => No,
RustcHasIncoherentInherentImpls => Yes,

View file

@ -29,7 +29,7 @@ pub(crate) fn opaque_hidden_types(tcx: TyCtxt<'_>) {
pub(crate) fn predicates_and_item_bounds(tcx: TyCtxt<'_>) {
for id in tcx.hir_crate_items(()).owners() {
if tcx.has_attr(id, sym::rustc_dump_predicates) {
if find_attr!(tcx.get_all_attrs(id), AttributeKind::RustcDumpPredicates) {
let preds = tcx.predicates_of(id).instantiate_identity(tcx).predicates;
let span = tcx.def_span(id);

View file

@ -311,6 +311,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
| AttributeKind::MustNotSupend { .. }
| AttributeKind::RustcDumpUserArgs
| AttributeKind::RustcDumpItemBounds
| AttributeKind::RustcDumpPredicates
| AttributeKind::RustcDumpDefParents
| AttributeKind::RustcDumpVtable(..)
) => { /* do nothing */ }
@ -377,7 +378,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
| sym::rustc_capture_analysis
| sym::rustc_regions
| sym::rustc_strict_coherence
| sym::rustc_dump_predicates
| sym::rustc_variance
| sym::rustc_variance_of_opaques
| sym::rustc_hidden_type_of_opaques