1
Fork 0

don't do Sized/other fn signature checks on RPIT's real type

This commit is contained in:
Michael Goulet 2022-05-26 10:21:20 -07:00
parent fa70b89d19
commit 126ef8ee31
3 changed files with 24 additions and 7 deletions

View file

@ -103,12 +103,6 @@ pub(super) fn check_fn<'a, 'tcx>(
DUMMY_SP,
param_env,
));
// HACK(oli-obk): we rewrite the declared return type, too, so that we don't end up inferring all
// unconstrained RPIT to have `()` as their hidden type. This would happen because further down we
// compare the ret_coercion with declared_ret_ty, and anything uninferred would be inferred to the
// opaque type itself. That again would cause writeback to assume we have a recursive call site
// and do the sadly stabilized fallback to `()`.
let declared_ret_ty = ret_ty;
fcx.ret_coercion = Some(RefCell::new(CoerceMany::new(ret_ty)));
fcx.ret_type_span = Some(decl.output.span());
@ -252,7 +246,12 @@ pub(super) fn check_fn<'a, 'tcx>(
fcx.next_ty_var(TypeVariableOrigin { kind: TypeVariableOriginKind::DynReturnFn, span });
debug!("actual_return_ty replaced with {:?}", actual_return_ty);
}
fcx.demand_suptype(span, declared_ret_ty, actual_return_ty);
// HACK(oli-obk, compiler-errors): We should be comparing this against
// `declared_ret_ty`, but then anything uninferred would be inferred to
// the opaque type itself. That again would cause writeback to assume
// we have a recursive call site and do the sadly stabilized fallback to `()`.
fcx.demand_suptype(span, ret_ty, actual_return_ty);
// Check that a function marked as `#[panic_handler]` has signature `fn(&PanicInfo) -> !`
if let Some(panic_impl_did) = tcx.lang_items().panic_impl()