From c925008a5ce44fd5f4755279793c64bb9ccb50f4 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Wed, 1 Nov 2017 14:52:24 -0400 Subject: [PATCH] assert that we are consuming all of the region obligations When we get around to resolving regions, we really ought to take region obligations into account. There is one case where they are presently being ignored. Keep ignoring them there for now but leave a TODO. --- src/librustc/infer/mod.rs | 6 +++--- src/librustc/traits/mod.rs | 9 +++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/librustc/infer/mod.rs b/src/librustc/infer/mod.rs index 110c49d820a..ba99ff5291a 100644 --- a/src/librustc/infer/mod.rs +++ b/src/librustc/infer/mod.rs @@ -1131,9 +1131,9 @@ pub fn resolve_regions_and_report_errors(&self, region_context: DefId, region_map: ®ion::ScopeTree, free_regions: &FreeRegionMap<'tcx>) { - // TODO assert!(self.region_obligations.borrow().is_empty(), - // TODO "region_obligations not empty: {:#?}", - // TODO self.region_obligations.borrow()); + assert!(self.is_tainted_by_errors() || self.region_obligations.borrow().is_empty(), + "region_obligations not empty: {:#?}", + self.region_obligations.borrow()); let region_rels = RegionRelations::new(self.tcx, region_context, diff --git a/src/librustc/traits/mod.rs b/src/librustc/traits/mod.rs index 297974f1c9a..cd4a6878851 100644 --- a/src/librustc/traits/mod.rs +++ b/src/librustc/traits/mod.rs @@ -511,6 +511,7 @@ pub fn normalize_param_env_or_error<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, unnormalized_env.reveal); tcx.infer_ctxt().enter(|infcx| { + let body_id = cause.body_id; let predicates = match fully_normalize( &infcx, cause, @@ -536,6 +537,14 @@ pub fn normalize_param_env_or_error<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let region_scope_tree = region::ScopeTree::default(); let free_regions = FreeRegionMap::new(); + + // TODO We should really... do something with these. But as of + // this writing we were ignoring them, just without knowing + // it, and it would take some refactoring to stop doing so. + // (In particular, the needed methods currently live in + // regionck.) -nmatsakis + let _ = infcx.take_region_obligations(body_id); + infcx.resolve_regions_and_report_errors(region_context, ®ion_scope_tree, &free_regions); let predicates = match infcx.fully_resolve(&predicates) { Ok(predicates) => predicates,