-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Remove except
in suspicious_else_formatting
#3960
Conversation
This was causing two different ICEs in rust-lang#3741. The first was fixed in rust-lang#3925. The second one is fixed with this commit: We just don't `expect` anymore. If the snippet doesn't contain an `else`, we stop emitting the lint because it's not a suspiciously formatted else anyway.
clippy_lints/src/formatting.rs
Outdated
let else_pos = else_snippet.find("else").expect("there must be a `else` here"); | ||
// this will be a span from the closing ‘}’ of the “then” block (excluding) to | ||
// the | ||
// “if” of the “else if” block (excluding) |
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.
NIT: formatting
Is it possible to add a test for this ICE? Otherwise r=me with formatting fixed.
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.
nit fixed =)
I tried since yesterday but couldn't come up with a test case without external dependencies on relm and gtk. I think it's fine to merge it in this case since the ICE was triggered by an explicit expect
in our code and it would only regress if we were to add it back.
@bors r+ |
📌 Commit 289a9af has been approved by |
Remove `except` in suspicious_else_formatting 96c34e8 contains the fix: This was causing two different ICEs in #3741. The first was fixed in #3925. The second one is fixed with this commit: We just don't `expect` anymore. If the snippet doesn't contain an `else`, we stop emitting the lint because it's not a suspiciously formatted else anyway. Unfortunately I wasn't able to provide a minimal test case, but I think it's fine since it's just ignoring the `None` case now. And ad27e3f cleans up the lint code to use `if_chain`. Fixes #3741 once more.
Just a small nit, but the PR and the branch name use "except" instead of "expect". 😆 |
☀️ Test successful - checks-travis, status-appveyor |
96c34e8 contains the fix:
This was causing two different ICEs in #3741. The first was fixed in #3925.
The second one is fixed with this commit: We just don't
expect
anymore.If the snippet doesn't contain an
else
, we stop emitting the lint becauseit's not a suspiciously formatted else anyway.
Unfortunately I wasn't able to provide a minimal test case, but I think it's
fine since it's just ignoring the
None
case now.And ad27e3f cleans up the lint code to use
if_chain
.Fixes #3741 once more.