@@ -10,6 +10,7 @@ use rustc_hir::lang_items::LangItem;
10
10
use rustc_hir_analysis:: check:: { check_function_signature, forbid_intrinsic_abi} ;
11
11
use rustc_infer:: infer:: type_variable:: TypeVariableOrigin ;
12
12
use rustc_infer:: infer:: RegionVariableOrigin ;
13
+ use rustc_infer:: traits:: WellFormedLoc ;
13
14
use rustc_middle:: ty:: { self , Binder , Ty , TyCtxt } ;
14
15
use rustc_span:: def_id:: LocalDefId ;
15
16
use rustc_span:: symbol:: sym;
@@ -71,6 +72,18 @@ pub(super) fn check_fn<'a, 'tcx>(
71
72
let inputs_hir = hir. fn_decl_by_hir_id ( fn_id) . map ( |decl| & decl. inputs ) ;
72
73
let inputs_fn = fn_sig. inputs ( ) . iter ( ) . copied ( ) ;
73
74
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
+
74
87
// Check the pattern.
75
88
let ty: Option < & hir:: Ty < ' _ > > = inputs_hir. and_then ( |h| h. get ( idx) ) ;
76
89
let ty_span = ty. map ( |ty| ty. span ) ;
@@ -108,7 +121,13 @@ pub(super) fn check_fn<'a, 'tcx>(
108
121
hir:: FnRetTy :: DefaultReturn ( _) => body. value . span ,
109
122
hir:: FnRetTy :: Return ( ty) => ty. span ,
110
123
} ;
124
+
111
125
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
+
112
131
fcx. is_whole_body . set ( true ) ;
113
132
fcx. check_return_expr ( body. value , false ) ;
114
133
0 commit comments