@@ -390,7 +390,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
390390 }
391391 let hir = self . tcx . hir ( ) ;
392392 // Get the name of the callable and the arguments to be used in the suggestion.
393- let snippet = match hir. get_if_local ( def_id) {
393+ let ( snippet, sugg ) = match hir. get_if_local ( def_id) {
394394 Some ( hir:: Node :: Expr ( hir:: Expr {
395395 kind : hir:: ExprKind :: Closure ( _, decl, _, span, ..) ,
396396 ..
@@ -401,7 +401,8 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
401401 None => return ,
402402 } ;
403403 let args = decl. inputs . iter ( ) . map ( |_| "_" ) . collect :: < Vec < _ > > ( ) . join ( ", " ) ;
404- format ! ( "{}({})" , name, args)
404+ let sugg = format ! ( "({})" , args) ;
405+ ( format ! ( "{}{}" , name, sugg) , sugg)
405406 }
406407 Some ( hir:: Node :: Item ( hir:: Item {
407408 ident,
@@ -422,7 +423,8 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
422423 } )
423424 . collect :: < Vec < _ > > ( )
424425 . join ( ", " ) ;
425- format ! ( "{}({})" , ident, args)
426+ let sugg = format ! ( "({})" , args) ;
427+ ( format ! ( "{}{}" , ident, sugg) , sugg)
426428 }
427429 _ => return ,
428430 } ;
@@ -431,10 +433,10 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
431433 // an argument, the `obligation.cause.span` points at the expression
432434 // of the argument, so we can provide a suggestion. This is signaled
433435 // by `points_at_arg`. Otherwise, we give a more general note.
434- err. span_suggestion (
435- obligation. cause . span ,
436+ err. span_suggestion_verbose (
437+ obligation. cause . span . shrink_to_hi ( ) ,
436438 & msg,
437- snippet ,
439+ sugg ,
438440 Applicability :: HasPlaceholders ,
439441 ) ;
440442 } else {
@@ -619,7 +621,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
619621 . source_map ( )
620622 . span_take_while ( span, |c| c. is_whitespace ( ) || * c == '&' ) ;
621623 if points_at_arg && mutability == hir:: Mutability :: Not && refs_number > 0 {
622- err. span_suggestion (
624+ err. span_suggestion_verbose (
623625 sp,
624626 "consider changing this borrow's mutability" ,
625627 "&mut " . to_string ( ) ,
0 commit comments