mirror of
https://github.com/rust-lang/rust.git
synced 2025-12-02 22:39:08 +00:00
The end goal is to eliminate `Map` altogether. I added a `hir_` prefix to all of them, that seemed simplest. The exceptions are `module_items` which became `hir_module_free_items` because there was already a `hir_module_items`, and `items` which became `hir_free_items` for consistency with `hir_module_free_items`.
30 lines
926 B
Rust
30 lines
926 B
Rust
use rustc_middle::bug;
|
|
use rustc_middle::ty::{self, TyCtxt};
|
|
use rustc_span::sym;
|
|
|
|
pub(crate) fn inferred_outlives(tcx: TyCtxt<'_>) {
|
|
for id in tcx.hir_free_items() {
|
|
if !tcx.has_attr(id.owner_id, sym::rustc_outlives) {
|
|
continue;
|
|
}
|
|
|
|
let preds = tcx.inferred_outlives_of(id.owner_id);
|
|
let mut preds: Vec<_> = preds
|
|
.iter()
|
|
.map(|(pred, _)| match pred.kind().skip_binder() {
|
|
ty::ClauseKind::RegionOutlives(p) => p.to_string(),
|
|
ty::ClauseKind::TypeOutlives(p) => p.to_string(),
|
|
err => bug!("unexpected clause {:?}", err),
|
|
})
|
|
.collect();
|
|
preds.sort();
|
|
|
|
let span = tcx.def_span(id.owner_id);
|
|
let mut err = tcx.dcx().struct_span_err(span, sym::rustc_outlives.as_str());
|
|
for pred in preds {
|
|
err.note(pred);
|
|
}
|
|
err.emit();
|
|
}
|
|
}
|