diff options
| author | Michael Goulet <michael@errs.io> | 2024-01-13 21:53:42 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2024-01-13 22:00:35 +0000 |
| commit | 7724ba7bd5f2c947a7dc561c24b19bb8409a6ed6 (patch) | |
| tree | 2d00033a87640f6b04028ef6f38a5f36227b693f | |
| parent | 04a6fd241bc18391b3f1f6ece1b109acd19842f1 (diff) | |
| download | rust-7724ba7bd5f2c947a7dc561c24b19bb8409a6ed6.tar.gz rust-7724ba7bd5f2c947a7dc561c24b19bb8409a6ed6.zip | |
assert that trait solver is only created in proper infcx
| -rw-r--r-- | compiler/rustc_trait_selection/src/solve/fulfill.rs | 5 | ||||
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/fulfill.rs | 5 |
2 files changed, 10 insertions, 0 deletions
diff --git a/compiler/rustc_trait_selection/src/solve/fulfill.rs b/compiler/rustc_trait_selection/src/solve/fulfill.rs index 2139210b873..09f4f3e9702 100644 --- a/compiler/rustc_trait_selection/src/solve/fulfill.rs +++ b/compiler/rustc_trait_selection/src/solve/fulfill.rs @@ -36,6 +36,11 @@ pub struct FulfillmentCtxt<'tcx> { impl<'tcx> FulfillmentCtxt<'tcx> { pub fn new(infcx: &InferCtxt<'tcx>) -> FulfillmentCtxt<'tcx> { + assert!( + infcx.next_trait_solver(), + "new trait solver fulfillment context created when \ + infcx is set up for old trait solver" + ); FulfillmentCtxt { obligations: Vec::new(), usable_in_snapshot: infcx.num_open_snapshots() } } } diff --git a/compiler/rustc_trait_selection/src/traits/fulfill.rs b/compiler/rustc_trait_selection/src/traits/fulfill.rs index 045d7e444b6..472342f9898 100644 --- a/compiler/rustc_trait_selection/src/traits/fulfill.rs +++ b/compiler/rustc_trait_selection/src/traits/fulfill.rs @@ -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(), |
