@@ -15,7 +15,7 @@ use CrateCtxt;
15
15
use middle:: cstore:: LOCAL_CRATE ;
16
16
use hir:: def:: Def ;
17
17
use hir:: def_id:: DefId ;
18
- use rustc:: infer;
18
+ use rustc:: { infer, traits } ;
19
19
use rustc:: ty:: { self , LvaluePreference , Ty } ;
20
20
use syntax:: parse:: token;
21
21
use syntax:: ptr:: P ;
@@ -56,7 +56,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
56
56
let callee_ty = autoderef. unambiguous_final_ty ( ) ;
57
57
autoderef. finalize ( LvaluePreference :: NoPreference , Some ( callee_expr) ) ;
58
58
59
- match result {
59
+ let output = match result {
60
60
None => {
61
61
// this will report an error since original_callee_ty is not a fn
62
62
self . confirm_builtin_call ( call_expr, original_callee_ty, arg_exprs, expected)
@@ -74,7 +74,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
74
74
self . confirm_overloaded_call ( call_expr, callee_expr,
75
75
arg_exprs, expected, method_callee)
76
76
}
77
- }
77
+ } ;
78
+
79
+ // we must check that return type of called functions is WF:
80
+ self . register_wf_obligation ( output, call_expr. span , traits:: MiscObligation ) ;
81
+
82
+ output
78
83
}
79
84
80
85
fn try_overloaded_call_step ( & self ,
@@ -244,7 +249,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
244
249
fn_sig. variadic ,
245
250
TupleArgumentsFlag :: DontTupleArguments ) ;
246
251
247
- self . write_ty ( call_expr . id , fn_sig. output )
252
+ fn_sig. output
248
253
}
249
254
250
255
fn confirm_deferred_closure_call ( & self ,
@@ -271,7 +276,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
271
276
fn_sig. variadic ,
272
277
TupleArgumentsFlag :: TupleArguments ) ;
273
278
274
- self . write_ty ( call_expr . id , fn_sig. output )
279
+ fn_sig. output
275
280
}
276
281
277
282
fn confirm_overloaded_call ( & self ,
@@ -288,10 +293,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
288
293
arg_exprs,
289
294
TupleArgumentsFlag :: TupleArguments ,
290
295
expected) ;
291
- let ty = self . write_ty ( call_expr. id , output_type) ;
292
296
293
297
self . write_overloaded_call_method_map ( call_expr, method_callee) ;
294
- ty
298
+ output_type
295
299
}
296
300
297
301
fn write_overloaded_call_method_map ( & self ,
0 commit comments