Auto merge of #49313 - sgrif:sg-revert-stuff, r=nikomatsakis
Remove universes from `ty::ParamEnv` This change was never meant to land. #48407 takes an alternate approach. However, that PR is now blocked on some issues with canonicalization, and rebasing these reverts gets harder each time, so let's just get this bit out of the way now. r? @nikomatsakis
This commit is contained in:
commit
dca14701a5
32 changed files with 97 additions and 244 deletions
|
@ -1111,7 +1111,6 @@ for ty::steal::Steal<T>
|
||||||
|
|
||||||
impl_stable_hash_for!(struct ty::ParamEnv<'tcx> {
|
impl_stable_hash_for!(struct ty::ParamEnv<'tcx> {
|
||||||
caller_bounds,
|
caller_bounds,
|
||||||
universe,
|
|
||||||
reveal
|
reveal
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1282,15 +1281,6 @@ for traits::VtableGeneratorData<'gcx, N> where N: HashStable<StableHashingContex
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> HashStable<StableHashingContext<'a>>
|
|
||||||
for ty::UniverseIndex {
|
|
||||||
fn hash_stable<W: StableHasherResult>(&self,
|
|
||||||
hcx: &mut StableHashingContext<'a>,
|
|
||||||
hasher: &mut StableHasher<W>) {
|
|
||||||
self.depth().hash_stable(hcx, hasher);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl_stable_hash_for!(
|
impl_stable_hash_for!(
|
||||||
impl<'tcx, V> for struct infer::canonical::Canonical<'tcx, V> {
|
impl<'tcx, V> for struct infer::canonical::Canonical<'tcx, V> {
|
||||||
variables, value
|
variables, value
|
||||||
|
|
|
@ -726,10 +726,7 @@ impl<'a, 'gcx, 'tcx> Instantiator<'a, 'gcx, 'tcx> {
|
||||||
return anon_defn.concrete_ty;
|
return anon_defn.concrete_ty;
|
||||||
}
|
}
|
||||||
let span = tcx.def_span(def_id);
|
let span = tcx.def_span(def_id);
|
||||||
let ty_var = infcx.next_ty_var(
|
let ty_var = infcx.next_ty_var(TypeVariableOrigin::TypeInference(span));
|
||||||
ty::UniverseIndex::ROOT,
|
|
||||||
TypeVariableOrigin::TypeInference(span),
|
|
||||||
);
|
|
||||||
|
|
||||||
let predicates_of = tcx.predicates_of(def_id);
|
let predicates_of = tcx.predicates_of(def_id);
|
||||||
let bounds = predicates_of.instantiate(tcx, substs);
|
let bounds = predicates_of.instantiate(tcx, substs);
|
||||||
|
|
|
@ -254,8 +254,6 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
|
||||||
let ty = match ty_kind {
|
let ty = match ty_kind {
|
||||||
CanonicalTyVarKind::General => {
|
CanonicalTyVarKind::General => {
|
||||||
self.next_ty_var(
|
self.next_ty_var(
|
||||||
// FIXME(#48696) this handling of universes is not right.
|
|
||||||
ty::UniverseIndex::ROOT,
|
|
||||||
TypeVariableOrigin::MiscVariable(span),
|
TypeVariableOrigin::MiscVariable(span),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -407,7 +407,7 @@ impl<'cx, 'gcx, 'tcx> TypeRelation<'cx, 'gcx, 'tcx> for Generalizer<'cx, 'gcx, '
|
||||||
drop(variables);
|
drop(variables);
|
||||||
self.relate(&u, &u)
|
self.relate(&u, &u)
|
||||||
}
|
}
|
||||||
TypeVariableValue::Unknown { universe } => {
|
TypeVariableValue::Unknown { .. } => {
|
||||||
match self.ambient_variance {
|
match self.ambient_variance {
|
||||||
// Invariant: no need to make a fresh type variable.
|
// Invariant: no need to make a fresh type variable.
|
||||||
ty::Invariant => return Ok(t),
|
ty::Invariant => return Ok(t),
|
||||||
|
@ -424,7 +424,7 @@ impl<'cx, 'gcx, 'tcx> TypeRelation<'cx, 'gcx, 'tcx> for Generalizer<'cx, 'gcx, '
|
||||||
}
|
}
|
||||||
|
|
||||||
let origin = *variables.var_origin(vid);
|
let origin = *variables.var_origin(vid);
|
||||||
let new_var_id = variables.new_var(universe, false, origin);
|
let new_var_id = variables.new_var(false, origin);
|
||||||
let u = self.tcx().mk_var(new_var_id);
|
let u = self.tcx().mk_var(new_var_id);
|
||||||
debug!("generalize: replacing original vid={:?} with new={:?}",
|
debug!("generalize: replacing original vid={:?} with new={:?}",
|
||||||
vid, u);
|
vid, u);
|
||||||
|
|
|
@ -141,11 +141,7 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for RegionFudger<'a, 'gcx, 'tcx> {
|
||||||
// This variable was created during the
|
// This variable was created during the
|
||||||
// fudging. Recreate it with a fresh variable
|
// fudging. Recreate it with a fresh variable
|
||||||
// here.
|
// here.
|
||||||
//
|
self.infcx.next_ty_var(origin)
|
||||||
// The ROOT universe is fine because we only
|
|
||||||
// ever invoke this routine at the
|
|
||||||
// "item-level" of inference.
|
|
||||||
self.infcx.next_ty_var(ty::UniverseIndex::ROOT, origin)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,17 +88,13 @@ pub fn super_lattice_tys<'a, 'gcx, 'tcx, L>(this: &mut L,
|
||||||
// is (e.g.) `Box<i32>`. A more obvious solution might be to
|
// is (e.g.) `Box<i32>`. A more obvious solution might be to
|
||||||
// iterate on the subtype obligations that are returned, but I
|
// iterate on the subtype obligations that are returned, but I
|
||||||
// think this suffices. -nmatsakis
|
// think this suffices. -nmatsakis
|
||||||
(&ty::TyInfer(TyVar(a_vid)), _) => {
|
(&ty::TyInfer(TyVar(..)), _) => {
|
||||||
let universe = infcx.type_variables.borrow_mut().probe(a_vid).universe().unwrap();
|
let v = infcx.next_ty_var(TypeVariableOrigin::LatticeVariable(this.cause().span));
|
||||||
let v = infcx.next_ty_var(universe,
|
|
||||||
TypeVariableOrigin::LatticeVariable(this.cause().span));
|
|
||||||
this.relate_bound(v, b, a)?;
|
this.relate_bound(v, b, a)?;
|
||||||
Ok(v)
|
Ok(v)
|
||||||
}
|
}
|
||||||
(_, &ty::TyInfer(TyVar(b_vid))) => {
|
(_, &ty::TyInfer(TyVar(..))) => {
|
||||||
let universe = infcx.type_variables.borrow_mut().probe(b_vid).universe().unwrap();
|
let v = infcx.next_ty_var(TypeVariableOrigin::LatticeVariable(this.cause().span));
|
||||||
let v = infcx.next_ty_var(universe,
|
|
||||||
TypeVariableOrigin::LatticeVariable(this.cause().span));
|
|
||||||
this.relate_bound(v, a, b)?;
|
this.relate_bound(v, a, b)?;
|
||||||
Ok(v)
|
Ok(v)
|
||||||
}
|
}
|
||||||
|
|
|
@ -837,25 +837,18 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn next_ty_var_id(&self,
|
pub fn next_ty_var_id(&self, diverging: bool, origin: TypeVariableOrigin) -> TyVid {
|
||||||
universe: ty::UniverseIndex,
|
|
||||||
diverging: bool,
|
|
||||||
origin: TypeVariableOrigin)
|
|
||||||
-> TyVid {
|
|
||||||
self.type_variables
|
self.type_variables
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
.new_var(universe, diverging, origin)
|
.new_var(diverging, origin)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn next_ty_var(&self, universe: ty::UniverseIndex, origin: TypeVariableOrigin) -> Ty<'tcx> {
|
pub fn next_ty_var(&self, origin: TypeVariableOrigin) -> Ty<'tcx> {
|
||||||
self.tcx.mk_var(self.next_ty_var_id(universe, false, origin))
|
self.tcx.mk_var(self.next_ty_var_id(false, origin))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn next_diverging_ty_var(&self,
|
pub fn next_diverging_ty_var(&self, origin: TypeVariableOrigin) -> Ty<'tcx> {
|
||||||
universe: ty::UniverseIndex,
|
self.tcx.mk_var(self.next_ty_var_id(true, origin))
|
||||||
origin: TypeVariableOrigin)
|
|
||||||
-> Ty<'tcx> {
|
|
||||||
self.tcx.mk_var(self.next_ty_var_id(universe, true, origin))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn next_int_var_id(&self) -> IntVid {
|
pub fn next_int_var_id(&self) -> IntVid {
|
||||||
|
@ -910,14 +903,12 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||||
/// use an inference variable for `C` with `[T, U]`
|
/// use an inference variable for `C` with `[T, U]`
|
||||||
/// as the substitutions for the default, `(T, U)`.
|
/// as the substitutions for the default, `(T, U)`.
|
||||||
pub fn type_var_for_def(&self,
|
pub fn type_var_for_def(&self,
|
||||||
universe: ty::UniverseIndex,
|
|
||||||
span: Span,
|
span: Span,
|
||||||
def: &ty::TypeParameterDef)
|
def: &ty::TypeParameterDef)
|
||||||
-> Ty<'tcx> {
|
-> Ty<'tcx> {
|
||||||
let ty_var_id = self.type_variables
|
let ty_var_id = self.type_variables
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
.new_var(universe,
|
.new_var(false,
|
||||||
false,
|
|
||||||
TypeVariableOrigin::TypeParameterDefinition(span, def.name));
|
TypeVariableOrigin::TypeParameterDefinition(span, def.name));
|
||||||
|
|
||||||
self.tcx.mk_var(ty_var_id)
|
self.tcx.mk_var(ty_var_id)
|
||||||
|
@ -926,14 +917,13 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||||
/// Given a set of generics defined on a type or impl, returns a substitution mapping each
|
/// Given a set of generics defined on a type or impl, returns a substitution mapping each
|
||||||
/// type/region parameter to a fresh inference variable.
|
/// type/region parameter to a fresh inference variable.
|
||||||
pub fn fresh_substs_for_item(&self,
|
pub fn fresh_substs_for_item(&self,
|
||||||
universe: ty::UniverseIndex,
|
|
||||||
span: Span,
|
span: Span,
|
||||||
def_id: DefId)
|
def_id: DefId)
|
||||||
-> &'tcx Substs<'tcx> {
|
-> &'tcx Substs<'tcx> {
|
||||||
Substs::for_item(self.tcx, def_id, |def, _| {
|
Substs::for_item(self.tcx, def_id, |def, _| {
|
||||||
self.region_var_for_def(span, def)
|
self.region_var_for_def(span, def)
|
||||||
}, |def, _| {
|
}, |def, _| {
|
||||||
self.type_var_for_def(universe, span, def)
|
self.type_var_for_def(span, def)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ pub struct RegionConstraintCollector<'tcx> {
|
||||||
glbs: CombineMap<'tcx>,
|
glbs: CombineMap<'tcx>,
|
||||||
|
|
||||||
/// Number of skolemized variables currently active.
|
/// Number of skolemized variables currently active.
|
||||||
skolemization_count: ty::UniverseIndex,
|
skolemization_count: u32,
|
||||||
|
|
||||||
/// Global counter used during the GLB algorithm to create unique
|
/// Global counter used during the GLB algorithm to create unique
|
||||||
/// names for fresh bound regions
|
/// names for fresh bound regions
|
||||||
|
@ -233,7 +233,7 @@ type CombineMap<'tcx> = FxHashMap<TwoRegions<'tcx>, RegionVid>;
|
||||||
pub struct RegionSnapshot {
|
pub struct RegionSnapshot {
|
||||||
length: usize,
|
length: usize,
|
||||||
region_snapshot: ut::Snapshot<ut::InPlace<ty::RegionVid>>,
|
region_snapshot: ut::Snapshot<ut::InPlace<ty::RegionVid>>,
|
||||||
skolemization_count: ty::UniverseIndex,
|
skolemization_count: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// When working with skolemized regions, we often wish to find all of
|
/// When working with skolemized regions, we often wish to find all of
|
||||||
|
@ -277,7 +277,7 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
|
||||||
data: RegionConstraintData::default(),
|
data: RegionConstraintData::default(),
|
||||||
lubs: FxHashMap(),
|
lubs: FxHashMap(),
|
||||||
glbs: FxHashMap(),
|
glbs: FxHashMap(),
|
||||||
skolemization_count: ty::UniverseIndex::ROOT,
|
skolemization_count: 0,
|
||||||
bound_count: 0,
|
bound_count: 0,
|
||||||
undo_log: Vec::new(),
|
undo_log: Vec::new(),
|
||||||
unification_table: ut::UnificationTable::new(),
|
unification_table: ut::UnificationTable::new(),
|
||||||
|
@ -329,7 +329,7 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
|
||||||
unification_table,
|
unification_table,
|
||||||
} = self;
|
} = self;
|
||||||
|
|
||||||
assert_eq!(skolemization_count.as_usize(), 0);
|
assert_eq!(*skolemization_count, 0);
|
||||||
|
|
||||||
// Clear the tables of (lubs, glbs), so that we will create
|
// Clear the tables of (lubs, glbs), so that we will create
|
||||||
// fresh regions if we do a LUB operation. As it happens,
|
// fresh regions if we do a LUB operation. As it happens,
|
||||||
|
@ -375,7 +375,7 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
|
||||||
assert!(self.undo_log[snapshot.length] == OpenSnapshot);
|
assert!(self.undo_log[snapshot.length] == OpenSnapshot);
|
||||||
assert!(
|
assert!(
|
||||||
self.skolemization_count == snapshot.skolemization_count,
|
self.skolemization_count == snapshot.skolemization_count,
|
||||||
"failed to pop skolemized regions: {:?} now vs {:?} at start",
|
"failed to pop skolemized regions: {} now vs {} at start",
|
||||||
self.skolemization_count,
|
self.skolemization_count,
|
||||||
snapshot.skolemization_count
|
snapshot.skolemization_count
|
||||||
);
|
);
|
||||||
|
@ -485,9 +485,9 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
|
||||||
assert!(self.in_snapshot());
|
assert!(self.in_snapshot());
|
||||||
assert!(self.undo_log[snapshot.length] == OpenSnapshot);
|
assert!(self.undo_log[snapshot.length] == OpenSnapshot);
|
||||||
|
|
||||||
let universe = self.skolemization_count.subuniverse();
|
let sc = self.skolemization_count;
|
||||||
self.skolemization_count = universe;
|
self.skolemization_count = sc + 1;
|
||||||
tcx.mk_region(ReSkolemized(universe, br))
|
tcx.mk_region(ReSkolemized(ty::SkolemizedRegionVid { index: sc }, br))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Removes all the edges to/from the skolemized regions that are
|
/// Removes all the edges to/from the skolemized regions that are
|
||||||
|
@ -505,20 +505,20 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
|
||||||
assert!(self.in_snapshot());
|
assert!(self.in_snapshot());
|
||||||
assert!(self.undo_log[snapshot.length] == OpenSnapshot);
|
assert!(self.undo_log[snapshot.length] == OpenSnapshot);
|
||||||
assert!(
|
assert!(
|
||||||
self.skolemization_count.as_usize() >= skols.len(),
|
self.skolemization_count as usize >= skols.len(),
|
||||||
"popping more skolemized variables than actually exist, \
|
"popping more skolemized variables than actually exist, \
|
||||||
sc now = {}, skols.len = {}",
|
sc now = {}, skols.len = {}",
|
||||||
self.skolemization_count.as_usize(),
|
self.skolemization_count,
|
||||||
skols.len()
|
skols.len()
|
||||||
);
|
);
|
||||||
|
|
||||||
let last_to_pop = self.skolemization_count.subuniverse();
|
let last_to_pop = self.skolemization_count;
|
||||||
let first_to_pop = ty::UniverseIndex::from(last_to_pop.as_u32() - (skols.len() as u32));
|
let first_to_pop = last_to_pop - (skols.len() as u32);
|
||||||
|
|
||||||
assert!(
|
assert!(
|
||||||
first_to_pop >= snapshot.skolemization_count,
|
first_to_pop >= snapshot.skolemization_count,
|
||||||
"popping more regions than snapshot contains, \
|
"popping more regions than snapshot contains, \
|
||||||
sc now = {:?}, sc then = {:?}, skols.len = {}",
|
sc now = {}, sc then = {}, skols.len = {}",
|
||||||
self.skolemization_count,
|
self.skolemization_count,
|
||||||
snapshot.skolemization_count,
|
snapshot.skolemization_count,
|
||||||
skols.len()
|
skols.len()
|
||||||
|
@ -526,13 +526,13 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
|
||||||
debug_assert! {
|
debug_assert! {
|
||||||
skols.iter()
|
skols.iter()
|
||||||
.all(|&k| match *k {
|
.all(|&k| match *k {
|
||||||
ty::ReSkolemized(universe, _) =>
|
ty::ReSkolemized(index, _) =>
|
||||||
universe >= first_to_pop &&
|
index.index >= first_to_pop &&
|
||||||
universe < last_to_pop,
|
index.index < last_to_pop,
|
||||||
_ =>
|
_ =>
|
||||||
false
|
false
|
||||||
}),
|
}),
|
||||||
"invalid skolemization keys or keys out of range ({:?}..{:?}): {:?}",
|
"invalid skolemization keys or keys out of range ({}..{}): {:?}",
|
||||||
snapshot.skolemization_count,
|
snapshot.skolemization_count,
|
||||||
self.skolemization_count,
|
self.skolemization_count,
|
||||||
skols
|
skols
|
||||||
|
@ -867,7 +867,7 @@ impl fmt::Debug for RegionSnapshot {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
write!(
|
write!(
|
||||||
f,
|
f,
|
||||||
"RegionSnapshot(length={},skolemization={:?})",
|
"RegionSnapshot(length={},skolemization={})",
|
||||||
self.length,
|
self.length,
|
||||||
self.skolemization_count
|
self.skolemization_count
|
||||||
)
|
)
|
||||||
|
|
|
@ -78,18 +78,10 @@ struct TypeVariableData {
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub enum TypeVariableValue<'tcx> {
|
pub enum TypeVariableValue<'tcx> {
|
||||||
Known { value: Ty<'tcx> },
|
Known { value: Ty<'tcx> },
|
||||||
Unknown { universe: ty::UniverseIndex },
|
Unknown,
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug)]
|
|
||||||
pub enum ProbeTyValue<'tcx> {
|
|
||||||
Ty(Ty<'tcx>),
|
|
||||||
Vid(ty::TyVid),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> TypeVariableValue<'tcx> {
|
impl<'tcx> TypeVariableValue<'tcx> {
|
||||||
/// If this value is known, returns the type it is known to be.
|
|
||||||
/// Otherwise, `None`.
|
|
||||||
pub fn known(&self) -> Option<Ty<'tcx>> {
|
pub fn known(&self) -> Option<Ty<'tcx>> {
|
||||||
match *self {
|
match *self {
|
||||||
TypeVariableValue::Unknown { .. } => None,
|
TypeVariableValue::Unknown { .. } => None,
|
||||||
|
@ -97,14 +89,6 @@ impl<'tcx> TypeVariableValue<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// If this value is unknown, returns the universe, otherwise `None`.
|
|
||||||
pub fn universe(&self) -> Option<ty::UniverseIndex> {
|
|
||||||
match *self {
|
|
||||||
TypeVariableValue::Unknown { universe } => Some(universe),
|
|
||||||
TypeVariableValue::Known { .. } => None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn is_unknown(&self) -> bool {
|
pub fn is_unknown(&self) -> bool {
|
||||||
match *self {
|
match *self {
|
||||||
TypeVariableValue::Unknown { .. } => true,
|
TypeVariableValue::Unknown { .. } => true,
|
||||||
|
@ -197,11 +181,10 @@ impl<'tcx> TypeVariableTable<'tcx> {
|
||||||
/// The code in this module doesn't care, but it can be useful
|
/// The code in this module doesn't care, but it can be useful
|
||||||
/// for improving error messages.
|
/// for improving error messages.
|
||||||
pub fn new_var(&mut self,
|
pub fn new_var(&mut self,
|
||||||
universe: ty::UniverseIndex,
|
|
||||||
diverging: bool,
|
diverging: bool,
|
||||||
origin: TypeVariableOrigin)
|
origin: TypeVariableOrigin)
|
||||||
-> ty::TyVid {
|
-> ty::TyVid {
|
||||||
let eq_key = self.eq_relations.new_key(TypeVariableValue::Unknown { universe });
|
let eq_key = self.eq_relations.new_key(TypeVariableValue::Unknown);
|
||||||
|
|
||||||
let sub_key = self.sub_relations.new_key(());
|
let sub_key = self.sub_relations.new_key(());
|
||||||
assert_eq!(eq_key.vid, sub_key);
|
assert_eq!(eq_key.vid, sub_key);
|
||||||
|
@ -453,12 +436,8 @@ impl<'tcx> ut::UnifyValue for TypeVariableValue<'tcx> {
|
||||||
(&TypeVariableValue::Known { .. }, &TypeVariableValue::Unknown { .. }) => Ok(*value1),
|
(&TypeVariableValue::Known { .. }, &TypeVariableValue::Unknown { .. }) => Ok(*value1),
|
||||||
(&TypeVariableValue::Unknown { .. }, &TypeVariableValue::Known { .. }) => Ok(*value2),
|
(&TypeVariableValue::Unknown { .. }, &TypeVariableValue::Known { .. }) => Ok(*value2),
|
||||||
|
|
||||||
// If both sides are unknown, we need to pick the most restrictive universe.
|
// If both sides are *unknown*, it hardly matters, does it?
|
||||||
(&TypeVariableValue::Unknown { universe: universe1 },
|
(&TypeVariableValue::Unknown, &TypeVariableValue::Unknown) => Ok(*value1),
|
||||||
&TypeVariableValue::Unknown { universe: universe2 }) => {
|
|
||||||
let universe = cmp::min(universe1, universe2);
|
|
||||||
Ok(TypeVariableValue::Unknown { universe })
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,9 +92,7 @@ fn with_fresh_ty_vars<'cx, 'gcx, 'tcx>(selcx: &mut SelectionContext<'cx, 'gcx, '
|
||||||
-> ty::ImplHeader<'tcx>
|
-> ty::ImplHeader<'tcx>
|
||||||
{
|
{
|
||||||
let tcx = selcx.tcx();
|
let tcx = selcx.tcx();
|
||||||
let impl_substs = selcx.infcx().fresh_substs_for_item(param_env.universe,
|
let impl_substs = selcx.infcx().fresh_substs_for_item(DUMMY_SP, impl_def_id);
|
||||||
DUMMY_SP,
|
|
||||||
impl_def_id);
|
|
||||||
|
|
||||||
let header = ty::ImplHeader {
|
let header = ty::ImplHeader {
|
||||||
impl_def_id,
|
impl_def_id,
|
||||||
|
|
|
@ -292,9 +292,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||||
|
|
||||||
self.tcx.for_each_relevant_impl(
|
self.tcx.for_each_relevant_impl(
|
||||||
trait_ref.def_id, trait_self_ty, |def_id| {
|
trait_ref.def_id, trait_self_ty, |def_id| {
|
||||||
let impl_substs = self.fresh_substs_for_item(param_env.universe,
|
let impl_substs = self.fresh_substs_for_item(obligation.cause.span, def_id);
|
||||||
obligation.cause.span,
|
|
||||||
def_id);
|
|
||||||
let impl_trait_ref = tcx
|
let impl_trait_ref = tcx
|
||||||
.impl_trait_ref(def_id)
|
.impl_trait_ref(def_id)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -1285,7 +1283,6 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||||
-> bool {
|
-> bool {
|
||||||
struct ParamToVarFolder<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
|
struct ParamToVarFolder<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
|
||||||
infcx: &'a InferCtxt<'a, 'gcx, 'tcx>,
|
infcx: &'a InferCtxt<'a, 'gcx, 'tcx>,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
|
||||||
var_map: FxHashMap<Ty<'tcx>, Ty<'tcx>>
|
var_map: FxHashMap<Ty<'tcx>, Ty<'tcx>>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1295,14 +1292,9 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||||
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||||
if let ty::TyParam(ty::ParamTy {name, ..}) = ty.sty {
|
if let ty::TyParam(ty::ParamTy {name, ..}) = ty.sty {
|
||||||
let infcx = self.infcx;
|
let infcx = self.infcx;
|
||||||
let param_env = self.param_env;
|
self.var_map.entry(ty).or_insert_with(||
|
||||||
self.var_map
|
infcx.next_ty_var(
|
||||||
.entry(ty)
|
TypeVariableOrigin::TypeParameterDefinition(DUMMY_SP, name)))
|
||||||
.or_insert_with(|| {
|
|
||||||
let origin = TypeVariableOrigin::TypeParameterDefinition(DUMMY_SP,
|
|
||||||
name);
|
|
||||||
infcx.next_ty_var(param_env.universe, origin)
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
ty.super_fold_with(self)
|
ty.super_fold_with(self)
|
||||||
}
|
}
|
||||||
|
@ -1314,7 +1306,6 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||||
|
|
||||||
let cleaned_pred = pred.fold_with(&mut ParamToVarFolder {
|
let cleaned_pred = pred.fold_with(&mut ParamToVarFolder {
|
||||||
infcx: self,
|
infcx: self,
|
||||||
param_env,
|
|
||||||
var_map: FxHashMap()
|
var_map: FxHashMap()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -612,8 +612,7 @@ pub fn normalize_param_env_or_error<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
predicates);
|
predicates);
|
||||||
|
|
||||||
let elaborated_env = ty::ParamEnv::new(tcx.intern_predicates(&predicates),
|
let elaborated_env = ty::ParamEnv::new(tcx.intern_predicates(&predicates),
|
||||||
unnormalized_env.reveal,
|
unnormalized_env.reveal);
|
||||||
unnormalized_env.universe);
|
|
||||||
|
|
||||||
tcx.infer_ctxt().enter(|infcx| {
|
tcx.infer_ctxt().enter(|infcx| {
|
||||||
// FIXME. We should really... do something with these region
|
// FIXME. We should really... do something with these region
|
||||||
|
@ -687,9 +686,7 @@ pub fn normalize_param_env_or_error<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
debug!("normalize_param_env_or_error: resolved predicates={:?}",
|
debug!("normalize_param_env_or_error: resolved predicates={:?}",
|
||||||
predicates);
|
predicates);
|
||||||
|
|
||||||
ty::ParamEnv::new(tcx.intern_predicates(&predicates),
|
ty::ParamEnv::new(tcx.intern_predicates(&predicates), unnormalized_env.reveal)
|
||||||
unnormalized_env.reveal,
|
|
||||||
unnormalized_env.universe)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -477,7 +477,6 @@ pub fn normalize_projection_type<'a, 'b, 'gcx, 'tcx>(
|
||||||
let tcx = selcx.infcx().tcx;
|
let tcx = selcx.infcx().tcx;
|
||||||
let def_id = projection_ty.item_def_id;
|
let def_id = projection_ty.item_def_id;
|
||||||
let ty_var = selcx.infcx().next_ty_var(
|
let ty_var = selcx.infcx().next_ty_var(
|
||||||
param_env.universe,
|
|
||||||
TypeVariableOrigin::NormalizeProjectionType(tcx.def_span(def_id)));
|
TypeVariableOrigin::NormalizeProjectionType(tcx.def_span(def_id)));
|
||||||
let projection = ty::Binder(ty::ProjectionPredicate {
|
let projection = ty::Binder(ty::ProjectionPredicate {
|
||||||
projection_ty,
|
projection_ty,
|
||||||
|
@ -798,7 +797,6 @@ fn normalize_to_error<'a, 'gcx, 'tcx>(selcx: &mut SelectionContext<'a, 'gcx, 'tc
|
||||||
let tcx = selcx.infcx().tcx;
|
let tcx = selcx.infcx().tcx;
|
||||||
let def_id = projection_ty.item_def_id;
|
let def_id = projection_ty.item_def_id;
|
||||||
let new_value = selcx.infcx().next_ty_var(
|
let new_value = selcx.infcx().next_ty_var(
|
||||||
param_env.universe,
|
|
||||||
TypeVariableOrigin::NormalizeProjectionType(tcx.def_span(def_id)));
|
TypeVariableOrigin::NormalizeProjectionType(tcx.def_span(def_id)));
|
||||||
Normalized {
|
Normalized {
|
||||||
value: new_value,
|
value: new_value,
|
||||||
|
|
|
@ -3040,8 +3040,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
||||||
snapshot);
|
snapshot);
|
||||||
let skol_obligation_trait_ref = skol_obligation.trait_ref;
|
let skol_obligation_trait_ref = skol_obligation.trait_ref;
|
||||||
|
|
||||||
let impl_substs = self.infcx.fresh_substs_for_item(obligation.param_env.universe,
|
let impl_substs = self.infcx.fresh_substs_for_item(obligation.cause.span,
|
||||||
obligation.cause.span,
|
|
||||||
impl_def_id);
|
impl_def_id);
|
||||||
|
|
||||||
let impl_trait_ref = impl_trait_ref.subst(self.tcx(),
|
let impl_trait_ref = impl_trait_ref.subst(self.tcx(),
|
||||||
|
|
|
@ -221,7 +221,7 @@ fn fulfill_implication<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>,
|
||||||
target_impl: DefId)
|
target_impl: DefId)
|
||||||
-> Result<&'tcx Substs<'tcx>, ()> {
|
-> Result<&'tcx Substs<'tcx>, ()> {
|
||||||
let selcx = &mut SelectionContext::new(&infcx);
|
let selcx = &mut SelectionContext::new(&infcx);
|
||||||
let target_substs = infcx.fresh_substs_for_item(param_env.universe, DUMMY_SP, target_impl);
|
let target_substs = infcx.fresh_substs_for_item(DUMMY_SP, target_impl);
|
||||||
let (target_trait_ref, mut obligations) = impl_trait_ref_and_oblig(selcx,
|
let (target_trait_ref, mut obligations) = impl_trait_ref_and_oblig(selcx,
|
||||||
param_env,
|
param_env,
|
||||||
target_impl,
|
target_impl,
|
||||||
|
|
|
@ -69,7 +69,7 @@ pub use self::sty::{ExistentialTraitRef, PolyExistentialTraitRef};
|
||||||
pub use self::sty::{ExistentialProjection, PolyExistentialProjection, Const};
|
pub use self::sty::{ExistentialProjection, PolyExistentialProjection, Const};
|
||||||
pub use self::sty::{BoundRegion, EarlyBoundRegion, FreeRegion, Region};
|
pub use self::sty::{BoundRegion, EarlyBoundRegion, FreeRegion, Region};
|
||||||
pub use self::sty::RegionKind;
|
pub use self::sty::RegionKind;
|
||||||
pub use self::sty::{TyVid, IntVid, FloatVid, RegionVid};
|
pub use self::sty::{TyVid, IntVid, FloatVid, RegionVid, SkolemizedRegionVid};
|
||||||
pub use self::sty::BoundRegion::*;
|
pub use self::sty::BoundRegion::*;
|
||||||
pub use self::sty::InferTy::*;
|
pub use self::sty::InferTy::*;
|
||||||
pub use self::sty::RegionKind::*;
|
pub use self::sty::RegionKind::*;
|
||||||
|
@ -1344,13 +1344,15 @@ impl<'tcx> InstantiatedPredicates<'tcx> {
|
||||||
/// type name in a non-zero universe is a skolemized type -- an
|
/// type name in a non-zero universe is a skolemized type -- an
|
||||||
/// idealized representative of "types in general" that we use for
|
/// idealized representative of "types in general" that we use for
|
||||||
/// checking generic functions.
|
/// checking generic functions.
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
pub struct UniverseIndex(u32);
|
pub struct UniverseIndex(u32);
|
||||||
|
|
||||||
impl UniverseIndex {
|
impl UniverseIndex {
|
||||||
/// The root universe, where things that the user defined are
|
/// The root universe, where things that the user defined are
|
||||||
/// visible.
|
/// visible.
|
||||||
pub const ROOT: UniverseIndex = UniverseIndex(0);
|
pub fn root() -> UniverseIndex {
|
||||||
|
UniverseIndex(0)
|
||||||
|
}
|
||||||
|
|
||||||
/// A "subuniverse" corresponds to being inside a `forall` quantifier.
|
/// A "subuniverse" corresponds to being inside a `forall` quantifier.
|
||||||
/// So, for example, suppose we have this type in universe `U`:
|
/// So, for example, suppose we have this type in universe `U`:
|
||||||
|
@ -1364,26 +1366,7 @@ impl UniverseIndex {
|
||||||
/// region `'a`, but that region was not nameable from `U` because
|
/// region `'a`, but that region was not nameable from `U` because
|
||||||
/// it was not in scope there.
|
/// it was not in scope there.
|
||||||
pub fn subuniverse(self) -> UniverseIndex {
|
pub fn subuniverse(self) -> UniverseIndex {
|
||||||
UniverseIndex(self.0.checked_add(1).unwrap())
|
UniverseIndex(self.0 + 1)
|
||||||
}
|
|
||||||
|
|
||||||
pub fn from(v: u32) -> UniverseIndex {
|
|
||||||
UniverseIndex(v)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn as_u32(&self) -> u32 {
|
|
||||||
self.0
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn as_usize(&self) -> usize {
|
|
||||||
self.0 as usize
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Gets the "depth" of this universe in the universe tree. This
|
|
||||||
/// is not really useful except for e.g. the `HashStable`
|
|
||||||
/// implementation
|
|
||||||
pub fn depth(&self) -> u32 {
|
|
||||||
self.0
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1401,17 +1384,6 @@ pub struct ParamEnv<'tcx> {
|
||||||
/// want `Reveal::All` -- note that this is always paired with an
|
/// want `Reveal::All` -- note that this is always paired with an
|
||||||
/// empty environment. To get that, use `ParamEnv::reveal()`.
|
/// empty environment. To get that, use `ParamEnv::reveal()`.
|
||||||
pub reveal: traits::Reveal,
|
pub reveal: traits::Reveal,
|
||||||
|
|
||||||
/// What is the innermost universe we have created? Starts out as
|
|
||||||
/// `UniverseIndex::root()` but grows from there as we enter
|
|
||||||
/// universal quantifiers.
|
|
||||||
///
|
|
||||||
/// NB: At present, we exclude the universal quantifiers on the
|
|
||||||
/// item we are type-checking, and just consider those names as
|
|
||||||
/// part of the root universe. So this would only get incremented
|
|
||||||
/// when we enter into a higher-ranked (`for<..>`) type or trait
|
|
||||||
/// bound.
|
|
||||||
pub universe: UniverseIndex,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> ParamEnv<'tcx> {
|
impl<'tcx> ParamEnv<'tcx> {
|
||||||
|
@ -1420,7 +1392,7 @@ impl<'tcx> ParamEnv<'tcx> {
|
||||||
/// Trait`) are left hidden, so this is suitable for ordinary
|
/// Trait`) are left hidden, so this is suitable for ordinary
|
||||||
/// type-checking.
|
/// type-checking.
|
||||||
pub fn empty() -> Self {
|
pub fn empty() -> Self {
|
||||||
Self::new(ty::Slice::empty(), Reveal::UserFacing, ty::UniverseIndex::ROOT)
|
Self::new(ty::Slice::empty(), Reveal::UserFacing)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Construct a trait environment with no where clauses in scope
|
/// Construct a trait environment with no where clauses in scope
|
||||||
|
@ -1431,15 +1403,14 @@ impl<'tcx> ParamEnv<'tcx> {
|
||||||
/// NB. If you want to have predicates in scope, use `ParamEnv::new`,
|
/// NB. If you want to have predicates in scope, use `ParamEnv::new`,
|
||||||
/// or invoke `param_env.with_reveal_all()`.
|
/// or invoke `param_env.with_reveal_all()`.
|
||||||
pub fn reveal_all() -> Self {
|
pub fn reveal_all() -> Self {
|
||||||
Self::new(ty::Slice::empty(), Reveal::All, ty::UniverseIndex::ROOT)
|
Self::new(ty::Slice::empty(), Reveal::All)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Construct a trait environment with the given set of predicates.
|
/// Construct a trait environment with the given set of predicates.
|
||||||
pub fn new(caller_bounds: &'tcx ty::Slice<ty::Predicate<'tcx>>,
|
pub fn new(caller_bounds: &'tcx ty::Slice<ty::Predicate<'tcx>>,
|
||||||
reveal: Reveal,
|
reveal: Reveal)
|
||||||
universe: ty::UniverseIndex)
|
|
||||||
-> Self {
|
-> Self {
|
||||||
ty::ParamEnv { caller_bounds, reveal, universe }
|
ty::ParamEnv { caller_bounds, reveal }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a new parameter environment with the same clauses, but
|
/// Returns a new parameter environment with the same clauses, but
|
||||||
|
@ -2731,8 +2702,7 @@ fn param_env<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
// sure that this will succeed without errors anyway.
|
// sure that this will succeed without errors anyway.
|
||||||
|
|
||||||
let unnormalized_env = ty::ParamEnv::new(tcx.intern_predicates(&predicates),
|
let unnormalized_env = ty::ParamEnv::new(tcx.intern_predicates(&predicates),
|
||||||
traits::Reveal::UserFacing,
|
traits::Reveal::UserFacing);
|
||||||
ty::UniverseIndex::ROOT);
|
|
||||||
|
|
||||||
let body_id = tcx.hir.as_local_node_id(def_id).map_or(DUMMY_NODE_ID, |id| {
|
let body_id = tcx.hir.as_local_node_id(def_id).map_or(DUMMY_NODE_ID, |id| {
|
||||||
tcx.hir.maybe_body_owned_by(id).map_or(id, |body| body.node_id)
|
tcx.hir.maybe_body_owned_by(id).map_or(id, |body| body.node_id)
|
||||||
|
|
|
@ -280,7 +280,6 @@ impl<'a, 'tcx> Lift<'tcx> for ty::ParamEnv<'a> {
|
||||||
tcx.lift(&self.caller_bounds).map(|caller_bounds| {
|
tcx.lift(&self.caller_bounds).map(|caller_bounds| {
|
||||||
ty::ParamEnv {
|
ty::ParamEnv {
|
||||||
reveal: self.reveal,
|
reveal: self.reveal,
|
||||||
universe: self.universe,
|
|
||||||
caller_bounds,
|
caller_bounds,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -738,29 +737,8 @@ impl<'tcx, T:TypeFoldable<'tcx>> TypeFoldable<'tcx> for ty::Binder<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> TypeFoldable<'tcx> for ty::ParamEnv<'tcx> {
|
BraceStructTypeFoldableImpl! {
|
||||||
fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self {
|
impl<'tcx> TypeFoldable<'tcx> for ty::ParamEnv<'tcx> { reveal, caller_bounds }
|
||||||
ty::ParamEnv {
|
|
||||||
reveal: self.reveal,
|
|
||||||
caller_bounds: self.caller_bounds.fold_with(folder),
|
|
||||||
universe: self.universe.fold_with(folder),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
|
|
||||||
let &ty::ParamEnv { reveal: _, ref universe, ref caller_bounds } = self;
|
|
||||||
universe.super_visit_with(visitor) || caller_bounds.super_visit_with(visitor)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'tcx> TypeFoldable<'tcx> for ty::UniverseIndex {
|
|
||||||
fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, _folder: &mut F) -> Self {
|
|
||||||
*self
|
|
||||||
}
|
|
||||||
|
|
||||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, _visitor: &mut V) -> bool {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::Slice<ty::ExistentialPredicate<'tcx>> {
|
impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::Slice<ty::ExistentialPredicate<'tcx>> {
|
||||||
|
|
|
@ -1028,7 +1028,7 @@ pub enum RegionKind {
|
||||||
|
|
||||||
/// A skolemized region - basically the higher-ranked version of ReFree.
|
/// A skolemized region - basically the higher-ranked version of ReFree.
|
||||||
/// Should not exist after typeck.
|
/// Should not exist after typeck.
|
||||||
ReSkolemized(ty::UniverseIndex, BoundRegion),
|
ReSkolemized(SkolemizedRegionVid, BoundRegion),
|
||||||
|
|
||||||
/// Empty lifetime is for data that is never accessed.
|
/// Empty lifetime is for data that is never accessed.
|
||||||
/// Bottom in the region lattice. We treat ReEmpty somewhat
|
/// Bottom in the region lattice. We treat ReEmpty somewhat
|
||||||
|
@ -1082,6 +1082,11 @@ newtype_index!(RegionVid
|
||||||
DEBUG_FORMAT = custom,
|
DEBUG_FORMAT = custom,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, PartialOrd, Ord)]
|
||||||
|
pub struct SkolemizedRegionVid {
|
||||||
|
pub index: u32,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)]
|
#[derive(Clone, Copy, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)]
|
||||||
pub enum InferTy {
|
pub enum InferTy {
|
||||||
TyVar(TyVid),
|
TyVar(TyVid),
|
||||||
|
|
|
@ -793,7 +793,7 @@ define_print! {
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::ReSkolemized(id, ref bound_region) => {
|
ty::ReSkolemized(id, ref bound_region) => {
|
||||||
write!(f, "ReSkolemized({:?}, {:?})", id, bound_region)
|
write!(f, "ReSkolemized({}, {:?})", id.index, bound_region)
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::ReEmpty => write!(f, "ReEmpty"),
|
ty::ReEmpty => write!(f, "ReEmpty"),
|
||||||
|
|
|
@ -455,8 +455,7 @@ fn sub_free_bound_false_infer() {
|
||||||
//! does NOT hold for any instantiation of `_#1`.
|
//! does NOT hold for any instantiation of `_#1`.
|
||||||
|
|
||||||
test_env(EMPTY_SOURCE_STR, errors(&[]), |env| {
|
test_env(EMPTY_SOURCE_STR, errors(&[]), |env| {
|
||||||
let t_infer1 = env.infcx.next_ty_var(ty::UniverseIndex::ROOT,
|
let t_infer1 = env.infcx.next_ty_var(TypeVariableOrigin::MiscVariable(DUMMY_SP));
|
||||||
TypeVariableOrigin::MiscVariable(DUMMY_SP));
|
|
||||||
let t_rptr_bound1 = env.t_rptr_late_bound(1);
|
let t_rptr_bound1 = env.t_rptr_late_bound(1);
|
||||||
env.check_not_sub(env.t_fn(&[t_infer1], env.tcx().types.isize),
|
env.check_not_sub(env.t_fn(&[t_infer1], env.tcx().types.isize),
|
||||||
env.t_fn(&[t_rptr_bound1], env.tcx().types.isize));
|
env.t_fn(&[t_rptr_bound1], env.tcx().types.isize));
|
||||||
|
|
|
@ -296,7 +296,6 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
let element_tys_iter = (0..max_len).map(|_| self.next_ty_var(
|
let element_tys_iter = (0..max_len).map(|_| self.next_ty_var(
|
||||||
// FIXME: MiscVariable for now, obtaining the span and name information
|
// FIXME: MiscVariable for now, obtaining the span and name information
|
||||||
// from all tuple elements isn't trivial.
|
// from all tuple elements isn't trivial.
|
||||||
ty::UniverseIndex::ROOT,
|
|
||||||
TypeVariableOrigin::TypeInference(pat.span)));
|
TypeVariableOrigin::TypeInference(pat.span)));
|
||||||
let element_tys = tcx.mk_type_list(element_tys_iter);
|
let element_tys = tcx.mk_type_list(element_tys_iter);
|
||||||
let pat_ty = tcx.mk_ty(ty::TyTuple(element_tys));
|
let pat_ty = tcx.mk_ty(ty::TyTuple(element_tys));
|
||||||
|
@ -307,8 +306,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
pat_ty
|
pat_ty
|
||||||
}
|
}
|
||||||
PatKind::Box(ref inner) => {
|
PatKind::Box(ref inner) => {
|
||||||
let inner_ty = self.next_ty_var(ty::UniverseIndex::ROOT,
|
let inner_ty = self.next_ty_var(TypeVariableOrigin::TypeInference(inner.span));
|
||||||
TypeVariableOrigin::TypeInference(inner.span));
|
|
||||||
let uniq_ty = tcx.mk_box(inner_ty);
|
let uniq_ty = tcx.mk_box(inner_ty);
|
||||||
|
|
||||||
if self.check_dereferencable(pat.span, expected, &inner) {
|
if self.check_dereferencable(pat.span, expected, &inner) {
|
||||||
|
@ -341,7 +339,6 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
let inner_ty = self.next_ty_var(
|
let inner_ty = self.next_ty_var(
|
||||||
ty::UniverseIndex::ROOT,
|
|
||||||
TypeVariableOrigin::TypeInference(inner.span));
|
TypeVariableOrigin::TypeInference(inner.span));
|
||||||
let mt = ty::TypeAndMut { ty: inner_ty, mutbl: mutbl };
|
let mt = ty::TypeAndMut { ty: inner_ty, mutbl: mutbl };
|
||||||
let region = self.next_region_var(infer::PatternRegion(pat.span));
|
let region = self.next_region_var(infer::PatternRegion(pat.span));
|
||||||
|
@ -600,8 +597,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
|
||||||
// ...but otherwise we want to use any supertype of the
|
// ...but otherwise we want to use any supertype of the
|
||||||
// discriminant. This is sort of a workaround, see note (*) in
|
// discriminant. This is sort of a workaround, see note (*) in
|
||||||
// `check_pat` for some details.
|
// `check_pat` for some details.
|
||||||
discrim_ty = self.next_ty_var(ty::UniverseIndex::ROOT,
|
discrim_ty = self.next_ty_var(TypeVariableOrigin::TypeInference(discrim.span));
|
||||||
TypeVariableOrigin::TypeInference(discrim.span));
|
|
||||||
self.check_expr_has_type_or_error(discrim, discrim_ty);
|
self.check_expr_has_type_or_error(discrim, discrim_ty);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -662,8 +658,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
|
||||||
// arm for inconsistent arms or to the whole match when a `()` type
|
// arm for inconsistent arms or to the whole match when a `()` type
|
||||||
// is required).
|
// is required).
|
||||||
Expectation::ExpectHasType(ety) if ety != self.tcx.mk_nil() => ety,
|
Expectation::ExpectHasType(ety) if ety != self.tcx.mk_nil() => ety,
|
||||||
_ => self.next_ty_var(ty::UniverseIndex::ROOT,
|
_ => self.next_ty_var(TypeVariableOrigin::MiscVariable(expr.span)),
|
||||||
TypeVariableOrigin::MiscVariable(expr.span)),
|
|
||||||
};
|
};
|
||||||
CoerceMany::with_coercion_sites(coerce_first, arms)
|
CoerceMany::with_coercion_sites(coerce_first, arms)
|
||||||
};
|
};
|
||||||
|
|
|
@ -110,8 +110,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
|_, _| span_bug!(expr.span, "closure has region param"),
|
|_, _| span_bug!(expr.span, "closure has region param"),
|
||||||
|_, _| {
|
|_, _| {
|
||||||
self.infcx
|
self.infcx
|
||||||
.next_ty_var(ty::UniverseIndex::ROOT,
|
.next_ty_var(TypeVariableOrigin::ClosureSynthetic(expr.span))
|
||||||
TypeVariableOrigin::ClosureSynthetic(expr.span))
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
let substs = ty::ClosureSubsts { substs };
|
let substs = ty::ClosureSubsts { substs };
|
||||||
|
|
|
@ -176,7 +176,6 @@ impl<'f, 'gcx, 'tcx> Coerce<'f, 'gcx, 'tcx> {
|
||||||
// micro-optimization: no need for this if `b` is
|
// micro-optimization: no need for this if `b` is
|
||||||
// already resolved in some way.
|
// already resolved in some way.
|
||||||
let diverging_ty = self.next_diverging_ty_var(
|
let diverging_ty = self.next_diverging_ty_var(
|
||||||
ty::UniverseIndex::ROOT,
|
|
||||||
TypeVariableOrigin::AdjustmentType(self.cause.span));
|
TypeVariableOrigin::AdjustmentType(self.cause.span));
|
||||||
self.unify_and(&b, &diverging_ty, simple(Adjust::NeverToAny))
|
self.unify_and(&b, &diverging_ty, simple(Adjust::NeverToAny))
|
||||||
} else {
|
} else {
|
||||||
|
@ -510,7 +509,7 @@ impl<'f, 'gcx, 'tcx> Coerce<'f, 'gcx, 'tcx> {
|
||||||
// We only have the latter, so we use an inference variable
|
// We only have the latter, so we use an inference variable
|
||||||
// for the former and let type inference do the rest.
|
// for the former and let type inference do the rest.
|
||||||
let origin = TypeVariableOrigin::MiscVariable(self.cause.span);
|
let origin = TypeVariableOrigin::MiscVariable(self.cause.span);
|
||||||
let coerce_target = self.next_ty_var(ty::UniverseIndex::ROOT, origin);
|
let coerce_target = self.next_ty_var(origin);
|
||||||
let mut coercion = self.unify_and(coerce_target, target, |target| {
|
let mut coercion = self.unify_and(coerce_target, target, |target| {
|
||||||
let unsize = Adjustment {
|
let unsize = Adjustment {
|
||||||
kind: Adjust::Unsize,
|
kind: Adjust::Unsize,
|
||||||
|
|
|
@ -218,8 +218,7 @@ fn compare_predicate_entailment<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
// the new hybrid bounds we computed.
|
// the new hybrid bounds we computed.
|
||||||
let normalize_cause = traits::ObligationCause::misc(impl_m_span, impl_m_node_id);
|
let normalize_cause = traits::ObligationCause::misc(impl_m_span, impl_m_node_id);
|
||||||
let param_env = ty::ParamEnv::new(tcx.intern_predicates(&hybrid_preds.predicates),
|
let param_env = ty::ParamEnv::new(tcx.intern_predicates(&hybrid_preds.predicates),
|
||||||
Reveal::UserFacing,
|
Reveal::UserFacing);
|
||||||
ty::UniverseIndex::ROOT);
|
|
||||||
let param_env = traits::normalize_param_env_or_error(tcx,
|
let param_env = traits::normalize_param_env_or_error(tcx,
|
||||||
impl_m.def_id,
|
impl_m.def_id,
|
||||||
param_env,
|
param_env,
|
||||||
|
|
|
@ -90,7 +90,7 @@ fn ensure_drop_params_and_item_params_correspond<'a, 'tcx>(
|
||||||
|
|
||||||
let drop_impl_span = tcx.def_span(drop_impl_did);
|
let drop_impl_span = tcx.def_span(drop_impl_did);
|
||||||
let fresh_impl_substs =
|
let fresh_impl_substs =
|
||||||
infcx.fresh_substs_for_item(ty::UniverseIndex::ROOT, drop_impl_span, drop_impl_did);
|
infcx.fresh_substs_for_item(drop_impl_span, drop_impl_did);
|
||||||
let fresh_impl_self_ty = drop_impl_ty.subst(tcx, fresh_impl_substs);
|
let fresh_impl_self_ty = drop_impl_ty.subst(tcx, fresh_impl_substs);
|
||||||
|
|
||||||
let cause = &ObligationCause::misc(drop_impl_span, drop_impl_node_id);
|
let cause = &ObligationCause::misc(drop_impl_span, drop_impl_node_id);
|
||||||
|
|
|
@ -259,7 +259,7 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {
|
||||||
// the process we will unify the transformed-self-type
|
// the process we will unify the transformed-self-type
|
||||||
// of the method with the actual type in order to
|
// of the method with the actual type in order to
|
||||||
// unify some of these variables.
|
// unify some of these variables.
|
||||||
self.fresh_substs_for_item(ty::UniverseIndex::ROOT, self.span, trait_def_id)
|
self.fresh_substs_for_item(self.span, trait_def_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
probe::WhereClausePick(ref poly_trait_ref) => {
|
probe::WhereClausePick(ref poly_trait_ref) => {
|
||||||
|
@ -336,7 +336,7 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {
|
||||||
{
|
{
|
||||||
self.to_ty(ast_ty)
|
self.to_ty(ast_ty)
|
||||||
} else {
|
} else {
|
||||||
self.type_var_for_def(ty::UniverseIndex::ROOT, self.span, def)
|
self.type_var_for_def(self.span, def)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -257,7 +257,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
} else if let Some(ref input_types) = opt_input_types {
|
} else if let Some(ref input_types) = opt_input_types {
|
||||||
input_types[def.index as usize - 1]
|
input_types[def.index as usize - 1]
|
||||||
} else {
|
} else {
|
||||||
self.type_var_for_def(ty::UniverseIndex::ROOT, span, def)
|
self.type_var_for_def(span, def)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -736,9 +736,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
|
||||||
Def::Method(def_id) => {
|
Def::Method(def_id) => {
|
||||||
let fty = self.tcx.fn_sig(def_id);
|
let fty = self.tcx.fn_sig(def_id);
|
||||||
self.probe(|_| {
|
self.probe(|_| {
|
||||||
let substs = self.fresh_substs_for_item(ty::UniverseIndex::ROOT,
|
let substs = self.fresh_substs_for_item(self.span, method.def_id);
|
||||||
self.span,
|
|
||||||
method.def_id);
|
|
||||||
let fty = fty.subst(self.tcx, substs);
|
let fty = fty.subst(self.tcx, substs);
|
||||||
let (fty, _) = self.replace_late_bound_regions_with_fresh_var(
|
let (fty, _) = self.replace_late_bound_regions_with_fresh_var(
|
||||||
self.span, infer::FnCall, &fty);
|
self.span, infer::FnCall, &fty);
|
||||||
|
@ -1389,7 +1387,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
|
||||||
if i < substs.len() {
|
if i < substs.len() {
|
||||||
substs.type_at(i)
|
substs.type_at(i)
|
||||||
} else {
|
} else {
|
||||||
self.type_var_for_def(ty::UniverseIndex::ROOT, self.span, def)
|
self.type_var_for_def(self.span, def)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
xform_fn_sig.subst(self.tcx, substs)
|
xform_fn_sig.subst(self.tcx, substs)
|
||||||
|
@ -1406,7 +1404,6 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
|
||||||
def_id,
|
def_id,
|
||||||
|_, _| self.tcx.types.re_erased,
|
|_, _| self.tcx.types.re_erased,
|
||||||
|_, _| self.next_ty_var(
|
|_, _| self.next_ty_var(
|
||||||
ty::UniverseIndex::ROOT,
|
|
||||||
TypeVariableOrigin::SubstitutionPlaceholder(
|
TypeVariableOrigin::SubstitutionPlaceholder(
|
||||||
self.tcx.def_span(def_id))))
|
self.tcx.def_span(def_id))))
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,8 +56,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
self.autoderef(span, ty).any(|(ty, _)| {
|
self.autoderef(span, ty).any(|(ty, _)| {
|
||||||
self.probe(|_| {
|
self.probe(|_| {
|
||||||
let fn_once_substs = tcx.mk_substs_trait(ty,
|
let fn_once_substs = tcx.mk_substs_trait(ty,
|
||||||
&[self.next_ty_var(ty::UniverseIndex::ROOT,
|
&[self.next_ty_var(TypeVariableOrigin::MiscVariable(span))]);
|
||||||
TypeVariableOrigin::MiscVariable(span))]);
|
|
||||||
let trait_ref = ty::TraitRef::new(fn_once, fn_once_substs);
|
let trait_ref = ty::TraitRef::new(fn_once, fn_once_substs);
|
||||||
let poly_trait_ref = trait_ref.to_poly_trait_ref();
|
let poly_trait_ref = trait_ref.to_poly_trait_ref();
|
||||||
let obligation =
|
let obligation =
|
||||||
|
|
|
@ -362,8 +362,7 @@ impl<'a, 'gcx, 'tcx> Expectation<'tcx> {
|
||||||
/// hard constraint exists, creates a fresh type variable.
|
/// hard constraint exists, creates a fresh type variable.
|
||||||
fn coercion_target_type(self, fcx: &FnCtxt<'a, 'gcx, 'tcx>, span: Span) -> Ty<'tcx> {
|
fn coercion_target_type(self, fcx: &FnCtxt<'a, 'gcx, 'tcx>, span: Span) -> Ty<'tcx> {
|
||||||
self.only_has_type(fcx)
|
self.only_has_type(fcx)
|
||||||
.unwrap_or_else(|| fcx.next_ty_var(ty::UniverseIndex::ROOT,
|
.unwrap_or_else(|| fcx.next_ty_var(TypeVariableOrigin::MiscVariable(span)))
|
||||||
TypeVariableOrigin::MiscVariable(span)))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -938,8 +937,7 @@ impl<'a, 'gcx, 'tcx> GatherLocalsVisitor<'a, 'gcx, 'tcx> {
|
||||||
match ty_opt {
|
match ty_opt {
|
||||||
None => {
|
None => {
|
||||||
// infer the variable's type
|
// infer the variable's type
|
||||||
let var_ty = self.fcx.next_ty_var(ty::UniverseIndex::ROOT,
|
let var_ty = self.fcx.next_ty_var(TypeVariableOrigin::TypeInference(span));
|
||||||
TypeVariableOrigin::TypeInference(span));
|
|
||||||
self.fcx.locals.borrow_mut().insert(nid, var_ty);
|
self.fcx.locals.borrow_mut().insert(nid, var_ty);
|
||||||
var_ty
|
var_ty
|
||||||
}
|
}
|
||||||
|
@ -1052,8 +1050,7 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>,
|
||||||
let span = body.value.span;
|
let span = body.value.span;
|
||||||
|
|
||||||
if body.is_generator && can_be_generator.is_some() {
|
if body.is_generator && can_be_generator.is_some() {
|
||||||
let yield_ty = fcx.next_ty_var(ty::UniverseIndex::ROOT,
|
let yield_ty = fcx.next_ty_var(TypeVariableOrigin::TypeInference(span));
|
||||||
TypeVariableOrigin::TypeInference(span));
|
|
||||||
fcx.require_type_is_sized(yield_ty, span, traits::SizedYieldType);
|
fcx.require_type_is_sized(yield_ty, span, traits::SizedYieldType);
|
||||||
fcx.yield_ty = Some(yield_ty);
|
fcx.yield_ty = Some(yield_ty);
|
||||||
}
|
}
|
||||||
|
@ -1086,8 +1083,7 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>,
|
||||||
// This ensures that all nested generators appear before the entry of this generator.
|
// This ensures that all nested generators appear before the entry of this generator.
|
||||||
// resolve_generator_interiors relies on this property.
|
// resolve_generator_interiors relies on this property.
|
||||||
let gen_ty = if can_be_generator.is_some() && body.is_generator {
|
let gen_ty = if can_be_generator.is_some() && body.is_generator {
|
||||||
let witness = fcx.next_ty_var(ty::UniverseIndex::ROOT,
|
let witness = fcx.next_ty_var(TypeVariableOrigin::MiscVariable(span));
|
||||||
TypeVariableOrigin::MiscVariable(span));
|
|
||||||
let interior = ty::GeneratorInterior {
|
let interior = ty::GeneratorInterior {
|
||||||
witness,
|
witness,
|
||||||
movable: can_be_generator.unwrap() == hir::GeneratorMovability::Movable,
|
movable: can_be_generator.unwrap() == hir::GeneratorMovability::Movable,
|
||||||
|
@ -1125,7 +1121,6 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>,
|
||||||
let mut actual_return_ty = coercion.complete(&fcx);
|
let mut actual_return_ty = coercion.complete(&fcx);
|
||||||
if actual_return_ty.is_never() {
|
if actual_return_ty.is_never() {
|
||||||
actual_return_ty = fcx.next_diverging_ty_var(
|
actual_return_ty = fcx.next_diverging_ty_var(
|
||||||
ty::UniverseIndex::ROOT,
|
|
||||||
TypeVariableOrigin::DivergingFn(span));
|
TypeVariableOrigin::DivergingFn(span));
|
||||||
}
|
}
|
||||||
fcx.demand_suptype(span, ret_ty, actual_return_ty);
|
fcx.demand_suptype(span, ret_ty, actual_return_ty);
|
||||||
|
@ -1738,14 +1733,13 @@ impl<'a, 'gcx, 'tcx> AstConv<'gcx, 'tcx> for FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ty_infer(&self, span: Span) -> Ty<'tcx> {
|
fn ty_infer(&self, span: Span) -> Ty<'tcx> {
|
||||||
self.next_ty_var(ty::UniverseIndex::ROOT,
|
self.next_ty_var(TypeVariableOrigin::TypeInference(span))
|
||||||
TypeVariableOrigin::TypeInference(span))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ty_infer_for_def(&self,
|
fn ty_infer_for_def(&self,
|
||||||
ty_param_def: &ty::TypeParameterDef,
|
ty_param_def: &ty::TypeParameterDef,
|
||||||
span: Span) -> Ty<'tcx> {
|
span: Span) -> Ty<'tcx> {
|
||||||
self.type_var_for_def(ty::UniverseIndex::ROOT, span, ty_param_def)
|
self.type_var_for_def(span, ty_param_def)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn projected_ty_from_poly_trait_ref(&self,
|
fn projected_ty_from_poly_trait_ref(&self,
|
||||||
|
@ -2370,8 +2364,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
// If some lookup succeeds, write callee into table and extract index/element
|
// If some lookup succeeds, write callee into table and extract index/element
|
||||||
// type from the method signature.
|
// type from the method signature.
|
||||||
// If some lookup succeeded, install method in table
|
// If some lookup succeeded, install method in table
|
||||||
let input_ty = self.next_ty_var(ty::UniverseIndex::ROOT,
|
let input_ty = self.next_ty_var(TypeVariableOrigin::AutoDeref(base_expr.span));
|
||||||
TypeVariableOrigin::AutoDeref(base_expr.span));
|
|
||||||
let method = self.try_overloaded_place_op(
|
let method = self.try_overloaded_place_op(
|
||||||
expr.span, self_ty, &[input_ty], needs, PlaceOp::Index);
|
expr.span, self_ty, &[input_ty], needs, PlaceOp::Index);
|
||||||
|
|
||||||
|
@ -2810,7 +2803,6 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
assert!(!self.tables.borrow().adjustments().contains_key(expr.hir_id),
|
assert!(!self.tables.borrow().adjustments().contains_key(expr.hir_id),
|
||||||
"expression with never type wound up being adjusted");
|
"expression with never type wound up being adjusted");
|
||||||
let adj_ty = self.next_diverging_ty_var(
|
let adj_ty = self.next_diverging_ty_var(
|
||||||
ty::UniverseIndex::ROOT,
|
|
||||||
TypeVariableOrigin::AdjustmentType(expr.span));
|
TypeVariableOrigin::AdjustmentType(expr.span));
|
||||||
self.apply_adjustments(expr, vec![Adjustment {
|
self.apply_adjustments(expr, vec![Adjustment {
|
||||||
kind: Adjust::NeverToAny,
|
kind: Adjust::NeverToAny,
|
||||||
|
@ -2888,7 +2880,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
let ity = self.tcx.type_of(did);
|
let ity = self.tcx.type_of(did);
|
||||||
debug!("impl_self_ty: ity={:?}", ity);
|
debug!("impl_self_ty: ity={:?}", ity);
|
||||||
|
|
||||||
let substs = self.fresh_substs_for_item(ty::UniverseIndex::ROOT, span, did);
|
let substs = self.fresh_substs_for_item(span, did);
|
||||||
let substd_ty = self.instantiate_type_scheme(span, &substs, &ity);
|
let substd_ty = self.instantiate_type_scheme(span, &substs, &ity);
|
||||||
|
|
||||||
TypeAndSubsts { substs: substs, ty: substd_ty }
|
TypeAndSubsts { substs: substs, ty: substd_ty }
|
||||||
|
@ -4021,8 +4013,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
|
|
||||||
let element_ty = if !args.is_empty() {
|
let element_ty = if !args.is_empty() {
|
||||||
let coerce_to = uty.unwrap_or_else(
|
let coerce_to = uty.unwrap_or_else(
|
||||||
|| self.next_ty_var(ty::UniverseIndex::ROOT,
|
|| self.next_ty_var(TypeVariableOrigin::TypeInference(expr.span)));
|
||||||
TypeVariableOrigin::TypeInference(expr.span)));
|
|
||||||
let mut coerce = CoerceMany::with_coercion_sites(coerce_to, args);
|
let mut coerce = CoerceMany::with_coercion_sites(coerce_to, args);
|
||||||
assert_eq!(self.diverges.get(), Diverges::Maybe);
|
assert_eq!(self.diverges.get(), Diverges::Maybe);
|
||||||
for e in args {
|
for e in args {
|
||||||
|
@ -4032,8 +4023,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
}
|
}
|
||||||
coerce.complete(self)
|
coerce.complete(self)
|
||||||
} else {
|
} else {
|
||||||
self.next_ty_var(ty::UniverseIndex::ROOT,
|
self.next_ty_var(TypeVariableOrigin::TypeInference(expr.span))
|
||||||
TypeVariableOrigin::TypeInference(expr.span))
|
|
||||||
};
|
};
|
||||||
tcx.mk_array(element_ty, args.len() as u64)
|
tcx.mk_array(element_ty, args.len() as u64)
|
||||||
}
|
}
|
||||||
|
@ -4073,8 +4063,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
(uty, uty)
|
(uty, uty)
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
let t: Ty = self.next_ty_var(ty::UniverseIndex::ROOT,
|
let t: Ty = self.next_ty_var(TypeVariableOrigin::MiscVariable(element.span));
|
||||||
TypeVariableOrigin::MiscVariable(element.span));
|
|
||||||
let element_ty = self.check_expr_has_type_or_error(&element, t);
|
let element_ty = self.check_expr_has_type_or_error(&element, t);
|
||||||
(element_ty, t)
|
(element_ty, t)
|
||||||
}
|
}
|
||||||
|
@ -4853,7 +4842,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
// Handle Self first, so we can adjust the index to match the AST.
|
// Handle Self first, so we can adjust the index to match the AST.
|
||||||
if has_self && i == 0 {
|
if has_self && i == 0 {
|
||||||
return opt_self_ty.unwrap_or_else(|| {
|
return opt_self_ty.unwrap_or_else(|| {
|
||||||
self.type_var_for_def(ty::UniverseIndex::ROOT, span, def)
|
self.type_var_for_def(span, def)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
i -= has_self as usize;
|
i -= has_self as usize;
|
||||||
|
@ -4886,7 +4875,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
// This can also be reached in some error cases:
|
// This can also be reached in some error cases:
|
||||||
// We prefer to use inference variables instead of
|
// We prefer to use inference variables instead of
|
||||||
// TyError to let type inference recover somewhat.
|
// TyError to let type inference recover somewhat.
|
||||||
self.type_var_for_def(ty::UniverseIndex::ROOT, span, def)
|
self.type_var_for_def(span, def)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -174,10 +174,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
// trait matching creating lifetime constraints that are too strict.
|
// trait matching creating lifetime constraints that are too strict.
|
||||||
// E.g. adding `&'a T` and `&'b T`, given `&'x T: Add<&'x T>`, will result
|
// E.g. adding `&'a T` and `&'b T`, given `&'x T: Add<&'x T>`, will result
|
||||||
// in `&'a T <: &'x T` and `&'b T <: &'x T`, instead of `'a = 'b = 'x`.
|
// in `&'a T <: &'x T` and `&'b T <: &'x T`, instead of `'a = 'b = 'x`.
|
||||||
let lhs_ty = self.check_expr_coercable_to_type_with_needs(
|
let lhs_ty = self.check_expr_coercable_to_type_with_needs(lhs_expr,
|
||||||
lhs_expr,
|
self.next_ty_var(TypeVariableOrigin::MiscVariable(lhs_expr.span)),
|
||||||
self.next_ty_var(ty::UniverseIndex::ROOT,
|
|
||||||
TypeVariableOrigin::MiscVariable(lhs_expr.span)),
|
|
||||||
lhs_needs);
|
lhs_needs);
|
||||||
let lhs_ty = self.resolve_type_vars_with_obligations(lhs_ty);
|
let lhs_ty = self.resolve_type_vars_with_obligations(lhs_ty);
|
||||||
|
|
||||||
|
@ -187,8 +185,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
// using this variable as the expected type, which sometimes lets
|
// using this variable as the expected type, which sometimes lets
|
||||||
// us do better coercions than we would be able to do otherwise,
|
// us do better coercions than we would be able to do otherwise,
|
||||||
// particularly for things like `String + &String`.
|
// particularly for things like `String + &String`.
|
||||||
let rhs_ty_var = self.next_ty_var(ty::UniverseIndex::ROOT,
|
let rhs_ty_var = self.next_ty_var(TypeVariableOrigin::MiscVariable(rhs_expr.span));
|
||||||
TypeVariableOrigin::MiscVariable(rhs_expr.span));
|
|
||||||
|
|
||||||
let result = self.lookup_op_method(lhs_ty, &[rhs_ty_var], Op::Binary(op, is_assign));
|
let result = self.lookup_op_method(lhs_ty, &[rhs_ty_var], Op::Binary(op, is_assign));
|
||||||
|
|
||||||
|
|
|
@ -685,14 +685,12 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> {
|
||||||
new_env = ty::ParamEnv::new(
|
new_env = ty::ParamEnv::new(
|
||||||
tcx.mk_predicates(normalized_preds),
|
tcx.mk_predicates(normalized_preds),
|
||||||
param_env.reveal,
|
param_env.reveal,
|
||||||
ty::UniverseIndex::ROOT,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let final_user_env = ty::ParamEnv::new(
|
let final_user_env = ty::ParamEnv::new(
|
||||||
tcx.mk_predicates(user_computed_preds.into_iter()),
|
tcx.mk_predicates(user_computed_preds.into_iter()),
|
||||||
user_env.reveal,
|
user_env.reveal,
|
||||||
ty::UniverseIndex::ROOT,
|
|
||||||
);
|
);
|
||||||
debug!(
|
debug!(
|
||||||
"evaluate_nested_obligations(ty_did={:?}, trait_did={:?}): succeeded with '{:?}' \
|
"evaluate_nested_obligations(ty_did={:?}, trait_did={:?}): succeeded with '{:?}' \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue