|
1 | 1 | use rustc_errors::struct_span_err;
|
2 |
| -use rustc_hir as hir; |
3 |
| -use rustc_hir::itemlikevisit::ItemLikeVisitor; |
4 | 2 | use rustc_middle::ty::TyCtxt;
|
5 | 3 | use rustc_span::symbol::sym;
|
6 | 4 |
|
7 | 5 | pub fn test_inferred_outlives(tcx: TyCtxt<'_>) {
|
8 |
| - tcx.hir().visit_all_item_likes(&mut OutlivesTest { tcx }); |
9 |
| -} |
10 |
| - |
11 |
| -struct OutlivesTest<'tcx> { |
12 |
| - tcx: TyCtxt<'tcx>, |
13 |
| -} |
14 |
| - |
15 |
| -impl<'tcx> ItemLikeVisitor<'tcx> for OutlivesTest<'tcx> { |
16 |
| - fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) { |
| 6 | + for id in tcx.hir().items() { |
17 | 7 | // For unit testing: check for a special "rustc_outlives"
|
18 | 8 | // attribute and report an error with various results if found.
|
19 |
| - if self.tcx.has_attr(item.def_id.to_def_id(), sym::rustc_outlives) { |
20 |
| - let inferred_outlives_of = self.tcx.inferred_outlives_of(item.def_id); |
21 |
| - struct_span_err!(self.tcx.sess, item.span, E0640, "{:?}", inferred_outlives_of).emit(); |
| 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!(tcx.sess, tcx.hir().span(id.hir_id()), E0640, "{:?}", inferred_outlives_of).emit(); |
22 | 12 | }
|
23 | 13 | }
|
24 |
| - |
25 |
| - fn visit_trait_item(&mut self, _: &'tcx hir::TraitItem<'tcx>) {} |
26 |
| - fn visit_impl_item(&mut self, _: &'tcx hir::ImplItem<'tcx>) {} |
27 |
| - fn visit_foreign_item(&mut self, _: &'tcx hir::ForeignItem<'tcx>) {} |
28 | 14 | }
|
0 commit comments