Improve a few errors and fix #33366
This commit is contained in:
parent
3e9747af49
commit
175ecfefd5
11 changed files with 68 additions and 58 deletions
|
|
@ -19,8 +19,8 @@ enum Foo {
|
|||
fn blah() {
|
||||
let f = &Foo::Foo1(box 1, box 2);
|
||||
match *f { //~ ERROR cannot move out of
|
||||
//~| move occurs here
|
||||
Foo::Foo1(num1, //~ NOTE attempting to move value to here
|
||||
//~| cannot move out
|
||||
Foo::Foo1(num1, //~ NOTE to prevent move
|
||||
num2) => (), //~ NOTE and here
|
||||
Foo::Foo2(num) => (), //~ NOTE and here
|
||||
Foo::Foo3 => ()
|
||||
|
|
@ -38,8 +38,8 @@ impl Drop for S {
|
|||
fn move_in_match() {
|
||||
match (S {f: "foo".to_string(), g: "bar".to_string()}) {
|
||||
S { //~ ERROR cannot move out of type `S`, which defines the `Drop` trait
|
||||
//~| can not move out of here
|
||||
f: _s, //~ NOTE attempting to move value to here
|
||||
//~| cannot move out of here
|
||||
f: _s, //~ NOTE to prevent move
|
||||
g: _t //~ NOTE and here
|
||||
} => {}
|
||||
}
|
||||
|
|
@ -55,8 +55,8 @@ fn free<T>(_: T) {}
|
|||
fn blah2() {
|
||||
let a = &A { a: box 1 };
|
||||
match a.a { //~ ERROR cannot move out of
|
||||
//~| move occurs here
|
||||
n => { //~ NOTE attempting to move value to here
|
||||
//~| cannot move out
|
||||
n => { //~ NOTE to prevent move
|
||||
free(n)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,8 +29,8 @@ pub fn main() {
|
|||
match tail {
|
||||
[Foo { string: a },
|
||||
//~^ ERROR cannot move out of borrowed content
|
||||
//~| move occurs here
|
||||
//~| attempting to move value to here
|
||||
//~| cannot move out
|
||||
//~| to prevent move
|
||||
Foo { string: b }] => {
|
||||
//~^ NOTE and here
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ fn a() {
|
|||
[box ref _a, _, _] => {
|
||||
//~^ borrow of `vec[..]` occurs here
|
||||
vec[0] = box 4; //~ ERROR cannot assign
|
||||
//~^ assignment to `vec[..]` occurs here
|
||||
//~^ assignment to borrowed `vec[..]` occurs here
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -31,7 +31,7 @@ fn b() {
|
|||
[_b..] => {
|
||||
//~^ borrow of `vec[..]` occurs here
|
||||
vec[0] = box 4; //~ ERROR cannot assign
|
||||
//~^ assignment to `vec[..]` occurs here
|
||||
//~^ assignment to borrowed `vec[..]` occurs here
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -41,8 +41,8 @@ fn c() {
|
|||
let vec: &mut [Box<isize>] = &mut vec;
|
||||
match vec {
|
||||
[_a, //~ ERROR cannot move out
|
||||
//~| move occurs here
|
||||
//~| attempting to move value to here
|
||||
//~| cannot move out
|
||||
//~| to prevent move
|
||||
_b..] => {
|
||||
// Note: `_a` is *moved* here, but `b` is borrowing,
|
||||
// hence illegal.
|
||||
|
|
@ -53,8 +53,8 @@ fn c() {
|
|||
_ => {}
|
||||
}
|
||||
let a = vec[0]; //~ ERROR cannot move out
|
||||
//~^ NOTE attempting to move value to here
|
||||
//~| can not move out of here
|
||||
//~^ NOTE to prevent move
|
||||
//~| cannot move out of here
|
||||
}
|
||||
|
||||
fn d() {
|
||||
|
|
@ -62,13 +62,13 @@ fn d() {
|
|||
let vec: &mut [Box<isize>] = &mut vec;
|
||||
match vec {
|
||||
[_a.., //~ ERROR cannot move out
|
||||
//~^ move occurs here
|
||||
_b] => {} //~ NOTE attempting to move value to here
|
||||
//~^ cannot move out
|
||||
_b] => {} //~ NOTE to prevent move
|
||||
_ => {}
|
||||
}
|
||||
let a = vec[0]; //~ ERROR cannot move out
|
||||
//~^ NOTE attempting to move value to here
|
||||
//~| can not move out of here
|
||||
//~^ NOTE to prevent move
|
||||
//~| cannot move out of here
|
||||
}
|
||||
|
||||
fn e() {
|
||||
|
|
@ -76,15 +76,15 @@ fn e() {
|
|||
let vec: &mut [Box<isize>] = &mut vec;
|
||||
match vec {
|
||||
[_a, _b, _c] => {} //~ ERROR cannot move out
|
||||
//~| move occurs here
|
||||
//~| NOTE attempting to move value to here
|
||||
//~| cannot move out
|
||||
//~| NOTE to prevent move
|
||||
//~| NOTE and here
|
||||
//~| NOTE and here
|
||||
_ => {}
|
||||
}
|
||||
let a = vec[0]; //~ ERROR cannot move out
|
||||
//~^ NOTE attempting to move value to here
|
||||
//~| can not move out of here
|
||||
//~^ NOTE to prevent move
|
||||
//~| cannot move out of here
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@ macro_rules! write {
|
|||
$arr.len() * size_of($arr[0]));
|
||||
//~^ ERROR mismatched types
|
||||
//~| expected u64, found usize
|
||||
//~| expected type
|
||||
//~| found type
|
||||
}
|
||||
}}
|
||||
}
|
||||
|
|
@ -38,6 +40,8 @@ fn main() {
|
|||
let hello = ['H', 'e', 'y'];
|
||||
write!(hello);
|
||||
//~^ NOTE in this expansion of write!
|
||||
//~| NOTE in this expansion of write!
|
||||
//~| NOTE in this expansion of write!
|
||||
|
||||
cast!(2);
|
||||
//~^ NOTE in this expansion of cast!
|
||||
|
|
|
|||
|
|
@ -32,9 +32,10 @@ fn main() {
|
|||
loop {
|
||||
f(&s, |hellothere| {
|
||||
match hellothere.x { //~ ERROR cannot move out
|
||||
//~| move occurs here
|
||||
//~| cannot move out of borrowed content
|
||||
box E::Foo(_) => {}
|
||||
box E::Bar(x) => println!("{}", x.to_string()), //~ NOTE attempting to move value to here
|
||||
box E::Bar(x) => println!("{}", x.to_string()),
|
||||
//~^ NOTE to prevent move
|
||||
box E::Baz => {}
|
||||
}
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue