@@ -1702,7 +1702,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
1702
1702
"check_access_permissions({:?}, {:?}, {:?})" ,
1703
1703
place, kind, is_local_mutation_allowed
1704
1704
) ;
1705
- let mut error_reported = false ;
1705
+
1706
1706
match kind {
1707
1707
Reservation ( WriteKind :: MutableBorrow ( borrow_kind @ BorrowKind :: Unique ) )
1708
1708
| Reservation ( WriteKind :: MutableBorrow ( borrow_kind @ BorrowKind :: Mut { .. } ) )
@@ -1715,9 +1715,11 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
1715
1715
BorrowKind :: Shared => unreachable ! ( ) ,
1716
1716
} ;
1717
1717
match self . is_mutable ( place, is_local_mutation_allowed) {
1718
- Ok ( root_place) => self . add_used_mut ( root_place, flow_state) ,
1718
+ Ok ( root_place) => {
1719
+ self . add_used_mut ( root_place, flow_state) ;
1720
+ return false ;
1721
+ }
1719
1722
Err ( place_err) => {
1720
- error_reported = true ;
1721
1723
let item_msg = self . get_default_err_msg ( place) ;
1722
1724
let mut err = self . tcx
1723
1725
. cannot_borrow_path_as_mutable ( span, & item_msg, Origin :: Mir ) ;
@@ -1731,15 +1733,17 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
1731
1733
}
1732
1734
1733
1735
err. emit ( ) ;
1736
+ return true ;
1734
1737
}
1735
1738
}
1736
1739
}
1737
1740
Reservation ( WriteKind :: Mutate ) | Write ( WriteKind :: Mutate ) => {
1738
1741
match self . is_mutable ( place, is_local_mutation_allowed) {
1739
- Ok ( root_place) => self . add_used_mut ( root_place, flow_state) ,
1742
+ Ok ( root_place) => {
1743
+ self . add_used_mut ( root_place, flow_state) ;
1744
+ return false ;
1745
+ }
1740
1746
Err ( place_err) => {
1741
- error_reported = true ;
1742
-
1743
1747
let err_info = if let Place :: Projection (
1744
1748
box Projection {
1745
1749
base : Place :: Local ( local) ,
@@ -1748,11 +1752,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
1748
1752
) = * place_err {
1749
1753
let locations = self . mir . find_assignments ( local) ;
1750
1754
if locations. len ( ) > 0 {
1751
- let item_msg = if error_reported {
1752
- self . get_secondary_err_msg ( & Place :: Local ( local) )
1753
- } else {
1754
- self . get_default_err_msg ( place)
1755
- } ;
1755
+ let item_msg = self . get_secondary_err_msg ( & Place :: Local ( local) ) ;
1756
1756
let sp = self . mir . source_info ( locations[ 0 ] ) . span ;
1757
1757
let mut to_suggest_span = String :: new ( ) ;
1758
1758
if let Ok ( src) =
@@ -1797,6 +1797,8 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
1797
1797
}
1798
1798
err. emit ( ) ;
1799
1799
}
1800
+
1801
+ return true ;
1800
1802
}
1801
1803
}
1802
1804
}
@@ -1815,15 +1817,20 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
1815
1817
) ,
1816
1818
) ;
1817
1819
}
1820
+ return false ;
1821
+ }
1822
+ Activation ( ..) => {
1823
+ // permission checks are done at Reservation point.
1824
+ return false ;
1818
1825
}
1819
- Activation ( ..) => { } // permission checks are done at Reservation point.
1820
1826
Read ( ReadKind :: Borrow ( BorrowKind :: Unique ) )
1821
1827
| Read ( ReadKind :: Borrow ( BorrowKind :: Mut { .. } ) )
1822
1828
| Read ( ReadKind :: Borrow ( BorrowKind :: Shared ) )
1823
- | Read ( ReadKind :: Copy ) => { } // Access authorized
1829
+ | Read ( ReadKind :: Copy ) => {
1830
+ // Access authorized
1831
+ return false ;
1832
+ }
1824
1833
}
1825
-
1826
- error_reported
1827
1834
}
1828
1835
1829
1836
/// Adds the place into the used mutable variables set
0 commit comments