@@ -258,7 +258,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
258
258
format ! ( "cannot use `{}=` on type `{}`" ,
259
259
op. node. as_str( ) , lhs_ty) ) ;
260
260
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 {
262
262
if {
263
263
!self . infcx . type_moves_by_default ( self . param_env ,
264
264
ty_mut. ty ,
@@ -269,10 +269,16 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
269
269
. is_ok ( )
270
270
} {
271
271
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
+ }
272
275
let msg = & format ! (
273
276
"`{}=` can be used on '{}', you can \
274
277
dereference `{2}`: `*{2}`",
275
- op. node. as_str( ) , ty_mut. ty, lstring) ;
278
+ op. node. as_str( ) ,
279
+ ty_mut. ty,
280
+ lstring
281
+ ) ;
276
282
err. help ( msg) ;
277
283
suggested_deref = true ;
278
284
}
@@ -300,14 +306,16 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
300
306
// we don't want the note in the else clause to be emitted
301
307
} else if let ty:: TyParam ( _) = lhs_ty. sty {
302
308
// 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
+ ) ) ;
306
313
} 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
+ ) ) ;
311
319
}
312
320
}
313
321
err. emit ( ) ;
@@ -318,7 +326,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
318
326
op. node. as_str( ) ,
319
327
lhs_ty) ;
320
328
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 {
322
330
if {
323
331
!self . infcx . type_moves_by_default ( self . param_env ,
324
332
ty_mut. ty ,
@@ -329,10 +337,16 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
329
337
. is_ok ( )
330
338
} {
331
339
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
+ }
332
343
let msg = & format ! (
333
344
"`{}` can be used on '{}', you can \
334
345
dereference `{2}`: `*{2}`",
335
- op. node. as_str( ) , ty_mut. ty, lstring) ;
346
+ op. node. as_str( ) ,
347
+ ty_mut. ty,
348
+ lstring
349
+ ) ;
336
350
err. help ( msg) ;
337
351
suggested_deref = true ;
338
352
}
@@ -363,14 +377,16 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
363
377
// we don't want the note in the else clause to be emitted
364
378
} else if let ty:: TyParam ( _) = lhs_ty. sty {
365
379
// 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
+ ) ) ;
369
384
} 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
+ ) ) ;
374
390
}
375
391
}
376
392
err. emit ( ) ;
0 commit comments