@@ -557,24 +557,26 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
557
557
let msg = format ! ( "the `{}` method cannot be invoked on a trait object" , item_name) ;
558
558
let mut err = self . sess ( ) . struct_span_err ( span, & msg) ;
559
559
if !candidates. is_empty ( ) {
560
- let help = format ! ( "{an}other candidate{s} {were} found in the following \
561
- trait{s}, perhaps add a `use` for {one_of_them}:",
562
- an = if candidates. len( ) == 1 { "an" } else { "" } ,
563
- s = pluralise!( candidates. len( ) ) ,
564
- were = if candidates. len( ) == 1 { "was" } else { "were" } ,
565
- one_of_them = if candidates. len( ) == 1 {
566
- "it"
567
- } else {
568
- "one_of_them"
569
- } ) ;
560
+ let help = format ! (
561
+ "{an}other candidate{s} {were} found in the following trait{s}, perhaps \
562
+ add a `use` for {one_of_them}:",
563
+ an = if candidates. len( ) == 1 { "an" } else { "" } ,
564
+ s = pluralise!( candidates. len( ) ) ,
565
+ were = if candidates. len( ) == 1 { "was" } else { "were" } ,
566
+ one_of_them = if candidates. len( ) == 1 {
567
+ "it"
568
+ } else {
569
+ "one_of_them"
570
+ } ,
571
+ ) ;
570
572
self . suggest_use_candidates ( & mut err, help, candidates) ;
571
573
}
572
574
if let ty:: Ref ( region, t_type, mutability) = rcvr_ty. kind {
573
- let trait_type = match mutability {
574
- hir:: Mutability :: MutMutable => self . tcx . mk_imm_ref ( region, t_type) ,
575
- hir:: Mutability :: MutImmutable => self . tcx . mk_mut_ref ( region, t_type) ,
576
- } ;
577
575
if needs_mut {
576
+ let trait_type = self . tcx . mk_ref ( region, ty:: TypeAndMut {
577
+ ty : t_type,
578
+ mutbl : mutability. not ( ) ,
579
+ } ) ;
578
580
err. note ( & format ! ( "you need `{}` instead of `{}`" , trait_type, rcvr_ty) ) ;
579
581
}
580
582
}
0 commit comments