@@ -2,7 +2,7 @@ use super::method::MethodCallee;
22use super :: { DefIdOrName , Expectation , FnCtxt , TupleArgumentsFlag } ;
33use crate :: type_error_struct;
44
5- use rustc_errors:: { struct_span_err, Applicability , Diagnostic } ;
5+ use rustc_errors:: { struct_span_err, Applicability , Diagnostic , StashKey } ;
66use rustc_hir as hir;
77use rustc_hir:: def:: { self , Namespace , Res } ;
88use rustc_hir:: def_id:: DefId ;
@@ -60,6 +60,7 @@ pub fn check_legal_trait_for_method_call(
6060 }
6161}
6262
63+ #[ derive( Debug ) ]
6364enum CallStep < ' tcx > {
6465 Builtin ( Ty < ' tcx > ) ,
6566 DeferredClosure ( LocalDefId , ty:: FnSig < ' tcx > ) ,
@@ -188,6 +189,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
188189 return None ;
189190 }
190191
192+ ty:: Error ( _) => {
193+ return None ;
194+ }
195+
191196 _ => { }
192197 }
193198
@@ -394,6 +399,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
394399 }
395400 ty:: FnPtr ( sig) => ( sig, None ) ,
396401 _ => {
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+
397413 self . report_invalid_callee ( call_expr, callee_expr, callee_ty, arg_exprs) ;
398414
399415 // This is the "default" function signature, used in case of error.
0 commit comments