-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Error on using
yield
without also using gen
on the closure
And suggest adding the `gen` to the closure or function
- Loading branch information
Showing
19 changed files
with
138 additions
and
21 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
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
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
//@ edition: 2024 | ||
//@ compile-flags: -Zunstable-options | ||
//@ run-rustfix | ||
|
||
#![feature(coroutines, gen_blocks)] | ||
|
||
fn main() { | ||
let _ = gen || yield; | ||
//~^ ERROR `yield` can only be used in `gen` closures, functions, or blocks | ||
} | ||
|
||
gen fn _foo() { | ||
yield; | ||
//~^ ERROR `yield` can only be used in `gen` closures, functions, or blocks | ||
//~| ERROR yield expression outside of coroutine literal | ||
} |
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,16 @@ | ||
//@ edition: 2024 | ||
//@ compile-flags: -Zunstable-options | ||
//@ run-rustfix | ||
|
||
#![feature(coroutines, gen_blocks)] | ||
|
||
fn main() { | ||
let _ = || yield; | ||
//~^ ERROR `yield` can only be used in `gen` closures, functions, or blocks | ||
} | ||
|
||
fn _foo() { | ||
yield; | ||
//~^ ERROR `yield` can only be used in `gen` closures, functions, or blocks | ||
//~| ERROR yield expression outside of coroutine literal | ||
} |
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,31 @@ | ||
error: `yield` can only be used in `gen` closures, functions, or blocks | ||
--> $DIR/missing_gen_in_2024.rs:8:16 | ||
| | ||
LL | let _ = || yield; | ||
| ^^^^^ | ||
| | ||
help: use `gen` to make this item a coroutine | ||
| | ||
LL | let _ = gen || yield; | ||
| +++ | ||
|
||
error: `yield` can only be used in `gen` closures, functions, or blocks | ||
--> $DIR/missing_gen_in_2024.rs:13:5 | ||
| | ||
LL | yield; | ||
| ^^^^^ | ||
| | ||
help: use `gen` to make this item a coroutine | ||
| | ||
LL | gen fn _foo() { | ||
| +++ | ||
|
||
error[E0627]: yield expression outside of coroutine literal | ||
--> $DIR/missing_gen_in_2024.rs:13:5 | ||
| | ||
LL | yield; | ||
| ^^^^^ | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
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
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