@@ -258,7 +258,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
258258 format ! ( "cannot use `{}=` on type `{}`" ,
259259 op. node. as_str( ) , lhs_ty) ) ;
260260 let mut suggested_deref = false ;
261- if let TyRef ( _, ref ty_mut) = lhs_ty. sty {
261+ if let TyRef ( _, mut ty_mut) = lhs_ty. sty {
262262 if {
263263 !self . infcx . type_moves_by_default ( self . param_env ,
264264 ty_mut. ty ,
@@ -269,10 +269,16 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
269269 . is_ok ( )
270270 } {
271271 if let Ok ( lstring) = codemap. span_to_snippet ( lhs_expr. span ) {
272+ while let TyRef ( _, ty_mut_inner) = ty_mut. ty . sty {
273+ ty_mut = ty_mut_inner;
274+ }
272275 let msg = & format ! (
273276 "`{}=` can be used on '{}', you can \
274277 dereference `{2}`: `*{2}`",
275- op. node. as_str( ) , ty_mut. ty, lstring) ;
278+ op. node. as_str( ) ,
279+ ty_mut. ty,
280+ lstring
281+ ) ;
276282 err. help ( msg) ;
277283 suggested_deref = true ;
278284 }
@@ -300,14 +306,16 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
300306 // we don't want the note in the else clause to be emitted
301307 } else if let ty:: TyParam ( _) = lhs_ty. sty {
302308 // FIXME: point to span of param
303- err. note (
304- & format ! ( "`{}` might need a bound for `{}`" ,
305- lhs_ty, missing_trait) ) ;
309+ err. note ( & format ! (
310+ "`{}` might need a bound for `{}`" ,
311+ lhs_ty, missing_trait
312+ ) ) ;
306313 } else if !suggested_deref {
307- err. note (
308- & format ! ( "an implementation of `{}` might \
309- be missing for `{}`",
310- missing_trait, lhs_ty) ) ;
314+ err. note ( & format ! (
315+ "an implementation of `{}` might \
316+ be missing for `{}`",
317+ missing_trait, lhs_ty
318+ ) ) ;
311319 }
312320 }
313321 err. emit ( ) ;
@@ -318,7 +326,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
318326 op. node. as_str( ) ,
319327 lhs_ty) ;
320328 let mut suggested_deref = false ;
321- if let TyRef ( _, ref ty_mut) = lhs_ty. sty {
329+ if let TyRef ( _, mut ty_mut) = lhs_ty. sty {
322330 if {
323331 !self . infcx . type_moves_by_default ( self . param_env ,
324332 ty_mut. ty ,
@@ -329,10 +337,16 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
329337 . is_ok ( )
330338 } {
331339 if let Ok ( lstring) = codemap. span_to_snippet ( lhs_expr. span ) {
340+ while let TyRef ( _, ty_mut_inner) = ty_mut. ty . sty {
341+ ty_mut = ty_mut_inner;
342+ }
332343 let msg = & format ! (
333344 "`{}` can be used on '{}', you can \
334345 dereference `{2}`: `*{2}`",
335- op. node. as_str( ) , ty_mut. ty, lstring) ;
346+ op. node. as_str( ) ,
347+ ty_mut. ty,
348+ lstring
349+ ) ;
336350 err. help ( msg) ;
337351 suggested_deref = true ;
338352 }
@@ -363,14 +377,16 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
363377 // we don't want the note in the else clause to be emitted
364378 } else if let ty:: TyParam ( _) = lhs_ty. sty {
365379 // FIXME: point to span of param
366- err. note (
367- & format ! ( "`{}` might need a bound for `{}`" ,
368- lhs_ty, missing_trait) ) ;
380+ err. note ( & format ! (
381+ "`{}` might need a bound for `{}`" ,
382+ lhs_ty, missing_trait
383+ ) ) ;
369384 } else if !suggested_deref {
370- err. note (
371- & format ! ( "an implementation of `{}` might \
372- be missing for `{}`",
373- missing_trait, lhs_ty) ) ;
385+ err. note ( & format ! (
386+ "an implementation of `{}` might \
387+ be missing for `{}`",
388+ missing_trait, lhs_ty
389+ ) ) ;
374390 }
375391 }
376392 err. emit ( ) ;
0 commit comments