Skip to content

Commit 91dafeb

Browse files
authored
Rollup merge of #108575 - compiler-errors:erase, r=estebank
Erase **all** regions when probing for associated types on ambiguity in astconv Fixes #108562
2 parents c9c9283 + cb9852b commit 91dafeb

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

compiler/rustc_hir_analysis/src/astconv/mod.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -2399,8 +2399,10 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
23992399
infcx
24002400
.can_eq(
24012401
ty::ParamEnv::empty(),
2402-
tcx.erase_regions(impl_.self_ty()),
2403-
tcx.erase_regions(qself_ty),
2402+
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),
24042406
)
24052407
})
24062408
&& tcx.impl_polarity(impl_def_id) != ty::ImplPolarity::Negative
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
pub struct Bar<S>(S);
2+
3+
pub trait Foo {}
4+
5+
impl<S> Foo for Bar<S> where for<'a> <&'a S>::Item: Foo {}
6+
//~^ ERROR ambiguous associated type
7+
8+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0223]: ambiguous associated type
2+
--> $DIR/suggest-trait-in-ufcs-in-hrtb.rs:5:38
3+
|
4+
LL | impl<S> Foo for Bar<S> where for<'a> <&'a S>::Item: Foo {}
5+
| ^^^^^^^^^^^^^ help: use the fully-qualified path: `<&'a S as IntoIterator>::Item`
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0223`.

0 commit comments

Comments
 (0)