From a4b7ed7a42c716ab9f05e351f003d589124fd55d Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:18:58 +0200 Subject: Adding upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- .../borrowck-closures-slice-patterns.stderr | 114 +++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 tests/ui/borrowck/borrowck-closures-slice-patterns.stderr (limited to 'tests/ui/borrowck/borrowck-closures-slice-patterns.stderr') diff --git a/tests/ui/borrowck/borrowck-closures-slice-patterns.stderr b/tests/ui/borrowck/borrowck-closures-slice-patterns.stderr new file mode 100644 index 000000000..411d85b8e --- /dev/null +++ b/tests/ui/borrowck/borrowck-closures-slice-patterns.stderr @@ -0,0 +1,114 @@ +error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-closures-slice-patterns.rs:7:13 + | +LL | let f = || { + | -- immutable borrow occurs here +LL | let [ref y, ref z @ ..] = x; + | - first borrow occurs due to use of `x` in closure +LL | }; +LL | let r = &mut x; + | ^^^^^^ mutable borrow occurs here +LL | +LL | f(); + | - immutable borrow later used here + +error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-closures-slice-patterns.rs:16:13 + | +LL | let mut f = || { + | -- mutable borrow occurs here +LL | let [ref mut y, ref mut z @ ..] = x; + | - first borrow occurs due to use of `x` in closure +LL | }; +LL | let r = &x; + | ^^ immutable borrow occurs here +LL | +LL | f(); + | - mutable borrow later used here + +error[E0382]: borrow of moved value: `x` + --> $DIR/borrowck-closures-slice-patterns.rs:25:5 + | +LL | fn arr_by_move(x: [String; 3]) { + | - move occurs because `x` has type `[String; 3]`, which does not implement the `Copy` trait +LL | let f = || { + | -- value moved into closure here +LL | let [y, z @ ..] = x; + | - variable moved due to use in closure +LL | }; +LL | &x; + | ^^ value borrowed here after move + +error[E0502]: cannot borrow `*x` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-closures-slice-patterns.rs:33:13 + | +LL | let f = || { + | -- immutable borrow occurs here +LL | let [ref y, ref z @ ..] = *x; + | -- first borrow occurs due to use of `x` in closure +LL | }; +LL | let r = &mut *x; + | ^^^^^^^ mutable borrow occurs here +LL | +LL | f(); + | - immutable borrow later used here + +error[E0501]: cannot borrow `x` as immutable because previous closure requires unique access + --> $DIR/borrowck-closures-slice-patterns.rs:42:13 + | +LL | let mut f = || { + | -- closure construction occurs here +LL | let [ref mut y, ref mut z @ ..] = *x; + | -- first borrow occurs due to use of `x` in closure +LL | }; +LL | let r = &x; + | ^^ second borrow occurs here +LL | +LL | f(); + | - first borrow later used here + +error[E0382]: borrow of moved value: `x` + --> $DIR/borrowck-closures-slice-patterns.rs:51:5 + | +LL | fn arr_box_by_move(x: Box<[String; 3]>) { + | - move occurs because `x` has type `Box<[String; 3]>`, which does not implement the `Copy` trait +LL | let f = || { + | -- value moved into closure here +LL | let [y, z @ ..] = *x; + | -- variable moved due to use in closure +LL | }; +LL | &x; + | ^^ value borrowed here after move + +error[E0502]: cannot borrow `*x` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-closures-slice-patterns.rs:59:13 + | +LL | let f = || { + | -- immutable borrow occurs here +LL | if let [ref y, ref z @ ..] = *x {} + | -- first borrow occurs due to use of `x` in closure +LL | }; +LL | let r = &mut *x; + | ^^^^^^^ mutable borrow occurs here +LL | +LL | f(); + | - immutable borrow later used here + +error[E0501]: cannot borrow `x` as immutable because previous closure requires unique access + --> $DIR/borrowck-closures-slice-patterns.rs:68:13 + | +LL | let mut f = || { + | -- closure construction occurs here +LL | if let [ref mut y, ref mut z @ ..] = *x {} + | -- first borrow occurs due to use of `x` in closure +LL | }; +LL | let r = &x; + | ^^ second borrow occurs here +LL | +LL | f(); + | - first borrow later used here + +error: aborting due to 8 previous errors + +Some errors have detailed explanations: E0382, E0501, E0502. +For more information about an error, try `rustc --explain E0382`. -- cgit v1.2.3