Skip to content

Commit 0ee7539

Browse files
authored
Rollup merge of #109102 - compiler-errors:ambig-assoc-in-non-lt-binder, r=jackh726
Erase escaping late-bound regions when probing for ambiguous associated types Fixes #109090
2 parents 13afbda + 79ad7cc commit 0ee7539

File tree

3 files changed

+43
-3
lines changed

3 files changed

+43
-3
lines changed

compiler/rustc_hir_analysis/src/astconv/mod.rs

+14-3
Original file line numberDiff line numberDiff line change
@@ -2396,13 +2396,24 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
23962396
tcx,
23972397
infcx.fresh_substs_for_item(DUMMY_SP, impl_def_id),
23982398
);
2399+
// I guess we don't need to make a universe unless we need it,
2400+
// but also we're on the error path, so it doesn't matter here.
2401+
let universe = infcx.create_next_universe();
23992402
infcx
24002403
.can_eq(
24012404
ty::ParamEnv::empty(),
24022405
impl_.self_ty(),
2403-
// Must fold past escaping bound vars too,
2404-
// since we have those at this point in astconv.
2405-
tcx.fold_regions(qself_ty, |_, _| tcx.lifetimes.re_erased),
2406+
tcx.replace_escaping_bound_vars_uncached(qself_ty, ty::fold::FnMutDelegate {
2407+
regions: &mut |_| tcx.lifetimes.re_erased,
2408+
types: &mut |bv| tcx.mk_placeholder(ty::PlaceholderType {
2409+
universe,
2410+
name: bv.kind,
2411+
}),
2412+
consts: &mut |bv, ty| tcx.mk_const(ty::PlaceholderConst {
2413+
universe,
2414+
name: bv
2415+
}, ty),
2416+
})
24062417
)
24072418
})
24082419
&& tcx.impl_polarity(impl_def_id) != ty::ImplPolarity::Negative
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#![feature(non_lifetime_binders)]
2+
//~^ WARN the feature `non_lifetime_binders` is incomplete
3+
4+
fn f()
5+
where
6+
for<B> B::Item: Send,
7+
//~^ ERROR ambiguous associated type
8+
{
9+
}
10+
11+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
2+
--> $DIR/missing-assoc-item.rs:1:12
3+
|
4+
LL | #![feature(non_lifetime_binders)]
5+
| ^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information
8+
= note: `#[warn(incomplete_features)]` on by default
9+
10+
error[E0223]: ambiguous associated type
11+
--> $DIR/missing-assoc-item.rs:6:12
12+
|
13+
LL | for<B> B::Item: Send,
14+
| ^^^^^^^ help: use the fully-qualified path: `<B as IntoIterator>::Item`
15+
16+
error: aborting due to previous error; 1 warning emitted
17+
18+
For more information about this error, try `rustc --explain E0223`.

0 commit comments

Comments
 (0)