1
Fork 0

Auto merge of #101359 - compiler-errors:cannot-call-trait-object-with-unsized-return, r=lcnr

Point out when a callable is not actually callable because its return is not sized

Fixes #100755

I didn't add a UI test for that one because it's equivalent to the UI test that already exists in the suite.
This commit is contained in:
bors 2022-09-06 05:57:39 +00:00
commit 098cf88022
5 changed files with 47 additions and 19 deletions

View file

@ -24,6 +24,13 @@ pub trait InferCtxtExt<'tcx> {
span: Span,
) -> bool;
fn type_is_sized_modulo_regions(
&self,
param_env: ty::ParamEnv<'tcx>,
ty: Ty<'tcx>,
span: Span,
) -> bool;
fn partially_normalize_associated_types_in<T>(
&self,
cause: ObligationCause<'tcx>,
@ -74,6 +81,16 @@ impl<'cx, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'cx, 'tcx> {
traits::type_known_to_meet_bound_modulo_regions(self, param_env, ty, copy_def_id, span)
}
fn type_is_sized_modulo_regions(
&self,
param_env: ty::ParamEnv<'tcx>,
ty: Ty<'tcx>,
span: Span,
) -> bool {
let lang_item = self.tcx.require_lang_item(LangItem::Sized, None);
traits::type_known_to_meet_bound_modulo_regions(self, param_env, ty, lang_item, span)
}
/// Normalizes associated types in `value`, potentially returning
/// new obligations that must further be processed.
fn partially_normalize_associated_types_in<T>(