@@ -256,14 +256,19 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
256256 let source_map = self . tcx . sess . source_map ( ) ;
257257 match is_assign {
258258 IsAssign :: Yes => {
259- let mut err = struct_span_err ! ( self . tcx. sess, expr. span, E0368 ,
260- "binary assignment operation `{}=` \
261- cannot be applied to type `{}`",
262- op. node. as_str( ) ,
263- lhs_ty) ;
264- err. span_label ( lhs_expr. span ,
265- format ! ( "cannot use `{}=` on type `{}`" ,
266- op. node. as_str( ) , lhs_ty) ) ;
259+ let mut err = struct_span_err ! (
260+ self . tcx. sess,
261+ expr. span,
262+ E0368 ,
263+ "binary assignment operation `{}=` cannot be applied to type `{}`" ,
264+ op. node. as_str( ) ,
265+ lhs_ty,
266+ ) ;
267+ err. span_label (
268+ lhs_expr. span ,
269+ format ! ( "cannot use `{}=` on type `{}`" ,
270+ op. node. as_str( ) , lhs_ty) ,
271+ ) ;
267272 let mut suggested_deref = false ;
268273 if let Ref ( _, mut rty, _) = lhs_ty. sty {
269274 if {
@@ -280,13 +285,17 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
280285 rty = rty_inner;
281286 }
282287 let msg = & format ! (
283- "`{}=` can be used on '{}', you can \
284- dereference `{2}`: `*{2}`",
285- op. node. as_str( ) ,
286- rty,
287- lstring
288+ "`{}=` can be used on '{}', you can dereference `{}`" ,
289+ op. node. as_str( ) ,
290+ rty,
291+ lstring,
292+ ) ;
293+ err. span_suggestion_with_applicability (
294+ lhs_expr. span ,
295+ msg,
296+ format ! ( "*{}" , lstring) ,
297+ errors:: Applicability :: MachineApplicable ,
288298 ) ;
289- err. help ( msg) ;
290299 suggested_deref = true ;
291300 }
292301 }
0 commit comments