-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
217 additions
and
62 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
14 changes: 9 additions & 5 deletions
14
tests/ui/async-await/async-outside-of-await-issue-121096.stderr
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
12 changes: 7 additions & 5 deletions
12
tests/ui/async-await/issues/non-async-enclosing-span.stderr
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 or blocks | ||
} | ||
|
||
gen fn _foo() { | ||
yield; | ||
//~^ ERROR `yield` can only be used in `gen` closures 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 or blocks | ||
} | ||
|
||
fn _foo() { | ||
yield; | ||
//~^ ERROR `yield` can only be used in `gen` closures 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 or blocks | ||
--> $DIR/missing_gen_in_2024.rs:8:16 | ||
| | ||
LL | let _ = || yield; | ||
| ^^^^^ | ||
| | ||
help: use `gen` to make the closure a coroutine | ||
| | ||
LL | let _ = gen || yield; | ||
| +++ | ||
|
||
error: `yield` can only be used in `gen` closures or blocks | ||
--> $DIR/missing_gen_in_2024.rs:13:5 | ||
| | ||
LL | yield; | ||
| ^^^^^ | ||
| | ||
help: use `gen` to make the closure 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`. |
Oops, something went wrong.