rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
93.58k stars 12.05k forks source link

Fix Error Messages for `break` Inside Coroutines #124777

Closed veera-sivarajan closed 1 week ago

veera-sivarajan commented 1 week ago

Fixes #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.~~

rustbot commented 1 week ago

r? @compiler-errors

rustbot has assigned @compiler-errors. They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

veera-sivarajan commented 1 week ago

@rustbot ready

compiler-errors commented 1 week ago

@rustbot author

r=me after changing the diagnostic one last time, thanks for dealing with the back-and-forth

compiler-errors commented 1 week ago

Thanks @bors r+ rollup

bors commented 1 week ago

:pushpin: Commit 21ccec0cc8a5ee253f021cdc81e05dbab43e59e1 has been approved by compiler-errors

It is now in the queue for this repository.