Rollup merge of #104206 - compiler-errors:ocx-more-2, r=lcnr
Remove `save_and_restore_in_snapshot_flag`, use `ObligationCtxt` more r? ```@lcnr```
This commit is contained in:
commit
662df1ec86
4 changed files with 119 additions and 179 deletions
|
@ -778,32 +778,6 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Clear the "currently in a snapshot" flag, invoke the closure,
|
||||
/// then restore the flag to its original value. This flag is a
|
||||
/// debugging measure designed to detect cases where we start a
|
||||
/// snapshot, create type variables, and register obligations
|
||||
/// which may involve those type variables in the fulfillment cx,
|
||||
/// potentially leaving "dangling type variables" behind.
|
||||
/// In such cases, an assertion will fail when attempting to
|
||||
/// register obligations, within a snapshot. Very useful, much
|
||||
/// better than grovelling through megabytes of `RUSTC_LOG` output.
|
||||
///
|
||||
/// HOWEVER, in some cases the flag is unhelpful. In particular, we
|
||||
/// sometimes create a "mini-fulfilment-cx" in which we enroll
|
||||
/// obligations. As long as this fulfillment cx is fully drained
|
||||
/// before we return, this is not a problem, as there won't be any
|
||||
/// escaping obligations in the main cx. In those cases, you can
|
||||
/// use this function.
|
||||
pub fn save_and_restore_in_snapshot_flag<F, R>(&self, func: F) -> R
|
||||
where
|
||||
F: FnOnce(&Self) -> R,
|
||||
{
|
||||
let flag = self.in_snapshot.replace(false);
|
||||
let result = func(self);
|
||||
self.in_snapshot.set(flag);
|
||||
result
|
||||
}
|
||||
|
||||
fn start_snapshot(&self) -> CombinedSnapshot<'tcx> {
|
||||
debug!("start_snapshot()");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue