Commit graph

3117 commits

Author SHA1 Message Date
bors
23d2b21297 Auto merge of #5230 - DevinR528:macro-use, r=flip1995
Macro use

---

changelog: This lint enforces Rust 2018 idiom of importing macro's directly without `#[macro_use]` fixes #5179 .
2020-03-05 17:30:52 +00:00
bors
329923edec Auto merge of #5257 - mlegner:cast_hex_fp, r=flip1995
Resolve false positives of unnecessary_cast for non-decimal integers

This PR resolves false positives of `unnecessary_cast` for hexadecimal integers to floats and adds a corresponding test case.

Fixes: #5220

changelog: none
2020-03-04 16:11:40 +00:00
Devin R
597e02dcdf warn on macro_use attr 2020-03-04 09:36:02 -05:00
bors
8c7b3ad3fa Auto merge of #5266 - sinkuu:questionmark, r=flip1995
Lint `if let Some` and early return in question_mark lint

Fixes #5260

changelog: lint `if let Some` and early return in `question_mark` lint
2020-03-04 13:30:08 +00:00
mlegner
73deb723dd
Included binary and octal cases. 2020-03-04 13:21:01 +01:00
mlegner
9ff4581cd3
Test for unnecessary_cast of hex int literal. 2020-03-04 13:21:00 +01:00
bors
36b65986af Auto merge of #5258 - ThibsG:UselessBindingInStruct638, r=flip1995
Add lint for .. use in fully binded struct

This PR adds the lint `match-wild-in-fully-binded-struct` to prevent the use of the `..` pattern when all fields of the struct are already binded.

Fixes: #638

changelog: Add [`rest_pat_in_fully_bound_structs`] lint to warn against the use of `..` in fully binded struct
2020-03-04 11:06:31 +00:00
bors
8dc3fde127 Auto merge of #5246 - JarredAllen:master, r=flip1995
Detect usage of custom floating-point abs implementation

Closes #5224

changelog: Enhance [`suboptimal_flops`] lint to detect manual implementations of the `abs` method
2020-03-04 10:53:03 +00:00
Shotaro Yamada
246709f89e run-rustfix 2020-03-04 17:37:01 +09:00
Shotaro Yamada
45f61ead2c Lint if let Some in question_mark lint 2020-03-04 17:24:12 +09:00
ThibsG
2aa14c9beb Add restrictive pat use in full binded struct 2020-03-04 09:11:07 +01:00
JarredAllen
c3e96d14ab Update test case answers to match cargo dev fmt 2020-03-03 19:23:04 -08:00
JarredAllen
fe342f3291 Ran cargo dev fmt 2020-03-03 18:06:59 -08:00
flip1995
a640696cdf
Rustup to rust-lang/rust#69506 2020-03-04 00:56:43 +01:00
JarredAllen
f8e949fa1c Recommended changes from flip1995 2020-03-03 15:52:53 -08:00
Yuki Okushi
46ee6b1840 Add regression test 2020-03-03 22:22:46 +09:00
bors
f44181e799 Auto merge of #5047 - flip1995:use_debug, r=phansch
Don't trigger use_debug lint in Debug impl

Fixes #5039

changelog: Don't trigger [`use_debug`] lint in Debug impl
2020-03-03 11:32:51 +00:00
bors
5d3e3e1a9e Auto merge of #5250 - mlegner:unused_fp, r=flip1995
Whitelist unused attribute for use items.

This PR whitelists the `unused` attribute with `use` items and adds a corresponding test case.

Fixes: #5229
changelog: none
2020-03-03 11:16:55 +00:00
flip1995
a540b5ca2e
Update stderr 2020-03-03 10:48:08 +01:00
mlegner
8669be56c4
Whitelist unused attribute for use items. 2020-03-02 10:22:05 +01:00
JarredAllen
ee73972537 Changed test output to reflect cargo fmt 2020-02-29 19:11:38 -08:00
JarredAllen
bfa2691559 Run cargo dev fmt 2020-02-29 18:51:39 -08:00
JarredAllen
028cddb956 Finished checking for cases of absolute values 2020-02-29 13:46:59 -08:00
Matthias Krüger
1e29b36e4e add test for #5238 2020-02-28 22:00:20 +01:00
JarredAllen
5a21661ce5 Some bugfixing 2020-02-28 12:40:13 -08:00
JarredAllen
ce0dc9b70e Created floating point abs lint and test, but not yet run 2020-02-27 22:31:41 -08:00
Yuki Okushi
7c760e5f83 Rustup to rust-lang/rust#61812 2020-02-27 12:19:18 +09:00
Krishna Sai Veera Reddy
ff0d44e45a Add imprecise_flops lint
Add lint to detect floating point operations that can be computed more
accurately at the cost of performance. `cbrt`, `ln_1p` and `exp_m1`
library functions call their equivalent cmath implementations which is
slower but more accurate so moving checks for these under this new lint.
2020-02-23 22:36:15 -08:00
Krishna Sai Veera Reddy
e94a167508 Rename mul_add test file and add general improvements 2020-02-23 22:20:34 -08:00
Krishna Sai Veera Reddy
4065ca9c8c Move manual_mul_add into suboptimal_flops lint 2020-02-23 22:20:34 -08:00
Krishna Sai Veera Reddy
454e505c12 Run rust-fix on tests 2020-02-23 22:20:34 -08:00
Krishna Sai Veera Reddy
6dacb1aa67 Change lint name to suboptimal_flops 2020-02-23 22:20:34 -08:00
Krishna Sai Veera Reddy
bc03f465c3 Remove lint for logarithm division identity 2020-02-23 22:20:34 -08:00
Krishna Veera Reddy
fd2506bcbf Add type suffixes to unsuffixed method receiver suggestions 2020-02-23 22:20:34 -08:00
Krishna Veera Reddy
de07c84903 Detect usage of (x + 1).ln() and suggest x.ln_1p() instead 2020-02-23 22:20:34 -08:00
Krishna Veera Reddy
a60ae5d31c Split test cases into separate files 2020-02-23 22:20:34 -08:00
Krishna Veera Reddy
de79733924 Lint expressions of the form x.log(b) / y.log(b) 2020-02-23 22:20:33 -08:00
Krishna Veera Reddy
9520d3dfa4 Suggest usage of powi method when applicable 2020-02-23 22:20:33 -08:00
Krishna Veera Reddy
1f4f357bf5 Consolidate the accuracy and efficiency lints
Merge the accuracy and efficiency lints into a single lint that
checks for improvements to accuracy, efficiency and readability
of floating-point expressions.
2020-02-23 22:20:33 -08:00
Krishna Veera Reddy
c636c6a55b Add lints to detect inaccurate and inefficient FP operations
Add lints to detect floating point computations that are either
inaccurate or inefficient and suggest better alternatives.
2020-02-23 22:20:33 -08:00
Krishna Sai Veera Reddy
049079856b Prevent missing_const_for_fn on functions with const generic params
`const` functions cannot have const generic parameters so prevent the
`missing_const_for_fn` lint from firing in that case.
2020-02-21 19:56:44 -08:00
flip1995
4dd2252b17
Fix suggestion for weird formattings 2020-02-21 11:14:19 +01:00
flip1995
b67764d5cb
Add test for prelude import 2020-02-21 11:14:18 +01:00
flip1995
06a6189376
Move enum_glob_use lint into wildcard_imports pass 2020-02-21 11:14:17 +01:00
flip1995
8a572a540a
Add tests for wildcard_imports lint 2020-02-21 11:02:25 +01:00
bors
acfcbee4a2 Auto merge of #5202 - krishna-veerareddy:issue-5201-move-lossy-float-literal-restriction, r=flip1995
Move check for lossy whole-number floats out of `excessive_precision`

changelog: Add new lint `lossy_float_literal` to detect lossy whole number float literals and move it out of `excessive_precision` again.

Fixes #5201
2020-02-21 09:43:55 +00:00
Yuki Okushi
8abe4365f3 Use generator own DefId 2020-02-21 16:24:58 +09:00
Krishna Sai Veera Reddy
219c94d028 Separate out lint to check lossy whole number float literals 2020-02-20 22:33:36 -08:00
Matthias Krüger
4f85bc2fe9 rustup https://github.com/rust-lang/rust/pull/69325, update test stderr 2020-02-20 23:54:10 +01:00
flip1995
fb989d3215
Remove remaining license header in test file 2020-02-20 12:06:45 +01:00
Krishna Sai Veera Reddy
533422fcce Add LOG2_10 and LOG10_2 to approx_const lint 2020-02-18 08:05:00 -08:00
daxpedda
0ee393cf01
Add tests and improve checks. 2020-02-17 14:43:38 +01:00
Krishna Sai Veera Reddy
552452873c Add tests for lossy whole number float literals 2020-02-17 00:05:50 -08:00
Yuki Okushi
09165ff576 Don't lint single_component_path_imports in macros 2020-02-17 11:13:42 +09:00
Yuki Okushi
f77158bc14 Fix false positive in zero_prefixed_literal 2020-02-13 14:39:29 +09:00
flip1995
b47dada167
Apply review comments 2020-02-12 09:34:28 +01:00
flip1995
095287dbc8
Add two more error causes to integration test 2020-02-12 09:34:27 +01:00
flip1995
1717a6f7d5
Ignore fmt test in GHA CI
This is already checked by clippy_dev.yml GHA
2020-02-12 09:34:26 +01:00
Krishna Sai Veera Reddy
fcc3e7238f Remove unnecessary imports from tests 2020-02-11 06:20:47 -08:00
Philipp Krones
c86c09b19a
Use current_dir instead of cargo_metadata
Co-Authored-By: lzutao <taolzu@gmail.com>
2020-02-10 16:42:50 +01:00
flip1995
f940b04de6
Fix run-pass tests when CARGO_TARGET_DIR is not set 2020-02-10 15:51:51 +01:00
bors
c066807a70 Auto merge of #5148 - krishna-veerareddy:issue-5147-option-env-unwrap, r=flip1995
Add `option-env-unwrap` lint

changelog: Add `option-env-unwrap` lint

Fixes #5147
2020-02-10 08:08:53 +00:00
Krishna Sai Veera Reddy
b48b221f80 Use PATH environment variable for testing
The tests were failing on windows because the `HOME` env variable
doesn't exist on it so using the `PATH` variable to test instead.
2020-02-09 15:35:51 -08:00
Krishna Sai Veera Reddy
a3a1587a1c Allow option-env-unwrap within external macros 2020-02-09 10:58:08 -08:00
Krishna Sai Veera Reddy
0e5ba2f0e7 Account for expect being used to unwrap Option 2020-02-09 08:54:23 -08:00
Lzu Tao
9eb913a7e2 Fix error E0460 when compiled on Rustc repo 2020-02-09 19:02:27 +07:00
Krishna Sai Veera Reddy
be1bc571c3 Add option-env-unwrap lint 2020-02-08 16:44:35 -08:00
Lzu Tao
9a12baad35 Update CARGO_TARGET_DIR 2020-02-07 14:41:04 +07:00
Lzu Tao
c6a4beaf56 Rustup https://github.com/rust-lang/rust/pull/67359 2020-02-07 10:40:09 +07:00
bors
b5e6d6db41 Auto merge of #5134 - flip1995:snippet_block, r=phansch
Make it possible to correctly indent snippet_block snippets

This adds a `indent_relative_to` arg to the `{snippet,expr}_block` functions. This makes it possible to keep the correct indentation of block like suggestions.

In addition, this makes the `trim_multiline` function private and adds a `indent_of` function, to get the indentation of the first line of a span.

The suggestion of `needless_continue` cannot be made auto applicable, since it would be also necessary to remove code following the linted expression. (Well, maybe it is possible, but I don't know how to do it. Expanding the suggestion span to the last expression, that should be removed didn't work)

changelog: Improve suggestions, when blocks of code are involved
2020-02-06 21:41:50 +00:00
flip1995
9897927504
Rustup to rust-lang/rust#68788 2020-02-06 20:33:39 +01:00
flip1995
4068ff4d8a
Improve help message in needless_continue 2020-02-06 19:15:01 +01:00
flip1995
c7979d3515
Fix rebase fallout 2020-02-06 19:15:01 +01:00
flip1995
7363728d18
Update remaining test files 2020-02-06 19:15:01 +01:00
flip1995
f1a72e992d
Update needless_continue stderr 2020-02-06 19:13:46 +01:00
flip1995
8e15985827
Rewrite suggestion generation of needless_continue 2020-02-06 19:13:46 +01:00
flip1995
10cd1662c1
Update block_in_if_condition test files 2020-02-06 19:13:46 +01:00
bors
75e983a518 Auto merge of #5125 - Areredify:too_many_bools, r=flip1995
Port mitsuhiko's excessive bools lints

Closes #4 .
changelog: add `struct_excessive_bools` and `fn_params_excessive_bools` lints.
I moved is_trait_impl_item check because at first I implemented it as a late pass for some reason but then I realized it's actually an early lint. But it's a useful function to have, should I move it into a separate pr?
2020-02-06 14:47:14 +00:00
bors
a3135ba131 Auto merge of #5132 - JohnTitor:fix-fp-in-unwrap-lint, r=flip1995
Do not lint `unnecessary_unwrap` in external macros

Fixes #5131

I think we shouldn't lint `{panicking, unnecessary}_unwrap` in macros, not just `assert!`.

changelog: Fix false positive in `unnecessary_unwrap`
2020-02-06 14:17:35 +00:00
Areredify
338fb7a3e9 add excessive bools lints 2020-02-05 20:54:58 +03:00
Lzu Tao
c4b4dd200c Use lazy_static 2020-02-05 16:13:55 +01:00
Lzu Tao
3485d22139 Add serde_derive to the need-to-be-disambiguated-crates list 2020-02-05 22:00:19 +07:00
Lzu Tao
47abd0a217 Fix dogfood to use cargo mod too 2020-02-05 21:55:03 +07:00
Lzu Tao
4c2a5f857a compile-test: Handle CARGO_TARGET_DIR and transitive deps 2020-02-05 21:55:03 +07:00
ThibsG
53094de08e Merge fixes 2020-02-04 22:53:24 +01:00
ThibsG
b29aacfec8 Add wild and struct handling 2020-02-04 22:53:24 +01:00
ThibsG
6afd7ea147 Use span_lint_and_sugg + move infaillible lint
- moving infaillible lint to prevent collisions
2020-02-04 22:49:08 +01:00
Yuki Okushi
19ce66c1c1 Re-cover use of unnecessary unwraps in macros 2020-02-05 05:38:26 +09:00
ThibsG
3445d41f07 Add new lint: match with a single binding statement
- Lint name: MATCH_SINGLE_BINDING
2020-02-04 01:06:16 +01:00
Yuki Okushi
514b1bc2af Do not lint unnecessary_unwrap in macros 2020-02-04 04:01:42 +09:00
Yuki Okushi
49934e70a2 Remove unnecessary comment 2020-02-04 01:29:11 +09:00
Yuki Okushi
7c5785ca2b Split up indexing_slicing ui test 2020-02-03 15:09:17 +09:00
Yuki Okushi
fa32b41365 Split up drop_forget_ref ui test 2020-02-01 20:28:27 +09:00
Matthias Krüger
187983e991 update test stderr 2020-01-31 20:21:10 +01:00
flip1995
006f07f090
Add test for await in debug_assert!(..) 2020-01-31 10:57:51 +01:00
bors
ca2abaf366 Auto merge of #5109 - phansch:ciao_util_dev, r=flip1995
Deprecate util/dev in favor of cargo alias

This means one less shell script and a bit more cross-platform support
for contributors.

If you've been using `./util/dev` before, this now becomes `cargo dev`.

The key part of this change is found in `.cargo/config` where an alias for calling the `clippy_dev` binary is defined.

changelog: none
2020-01-31 07:18:06 +00:00
bors
bbef531518 Auto merge of #5108 - JohnTitor:split-up-0130, r=flip1995
Split up `match` ui test

Part of #2038

Also, this decreases the line length limit to 220.

changelog: none
2020-01-30 21:06:47 +00:00
Philipp Hansch
4d1a11d354
Deprecate util/dev in favor of cargo alias
If you've been using `./util/dev` before, this now becomes `cargo dev`.

The key part of this change is found in `.cargo/config`.

This means one less shell script and a bit more cross-platform support
for contributors.
2020-01-30 21:34:31 +01:00
bors
668bc485da Auto merge of #5101 - Areredify:let_underscore_lock, r=flip1995
add `let_underscore_lock` lint

closes #1574
changelog: add `let_underscore_lock` lint

I am not entirely sure about my docs/messages wording here, improvements are welcome
2020-01-30 20:24:24 +00:00
Areredify
63ab7a5e8c lint all guard types, not just lock functions 2020-01-30 18:46:22 +03:00
Mikhail Babenko
9b88a2b295 decouple 'let_underscore' tests 2020-01-30 16:51:23 +03:00
Mikhail Babenko
d1f8621711 add lint 2020-01-30 16:48:56 +03:00
Yuki Okushi
17489ef811 Split up match ui test 2020-01-30 12:06:42 +09:00
Yuki Okushi
ed6a0cc8a1 Revive test in enum_clike_unportable_variant 2020-01-30 11:43:19 +09:00
xiongmao86
26b1d60f15 Add test and update reference. 2020-01-30 00:22:42 +08:00
Yuki Okushi
314f438ab4 Split up non_copy_const ui test 2020-01-27 12:14:11 +09:00
bors
4f65bec39a Auto merge of #5084 - JohnTitor:clean-up-span-lint, r=flip1995
Clean up `span_lint` in `methods/mod.rs`

Uses `span_help_and_lint` instead of `span_lint` and `span_lint_and_sugg` instead of `span_lint_and_then`.

changelog: none
2020-01-26 15:28:39 +00:00
Philipp Hansch
45333102d7
Resolve FIXME: String::new is now a const fn
`const_string_new` is stable since Rust 1.39
2020-01-26 11:03:53 +01:00
Yuki Okushi
4b133f2867 Apply review comments 2020-01-26 07:01:16 +09:00
bors
fd6f609f64 Auto merge of #5083 - Areredify:issue-4399, r=flip1995
dont fire `possible_missing_comma` if intendation is present

Closes #4399
changelog: dont fire `possible_missing_comma` if intendation is present

I suspect there is already a utils function for indentation (but searching indent didn't yield a function for that), and my solution is certainly not universal, but it's probably the best we can do.
2020-01-25 17:47:54 +00:00
Mikhail Babenko
a234aef084 dont fire possible_missing_comma if intendation is present 2020-01-25 20:16:05 +03:00
bors
6b5419412e Auto merge of #5081 - Areredify:vec_box_threshold, r=flip1995
add size parameter for `vec_box`  lint

changelog: add size threshold for the `vec_box` lint, currently 4096 bytes (one page) (subject to change). Closes #3547.

diff is a little bit confusing due to some refactoring (moving free functions to lint struct functions), relevant portion is [this](https://github.com/rust-lang/rust-clippy/compare/master...Areredify:vec_box_threshold?expand=1#diff-1096120ca9143af89dcc9175ea92b54aR294-R298). In hindsight should've been different commits, but oh well.
2020-01-25 16:11:43 +00:00
Mikhail Babenko
2b7bc260de add size parameter for lint 2020-01-25 18:06:52 +03:00
Yuki Okushi
83f6b516a0 Split up match_same_arms ui test 2020-01-25 14:25:45 +09:00
bors
87597b5a42 Auto merge of #5087 - Areredify:issue-4905, r=phansch
improve `empty_enum` documentation

closes #4905
changelog: improve `empty_enum` help message and documentation.
2020-01-24 22:30:07 +00:00
bors
1ccd284ec6 Auto merge of #5086 - Areredify:issue-3746, r=phansch
don't fire `empty_loop` in `no_std` crates

closes #3746.
changelog: move no_std detection to utils, don't fire empty_loop in no_std crates
2020-01-24 21:42:46 +00:00
Mikhail Babenko
634774b89b don't fire empty_loop in no_std crates 2020-01-24 14:42:24 +03:00
Mikhail Babenko
199ae1714e improve empty_enum documentation 2020-01-24 14:37:16 +03:00
Yuki Okushi
46b787d1b8 Split up needless_range_loop ui test 2020-01-24 17:21:50 +09:00
Yuki Okushi
3999b30d9b Update stderrs 2020-01-24 17:04:46 +09:00
bors
2c7cfa8321 Auto merge of #5027 - sinkuu:vectored_io, r=phansch
Lint vectored IO in unused_io_amount lint

`read_vectored` & `write_vectored` require handling returned value likewise non-vectored methods. https://github.com/rust-lang/rust/issues/68041

---

changelog: lint vectored IO in `unused_io_amount` lint
2020-01-24 06:44:09 +00:00
bors
3237b7a69f Auto merge of #5082 - Areredify:issue-4980, r=flip1995
disable let_underscore_must_use in external macros

changelog: disable let_underscore_must_use in external macros
Closes #4980
2020-01-23 18:29:28 +00:00
Mikhail Babenko
fef3657100 disable let_underscore_must_use in external macros 2020-01-23 20:02:34 +03:00
Areredify
796958c7e2 add option_as_ref_deref lint 2020-01-23 16:12:16 +03:00
Yuki Okushi
a7d58edf27 Ignore macros with ! operators in eq_op 2020-01-22 16:48:00 +09:00
bors
f78cc07509 Auto merge of #5068 - JohnTitor:split-up-transmute, r=phansch
Split up `transmute` ui test

Part of #2038

changelog: none
2020-01-21 06:22:05 +00:00
bors
dd06c06183 Auto merge of #5028 - krishna-veerareddy:issue-5026-mem-ordering-fences, r=phansch
Detect usage of invalid atomic ordering in memory fences

Detect usage of `core::sync::atomic::{fence, compiler_fence}` with `Ordering::Relaxed` and suggest valid alternatives.

changelog: Extend `invalid_atomic_ordering` to lint memory fences

Fixes #5026
2020-01-21 05:53:46 +00:00
bors
eca0d8e5d0 Auto merge of #5067 - JohnTitor:lint-skip-while-next, r=flip1995
Add `skip_while_next` lint

Fixes #4036

changelog: Add `skip_while_next` lint
2020-01-20 17:28:38 +00:00
bors
32949da78e Auto merge of #5070 - JohnTitor:suspicious-map-doc, r=flip1995
Improve `suspicious_map`documentation

Fixes #4793

changelog: none
2020-01-20 12:12:03 +00:00
Yuki Okushi
bec5b69e45 Apply review comment 2020-01-20 21:07:31 +09:00
Yuki Okushi
f8034e0bc6 Improve suspicious_mapdocumentation 2020-01-20 15:05:40 +09:00
Yuki Okushi
fdda3c3f25 Tweak wording in assertions_on_constants 2020-01-20 11:52:58 +09:00
Yuki Okushi
67d0f443b3 Split up transmute ui test 2020-01-20 11:16:50 +09:00
Yuki Okushi
95c369fa91 Add skip_while_next lint 2020-01-20 10:56:02 +09:00
bors
f7b3e4f29c Auto merge of #5056 - rust-lang:dissasociate-mut-key, r=flip1995
Avoid mut_key on types of unknown layout

This fixes #5020 by requiring a known layout for the key type before linting. Edit: This fixes #5043, too.

changelog: none
2020-01-19 14:41:28 +00:00
Andre Bogus
59fd637ba1 Avoid mut_key on types of unknown layout 2020-01-19 14:49:18 +01:00
bors
fd0428f622 Auto merge of #5032 - JohnTitor:add-sugg-some-result, r=flip1995
Add suggestions for `if_let_some_result`

Fixes #4991

This approach may be fragile though...

changelog: Add suggestions for `if_let_some_result`
2020-01-19 12:27:35 +00:00
Yuki Okushi
c9f8d03f42 Treat more strange pattern 2020-01-19 21:14:47 +09:00
Yuki Okushi
dfab83fe11 Split up if_same_then_else ui test 2020-01-19 15:04:41 +09:00
Yuki Okushi
7e76a19664 Apply review comments 2020-01-19 10:14:03 +09:00
Yuki Okushi
aab64a21cc Reduce span range 2020-01-19 10:06:08 +09:00
Yuki Okushi
ae872fe1c7 Rename ok_if_let to if_let_some_result 2020-01-19 10:06:08 +09:00
Yuki Okushi
9e55424bdc Apply review comments 2020-01-19 10:06:08 +09:00
Yuki Okushi
9035264a8f Add suggestion in if_let_some_result 2020-01-19 10:06:08 +09:00
bors
0a7003ecf0 Auto merge of #5065 - matthiaskrgr:rustup_28, r=matthiaskrgr
rustup https://github.com/rust-lang/rust/pull/67712

slice_patterns have been stabilized.

changelog: none
2020-01-18 22:44:46 +00:00
Matthias Krüger
b2c4f09d77 rustup https://github.com/rust-lang/rust/pull/67712
slice_patterns have been stabilized.
2020-01-18 23:43:28 +01:00
bors
0964b8d192 Auto merge of #5046 - JohnTitor:order-nonminimal-bool, r=flip1995
Keep the ordering in `nonminimal_bool` lint

I believe it shouldn't cause any regression but feel free to let me know if you have a doubtful example.
Also, splits up `booleans` ui test.

Fixes #5045

changelog: none
2020-01-18 19:51:46 +00:00
Yuki Okushi
ff0a22d99f Allow unused_self lint at the function level 2020-01-18 21:05:42 +09:00
bors
8b72b7251c Auto merge of #4994 - bradsherman:new_lint_gen, r=flip1995
Autogenerate new lints

Add option in clippy_dev to automatically generate boilerplate code for adding new lints

example:

`./util/dev new_lint --name=iter_nth_zero --type=late`

Fixes #4942

changelog: none
2020-01-16 16:24:41 +00:00
flip1995
3c68d892ff
Update custom_ice_message.stderr 2020-01-16 16:01:36 +01:00
Brad Sherman
32337a9b58 Add lint for default lint description
- Lint for any new lints that have the default lint description
  from the automation
2020-01-15 21:23:08 -06:00
bors
be09bb47db Auto merge of #5034 - ThibsG:MatchWildErrArmImprove5024, r=flip1995
Match wild err arm improvements

This lint should trigger on other identifiers which have `_` prefix (such as `_e`) and only if they are unused in the panic block.

_Note_: the `is_unused` function is greatly inspired from `pat_is_wild` function in [loops lints](43ac9416d9/clippy_lints/src/loops.rs (L1689)).
I've been considering doing some refactoring, maybe in utils. Maybe this PR or a new one. What do you think ?

fixes #5024

changelog: none
2020-01-15 21:17:21 +00:00
Andre Bogus
2797b64f7e Omit doc safety/errors header checking for main 2020-01-14 18:20:56 +01:00
Yuki Okushi
3885033e5f Split up booleans ui test 2020-01-14 08:32:33 +09:00
bors
c24a42289b Auto merge of #4543 - xiongmao86:issue4503, r=flip1995
Fix issue4503

Fixes #4503.

changelog: Add a lint checking user are using FileType.is_file() method and suggest using !FileType.is_dir().

- [x] Followed [lint naming conventions][lint_naming]
- [x] Added passing UI tests (including committed `.stderr` file)
- [x] `cargo test` passes locally
- [x] Executed `./util/dev update_lints`
- [x] Added lint documentation
- [x] Run `./util/dev fmt`
2020-01-13 22:09:39 +00:00
Yuki Okushi
73e525019d Fix the ordering on nonminimal_bool 2020-01-14 07:08:45 +09:00
bors
05cb0df748 Auto merge of #5033 - JohnTitor:split-use-self, r=flip1995
Split up `use_self` ui test

Part of #2038

changelog: none
2020-01-13 20:21:04 +00:00
ThibsG
d3c76b5b2a Change note message 2020-01-13 16:25:35 +01:00
ThibsG
e5c9073f9c Better binding name on Err for note 2020-01-13 16:25:35 +01:00
ThibsG
f79c47f28d Match underscore-prefixed variable also 2020-01-13 16:25:35 +01:00
Yuki Okushi
ce1c6b285d Rustup to rust-lang/rust#68045 2020-01-13 21:55:57 +09:00
xiongmao86
77c48ca341 Fix grammar error. 2020-01-12 19:54:17 +08:00
xiongmao86
8d3cc6b8a9 Change lint message. 2020-01-12 19:54:17 +08:00
xiongmao86
8d333a3cbb Extend spans to include !. 2020-01-12 19:54:17 +08:00
xiongmao86
bf9e6ca9f6 Fix lint warning in compile-test.rs 2020-01-12 19:54:17 +08:00
xiongmao86
a1f81355a7 format codebase. 2020-01-12 19:54:17 +08:00
xiongmao86
3c59eaf91c Add lint logic. 2020-01-12 19:54:17 +08:00
xiongmao86
3a788452e2 Add test. 2020-01-12 19:54:17 +08:00
Yuki Okushi
291f2cbeb8 Split up use_self ui test 2020-01-12 06:08:58 +09:00
Yuki Okushi
11fb749a96 Comment out half-open patterns' tests 2020-01-12 03:05:47 +09:00
Yuki Okushi
39947992b5 Rustup to rust-lang/rust#67806 2020-01-11 21:50:00 +09:00
Yuki Okushi
10cf141ebb Apply review comments 2020-01-11 19:39:43 +09:00
Yuki Okushi
77e5a1b227 Split up missing-doc ui test 2020-01-10 04:35:37 +09:00
Krishna Sai Veera Reddy
5e058f38f4 Add memory fence tests for invalid_atomic_ordering 2020-01-09 09:51:42 -08:00
Shotaro Yamada
b3971fdd5d Lint vectored IO in unused_io_amount lint 2020-01-09 23:46:55 +09:00
bors
ac795a6f3a Auto merge of #4960 - ThibsG:patterns_with_wildcard_#4640, r=flip1995
New lint: pats_with_wild_match_arm

Wildcard use with other pattern in same match arm.

The wildcard covers other(s) pattern(s) as it will match anyway.

changelog: add new lint when multiple patterns (including wildcard) are used in a match arm.

Fixes #4640.
2020-01-09 13:51:00 +00:00
bors
0da0ae3aa6 Auto merge of #5022 - flip1995:useless_attr, r=phansch
Fix useless_attribute suggestion

Fixes #5021

changelog: Fix [`useless_attribute`] suggestion, which tripped rustfix
2020-01-08 20:28:19 +00:00
flip1995
6eba66532c
Add regression test for useless_attribute lint 2020-01-08 17:47:01 +01:00
bors
52b9e704c6 Auto merge of #5017 - sinkuu:mir_no_opt_fallout, r=flip1995
Fix redundant_clone lint not working with PathBuf and OsString

https://github.com/rust-lang/rust-clippy/pull/4825 diabled MIR optimization in clippy, including `rustc_mir::transform::InstCombine` which reduces `&(*x)` to `x`. This PR tries to unwrap `&*` when looking into `mir::Rvalue`s.

Fixes #5014.

---

changelog: fixed `redundant_clone` lint not working with `PathBuf` and `OsString`
2020-01-08 12:09:45 +00:00
Yuki Okushi
787106c380 Normalize lint messages in cast_precision_loss 2020-01-08 16:36:02 +09:00
Shotaro Yamada
99eec3f54f Fix redundant_clone 2020-01-08 14:18:00 +09:00
ThibsG
0fa0df9efb Span help without suggestion 2020-01-07 19:10:59 +01:00
ThibsG
8ae8b08e32 Change lint name to WILDCARD_IN_OR_PATTERNS 2020-01-07 18:48:16 +01:00
ThibsG
58deaad42d Handle case for non-exhaustive enums 2020-01-07 18:48:16 +01:00
ThibsG
d60c6f9398 Move to complexity and adapt test
- test wildcard_enum_match_arm has been impacted by this new lint
2020-01-07 18:48:16 +01:00
ThibsG
96c4198832 New lint: pats_with_wild_match_arm
- Wildcard use with other pattern in same match arm
2020-01-07 18:48:16 +01:00
Yuki Okushi
abc49c3139 Bless 32bit test 2020-01-07 19:56:21 +09:00
Yuki Okushi
f7a93f029c Apply suggestion from code review 2020-01-07 18:38:12 +09:00
Yuki Okushi
07e33633a3 Update stderrs 2020-01-07 18:38:12 +09:00
bors
fdccfe7bca Auto merge of #5011 - JohnTitor:split-collapsible-if, r=flip1995
Split up `collapsible_if` ui test

Part of #2038

changelog: none
2020-01-07 08:45:14 +00:00
Yuki Okushi
175c78bc17 Split up collapsible_if ui test 2020-01-07 15:06:23 +09:00
Krishna Sai Veera Reddy
18060eb81e Split test cases into separate files 2020-01-06 16:39:31 -08:00
Krishna Sai Veera Reddy
9e6a6069a7 Add lint to detect usage of invalid atomic ordering
Detect usage of invalid atomic ordering modes such as
`Ordering::{Release, AcqRel}` in atomic loads and
`Ordering::{Acquire, AcqRel}` in atomic stores.
2020-01-06 16:39:31 -08:00
Yuki Okushi
2213989a01 Do not trigger let_and_return lint on macros 2020-01-07 05:26:20 +09:00
Yuki Okushi
65d15340cd Fix test again 2020-01-07 02:04:10 +09:00
Yuki Okushi
ce36335cf0 Pick up lost property 2020-01-07 01:54:51 +09:00
Yuki Okushi
2f2eaf8b7e Rustup to rust-lang/rust#67886 2020-01-07 01:46:33 +09:00
Andre Bogus
539cd25262 External macro check for missing_*_doc 2020-01-04 20:19:14 +01:00
Brad Sherman
ab5ff0352e Add lint for iter.nth(0)
- Encourage iter.next() rather than iter.nth(0), which is less readable
2020-01-04 11:20:11 -06:00
Philipp Hansch
c5178e82b4
Rustup to https://github.com/rust-lang/rust/pull/67853
Specifically caused by https://github.com/rust-lang/rust/pull/67786
2020-01-04 11:30:03 +01:00
bors
fa9b85d4df Auto merge of #4881 - krishna-veerareddy:issue-4871-use-mem-take, r=flip1995
Use `mem::take` instead of `mem::replace` when applicable

`std::mem::take` can be used to replace a value of type `T` with `T::default()` instead of `std::mem::replace`.

Fixes issue #4871

changelog: Added lint for [`mem_replace_with_default`]
2020-01-04 08:09:43 +00:00
Andre Bogus
47972cdf12 No #[no_mangle] must_use_candidate functions 2020-01-03 17:21:36 +01:00
bors
2e8c3c3e9e Auto merge of #4975 - JohnTitor:fix-4968, r=phansch
Fix ICE on `unsound_collection_transmute`

Fixes #4968

Check if `Ty`s are normalizable. It might show hidden false negative, I'm not sure.
Also, the regression tests are placed on two dirs, so move them to `/crashes`. I think it will be easier to find the right place.

changelog: Fix ICE on `unsound_collection_transmute`
2020-01-03 08:48:05 +00:00
Yuki Okushi
c6aeda7bd5 Move use_self_macro into crashes/auxiliary 2020-01-03 17:03:07 +09:00
bors
304edf39c3 Auto merge of #4978 - mikerite:fix-4958, r=phansch
Fix bad `explicit_into_iter_loop` suggestion

Fixes #4958

changelog: Fix bad `explicit_into_iter_loop` suggestion
2020-01-03 05:59:19 +00:00
Krishna Veera Reddy
8b36196cb6 Add if let test case 2020-01-01 23:22:57 -08:00
Yuki Okushi
20318e00ef Add attribute 2020-01-02 09:32:55 +09:00
Michael Wright
ea829bd8c6 Fix bad explicit_into_iter_loop suggestion
Fixes #4958
2020-01-01 07:09:09 +02:00
Krishna Veera Reddy
84a60c3186 Prevent replace_consts lint within match patterns
Currently `replace_consts` lint applies within match patterns but
the suggestion is incorrect as function calls are disallowed in
them. To fix this we prevent the lint from firing within patterns.
2019-12-31 10:33:15 -08:00
Krishna Veera Reddy
a8413a32b3 Remove unnecessary import 2019-12-31 09:22:35 -08:00
Krishna Veera Reddy
c09e79e226 Lint within internal macros without a suggestion 2019-12-31 09:22:35 -08:00
Krishna Veera Reddy
26812f733d Prevent mem_replace_with_default lint within macros
Also added test cases for internal and external macros.
2019-12-31 09:22:34 -08:00
Krishna Veera Reddy
2a75241c1a Add test cases for replace with Default::default() 2019-12-31 09:22:34 -08:00
Krishna Veera Reddy
8db319f957 Use mem::take instead of mem::replace when applicable
`std::mem::take` can be used to replace a value of type `T`
with `T::default()` instead of `std::mem::replace`.
2019-12-31 09:22:34 -08:00
Yuki Okushi
de6fe1071b Rename test prefix 2019-12-31 20:55:12 +09:00
Yuki Okushi
50a8582980 Move ICE tests to /crashes 2019-12-31 20:55:12 +09:00
Yuki Okushi
12a3d72462 Add regression test for #4968 2019-12-31 20:55:12 +09:00
bors
cecaca3382 Auto merge of #4634 - m-ober:feature/2320-map-or, r=llogiq
Add real suggestion to option_map_unwrap_or

changelog: Add real suggestion to `option_map_unwrap_or`

Fixes #2320
2019-12-30 15:50:06 +00:00
Micha Ober
c5046fdce5 Add real suggestion to option_map_unwrap_or 2019-12-28 23:24:45 +01:00
mgr-inz-rafal
6223391170 Add tests for new lint (modulo_arithmetic) 2019-12-28 16:46:08 +01:00
Yuki Okushi
6e525fc7b1 Improve tests 2019-12-27 22:07:55 +09:00
Yuki Okushi
b68e65b4da Do not drop suffixes on decimal_literal_representation 2019-12-26 01:22:36 +09:00
bors
a68ef55dbf Auto merge of #4947 - rust-lang:doc-main-extern-crate, r=flip1995
Avoid needless_doctest_main on 'extern crate'

This fixes #4927.

r? @flip1995

changelog: none
2019-12-24 15:03:54 +00:00
bors
1837cbce6c Auto merge of #4885 - rust-lang:mut-key-types, r=flip1995
new lint: mutable_key_type

This fixes #732 - well, partly, it doesn't adress `Hash` impls, but the use of mutable types as map keys or set members

changelog: add `mutable_key_type` lint

r? @flip1995
2019-12-24 13:32:45 +00:00
Andre Bogus
40435acf3d new lint: mutable_key_type 2019-12-24 13:46:19 +01:00
Andre Bogus
129d0cd0f4 Avoid needless_doctest_main on 'extern crate' 2019-12-24 13:42:37 +01:00
Lzu Tao
652666b288 rustup "Add span information to ExprKind::Assign" 2019-12-24 11:25:24 +07:00
Lzu Tao
f5b896451a do minor cleanups
* ToString and AsRef are in prelude, no need to import them
2019-12-24 03:06:52 +07:00
bors
37b7970a7c Auto merge of #4934 - illicitonion:exhaustive_match, r=flip1995
Update wildcard enum match lint for non_exhaustive enums

changelog: wildcard_enum_match_arm gives better suggestions for non_exhaustive enums
2019-12-23 17:00:38 +00:00
bors
b38b026a98 Auto merge of #4823 - Areredify:must_use_res, r=flip1995
Add `let_underscore_must_use` lint

changelog: closes #4812 , added a new `let_underscore_must_use` lint, moved `is_must_use_ty` to utils, added `is_must_use_fn` util function
2019-12-23 06:16:37 +00:00
Lzu Tao
185e608ae2 a few small cleanups 2019-12-23 05:28:23 +07:00
Mikhail Babenko
a310cb2d0b implemented let_underscore lint
actually add files

update lints

change to pedantic
2019-12-22 22:10:25 +03:00
Daniel Wagner-Hall
4f4444c429 Remove trailling .s 2019-12-22 11:51:39 +00:00
bors
8723eb6035 Auto merge of #4937 - mikerite:fix-4824, r=phansch
Fix `map_clone` false positive

Don't lint when the item type is not a reference. `copied` only applies to references.

changelog: Fix `map_clone` false positive
2019-12-22 09:55:50 +00:00
bors
19dbb22032 Auto merge of #4930 - flip1995:unused_label, r=phansch
Deprecate unused_label lint

This lint was uplifted/turned into warn-by-default in rustc

Fixes #4925

changelog: Deprecate [`unused_label`] lint
2019-12-22 09:39:32 +00:00
Michael Wright
b15b977d76 Fix map_clone false positive
Don't lint when the item type is not a reference. `copied` only applies
to references.
2019-12-22 11:26:51 +02:00
Daniel Wagner-Hall
c21b4ad7d4 Update wildcard enum match lint for non_exhaustive enums 2019-12-22 02:13:39 +00:00
Krishna Veera Reddy
91a491e68e Reduce cognitive complexity lint span
Currently the cognitive complexity lint spans the entire function
body making it really difficult to read and refactor the code in
editors. To fix this we reduce the lint span to the function name.
2019-12-21 18:07:53 -08:00
Lzu Tao
d1ca5f1d7c rustup "Merge ast::Mutability and mir::Mutability" 2019-12-21 18:38:45 +00:00
flip1995
710c749bb1
Deprecate unused_label lint
This lint was uplifted/turned into warn-by-default in rustc
2019-12-21 16:20:30 +01:00
Matthias Krüger
907078a8f8 rustup https://github.com/rust-lang/rust/pull/67130 2019-12-21 15:13:22 +01:00
bors
a86463c99f Auto merge of #4913 - mikerite:step-by-zero-20191218, r=phansch
Move `iterator_step_by_zero` and correct the documentation

Move `iterator_step_by_zero` and correct the documentation.

changelog: Corrected `iterator_step_by_zero` documentation
2019-12-20 07:10:11 +00:00
bors
584f95fc54 Auto merge of #4915 - mikerite:fix-4912-2, r=phansch
Fix `expect_fun_call` false negative on references

Closes #4912

changelog: Fix `expect_fun_call` false negative on references
2019-12-19 09:44:14 +00:00
Michael Wright
1559f8bf34 Fix expect_fun_call false negative on references
Closes #4912
2019-12-19 06:57:56 +02:00
Michael Wright
e097fca4df Update iterator_step_by_zero
Move `iterator_step_by_zero` into `methods` since it applies to all
iterators and not just ranges. Simplify the code while doing so.
2019-12-18 18:59:43 +02:00
Krishna Veera Reddy
eb0408ea65 Detect comparisons with NAN constants
Currently `cmp_nan` lint doesn't detect comparisons with NaN's
if the operands are consts variables so to fix this we evaluate
the const variables first before testing for NaN.
2019-12-17 18:51:30 -08:00
Mark Rousskov
69f99e74ac Update tests for revert of never type stabilization 2019-12-14 08:40:43 -05:00
bors
d82debbd01 Auto merge of #4883 - krishna-veerareddy:issue-4818-cast-sign-loss-false-positive, r=flip1995
Fix false positive with cast_sign_loss lint

`cast_sign_loss` lint incorrectly suggests that the result of `checked_abs`, `rem_euclid` and `checked_rem_euclid` cannot be casted to an unsigned integer without loss.

Fixes #4818 #4764 #4743

changelog: Fix false positives in `cast_sign_loss` lint
2019-12-12 00:34:59 +00:00
Krishna Veera Reddy
23c03e4994 Move transmute_float_to_int test cases into separate file
`transmute.stderr` file line count exceeded due to the new test
cases so moving the new test cases into a separate file.
2019-12-07 17:19:56 -08:00
Krishna Veera Reddy
c77fc06d52 Add lint to detect transmutes from float to integer
Add lint that detects transmutation from a float to an integer
and suggests usage of `{f32, f64}.to_bits()` instead.
2019-12-07 16:33:49 -08:00