@@ -268,7 +268,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
268
268
op. node. as_str( ) , lhs_ty) ,
269
269
) ;
270
270
let mut suggested_deref = false ;
271
- if let Ref ( _, mut rty, _) = lhs_ty. sty {
271
+ if let Ref ( _, rty, _) = lhs_ty. sty {
272
272
if {
273
273
self . infcx . type_is_copy_modulo_regions ( self . param_env ,
274
274
rty,
@@ -279,13 +279,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
279
279
. is_ok ( )
280
280
} {
281
281
if let Ok ( lstring) = source_map. span_to_snippet ( lhs_expr. span ) {
282
- while let Ref ( _, rty_inner, _) = rty. sty {
283
- rty = rty_inner;
284
- }
285
282
let msg = & format ! (
286
283
"`{}=` can be used on '{}', you can dereference `{}`" ,
287
284
op. node. as_str( ) ,
288
- rty,
285
+ rty. peel_refs ( ) ,
289
286
lstring,
290
287
) ;
291
288
err. span_suggestion (
@@ -361,7 +358,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
361
358
}
362
359
363
360
let mut suggested_deref = false ;
364
- if let Ref ( _, mut rty, _) = lhs_ty. sty {
361
+ if let Ref ( _, rty, _) = lhs_ty. sty {
365
362
if {
366
363
self . infcx . type_is_copy_modulo_regions ( self . param_env ,
367
364
rty,
@@ -372,17 +369,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
372
369
. is_ok ( )
373
370
} {
374
371
if let Ok ( lstring) = source_map. span_to_snippet ( lhs_expr. span ) {
375
- while let Ref ( _, rty_inner, _) = rty. sty {
376
- rty = rty_inner;
377
- }
378
- let msg = & format ! (
379
- "`{}` can be used on '{}', you can \
380
- dereference `{2}`: `*{2}`",
381
- op. node. as_str( ) ,
382
- rty,
383
- lstring
384
- ) ;
385
- err. help ( msg) ;
372
+ err. help ( & format ! (
373
+ "`{}` can be used on '{}', you can \
374
+ dereference `{2}`: `*{2}`",
375
+ op. node. as_str( ) ,
376
+ rty. peel_refs( ) ,
377
+ lstring
378
+ ) ) ;
386
379
suggested_deref = true ;
387
380
}
388
381
}
0 commit comments