Skip to content
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

Incorrect indentation in suggestion of collapsible_if #2974

Closed
phansch opened this issue Jul 29, 2018 · 2 comments
Closed

Incorrect indentation in suggestion of collapsible_if #2974

phansch opened this issue Jul 29, 2018 · 2 comments
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages L-suggestion Lint: Improving, adding or fixing lint suggestions

Comments

@phansch
Copy link
Member

phansch commented Jul 29, 2018

Adding Clippy to libsyntax2, the suggestion for the collapsible_if lint has incorrect indentation.
See https://travis-ci.org/matklad/libsyntax2/jobs/409527826#L508-L523

The suggestion is:

warning: this if statement can be collapsed
   --> src/parser/grammar/items/mod.rs:277:5
    |
277 | /     if !p.eat(SEMI) {
278 | |         if p.expect(L_CURLY) {
279 | |             mod_contents(p, true);
280 | |             p.expect(R_CURLY);
281 | |         }
282 | |     }
    | |_____^
    |
    = note: #[warn(collapsible_if)] on by default
    = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#collapsible_if
help: try
    |
277 |     if !p.eat(SEMI) && p.expect(L_CURLY) {
278 |     mod_contents(p, true);
279 |     p.expect(R_CURLY);
280 | }
    |

It should be:

277 |     if !p.eat(SEMI) && p.expect(L_CURLY) {
278 |         mod_contents(p, true);
279 |         p.expect(R_CURLY);
280 |     }
@phansch phansch added C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages L-suggestion Lint: Improving, adding or fixing lint suggestions labels Jul 29, 2018
@lukasstevens
Copy link
Contributor

lukasstevens commented Oct 18, 2018

The culprit is utils::snippet_block, which trims all indentation except on the first line. My idea would be to just re-indent all lines except the last by one level; however, it is not clear whether to use tabs or spaces.

@giraffate
Copy link
Contributor

It seems to be fixed by #5134, so I'm closing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages L-suggestion Lint: Improving, adding or fixing lint suggestions
Projects
None yet
Development

No branches or pull requests

3 participants