|
11 | 11 | use dep_graph::DepGraph;
|
12 | 12 | use middle::infer::InferCtxt;
|
13 | 13 | use middle::ty::{self, Ty, TypeFoldable};
|
14 |
| -use rustc_data_structures::obligation_forest::{Backtrace, ObligationForest, Error}; |
| 14 | +use rustc_data_structures::obligation_forest::{Backtrace, Error, ObligationForest}; |
| 15 | +use rustc_data_structures::obligation_forest::Snapshot as ForestSnapshot; |
15 | 16 | use std::iter;
|
16 | 17 | use syntax::ast;
|
17 | 18 | use util::common::ErrorReported;
|
@@ -95,6 +96,8 @@ pub struct FulfillmentContext<'tcx> {
|
95 | 96 | region_obligations: NodeMap<Vec<RegionObligation<'tcx>>>,
|
96 | 97 | }
|
97 | 98 |
|
| 99 | +pub struct FulfillmentSnapshot(ForestSnapshot); |
| 100 | + |
98 | 101 | #[derive(Clone)]
|
99 | 102 | pub struct RegionObligation<'tcx> {
|
100 | 103 | pub sub_region: ty::Region,
|
@@ -311,6 +314,20 @@ impl<'tcx> FulfillmentContext<'tcx> {
|
311 | 314 | Err(errors)
|
312 | 315 | }
|
313 | 316 | }
|
| 317 | + |
| 318 | + // FIXME Perhaps this function (and rollback_to, and commit_from) should not be public if/when |
| 319 | + // the super all powerful TypeCtxt thing appears. |
| 320 | + pub fn start_snapshot(&mut self) -> FulfillmentSnapshot { |
| 321 | + FulfillmentSnapshot(self.predicates.start_snapshot()) |
| 322 | + } |
| 323 | + |
| 324 | + pub fn rollback_to(&mut self, snapshot: FulfillmentSnapshot) { |
| 325 | + self.predicates.rollback_snapshot(snapshot.0) |
| 326 | + } |
| 327 | + |
| 328 | + pub fn commit_from(&mut self, snapshot: FulfillmentSnapshot) { |
| 329 | + self.predicates.commit_snapshot(snapshot.0) |
| 330 | + } |
314 | 331 | }
|
315 | 332 |
|
316 | 333 | /// Like `process_predicate1`, but wrap result into a pending predicate.
|
|
0 commit comments