Port #[rustc_dump_item_bounds]

This commit is contained in:
Jonathan Brouwer 2026-01-12 19:47:18 +01:00
parent cf4d480eff
commit 2a455409e3
No known key found for this signature in database
GPG key ID: F13E55D38C971DEF
6 changed files with 20 additions and 6 deletions

View file

@ -24,3 +24,12 @@ impl<S: Stage> NoArgsAttributeParser<S> for RustcDumpDefParents {
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Fn)]);
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcDumpDefParents;
}
pub(crate) struct RustcDumpItemBounds;
impl<S: Stage> NoArgsAttributeParser<S> for RustcDumpItemBounds {
const PATH: &[Symbol] = &[sym::rustc_dump_item_bounds];
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::AssocTy)]);
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcDumpItemBounds;
}

View file

@ -63,7 +63,7 @@ use crate::attributes::proc_macro_attrs::{
};
use crate::attributes::prototype::CustomMirParser;
use crate::attributes::repr::{AlignParser, AlignStaticParser, ReprParser};
use crate::attributes::rustc_dump::{RustcDumpUserArgs, RustcDumpDefParents};
use crate::attributes::rustc_dump::{RustcDumpDefParents, RustcDumpItemBounds, RustcDumpUserArgs};
use crate::attributes::rustc_internal::{
RustcHasIncoherentInherentImplsParser, RustcLayoutScalarValidRangeEndParser,
RustcLayoutScalarValidRangeStartParser, RustcLegacyConstGenericsParser,
@ -268,7 +268,8 @@ attribute_parsers!(
Single<WithoutArgs<ProcMacroParser>>,
Single<WithoutArgs<PubTransparentParser>>,
Single<WithoutArgs<RustcCoherenceIsCoreParser>>,
Single<WithoutArgs<RustcDumpDefParents >>,
Single<WithoutArgs<RustcDumpDefParents>>,
Single<WithoutArgs<RustcDumpItemBounds>>,
Single<WithoutArgs<RustcDumpUserArgs>>,
Single<WithoutArgs<RustcHasIncoherentInherentImplsParser>>,
Single<WithoutArgs<RustcLintDiagnosticsParser>>,

View file

@ -908,7 +908,10 @@ pub enum AttributeKind {
/// Represents `#[rustc_dump_def_parents]`
RustcDumpDefParents,
/// Represents `#[rustc_dump_item_bounds]`
RustcDumpItemBounds,
/// Represents `#[rustc_dump_user_args]`
RustcDumpUserArgs,

View file

@ -98,6 +98,7 @@ impl AttributeKind {
RustcBuiltinMacro { .. } => Yes,
RustcCoherenceIsCore(..) => No,
RustcDumpDefParents => No,
RustcDumpItemBounds => No,
RustcDumpUserArgs => No,
RustcHasIncoherentInherentImpls => Yes,
RustcLayoutScalarValidRangeEnd(..) => Yes,

View file

@ -1,7 +1,7 @@
use rustc_hir as hir;
use rustc_hir::attrs::AttributeKind;
use rustc_hir::def_id::{CRATE_DEF_ID, LocalDefId};
use rustc_hir::{find_attr, intravisit};
use rustc_hir::attrs::AttributeKind;
use rustc_middle::hir::nested_filter;
use rustc_middle::ty::{self, TyCtxt, TypeVisitableExt};
use rustc_span::sym;
@ -39,7 +39,7 @@ pub(crate) fn predicates_and_item_bounds(tcx: TyCtxt<'_>) {
}
diag.emit();
}
if tcx.has_attr(id, sym::rustc_dump_item_bounds) {
if find_attr!(tcx.get_all_attrs(id), AttributeKind::RustcDumpItemBounds) {
let bounds = tcx.item_bounds(id).instantiate_identity();
let span = tcx.def_span(id);

View file

@ -310,6 +310,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
| AttributeKind::RustcHasIncoherentInherentImpls
| AttributeKind::MustNotSupend { .. }
| AttributeKind::RustcDumpUserArgs
| AttributeKind::RustcDumpItemBounds
| AttributeKind::RustcDumpDefParents
) => { /* do nothing */ }
Attribute::Unparsed(attr_item) => {
@ -386,7 +387,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
| sym::rustc_evaluate_where_clauses
| sym::rustc_dump_vtable
| sym::rustc_delayed_bug_from_inside_query
| sym::rustc_dump_item_bounds
| sym::rustc_def_path
| sym::rustc_partition_reused
| sym::rustc_partition_codegened