added components for testing. added outlives test to the check_crate function of librustc_typeck

This commit is contained in:
toidiu 2017-09-27 21:01:48 -04:00
parent 7c8a7221a4
commit ba1efa3b61
4 changed files with 39 additions and 30 deletions

View File

@ -4679,4 +4679,5 @@ register_diagnostics! {
E0627, // yield statement outside of generator literal E0627, // yield statement outside of generator literal
E0632, // cannot provide explicit type parameters when `impl Trait` is used in E0632, // cannot provide explicit type parameters when `impl Trait` is used in
// argument position. // argument position.
E0628, // infer outlives
} }

View File

@ -289,6 +289,7 @@ pub fn provide(providers: &mut Providers) {
coherence::provide(providers); coherence::provide(providers);
check::provide(providers); check::provide(providers);
variance::provide(providers); variance::provide(providers);
outlives::provide(providers);
} }
pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>)
@ -319,10 +320,10 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>)
variance::test::test_variance(tcx)); variance::test::test_variance(tcx));
})?; })?;
// tcx.sess.track_errors(|| { tcx.sess.track_errors(|| {
// time(time_passes, "outlives testing", || time(time_passes, "outlives testing", ||
// outlives::test::test_inferred_outlives(tcx)); outlives::test::test_inferred_outlives(tcx));
// })?; })?;
time(time_passes, "wf checking", || check::check_wf_new(tcx))?; time(time_passes, "wf checking", || check::check_wf_new(tcx))?;

View File

@ -10,13 +10,20 @@
use rustc::hir::def_id::DefId; use rustc::hir::def_id::DefId;
use rustc::ty::{self, TyCtxt}; use rustc::ty::{self, TyCtxt};
use rustc::ty::maps::Providers;
/// Code to write unit test for outlives. /// Code to write unit test for outlives.
pub mod test; pub mod test;
pub fn provide(providers: &mut Providers) {
*providers = Providers {
inferred_outlives_of,
..*providers
};
}
//todo //todo
pub fn inferred_outlives_of<'a, 'tcx>(_tcx: TyCtxt<'a, 'tcx, 'tcx>, fn inferred_outlives_of<'a, 'tcx>(_tcx: TyCtxt<'a, 'tcx, 'tcx>, _def_id: DefId)
_def_id: DefId)
-> Vec<ty::Predicate<'tcx>> { -> Vec<ty::Predicate<'tcx>> {
Vec::new() Vec::new()
} }

View File

@ -8,34 +8,34 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
//use rustc::hir; use rustc::hir;
//use rustc::hir::itemlikevisit::ItemLikeVisitor; use rustc::hir::itemlikevisit::ItemLikeVisitor;
use rustc::ty::TyCtxt; use rustc::ty::TyCtxt;
//pub fn test_outlives<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { pub fn test_inferred_outlives<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
// tcx.hir.krate().visit_all_item_likes(&mut OutlivesTest { tcx }); tcx.hir.krate().visit_all_item_likes(&mut OutlivesTest { tcx });
//} }
struct OutlivesTest<'a, 'tcx: 'a> { struct OutlivesTest<'a, 'tcx: 'a> {
tcx: TyCtxt<'a, 'tcx, 'tcx> tcx: TyCtxt<'a, 'tcx, 'tcx>
} }
//impl<'a, 'tcx> ItemLikeVisitor<'tcx> for OutlivesTest<'a, 'tcx> { impl<'a, 'tcx> ItemLikeVisitor<'tcx> for OutlivesTest<'a, 'tcx> {
// fn visit_item(&mut self, item: &'tcx hir::Item) { fn visit_item(&mut self, item: &'tcx hir::Item) {
// let item_def_id = self.tcx.hir.local_def_id(item.id); let item_def_id = self.tcx.hir.local_def_id(item.id);
//
// // For unit testing: check for a special "rustc_outlives" // For unit testing: check for a special "rustc_outlives"
// // attribute and report an error with various results if found. // attribute and report an error with various results if found.
// if self.tcx.has_attr(item_def_id, "rustc_outlives") { if self.tcx.has_attr(item_def_id, "rustc_outlives") {
// let outlives_of = self.tcx.outlives_of(item_def_id); let inferred_outlives_of = self.tcx.inferred_outlives_of(item_def_id);
// span_err!(self.tcx.sess, span_err!(self.tcx.sess,
// item.span, item.span,
// E0208, E0628,
// "{:?}", "{:?}",
// outlives_of); inferred_outlives_of);
// } }
// } }
//
// fn visit_trait_item(&mut self, _: &'tcx hir::TraitItem) { } fn visit_trait_item(&mut self, _: &'tcx hir::TraitItem) { }
// fn visit_impl_item(&mut self, _: &'tcx hir::ImplItem) { } fn visit_impl_item(&mut self, _: &'tcx hir::ImplItem) { }
//} }