diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:18:25 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:18:25 +0000 |
commit | 5363f350887b1e5b5dd21a86f88c8af9d7fea6da (patch) | |
tree | 35ca005eb6e0e9a1ba3bb5dbc033209ad445dc17 /src/test/ui/pattern | |
parent | Adding debian version 1.66.0+dfsg1-1. (diff) | |
download | rustc-5363f350887b1e5b5dd21a86f88c8af9d7fea6da.tar.xz rustc-5363f350887b1e5b5dd21a86f88c8af9d7fea6da.zip |
Merging upstream version 1.67.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/pattern')
18 files changed, 317 insertions, 27 deletions
diff --git a/src/test/ui/pattern/bindings-after-at/bind-by-move-neither-can-live-while-the-other-survives-1.stderr b/src/test/ui/pattern/bindings-after-at/bind-by-move-neither-can-live-while-the-other-survives-1.stderr index fad84dda0..c8b45fd24 100644 --- a/src/test/ui/pattern/bindings-after-at/bind-by-move-neither-can-live-while-the-other-survives-1.stderr +++ b/src/test/ui/pattern/bindings-after-at/bind-by-move-neither-can-live-while-the-other-survives-1.stderr @@ -16,6 +16,11 @@ LL | Some(_z @ ref _y) => {} | | value borrowed here after move | value moved into `_z` here | move occurs because `_z` has type `X` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | Some(ref _z @ ref _y) => {} + | +++ error: cannot move out of value because it is borrowed --> $DIR/bind-by-move-neither-can-live-while-the-other-survives-1.rs:26:14 @@ -35,6 +40,11 @@ LL | Some(_z @ ref mut _y) => {} | | value borrowed here after move | value moved into `_z` here | move occurs because `_z` has type `X` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | Some(ref _z @ ref mut _y) => {} + | +++ error[E0382]: borrow of moved value --> $DIR/bind-by-move-neither-can-live-while-the-other-survives-1.rs:12:14 @@ -45,7 +55,7 @@ LL | Some(ref _y @ _z) => {} | value borrowed here after move | = note: move occurs because value has type `X`, which does not implement the `Copy` trait -help: borrow this field in the pattern to avoid moving `x.0` +help: borrow this binding in the pattern to avoid moving the value | LL | Some(ref _y @ ref _z) => {} | +++ @@ -59,7 +69,7 @@ LL | Some(ref mut _y @ _z) => {} | value borrowed here after move | = note: move occurs because value has type `X`, which does not implement the `Copy` trait -help: borrow this field in the pattern to avoid moving `x.0` +help: borrow this binding in the pattern to avoid moving the value | LL | Some(ref mut _y @ ref _z) => {} | +++ diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.stderr b/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.stderr index a227cc583..324897151 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.stderr +++ b/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.stderr @@ -6,6 +6,11 @@ LL | let a @ b = U; | | | | | value moved here | value used here after move + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref a @ ref b = U; + | +++ +++ error[E0382]: use of partially moved value --> $DIR/borrowck-move-and-move.rs:13:9 @@ -16,6 +21,10 @@ LL | let a @ (b, c) = (U, U); | value used here after partial move | = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref a @ (b, ref c) = (U, U); + | +++ +++ error[E0382]: use of partially moved value --> $DIR/borrowck-move-and-move.rs:15:9 @@ -26,6 +35,10 @@ LL | let a @ (b, c) = (u(), u()); | value used here after partial move | = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref a @ (b, ref c) = (u(), u()); + | +++ +++ error[E0382]: use of moved value --> $DIR/borrowck-move-and-move.rs:18:16 @@ -36,6 +49,11 @@ LL | a @ Ok(b) | a @ Err(b) => {} | - ^ value used here after move | | | value moved here + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | ref a @ Ok(b) | a @ Err(b) => {} + | +++ error[E0382]: use of moved value --> $DIR/borrowck-move-and-move.rs:18:29 @@ -46,6 +64,11 @@ LL | a @ Ok(b) | a @ Err(b) => {} | - ^ value used here after move | | | value moved here + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | a @ Ok(b) | ref a @ Err(b) => {} + | +++ error[E0382]: use of partially moved value --> $DIR/borrowck-move-and-move.rs:25:9 @@ -56,6 +79,10 @@ LL | xs @ [a, .., b] => {} | value used here after partial move | = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | ref xs @ [a, .., ref b] => {} + | +++ +++ error[E0382]: use of partially moved value --> $DIR/borrowck-move-and-move.rs:29:9 @@ -66,6 +93,10 @@ LL | xs @ [_, ys @ .., _] => {} | value used here after partial move | = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | ref xs @ [_, ref ys @ .., _] => {} + | +++ +++ error[E0382]: use of moved value --> $DIR/borrowck-move-and-move.rs:22:12 diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-at-and-box.stderr b/src/test/ui/pattern/bindings-after-at/borrowck-pat-at-and-box.stderr index 002c7609f..f27df32cc 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-at-and-box.stderr +++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-at-and-box.stderr @@ -79,6 +79,10 @@ LL | let ref a @ box b = Box::new(NC); | value borrowed here after move | = note: move occurs because value has type `NC`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref a @ box ref b = Box::new(NC); + | +++ error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable --> $DIR/borrowck-pat-at-and-box.rs:38:9 diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse-promotion.stderr b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse-promotion.stderr index be4e81c61..d6474f1b4 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse-promotion.stderr +++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse-promotion.stderr @@ -7,6 +7,11 @@ LL | let a @ ref b = U; | | value borrowed here after move | value moved into `a` here | move occurs because `a` has type `U` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref a @ ref b = U; + | +++ error: aborting due to previous error diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.stderr b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.stderr index a9e66de08..389e86e64 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.stderr +++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.stderr @@ -7,6 +7,11 @@ LL | let a @ ref b = U; | | value borrowed here after move | value moved into `a` here | move occurs because `a` has type `U` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref a @ ref b = U; + | +++ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:24:9 @@ -18,6 +23,11 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (U, U); | | value borrowed here after move | value moved into `a` here | move occurs because `a` has type `(U, U)` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref a @ (mut b @ ref mut c, d @ ref e) = (U, U); + | +++ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:24:14 @@ -28,6 +38,11 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (U, U); | | value borrowed here after move | value moved into `b` here | move occurs because `b` has type `U` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | let a @ (ref mut b @ ref mut c, d @ ref e) = (U, U); + | +++ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:24:33 @@ -38,6 +53,11 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (U, U); | | value borrowed here after move | value moved into `d` here | move occurs because `d` has type `U` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | let a @ (mut b @ ref mut c, ref d @ ref e) = (U, U); + | +++ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:29:9 @@ -49,6 +69,11 @@ LL | let a @ [ref mut b, ref c] = [U, U]; | | value borrowed here after move | value moved into `a` here | move occurs because `a` has type `[U; 2]` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref a @ [ref mut b, ref c] = [U, U]; + | +++ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:31:9 @@ -59,6 +84,11 @@ LL | let a @ ref b = u(); | | value borrowed here after move | value moved into `a` here | move occurs because `a` has type `U` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref a @ ref b = u(); + | +++ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:33:9 @@ -70,6 +100,11 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (u(), u()); | | value borrowed here after move | value moved into `a` here | move occurs because `a` has type `(U, U)` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref a @ (mut b @ ref mut c, d @ ref e) = (u(), u()); + | +++ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:33:14 @@ -80,6 +115,11 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (u(), u()); | | value borrowed here after move | value moved into `b` here | move occurs because `b` has type `U` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | let a @ (ref mut b @ ref mut c, d @ ref e) = (u(), u()); + | +++ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:33:33 @@ -90,6 +130,11 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (u(), u()); | | value borrowed here after move | value moved into `d` here | move occurs because `d` has type `U` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | let a @ (mut b @ ref mut c, ref d @ ref e) = (u(), u()); + | +++ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:38:9 @@ -101,6 +146,11 @@ LL | let a @ [ref mut b, ref c] = [u(), u()]; | | value borrowed here after move | value moved into `a` here | move occurs because `a` has type `[U; 2]` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref a @ [ref mut b, ref c] = [u(), u()]; + | +++ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:42:9 @@ -111,6 +161,11 @@ LL | a @ Some(ref b) => {} | | value borrowed here after move | value moved into `a` here | move occurs because `a` has type `Option<U>` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | ref a @ Some(ref b) => {} + | +++ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:47:9 @@ -122,6 +177,11 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | | value borrowed here after move | value moved into `a` here | move occurs because `a` has type `Option<(U, U)>` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | ref a @ Some((mut b @ ref mut c, d @ ref e)) => {} + | +++ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:47:19 @@ -132,6 +192,11 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | | value borrowed here after move | value moved into `b` here | move occurs because `b` has type `U` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | a @ Some((ref mut b @ ref mut c, d @ ref e)) => {} + | +++ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:47:38 @@ -142,6 +207,11 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | | value borrowed here after move | value moved into `d` here | move occurs because `d` has type `U` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | a @ Some((mut b @ ref mut c, ref d @ ref e)) => {} + | +++ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:55:9 @@ -153,6 +223,11 @@ LL | mut a @ Some([ref b, ref mut c]) => {} | | value borrowed here after move | value moved into `a` here | move occurs because `a` has type `Option<[U; 2]>` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | ref mut a @ Some([ref b, ref mut c]) => {} + | +++ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:61:9 @@ -163,6 +238,11 @@ LL | a @ Some(ref b) => {} | | value borrowed here after move | value moved into `a` here | move occurs because `a` has type `Option<U>` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | ref a @ Some(ref b) => {} + | +++ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:67:9 @@ -174,6 +254,11 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | | value borrowed here after move | value moved into `a` here | move occurs because `a` has type `Option<(U, U)>` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | ref a @ Some((mut b @ ref mut c, d @ ref e)) => {} + | +++ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:67:19 @@ -184,6 +269,11 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | | value borrowed here after move | value moved into `b` here | move occurs because `b` has type `U` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | a @ Some((ref mut b @ ref mut c, d @ ref e)) => {} + | +++ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:67:38 @@ -194,6 +284,11 @@ LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | | value borrowed here after move | value moved into `d` here | move occurs because `d` has type `U` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | a @ Some((mut b @ ref mut c, ref d @ ref e)) => {} + | +++ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:75:9 @@ -205,6 +300,11 @@ LL | mut a @ Some([ref b, ref mut c]) => {} | | value borrowed here after move | value moved into `a` here | move occurs because `a` has type `Option<[U; 2]>` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | ref mut a @ Some([ref b, ref mut c]) => {} + | +++ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:11:11 @@ -215,6 +315,11 @@ LL | fn f1(a @ ref b: U) {} | | value borrowed here after move | value moved into `a` here | move occurs because `a` has type `U` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | fn f1(ref a @ ref b: U) {} + | +++ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:14:11 @@ -226,6 +331,11 @@ LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {} | | value borrowed here after move | value moved into `a` here | move occurs because `a` has type `(U, U)` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | fn f2(ref mut a @ (b @ ref c, mut d @ ref e): (U, U)) {} + | +++ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:14:20 @@ -236,6 +346,11 @@ LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {} | | value borrowed here after move | value moved into `b` here | move occurs because `b` has type `U` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | fn f2(mut a @ (ref b @ ref c, mut d @ ref e): (U, U)) {} + | +++ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:14:31 @@ -246,6 +361,11 @@ LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {} | | value borrowed here after move | value moved into `d` here | move occurs because `d` has type `U` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | fn f2(mut a @ (b @ ref c, ref mut d @ ref e): (U, U)) {} + | +++ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:19:11 @@ -257,6 +377,11 @@ LL | fn f3(a @ [ref mut b, ref c]: [U; 2]) {} | | value borrowed here after move | value moved into `a` here | move occurs because `a` has type `[U; 2]` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | fn f3(ref a @ [ref mut b, ref c]: [U; 2]) {} + | +++ error[E0382]: use of partially moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:24:9 @@ -267,6 +392,10 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (U, U); | value used here after partial move | = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref a @ (mut b @ ref mut c, ref d @ ref e) = (U, U); + | +++ +++ error[E0382]: use of partially moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:33:9 @@ -277,6 +406,10 @@ LL | let a @ (mut b @ ref mut c, d @ ref e) = (u(), u()); | value used here after partial move | = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref a @ (mut b @ ref mut c, ref d @ ref e) = (u(), u()); + | +++ +++ error[E0382]: use of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:47:38 @@ -285,6 +418,11 @@ LL | match Some((U, U)) { | ------------ move occurs because value has type `Option<(U, U)>`, which does not implement the `Copy` trait LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | - value moved here ^ value used here after move + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | ref a @ Some((mut b @ ref mut c, d @ ref e)) => {} + | +++ error[E0382]: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:55:30 @@ -305,6 +443,11 @@ LL | a @ Some(ref b) => {} | - ^^^^^ value borrowed here after move | | | value moved here + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | ref a @ Some(ref b) => {} + | +++ error[E0382]: use of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:67:38 @@ -313,6 +456,11 @@ LL | match Some((u(), u())) { | ---------------- move occurs because value has type `Option<(U, U)>`, which does not implement the `Copy` trait LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} | - value moved here ^ value used here after move + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | ref a @ Some((mut b @ ref mut c, d @ ref e)) => {} + | +++ error[E0382]: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:75:30 diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.stderr b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.stderr index b2f22fe86..770bb8953 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.stderr +++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.stderr @@ -242,6 +242,10 @@ LL | let ref mut a @ [b, mut c] = [U, U]; | value borrowed here after partial move | = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref mut a @ [b, ref mut c] = [U, U]; + | +++ error[E0382]: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref.rs:33:9 @@ -251,6 +255,11 @@ LL | let ref a @ b = u(); | | | | | value moved here | value borrowed here after move + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref a @ ref b = u(); + | +++ error[E0382]: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref.rs:36:18 @@ -261,6 +270,10 @@ LL | let ref a @ (ref b @ mut c, ref d @ e) = (u(), u()); | value borrowed here after move | = note: move occurs because value has type `U`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref a @ (ref b @ ref mut c, ref d @ e) = (u(), u()); + | +++ error[E0382]: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref.rs:36:33 @@ -271,6 +284,10 @@ LL | let ref a @ (ref b @ mut c, ref d @ e) = (u(), u()); | value borrowed here after move | = note: move occurs because value has type `U`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref a @ (ref b @ mut c, ref d @ ref e) = (u(), u()); + | +++ error[E0382]: borrow of partially moved value --> $DIR/borrowck-pat-by-move-and-ref.rs:42:9 @@ -281,6 +298,10 @@ LL | let ref mut a @ [b, mut c] = [u(), u()]; | value borrowed here after partial move | = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref mut a @ [b, ref mut c] = [u(), u()]; + | +++ error[E0382]: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref.rs:69:23 @@ -291,7 +312,7 @@ LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} | value borrowed here after move | = note: move occurs because value has type `U`, which does not implement the `Copy` trait -help: borrow this field in the pattern to avoid moving the value +help: borrow this binding in the pattern to avoid moving the value | LL | ref a @ Some((ref b @ ref mut c, ref d @ e)) => {} | +++ @@ -305,7 +326,7 @@ LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} | value borrowed here after move | = note: move occurs because value has type `U`, which does not implement the `Copy` trait -help: borrow this field in the pattern to avoid moving the value +help: borrow this binding in the pattern to avoid moving the value | LL | ref a @ Some((ref b @ mut c, ref d @ ref e)) => {} | +++ diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.stderr b/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.stderr index 384a57b2e..ad4ce7952 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.stderr +++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.stderr @@ -97,6 +97,11 @@ LL | let a @ (ref mut b, ref mut c) = (U, U); | | value borrowed here after move | value moved into `a` here | move occurs because `a` has type `(U, U)` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref a @ (ref mut b, ref mut c) = (U, U); + | +++ error: borrow of moved value --> $DIR/borrowck-pat-ref-mut-twice.rs:67:9 @@ -109,6 +114,11 @@ LL | let a @ (b, [c, d]) = &mut val; // Same as ^-- | | value borrowed here after move | value moved into `a` here | move occurs because `a` has type `&mut (U, [U; 2])` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref a @ (b, [c, d]) = &mut val; // Same as ^-- + | +++ error: borrow of moved value --> $DIR/borrowck-pat-ref-mut-twice.rs:70:9 @@ -119,6 +129,11 @@ LL | let a @ &mut ref mut b = &mut U; | | value borrowed here after move | value moved into `a` here | move occurs because `a` has type `&mut U` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref a @ &mut ref mut b = &mut U; + | +++ error: borrow of moved value --> $DIR/borrowck-pat-ref-mut-twice.rs:72:9 @@ -130,6 +145,11 @@ LL | let a @ &mut (ref mut b, ref mut c) = &mut (U, U); | | value borrowed here after move | value moved into `a` here | move occurs because `a` has type `&mut (U, U)` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref a @ &mut (ref mut b, ref mut c) = &mut (U, U); + | +++ error: cannot borrow value as mutable more than once at a time --> $DIR/borrowck-pat-ref-mut-twice.rs:76:9 diff --git a/src/test/ui/pattern/bindings-after-at/copy-and-move-mixed.stderr b/src/test/ui/pattern/bindings-after-at/copy-and-move-mixed.stderr index cd3234952..e0e623fa5 100644 --- a/src/test/ui/pattern/bindings-after-at/copy-and-move-mixed.stderr +++ b/src/test/ui/pattern/bindings-after-at/copy-and-move-mixed.stderr @@ -7,6 +7,10 @@ LL | let a @ NC(b, c @ NC(d, e)) = NC(C, NC(C, C)); | value used here after partial move | = note: partial move occurs because value has type `NC<C, C>`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref a @ NC(b, ref c @ NC(d, e)) = NC(C, NC(C, C)); + | +++ +++ error: aborting due to previous error diff --git a/src/test/ui/pattern/bindings-after-at/default-binding-modes-both-sides-independent.stderr b/src/test/ui/pattern/bindings-after-at/default-binding-modes-both-sides-independent.stderr index 840a513d6..638bdd6db 100644 --- a/src/test/ui/pattern/bindings-after-at/default-binding-modes-both-sides-independent.stderr +++ b/src/test/ui/pattern/bindings-after-at/default-binding-modes-both-sides-independent.stderr @@ -34,6 +34,11 @@ LL | Ok(ref a @ b) | Err(b @ ref a) => { | | value borrowed here after move | value moved into `b` here | move occurs because `b` has type `NotCopy` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | Ok(ref a @ b) | Err(ref b @ ref a) => { + | +++ error: cannot move out of value because it is borrowed --> $DIR/default-binding-modes-both-sides-independent.rs:42:9 @@ -52,6 +57,11 @@ LL | let ref mut a @ b = NotCopy; | | | | | value moved here | value borrowed here after move + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ref mut a @ ref b = NotCopy; + | +++ error: aborting due to 6 previous errors diff --git a/src/test/ui/pattern/issue-52240.rs b/src/test/ui/pattern/issue-52240.rs new file mode 100644 index 000000000..5def55778 --- /dev/null +++ b/src/test/ui/pattern/issue-52240.rs @@ -0,0 +1,16 @@ +// issue-52240: Can turn immutable into mut with `ref mut` + +enum Foo { + Bar(i32), +} + +fn main() { + let arr = vec!(Foo::Bar(0)); + if let (Some(Foo::Bar(ref mut val)), _) = (&arr.get(0), 0) { + //~^ ERROR cannot borrow data in a `&` reference as mutable + *val = 9001; + } + match arr[0] { + Foo::Bar(ref s) => println!("{}", s) + } +} diff --git a/src/test/ui/pattern/issue-52240.stderr b/src/test/ui/pattern/issue-52240.stderr new file mode 100644 index 000000000..69b663b17 --- /dev/null +++ b/src/test/ui/pattern/issue-52240.stderr @@ -0,0 +1,9 @@ +error[E0596]: cannot borrow data in a `&` reference as mutable + --> $DIR/issue-52240.rs:9:27 + | +LL | if let (Some(Foo::Bar(ref mut val)), _) = (&arr.get(0), 0) { + | ^^^^^^^^^^^ cannot borrow as mutable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.stderr b/src/test/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.stderr index bac2db6ce..bb7b81836 100644 --- a/src/test/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.stderr +++ b/src/test/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.stderr @@ -129,6 +129,10 @@ LL | drop(tup.1); | ^^^^^ value used here after move | = note: move occurs because `tup.1` has type `U`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | let (ref _x0, ref _x1, ref _x2, ..) = tup; + | +++ error[E0382]: borrow of moved value: `tup.1` --> $DIR/borrowck-move-ref-pattern.rs:29:20 diff --git a/src/test/ui/pattern/non-structural-match-types.stderr b/src/test/ui/pattern/non-structural-match-types.stderr index 45e162649..dea7c4695 100644 --- a/src/test/ui/pattern/non-structural-match-types.stderr +++ b/src/test/ui/pattern/non-structural-match-types.stderr @@ -4,7 +4,7 @@ error: `[closure@$DIR/non-structural-match-types.rs:9:17: 9:19]` cannot be used LL | const { || {} } => {}, | ^^^^^^^^^^^^^^^ -error: `impl Future<Output = ()>` cannot be used in patterns +error: `[async block@$DIR/non-structural-match-types.rs:12:17: 12:25]` cannot be used in patterns --> $DIR/non-structural-match-types.rs:12:9 | LL | const { async {} } => {}, diff --git a/src/test/ui/pattern/pattern-binding-disambiguation.rs b/src/test/ui/pattern/pattern-binding-disambiguation.rs index 2e80ea345..ce1d8c6c0 100644 --- a/src/test/ui/pattern/pattern-binding-disambiguation.rs +++ b/src/test/ui/pattern/pattern-binding-disambiguation.rs @@ -33,7 +33,7 @@ fn main() { TupleVariant => {} //~ ERROR match bindings cannot shadow tuple variants } match doesnt_matter { - BracedVariant => {} //~ ERROR match bindings cannot shadow struct variants + BracedVariant => {} // OK, `BracedVariant` is a fresh binding } match CONST { CONST => {} // OK, `CONST` is a const pattern @@ -50,7 +50,7 @@ fn main() { let BracedStruct = doesnt_matter; // OK, `BracedStruct` is a fresh binding let UnitVariant = UnitVariant; // OK, `UnitVariant` is a unit variant pattern let TupleVariant = doesnt_matter; //~ ERROR let bindings cannot shadow tuple variants - let BracedVariant = doesnt_matter; //~ ERROR let bindings cannot shadow struct variants + let BracedVariant = doesnt_matter; // OK, `BracedVariant` is a fresh binding let CONST = CONST; // OK, `CONST` is a const pattern let STATIC = doesnt_matter; //~ ERROR let bindings cannot shadow statics let function = doesnt_matter; // OK, `function` is a fresh binding diff --git a/src/test/ui/pattern/pattern-binding-disambiguation.stderr b/src/test/ui/pattern/pattern-binding-disambiguation.stderr index 1529e538b..d54467b3c 100644 --- a/src/test/ui/pattern/pattern-binding-disambiguation.stderr +++ b/src/test/ui/pattern/pattern-binding-disambiguation.stderr @@ -22,15 +22,6 @@ LL | TupleVariant => {} | cannot be named the same as a tuple variant | help: try specify the pattern arguments: `TupleVariant(..)` -error[E0530]: match bindings cannot shadow struct variants - --> $DIR/pattern-binding-disambiguation.rs:36:9 - | -LL | use E::*; - | ---- the struct variant `BracedVariant` is imported here -... -LL | BracedVariant => {} - | ^^^^^^^^^^^^^ cannot be named the same as a struct variant - error[E0530]: match bindings cannot shadow statics --> $DIR/pattern-binding-disambiguation.rs:42:9 | @@ -58,15 +49,6 @@ LL | use E::*; LL | let TupleVariant = doesnt_matter; | ^^^^^^^^^^^^ cannot be named the same as a tuple variant -error[E0530]: let bindings cannot shadow struct variants - --> $DIR/pattern-binding-disambiguation.rs:53:9 - | -LL | use E::*; - | ---- the struct variant `BracedVariant` is imported here -... -LL | let BracedVariant = doesnt_matter; - | ^^^^^^^^^^^^^ cannot be named the same as a struct variant - error[E0530]: let bindings cannot shadow statics --> $DIR/pattern-binding-disambiguation.rs:55:9 | @@ -76,6 +58,6 @@ LL | static STATIC: () = (); LL | let STATIC = doesnt_matter; | ^^^^^^ cannot be named the same as a static -error: aborting due to 8 previous errors +error: aborting due to 6 previous errors For more information about this error, try `rustc --explain E0530`. diff --git a/src/test/ui/pattern/usefulness/const-partial_eq-fallback-ice.rs b/src/test/ui/pattern/usefulness/const-partial_eq-fallback-ice.rs new file mode 100644 index 000000000..02599d7c0 --- /dev/null +++ b/src/test/ui/pattern/usefulness/const-partial_eq-fallback-ice.rs @@ -0,0 +1,18 @@ +#![allow(warnings)] + +struct MyType; + +impl PartialEq<usize> for MyType { + fn eq(&self, y: &usize) -> bool { + true + } +} + +const CONSTANT: &&MyType = &&MyType; + +fn main() { + if let CONSTANT = &&MyType { + //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` + println!("did match!"); + } +} diff --git a/src/test/ui/pattern/usefulness/const-partial_eq-fallback-ice.stderr b/src/test/ui/pattern/usefulness/const-partial_eq-fallback-ice.stderr new file mode 100644 index 000000000..358421cd6 --- /dev/null +++ b/src/test/ui/pattern/usefulness/const-partial_eq-fallback-ice.stderr @@ -0,0 +1,8 @@ +error: to use a constant of type `MyType` in a pattern, `MyType` must be annotated with `#[derive(PartialEq, Eq)]` + --> $DIR/const-partial_eq-fallback-ice.rs:14:12 + | +LL | if let CONSTANT = &&MyType { + | ^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/pattern/usefulness/uninhabited.rs b/src/test/ui/pattern/usefulness/uninhabited.rs index 77cd0f400..5622808d4 100644 --- a/src/test/ui/pattern/usefulness/uninhabited.rs +++ b/src/test/ui/pattern/usefulness/uninhabited.rs @@ -2,7 +2,7 @@ // aux-build:empty.rs // // This tests plays with matching and uninhabited types. This also serves as a test for the -// `tcx.is_ty_uninhabited_from()` function. +// `Ty::is_inhabited_from` function. #![feature(never_type)] #![feature(never_type_fallback)] #![feature(exhaustive_patterns)] |