summaryrefslogtreecommitdiffstats
path: root/tests/ui/binding
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
commitef24de24a82fe681581cc130f342363c47c0969a (patch)
tree0d494f7e1a38b95c92426f58fe6eaa877303a86c /tests/ui/binding
parentReleasing progress-linux version 1.74.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-ef24de24a82fe681581cc130f342363c47c0969a.tar.xz
rustc-ef24de24a82fe681581cc130f342363c47c0969a.zip
Merging upstream version 1.75.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/binding')
-rw-r--r--tests/ui/binding/issue-53114-borrow-checks.rs13
-rw-r--r--tests/ui/binding/issue-53114-borrow-checks.stderr81
2 files changed, 4 insertions, 90 deletions
diff --git a/tests/ui/binding/issue-53114-borrow-checks.rs b/tests/ui/binding/issue-53114-borrow-checks.rs
index 7646472f4..6ab1f4f47 100644
--- a/tests/ui/binding/issue-53114-borrow-checks.rs
+++ b/tests/ui/binding/issue-53114-borrow-checks.rs
@@ -1,8 +1,9 @@
+// check-pass
// Issue #53114: NLL's borrow check had some deviations from the old borrow
// checker, and both had some deviations from our ideal state. This test
// captures the behavior of how `_` bindings are handled with respect to how we
// flag expressions that are meant to request unsafe blocks.
-#![allow(irrefutable_let_patterns)]
+#![allow(irrefutable_let_patterns, dropping_references)]
struct M;
fn let_wild_gets_moved_expr() {
@@ -19,29 +20,23 @@ fn let_wild_gets_moved_expr() {
fn match_moved_expr_to_wild() {
let m = M;
drop(m);
- match m { _ => { } } // #53114: should eventually be accepted too
- //~^ ERROR [E0382]
+ match m { _ => { } } // #53114: accepted too
let mm = (M, M); // variation on above with `_` in substructure
match mm { (_x, _) => { } }
match mm { (_, _y) => { } }
- //~^ ERROR [E0382]
match mm { (_, _) => { } }
- //~^ ERROR [E0382]
}
fn if_let_moved_expr_to_wild() {
let m = M;
drop(m);
- if let _ = m { } // #53114: should eventually be accepted too
- //~^ ERROR [E0382]
+ if let _ = m { } // #53114: accepted too
let mm = (M, M); // variation on above with `_` in substructure
if let (_x, _) = mm { }
if let (_, _y) = mm { }
- //~^ ERROR [E0382]
if let (_, _) = mm { }
- //~^ ERROR [E0382]
}
fn let_wild_gets_borrowed_expr() {
diff --git a/tests/ui/binding/issue-53114-borrow-checks.stderr b/tests/ui/binding/issue-53114-borrow-checks.stderr
deleted file mode 100644
index 0ec2ae883..000000000
--- a/tests/ui/binding/issue-53114-borrow-checks.stderr
+++ /dev/null
@@ -1,81 +0,0 @@
-error[E0382]: use of moved value: `m`
- --> $DIR/issue-53114-borrow-checks.rs:22:11
- |
-LL | let m = M;
- | - move occurs because `m` has type `M`, which does not implement the `Copy` trait
-LL | drop(m);
- | - value moved here
-LL | match m { _ => { } } // #53114: should eventually be accepted too
- | ^ value used here after move
-
-error[E0382]: use of partially moved value: `mm`
- --> $DIR/issue-53114-borrow-checks.rs:27:11
- |
-LL | match mm { (_x, _) => { } }
- | -- value partially moved here
-LL | match mm { (_, _y) => { } }
- | ^^ value used here after partial move
- |
- = note: partial move occurs because `mm.0` has type `M`, which does not implement the `Copy` trait
-help: borrow this binding in the pattern to avoid moving the value
- |
-LL | match mm { (ref _x, _) => { } }
- | +++
-
-error[E0382]: use of partially moved value: `mm`
- --> $DIR/issue-53114-borrow-checks.rs:29:11
- |
-LL | match mm { (_, _y) => { } }
- | -- value partially moved here
-LL |
-LL | match mm { (_, _) => { } }
- | ^^ value used here after partial move
- |
- = note: partial move occurs because `mm.1` has type `M`, which does not implement the `Copy` trait
-help: borrow this binding in the pattern to avoid moving the value
- |
-LL | match mm { (_, ref _y) => { } }
- | +++
-
-error[E0382]: use of moved value: `m`
- --> $DIR/issue-53114-borrow-checks.rs:36:16
- |
-LL | let m = M;
- | - move occurs because `m` has type `M`, which does not implement the `Copy` trait
-LL | drop(m);
- | - value moved here
-LL | if let _ = m { } // #53114: should eventually be accepted too
- | ^ value used here after move
-
-error[E0382]: use of partially moved value: `mm`
- --> $DIR/issue-53114-borrow-checks.rs:41:22
- |
-LL | if let (_x, _) = mm { }
- | -- value partially moved here
-LL | if let (_, _y) = mm { }
- | ^^ value used here after partial move
- |
- = note: partial move occurs because `mm.0` has type `M`, which does not implement the `Copy` trait
-help: borrow this binding in the pattern to avoid moving the value
- |
-LL | if let (ref _x, _) = mm { }
- | +++
-
-error[E0382]: use of partially moved value: `mm`
- --> $DIR/issue-53114-borrow-checks.rs:43:21
- |
-LL | if let (_, _y) = mm { }
- | -- value partially moved here
-LL |
-LL | if let (_, _) = mm { }
- | ^^ value used here after partial move
- |
- = note: partial move occurs because `mm.1` has type `M`, which does not implement the `Copy` trait
-help: borrow this binding in the pattern to avoid moving the value
- |
-LL | if let (_, ref _y) = mm { }
- | +++
-
-error: aborting due to 6 previous errors
-
-For more information about this error, try `rustc --explain E0382`.