@@ -1536,8 +1536,15 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
1536
1536
is_local_mutation_allowed : LocalMutationIsAllowed ,
1537
1537
) -> bool {
1538
1538
debug ! (
1539
+ <<<<<<< HEAD
1539
1540
"check_access_permissions({:?}, {:?}, {:?})" ,
1540
1541
place, kind, is_local_mutation_allowed
1542
+ =======
1543
+ " ({:?}, {:?}, {:?})" ,
1544
+ place,
1545
+ kind,
1546
+ is_local_mutation_allowed
1547
+ >>>>>>> minor changes
1541
1548
) ;
1542
1549
let mut error_reported = false ;
1543
1550
match kind {
@@ -1573,13 +1580,15 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
1573
1580
if let Err ( place_err) = self . is_mutable ( place, is_local_mutation_allowed) {
1574
1581
error_reported = true ;
1575
1582
1576
- match * place{
1577
- Place :: Local ( local) => { let locations = self . mir . find_assignments ( local) ;
1578
-
1579
- for n in & locations{
1580
- debug ! ( "locations ={:?}" , n) ; }
1583
+ let err_help = match * place {
1584
+ Place :: Local ( local) => {
1585
+ let locations = self . mir . find_assignments ( local) ;
1586
+ Some ( ( self . mir . source_info ( locations[ 0 ] ) . span , "consider changing this to be a mutable reference: `&mut `" ) )
1581
1587
}
1582
- _ => { } }
1588
+ _ => {
1589
+ None
1590
+ }
1591
+ } ;
1583
1592
1584
1593
let item_msg = if error_reported{
1585
1594
if let Some ( name) = self . describe_place ( place_err) {
@@ -1602,6 +1611,10 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
1602
1611
if place != place_err {
1603
1612
err. span_label ( span, "cannot assign through `&`-reference" ) ;
1604
1613
}
1614
+
1615
+ if !err_help. is_none ( ) {
1616
+ let ( err_help_span, err_help_stmt) = err_help. unwrap ( ) ;
1617
+ err. span_help ( err_help_span, err_help_stmt) ; }
1605
1618
err. emit ( ) ;
1606
1619
}
1607
1620
}
0 commit comments