Rollup merge of #71587 - matthewjasper:promoted-move-errors, r=nikomatsakis
Report cannot move errors in promoted MIR Closes #70934
This commit is contained in:
commit
4bde46e0e3
5 changed files with 93 additions and 6 deletions
10
src/test/ui/borrowck/move-error-in-promoted-2.rs
Normal file
10
src/test/ui/borrowck/move-error-in-promoted-2.rs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
// Regression test for #70934
|
||||
|
||||
struct S;
|
||||
|
||||
fn foo() {
|
||||
&([S][0],);
|
||||
//~^ ERROR cannot move out of type `[S; 1]`
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
12
src/test/ui/borrowck/move-error-in-promoted-2.stderr
Normal file
12
src/test/ui/borrowck/move-error-in-promoted-2.stderr
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
error[E0508]: cannot move out of type `[S; 1]`, a non-copy array
|
||||
--> $DIR/move-error-in-promoted-2.rs:6:7
|
||||
|
|
||||
LL | &([S][0],);
|
||||
| ^^^^^^
|
||||
| |
|
||||
| cannot move out of here
|
||||
| move occurs because value has type `S`, which does not implement the `Copy` trait
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0508`.
|
||||
17
src/test/ui/borrowck/move-error-in-promoted.rs
Normal file
17
src/test/ui/borrowck/move-error-in-promoted.rs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
// Regression test for #70934
|
||||
|
||||
fn f() {
|
||||
const C: [S2; 1] = [S2];
|
||||
let _ = S1(C[0]).clone();
|
||||
//~^ ERROR cannot move out of type `[S2; 1]`
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
struct S1(S2);
|
||||
|
||||
#[derive(Clone)]
|
||||
struct S2;
|
||||
|
||||
fn main() {
|
||||
f();
|
||||
}
|
||||
12
src/test/ui/borrowck/move-error-in-promoted.stderr
Normal file
12
src/test/ui/borrowck/move-error-in-promoted.stderr
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
error[E0508]: cannot move out of type `[S2; 1]`, a non-copy array
|
||||
--> $DIR/move-error-in-promoted.rs:5:16
|
||||
|
|
||||
LL | let _ = S1(C[0]).clone();
|
||||
| ^^^^
|
||||
| |
|
||||
| cannot move out of here
|
||||
| move occurs because value has type `S2`, which does not implement the `Copy` trait
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0508`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue