Skip to content

Commit 9baf013

Browse files
nikomatsakispnkfelix
authored andcommitted
assert no region obligations on entering custom type op
Fixes #51649
1 parent 68c2a39 commit 9baf013

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/librustc/traits/query/type_op/custom.rs

+13
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,19 @@ fn scrape_region_constraints<'gcx, 'tcx, R>(
7575
) -> Fallible<(R, Option<Rc<Vec<QueryRegionConstraint<'tcx>>>>)> {
7676
let mut fulfill_cx = TraitEngine::new(infcx.tcx);
7777
let dummy_body_id = ObligationCause::dummy().body_id;
78+
79+
// During NLL, we expect that nobody will register region
80+
// obligations **except** as part of a custom type op (and, at the
81+
// end of each custom type op, we scrape out the region
82+
// obligations that resulted). So this vector should be empty on
83+
// entry.
84+
let pre_obligations = infcx.take_registered_region_obligations();
85+
assert!(
86+
pre_obligations.is_empty(),
87+
"scrape_region_constraints: incoming region obligations = {:#?}",
88+
pre_obligations,
89+
);
90+
7891
let InferOk { value, obligations } = infcx.commit_if_ok(|_| op())?;
7992
debug_assert!(obligations.iter().all(|o| o.cause.body_id == dummy_body_id));
8093
fulfill_cx.register_predicate_obligations(infcx, obligations);

0 commit comments

Comments
 (0)