Skip to content

Commit e5397d3

Browse files
committed
WIP
1 parent 84e45e0 commit e5397d3

File tree

3 files changed

+31
-4
lines changed

3 files changed

+31
-4
lines changed

compiler/rustc_hir_analysis/src/astconv/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1407,6 +1407,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
14071407
hir_ref_id,
14081408
span,
14091409
)? {
1410+
assert!(!ty.has_infer());
14101411
return Ok((ty, DefKind::AssocTy, did));
14111412
}
14121413
}

compiler/rustc_trait_selection/src/traits/project.rs

+18-4
Original file line numberDiff line numberDiff line change
@@ -1001,7 +1001,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for PlaceholderReplacer<'_, 'tcx> {
10011001
&mut self,
10021002
t: ty::Binder<'tcx, T>,
10031003
) -> ty::Binder<'tcx, T> {
1004-
if !t.has_placeholders() && !t.has_infer_regions() {
1004+
if !t.has_placeholders() && !t.has_infer() {
10051005
return t;
10061006
}
10071007
self.current_index.shift_in(1);
@@ -1048,6 +1048,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for PlaceholderReplacer<'_, 'tcx> {
10481048
}
10491049

10501050
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
1051+
let ty = self.infcx.shallow_resolve(ty);
10511052
match *ty.kind() {
10521053
ty::Placeholder(p) => {
10531054
let replace_var = self.mapped_types.get(&p);
@@ -1063,16 +1064,23 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for PlaceholderReplacer<'_, 'tcx> {
10631064
);
10641065
Ty::new_bound(self.infcx.tcx, db, *replace_var)
10651066
}
1066-
None => ty,
1067+
None => {
1068+
if ty.has_infer() {
1069+
ty.super_fold_with(self)
1070+
} else {
1071+
ty
1072+
}
1073+
}
10671074
}
10681075
}
10691076

1070-
_ if ty.has_placeholders() || ty.has_infer_regions() => ty.super_fold_with(self),
1077+
_ if ty.has_placeholders() || ty.has_infer() => ty.super_fold_with(self),
10711078
_ => ty,
10721079
}
10731080
}
10741081

10751082
fn fold_const(&mut self, ct: ty::Const<'tcx>) -> ty::Const<'tcx> {
1083+
let ct = self.infcx.shallow_resolve(ct);
10761084
if let ty::ConstKind::Placeholder(p) = ct.kind() {
10771085
let replace_var = self.mapped_consts.get(&p);
10781086
match replace_var {
@@ -1087,7 +1095,13 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for PlaceholderReplacer<'_, 'tcx> {
10871095
);
10881096
ty::Const::new_bound(self.infcx.tcx, db, *replace_var, ct.ty())
10891097
}
1090-
None => ct,
1098+
None => {
1099+
if ct.has_infer() {
1100+
ct.super_fold_with(self)
1101+
} else {
1102+
ct
1103+
}
1104+
}
10911105
}
10921106
} else {
10931107
ct.super_fold_with(self)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#![feature(inherent_associated_types)]
2+
#![allow(incomplete_features)]
3+
4+
struct Foo<T>(T);
5+
6+
impl<'a> Foo<fn(&'a ())> {
7+
type Assoc = &'a ();
8+
}
9+
10+
fn bar(_: for<'a> fn(Foo<fn(Foo<fn(&'static ())>::Assoc)>::Assoc)) {}
11+
12+
fn main() {}

0 commit comments

Comments
 (0)