-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Error Messages for break
Inside Coroutines
#124777
Fix Error Messages for break
Inside Coroutines
#124777
Conversation
rustbot has assigned @compiler-errors. Use |
5f66961
to
9d2685e
Compare
@rustbot ready |
compiler/rustc_passes/src/loops.rs
Outdated
coroutine_span, | ||
kind: hir::CoroutineDesugaring::Async, | ||
source: hir::CoroutineSource::Block, | ||
} => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can make this into a single match statement and do:
let source = match source {
...
};
let kind = match kind {
...
};
I also wonder if we should just get rid of the article "a"/"an" from the error message so that we don't need to put that into the fluent file... Seems kind of annoying to have to put that in there -- it's definitely not very translatable. 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, same. The of
followed by the article makes it wordy.
Can I remove both of
and the article to make it like cannot `break` inside `async` function
in all places? It's concise and flows well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess that's fine, yes
@rustbot author r=me after changing the diagnostic one last time, thanks for dealing with the back-and-forth |
Previously, `break` inside `gen` blocks and functions were incorrectly identified to be enclosed by a closure. This PR fixes it by displaying an appropriate error message for async blocks, async closures, async functions, gen blocks, gen closures, gen functions, async gen blocks, async gen closures and async gen functions. Note: gen closure and async gen closure are not supported by the compiler yet but I have added an error message here assuming that they might be implemented in the future. Also, fixes grammar in a few places by replacing `inside of a $coroutine` with `inside a $coroutine`.
9d2685e
to
21ccec0
Compare
Thanks @bors r+ rollup |
…iaskrgr Rollup of 4 pull requests Successful merges: - rust-lang#124777 (Fix Error Messages for `break` Inside Coroutines) - rust-lang#124837 (Migrate `run-make/rustdoc-map-file` to rmake) - rust-lang#124875 (Fix more ICEs in `diagnostic::on_unimplemented`) - rust-lang#124908 (Handle field projections like slice indexing in invalid_reference_casting) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#124777 - veera-sivarajan:bugfix-124495-identify-gen-block, r=compiler-errors Fix Error Messages for `break` Inside Coroutines Fixes rust-lang#124495 Previously, `break` inside `gen` blocks and functions were incorrectly identified to be enclosed by a closure. This PR fixes it by displaying an appropriate error message for async blocks, async closures, async functions, gen blocks, gen closures, gen functions, async gen blocks, async gen closures and async gen functions. Note: gen closure and async gen closure are not supported by the compiler yet but I have added an error message here assuming that they might be implemented in the future. ~~Also, fixes grammar in a few places by replacing `inside of a $coroutine` with `inside a $coroutine`.~~
Fixes #124495
Previously,
break
insidegen
blocks and functionswere incorrectly identified to be enclosed by a closure.
This PR fixes it by displaying an appropriate error message
for async blocks, async closures, async functions, gen blocks,
gen closures, gen functions, async gen blocks, async gen closures
and async gen functions.
Note: gen closure and async gen closure are not supported by the
compiler yet but I have added an error message here assuming that
they might be implemented in the future.
Also, fixes grammar in a few places by replacing
inside of a $coroutine
withinside a $coroutine
.