add non-copy note to stderr

This commit is contained in:
csmoe 2018-12-27 19:08:51 +08:00
parent 8d77c7c037
commit 48de0ff333
20 changed files with 62 additions and 45 deletions

View file

@ -316,7 +316,7 @@ LL | v[0].y;
LL | drop(x);
| - borrow later used here
error[E0503]: cannot use `v[..].y` because it was mutably borrowed
error[E0503]: cannot use `v[_].y` because it was mutably borrowed
--> $DIR/borrowck-describe-lvalue.rs:261:9
|
LL | let x = &mut v;

View file

@ -316,7 +316,7 @@ LL | v[0].y;
LL | drop(x);
| - borrow later used here
error[E0503]: cannot use `v[..].y` because it was mutably borrowed
error[E0503]: cannot use `v[_].y` because it was mutably borrowed
--> $DIR/borrowck-describe-lvalue.rs:261:9
|
LL | let x = &mut v;

View file

@ -5,6 +5,8 @@ LL | drop(x.b);
| --- value moved here
LL | drop(*x.b); //~ ERROR use of moved value: `*x.b`
| ^^^^ value used here after move
|
= note: move occurs because `x.b` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait
error[E0382]: use of moved value: `x.b`
--> $DIR/borrowck-field-sensitivity.rs:14:10
@ -13,6 +15,8 @@ LL | let y = A { a: 3, .. x };
| ---------------- value moved here
LL | drop(*x.b); //~ ERROR use of moved value: `*x.b`
| ^^^^ value used here after move
|
= note: move occurs because `x.b` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait
error[E0382]: borrow of moved value: `x.b`
--> $DIR/borrowck-field-sensitivity.rs:20:13

View file

@ -1,19 +0,0 @@
error[E0382]: use of moved value: `a[..]`
--> $DIR/borrowck-move-out-from-array.rs:10:14
|
LL | let [_, _x] = a;
| -- value moved here
LL | let [.., _y] = a; //[ast]~ ERROR [E0382]
| ^^ value used here after move
error[E0382]: use of moved value: `a[..]`
--> $DIR/borrowck-move-out-from-array.rs:17:10
|
LL | let [_x, _] = a;
| -- value moved here
LL | let [_y..] = a; //[ast]~ ERROR [E0382]
| ^^ value used here after move
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0382`.

View file

@ -5,6 +5,8 @@ LL | let [_, _x] = a;
| -- value moved here
LL | let [.., _y] = a; //[ast]~ ERROR [E0382]
| ^^ value used here after move
|
= note: move occurs because `a[..]` has type `std::boxed::Box<i32>`, which does not implement the `Copy` trait
error[E0382]: use of moved value: `a[..]`
--> $DIR/borrowck-move-out-from-array.rs:17:10
@ -13,6 +15,8 @@ LL | let [_x, _] = a;
| -- value moved here
LL | let [_y..] = a; //[ast]~ ERROR [E0382]
| ^^ value used here after move
|
= note: move occurs because `a[..]` has type `std::boxed::Box<i32>`, which does not implement the `Copy` trait
error: aborting due to 2 previous errors

View file

@ -1,11 +1,11 @@
error[E0506]: cannot assign to `a[..]` because it is borrowed
error[E0506]: cannot assign to `a[_]` because it is borrowed
--> $DIR/borrowck-vec-pattern-move-tail.rs:16:5
|
LL | [1, 2, ref tail..] => tail,
| -------- borrow of `a[..]` occurs here
| -------- borrow of `a[_]` occurs here
...
LL | a[2] = 0; //[ast]~ ERROR cannot assign to `a[..]` because it is borrowed
| ^^^^^^^^ assignment to borrowed `a[..]` occurs here
| ^^^^^^^^ assignment to borrowed `a[_]` occurs here
...
LL | println!("t[0]: {}", t[0]);
| ---- borrow later used here

View file

@ -7,14 +7,14 @@ LL | [1, 2, ref tail..] => tail,
LL | a[2] = 0; //[ast]~ ERROR cannot assign to `a[..]` because it is borrowed
| ^^^^^^^^ assignment to borrowed `a[..]` occurs here
error[E0506]: cannot assign to `a[..]` because it is borrowed (Mir)
error[E0506]: cannot assign to `a[_]` because it is borrowed (Mir)
--> $DIR/borrowck-vec-pattern-move-tail.rs:16:5
|
LL | [1, 2, ref tail..] => tail,
| -------- borrow of `a[..]` occurs here
| -------- borrow of `a[_]` occurs here
...
LL | a[2] = 0; //[ast]~ ERROR cannot assign to `a[..]` because it is borrowed
| ^^^^^^^^ assignment to borrowed `a[..]` occurs here
| ^^^^^^^^ assignment to borrowed `a[_]` occurs here
...
LL | println!("t[0]: {}", t[0]);
| ---- borrow later used here

View file

@ -1,23 +1,23 @@
error[E0506]: cannot assign to `vec[..]` because it is borrowed
error[E0506]: cannot assign to `vec[_]` because it is borrowed
--> $DIR/borrowck-vec-pattern-nesting.rs:10:13
|
LL | [box ref _a, _, _] => {
| ------ borrow of `vec[..]` occurs here
| ------ borrow of `vec[_]` occurs here
LL | //~^ borrow of `vec[..]` occurs here
LL | vec[0] = box 4; //~ ERROR cannot assign
| ^^^^^^ assignment to borrowed `vec[..]` occurs here
| ^^^^^^ assignment to borrowed `vec[_]` occurs here
LL | //~^ assignment to borrowed `vec[..]` occurs here
LL | _a.use_ref();
| -- borrow later used here
error[E0506]: cannot assign to `vec[..]` because it is borrowed
error[E0506]: cannot assign to `vec[_]` because it is borrowed
--> $DIR/borrowck-vec-pattern-nesting.rs:23:13
|
LL | &mut [ref _b..] => {
| ------ borrow of `vec[..]` occurs here
| ------ borrow of `vec[_]` occurs here
LL | //~^ borrow of `vec[..]` occurs here
LL | vec[0] = box 4; //~ ERROR cannot assign
| ^^^^^^ assignment to borrowed `vec[..]` occurs here
| ^^^^^^ assignment to borrowed `vec[_]` occurs here
LL | //~^ assignment to borrowed `vec[..]` occurs here
LL | _b.use_ref();
| -- borrow later used here

View file

@ -14,6 +14,8 @@ LL | f(f(10));
| - ^ value used here after move
| |
| value moved here
|
= note: move occurs because `*f` has type `F`, which does not implement the `Copy` trait
error[E0499]: cannot borrow `*f` as mutable more than once at a time
--> $DIR/two-phase-nonrecv-autoref.rs:76:11
@ -43,6 +45,8 @@ LL | f(f(10));
| - ^ value used here after move
| |
| value moved here
|
= note: move occurs because `*f` has type `dyn std::ops::FnOnce(i32) -> i32`, which does not implement the `Copy` trait
error[E0502]: cannot borrow `a` as immutable because it is also borrowed as mutable
--> $DIR/two-phase-nonrecv-autoref.rs:129:27

View file

@ -14,6 +14,8 @@ LL | f(f(10));
| - ^ value used here after move
| |
| value moved here
|
= note: move occurs because `*f` has type `F`, which does not implement the `Copy` trait
error[E0499]: cannot borrow `*f` as mutable more than once at a time
--> $DIR/two-phase-nonrecv-autoref.rs:76:11
@ -43,6 +45,8 @@ LL | f(f(10));
| - ^ value used here after move
| |
| value moved here
|
= note: move occurs because `*f` has type `dyn std::ops::FnOnce(i32) -> i32`, which does not implement the `Copy` trait
error[E0502]: cannot borrow `a` as immutable because it is also borrowed as mutable
--> $DIR/two-phase-nonrecv-autoref.rs:129:27

View file

@ -8,6 +8,8 @@ LL | _ if { (|| { let bar = b; *bar = false; })();
LL | false } => { },
LL | &mut true => { println!("You might think we should get here"); },
| ^^^^ value used here after move
|
= note: move occurs because `b` has type `&mut bool`, which does not implement the `Copy` trait
error: aborting due to previous error

View file

@ -1,4 +1,4 @@
error[E0596]: cannot borrow `*TAB[..]` as mutable, as `TAB` is an immutable static item
error[E0596]: cannot borrow `*TAB[_]` as mutable, as `TAB` is an immutable static item
--> $DIR/issue-42344.rs:4:5
|
LL | TAB[0].iter_mut(); //~ ERROR cannot borrow data mutably in a `&` reference [E0389]

View file

@ -4,7 +4,7 @@ error[E0017]: references in statics may only refer to immutable values
LL | static buf: &mut [u8] = &mut [1u8,2,3,4,5,7]; //[ast]~ ERROR E0017
| ^^^^^^^^^^^^^^^^^^^^ statics require immutable values
error[E0594]: cannot assign to `buf[..]`, as `buf` is an immutable static item
error[E0594]: cannot assign to `buf[_]`, as `buf` is an immutable static item
--> $DIR/issue-46604.rs:10:5
|
LL | buf[0]=2; //[ast]~ ERROR E0389

View file

@ -4,7 +4,7 @@ error[E0017]: references in statics may only refer to immutable values
LL | static buf: &mut [u8] = &mut [1u8,2,3,4,5,7]; //[ast]~ ERROR E0017
| ^^^^^^^^^^^^^^^^^^^^ statics require immutable values
error[E0594]: cannot assign to `buf[..]`, as `buf` is an immutable static item
error[E0594]: cannot assign to `buf[_]`, as `buf` is an immutable static item
--> $DIR/issue-46604.rs:10:5
|
LL | buf[0]=2; //[ast]~ ERROR E0389

View file

@ -5,6 +5,8 @@ LL | let y = x;
| - value moved here
LL | println!("{}", *x); //~ ERROR use of moved value: `*x`
| ^^ value borrowed here after move
|
= note: move occurs because `x` has type `std::boxed::Box<i32>`, which does not implement the `Copy` trait
error: aborting due to previous error

View file

@ -1,23 +1,23 @@
error[E0506]: cannot assign to `v[..]` because it is borrowed
error[E0506]: cannot assign to `v[_]` because it is borrowed
--> $DIR/drop-no-may-dangle.rs:20:9
|
LL | let p: WrapMayNotDangle<&usize> = WrapMayNotDangle { value: &v[0] };
| ----- borrow of `v[..]` occurs here
| ----- borrow of `v[_]` occurs here
...
LL | v[0] += 1; //~ ERROR cannot assign to `v[..]` because it is borrowed
| ^^^^^^^^^ assignment to borrowed `v[..]` occurs here
LL | v[0] += 1; //~ ERROR cannot assign to `v[_]` because it is borrowed
| ^^^^^^^^^ assignment to borrowed `v[_]` occurs here
...
LL | }
| - borrow might be used here, when `p` is dropped and runs the `Drop` code for type `WrapMayNotDangle`
error[E0506]: cannot assign to `v[..]` because it is borrowed
error[E0506]: cannot assign to `v[_]` because it is borrowed
--> $DIR/drop-no-may-dangle.rs:23:5
|
LL | let p: WrapMayNotDangle<&usize> = WrapMayNotDangle { value: &v[0] };
| ----- borrow of `v[..]` occurs here
| ----- borrow of `v[_]` occurs here
...
LL | v[0] += 1; //~ ERROR cannot assign to `v[..]` because it is borrowed
| ^^^^^^^^^ assignment to borrowed `v[..]` occurs here
LL | v[0] += 1; //~ ERROR cannot assign to `v[_]` because it is borrowed
| ^^^^^^^^^ assignment to borrowed `v[_]` occurs here
LL | }
| - borrow might be used here, when `p` is dropped and runs the `Drop` code for type `WrapMayNotDangle`

View file

@ -6,6 +6,8 @@ LL | let y = *x;
LL | drop_unsized(y);
LL | println!("{}", &x);
| ^^ value borrowed here after move
|
= note: move occurs because `*x` has type `str`, which does not implement the `Copy` trait
error[E0382]: borrow of moved value: `y`
--> $DIR/borrow-after-move.rs:22:24
@ -26,6 +28,8 @@ LL | let y = *x;
LL | y.foo();
LL | println!("{}", &x);
| ^^ value borrowed here after move
|
= note: move occurs because `*x` has type `str`, which does not implement the `Copy` trait
error[E0382]: borrow of moved value: `y`
--> $DIR/borrow-after-move.rs:32:24
@ -45,6 +49,8 @@ LL | x.foo();
| - value moved here
LL | println!("{}", &x);
| ^^ value borrowed here after move
|
= note: move occurs because `*x` has type `str`, which does not implement the `Copy` trait
error: aborting due to 5 previous errors

View file

@ -15,6 +15,8 @@ LL | let _y = *x;
| -- value moved here
LL | drop_unsized(x); //~ERROR use of moved value
| ^ value used here after move
|
= note: move occurs because `*x` has type `str`, which does not implement the `Copy` trait
error[E0382]: use of moved value: `*x`
--> $DIR/double-move.rs:32:18
@ -23,6 +25,8 @@ LL | drop_unsized(x);
| - value moved here
LL | let _y = *x; //~ERROR use of moved value
| ^^ value used here after move
|
= note: move occurs because `x` has type `std::boxed::Box<str>`, which does not implement the `Copy` trait
error[E0382]: use of moved value: `y`
--> $DIR/double-move.rs:39:9
@ -41,6 +45,8 @@ LL | let _y = *x;
| -- value moved here
LL | x.foo(); //~ERROR use of moved value
| ^ value used here after move
|
= note: move occurs because `*x` has type `str`, which does not implement the `Copy` trait
error[E0382]: use of moved value: `*x`
--> $DIR/double-move.rs:51:18
@ -49,6 +55,8 @@ LL | x.foo();
| - value moved here
LL | let _y = *x; //~ERROR use of moved value
| ^^ value used here after move
|
= note: move occurs because `*x` has type `str`, which does not implement the `Copy` trait
error: aborting due to 6 previous errors

View file

@ -5,6 +5,8 @@ LL | self.bar();
| ---- value moved here
LL | return *self.x; //~ ERROR use of moved value: `*self.x`
| ^^^^^^^ value used here after move
|
= note: move occurs because `self` has type `S`, which does not implement the `Copy` trait
error: aborting due to previous error

View file

@ -7,7 +7,7 @@ struct S {
impl S {
pub fn foo(self) -> isize {
self.bar();
return *self.x; //~ ERROR use of moved value: `self`
return *self.x; //~ ERROR use of moved value: `*self.x`
}
pub fn bar(self) {}