]> git.lizzy.rs Git - rust.git/commitdiff
assert that we are consuming all of the region obligations
authorNiko Matsakis <niko@alum.mit.edu>
Wed, 1 Nov 2017 18:52:24 +0000 (14:52 -0400)
committerNiko Matsakis <niko@alum.mit.edu>
Wed, 15 Nov 2017 21:49:21 +0000 (16:49 -0500)
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
src/librustc/traits/mod.rs

index 110c49d820abb9171f18842f80b2e1a97460eccd..ba99ff5291a1c2e953da1193dee6a3782f072f4b 100644 (file)
@@ -1131,9 +1131,9 @@ pub fn resolve_regions_and_report_errors(&self,
                                              region_context: DefId,
                                              region_map: &region::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,
index 297974f1c9a984d83da87a7d4ba14f5082979127..cd4a6878851c130fe8b1923b66eff5a6c11ba801 100644 (file)
@@ -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, &region_scope_tree, &free_regions);
         let predicates = match infcx.fully_resolve(&predicates) {
             Ok(predicates) => predicates,