@@ -103,24 +103,8 @@ pub(super) fn check_fn<'a, 'tcx>(
103
103
104
104
fcx. typeck_results . borrow_mut ( ) . liberated_fn_sigs_mut ( ) . insert ( fn_id, fn_sig) ;
105
105
106
- if let ty:: Dynamic ( _, _, ty:: Dyn ) = declared_ret_ty. kind ( ) {
107
- // FIXME: We need to verify that the return type is `Sized` after the return expression has
108
- // been evaluated so that we have types available for all the nodes being returned, but that
109
- // requires the coerced evaluated type to be stored. Moving `check_return_expr` before this
110
- // causes unsized errors caused by the `declared_ret_ty` to point at the return expression,
111
- // while keeping the current ordering we will ignore the tail expression's type because we
112
- // don't know it yet. We can't do `check_expr_kind` while keeping `check_return_expr`
113
- // because we will trigger "unreachable expression" lints unconditionally.
114
- // Because of all of this, we perform a crude check to know whether the simplest `!Sized`
115
- // case that a newcomer might make, returning a bare trait, and in that case we populate
116
- // the tail expression's type so that the suggestion will be correct, but ignore all other
117
- // possible cases.
118
- fcx. check_expr ( & body. value ) ;
119
- fcx. require_type_is_sized ( declared_ret_ty, decl. output . span ( ) , traits:: SizedReturnType ) ;
120
- } else {
121
- fcx. require_type_is_sized ( declared_ret_ty, decl. output . span ( ) , traits:: SizedReturnType ) ;
122
- fcx. check_return_expr ( & body. value , false ) ;
123
- }
106
+ fcx. require_type_is_sized ( declared_ret_ty, decl. output . span ( ) , traits:: SizedReturnType ) ;
107
+ fcx. check_return_expr ( & body. value , false ) ;
124
108
125
109
// We insert the deferred_generator_interiors entry after visiting the body.
126
110
// This ensures that all nested generators appear before the entry of this generator.
0 commit comments