Skip to content

Commit c925008

Browse files
committed
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.
1 parent 0d78e40 commit c925008

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/librustc/infer/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,9 +1131,9 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
11311131
region_context: DefId,
11321132
region_map: &region::ScopeTree,
11331133
free_regions: &FreeRegionMap<'tcx>) {
1134-
// TODO assert!(self.region_obligations.borrow().is_empty(),
1135-
// TODO "region_obligations not empty: {:#?}",
1136-
// TODO self.region_obligations.borrow());
1134+
assert!(self.is_tainted_by_errors() || self.region_obligations.borrow().is_empty(),
1135+
"region_obligations not empty: {:#?}",
1136+
self.region_obligations.borrow());
11371137

11381138
let region_rels = RegionRelations::new(self.tcx,
11391139
region_context,

src/librustc/traits/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,7 @@ pub fn normalize_param_env_or_error<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
511511
unnormalized_env.reveal);
512512

513513
tcx.infer_ctxt().enter(|infcx| {
514+
let body_id = cause.body_id;
514515
let predicates = match fully_normalize(
515516
&infcx,
516517
cause,
@@ -536,6 +537,14 @@ pub fn normalize_param_env_or_error<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
536537

537538
let region_scope_tree = region::ScopeTree::default();
538539
let free_regions = FreeRegionMap::new();
540+
541+
// TODO We should really... do something with these. But as of
542+
// this writing we were ignoring them, just without knowing
543+
// it, and it would take some refactoring to stop doing so.
544+
// (In particular, the needed methods currently live in
545+
// regionck.) -nmatsakis
546+
let _ = infcx.take_region_obligations(body_id);
547+
539548
infcx.resolve_regions_and_report_errors(region_context, &region_scope_tree, &free_regions);
540549
let predicates = match infcx.fully_resolve(&predicates) {
541550
Ok(predicates) => predicates,

0 commit comments

Comments
 (0)