-
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
Add suggestion to "use break" when attempting to implicit-break a loop #84516
Conversation
r? @estebank (rust-highfive has picked a reviewer for you, use r? to override) |
Could you add some tests exercising these changes? |
Sure, it's ready now. |
|
||
loop { | ||
return 1; | ||
} |
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.
Can you add another case of loop { 1 }
as foo
's tail expression? That could suggest either return
or break
, right?
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.
Done. Yes, I thought it best to output no more than one of the suggestions, so that case is suggesting return
as before. Note that this is also the case with the third error, hence this new test case may seem a bit redundant.
@bors r+ |
📌 Commit 3b50461 has been approved by |
Add suggestion to "use break" when attempting to implicit-break a loop Fixes rust-lang#84114
Add suggestion to "use break" when attempting to implicit-break a loop Fixes rust-lang#84114
Add suggestion to "use break" when attempting to implicit-break a loop Fixes rust-lang#84114
Rollup of 8 pull requests Successful merges: - rust-lang#84235 (refactor StyledBuffer) - rust-lang#84450 (Give a better error when `std` or `core` are missing) - rust-lang#84486 (Handle pretty printing of `else if let` clauses without ICEing) - rust-lang#84499 (Tweak trait not `use`d suggestion) - rust-lang#84516 (Add suggestion to "use break" when attempting to implicit-break a loop) - rust-lang#84520 (Improve diagnostics for function passed when a type was expected.) - rust-lang#84541 (Inline most raw socket, fd and handle conversions) - rust-lang#84547 (Get rid of is_min_const_fn) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Fixes #84114