rustc_hir_analysis/outlives/
dump.rs

1use rustc_middle::bug;
2use rustc_middle::ty::{self, TyCtxt};
3use rustc_span::sym;
4
5pub(crate) fn inferred_outlives(tcx: TyCtxt<'_>) {
6    for id in tcx.hir().items() {
7        if !tcx.has_attr(id.owner_id, sym::rustc_outlives) {
8            continue;
9        }
10
11        let preds = tcx.inferred_outlives_of(id.owner_id);
12        let mut preds: Vec<_> = preds
13            .iter()
14            .map(|(pred, _)| match pred.kind().skip_binder() {
15                ty::ClauseKind::RegionOutlives(p) => p.to_string(),
16                ty::ClauseKind::TypeOutlives(p) => p.to_string(),
17                err => bug!("unexpected clause {:?}", err),
18            })
19            .collect();
20        preds.sort();
21
22        let span = tcx.def_span(id.owner_id);
23        let mut err = tcx.dcx().struct_span_err(span, sym::rustc_outlives.as_str());
24        for pred in preds {
25            err.note(pred);
26        }
27        err.emit();
28    }
29}