Uh oh!
There was an error while loading. Please reload this page.
Suggest adding {} for 'label: non_block_expr - #97759
Conversation
| help: consider enclosing expression in a block | ||
| | | ||
| LL ~ let _i = 'label: {match x { | ||
| LL | 0 => 42, | ||
| LL | 1 if false => break 'label 17, | ||
| LL | 1 => { | ||
| LL | if true { | ||
| LL | break 'label 13 | ||
| ... |
There was a problem hiding this comment.
Can someone explain where the second part of the suggestion (}) went?
There was a problem hiding this comment.
suggestions only render up to 5 lines i think
There was a problem hiding this comment.
I thought that it'd show multiple parts :(
There was a problem hiding this comment.
I think this is a bug in the rendering code. Your suggestion is still MachineApplicable so it will apply just fine, it's just the rendered code will be cut off.
I don't know if there's much you can do to fix it in this PR specifically, but maybe you could file a bug, or look into fixing the rendering code to omit lines in the middle?
There was a problem hiding this comment.
It's not a "bug", but rather a non-implementation of the logic for multiple "windows" into the code, like span labels have.
WaffleLapkin
commented
Jun 5, 2022
@rustbot label +A-diagnostics +A-suggestion-diagnostics |
Uh oh!
There was an error while loading. Please reload this page.
compiler-errors
left a comment
There was a problem hiding this comment.
This looks basically read to go. Can you fix a few more nits? Thanks!
| // Continue as an expression in an effort to recover on `'label: non_block_expr`. | ||
| self.parse_expr() | ||
| let expr = self.parse_expr().map(|expr| { |
There was a problem hiding this comment.
Can you actually use ? here, move the body of the closure to below, and remove the ? on line 1614?
There was a problem hiding this comment.
All other if branches also return Results, so I don't think it makes sense to do that
There was a problem hiding this comment.
Oh, oops, I thought there was only two if branches. I should've clicked the button to reveal the lines above 😓
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Michael Goulet <michael@errs.io>
3cbe9ee to
4f85a73Comparecompiler-errors
commented
Jun 5, 2022
Okay this looks good! Thanks for the contribution. @bors r+ |
bors
commented
Jun 5, 2022
📌 Commit 4f85a73 has been approved by |
…compiler-errors
Suggest adding `{}` for `'label: non_block_expr`
Adds suggestions like this:
```text
help: consider enclosing expression in a block
|
3 | 'l {0};
| + +
```
inspired by rust-lang#48594 (comment)
r? `@compiler-errors`…askrgr Rollup of 7 pull requests Successful merges: - rust-lang#90905 (Add empty impl blocks if they have documentation) - rust-lang#97683 (Fail gracefully when encountering an HRTB in APIT. ) - rust-lang#97721 (Do `suggest_await_before_try` with infer variables in self, and clean up binders) - rust-lang#97752 (typo: `-Zcodegen-backend=llvm -Cpasses=list` should work now) - rust-lang#97759 (Suggest adding `{}` for `'label: non_block_expr`) - rust-lang#97764 (use strict provenance APIs) - rust-lang#97765 (Restore a test that was intended to test `as` cast to ptr) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
…that_are_quite_far_away_from_each_other, r=estebank Hide irrelevant lines in suggestions to allow for suggestions that are far from each other to be shown This is an attempt to fix suggestions one part of which is 6 lines or more far from the first. I've noticed "the problem" (of not showing some parts of the suggestion) here: rust-lang#97759 (comment). I'm not sure about the implementation (this big closure is just bad and makes already complicated code even more so), but I want to at least discuss the result. Here is an example of how this changes the output: Before: ```text help: consider enclosing expression in a block | 3 ~ 'l: { match () { () => break 'l, 4 | 5 | 6 | 7 | 8 | ... ``` After: ```text help: consider enclosing expression in a block | 3 ~ 'l: { match () { () => break 'l, 4 | ... 31| 32~ } }; | ``` r? `@estebank` `@rustbot` label +A-diagnostics +A-suggestion-diagnostics
…that_are_quite_far_away_from_each_other, r=estebank Hide irrelevant lines in suggestions to allow for suggestions that are far from each other to be shown This is an attempt to fix suggestions one part of which is 6 lines or more far from the first. I've noticed "the problem" (of not showing some parts of the suggestion) here: rust-lang#97759 (comment). I'm not sure about the implementation (this big closure is just bad and makes already complicated code even more so), but I want to at least discuss the result. Here is an example of how this changes the output: Before: ```text help: consider enclosing expression in a block | 3 ~ 'l: { match () { () => break 'l, 4 | 5 | 6 | 7 | 8 | ... ``` After: ```text help: consider enclosing expression in a block | 3 ~ 'l: { match () { () => break 'l, 4 | ... 31| 32~ } }; | ``` r? `@estebank` `@rustbot` label +A-diagnostics +A-suggestion-diagnostics
…quite_far_away_from_each_other, r=estebank Hide irrelevant lines in suggestions to allow for suggestions that are far from each other to be shown This is an attempt to fix suggestions one part of which is 6 lines or more far from the first. I've noticed "the problem" (of not showing some parts of the suggestion) here: rust-lang/rust#97759 (comment). I'm not sure about the implementation (this big closure is just bad and makes already complicated code even more so), but I want to at least discuss the result. Here is an example of how this changes the output: Before: ```text help: consider enclosing expression in a block | 3 ~ 'l: { match () { () => break 'l, 4 | 5 | 6 | 7 | 8 | ... ``` After: ```text help: consider enclosing expression in a block | 3 ~ 'l: { match () { () => break 'l, 4 | ... 31| 32~ } }; | ``` r? `@estebank` `@rustbot` label +A-diagnostics +A-suggestion-diagnostics
Adds suggestions like this:
inspired by #48594 (comment)
r? @compiler-errors