bindings_after_at: harden tests wrt. contexts & slice_patterns
This commit is contained in:
parent
0034e6199e
commit
6fa8f4a57b
|
@ -2,6 +2,7 @@
|
|||
|
||||
#![feature(bindings_after_at)]
|
||||
//~^ WARN the feature `bindings_after_at` is incomplete and may cause the compiler to crash
|
||||
#![feature(slice_patterns)]
|
||||
|
||||
fn main() {
|
||||
struct U; // Not copy!
|
||||
|
@ -28,4 +29,20 @@ fn main() {
|
|||
//~| ERROR cannot bind by-move with sub-bindings
|
||||
//~| ERROR use of moved value
|
||||
}
|
||||
|
||||
fn fun(a @ b: U) {}
|
||||
//~^ ERROR cannot bind by-move with sub-bindings
|
||||
//~| ERROR use of moved value
|
||||
|
||||
match [u(), u(), u(), u()] {
|
||||
xs @ [a, .., b] => {}
|
||||
//~^ ERROR cannot bind by-move with sub-bindings
|
||||
//~| ERROR use of moved value
|
||||
}
|
||||
|
||||
match [u(), u(), u(), u()] {
|
||||
xs @ [_, ys @ .., _] => {}
|
||||
//~^ ERROR cannot bind by-move with sub-bindings
|
||||
//~| ERROR use of moved value
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,37 +7,55 @@ LL | #![feature(bindings_after_at)]
|
|||
= note: `#[warn(incomplete_features)]` on by default
|
||||
|
||||
error[E0007]: cannot bind by-move with sub-bindings
|
||||
--> $DIR/borrowck-move-and-move.rs:12:9
|
||||
--> $DIR/borrowck-move-and-move.rs:13:9
|
||||
|
|
||||
LL | let a @ b = U;
|
||||
| ^^^^^ binds an already bound by-move value by moving it
|
||||
|
||||
error[E0007]: cannot bind by-move with sub-bindings
|
||||
--> $DIR/borrowck-move-and-move.rs:16:9
|
||||
--> $DIR/borrowck-move-and-move.rs:17:9
|
||||
|
|
||||
LL | let a @ (b, c) = (U, U);
|
||||
| ^^^^^^^^^^ binds an already bound by-move value by moving it
|
||||
|
||||
error[E0007]: cannot bind by-move with sub-bindings
|
||||
--> $DIR/borrowck-move-and-move.rs:20:9
|
||||
--> $DIR/borrowck-move-and-move.rs:21:9
|
||||
|
|
||||
LL | let a @ (b, c) = (u(), u());
|
||||
| ^^^^^^^^^^ binds an already bound by-move value by moving it
|
||||
|
||||
error[E0007]: cannot bind by-move with sub-bindings
|
||||
--> $DIR/borrowck-move-and-move.rs:25:9
|
||||
--> $DIR/borrowck-move-and-move.rs:26:9
|
||||
|
|
||||
LL | a @ Ok(b) | a @ Err(b) => {}
|
||||
| ^^^^^^^^^ binds an already bound by-move value by moving it
|
||||
|
||||
error[E0007]: cannot bind by-move with sub-bindings
|
||||
--> $DIR/borrowck-move-and-move.rs:25:21
|
||||
--> $DIR/borrowck-move-and-move.rs:26:21
|
||||
|
|
||||
LL | a @ Ok(b) | a @ Err(b) => {}
|
||||
| ^^^^^^^^^^ binds an already bound by-move value by moving it
|
||||
|
||||
error[E0007]: cannot bind by-move with sub-bindings
|
||||
--> $DIR/borrowck-move-and-move.rs:38:9
|
||||
|
|
||||
LL | xs @ [a, .., b] => {}
|
||||
| ^^^^^^^^^^^^^^^ binds an already bound by-move value by moving it
|
||||
|
||||
error[E0007]: cannot bind by-move with sub-bindings
|
||||
--> $DIR/borrowck-move-and-move.rs:44:9
|
||||
|
|
||||
LL | xs @ [_, ys @ .., _] => {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^ binds an already bound by-move value by moving it
|
||||
|
||||
error[E0007]: cannot bind by-move with sub-bindings
|
||||
--> $DIR/borrowck-move-and-move.rs:33:12
|
||||
|
|
||||
LL | fn fun(a @ b: U) {}
|
||||
| ^^^^^ binds an already bound by-move value by moving it
|
||||
|
||||
error[E0382]: use of moved value
|
||||
--> $DIR/borrowck-move-and-move.rs:12:13
|
||||
--> $DIR/borrowck-move-and-move.rs:13:13
|
||||
|
|
||||
LL | let a @ b = U;
|
||||
| ----^ - move occurs because value has type `main::U`, which does not implement the `Copy` trait
|
||||
|
@ -46,7 +64,7 @@ LL | let a @ b = U;
|
|||
| value moved here
|
||||
|
||||
error[E0382]: use of moved value
|
||||
--> $DIR/borrowck-move-and-move.rs:16:17
|
||||
--> $DIR/borrowck-move-and-move.rs:17:17
|
||||
|
|
||||
LL | let a @ (b, c) = (U, U);
|
||||
| --------^- ------ move occurs because value has type `(main::U, main::U)`, which does not implement the `Copy` trait
|
||||
|
@ -55,7 +73,7 @@ LL | let a @ (b, c) = (U, U);
|
|||
| value moved here
|
||||
|
||||
error[E0382]: use of moved value
|
||||
--> $DIR/borrowck-move-and-move.rs:20:17
|
||||
--> $DIR/borrowck-move-and-move.rs:21:17
|
||||
|
|
||||
LL | let a @ (b, c) = (u(), u());
|
||||
| --------^- ---------- move occurs because value has type `(main::U, main::U)`, which does not implement the `Copy` trait
|
||||
|
@ -64,7 +82,7 @@ LL | let a @ (b, c) = (u(), u());
|
|||
| value moved here
|
||||
|
||||
error[E0382]: use of moved value
|
||||
--> $DIR/borrowck-move-and-move.rs:25:16
|
||||
--> $DIR/borrowck-move-and-move.rs:26:16
|
||||
|
|
||||
LL | match Ok(U) {
|
||||
| ----- move occurs because value has type `std::result::Result<main::U, main::U>`, which does not implement the `Copy` trait
|
||||
|
@ -75,7 +93,7 @@ LL | a @ Ok(b) | a @ Err(b) => {}
|
|||
| value moved here
|
||||
|
||||
error[E0382]: use of moved value
|
||||
--> $DIR/borrowck-move-and-move.rs:25:29
|
||||
--> $DIR/borrowck-move-and-move.rs:26:29
|
||||
|
|
||||
LL | match Ok(U) {
|
||||
| ----- move occurs because value has type `std::result::Result<main::U, main::U>`, which does not implement the `Copy` trait
|
||||
|
@ -85,7 +103,39 @@ LL | a @ Ok(b) | a @ Err(b) => {}
|
|||
| | value used here after move
|
||||
| value moved here
|
||||
|
||||
error: aborting due to 10 previous errors
|
||||
error[E0382]: use of moved value
|
||||
--> $DIR/borrowck-move-and-move.rs:38:22
|
||||
|
|
||||
LL | match [u(), u(), u(), u()] {
|
||||
| -------------------- move occurs because value has type `[main::U; 4]`, which does not implement the `Copy` trait
|
||||
LL | xs @ [a, .., b] => {}
|
||||
| -------------^-
|
||||
| | |
|
||||
| | value used here after move
|
||||
| value moved here
|
||||
|
||||
error[E0382]: use of moved value
|
||||
--> $DIR/borrowck-move-and-move.rs:44:18
|
||||
|
|
||||
LL | match [u(), u(), u(), u()] {
|
||||
| -------------------- move occurs because value has type `[main::U; 4]`, which does not implement the `Copy` trait
|
||||
LL | xs @ [_, ys @ .., _] => {}
|
||||
| ---------^^^^^^^----
|
||||
| | |
|
||||
| | value used here after move
|
||||
| value moved here
|
||||
|
||||
error[E0382]: use of moved value
|
||||
--> $DIR/borrowck-move-and-move.rs:33:16
|
||||
|
|
||||
LL | fn fun(a @ b: U) {}
|
||||
| ----^
|
||||
| | |
|
||||
| | value used here after move
|
||||
| value moved here
|
||||
| move occurs because value has type `main::U`, which does not implement the `Copy` trait
|
||||
|
||||
error: aborting due to 16 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0007, E0382.
|
||||
For more information about an error, try `rustc --explain E0007`.
|
||||
|
|
|
@ -9,6 +9,10 @@ struct C;
|
|||
|
||||
fn c() -> C { C }
|
||||
|
||||
struct NC;
|
||||
|
||||
fn nc() -> NC { NC }
|
||||
|
||||
fn main() {
|
||||
let a @ box &b = Box::new(&C);
|
||||
//~^ ERROR cannot bind by-move with sub-bindings
|
||||
|
@ -18,6 +22,18 @@ fn main() {
|
|||
//~^ ERROR cannot bind by-move with sub-bindings
|
||||
//~| ERROR use of moved value
|
||||
|
||||
fn f1(a @ box &b: Box<&C>) {}
|
||||
//~^ ERROR cannot bind by-move with sub-bindings
|
||||
//~| ERROR use of moved value
|
||||
|
||||
fn f2(a @ box b: Box<C>) {}
|
||||
//~^ ERROR cannot bind by-move with sub-bindings
|
||||
//~| ERROR use of moved value
|
||||
|
||||
match Box::new(C) { a @ box b => {} }
|
||||
//~^ ERROR cannot bind by-move with sub-bindings
|
||||
//~| ERROR use of moved value
|
||||
|
||||
let ref a @ box b = Box::new(C); // OK; the type is `Copy`.
|
||||
drop(b);
|
||||
drop(b);
|
||||
|
@ -28,9 +44,18 @@ fn main() {
|
|||
drop(b);
|
||||
drop(a);
|
||||
|
||||
struct NC;
|
||||
|
||||
fn nc() -> NC { NC }
|
||||
fn f3(ref a @ box b: Box<C>) { // OK; the type is `Copy`.
|
||||
drop(b);
|
||||
drop(b);
|
||||
drop(a);
|
||||
}
|
||||
match Box::new(c()) {
|
||||
ref a @ box b => { // OK; the type is `Copy`.
|
||||
drop(b);
|
||||
drop(b);
|
||||
drop(a);
|
||||
}
|
||||
}
|
||||
|
||||
let ref a @ box b = Box::new(NC); //~ ERROR cannot bind by-move and by-ref in the same pattern
|
||||
|
||||
|
@ -38,6 +63,18 @@ fn main() {
|
|||
drop(a);
|
||||
drop(b);
|
||||
|
||||
fn f4(ref a @ box ref b: Box<NC>) { // OK.
|
||||
drop(a);
|
||||
drop(b)
|
||||
}
|
||||
|
||||
match Box::new(nc()) {
|
||||
ref a @ box ref b => { // OK.
|
||||
drop(a);
|
||||
drop(b);
|
||||
}
|
||||
}
|
||||
|
||||
let ref a @ box ref mut b = Box::new(nc());
|
||||
//~^ ERROR cannot borrow `a` as mutable because it is also borrowed as immutable
|
||||
let ref a @ box ref mut b = Box::new(NC);
|
||||
|
@ -56,4 +93,20 @@ fn main() {
|
|||
//~| ERROR cannot borrow `_` as immutable because it is also borrowed as mutable
|
||||
*a = Box::new(NC);
|
||||
drop(b);
|
||||
|
||||
fn f5(ref mut a @ box ref b: Box<NC>) {
|
||||
//~^ ERROR cannot borrow `a` as immutable because it is also borrowed as mutable
|
||||
//~| ERROR cannot borrow `_` as immutable because it is also borrowed as mutable
|
||||
*a = Box::new(NC);
|
||||
drop(b);
|
||||
}
|
||||
|
||||
match Box::new(nc()) {
|
||||
ref mut a @ box ref b => {
|
||||
//~^ ERROR cannot borrow `a` as immutable because it is also borrowed as mutable
|
||||
//~| ERROR cannot borrow `_` as immutable because it is also borrowed as mutable
|
||||
*a = Box::new(NC);
|
||||
drop(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,19 +7,25 @@ LL | #![feature(bindings_after_at)]
|
|||
= note: `#[warn(incomplete_features)]` on by default
|
||||
|
||||
error[E0007]: cannot bind by-move with sub-bindings
|
||||
--> $DIR/borrowck-pat-at-and-box.rs:13:9
|
||||
--> $DIR/borrowck-pat-at-and-box.rs:17:9
|
||||
|
|
||||
LL | let a @ box &b = Box::new(&C);
|
||||
| ^^^^^^^^^^ binds an already bound by-move value by moving it
|
||||
|
||||
error[E0007]: cannot bind by-move with sub-bindings
|
||||
--> $DIR/borrowck-pat-at-and-box.rs:17:9
|
||||
--> $DIR/borrowck-pat-at-and-box.rs:21:9
|
||||
|
|
||||
LL | let a @ box b = Box::new(C);
|
||||
| ^^^^^^^^^ binds an already bound by-move value by moving it
|
||||
|
||||
error[E0007]: cannot bind by-move with sub-bindings
|
||||
--> $DIR/borrowck-pat-at-and-box.rs:33:25
|
||||
|
|
||||
LL | match Box::new(C) { a @ box b => {} }
|
||||
| ^^^^^^^^^ binds an already bound by-move value by moving it
|
||||
|
||||
error[E0009]: cannot bind by-move and by-ref in the same pattern
|
||||
--> $DIR/borrowck-pat-at-and-box.rs:35:21
|
||||
--> $DIR/borrowck-pat-at-and-box.rs:60:21
|
||||
|
|
||||
LL | let ref a @ box b = Box::new(NC);
|
||||
| ------------^
|
||||
|
@ -28,7 +34,7 @@ LL | let ref a @ box b = Box::new(NC);
|
|||
| by-ref pattern here
|
||||
|
||||
error: cannot borrow `a` as mutable because it is also borrowed as immutable
|
||||
--> $DIR/borrowck-pat-at-and-box.rs:41:9
|
||||
--> $DIR/borrowck-pat-at-and-box.rs:78:9
|
||||
|
|
||||
LL | let ref a @ box ref mut b = Box::new(nc());
|
||||
| -----^^^^^^^---------
|
||||
|
@ -37,7 +43,7 @@ LL | let ref a @ box ref mut b = Box::new(nc());
|
|||
| immutable borrow occurs here
|
||||
|
||||
error: cannot borrow `a` as mutable because it is also borrowed as immutable
|
||||
--> $DIR/borrowck-pat-at-and-box.rs:43:9
|
||||
--> $DIR/borrowck-pat-at-and-box.rs:80:9
|
||||
|
|
||||
LL | let ref a @ box ref mut b = Box::new(NC);
|
||||
| -----^^^^^^^---------
|
||||
|
@ -46,7 +52,7 @@ LL | let ref a @ box ref mut b = Box::new(NC);
|
|||
| immutable borrow occurs here
|
||||
|
||||
error: cannot borrow `a` as mutable because it is also borrowed as immutable
|
||||
--> $DIR/borrowck-pat-at-and-box.rs:45:9
|
||||
--> $DIR/borrowck-pat-at-and-box.rs:82:9
|
||||
|
|
||||
LL | let ref a @ box ref mut b = Box::new(NC);
|
||||
| -----^^^^^^^---------
|
||||
|
@ -55,7 +61,7 @@ LL | let ref a @ box ref mut b = Box::new(NC);
|
|||
| immutable borrow occurs here
|
||||
|
||||
error: cannot borrow `a` as mutable because it is also borrowed as immutable
|
||||
--> $DIR/borrowck-pat-at-and-box.rs:48:9
|
||||
--> $DIR/borrowck-pat-at-and-box.rs:85:9
|
||||
|
|
||||
LL | let ref a @ box ref mut b = Box::new(NC);
|
||||
| -----^^^^^^^---------
|
||||
|
@ -64,7 +70,7 @@ LL | let ref a @ box ref mut b = Box::new(NC);
|
|||
| immutable borrow occurs here
|
||||
|
||||
error: cannot borrow `a` as immutable because it is also borrowed as mutable
|
||||
--> $DIR/borrowck-pat-at-and-box.rs:54:9
|
||||
--> $DIR/borrowck-pat-at-and-box.rs:91:9
|
||||
|
|
||||
LL | let ref mut a @ box ref b = Box::new(NC);
|
||||
| ---------^^^^^^^-----
|
||||
|
@ -72,8 +78,38 @@ LL | let ref mut a @ box ref b = Box::new(NC);
|
|||
| | immutable borrow occurs here
|
||||
| mutable borrow occurs here
|
||||
|
||||
error: cannot borrow `a` as immutable because it is also borrowed as mutable
|
||||
--> $DIR/borrowck-pat-at-and-box.rs:105:9
|
||||
|
|
||||
LL | ref mut a @ box ref b => {
|
||||
| ---------^^^^^^^-----
|
||||
| | |
|
||||
| | immutable borrow occurs here
|
||||
| mutable borrow occurs here
|
||||
|
||||
error[E0007]: cannot bind by-move with sub-bindings
|
||||
--> $DIR/borrowck-pat-at-and-box.rs:25:11
|
||||
|
|
||||
LL | fn f1(a @ box &b: Box<&C>) {}
|
||||
| ^^^^^^^^^^ binds an already bound by-move value by moving it
|
||||
|
||||
error[E0007]: cannot bind by-move with sub-bindings
|
||||
--> $DIR/borrowck-pat-at-and-box.rs:29:11
|
||||
|
|
||||
LL | fn f2(a @ box b: Box<C>) {}
|
||||
| ^^^^^^^^^ binds an already bound by-move value by moving it
|
||||
|
||||
error: cannot borrow `a` as immutable because it is also borrowed as mutable
|
||||
--> $DIR/borrowck-pat-at-and-box.rs:97:11
|
||||
|
|
||||
LL | fn f5(ref mut a @ box ref b: Box<NC>) {
|
||||
| ---------^^^^^^^-----
|
||||
| | |
|
||||
| | immutable borrow occurs here
|
||||
| mutable borrow occurs here
|
||||
|
||||
error[E0382]: use of moved value
|
||||
--> $DIR/borrowck-pat-at-and-box.rs:13:18
|
||||
--> $DIR/borrowck-pat-at-and-box.rs:17:18
|
||||
|
|
||||
LL | let a @ box &b = Box::new(&C);
|
||||
| ---------^ ------------ move occurs because value has type `std::boxed::Box<&C>`, which does not implement the `Copy` trait
|
||||
|
@ -82,7 +118,7 @@ LL | let a @ box &b = Box::new(&C);
|
|||
| value moved here
|
||||
|
||||
error[E0382]: use of moved value
|
||||
--> $DIR/borrowck-pat-at-and-box.rs:17:17
|
||||
--> $DIR/borrowck-pat-at-and-box.rs:21:17
|
||||
|
|
||||
LL | let a @ box b = Box::new(C);
|
||||
| --------^ ----------- move occurs because value has type `std::boxed::Box<C>`, which does not implement the `Copy` trait
|
||||
|
@ -90,8 +126,18 @@ LL | let a @ box b = Box::new(C);
|
|||
| | value used here after move
|
||||
| value moved here
|
||||
|
||||
error[E0382]: use of moved value
|
||||
--> $DIR/borrowck-pat-at-and-box.rs:33:33
|
||||
|
|
||||
LL | match Box::new(C) { a @ box b => {} }
|
||||
| ----------- --------^
|
||||
| | | |
|
||||
| | | value used here after move
|
||||
| | value moved here
|
||||
| move occurs because value has type `std::boxed::Box<C>`, which does not implement the `Copy` trait
|
||||
|
||||
error[E0502]: cannot borrow `_` as mutable because it is also borrowed as immutable
|
||||
--> $DIR/borrowck-pat-at-and-box.rs:48:21
|
||||
--> $DIR/borrowck-pat-at-and-box.rs:85:21
|
||||
|
|
||||
LL | let ref a @ box ref mut b = Box::new(NC);
|
||||
| ------------^^^^^^^^^
|
||||
|
@ -103,7 +149,7 @@ LL | drop(a);
|
|||
| - immutable borrow later used here
|
||||
|
||||
error[E0502]: cannot borrow `_` as immutable because it is also borrowed as mutable
|
||||
--> $DIR/borrowck-pat-at-and-box.rs:54:25
|
||||
--> $DIR/borrowck-pat-at-and-box.rs:91:25
|
||||
|
|
||||
LL | let ref mut a @ box ref b = Box::new(NC);
|
||||
| ----------------^^^^^
|
||||
|
@ -114,7 +160,51 @@ LL | let ref mut a @ box ref b = Box::new(NC);
|
|||
LL | *a = Box::new(NC);
|
||||
| -- mutable borrow later used here
|
||||
|
||||
error: aborting due to 12 previous errors
|
||||
error[E0502]: cannot borrow `_` as immutable because it is also borrowed as mutable
|
||||
--> $DIR/borrowck-pat-at-and-box.rs:105:25
|
||||
|
|
||||
LL | ref mut a @ box ref b => {
|
||||
| ----------------^^^^^
|
||||
| | |
|
||||
| | immutable borrow occurs here
|
||||
| mutable borrow occurs here
|
||||
...
|
||||
LL | *a = Box::new(NC);
|
||||
| -- mutable borrow later used here
|
||||
|
||||
error[E0382]: use of moved value
|
||||
--> $DIR/borrowck-pat-at-and-box.rs:25:20
|
||||
|
|
||||
LL | fn f1(a @ box &b: Box<&C>) {}
|
||||
| ---------^
|
||||
| | |
|
||||
| | value used here after move
|
||||
| value moved here
|
||||
| move occurs because value has type `std::boxed::Box<&C>`, which does not implement the `Copy` trait
|
||||
|
||||
error[E0382]: use of moved value
|
||||
--> $DIR/borrowck-pat-at-and-box.rs:29:19
|
||||
|
|
||||
LL | fn f2(a @ box b: Box<C>) {}
|
||||
| --------^
|
||||
| | |
|
||||
| | value used here after move
|
||||
| value moved here
|
||||
| move occurs because value has type `std::boxed::Box<C>`, which does not implement the `Copy` trait
|
||||
|
||||
error[E0502]: cannot borrow `_` as immutable because it is also borrowed as mutable
|
||||
--> $DIR/borrowck-pat-at-and-box.rs:97:27
|
||||
|
|
||||
LL | fn f5(ref mut a @ box ref b: Box<NC>) {
|
||||
| ----------------^^^^^
|
||||
| | |
|
||||
| | immutable borrow occurs here
|
||||
| mutable borrow occurs here
|
||||
...
|
||||
LL | *a = Box::new(NC);
|
||||
| -- mutable borrow later used here
|
||||
|
||||
error: aborting due to 22 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0007, E0009, E0382, E0502.
|
||||
For more information about an error, try `rustc --explain E0007`.
|
||||
|
|
|
@ -22,9 +22,12 @@ fn main() {
|
|||
let a @ P(b, P(c, d)) = P(mk_c(), P(C, C));
|
||||
let a @ [b, c] = [C, C];
|
||||
let a @ [b, .., c] = [C, mk_c(), C];
|
||||
let a @ [b, mid @ .., c] = [C, mk_c(), C];
|
||||
let a @ &(b, c) = &(C, C);
|
||||
let a @ &(b, &P(c, d)) = &(mk_c(), &P(C, C));
|
||||
|
||||
fn foo(a @ [b, mid @ .., c]: [C; 3]) {}
|
||||
|
||||
use self::E::*;
|
||||
match L(C) {
|
||||
L(a) | R(a) => {
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#![feature(bindings_after_at)]
|
||||
//~^ WARN the feature `bindings_after_at` is incomplete and may cause the compiler to crash
|
||||
#![feature(slice_patterns)]
|
||||
|
||||
fn main() {
|
||||
struct U; // Not copy!
|
||||
|
@ -27,6 +28,8 @@ fn main() {
|
|||
let _: &U = c;
|
||||
let _: &U = d;
|
||||
|
||||
fn f1(ref a @ (ref b, [ref c, ref mid @ .., ref d]): (U, [U; 4])) {}
|
||||
|
||||
let a @ (b, [c, d]) = &(u(), [u(), u()]);
|
||||
let _: &(U, [U; 2]) = a;
|
||||
let _: &U = b;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#![feature(bindings_after_at)]
|
||||
//~^ WARN the feature `bindings_after_at` is incomplete and may cause the compiler to crash
|
||||
#![feature(slice_patterns)]
|
||||
|
||||
enum Option<T> {
|
||||
None,
|
||||
|
@ -22,6 +23,17 @@ fn main() {
|
|||
// Prevent promotion:
|
||||
fn u() -> U { U }
|
||||
|
||||
fn f1(ref a @ ref mut b: U) {}
|
||||
//~^ ERROR cannot borrow `a` as mutable because it is also borrowed as immutable
|
||||
fn f2(ref mut a @ ref b: U) {}
|
||||
//~^ ERROR cannot borrow `a` as immutable because it is also borrowed as mutable
|
||||
fn f3(ref a @ [ref b, ref mut mid @ .., ref c]: [U; 4]) {}
|
||||
//~^ ERROR cannot borrow `a` as mutable because it is also borrowed as immutable
|
||||
|
||||
let ref mut a @ (ref b @ ref mut c) = u(); // sub-in-sub
|
||||
//~^ ERROR cannot borrow `a` as mutable more than once at a time
|
||||
//~| ERROR cannot borrow `b` as mutable because it is also borrowed as immutable
|
||||
|
||||
let ref a @ ref mut b = U;
|
||||
//~^ ERROR cannot borrow `a` as mutable because it is also borrowed as immutable
|
||||
let ref mut a @ ref b = U;
|
||||
|
|
|
@ -7,7 +7,7 @@ LL | #![feature(bindings_after_at)]
|
|||
= note: `#[warn(incomplete_features)]` on by default
|
||||
|
||||
error: cannot borrow `z` as immutable because it is also borrowed as mutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:11:9
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:12:9
|
||||
|
|
||||
LL | ref mut z @ &mut Some(ref a) => {
|
||||
| ---------^^^^^^^^^^^^^-----^
|
||||
|
@ -15,8 +15,27 @@ LL | ref mut z @ &mut Some(ref a) => {
|
|||
| | immutable borrow occurs here
|
||||
| mutable borrow occurs here
|
||||
|
||||
error: cannot borrow `a` as mutable more than once at a time
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:33:9
|
||||
|
|
||||
LL | let ref mut a @ (ref b @ ref mut c) = u(); // sub-in-sub
|
||||
| ---------^^^^-----------------^
|
||||
| | | |
|
||||
| | | another mutable borrow occurs here
|
||||
| | also borrowed as immutable here
|
||||
| first mutable borrow occurs here
|
||||
|
||||
error: cannot borrow `b` as mutable because it is also borrowed as immutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:33:22
|
||||
|
|
||||
LL | let ref mut a @ (ref b @ ref mut c) = u(); // sub-in-sub
|
||||
| -----^^^---------
|
||||
| | |
|
||||
| | mutable borrow occurs here
|
||||
| immutable borrow occurs here
|
||||
|
||||
error: cannot borrow `a` as mutable because it is also borrowed as immutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:25:9
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:37:9
|
||||
|
|
||||
LL | let ref a @ ref mut b = U;
|
||||
| -----^^^---------
|
||||
|
@ -25,7 +44,7 @@ LL | let ref a @ ref mut b = U;
|
|||
| immutable borrow occurs here
|
||||
|
||||
error: cannot borrow `a` as immutable because it is also borrowed as mutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:27:9
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:39:9
|
||||
|
|
||||
LL | let ref mut a @ ref b = U;
|
||||
| ---------^^^-----
|
||||
|
@ -34,7 +53,7 @@ LL | let ref mut a @ ref b = U;
|
|||
| mutable borrow occurs here
|
||||
|
||||
error: cannot borrow `a` as mutable because it is also borrowed as immutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:29:9
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:41:9
|
||||
|
|
||||
LL | let ref a @ (ref mut b, ref mut c) = (U, U);
|
||||
| -----^^^^---------^^---------^
|
||||
|
@ -44,7 +63,7 @@ LL | let ref a @ (ref mut b, ref mut c) = (U, U);
|
|||
| immutable borrow occurs here
|
||||
|
||||
error: cannot borrow `a` as immutable because it is also borrowed as mutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:31:9
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:43:9
|
||||
|
|
||||
LL | let ref mut a @ (ref b, ref c) = (U, U);
|
||||
| ---------^^^^-----^^-----^
|
||||
|
@ -54,7 +73,7 @@ LL | let ref mut a @ (ref b, ref c) = (U, U);
|
|||
| mutable borrow occurs here
|
||||
|
||||
error: cannot borrow `a` as immutable because it is also borrowed as mutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:34:9
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:46:9
|
||||
|
|
||||
LL | let ref mut a @ ref b = u();
|
||||
| ---------^^^-----
|
||||
|
@ -63,7 +82,7 @@ LL | let ref mut a @ ref b = u();
|
|||
| mutable borrow occurs here
|
||||
|
||||
error: cannot borrow `a` as mutable because it is also borrowed as immutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:39:9
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:51:9
|
||||
|
|
||||
LL | let ref a @ ref mut b = u();
|
||||
| -----^^^---------
|
||||
|
@ -72,7 +91,7 @@ LL | let ref a @ ref mut b = u();
|
|||
| immutable borrow occurs here
|
||||
|
||||
error: cannot borrow `a` as immutable because it is also borrowed as mutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:45:9
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:57:9
|
||||
|
|
||||
LL | let ref mut a @ ref b = U;
|
||||
| ---------^^^-----
|
||||
|
@ -81,7 +100,7 @@ LL | let ref mut a @ ref b = U;
|
|||
| mutable borrow occurs here
|
||||
|
||||
error: cannot borrow `a` as mutable because it is also borrowed as immutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:49:9
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:61:9
|
||||
|
|
||||
LL | let ref a @ ref mut b = U;
|
||||
| -----^^^---------
|
||||
|
@ -90,7 +109,7 @@ LL | let ref a @ ref mut b = U;
|
|||
| immutable borrow occurs here
|
||||
|
||||
error: cannot borrow `a` as immutable because it is also borrowed as mutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:55:9
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:67:9
|
||||
|
|
||||
LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) => {
|
||||
| ---------^^^^^^-----^
|
||||
|
@ -99,7 +118,7 @@ LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) => {
|
|||
| mutable borrow occurs here
|
||||
|
||||
error: cannot borrow `a` as immutable because it is also borrowed as mutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:55:33
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:67:33
|
||||
|
|
||||
LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) => {
|
||||
| ---------^^^^^^^-----^
|
||||
|
@ -108,7 +127,7 @@ LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) => {
|
|||
| mutable borrow occurs here
|
||||
|
||||
error: cannot borrow `a` as mutable because it is also borrowed as immutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:64:9
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:76:9
|
||||
|
|
||||
LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) => {
|
||||
| -----^^^^^^---------^
|
||||
|
@ -117,7 +136,7 @@ LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) => {
|
|||
| immutable borrow occurs here
|
||||
|
||||
error: cannot borrow `a` as mutable because it is also borrowed as immutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:64:33
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:76:33
|
||||
|
|
||||
LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) => {
|
||||
| -----^^^^^^^---------^
|
||||
|
@ -126,7 +145,7 @@ LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) => {
|
|||
| immutable borrow occurs here
|
||||
|
||||
error: cannot borrow `a` as mutable because it is also borrowed as immutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:75:9
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:87:9
|
||||
|
|
||||
LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { *b = U; false } => {}
|
||||
| -----^^^^^^---------^
|
||||
|
@ -135,7 +154,7 @@ LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { *b = U; false }
|
|||
| immutable borrow occurs here
|
||||
|
||||
error: cannot borrow `a` as mutable because it is also borrowed as immutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:75:33
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:87:33
|
||||
|
|
||||
LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { *b = U; false } => {}
|
||||
| -----^^^^^^^---------^
|
||||
|
@ -144,7 +163,7 @@ LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { *b = U; false }
|
|||
| immutable borrow occurs here
|
||||
|
||||
error: cannot borrow `a` as immutable because it is also borrowed as mutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:82:9
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:94:9
|
||||
|
|
||||
LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { *a = Err(U); false } => {}
|
||||
| ---------^^^^^^-----^
|
||||
|
@ -153,7 +172,7 @@ LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { *a = Err(U); fa
|
|||
| mutable borrow occurs here
|
||||
|
||||
error: cannot borrow `a` as immutable because it is also borrowed as mutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:82:33
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:94:33
|
||||
|
|
||||
LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { *a = Err(U); false } => {}
|
||||
| ---------^^^^^^^-----^
|
||||
|
@ -162,7 +181,7 @@ LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { *a = Err(U); fa
|
|||
| mutable borrow occurs here
|
||||
|
||||
error: cannot borrow `a` as mutable because it is also borrowed as immutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:89:9
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:101:9
|
||||
|
|
||||
LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false } => {}
|
||||
| -----^^^^^^---------^
|
||||
|
@ -171,7 +190,7 @@ LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false
|
|||
| immutable borrow occurs here
|
||||
|
||||
error: cannot borrow `a` as mutable because it is also borrowed as immutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:89:33
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:101:33
|
||||
|
|
||||
LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false } => {}
|
||||
| -----^^^^^^^---------^
|
||||
|
@ -180,42 +199,22 @@ LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false
|
|||
| immutable borrow occurs here
|
||||
|
||||
error: cannot borrow `a` as immutable because it is also borrowed as mutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:96:9
|
||||
|
|
||||
LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false } => {}
|
||||
| ---------^^^^^^-----^
|
||||
| | |
|
||||
| | immutable borrow occurs here
|
||||
| mutable borrow occurs here
|
||||
|
||||
error: cannot borrow `a` as immutable because it is also borrowed as mutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:96:33
|
||||
|
|
||||
LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false } => {}
|
||||
| ---------^^^^^^^-----^
|
||||
| | |
|
||||
| | immutable borrow occurs here
|
||||
| mutable borrow occurs here
|
||||
|
||||
error: cannot borrow `a` as mutable because it is also borrowed as immutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:103:9
|
||||
|
|
||||
LL | let ref a @ (ref mut b, ref mut c) = (U, U);
|
||||
| -----^^^^---------^^---------^
|
||||
| | | |
|
||||
| | | mutable borrow occurs here
|
||||
| | mutable borrow occurs here
|
||||
| immutable borrow occurs here
|
||||
|
||||
error: cannot borrow `a` as mutable because it is also borrowed as immutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:108:9
|
||||
|
|
||||
LL | let ref a @ (ref mut b, ref mut c) = (U, U);
|
||||
| -----^^^^---------^^---------^
|
||||
| | | |
|
||||
| | | mutable borrow occurs here
|
||||
| | mutable borrow occurs here
|
||||
| immutable borrow occurs here
|
||||
LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false } => {}
|
||||
| ---------^^^^^^-----^
|
||||
| | |
|
||||
| | immutable borrow occurs here
|
||||
| mutable borrow occurs here
|
||||
|
||||
error: cannot borrow `a` as immutable because it is also borrowed as mutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:108:33
|
||||
|
|
||||
LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false } => {}
|
||||
| ---------^^^^^^^-----^
|
||||
| | |
|
||||
| | immutable borrow occurs here
|
||||
| mutable borrow occurs here
|
||||
|
||||
error: cannot borrow `a` as mutable because it is also borrowed as immutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:115:9
|
||||
|
@ -227,9 +226,29 @@ LL | let ref a @ (ref mut b, ref mut c) = (U, U);
|
|||
| | mutable borrow occurs here
|
||||
| immutable borrow occurs here
|
||||
|
||||
error: cannot borrow `a` as immutable because it is also borrowed as mutable
|
||||
error: cannot borrow `a` as mutable because it is also borrowed as immutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:120:9
|
||||
|
|
||||
LL | let ref a @ (ref mut b, ref mut c) = (U, U);
|
||||
| -----^^^^---------^^---------^
|
||||
| | | |
|
||||
| | | mutable borrow occurs here
|
||||
| | mutable borrow occurs here
|
||||
| immutable borrow occurs here
|
||||
|
||||
error: cannot borrow `a` as mutable because it is also borrowed as immutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:127:9
|
||||
|
|
||||
LL | let ref a @ (ref mut b, ref mut c) = (U, U);
|
||||
| -----^^^^---------^^---------^
|
||||
| | | |
|
||||
| | | mutable borrow occurs here
|
||||
| | mutable borrow occurs here
|
||||
| immutable borrow occurs here
|
||||
|
||||
error: cannot borrow `a` as immutable because it is also borrowed as mutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:132:9
|
||||
|
|
||||
LL | let ref mut a @ (ref b, ref c) = (U, U);
|
||||
| ---------^^^^-----^^-----^
|
||||
| | | |
|
||||
|
@ -237,8 +256,35 @@ LL | let ref mut a @ (ref b, ref c) = (U, U);
|
|||
| | immutable borrow occurs here
|
||||
| mutable borrow occurs here
|
||||
|
||||
error: cannot borrow `a` as mutable because it is also borrowed as immutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:26:11
|
||||
|
|
||||
LL | fn f1(ref a @ ref mut b: U) {}
|
||||
| -----^^^---------
|
||||
| | |
|
||||
| | mutable borrow occurs here
|
||||
| immutable borrow occurs here
|
||||
|
||||
error: cannot borrow `a` as immutable because it is also borrowed as mutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:28:11
|
||||
|
|
||||
LL | fn f2(ref mut a @ ref b: U) {}
|
||||
| ---------^^^-----
|
||||
| | |
|
||||
| | immutable borrow occurs here
|
||||
| mutable borrow occurs here
|
||||
|
||||
error: cannot borrow `a` as mutable because it is also borrowed as immutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:30:11
|
||||
|
|
||||
LL | fn f3(ref a @ [ref b, ref mut mid @ .., ref c]: [U; 4]) {}
|
||||
| -----^^^^^^^^^^^----------------^^^^^^^^
|
||||
| | |
|
||||
| | mutable borrow occurs here
|
||||
| immutable borrow occurs here
|
||||
|
||||
error[E0502]: cannot borrow `_` as immutable because it is also borrowed as mutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:11:31
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:12:31
|
||||
|
|
||||
LL | ref mut z @ &mut Some(ref a) => {
|
||||
| ----------------------^^^^^-
|
||||
|
@ -250,7 +296,7 @@ LL | **z = None;
|
|||
| ---------- mutable borrow later used here
|
||||
|
||||
error[E0502]: cannot borrow `_` as immutable because it is also borrowed as mutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:34:21
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:46:21
|
||||
|
|
||||
LL | let ref mut a @ ref b = u();
|
||||
| ------------^^^^^
|
||||
|
@ -262,7 +308,7 @@ LL | *a = u();
|
|||
| -------- mutable borrow later used here
|
||||
|
||||
error[E0502]: cannot borrow `_` as mutable because it is also borrowed as immutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:39:17
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:51:17
|
||||
|
|
||||
LL | let ref a @ ref mut b = u();
|
||||
| --------^^^^^^^^^
|
||||
|
@ -274,7 +320,7 @@ LL | drop(a);
|
|||
| - immutable borrow later used here
|
||||
|
||||
error[E0502]: cannot borrow `_` as mutable because it is also borrowed as immutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:64:20
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:76:20
|
||||
|
|
||||
LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) => {
|
||||
| -----------^^^^^^^^^-
|
||||
|
@ -286,7 +332,7 @@ LL | drop(a);
|
|||
| - immutable borrow later used here
|
||||
|
||||
error[E0502]: cannot borrow `_` as mutable because it is also borrowed as immutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:64:45
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:76:45
|
||||
|
|
||||
LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) => {
|
||||
| ------------^^^^^^^^^-
|
||||
|
@ -298,7 +344,7 @@ LL | drop(a);
|
|||
| - immutable borrow later used here
|
||||
|
||||
error[E0594]: cannot assign to `*b`, as it is immutable for the pattern guard
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:75:61
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:87:61
|
||||
|
|
||||
LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { *b = U; false } => {}
|
||||
| ^^^^^^ cannot assign
|
||||
|
@ -306,7 +352,7 @@ LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { *b = U; false }
|
|||
= note: variables bound in patterns are immutable until the end of the pattern guard
|
||||
|
||||
error[E0594]: cannot assign to `*a`, as it is immutable for the pattern guard
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:82:61
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:94:61
|
||||
|
|
||||
LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { *a = Err(U); false } => {}
|
||||
| ^^^^^^^^^^^ cannot assign
|
||||
|
@ -314,7 +360,7 @@ LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { *a = Err(U); fa
|
|||
= note: variables bound in patterns are immutable until the end of the pattern guard
|
||||
|
||||
error[E0507]: cannot move out of `b` in pattern guard
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:89:66
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:101:66
|
||||
|
|
||||
LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false } => {}
|
||||
| ^ move occurs because `b` has type `&mut main::U`, which does not implement the `Copy` trait
|
||||
|
@ -322,7 +368,7 @@ LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false
|
|||
= note: variables bound in patterns cannot be moved from until after the end of the pattern guard
|
||||
|
||||
error[E0507]: cannot move out of `a` in pattern guard
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:96:66
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:108:66
|
||||
|
|
||||
LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false } => {}
|
||||
| ^ move occurs because `a` has type `&mut std::result::Result<main::U, main::U>`, which does not implement the `Copy` trait
|
||||
|
@ -330,7 +376,7 @@ LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false
|
|||
= note: variables bound in patterns cannot be moved from until after the end of the pattern guard
|
||||
|
||||
error[E0502]: cannot borrow `_` as mutable because it is also borrowed as immutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:108:18
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:120:18
|
||||
|
|
||||
LL | let ref a @ (ref mut b, ref mut c) = (U, U);
|
||||
| ---------^^^^^^^^^------------
|
||||
|
@ -342,7 +388,7 @@ LL | drop(a);
|
|||
| - immutable borrow later used here
|
||||
|
||||
error[E0502]: cannot borrow `_` as mutable because it is also borrowed as immutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:108:29
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:120:29
|
||||
|
|
||||
LL | let ref a @ (ref mut b, ref mut c) = (U, U);
|
||||
| --------------------^^^^^^^^^-
|
||||
|
@ -354,7 +400,7 @@ LL | drop(a);
|
|||
| - immutable borrow later used here
|
||||
|
||||
error[E0502]: cannot borrow `_` as mutable because it is also borrowed as immutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:115:18
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:127:18
|
||||
|
|
||||
LL | let ref a @ (ref mut b, ref mut c) = (U, U);
|
||||
| ---------^^^^^^^^^------------
|
||||
|
@ -366,7 +412,7 @@ LL | drop(a);
|
|||
| - immutable borrow later used here
|
||||
|
||||
error[E0502]: cannot borrow `_` as mutable because it is also borrowed as immutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:115:29
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:127:29
|
||||
|
|
||||
LL | let ref a @ (ref mut b, ref mut c) = (U, U);
|
||||
| --------------------^^^^^^^^^-
|
||||
|
@ -377,7 +423,7 @@ LL | let ref a @ (ref mut b, ref mut c) = (U, U);
|
|||
LL | drop(a);
|
||||
| - immutable borrow later used here
|
||||
|
||||
error: aborting due to 38 previous errors
|
||||
error: aborting due to 43 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0502, E0507, E0594.
|
||||
For more information about an error, try `rustc --explain E0502`.
|
||||
|
|
|
@ -2,12 +2,27 @@
|
|||
|
||||
#![feature(bindings_after_at)]
|
||||
//~^ WARN the feature `bindings_after_at` is incomplete and may cause the compiler to crash
|
||||
#![feature(slice_patterns)]
|
||||
|
||||
fn main() {
|
||||
struct U;
|
||||
|
||||
fn u() -> U { U }
|
||||
|
||||
fn f1(ref mut a @ ref mut b: U) {}
|
||||
//~^ ERROR cannot borrow `a` as mutable more than once at a time
|
||||
fn f2(ref mut a @ ref mut b: U) {}
|
||||
//~^ ERROR cannot borrow `a` as mutable more than once at a time
|
||||
fn f3(
|
||||
ref mut a @ [
|
||||
//~^ ERROR cannot borrow `a` as mutable more than once at a time
|
||||
[ref b @ .., _],
|
||||
[_, ref mut mid @ ..],
|
||||
..,
|
||||
[..],
|
||||
] : [[U; 4]; 5]
|
||||
) {}
|
||||
|
||||
let ref mut a @ ref mut b = U;
|
||||
//~^ ERROR cannot borrow `a` as mutable more than once at a time
|
||||
//~| ERROR cannot borrow `_` as mutable more than once at a time
|
||||
|
|
|
@ -7,7 +7,7 @@ LL | #![feature(bindings_after_at)]
|
|||
= note: `#[warn(incomplete_features)]` on by default
|
||||
|
||||
error: cannot borrow `a` as mutable more than once at a time
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:11:9
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:26:9
|
||||
|
|
||||
LL | let ref mut a @ ref mut b = U;
|
||||
| ---------^^^---------
|
||||
|
@ -16,7 +16,7 @@ LL | let ref mut a @ ref mut b = U;
|
|||
| first mutable borrow occurs here
|
||||
|
||||
error: cannot borrow `a` as mutable more than once at a time
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:15:9
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:30:9
|
||||
|
|
||||
LL | let ref mut a @ ref mut b = U;
|
||||
| ---------^^^---------
|
||||
|
@ -25,7 +25,7 @@ LL | let ref mut a @ ref mut b = U;
|
|||
| first mutable borrow occurs here
|
||||
|
||||
error: cannot borrow `a` as mutable more than once at a time
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:18:9
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:33:9
|
||||
|
|
||||
LL | let ref mut a @ ref mut b = U;
|
||||
| ---------^^^---------
|
||||
|
@ -34,7 +34,7 @@ LL | let ref mut a @ ref mut b = U;
|
|||
| first mutable borrow occurs here
|
||||
|
||||
error: cannot borrow `a` as mutable more than once at a time
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:21:9
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:36:9
|
||||
|
|
||||
LL | let ref mut a @ ref mut b = U;
|
||||
| ---------^^^---------
|
||||
|
@ -43,7 +43,7 @@ LL | let ref mut a @ ref mut b = U;
|
|||
| first mutable borrow occurs here
|
||||
|
||||
error: cannot borrow `a` as mutable more than once at a time
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:25:9
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:40:9
|
||||
|
|
||||
LL | let ref mut a @ ref mut b = U;
|
||||
| ---------^^^---------
|
||||
|
@ -52,7 +52,7 @@ LL | let ref mut a @ ref mut b = U;
|
|||
| first mutable borrow occurs here
|
||||
|
||||
error: cannot borrow `a` as mutable more than once at a time
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:29:9
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:44:9
|
||||
|
|
||||
LL | let ref mut a @ (
|
||||
| ^--------
|
||||
|
@ -74,7 +74,7 @@ LL | | ) = (U, [U, U, U]);
|
|||
| |_____^
|
||||
|
||||
error: cannot borrow `a` as mutable more than once at a time
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:39:9
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:54:9
|
||||
|
|
||||
LL | let ref mut a @ (
|
||||
| ^--------
|
||||
|
@ -96,31 +96,31 @@ LL | | ) = (u(), [u(), u(), u()]);
|
|||
| |_________^
|
||||
|
||||
error[E0007]: cannot bind by-move with sub-bindings
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:49:9
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:64:9
|
||||
|
|
||||
LL | let a @ (ref mut b, ref mut c) = (U, U);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ binds an already bound by-move value by moving it
|
||||
|
||||
error[E0007]: cannot bind by-move with sub-bindings
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:53:9
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:68:9
|
||||
|
|
||||
LL | let a @ (b, [c, d]) = &mut val; // Same as ^--
|
||||
| ^^^^^^^^^^^^^^^ binds an already bound by-move value by moving it
|
||||
|
||||
error[E0007]: cannot bind by-move with sub-bindings
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:57:9
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:72:9
|
||||
|
|
||||
LL | let a @ &mut ref mut b = &mut U;
|
||||
| ^^^^^^^^^^^^^^^^^^ binds an already bound by-move value by moving it
|
||||
|
||||
error[E0007]: cannot bind by-move with sub-bindings
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:60:9
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:75:9
|
||||
|
|
||||
LL | let a @ &mut (ref mut b, ref mut c) = &mut (U, U);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ binds an already bound by-move value by moving it
|
||||
|
||||
error: cannot borrow `a` as mutable more than once at a time
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:65:9
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:80:9
|
||||
|
|
||||
LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
|
||||
| ---------^^^^^^---------^
|
||||
|
@ -129,7 +129,7 @@ LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
|
|||
| first mutable borrow occurs here
|
||||
|
||||
error: cannot borrow `a` as mutable more than once at a time
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:65:37
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:80:37
|
||||
|
|
||||
LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
|
||||
| ---------^^^^^^^---------^
|
||||
|
@ -138,7 +138,7 @@ LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
|
|||
| first mutable borrow occurs here
|
||||
|
||||
error: cannot borrow `a` as mutable more than once at a time
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:71:9
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:86:9
|
||||
|
|
||||
LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
|
||||
| ---------^^^^^^---------^
|
||||
|
@ -147,7 +147,7 @@ LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
|
|||
| first mutable borrow occurs here
|
||||
|
||||
error: cannot borrow `a` as mutable more than once at a time
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:71:37
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:86:37
|
||||
|
|
||||
LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
|
||||
| ---------^^^^^^^---------^
|
||||
|
@ -156,7 +156,7 @@ LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
|
|||
| first mutable borrow occurs here
|
||||
|
||||
error: cannot borrow `a` as mutable more than once at a time
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:78:9
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:93:9
|
||||
|
|
||||
LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
|
||||
| ---------^^^^^^---------^
|
||||
|
@ -165,7 +165,7 @@ LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
|
|||
| first mutable borrow occurs here
|
||||
|
||||
error: cannot borrow `a` as mutable more than once at a time
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:78:37
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:93:37
|
||||
|
|
||||
LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
|
||||
| ---------^^^^^^^---------^
|
||||
|
@ -174,7 +174,7 @@ LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
|
|||
| first mutable borrow occurs here
|
||||
|
||||
error: cannot borrow `a` as mutable more than once at a time
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:90:9
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:105:9
|
||||
|
|
||||
LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
|
||||
| ---------^^^^^^---------^
|
||||
|
@ -183,7 +183,7 @@ LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
|
|||
| first mutable borrow occurs here
|
||||
|
||||
error: cannot borrow `a` as mutable more than once at a time
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:90:37
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:105:37
|
||||
|
|
||||
LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
|
||||
| ---------^^^^^^^---------^
|
||||
|
@ -191,8 +191,44 @@ LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
|
|||
| | another mutable borrow occurs here
|
||||
| first mutable borrow occurs here
|
||||
|
||||
error: cannot borrow `a` as mutable more than once at a time
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:12:11
|
||||
|
|
||||
LL | fn f1(ref mut a @ ref mut b: U) {}
|
||||
| ---------^^^---------
|
||||
| | |
|
||||
| | another mutable borrow occurs here
|
||||
| first mutable borrow occurs here
|
||||
|
||||
error: cannot borrow `a` as mutable more than once at a time
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:14:11
|
||||
|
|
||||
LL | fn f2(ref mut a @ ref mut b: U) {}
|
||||
| ---------^^^---------
|
||||
| | |
|
||||
| | another mutable borrow occurs here
|
||||
| first mutable borrow occurs here
|
||||
|
||||
error: cannot borrow `a` as mutable more than once at a time
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:17:9
|
||||
|
|
||||
LL | ref mut a @ [
|
||||
| ^--------
|
||||
| |
|
||||
| _________first mutable borrow occurs here
|
||||
| |
|
||||
LL | |
|
||||
LL | | [ref b @ .., _],
|
||||
| | ---------- also borrowed as immutable here
|
||||
LL | | [_, ref mut mid @ ..],
|
||||
| | ---------------- another mutable borrow occurs here
|
||||
LL | | ..,
|
||||
LL | | [..],
|
||||
LL | | ] : [[U; 4]; 5]
|
||||
| |_________^
|
||||
|
||||
error[E0499]: cannot borrow `_` as mutable more than once at a time
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:11:21
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:26:21
|
||||
|
|
||||
LL | let ref mut a @ ref mut b = U;
|
||||
| ------------^^^^^^^^^
|
||||
|
@ -204,7 +240,7 @@ LL | drop(a);
|
|||
| - first borrow later used here
|
||||
|
||||
error[E0499]: cannot borrow `_` as mutable more than once at a time
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:21:21
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:36:21
|
||||
|
|
||||
LL | let ref mut a @ ref mut b = U;
|
||||
| ------------^^^^^^^^^
|
||||
|
@ -216,7 +252,7 @@ LL | *a = U;
|
|||
| ------ first borrow later used here
|
||||
|
||||
error[E0382]: borrow of moved value
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:49:25
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:64:25
|
||||
|
|
||||
LL | let a @ (ref mut b, ref mut c) = (U, U);
|
||||
| ----------------^^^^^^^^^- ------ move occurs because value has type `(main::U, main::U)`, which does not implement the `Copy` trait
|
||||
|
@ -225,7 +261,7 @@ LL | let a @ (ref mut b, ref mut c) = (U, U);
|
|||
| value moved here
|
||||
|
||||
error[E0382]: borrow of moved value
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:53:21
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:68:21
|
||||
|
|
||||
LL | let a @ (b, [c, d]) = &mut val; // Same as ^--
|
||||
| ------------^-- -------- move occurs because value has type `&mut (main::U, [main::U; 2])`, which does not implement the `Copy` trait
|
||||
|
@ -234,7 +270,7 @@ LL | let a @ (b, [c, d]) = &mut val; // Same as ^--
|
|||
| value moved here
|
||||
|
||||
error[E0382]: borrow of moved value
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:57:18
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:72:18
|
||||
|
|
||||
LL | let a @ &mut ref mut b = &mut U;
|
||||
| ---------^^^^^^^^^ ------ move occurs because value has type `&mut main::U`, which does not implement the `Copy` trait
|
||||
|
@ -243,7 +279,7 @@ LL | let a @ &mut ref mut b = &mut U;
|
|||
| value moved here
|
||||
|
||||
error[E0382]: borrow of moved value
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:60:30
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:75:30
|
||||
|
|
||||
LL | let a @ &mut (ref mut b, ref mut c) = &mut (U, U);
|
||||
| ---------------------^^^^^^^^^- ----------- move occurs because value has type `&mut (main::U, main::U)`, which does not implement the `Copy` trait
|
||||
|
@ -252,7 +288,7 @@ LL | let a @ &mut (ref mut b, ref mut c) = &mut (U, U);
|
|||
| value moved here
|
||||
|
||||
error[E0499]: cannot borrow `_` as mutable more than once at a time
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:78:24
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:93:24
|
||||
|
|
||||
LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
|
||||
| ---------------^^^^^^^^^-
|
||||
|
@ -264,7 +300,7 @@ LL | *a = Err(U);
|
|||
| ----------- first borrow later used here
|
||||
|
||||
error[E0499]: cannot borrow `_` as mutable more than once at a time
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:78:53
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:93:53
|
||||
|
|
||||
LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
|
||||
| ----------------^^^^^^^^^-
|
||||
|
@ -276,7 +312,7 @@ LL | *a = Err(U);
|
|||
| ----------- first borrow later used here
|
||||
|
||||
error[E0499]: cannot borrow `_` as mutable more than once at a time
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:90:24
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:105:24
|
||||
|
|
||||
LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
|
||||
| ---------------^^^^^^^^^-
|
||||
|
@ -288,7 +324,7 @@ LL | drop(a);
|
|||
| - first borrow later used here
|
||||
|
||||
error[E0499]: cannot borrow `_` as mutable more than once at a time
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:90:53
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:105:53
|
||||
|
|
||||
LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
|
||||
| ----------------^^^^^^^^^-
|
||||
|
@ -299,7 +335,7 @@ LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
|
|||
LL | drop(a);
|
||||
| - first borrow later used here
|
||||
|
||||
error: aborting due to 29 previous errors
|
||||
error: aborting due to 32 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0007, E0382, E0499.
|
||||
For more information about an error, try `rustc --explain E0007`.
|
||||
|
|
|
@ -13,6 +13,13 @@
|
|||
fn main() {
|
||||
struct NotCopy;
|
||||
|
||||
fn f1(a @ b: &NotCopy) { // OK
|
||||
let _: &NotCopy = a;
|
||||
}
|
||||
fn f2(ref a @ b: &NotCopy) {
|
||||
let _: &&NotCopy = a; // Ok
|
||||
}
|
||||
|
||||
let a @ b = &NotCopy; // OK
|
||||
let _: &NotCopy = a;
|
||||
let ref a @ b = &NotCopy; // OK
|
||||
|
|
|
@ -7,7 +7,7 @@ LL | #![feature(bindings_after_at)]
|
|||
= note: `#[warn(incomplete_features)]` on by default
|
||||
|
||||
error[E0009]: cannot bind by-move and by-ref in the same pattern
|
||||
--> $DIR/default-binding-modes-both-sides-independent.rs:21:17
|
||||
--> $DIR/default-binding-modes-both-sides-independent.rs:28:17
|
||||
|
|
||||
LL | let ref a @ b = NotCopy;
|
||||
| --------^
|
||||
|
@ -16,7 +16,7 @@ LL | let ref a @ b = NotCopy;
|
|||
| by-ref pattern here
|
||||
|
||||
error[E0009]: cannot bind by-move and by-ref in the same pattern
|
||||
--> $DIR/default-binding-modes-both-sides-independent.rs:22:21
|
||||
--> $DIR/default-binding-modes-both-sides-independent.rs:29:21
|
||||
|
|
||||
LL | let ref mut a @ b = NotCopy;
|
||||
| ------------^
|
||||
|
@ -25,7 +25,7 @@ LL | let ref mut a @ b = NotCopy;
|
|||
| by-ref pattern here
|
||||
|
||||
error[E0009]: cannot bind by-move and by-ref in the same pattern
|
||||
--> $DIR/default-binding-modes-both-sides-independent.rs:24:20
|
||||
--> $DIR/default-binding-modes-both-sides-independent.rs:31:20
|
||||
|
|
||||
LL | Ok(ref a @ b) | Err(ref a @ b) => {}
|
||||
| --------^ --------^
|
||||
|
@ -36,7 +36,7 @@ LL | Ok(ref a @ b) | Err(ref a @ b) => {}
|
|||
| by-ref pattern here
|
||||
|
||||
error[E0009]: cannot bind by-move and by-ref in the same pattern
|
||||
--> $DIR/default-binding-modes-both-sides-independent.rs:28:17
|
||||
--> $DIR/default-binding-modes-both-sides-independent.rs:35:17
|
||||
|
|
||||
LL | ref a @ b => {}
|
||||
| --------^
|
||||
|
|
|
@ -7,6 +7,18 @@
|
|||
//~^ WARN the feature `or_patterns` is incomplete and may cause the compiler to crash
|
||||
|
||||
fn main() {
|
||||
fn f(a @ a @ a: ()) {}
|
||||
//~^ ERROR identifier `a` is bound more than once in this parameter list
|
||||
//~| ERROR identifier `a` is bound more than once in this parameter list
|
||||
|
||||
match Ok(0) {
|
||||
Ok(a @ b @ a)
|
||||
//~^ ERROR identifier `a` is bound more than once in the same pattern
|
||||
| Err(a @ b @ a)
|
||||
//~^ ERROR identifier `a` is bound more than once in the same pattern
|
||||
=> {}
|
||||
}
|
||||
|
||||
let a @ a @ a = ();
|
||||
//~^ ERROR identifier `a` is bound more than once in the same pattern
|
||||
//~| ERROR identifier `a` is bound more than once in the same pattern
|
||||
|
|
|
@ -1,35 +1,59 @@
|
|||
error[E0415]: identifier `a` is bound more than once in this parameter list
|
||||
--> $DIR/pat-at-same-name-both.rs:10:14
|
||||
|
|
||||
LL | fn f(a @ a @ a: ()) {}
|
||||
| ^ used as parameter more than once
|
||||
|
||||
error[E0415]: identifier `a` is bound more than once in this parameter list
|
||||
--> $DIR/pat-at-same-name-both.rs:10:18
|
||||
|
|
||||
LL | fn f(a @ a @ a: ()) {}
|
||||
| ^ used as parameter more than once
|
||||
|
||||
error[E0416]: identifier `a` is bound more than once in the same pattern
|
||||
--> $DIR/pat-at-same-name-both.rs:10:13
|
||||
--> $DIR/pat-at-same-name-both.rs:15:20
|
||||
|
|
||||
LL | Ok(a @ b @ a)
|
||||
| ^ used in a pattern more than once
|
||||
|
||||
error[E0416]: identifier `a` is bound more than once in the same pattern
|
||||
--> $DIR/pat-at-same-name-both.rs:17:23
|
||||
|
|
||||
LL | | Err(a @ b @ a)
|
||||
| ^ used in a pattern more than once
|
||||
|
||||
error[E0416]: identifier `a` is bound more than once in the same pattern
|
||||
--> $DIR/pat-at-same-name-both.rs:22:13
|
||||
|
|
||||
LL | let a @ a @ a = ();
|
||||
| ^ used in a pattern more than once
|
||||
|
||||
error[E0416]: identifier `a` is bound more than once in the same pattern
|
||||
--> $DIR/pat-at-same-name-both.rs:10:17
|
||||
--> $DIR/pat-at-same-name-both.rs:22:17
|
||||
|
|
||||
LL | let a @ a @ a = ();
|
||||
| ^ used in a pattern more than once
|
||||
|
||||
error[E0416]: identifier `a` is bound more than once in the same pattern
|
||||
--> $DIR/pat-at-same-name-both.rs:13:21
|
||||
--> $DIR/pat-at-same-name-both.rs:25:21
|
||||
|
|
||||
LL | let ref a @ ref a = ();
|
||||
| ^ used in a pattern more than once
|
||||
|
||||
error[E0416]: identifier `a` is bound more than once in the same pattern
|
||||
--> $DIR/pat-at-same-name-both.rs:15:29
|
||||
--> $DIR/pat-at-same-name-both.rs:27:29
|
||||
|
|
||||
LL | let ref mut a @ ref mut a = ();
|
||||
| ^ used in a pattern more than once
|
||||
|
||||
error[E0416]: identifier `a` is bound more than once in the same pattern
|
||||
--> $DIR/pat-at-same-name-both.rs:18:17
|
||||
--> $DIR/pat-at-same-name-both.rs:30:17
|
||||
|
|
||||
LL | let a @ (Ok(a) | Err(a)) = Ok(());
|
||||
| ^ used in a pattern more than once
|
||||
|
||||
error[E0416]: identifier `a` is bound more than once in the same pattern
|
||||
--> $DIR/pat-at-same-name-both.rs:18:26
|
||||
--> $DIR/pat-at-same-name-both.rs:30:26
|
||||
|
|
||||
LL | let a @ (Ok(a) | Err(a)) = Ok(());
|
||||
| ^ used in a pattern more than once
|
||||
|
@ -48,6 +72,7 @@ warning: the feature `or_patterns` is incomplete and may cause the compiler to c
|
|||
LL | #![feature(or_patterns)]
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
error: aborting due to 10 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0416`.
|
||||
Some errors have detailed explanations: E0415, E0416.
|
||||
For more information about an error, try `rustc --explain E0415`.
|
||||
|
|
Loading…
Reference in New Issue