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