assertion for only collection nll region variable information for debug in non-canonicalization contexts
This commit is contained in:
parent
439292bc79
commit
da0fe80137
5 changed files with 49 additions and 24 deletions
|
@ -30,6 +30,8 @@ use super::*;
|
|||
use rustc_middle::ty::relate::{Relate, TypeRelation};
|
||||
use rustc_middle::ty::{Const, ImplSubject};
|
||||
|
||||
use std::cell::Cell;
|
||||
|
||||
/// Whether we should define opaque types or just treat them opaquely.
|
||||
///
|
||||
/// Currently only used to prevent predicate matching from matching anything
|
||||
|
@ -82,6 +84,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
in_snapshot: self.in_snapshot.clone(),
|
||||
universe: self.universe.clone(),
|
||||
intercrate: self.intercrate,
|
||||
inside_canonicalization_ctxt: Cell::new(self.inside_canonicalization_ctxt()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -561,6 +561,8 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
|
|||
where
|
||||
V: TypeFoldable<TyCtxt<'tcx>>,
|
||||
{
|
||||
let _inside_canonical_ctxt_guard = infcx.set_canonicalization_ctxt();
|
||||
|
||||
let needs_canonical_flags = if canonicalize_region_mode.any() {
|
||||
TypeFlags::NEEDS_INFER |
|
||||
TypeFlags::HAS_FREE_REGIONS | // `HAS_RE_PLACEHOLDER` implies `HAS_FREE_REGIONS`
|
||||
|
|
|
@ -39,6 +39,7 @@ use rustc_span::Span;
|
|||
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::fmt;
|
||||
use std::ops::Drop;
|
||||
|
||||
use self::combine::CombineFields;
|
||||
use self::error_reporting::TypeErrCtxt;
|
||||
|
@ -342,6 +343,11 @@ pub struct InferCtxt<'tcx> {
|
|||
/// there is no type that the user could *actually name* that
|
||||
/// would satisfy it. This avoids crippling inference, basically.
|
||||
pub intercrate: bool,
|
||||
|
||||
/// Flag that is set when we enter canonicalization. Used for debugging to ensure
|
||||
/// that we only collect region information for `BorrowckInferCtxt::reg_var_to_origin`
|
||||
/// inside non-canonicalization contexts.
|
||||
inside_canonicalization_ctxt: Cell<bool>,
|
||||
}
|
||||
|
||||
/// See the `error_reporting` module for more details.
|
||||
|
@ -633,6 +639,7 @@ impl<'tcx> InferCtxtBuilder<'tcx> {
|
|||
skip_leak_check: Cell::new(false),
|
||||
universe: Cell::new(ty::UniverseIndex::ROOT),
|
||||
intercrate,
|
||||
inside_canonicalization_ctxt: Cell::new(false),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1728,6 +1735,31 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn inside_canonicalization_ctxt(&self) -> bool {
|
||||
self.inside_canonicalization_ctxt.get()
|
||||
}
|
||||
|
||||
pub fn set_canonicalization_ctxt(&self) -> CanonicalizationCtxtGuard<'_, 'tcx> {
|
||||
let prev_ctxt = self.inside_canonicalization_ctxt();
|
||||
self.inside_canonicalization_ctxt.set(true);
|
||||
CanonicalizationCtxtGuard { prev_ctxt, infcx: self }
|
||||
}
|
||||
|
||||
fn set_canonicalization_ctxt_to(&self, ctxt: bool) {
|
||||
self.inside_canonicalization_ctxt.set(ctxt);
|
||||
}
|
||||
}
|
||||
|
||||
pub struct CanonicalizationCtxtGuard<'cx, 'tcx> {
|
||||
prev_ctxt: bool,
|
||||
infcx: &'cx InferCtxt<'tcx>,
|
||||
}
|
||||
|
||||
impl<'cx, 'tcx> Drop for CanonicalizationCtxtGuard<'cx, 'tcx> {
|
||||
fn drop(&mut self) {
|
||||
self.infcx.set_canonicalization_ctxt_to(self.prev_ctxt)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue