-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not ICE when evaluating locals' types of invalid
yield
When a `yield` is outside of a generator, check its value regardless to avoid an ICE while trying to get all locals' types in writeback. Fix #78653.
- Loading branch information
Showing
3 changed files
with
30 additions
and
0 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,7 @@ | ||
#![feature(generators)] | ||
|
||
fn main() { | ||
yield || for i in 0 { } | ||
//~^ ERROR yield expression outside of generator literal | ||
//~| ERROR `{integer}` is not an iterator | ||
} |
21 changes: 21 additions & 0 deletions
21
src/test/ui/generator/yield-outside-generator-issue-78653.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
error[E0627]: yield expression outside of generator literal | ||
--> $DIR/yield-outside-generator-issue-78653.rs:4:5 | ||
| | ||
LL | yield || for i in 0 { } | ||
| ^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error[E0277]: `{integer}` is not an iterator | ||
--> $DIR/yield-outside-generator-issue-78653.rs:4:23 | ||
| | ||
LL | yield || for i in 0 { } | ||
| ^ `{integer}` is not an iterator | ||
| | ||
= help: the trait `Iterator` is not implemented for `{integer}` | ||
= note: if you want to iterate between `start` until a value `end`, use the exclusive range syntax `start..end` or the inclusive range syntax `start..=end` | ||
= note: required because of the requirements on the impl of `IntoIterator` for `{integer}` | ||
= note: required by `into_iter` | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
Some errors have detailed explanations: E0277, E0627. | ||
For more information about an error, try `rustc --explain E0277`. |