)
}
- (BorrowKind::Shallow, _, _, BorrowKind::Unique, _, _)
- | (BorrowKind::Shallow, _, _, BorrowKind::Mut { .. }, _, _) => {
- // Shallow borrows are uses from the user's point of view.
- self.report_use_while_mutably_borrowed(context, (place, span), issued_borrow);
- return;
- }
(BorrowKind::Shared, _, _, BorrowKind::Shared, _, _)
| (BorrowKind::Shared, _, _, BorrowKind::Shallow, _, _)
+ | (BorrowKind::Shallow, _, _, BorrowKind::Mut { .. }, _, _)
+ | (BorrowKind::Shallow, _, _, BorrowKind::Unique, _, _)
| (BorrowKind::Shallow, _, _, BorrowKind::Shared, _, _)
| (BorrowKind::Shallow, _, _, BorrowKind::Shallow, _, _) => unreachable!(),
};
interior mutability, create a static instead");
}
}
- } else {
+ } else if let BorrowKind::Mut { .. } | BorrowKind::Shared = kind {
+ // Don't promote BorrowKind::Shallow borrows, as they don't
+ // reach codegen.
+
// We might have a candidate for promotion.
let candidate = Candidate::Ref(location);
// We can only promote interior borrows of promotable temps.
// }
// bb8: { // binding1 and guard
// StorageLive(_6);
-// _6 = &(((promoted[1]: std::option::Option<i32>) as Some).0: i32);
-// _4 = &shallow (promoted[0]: std::option::Option<i32>);
+// _6 = &(((promoted[0]: std::option::Option<i32>) as Some).0: i32);
+// _4 = &shallow _2;
// StorageLive(_7);
// _7 = const guard() -> [return: bb9, unwind: bb1];
// }