Skip to content

Commit 6849362

Browse files
author
Cameron Zwarich
committed
Remove the last actual usage of RestrictionSet
Switch to checking BorrowKind values of loans instead of their RestrictionSet values. This was the last code that made a decision based on a RestrictionSet.
1 parent 6ca8dbf commit 6849362

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed

src/librustc/middle/borrowck/check_loans.rs

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -294,25 +294,11 @@ impl<'a> CheckLoanCtxt<'a> {
294294
loan1.repr(self.tcx()),
295295
loan2.repr(self.tcx()));
296296

297-
// Restrictions that would cause the new loan to be illegal:
298-
let illegal_if = match loan2.kind {
299-
// Look for restrictions against mutation. These are
300-
// generated by all other borrows.
301-
ty::MutBorrow => RESTR_MUTATE,
302-
303-
// Look for restrictions against freezing (immutable borrows).
304-
// These are generated by `&mut` borrows.
305-
ty::ImmBorrow => RESTR_FREEZE,
306-
307-
// No matter how the data is borrowed (as `&`, as `&mut`,
308-
// or as `&unique imm`) it will always generate a
309-
// restriction against mutating the data. So look for those.
310-
ty::UniqueImmBorrow => RESTR_MUTATE,
311-
};
312-
debug!("illegal_if={:?}", illegal_if);
297+
if compatible_borrow_kinds(loan1.kind, loan2.kind) {
298+
return true;
299+
}
313300

314301
for restr in loan1.restrictions.iter() {
315-
if !restr.set.intersects(illegal_if) { continue; }
316302
if restr.loan_path != loan2.loan_path { continue; }
317303

318304
let old_pronoun = if new_loan.loan_path == old_loan.loan_path {

0 commit comments

Comments
 (0)