Skip to content

Commit 7724ba7

Browse files
assert that trait solver is only created in proper infcx
1 parent 04a6fd2 commit 7724ba7

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

Diff for: compiler/rustc_trait_selection/src/solve/fulfill.rs

+5
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ pub struct FulfillmentCtxt<'tcx> {
3636

3737
impl<'tcx> FulfillmentCtxt<'tcx> {
3838
pub fn new(infcx: &InferCtxt<'tcx>) -> FulfillmentCtxt<'tcx> {
39+
assert!(
40+
infcx.next_trait_solver(),
41+
"new trait solver fulfillment context created when \
42+
infcx is set up for old trait solver"
43+
);
3944
FulfillmentCtxt { obligations: Vec::new(), usable_in_snapshot: infcx.num_open_snapshots() }
4045
}
4146
}

Diff for: compiler/rustc_trait_selection/src/traits/fulfill.rs

+5
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ static_assert_size!(PendingPredicateObligation<'_>, 72);
8080
impl<'tcx> FulfillmentContext<'tcx> {
8181
/// Creates a new fulfillment context.
8282
pub(super) fn new(infcx: &InferCtxt<'tcx>) -> FulfillmentContext<'tcx> {
83+
assert!(
84+
!infcx.next_trait_solver(),
85+
"old trait solver fulfillment context created when \
86+
infcx is set up for new trait solver"
87+
);
8388
FulfillmentContext {
8489
predicates: ObligationForest::new(),
8590
usable_in_snapshot: infcx.num_open_snapshots(),

0 commit comments

Comments
 (0)