@@ -2,7 +2,7 @@ use super::method::MethodCallee;
2
2
use super :: { DefIdOrName , Expectation , FnCtxt , TupleArgumentsFlag } ;
3
3
use crate :: type_error_struct;
4
4
5
- use rustc_errors:: { struct_span_err, Applicability , Diagnostic } ;
5
+ use rustc_errors:: { struct_span_err, Applicability , Diagnostic , StashKey } ;
6
6
use rustc_hir as hir;
7
7
use rustc_hir:: def:: { self , Namespace , Res } ;
8
8
use rustc_hir:: def_id:: DefId ;
@@ -60,6 +60,7 @@ pub fn check_legal_trait_for_method_call(
60
60
}
61
61
}
62
62
63
+ #[ derive( Debug ) ]
63
64
enum CallStep < ' tcx > {
64
65
Builtin ( Ty < ' tcx > ) ,
65
66
DeferredClosure ( LocalDefId , ty:: FnSig < ' tcx > ) ,
@@ -188,6 +189,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
188
189
return None ;
189
190
}
190
191
192
+ ty:: Error ( _) => {
193
+ return None ;
194
+ }
195
+
191
196
_ => { }
192
197
}
193
198
@@ -394,6 +399,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
394
399
}
395
400
ty:: FnPtr ( sig) => ( sig, None ) ,
396
401
_ => {
402
+ if let hir:: ExprKind :: Path ( hir:: QPath :: Resolved ( _, path) ) = & callee_expr. kind
403
+ && let [ segment] = path. segments
404
+ && let Some ( mut diag) = self
405
+ . tcx
406
+ . sess
407
+ . diagnostic ( )
408
+ . steal_diagnostic ( segment. ident . span , StashKey :: CallIntoMethod )
409
+ {
410
+ diag. emit ( ) ;
411
+ }
412
+
397
413
self . report_invalid_callee ( call_expr, callee_expr, callee_ty, arg_exprs) ;
398
414
399
415
// This is the "default" function signature, used in case of error.
0 commit comments