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

No need to instantiate binder in confirm_async_closure_candidate #132486

Merged
merged 1 commit into from
Nov 4, 2024
Merged
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
12 changes: 3 additions & 9 deletions compiler/rustc_trait_selection/src/traits/select/confirmation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -951,18 +951,12 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
});

// We must additionally check that the return type impls `Future`.

// FIXME(async_closures): Investigate this before stabilization.
// We instantiate this binder eagerly because the `confirm_future_candidate`
// method doesn't support higher-ranked futures, which the `AsyncFn`
// traits expressly allow the user to write. To fix this correctly,
// we'd need to instantiate trait bounds before we get to selection,
// like the new trait solver does.
let future_trait_def_id = tcx.require_lang_item(LangItem::Future, None);
let placeholder_output_ty = self.infcx.enter_forall_and_leak_universe(sig.output());
nested.push(obligation.with(
tcx,
ty::TraitRef::new(tcx, future_trait_def_id, [placeholder_output_ty]),
sig.output().map_bound(|output_ty| {
ty::TraitRef::new(tcx, future_trait_def_id, [output_ty])
}),
));

(trait_ref, Ty::from_closure_kind(tcx, ty::ClosureKind::Fn))
Expand Down
Loading