#![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!
//~| 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
+ }
}
= 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
| 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
| 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
| 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
| 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
| | 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`.
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
//~^ 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);
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
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);
//~| 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);
+ }
+ }
}
= 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);
| ------------^
| 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());
| -----^^^^^^^---------
| 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);
| -----^^^^^^^---------
| 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);
| -----^^^^^^^---------
| 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);
| -----^^^^^^^---------
| 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);
| ---------^^^^^^^-----
| | 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
| 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
| | 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);
| ------------^^^^^^^^^
| - 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);
| ----------------^^^^^
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`.
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) => {
#![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!
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;
#![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,
// 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;
= 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) => {
| ---------^^^^^^^^^^^^^-----^
| | 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;
| -----^^^---------
| 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;
| ---------^^^-----
| 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);
| -----^^^^---------^^---------^
| 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);
| ---------^^^^-----^^-----^
| 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();
| ---------^^^-----
| 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();
| -----^^^---------
| 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;
| ---------^^^-----
| 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;
| -----^^^---------
| 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) => {
| ---------^^^^^^-----^
| 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) => {
| ---------^^^^^^^-----^
| 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) => {
| -----^^^^^^---------^
| 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) => {
| -----^^^^^^^---------^
| 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 } => {}
| -----^^^^^^---------^
| 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 } => {}
| -----^^^^^^^---------^
| 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 } => {}
| ---------^^^^^^-----^
| 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 } => {}
| ---------^^^^^^^-----^
| 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 } => {}
| -----^^^^^^---------^
| 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 } => {}
| -----^^^^^^^---------^
| 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
+ --> $DIR/borrowck-pat-ref-mut-and-ref.rs:108:9
|
LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false } => {}
| ---------^^^^^^-----^
| 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
+ --> $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 } => {}
| ---------^^^^^^^-----^
| 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
+ --> $DIR/borrowck-pat-ref-mut-and-ref.rs:115:9
|
LL | let ref a @ (ref mut b, ref mut c) = (U, U);
| -----^^^^---------^^---------^
| 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
+ --> $DIR/borrowck-pat-ref-mut-and-ref.rs:120:9
|
LL | let ref a @ (ref mut b, ref mut c) = (U, U);
| -----^^^^---------^^---------^
| 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:115:9
+ --> $DIR/borrowck-pat-ref-mut-and-ref.rs:127:9
|
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:120:9
+ --> $DIR/borrowck-pat-ref-mut-and-ref.rs:132:9
|
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) => {
| ----------------------^^^^^-
| ---------- 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();
| ------------^^^^^
| -------- 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();
| --------^^^^^^^^^
| - 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) => {
| -----------^^^^^^^^^-
| - 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) => {
| ------------^^^^^^^^^-
| - 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
= 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
= 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
= 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
= 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);
| ---------^^^^^^^^^------------
| - 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);
| --------------------^^^^^^^^^-
| - 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);
| ---------^^^^^^^^^------------
| - 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);
| --------------------^^^^^^^^^-
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`.
#![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
= 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;
| ---------^^^---------
| 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;
| ---------^^^---------
| 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;
| ---------^^^---------
| 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;
| ---------^^^---------
| 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;
| ---------^^^---------
| 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 @ (
| ^--------
| |_____^
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 @ (
| ^--------
| |_________^
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) => {
| ---------^^^^^^---------^
| 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) => {
| ---------^^^^^^^---------^
| 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) => {
| ---------^^^^^^---------^
| 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) => {
| ---------^^^^^^^---------^
| 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) => {
| ---------^^^^^^---------^
| 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) => {
| ---------^^^^^^^---------^
| 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) => {
| ---------^^^^^^---------^
| 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) => {
| ---------^^^^^^^---------^
| | 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;
| ------------^^^^^^^^^
| - 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;
| ------------^^^^^^^^^
| ------ 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
| 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
| 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
| 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
| 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) => {
| ---------------^^^^^^^^^-
| ----------- 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) => {
| ----------------^^^^^^^^^-
| ----------- 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) => {
| ---------------^^^^^^^^^-
| - 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) => {
| ----------------^^^^^^^^^-
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`.
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
= 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;
| --------^
| 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;
| ------------^
| 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) => {}
| --------^ --------^
| 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 => {}
| --------^
//~^ 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
+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: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:10:13
+ --> $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
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`.