mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-31 13:40:15 +03:00
committed by
Josh Stone
parent
033c92370e
commit
cbdde36f5e
@@ -236,9 +236,12 @@ fn drop(&mut self) {
|
||||
fn temporary_scope_introduction() {
|
||||
// Fails to compile if the macros don't introduce a temporary scope, since `&mut val` would
|
||||
// create a second mutable borrow while `MutRefWithDrop` still holds a unique ref.
|
||||
// See https://github.com/rust-lang/rust/issues/154406 for reference.
|
||||
let mut val = 0;
|
||||
|
||||
(assert_matches!(*MutRefWithDrop(&mut val).0, 0), std::mem::take(&mut val));
|
||||
(assert_matches!(*MutRefWithDrop(&mut val).0, 0, "msg"), std::mem::take(&mut val));
|
||||
|
||||
(debug_assert_matches!(*MutRefWithDrop(&mut val).0, 0), std::mem::take(&mut val));
|
||||
(debug_assert_matches!(*MutRefWithDrop(&mut val).0, 0, "msg"), std::mem::take(&mut val));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user