1
Fork 0

Add #[rustc_dump_{predicates,item_bounds}]

This commit is contained in:
León Orell Valerian Liehr 2024-06-19 14:24:25 +02:00
parent bc12972bcd
commit 38bd7a0fcb
No known key found for this signature in database
GPG key ID: D17A07215F68E713
6 changed files with 95 additions and 0 deletions

View file

@ -16,3 +16,28 @@ pub(crate) fn opaque_hidden_types(tcx: TyCtxt<'_>) {
tcx.dcx().emit_err(crate::errors::TypeOf { span: tcx.def_span(id.owner_id), ty });
}
}
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) {
let preds = tcx.predicates_of(id).instantiate_identity(tcx).predicates;
let span = tcx.def_span(id);
let mut diag = tcx.dcx().struct_span_err(span, sym::rustc_dump_predicates.as_str());
for pred in preds {
diag.note(format!("{pred:?}"));
}
diag.emit();
}
if tcx.has_attr(id, sym::rustc_dump_item_bounds) {
let bounds = tcx.item_bounds(id).instantiate_identity();
let span = tcx.def_span(id);
let mut diag = tcx.dcx().struct_span_err(span, sym::rustc_dump_item_bounds.as_str());
for bound in bounds {
diag.note(format!("{bound:?}"));
}
diag.emit();
}
}
}

View file

@ -168,6 +168,7 @@ pub fn check_crate(tcx: TyCtxt<'_>) {
tcx.sess.time("outlives_dumping", || outlives::dump::inferred_outlives(tcx));
tcx.sess.time("variance_dumping", || variance::dump::variances(tcx));
collect::dump::opaque_hidden_types(tcx);
collect::dump::predicates_and_item_bounds(tcx);
}
// Make sure we evaluate all static and (non-associated) const items, even if unused.