Commit graph

1955 commits

Author SHA1 Message Date
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
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
Philipp Hansch
beb44ef6ca
Fix clippy build failure on latest master 2018-11-01 20:35:23 +01:00
Michael Wright
0a41dfd946 Use slice patterns instead of padding 2018-11-01 07:06:47 +02: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
Philipp Hansch
840e50e97f
Don't expand macro in or_fun_call suggestion 2018-10-27 15:47:56 +02:00
Philipp Hansch
af1548f58f
Don't expand macro in single_match suggestion 2018-10-27 15:47:56 +02:00
Philipp Hansch
aa7bcb9074
Don't expand macro in identity_conversion suggestion 2018-10-27 15:47:56 +02:00
Jane Lusby
19ac2e94c6 fix: correctly reconstruct raw strings 2018-10-26 09:12:01 -07:00
Jane Lusby
f9020bb2dd fix: extra semicolon, only create callsite once 2018-10-26 09:12:01 -07:00
Jane Lusby
c209fc9349 Fix string_lit_as_bytes lint for macros
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
2018-10-26 09:12:01 -07:00
bors[bot]
457e7f12e9 Merge #3355
3355: Lint to remove redundant `clone()`s r=oli-obk a=sinkuu

This PR adds lint `redundant_clone`. It suggests to remove redundant `clone()` that clones a owned value that will be dropped without any usage after that.

Real-world example: https://github.com/rust-lang/rust/compare/7b0735a..sinkuu:redundant_clone2

Co-authored-by: Shotaro Yamada <sinkuu@sinkuu.xyz>
2018-10-26 10:36:43 +00:00
bors[bot]
ead29847ff Merge #3357
3357: Check existential types in `use_self` r=oli-obk a=HMPerson1

Fixes #3231

Co-authored-by: HMPerson1 <hmperson1@gmail.com>
2018-10-26 08:48:12 +00:00
Shotaro Yamada
9034b87a53 Move in_macro check 2018-10-26 03:07:29 +09:00
Shotaro Yamada
a828692780 Use BasicBlockData::terminator 2018-10-26 01:27:28 +09:00
Shotaro Yamada
6d6ff88585 Refactor 2018-10-26 01:16:14 +09:00
Shotaro Yamada
9a150b4aa1 Use lint_root 2018-10-26 01:16:14 +09:00
Shotaro Yamada
24d3f5b48f Implement visit_basic_block_data 2018-10-26 01:16:14 +09:00
Shotaro Yamada
3ca0895920 Add redundant_clone lint 2018-10-26 01:15:55 +09:00
Matthias Krüger
b8a9099011 Revert "new_ret_no_self: add sample from #3313 to Known Problems section."
This reverts commit fd2f6dd382.

Issue #3313 has been fixed.
2018-10-25 13:39:02 +02:00
bors[bot]
a87e1b02ab Merge #3331
3331: Disable arithmetic lints in constant items r=oli-obk a=pengowen123

Currently this will not catch cases in associated constants. I'm not sure whether checking spans is the best way to solve this issue, but I don't think it will cause any problems.
Fixes #1858

Co-authored-by: Owen Sanchez <pengowen816@gmail.com>
2018-10-25 09:38:00 +00:00
Philipp Krones
5dbca1f6b1
Add Applicability 2018-10-24 23:39:54 -04:00
HMPerson1
aabf8083bd
Add lint for calling mem::discriminant on a non-enum type 2018-10-24 23:39:54 -04:00
HMPerson1
3db14f182c
Check existential types in use_self 2018-10-24 23:32:33 -04:00
Owen Sanchez
0b9e9c9e3d Disable arithmetic lints in constant items 2018-10-24 20:27:26 -07:00
bors[bot]
4c6201dceb Merge #3312
3312: OUT_OF_BOUNDS_INDEXING false negative r=phansch a=JoshMcguigan

fixes #3102

Co-authored-by: Josh Mcguigan <joshmcg88@gmail.com>
2018-10-24 21:17:43 +00:00
bors[bot]
44fb29a356 Merge #3356
3356: Fix warnings introduced by #3349 r=flip1995 a=flip1995

I missed these warnings during review, should have checked the Travis log first.

Co-authored-by: flip1995 <hello@philkrones.com>
2018-10-24 15:25:12 +00:00
bors[bot]
bce190558f Merge #3338
3338: new_ret_no_self false positives r=flip1995 a=JoshMcguigan

~~WORK IN PROGRESS~~

I plan to fix all of the false positives in #3313 in this PR, but I wanted to open it now to start gathering feedback.

In this first commit, I've updated the lint to allow tuple return types as long as `Self` shows up at least once, in any position of the tuple. I believe this is the broadest possible interpretation of what should be allowed for tuple return types, but I would certainly be okay making the lint more strict. 

fixes #3313 

Co-authored-by: Josh Mcguigan <joshmcg88@gmail.com>
2018-10-24 14:42:40 +00:00
flip1995
57a18b6520
Fix warnings introduced by #3349 2018-10-24 16:18:01 +02:00
bors[bot]
319b75c75b Merge #3349
3349: Fixes #3347: Lint for wildcard dependencies in Cargo.toml r=ordovicia a=ordovicia

Add a lint for wildcard dependencies in Cargo.toml.
How should I write a test for this lint?

Fixes #3347

Co-authored-by: Hidehito Yabuuchi <hdht.ybuc@gmail.com>
2018-10-24 12:21:19 +00:00