@@ -390,7 +390,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
390
390
}
391
391
let hir = self . tcx . hir ( ) ;
392
392
// 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) {
394
394
Some ( hir:: Node :: Expr ( hir:: Expr {
395
395
kind : hir:: ExprKind :: Closure ( _, decl, _, span, ..) ,
396
396
..
@@ -401,7 +401,8 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
401
401
None => return ,
402
402
} ;
403
403
let args = decl. inputs . iter ( ) . map ( |_| "_" ) . collect :: < Vec < _ > > ( ) . join ( ", " ) ;
404
- format ! ( "{}({})" , name, args)
404
+ let sugg = format ! ( "({})" , args) ;
405
+ ( format ! ( "{}{}" , name, sugg) , sugg)
405
406
}
406
407
Some ( hir:: Node :: Item ( hir:: Item {
407
408
ident,
@@ -422,7 +423,8 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
422
423
} )
423
424
. collect :: < Vec < _ > > ( )
424
425
. join ( ", " ) ;
425
- format ! ( "{}({})" , ident, args)
426
+ let sugg = format ! ( "({})" , args) ;
427
+ ( format ! ( "{}{}" , ident, sugg) , sugg)
426
428
}
427
429
_ => return ,
428
430
} ;
@@ -431,10 +433,10 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
431
433
// an argument, the `obligation.cause.span` points at the expression
432
434
// of the argument, so we can provide a suggestion. This is signaled
433
435
// 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 ( ) ,
436
438
& msg,
437
- snippet ,
439
+ sugg ,
438
440
Applicability :: HasPlaceholders ,
439
441
) ;
440
442
} else {
@@ -619,7 +621,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
619
621
. source_map ( )
620
622
. span_take_while ( span, |c| c. is_whitespace ( ) || * c == '&' ) ;
621
623
if points_at_arg && mutability == hir:: Mutability :: Not && refs_number > 0 {
622
- err. span_suggestion (
624
+ err. span_suggestion_verbose (
623
625
sp,
624
626
"consider changing this borrow's mutability" ,
625
627
"&mut " . to_string ( ) ,
0 commit comments