forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#71587 - matthewjasper:promoted-move-errors,…
… r=nikomatsakis Report cannot move errors in promoted MIR Closes rust-lang#70934
- Loading branch information
Showing
5 changed files
with
93 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Regression test for #70934 | ||
|
||
struct S; | ||
|
||
fn foo() { | ||
&([S][0],); | ||
//~^ ERROR cannot move out of type `[S; 1]` | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`. |