@@ -10,6 +10,7 @@ use rustc_hir::lang_items::LangItem;
1010use rustc_hir_analysis:: check:: { check_function_signature, forbid_intrinsic_abi} ;
1111use rustc_infer:: infer:: type_variable:: { TypeVariableOrigin , TypeVariableOriginKind } ;
1212use rustc_infer:: infer:: RegionVariableOrigin ;
13+ use rustc_infer:: traits:: WellFormedLoc ;
1314use rustc_middle:: ty:: { self , Binder , Ty , TyCtxt } ;
1415use rustc_span:: def_id:: LocalDefId ;
1516use rustc_span:: symbol:: sym;
@@ -71,6 +72,18 @@ pub(super) fn check_fn<'a, 'tcx>(
7172 let inputs_hir = hir. fn_decl_by_hir_id ( fn_id) . map ( |decl| & decl. inputs ) ;
7273 let inputs_fn = fn_sig. inputs ( ) . iter ( ) . copied ( ) ;
7374 for ( idx, ( param_ty, param) ) in inputs_fn. chain ( maybe_va_list) . zip ( body. params ) . enumerate ( ) {
75+ // We checked the root's signature during wfcheck, but not the child.
76+ if fcx. tcx . is_typeck_child ( fn_def_id. to_def_id ( ) ) {
77+ fcx. register_wf_obligation (
78+ param_ty. into ( ) ,
79+ param. span ,
80+ traits:: WellFormed ( Some ( WellFormedLoc :: Param {
81+ function : fn_def_id,
82+ param_idx : idx,
83+ } ) ) ,
84+ ) ;
85+ }
86+
7487 // Check the pattern.
7588 let ty: Option < & hir:: Ty < ' _ > > = inputs_hir. and_then ( |h| h. get ( idx) ) ;
7689 let ty_span = ty. map ( |ty| ty. span ) ;
@@ -108,7 +121,13 @@ pub(super) fn check_fn<'a, 'tcx>(
108121 hir:: FnRetTy :: DefaultReturn ( _) => body. value . span ,
109122 hir:: FnRetTy :: Return ( ty) => ty. span ,
110123 } ;
124+
111125 fcx. require_type_is_sized ( declared_ret_ty, return_or_body_span, traits:: SizedReturnType ) ;
126+ // We checked the root's signature during wfcheck, but not the child.
127+ if fcx. tcx . is_typeck_child ( fn_def_id. to_def_id ( ) ) {
128+ fcx. require_type_is_sized ( declared_ret_ty, return_or_body_span, traits:: WellFormed ( None ) ) ;
129+ }
130+
112131 fcx. is_whole_body . set ( true ) ;
113132 fcx. check_return_expr ( body. value , false ) ;
114133
0 commit comments