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.
This commit is contained in:
Niko Matsakis 2017-11-01 14:52:24 -04:00
parent 0d78e40e88
commit c925008a5c
2 changed files with 12 additions and 3 deletions

View 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,

View 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,