@@ -135,7 +135,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
135135 msg : & str ,
136136 method_name : ast:: Ident ,
137137 self_ty : Ty < ' tcx > ,
138- call_expr_id : hir:: HirId ,
138+ call_expr : & hir:: Expr < ' _ > ,
139139 ) {
140140 let has_params = self
141141 . probe_for_name (
@@ -144,21 +144,29 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
144144 method_name,
145145 IsSuggestion ( false ) ,
146146 self_ty,
147- call_expr_id ,
147+ call_expr . hir_id ,
148148 ProbeScope :: TraitsInScope ,
149149 )
150150 . and_then ( |pick| {
151151 let sig = self . tcx . fn_sig ( pick. item . def_id ) ;
152152 Ok ( sig. inputs ( ) . skip_binder ( ) . len ( ) > 1 )
153153 } ) ;
154154
155+ // Account for `foo.bar<T>`;
156+ let sugg_span = method_name. span . with_hi ( call_expr. span . hi ( ) ) ;
157+ let snippet = self
158+ . tcx
159+ . sess
160+ . source_map ( )
161+ . span_to_snippet ( sugg_span)
162+ . unwrap_or_else ( |_| method_name. to_string ( ) ) ;
155163 let ( suggestion, applicability) = if has_params. unwrap_or_default ( ) {
156- ( format ! ( "{}(...)" , method_name ) , Applicability :: HasPlaceholders )
164+ ( format ! ( "{}(...)" , snippet ) , Applicability :: HasPlaceholders )
157165 } else {
158- ( format ! ( "{}()" , method_name ) , Applicability :: MaybeIncorrect )
166+ ( format ! ( "{}()" , snippet ) , Applicability :: MaybeIncorrect )
159167 } ;
160168
161- err. span_suggestion ( method_name . span , msg, suggestion, applicability) ;
169+ err. span_suggestion ( sugg_span , msg, suggestion, applicability) ;
162170 }
163171
164172 /// Performs method lookup. If lookup is successful, it will return the callee
0 commit comments