rustc_hir_analysis/outlives/
dump.rs1use rustc_hir::find_attr;
2use rustc_middle::bug;
3use rustc_middle::ty::{self, TyCtxt};
4use rustc_span::sym;
5
6pub(crate) fn inferred_outlives(tcx: TyCtxt<'_>) {
7 for id in tcx.hir_free_items() {
8 if !{
#[allow(deprecated)]
{
{
'done:
{
for i in tcx.get_all_attrs(id.owner_id) {
#[allow(unused_imports)]
use rustc_hir::attrs::AttributeKind::*;
let i: &rustc_hir::Attribute = i;
match i {
rustc_hir::Attribute::Parsed(RustcOutlives) => {
break 'done Some(());
}
rustc_hir::Attribute::Unparsed(..) =>
{}
#[deny(unreachable_patterns)]
_ => {}
}
}
None
}
}
}
}.is_some()find_attr!(tcx, id.owner_id, RustcOutlives) {
9 continue;
10 }
11
12 let preds = tcx.inferred_outlives_of(id.owner_id);
13 let mut preds: Vec<_> = preds
14 .iter()
15 .map(|(pred, _)| match pred.kind().skip_binder() {
16 ty::ClauseKind::RegionOutlives(p) => p.to_string(),
17 ty::ClauseKind::TypeOutlives(p) => p.to_string(),
18 err => ::rustc_middle::util::bug::bug_fmt(format_args!("unexpected clause {0:?}",
err))bug!("unexpected clause {:?}", err),
19 })
20 .collect();
21 preds.sort();
22
23 let span = tcx.def_span(id.owner_id);
24 let mut err = tcx.dcx().struct_span_err(span, sym::rustc_outlives.as_str());
25 for pred in preds {
26 err.note(pred);
27 }
28 err.emit();
29 }
30}