Skip to content

Commit ee33517

Browse files
Expose snapshotting in FulfillmentContext
1 parent 3df29c0 commit ee33517

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

src/librustc/middle/traits/fulfill.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
use dep_graph::DepGraph;
1212
use middle::infer::InferCtxt;
1313
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;
1516
use std::iter;
1617
use syntax::ast;
1718
use util::common::ErrorReported;
@@ -95,6 +96,8 @@ pub struct FulfillmentContext<'tcx> {
9596
region_obligations: NodeMap<Vec<RegionObligation<'tcx>>>,
9697
}
9798

99+
pub struct FulfillmentSnapshot(ForestSnapshot);
100+
98101
#[derive(Clone)]
99102
pub struct RegionObligation<'tcx> {
100103
pub sub_region: ty::Region,
@@ -311,6 +314,20 @@ impl<'tcx> FulfillmentContext<'tcx> {
311314
Err(errors)
312315
}
313316
}
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+
}
314331
}
315332

316333
/// Like `process_predicate1`, but wrap result into a pending predicate.

src/librustc/middle/traits/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ pub use self::error_reporting::report_object_safety_error;
3535
pub use self::coherence::orphan_check;
3636
pub use self::coherence::overlapping_impls;
3737
pub use self::coherence::OrphanCheckErr;
38-
pub use self::fulfill::{FulfillmentContext, GlobalFulfilledPredicates, RegionObligation};
38+
pub use self::fulfill::{FulfillmentContext, FulfillmentSnapshot, GlobalFulfilledPredicates,
39+
RegionObligation};
3940
pub use self::project::MismatchedProjectionTypes;
4041
pub use self::project::normalize;
4142
pub use self::project::Normalized;

0 commit comments

Comments
 (0)