From c27f30835ccd356aba802146242cd369b52e224e Mon Sep 17 00:00:00 2001 From: Miguel Guarniz Date: Thu, 28 Apr 2022 10:47:13 -0400 Subject: [PATCH] remove OutlivesTest Signed-off-by: Miguel Guarniz --- compiler/rustc_typeck/src/outlives/test.rs | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/compiler/rustc_typeck/src/outlives/test.rs b/compiler/rustc_typeck/src/outlives/test.rs index b3efd9f9ec3..2b6f29a3373 100644 --- a/compiler/rustc_typeck/src/outlives/test.rs +++ b/compiler/rustc_typeck/src/outlives/test.rs @@ -1,28 +1,14 @@ use rustc_errors::struct_span_err; -use rustc_hir as hir; -use rustc_hir::itemlikevisit::ItemLikeVisitor; use rustc_middle::ty::TyCtxt; use rustc_span::symbol::sym; pub fn test_inferred_outlives(tcx: TyCtxt<'_>) { - tcx.hir().visit_all_item_likes(&mut OutlivesTest { tcx }); -} - -struct OutlivesTest<'tcx> { - tcx: TyCtxt<'tcx>, -} - -impl<'tcx> ItemLikeVisitor<'tcx> for OutlivesTest<'tcx> { - fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) { + for id in tcx.hir().items() { // For unit testing: check for a special "rustc_outlives" // attribute and report an error with various results if found. - if self.tcx.has_attr(item.def_id.to_def_id(), sym::rustc_outlives) { - let inferred_outlives_of = self.tcx.inferred_outlives_of(item.def_id); - struct_span_err!(self.tcx.sess, item.span, E0640, "{:?}", inferred_outlives_of).emit(); + if tcx.has_attr(id.def_id.to_def_id(), sym::rustc_outlives) { + let inferred_outlives_of = tcx.inferred_outlives_of(id.def_id); + struct_span_err!(tcx.sess, tcx.hir().span(id.hir_id()), E0640, "{:?}", inferred_outlives_of).emit(); } } - - fn visit_trait_item(&mut self, _: &'tcx hir::TraitItem<'tcx>) {} - fn visit_impl_item(&mut self, _: &'tcx hir::ImplItem<'tcx>) {} - fn visit_foreign_item(&mut self, _: &'tcx hir::ForeignItem<'tcx>) {} }