]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_hir_analysis/src/outlives/test.rs
Rollup merge of #102356 - davidtwco:translation-bootstrap-bump-allow-lint, r=lcnr
[rust.git] / compiler / rustc_hir_analysis / src / outlives / test.rs
1 use rustc_errors::struct_span_err;
2 use rustc_middle::ty::TyCtxt;
3 use rustc_span::symbol::sym;
4
5 pub fn test_inferred_outlives(tcx: TyCtxt<'_>) {
6     for id in tcx.hir().items() {
7         // For unit testing: check for a special "rustc_outlives"
8         // attribute and report an error with various results if found.
9         if tcx.has_attr(id.def_id.to_def_id(), sym::rustc_outlives) {
10             let inferred_outlives_of = tcx.inferred_outlives_of(id.def_id);
11             struct_span_err!(
12                 tcx.sess,
13                 tcx.def_span(id.def_id),
14                 E0640,
15                 "{:?}",
16                 inferred_outlives_of
17             )
18             .emit();
19         }
20     }
21 }