Commit graph

1854 commits

Author SHA1 Message Date
Michael Wright
c20e17f8ee Remove + from has_unary_equivalent
Rust doesn't has a unary + operator!
2018-11-06 07:05:13 +02:00
Michael Wright
2353f24095 Merge branch 'master' into fix-missing-comma-fp 2018-11-06 07:00:54 +02:00
Philipp Hansch
90f31e21ab
RIIR update lints: Add check mode (update_lints.py rewrite complete)
This finishes up the rewrite of `update_lints.py` in Rust. More
specifically, this

* adds the `--check` flag and handling to clippy_dev
* tracks file changes over the different calls to `replace_region_in_file`
* only writes changes to files if the `--check` flag is *not* used
* runs `./util/dev update_lints --check` on CI instead of the old script
* replaces usage of the `update_lints.py` script with an error

`./util/dev update_lints` behaves 99% the same as the python script.
The only difference that I'm aware of is an ordering change to
`clippy_lints/src/lib.rs` because underscores seem to be sorted
differently in Rust and in Python.

🏁
2018-11-05 07:18:47 +01:00
bors[bot]
7e417d4cbd Merge #3353
3353: float support added for mistyped_literal_suffixes lint r=mikerite a=Maxgy

I implemented the mistyped_literal_suffixes lint for float literals.

```
#![allow(unused_variables)]

fn main() {
    let x = 1E2_32;
    let x = 75.22_64;
}
```
Given the above, the additional check suggests the variables to be written as `let x = 1E2_f32` and `let x = 75.22_f64`.

Fixes #3167 

Co-authored-by: Maxwell Anderson <maxwell.brayden.anderson@gmail.com>
2018-11-05 03:58:15 +00:00
Matthias Krüger
396701613e rustup https://github.com/rust-lang/rust/pull/55665 (pass contexts by reference) 2018-11-04 22:47:20 +01:00
Maxwell Anderson
3e0de1745d changed into_iter to iter and fixed a lint check 2018-11-04 10:39:54 -07:00
Michael Wright
a3ab512576 Fix collapsible_if error 2018-11-04 10:48:24 +02:00
Michael Wright
0c1ffc1d1f Fix possible_missing_comma false positives
`possible_missing_comma` should only trigger when the binary operator has
unary equivalent. Otherwise, it's not possible to insert a comma without
breaking compilation. The operators identified were `+`, `&`, `*` and `-`.

This fixes the specific examples given in issues #3244 and #3396
but doesn't address the conflict this lint has with the style of starting
a line with a binary operator.
2018-11-04 10:02:49 +02:00
Matthias Krüger
b59b60c8ae rustup https://github.com/rust-lang/rust/pull/55330/ 2018-11-03 18:50:23 +01:00
bors[bot]
486300b89d Merge #3400
3400: Fix a false-positive of needless_borrow r=phansch a=sinkuu



Co-authored-by: Shotaro Yamada <sinkuu@sinkuu.xyz>
2018-11-03 08:34:13 +00:00
flip1995
cadb367a5c
Also lint cfg_attr(.., rustfmt::skip) 2018-11-02 19:50:24 +01:00
flip1995
a770d8edd0
Differ between inner and outer attributes 2018-11-02 19:49:58 +01:00
flip1995
e1cf160e2a
Add cfg_attr(rustfmt) lint 2018-11-02 19:49:57 +01:00
kennytm
5563bd6cc3
Addressed comments. 2018-11-02 22:53:57 +08:00
kennytm
2b2acf1002
Fix dogfood error. 2018-11-02 22:53:57 +08:00
kennytm
2d1c9313b0
Added lints into_iter_on_ref and into_iter_on_array. Fix #1565. 2018-11-02 22:53:56 +08:00
flip1995
32396f6e18
Allow single_match_else 2018-11-02 14:00:46 +01:00
flip1995
014cf3d6e0
Fix typos 2018-11-02 13:49:10 +01:00
flip1995
cf89c40e34
Fix dogfood error 2018-11-02 13:49:10 +01:00
flip1995
ea4a80f215
Fix typo and indentation 2018-11-02 13:49:10 +01:00
flip1995
f6d57862c7
Add new lint: unknwon_clippy_lintsg 2018-11-02 13:49:09 +01:00
Matthias Krüger
df7cff31dc clippy: fix pedantic warnings and run clippy::pedantic lints on the codebase.
Turn on pedantic lints in dogfood and base tests.

needless_bool: fix clippy::items-after-statements
redundant_pattern_matching: fix clippy::similar-names
mods.rs: fix clippy::explicit-iter-loop
returns.rs: allow clippy::cast-possible-wrap

Fixes #3172
2018-11-02 12:16:43 +01:00
bors[bot]
7c86a9c05c Merge #3387
3387: Replace big if/else expression with match r=flip1995 a=mikerite



Co-authored-by: Michael Wright <mikerite@lavabit.com>
2018-11-02 07:58:00 +00:00
Shotaro Yamada
d4370f8b07 Fix a false-positive of needless_borrow 2018-11-02 15:58:54 +09:00
bors[bot]
0ad5b9b9e0 Merge #3388
3388: RIIR update lints: Generate deprecated lints r=phansch a=phansch

The update script now also generates the 'register_removed' section in
`clippy_lints/src/lib.rs`.

Also, instead of using `let mut store ...`, I added a new identifier
line so that the replacement will continue to work in case `let mut
store ...` ever changes.

cc #2882

Co-authored-by: Philipp Hansch <dev@phansch.net>
2018-11-02 06:29:40 +00:00
Maxwell Anderson
b6b97e5c1f format code 2018-11-01 15:43:40 -06:00
Maxwell Anderson
6c1f89e8dc Merge remote-tracking branch 'upstream/master' 2018-11-01 15:26:38 -06:00
Philipp Hansch
beb44ef6ca
Fix clippy build failure on latest master 2018-11-01 20:35:23 +01:00
Maxwell Anderson
02340cc891
fix comment spacing 2018-11-01 12:35:01 -06:00
Michael Wright
0a41dfd946 Use slice patterns instead of padding 2018-11-01 07:06:47 +02:00
Maxwell Anderson
98ce3348d9 change single char str to char 2018-10-31 18:09:56 -06:00
Maxwell Anderson
3c22b2314c Merge remote-tracking branch 'upstream/master' 2018-10-31 16:48:47 -06:00
Maxwell Anderson
f4b919cad7 add lint to lintarray macro 2018-10-31 16:48:24 -06:00
Maxwell Anderson
6b895b8267 Revert "small fix"
This reverts commit b1abc81a60.
2018-10-31 16:39:12 -06:00
bors[bot]
73458aebe3 Merge #3368
3368: added downsides to "known problems" for get_unwrap lint r=flip1995 a=humean

As a beginner I found this lint to be confusing because I was not sure how the `Option` type disappeared as conceptually I know that my `.get()` and Index could fail. Initially I thought maybe the compiler or clippy was smart enough to understand that it was impossible for my `.get()` to fail in this particular case, but it was explained to me that using the Index syntax is just shorthand for directly unwrapping the value:

https://doc.rust-lang.org/src/std/collections/hash/map.rs.html#1547

For beginners or users trying to iterate quickly it seems common to litter your code with `unwrap` or `except` as placeholders for where some explicit error handling might need to take place. I think it should be warned that using Index is merely more concise, but doesn't at all reduce the risk of panics and might in fact cause you to miss handling them in a future refactor.

Co-authored-by: Michael Rutter <michael.john.rutter@gmail.com>
Co-authored-by: Michael Rutter <humean@users.noreply.github.com>
2018-10-31 10:21:51 +00:00
bors[bot]
c8308c92b6 Merge #3378
3378: Fix lint_without_lint_pass r=phansch a=mikerite



Co-authored-by: Michael Wright <mikerite@lavabit.com>
Co-authored-by: flip1995 <hello@philkrones.com>
2018-10-31 07:18:42 +00:00
Philipp Hansch
64bd658516
RIIR update lints: Generate deprecated lints
The update script now also generates the 'register_removed' section in
`clippy_lints/src/lib.rs`.

Also, instead of using `let mut store ...`, I added a new identifier
line so that the replacement will continue to work in case `let mut
store ...` ever changes.
2018-10-31 08:03:50 +01:00
bors[bot]
b144c7f35d Merge #3370
3370: bool_comparison triggers 3 times on same code r=phansch a=mrbuzz

Fix #3335 

Co-authored-by: Giorgio Gambino <gambnio.giorgio@gmail.com>
2018-10-31 06:48:49 +00:00
Michael Wright
4e054ad320 Replace big if/else expression with match 2018-10-31 06:29:38 +02:00
Matthias Krüger
650eb09981 docs: use_self: hightlight the "should be" code sample as rust code as well. 2018-10-31 01:42:17 +01:00
Manish Goregaokar
a06296f836 Rustup to rustc 1.31.0-nightly (fb2446ad5 2018-10-30) 2018-10-30 04:06:37 +00:00
Giorgio Gambino
c0c1f1f7fa Fix #3335 rev2: bool_comparison triggers 3 times on same code 2018-10-29 22:23:45 +01:00
flip1995
1e43c3bb9f
Register MISTYPED_LITERAL_SUFFIXES lint 2018-10-29 20:54:21 +01:00
flip1995
a7fc6799df
Rewrite registered lint collection 2018-10-29 20:44:45 +01:00
Michael Wright
267d5d3433
Fix lint_without_lint_pass 2018-10-29 20:28:06 +01:00
bors[bot]
14d2700b6f Merge #3217 #3366
3217: Fix string_lit_as_bytes lint for macros r=phansch a=yaahallo

Prior to this change, string_lit_as_bytes would trigger for constructs
like `include_str!("filename").as_bytes()` and would recommend fixing it
by rewriting as `binclude_str!("filename")`.

This change updates the lint to act as an EarlyLintPass lint. It then
differentiates between string literals and macros that have bytes
yielding alternatives.

Closes #3205

3366: Don't expand macros in some suggestions r=oli-obk a=phansch

Fixes #1148 
Fixes #1628
Fixes #2455
Fixes #3023
Fixes #3333
Fixes #3360

Co-authored-by: Jane Lusby <jlusby42@gmail.com>
Co-authored-by: Philipp Hansch <dev@phansch.net>
2018-10-28 17:13:34 +00:00
Giorgio Gambino
7cfde9cfa9 Fix #3335: bool_comparison triggers 3 times on same code 2018-10-28 15:37:39 +01:00
Matthias Krüger
6eb1f23555 rustup: fix build with rustc 1.31.0-nightly (cae6efc37 2018-10-27) 2018-10-28 13:56:50 +01:00
Michael Rutter
232a483331
more consistent use of terminology; trait > syntax 2018-10-28 12:31:02 +00:00
Michael Rutter
061a48321c added downsides to "known problems" for get_unwrap lint 2018-10-28 08:12:47 +00:00