1 use rustc_errors::struct_span_err; 2 use rustc_middle::ty::TyCtxt; 3 use rustc_span::symbol::sym; 4 test_inferred_outlives(tcx: TyCtxt<'_>)5pub 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.owner_id, sym::rustc_outlives) { 10 let inferred_outlives_of = tcx.inferred_outlives_of(id.owner_id); 11 struct_span_err!( 12 tcx.sess, 13 tcx.def_span(id.owner_id), 14 E0640, 15 "{:?}", 16 inferred_outlives_of 17 ) 18 .emit(); 19 } 20 } 21 } 22