forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
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#67551 - ldm0:E0627, r=Dylan-DPC
Add long error code explanation message for E0627 Part of rust-lang#61137. r? @GuillaumeGomez
- Loading branch information
Showing
13 changed files
with
47 additions
and
13 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,30 @@ | ||
A yield expression was used outside of the generator literal. | ||
|
||
Erroneous code example: | ||
|
||
```compile_fail,E0627 | ||
#![feature(generators, generator_trait)] | ||
fn fake_generator() -> &'static str { | ||
yield 1; | ||
return "foo" | ||
} | ||
fn main() { | ||
let mut generator = fake_generator; | ||
} | ||
``` | ||
|
||
The error occurs because keyword `yield` can only be used inside the generator | ||
literal. This can be fixed by constructing the generator correctly. | ||
|
||
``` | ||
#![feature(generators, generator_trait)] | ||
fn main() { | ||
let mut generator = || { | ||
yield 1; | ||
return "foo" | ||
}; | ||
} | ||
``` |
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
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
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#![feature(generators)] | ||
|
||
const A: u8 = { yield 3u8; 3u8}; | ||
//~^ ERROR yield statement outside | ||
//~^ ERROR yield expression outside | ||
|
||
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 |
---|---|---|
@@ -1,8 +1,9 @@ | ||
error[E0627]: yield statement outside of generator literal | ||
error[E0627]: yield expression outside of generator literal | ||
--> $DIR/yield-in-const.rs:3:17 | ||
| | ||
LL | const A: u8 = { yield 3u8; 3u8}; | ||
| ^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0627`. |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#![feature(generators)] | ||
|
||
fn main() { yield; } | ||
//~^ ERROR yield statement outside | ||
//~^ ERROR yield expression outside |
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 |
---|---|---|
@@ -1,8 +1,9 @@ | ||
error[E0627]: yield statement outside of generator literal | ||
error[E0627]: yield expression outside of generator literal | ||
--> $DIR/yield-in-function.rs:3:13 | ||
| | ||
LL | fn main() { yield; } | ||
| ^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0627`. |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#![feature(generators)] | ||
|
||
static B: u8 = { yield 3u8; 3u8}; | ||
//~^ ERROR yield statement outside | ||
//~^ ERROR yield expression outside | ||
|
||
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 |
---|---|---|
@@ -1,8 +1,9 @@ | ||
error[E0627]: yield statement outside of generator literal | ||
error[E0627]: yield expression outside of generator literal | ||
--> $DIR/yield-in-static.rs:3:18 | ||
| | ||
LL | static B: u8 = { yield 3u8; 3u8}; | ||
| ^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0627`. |