Skip to content

Erase escaping late-bound regions when probing for ambiguous associated types #109102

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

Merged
merged 1 commit into from
Mar 18, 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
17 changes: 14 additions & 3 deletions compiler/rustc_hir_analysis/src/astconv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2396,13 +2396,24 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
tcx,
infcx.fresh_substs_for_item(DUMMY_SP, impl_def_id),
);
// I guess we don't need to make a universe unless we need it,
// but also we're on the error path, so it doesn't matter here.
let universe = infcx.create_next_universe();
Copy link
Member Author

Choose a reason for hiding this comment

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

I guess we don't need to make a universe unless we need it, but also we're on the error path, so it doesn't matter here.

Copy link
Member

Choose a reason for hiding this comment

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

Please add this as a comment

infcx
.can_eq(
ty::ParamEnv::empty(),
impl_.self_ty(),
// 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.replace_escaping_bound_vars_uncached(qself_ty, ty::fold::FnMutDelegate {
regions: &mut |_| tcx.lifetimes.re_erased,
types: &mut |bv| tcx.mk_placeholder(ty::PlaceholderType {
universe,
name: bv.kind,
}),
consts: &mut |bv, ty| tcx.mk_const(ty::PlaceholderConst {
universe,
name: bv
}, ty),
})
)
})
&& tcx.impl_polarity(impl_def_id) != ty::ImplPolarity::Negative
Expand Down
11 changes: 11 additions & 0 deletions tests/ui/traits/non_lifetime_binders/missing-assoc-item.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#![feature(non_lifetime_binders)]
//~^ WARN the feature `non_lifetime_binders` is incomplete

fn f()
where
for<B> B::Item: Send,
//~^ ERROR ambiguous associated type
{
}

fn main() {}
18 changes: 18 additions & 0 deletions tests/ui/traits/non_lifetime_binders/missing-assoc-item.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/missing-assoc-item.rs:1:12
|
LL | #![feature(non_lifetime_binders)]
| ^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information
= note: `#[warn(incomplete_features)]` on by default

error[E0223]: ambiguous associated type
--> $DIR/missing-assoc-item.rs:6:12
|
LL | for<B> B::Item: Send,
| ^^^^^^^ help: use the fully-qualified path: `<B as IntoIterator>::Item`

error: aborting due to previous error; 1 warning emitted

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