Revert "Auto merge of #93893 - oli-obk:sad_revert, r=oli-obk"
This reverts commit6499c5e7fc
, reversing changes made to78450d2d60
.
This commit is contained in:
parent
0e4524e5b4
commit
264cd05b16
372 changed files with 3647 additions and 2503 deletions
|
@ -5,7 +5,7 @@ pub use self::RegionVariableOrigin::*;
|
|||
pub use self::SubregionOrigin::*;
|
||||
pub use self::ValuePairs::*;
|
||||
|
||||
use self::opaque_types::OpaqueTypeMap;
|
||||
use self::opaque_types::OpaqueTypeStorage;
|
||||
pub(crate) use self::undo_log::{InferCtxtUndoLogs, Snapshot, UndoLog};
|
||||
|
||||
use crate::traits::{self, ObligationCause, PredicateObligations, TraitEngine};
|
||||
|
@ -191,18 +191,8 @@ pub struct InferCtxtInner<'tcx> {
|
|||
|
||||
undo_log: InferCtxtUndoLogs<'tcx>,
|
||||
|
||||
// Opaque types found in explicit return types and their
|
||||
// associated fresh inference variable. Writeback resolves these
|
||||
// variables to get the concrete type, which can be used to
|
||||
// 'de-opaque' OpaqueTypeDecl outside of type inference.
|
||||
pub opaque_types: OpaqueTypeMap<'tcx>,
|
||||
|
||||
/// A map from inference variables created from opaque
|
||||
/// type instantiations (`ty::Infer`) to the actual opaque
|
||||
/// type (`ty::Opaque`). Used during fallback to map unconstrained
|
||||
/// opaque type inference variables to their corresponding
|
||||
/// opaque type.
|
||||
pub opaque_types_vars: FxHashMap<Ty<'tcx>, Ty<'tcx>>,
|
||||
/// Caches for opaque type inference.
|
||||
pub opaque_type_storage: OpaqueTypeStorage<'tcx>,
|
||||
}
|
||||
|
||||
impl<'tcx> InferCtxtInner<'tcx> {
|
||||
|
@ -216,8 +206,7 @@ impl<'tcx> InferCtxtInner<'tcx> {
|
|||
float_unification_storage: ut::UnificationTableStorage::new(),
|
||||
region_constraint_storage: Some(RegionConstraintStorage::new()),
|
||||
region_obligations: vec![],
|
||||
opaque_types: Default::default(),
|
||||
opaque_types_vars: Default::default(),
|
||||
opaque_type_storage: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -236,6 +225,11 @@ impl<'tcx> InferCtxtInner<'tcx> {
|
|||
self.type_variable_storage.with_log(&mut self.undo_log)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn opaque_types(&mut self) -> opaque_types::OpaqueTypeTable<'_, 'tcx> {
|
||||
self.opaque_type_storage.with_log(&mut self.undo_log)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn int_unification_table(
|
||||
&mut self,
|
||||
|
@ -296,6 +290,10 @@ pub struct InferCtxt<'a, 'tcx> {
|
|||
/// to the outside until the end up in an `InferCtxt` for typeck or borrowck.
|
||||
pub defining_use_anchor: Option<LocalDefId>,
|
||||
|
||||
/// Used by WF-checking to not have to figure out hidden types itself, but
|
||||
/// to just invoke type_of to get the already computed hidden type from typeck.
|
||||
pub reveal_defining_opaque_types: bool,
|
||||
|
||||
/// During type-checking/inference of a body, `in_progress_typeck_results`
|
||||
/// contains a reference to the typeck results being built up, which are
|
||||
/// used for reading closure kinds/signatures as they are inferred,
|
||||
|
@ -571,6 +569,7 @@ pub struct InferCtxtBuilder<'tcx> {
|
|||
tcx: TyCtxt<'tcx>,
|
||||
fresh_typeck_results: Option<RefCell<ty::TypeckResults<'tcx>>>,
|
||||
defining_use_anchor: Option<LocalDefId>,
|
||||
reveal_defining_opaque_types: bool,
|
||||
}
|
||||
|
||||
pub trait TyCtxtInferExt<'tcx> {
|
||||
|
@ -579,7 +578,12 @@ pub trait TyCtxtInferExt<'tcx> {
|
|||
|
||||
impl<'tcx> TyCtxtInferExt<'tcx> for TyCtxt<'tcx> {
|
||||
fn infer_ctxt(self) -> InferCtxtBuilder<'tcx> {
|
||||
InferCtxtBuilder { tcx: self, defining_use_anchor: None, fresh_typeck_results: None }
|
||||
InferCtxtBuilder {
|
||||
tcx: self,
|
||||
defining_use_anchor: None,
|
||||
fresh_typeck_results: None,
|
||||
reveal_defining_opaque_types: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -603,6 +607,13 @@ impl<'tcx> InferCtxtBuilder<'tcx> {
|
|||
self
|
||||
}
|
||||
|
||||
/// WF-checking doesn't need to recompute opaque types and can instead use
|
||||
/// the type_of query to get them from typeck.
|
||||
pub fn reveal_defining_opaque_types(mut self) -> Self {
|
||||
self.reveal_defining_opaque_types = true;
|
||||
self
|
||||
}
|
||||
|
||||
/// Given a canonical value `C` as a starting point, create an
|
||||
/// inference context that contains each of the bound values
|
||||
/// within instantiated as a fresh variable. The `f` closure is
|
||||
|
@ -627,11 +638,17 @@ impl<'tcx> InferCtxtBuilder<'tcx> {
|
|||
}
|
||||
|
||||
pub fn enter<R>(&mut self, f: impl for<'a> FnOnce(InferCtxt<'a, 'tcx>) -> R) -> R {
|
||||
let InferCtxtBuilder { tcx, defining_use_anchor, ref fresh_typeck_results } = *self;
|
||||
let InferCtxtBuilder {
|
||||
tcx,
|
||||
defining_use_anchor,
|
||||
reveal_defining_opaque_types,
|
||||
ref fresh_typeck_results,
|
||||
} = *self;
|
||||
let in_progress_typeck_results = fresh_typeck_results.as_ref();
|
||||
f(InferCtxt {
|
||||
tcx,
|
||||
defining_use_anchor,
|
||||
reveal_defining_opaque_types,
|
||||
in_progress_typeck_results,
|
||||
inner: RefCell::new(InferCtxtInner::new()),
|
||||
lexical_region_resolutions: RefCell::new(None),
|
||||
|
@ -766,6 +783,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
&'a self,
|
||||
trace: TypeTrace<'tcx>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
define_opaque_types: bool,
|
||||
) -> CombineFields<'a, 'tcx> {
|
||||
CombineFields {
|
||||
infcx: self,
|
||||
|
@ -773,6 +791,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
cause: None,
|
||||
param_env,
|
||||
obligations: PredicateObligations::new(),
|
||||
define_opaque_types,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1088,12 +1107,20 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
self.tcx.mk_ty_var(self.next_ty_var_id(origin))
|
||||
}
|
||||
|
||||
pub fn next_ty_var_id_in_universe(
|
||||
&self,
|
||||
origin: TypeVariableOrigin,
|
||||
universe: ty::UniverseIndex,
|
||||
) -> TyVid {
|
||||
self.inner.borrow_mut().type_variables().new_var(universe, origin)
|
||||
}
|
||||
|
||||
pub fn next_ty_var_in_universe(
|
||||
&self,
|
||||
origin: TypeVariableOrigin,
|
||||
universe: ty::UniverseIndex,
|
||||
) -> Ty<'tcx> {
|
||||
let vid = self.inner.borrow_mut().type_variables().new_var(universe, origin);
|
||||
let vid = self.next_ty_var_id_in_universe(origin, universe);
|
||||
self.tcx.mk_ty_var(vid)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue