summaryrefslogtreecommitdiffstats
path: root/src/test/ui/nll/issue-57100.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
commit64d98f8ee037282c35007b64c2649055c56af1db (patch)
tree5492bcf97fce41ee1c0b1cc2add283f3e66cdab0 /src/test/ui/nll/issue-57100.rs
parentAdding debian version 1.67.1+dfsg1-1. (diff)
downloadrustc-64d98f8ee037282c35007b64c2649055c56af1db.tar.xz
rustc-64d98f8ee037282c35007b64c2649055c56af1db.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/nll/issue-57100.rs')
-rw-r--r--src/test/ui/nll/issue-57100.rs67
1 files changed, 0 insertions, 67 deletions
diff --git a/src/test/ui/nll/issue-57100.rs b/src/test/ui/nll/issue-57100.rs
deleted file mode 100644
index f15929334..000000000
--- a/src/test/ui/nll/issue-57100.rs
+++ /dev/null
@@ -1,67 +0,0 @@
-#![allow(unused)]
-
-
-// This tests the error messages for borrows of union fields when the unions are embedded in other
-// structs or unions.
-
-#[derive(Clone, Copy, Default)]
-struct Leaf {
- l1_u8: u8,
- l2_u8: u8,
-}
-
-#[derive(Clone, Copy)]
-union First {
- f1_leaf: Leaf,
- f2_leaf: Leaf,
- f3_union: Second,
-}
-
-#[derive(Clone, Copy)]
-union Second {
- s1_leaf: Leaf,
- s2_leaf: Leaf,
-}
-
-struct Root {
- r1_u8: u8,
- r2_union: First,
-}
-
-// Borrow a different field of the nested union.
-fn nested_union() {
- unsafe {
- let mut r = Root {
- r1_u8: 3,
- r2_union: First { f3_union: Second { s2_leaf: Leaf { l1_u8: 8, l2_u8: 4 } } }
- };
-
- let mref = &mut r.r2_union.f3_union.s1_leaf.l1_u8;
- // ^^^^^^^
- *mref = 22;
- let nref = &r.r2_union.f3_union.s2_leaf.l1_u8;
- // ^^^^^^^
- //~^^ ERROR cannot borrow `r.r2_union.f3_union` (via `r.r2_union.f3_union.s2_leaf.l1_u8`) as immutable because it is also borrowed as mutable (via `r.r2_union.f3_union.s1_leaf.l1_u8`) [E0502]
- println!("{} {}", mref, nref)
- }
-}
-
-// Borrow a different field of the first union.
-fn first_union() {
- unsafe {
- let mut r = Root {
- r1_u8: 3,
- r2_union: First { f3_union: Second { s2_leaf: Leaf { l1_u8: 8, l2_u8: 4 } } }
- };
-
- let mref = &mut r.r2_union.f2_leaf.l1_u8;
- // ^^^^^^^
- *mref = 22;
- let nref = &r.r2_union.f1_leaf.l1_u8;
- // ^^^^^^^
- //~^^ ERROR cannot borrow `r.r2_union` (via `r.r2_union.f1_leaf.l1_u8`) as immutable because it is also borrowed as mutable (via `r.r2_union.f2_leaf.l1_u8`) [E0502]
- println!("{} {}", mref, nref)
- }
-}
-
-fn main() {}