assert that trait solver is only created in proper infcx

This commit is contained in:
Michael Goulet
2024-01-13 21:53:42 +00:00
parent 04a6fd241b
commit 7724ba7bd5
2 changed files with 10 additions and 0 deletions

View File

@@ -80,6 +80,11 @@ static_assert_size!(PendingPredicateObligation<'_>, 72);
impl<'tcx> FulfillmentContext<'tcx> {
/// Creates a new fulfillment context.
pub(super) fn new(infcx: &InferCtxt<'tcx>) -> FulfillmentContext<'tcx> {
assert!(
!infcx.next_trait_solver(),
"old trait solver fulfillment context created when \
infcx is set up for new trait solver"
);
FulfillmentContext {
predicates: ObligationForest::new(),
usable_in_snapshot: infcx.num_open_snapshots(),