1 // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
12 use rustc::hir::itemlikevisit::ItemLikeVisitor;
13 use rustc::ty::TyCtxt;
15 pub fn test_inferred_outlives<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
18 .visit_all_item_likes(&mut OutlivesTest { tcx });
21 struct OutlivesTest<'a, 'tcx: 'a> {
22 tcx: TyCtxt<'a, 'tcx, 'tcx>,
25 impl<'a, 'tcx> ItemLikeVisitor<'tcx> for OutlivesTest<'a, 'tcx> {
26 fn visit_item(&mut self, item: &'tcx hir::Item) {
27 let item_def_id = self.tcx.hir.local_def_id(item.id);
29 // For unit testing: check for a special "rustc_outlives"
30 // attribute and report an error with various results if found.
31 if self.tcx.has_attr(item_def_id, "rustc_outlives") {
32 let inferred_outlives_of = self.tcx.inferred_outlives_of(item_def_id);
43 fn visit_trait_item(&mut self, _: &'tcx hir::TraitItem) {}
44 fn visit_impl_item(&mut self, _: &'tcx hir::ImplItem) {}