Rollup merge of #132486 - compiler-errors:no-binder, r=lcnr

No need to instantiate binder in `confirm_async_closure_candidate`

Removes a FIXME that is redundant. No longer needed since #122267.
This commit is contained in:
Matthias Krüger 2024-11-04 18:12:45 +01:00 committed by GitHub
commit c89a6cd0ad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -951,18 +951,12 @@ fn confirm_async_closure_candidate(
});
// 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))