summaryrefslogtreecommitdiffstats
path: root/src/test/ui/nll/issue-16223.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
commit218caa410aa38c29984be31a5229b9fa717560ee (patch)
treec54bd55eeb6e4c508940a30e94c0032fbd45d677 /src/test/ui/nll/issue-16223.rs
parentReleasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz
rustc-218caa410aa38c29984be31a5229b9fa717560ee.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-16223.rs')
-rw-r--r--src/test/ui/nll/issue-16223.rs52
1 files changed, 0 insertions, 52 deletions
diff --git a/src/test/ui/nll/issue-16223.rs b/src/test/ui/nll/issue-16223.rs
deleted file mode 100644
index 0ae0ed3d8..000000000
--- a/src/test/ui/nll/issue-16223.rs
+++ /dev/null
@@ -1,52 +0,0 @@
-// Regression test for #16223: without NLL the `if let` construct together with
-// the nested box-structure of `Root` causes an unwanted collateral move.
-
-// The exact error prevented here is:
-//
-// error[E0382]: use of collaterally moved value: `(root.boxed.rhs as SomeVariant::B).0`
-// --> src/main.rs:55:29
-// |
-// 56 | lhs: SomeVariant::A(a),
-// | - value moved here
-// 57 | rhs: SomeVariant::B(b),
-// | ^ value used here after move
-// |
-// = note: move occurs because the value has type `A`, which does not implement the `Copy` trait
-
-// check-pass
-
-#![feature(box_patterns)]
-
-struct Root {
- boxed: Box<SetOfVariants>,
-}
-
-struct SetOfVariants {
- lhs: SomeVariant,
- rhs: SomeVariant,
-}
-
-enum SomeVariant {
- A(A),
- B(B),
-}
-
-struct A(String);
-struct B(String);
-
-fn main() {
- let root = Root {
- boxed: Box::new(SetOfVariants {
- lhs: SomeVariant::A(A(String::from("This is A"))),
- rhs: SomeVariant::B(B(String::from("This is B"))),
- }),
- };
- if let box SetOfVariants {
- lhs: SomeVariant::A(a),
- rhs: SomeVariant::B(b),
- } = root.boxed
- {
- println!("a = {}", a.0);
- println!("b = {}", b.0);
- }
-}