Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Erase **all** regions when probing for associated types on ambiguity in astconv #108575

Merged
merged 1 commit into from
Mar 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions compiler/rustc_hir_analysis/src/astconv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2403,8 +2403,10 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
infcx
.can_eq(
ty::ParamEnv::empty(),
tcx.erase_regions(impl_.self_ty()),
tcx.erase_regions(qself_ty),
impl_.self_ty(),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

impl self ty has no late-bound regions

// Must fold past escaping bound vars too,
// since we have those at this point in astconv.
tcx.fold_regions(qself_ty, |_, _| tcx.lifetimes.re_erased),
)
})
&& tcx.impl_polarity(impl_def_id) != ty::ImplPolarity::Negative
Expand Down
8 changes: 8 additions & 0 deletions tests/ui/suggestions/suggest-trait-in-ufcs-in-hrtb.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
pub struct Bar<S>(S);

pub trait Foo {}

impl<S> Foo for Bar<S> where for<'a> <&'a S>::Item: Foo {}
//~^ ERROR ambiguous associated type

fn main() {}
9 changes: 9 additions & 0 deletions tests/ui/suggestions/suggest-trait-in-ufcs-in-hrtb.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
error[E0223]: ambiguous associated type
--> $DIR/suggest-trait-in-ufcs-in-hrtb.rs:5:38
|
LL | impl<S> Foo for Bar<S> where for<'a> <&'a S>::Item: Foo {}
| ^^^^^^^^^^^^^ help: use the fully-qualified path: `<&'a S as IntoIterator>::Item`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0223`.