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 ad27e3ff cleans up the lint code to use `if_chain`.
Auto merge of #3951 - phansch:add_combine_integration_test, r=phansch
Add Marwes/combine to integration tests
link: https://github.com/Marwes/combine
`combine` uses a lot of macros internally, has been downloaded more than 200_000
times and is also a dependency of [`redis-rs`](https://crates.io/crates/redis).
Clippy also previously ICEd on combine in #3747 so I think it would be
good to have this crate as an integration test.
Philipp Hansch [Sun, 14 Apr 2019 09:04:41 +0000 (11:04 +0200)]
Remove `except` in suspicious_else_formatting
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.
Philipp Hansch [Sat, 13 Apr 2019 11:21:14 +0000 (13:21 +0200)]
Add Marwes/combine to integration tests
link: https://github.com/Marwes/combine
`combine` uses a lot of macros internally, has been downloaded more than 200_000
times and is also a dependency of [`redis-rs`](https://crates.io/crates/redis).
Clippy also previously ICEd on combine in #3747 so I think it would be
good to have this crate as an integration test.
Mention that -D warnings will deny ALL warnings, not just clippy warnings
If we pass `-D warnings` to clippy, it causes the build to fail if there are *any* warnings, even the ones not generated by clippy. This isn't immediately obvious when you're looking at this as someone just setting up clippy, so people might not expect this nor know how to fix it. I've added a few sentences in the README to help anyone who runs into this.
These docs are useful for anyone setting up clippy warnings to be denied during CI, but still otherwise want rustc warnings to be allowed.
I could have also changed `-D warnings` to `-D clippy::all` in the Travis configurations themselves, but I wasn't sure what you would prefer to have people use as the default.
Handling the integer parsing properly instead of just unwrapping.
Note that the test is not catching the ICE because plain UI tests
[currently hide ICEs][compiletest_issue]. Once that issue is fixed, this
test would fail properly again.
Philipp Hansch [Mon, 8 Apr 2019 20:06:02 +0000 (22:06 +0200)]
Fix ICE in decimal_literal_representation lint
Handling the integer parsing properly instead of just unwrapping.
Note that the test is not catching the ICE because plain UI tests
[currently hide ICEs][compiletest_issue]. Once that issue is fixed, this
test would fail properly again.
Auto merge of #3929 - KarboniteKream:single-char-pattern, r=oli-obk
Escape a single quote in single_char_pattern hint
This PR correctly escapes single quotes in the hint for `single_char_pattern`.
For instance, the hint for `x.split("'")` was `'''`, while it should be `'\''`.
Auto merge of #3901 - rail-rain:issue_1670, r=flip1995
Fix `explicit_counter_loop` suggestion
#1670
This code seems to me to work, but I have two question.
* Because range expression desugared in hir, `Sugg::hir` doesn't add parenthesis to range expression. Which function is better to check range do you think, `check_for_loop_explicit_counter` or `hir_from_snippet`?
* Do you think we need to distinguish between range expression and struct expression that creates `std::ops::Range*`?
Auto merge of #3885 - mikerite:clippy_dev_toolchain, r=phansch
Add rust-toolchain for clippy_dev
AFAIK, `clippy_dev` is supposed to be built on stable. (This is why it's not a `[bin]` inside the root `Cargo.toml`.) This adds a `rust-toolchain` file for easy switching.
Félix Fischer [Tue, 26 Mar 2019 14:12:14 +0000 (11:12 -0300)]
Add TransmutingNull Lint
* Late Lint pass, catches:
* One liner: 0 -> null -> transmute
* One liner: std:null() -> transmute
* Const (which resolves to null) -> transmute
* UI Test case for Lint
* Updated test for issue 3849, because now the lint that code generated is in Clippy.
* Expanded `const.rs` miri-based Constant Folding code, to cover
raw pointers
Philipp Hansch [Fri, 15 Mar 2019 06:50:31 +0000 (07:50 +0100)]
Move some `unreadable_literal` ui tests to correct file
The moved tests were part of `tests/ui/literals.rs` before. Now they are
placed in `tests/ui/unreadable_literal.rs`, which now also runs
`rustfix` on these 4 extra let statements.