diff options
| author | Michael Goulet <michael@errs.io> | 2022-08-25 23:35:09 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2022-08-26 00:10:38 +0000 |
| commit | e5602cb2a0e114729625cf27db819ef56a79d86e (patch) | |
| tree | 924fd909f17da177587acfb0daa46c74896bb490 /compiler/rustc_trait_selection | |
| parent | fee9e9b9d36649fe7ebc00b1eeefc6d97052798f (diff) | |
| download | rust-e5602cb2a0e114729625cf27db819ef56a79d86e.tar.gz rust-e5602cb2a0e114729625cf27db819ef56a79d86e.zip | |
Add and use ObligationCtxt::new_in_snapshot
Diffstat (limited to 'compiler/rustc_trait_selection')
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/engine.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/engine.rs b/compiler/rustc_trait_selection/src/traits/engine.rs index 136b9432145..f6df407118c 100644 --- a/compiler/rustc_trait_selection/src/traits/engine.rs +++ b/compiler/rustc_trait_selection/src/traits/engine.rs @@ -17,6 +17,7 @@ use rustc_span::Span; pub trait TraitEngineExt<'tcx> { fn new(tcx: TyCtxt<'tcx>) -> Box<Self>; + fn new_in_snapshot(tcx: TyCtxt<'tcx>) -> Box<Self>; } impl<'tcx> TraitEngineExt<'tcx> for dyn TraitEngine<'tcx> { @@ -27,6 +28,14 @@ impl<'tcx> TraitEngineExt<'tcx> for dyn TraitEngine<'tcx> { Box::new(FulfillmentContext::new()) } } + + fn new_in_snapshot(tcx: TyCtxt<'tcx>) -> Box<Self> { + if tcx.sess.opts.unstable_opts.chalk { + Box::new(ChalkFulfillmentContext::new()) + } else { + Box::new(FulfillmentContext::new_in_snapshot()) + } + } } /// Used if you want to have pleasant experience when dealing @@ -41,6 +50,10 @@ impl<'a, 'tcx> ObligationCtxt<'a, 'tcx> { Self { infcx, engine: RefCell::new(<dyn TraitEngine<'_>>::new(infcx.tcx)) } } + pub fn new_in_snapshot(infcx: &'a InferCtxt<'a, 'tcx>) -> Self { + Self { infcx, engine: RefCell::new(<dyn TraitEngine<'_>>::new_in_snapshot(infcx.tcx)) } + } + pub fn register_obligation(&self, obligation: PredicateObligation<'tcx>) { self.engine.borrow_mut().register_predicate_obligation(self.infcx, obligation); } |
