Skip to content

Commit cb9852b

Browse files
Erase **all** regions when probing for associated types in astconv
1 parent 31f858d commit cb9852b

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
@@ -2403,8 +2403,10 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
24032403
infcx
24042404
.can_eq(
24052405
ty::ParamEnv::empty(),
2406-
tcx.erase_regions(impl_.self_ty()),
2407-
tcx.erase_regions(qself_ty),
2406+
impl_.self_ty(),
2407+
// Must fold past escaping bound vars too,
2408+
// since we have those at this point in astconv.
2409+
tcx.fold_regions(qself_ty, |_, _| tcx.lifetimes.re_erased),
24082410
)
24092411
})
24102412
&& 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)