Skip to content

Commit 6940075

Browse files
committed
make needs_infer specific to inference variables
Notably, excluding ReSkolemized
1 parent 2e59e46 commit 6940075

File tree

8 files changed

+23
-11
lines changed

8 files changed

+23
-11
lines changed

src/librustc/traits/project.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for AssociatedTypeNormalizer<'a,
409409
if let ConstVal::Unevaluated(def_id, substs) = constant.val {
410410
let tcx = self.selcx.tcx().global_tcx();
411411
if let Some(param_env) = self.tcx().lift_to_global(&self.param_env) {
412-
if substs.needs_infer() {
412+
if substs.needs_infer() || substs.has_skol() {
413413
let identity_substs = Substs::identity_for_item(tcx, def_id);
414414
let instance = ty::Instance::resolve(tcx, param_env, def_id, identity_substs);
415415
if let Some(instance) = instance {

src/librustc/traits/query/normalize.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for QueryNormalizer<'cx, 'gcx, 'tcx
196196
if let ConstVal::Unevaluated(def_id, substs) = constant.val {
197197
let tcx = self.infcx.tcx.global_tcx();
198198
if let Some(param_env) = self.tcx().lift_to_global(&self.param_env) {
199-
if substs.needs_infer() {
199+
if substs.needs_infer() || substs.has_skol() {
200200
let identity_substs = Substs::identity_for_item(tcx, def_id);
201201
let instance = ty::Instance::resolve(tcx, param_env, def_id, identity_substs);
202202
if let Some(instance) = instance {

src/librustc/ty/context.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -2119,7 +2119,7 @@ macro_rules! intern_method {
21192119
$alloc_method:ident,
21202120
$alloc_to_key:expr,
21212121
$alloc_to_ret:expr,
2122-
$needs_infer:expr) -> $ty:ty) => {
2122+
$keep_in_local_tcx:expr) -> $ty:ty) => {
21232123
impl<'a, 'gcx, $lt_tcx> TyCtxt<'a, 'gcx, $lt_tcx> {
21242124
pub fn $method(self, v: $alloc) -> &$lt_tcx $ty {
21252125
{
@@ -2137,7 +2137,7 @@ macro_rules! intern_method {
21372137
// HACK(eddyb) Depend on flags being accurate to
21382138
// determine that all contents are in the global tcx.
21392139
// See comments on Lift for why we can't use that.
2140-
if !($needs_infer)(&v) {
2140+
if !($keep_in_local_tcx)(&v) {
21412141
if !self.is_global() {
21422142
let v = unsafe {
21432143
mem::transmute(v)
@@ -2165,7 +2165,7 @@ macro_rules! intern_method {
21652165
}
21662166

21672167
macro_rules! direct_interners {
2168-
($lt_tcx:tt, $($name:ident: $method:ident($needs_infer:expr) -> $ty:ty),+) => {
2168+
($lt_tcx:tt, $($name:ident: $method:ident($keep_in_local_tcx:expr) -> $ty:ty),+) => {
21692169
$(impl<$lt_tcx> PartialEq for Interned<$lt_tcx, $ty> {
21702170
fn eq(&self, other: &Self) -> bool {
21712171
self.0 == other.0
@@ -2180,7 +2180,10 @@ macro_rules! direct_interners {
21802180
}
21812181
}
21822182

2183-
intern_method!($lt_tcx, $name: $method($ty, alloc, |x| x, |x| x, $needs_infer) -> $ty);)+
2183+
intern_method!(
2184+
$lt_tcx,
2185+
$name: $method($ty, alloc, |x| x, |x| x, $keep_in_local_tcx) -> $ty
2186+
);)+
21842187
}
21852188
}
21862189

src/librustc/ty/fold.rs

+3
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ pub trait TypeFoldable<'tcx>: fmt::Debug + Clone {
9191
fn needs_infer(&self) -> bool {
9292
self.has_type_flags(TypeFlags::HAS_TY_INFER | TypeFlags::HAS_RE_INFER)
9393
}
94+
fn has_skol(&self) -> bool {
95+
self.has_type_flags(TypeFlags::HAS_RE_SKOL)
96+
}
9497
fn needs_subst(&self) -> bool {
9598
self.has_type_flags(TypeFlags::NEEDS_SUBST)
9699
}

src/librustc/ty/mod.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1476,7 +1476,11 @@ impl<'tcx> ParamEnv<'tcx> {
14761476
}
14771477

14781478
Reveal::All => {
1479-
if value.needs_infer() || value.has_param_types() || value.has_self_ty() {
1479+
if value.has_skol()
1480+
|| value.needs_infer()
1481+
|| value.has_param_types()
1482+
|| value.has_self_ty()
1483+
{
14801484
ParamEnvAnd {
14811485
param_env: self,
14821486
value,

src/librustc/ty/sty.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1199,7 +1199,6 @@ impl RegionKind {
11991199
}
12001200
ty::ReSkolemized(..) => {
12011201
flags = flags | TypeFlags::HAS_FREE_REGIONS;
1202-
flags = flags | TypeFlags::HAS_RE_INFER;
12031202
flags = flags | TypeFlags::HAS_RE_SKOL;
12041203
flags = flags | TypeFlags::KEEP_IN_LOCAL_TCX;
12051204
}

src/librustc_typeck/check/method/probe.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1485,7 +1485,10 @@ impl<'tcx> Candidate<'tcx> {
14851485
// inference variables or other artifacts. This
14861486
// means they are safe to put into the
14871487
// `WhereClausePick`.
1488-
assert!(!trait_ref.skip_binder().substs.needs_infer());
1488+
assert!(
1489+
!trait_ref.skip_binder().substs.needs_infer()
1490+
&& !trait_ref.skip_binder().substs.has_skol()
1491+
);
14891492

14901493
WhereClausePick(trait_ref.clone())
14911494
}

src/librustc_typeck/check/writeback.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> {
107107

108108
fn write_ty_to_tables(&mut self, hir_id: hir::HirId, ty: Ty<'gcx>) {
109109
debug!("write_ty_to_tables({:?}, {:?})", hir_id, ty);
110-
assert!(!ty.needs_infer());
110+
assert!(!ty.needs_infer() && !ty.has_skol());
111111
self.tables.node_types_mut().insert(hir_id, ty);
112112
}
113113

@@ -431,7 +431,7 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> {
431431
if let Some(substs) = self.fcx.tables.borrow().node_substs_opt(hir_id) {
432432
let substs = self.resolve(&substs, &span);
433433
debug!("write_substs_to_tcx({:?}, {:?})", hir_id, substs);
434-
assert!(!substs.needs_infer());
434+
assert!(!substs.needs_infer() && !substs.has_skol());
435435
self.tables.node_substs_mut().insert(hir_id, substs);
436436
}
437437
}

0 commit comments

Comments
 (0)