Commit Graph

3142 Commits

Author SHA1 Message Date
flip1995
b2616641d9
Fix dogfood findings 2019-10-24 14:39:19 +02:00
flip1995
562cc63b7e
Fix lint_without_lint_pass lint 2019-10-24 13:54:18 +02:00
flip1995
237e168b89
Fix tests 2019-10-24 13:29:51 +02:00
flip1995
ef02e3a755
Run ./util/dev fmt 2019-10-24 11:55:22 +02:00
flip1995
5f4b5b91d7
Rustup to rust-lang/rust#65657 2019-10-24 11:54:11 +02:00
Mark Rousskov
7e77f3c29f
Update clippy for latest rustc changes
Specifically, this revises the clippy integration to utilize a new
callback to register its lints, as the prior editing of lint store in
Session is no longer possible.
2019-10-24 11:40:45 +02:00
Philipp Hansch
52f52900a4
Don't emit try_err lint in external macros 2019-10-24 07:52:01 +02:00
bors
850dfdae60 Auto merge of #4680 - hellow554:debug_assert_mut_call, r=flip1995
Add lint for debug_assert_with_mut_call

closes #1526

**What does not work:**

* detecting a mut call in the format string itself, e.g. `debug_assert!(false, "{}", vec![1].pop())`
* detecting `*mut T` usage (pointer)

---

changelog: add new lint `debug_assert_with_mut_call`
2019-10-23 20:58:14 +00:00
bors
087e5eaea5 Auto merge of #4691 - HMPerson1:suggest_iter, r=phansch
Fix suggestion of `explicit_counter_loop`

changelog: In the suggestion of `explicit_counter_loop`, if the `for` loop argument doesn't implement `Iterator`, then we suggest `x.into_iter().enumerate()` (or `x.iter{_mut}()` as appropriate). Also, the span of the suggestion has been corrected.

Fixes #4678
2019-10-23 20:12:14 +00:00
Matthias Krüger
b5f73dad90 deps: update cargo_metadata from 0.8.0 to 0.9.0 2019-10-23 17:30:24 +02:00
flip1995
e8d5a9e95c
Use StableHasher in SpanlessHasher 2019-10-22 14:57:44 +02:00
flip1995
ef18ece564
Don't hash spans in SpanlessHasher 2019-10-22 11:17:16 +02:00
Marcel Hellwig
5572476a36 Add lint for debug_assert_with_mut_call
This lint will complain when you put a mutable function/method call
inside a `debug_assert` macro, because it will not be executed in
release mode, therefore it will change the execution flow, which is not
wanted.
2019-10-22 10:39:55 +02:00
Lzu Tao
4c7387e965 rustup https://github.com/rust-lang/rust/pull/65535 2019-10-19 12:27:21 +07:00
HMPerson1
a9cb2b9001
Fix suggestion for ranges 2019-10-18 12:11:15 -04:00
Andre Bogus
d723b35aee Omit proc macros from must_use_candidate 2019-10-18 15:54:25 +02:00
Heinz N. Gies
7f454d8d06 Split out tests 2019-10-18 07:40:48 +02:00
Heinz N. Gies
a7ad78f3eb Add expect
Co-Authored-By: Philipp Krones <hello@philkrones.com>
2019-10-18 07:37:58 +02:00
Heinz N. Gies
98dc3aabea Add todo and tests 2019-10-18 07:37:58 +02:00
Heinz Gies
8d911fe988 add restirction for unreachable and panic 2019-10-18 07:35:25 +02:00
HMPerson1
4578e5e15e
Fix suggestion span in explicit_counter_loop 2019-10-18 01:15:54 -04:00
HMPerson1
72f3439346
Suggest calling iter if needed in explicit_counter_loop 2019-10-18 00:03:27 -04:00
bors
14a0f36617 Auto merge of #4683 - HMPerson1:inefficient_to_string, r=Manishearth
Add `inefficient_to_string` lint

Closes #4586

changelog: Add `inefficient_to_string` lint, which checks for calling `to_string` on `&&str`, which would bypass the `str`'s specialization
2019-10-17 23:48:55 +00:00
Michael Zhang
2106a23966
Update help text in inefficient_to_string
Co-Authored-By: Manish Goregaokar <manishsmail@gmail.com>
2019-10-17 19:13:32 -04:00
Manish Goregaokar
fcad3cb9ea syntax::ext -> syntax_expand 2019-10-17 15:57:48 -07:00
HMPerson1
106a72592c
Dogfood for inefficient_to_string 2019-10-16 17:12:41 -04:00
HMPerson1
76b44f34b9
Add inefficient_to_string lint 2019-10-16 15:54:20 -04:00
Manish Goregaokar
608d09c26c Rustup to rustc 1.40.0-nightly (237d54ff6 2019-10-15) 2019-10-15 12:29:28 -07:00
flip1995
c9dc2b5f6e
Fix ICE in use_self lint 2019-10-15 15:11:29 +02:00
James Wang
adf58868e9
Change terminology from static to associated 2019-10-15 09:58:12 +02:00
James Wang
8b50599cb4
Switch to OnlyBodies 2019-10-15 09:58:12 +02:00
James Wang
e23a424b31
Change lint to be pedantic 2019-10-15 09:58:11 +02:00
James Wang
e64b27525b
Remove prints 2019-10-15 09:58:11 +02:00
James Wang
664522badd
Add a new lint for unused self 2019-10-15 09:58:11 +02:00
Andre Bogus
cc622608db new lints around #[must_use] fns
`must_use_unit` lints unit-returning functions with a `#[must_use]`
attribute, suggesting to remove it.

`double_must_use` lints functions with a plain `#[must_use]`
attribute, but which return a type which is already `#[must_use]`,
so the attribute has no benefit.

`must_use_candidate` is a pedantic lint that lints functions and
methods that return some non-unit type that is not already
`#[must_use]` and suggests to add the annotation.
2019-10-14 12:09:04 +02:00
Matthias Seiffert
15b433af48 Use match_function_call wherever possible 2019-10-10 20:06:04 +02:00
Matthias Seiffert
37a2de1562 Move match_function_call to utils 2019-10-10 10:57:12 +02:00
bors
db233b0920 Auto merge of #4616 - mati865:license, r=Manishearth
Fix license in Cargo.toml files

Missed in https://github.com/rust-lang/rust-clippy/pull/3269

changelog: none

r? @Manishearth
2019-10-09 16:09:26 +00:00
Nikos Filippakis
5143fe1a78 New lint: suspicious_unary_op_formatting
Lints when, on the RHS of a BinOp, there is a UnOp without a space
before the operator but with a space after (e.g. foo >- 1).

Signed-off-by: Nikos Filippakis <nikolaos.filippakis@cern.ch>
2019-10-09 16:22:00 +02:00
bors
d97fbdbb42 Auto merge of #4635 - Lythenas:suggestions-for-assert-false, r=flip1995
Add assert message to suggestion in lint assertions_on_constants

<!--
Thank you for making Clippy better!

We're collecting our changelog from pull request descriptions.
If your PR only updates to the latest nightly, you can leave the
`changelog` entry as `none`. Otherwise, please write a short comment
explaining your change.

If your PR fixes an issue, you can add "fixes #issue_number" into this
PR description. This way the issue will be automatically closed when
your PR is merged.

If you added a new lint, here's a checklist for things that will be
checked during review or continuous integration.

- [x] Followed [lint naming conventions][lint_naming]
- [x] Added passing UI tests (including committed `.stderr` file)
- [ ] `cargo test` passes locally
- [x] Executed `./util/dev update_lints`
- [ ] Added lint documentation
- [ ] Run `./util/dev fmt`

[lint_naming]: https://rust-lang.github.io/rfcs/0344-conventions-galore.html#lints

Note that you can skip the above if you are just opening a WIP PR in
order to get feedback.

Delete this line and everything above before opening your PR -->

- [x] suggest replacing `assert!(false, "msg")` with `panic!("msg")`
- [x] extend to allow ~~variables~~ any expression for `"msg"`
- ~~suggest replacing `assert!(false, "msg {}", "arg")` with `panic!("msg {}", "arg")`~~

changelog: add assert message to suggestion in lint assertions_on_constants

Work towards fixing: #3575
2019-10-09 08:56:30 +00:00
Ethan Lam
327c91f8c7 Addresses Issue #4001
Fixed typo

Fixes lint name and uses appropriate linting suggestion

changed lint help message

Added autofixable test

Added Autofixable Test

Removed Broken Autofixable File

updated lints

Generated Autofixable/Nonfixable Test Cases

Changed Suggestion Applicability

Updated Lint Count
2019-10-08 08:46:29 -05:00
bors
30a3992e97 Auto merge of #4627 - kerhong:fix-typo-in-inherent-to-string, r=phansch
Fix typo in inherent_to_string documentation

A simple typo fix in `inherent_to_string` and `inherent_to_string_shadow_display` documentation

changelog: none
2019-10-08 07:52:44 +00:00
bors
b690cdb1e7 Auto merge of #4611 - rust-lang:doc-visibility, r=flip1995
account for doc visibility

This fixes #4608.

Also I noticed that the lint failed to look at trait and impl items. There's a small bit of fallout in the code, too, but not enough to warrant its own commit.

changelog: check docs of trait items and impl items, also make `missing_safety_doc` account for visibility
2019-10-08 07:11:26 +00:00
bors
e2393b09ac Auto merge of #4592 - rust-lang:transmute-collection, r=flip1995
New lint: `unsound_collection_transmute`

changelog: Add `unsound_collection_transmute` lint

This fixes #4515
2019-10-08 05:51:07 +00:00
Matthias Seiffert
6ee8d751f6 Reduce duplication 2019-10-07 22:08:00 +02:00
Matthias Seiffert
22f057972f Match any expr for panic message 2019-10-07 20:40:05 +02:00
Matthias Seiffert
d66acc23a9 Make if_chain more readable 2019-10-07 19:13:10 +02:00
Matthias Seiffert
72a5d7b612 Add message to replace assert!(false) help 2019-10-07 19:13:10 +02:00
flip1995
3d39379f9c
Move is_argument check into mutate 2019-10-06 14:49:26 +02:00
flip1995
3aa531c194
Run util/dev fmt 2019-10-05 12:42:09 +02:00
flip1995
3b23092b69
Get rid of rvalue_promotable_map method call 2019-10-05 12:38:38 +02:00
flip1995
b7d473503b
Merge consume and consume_pat in escape analysis
FIXME: This doesn't work and probably needs a rewrite of the lint

See https://github.com/rust-lang/rust-clippy/pull/4628#issuecomment-538574944
2019-10-05 12:23:59 +02:00
Mateusz Mikuła
4f1d907462 Use new format of licenses
Co-Authored-By: lzutao <taolzu@gmail.com>
2019-10-04 17:40:32 +02:00
flip1995
c420b07191
Fix needless_pass_by_value
This also accidentally improved the spans of the suggestions
2019-10-04 15:39:46 +02:00
flip1995
b46f5b4a98
Rustup to rust-lang/rust#64874
Episode 1 - The simple cases
2019-10-04 15:39:46 +02:00
bors
54bf4ffd62 Auto merge of #4613 - Lythenas:lint-assert_eq-unit_exprs, r=flip1995
Add check for assert_eq macros to unit_cmp lint

changelog: Add check for unit comparisons through `assert_eq!`, `debug_assert_eq!`, `assert_ne!` and `debug_assert_ne!` macros to unit_cmp lint.

fixes #4481
2019-10-04 10:27:44 +00:00
Edgars Baduns
a1137a8439 Fix typo in inherent_to_string documentation 2019-10-04 10:58:53 +01:00
bors
249b6cac3e Auto merge of #4625 - phansch:rollup-qp7ki0h, r=phansch
Rollup of 2 pull requests

Successful merges:

 - #4509 (Fix false-positive of redundant_clone and move to clippy::perf)
 - #4614 (Allow casts from the result of `abs` to unsigned)

Failed merges:

changelog: none

r? @ghost
2019-10-04 06:45:04 +00:00
Phil Hansch
19c58d260b
Rollup merge of #4614 - HMPerson1:abs_cast_unsigned, r=flip1995
Allow casts from the result of `abs` to unsigned

changelog: Allow casts from the result of `abs` to unsigned in `cast_sign_loss`

Fixes #4605
2019-10-04 08:08:59 +02:00
Matthias Seiffert
e333ed0d53 Correctly align doc of mistyped literal suffixes 2019-10-03 22:14:32 +02:00
Mateusz Mikuła
d743a8992a Fix license in Cargo.toml files 2019-10-03 19:55:05 +02:00
Matthias Seiffert
5a0a2b383c Remove assert_ne example from doc 2019-10-03 19:53:41 +02:00
Matthias Seiffert
fb25d56799 Mention asserts in doc for unit_cmp lint 2019-10-03 14:35:05 +02:00
Matthias Seiffert
288f02da44
Print assert macro name in backticks
Co-Authored-By: Philipp Krones <hello@philkrones.com>
2019-10-03 11:43:39 +02:00
Shotaro Yamada
4cded6d901 extern rustc_index 2019-10-03 08:27:47 +09:00
Shotaro Yamada
866729f5db Add comments 2019-10-03 08:10:29 +09:00
Shotaro Yamada
1cee3fe00e Resolve reviews 2019-10-03 08:10:29 +09:00
Shotaro Yamada
a3f403aa50 Apply suggestion
Co-Authored-By: ecstatic-morse <ecstaticmorse@gmail.com>
2019-10-03 08:10:29 +09:00
Shotaro Yamada
667223c35d Add run-rustfix 2019-10-03 08:10:29 +09:00
Shotaro Yamada
301ef6bb2a Fix false-positive of redundant_clone and move to clippy::perf 2019-10-03 08:10:29 +09:00
HMPerson1
0e1dd65c14
Allow casts from the result of abs to unsigned 2019-10-02 17:23:54 -04:00
Matthias Seiffert
3557084b01 Add check for assert_eq macros to unit_cmp lint 2019-10-02 22:48:19 +02:00
Andre Bogus
27fa2b7944 New lint: unsound_collection_transmute 2019-10-02 21:18:00 +02:00
Andre Bogus
e3f143ff0a account for doc visibility 2019-10-02 21:15:28 +02:00
bors
737f0a6bb5 Auto merge of #4599 - lzutao:zero-ptr-suggestion, r=flip1995
Add suggestion for zero-ptr lint

changelog: Improve suggestion of `zero_ptr` lint
2019-10-02 17:16:29 +00:00
Lzu Tao
6b1a8683f4 Add suggestion for zero-ptr lint 2019-10-02 22:38:00 +07:00
Andre Bogus
23a9c02120 New lint: needless_doc_main 2019-10-02 17:17:22 +02:00
flip1995
93bda4876a
Fix ICE #4579 2019-10-02 09:39:04 +02:00
Manish Goregaokar
9e166e09b8 Use new spans for expansion checking in loop lints 2019-10-01 10:17:29 -07:00
Lzu Tao
aa4f3fb537 Clean up some unused vars 2019-09-29 23:46:32 +07:00
Lzu Tao
6e3a0ea6b3 Rustup rust-lang/rust#63492 2019-09-29 22:58:17 +07:00
bors
fe920ebf8b Auto merge of #4593 - james9909:fix-multiple-inherent-impls, r=llogiq
Fix false positive in `multiple_inherent_impl`

changelog: Fix false positive in `multiple_inherent_impl` by ignoring impls derived from macros.

Closes #4578.
2019-09-29 06:21:55 +00:00
Matthias Krüger
5f6e3f35b5 rustup https://github.com/rust-lang/rust/pull/64781/
cc https://github.com/rust-lang/rust/issues/64867
2019-09-28 10:42:41 +02:00
James Wang
189eaa54c6
Ignore impls derived from macros 2019-09-27 20:47:00 -05:00
flip1995
8d8ba14371
Fix author lint 2019-09-27 18:01:04 +02:00
flip1995
4bbd10a585
Rustup to rust-lang/rust#64813 2019-09-27 17:21:20 +02:00
Michael Wright
8b9415cd88 Refactor booleans
Remove unused output from `suggest(..)`
2019-09-27 07:59:34 +02:00
Michael Sproul
4f9d6eea5c
Detect assignment ops in integer_arithmetic 2019-09-27 11:55:42 +10:00
Matthias Krüger
e59d619981 rustup https://github.com/rust-lang/rust/pull/64515
changelog: none
2019-09-26 18:34:43 +02:00
Lzu Tao
54371929d2 Remove unused import 2019-09-26 16:08:30 +07:00
Lzu Tao
a7b7e19f49 Rustup https://github.com/rust-lang/rust/pull/64513 2019-09-26 16:03:36 +07:00
bors
adc1df11b4 Auto merge of #4568 - mikerite:fix-4548, r=flip1995
Fix `nonminimal-bool` false positive

Closes #4548
Closes #3847

changelog: Fix `nonminimal-bool` false positive
2019-09-26 08:06:16 +00:00
bors
4d30b08027 Auto merge of #4569 - james9909:add-comparison-chain, r=oli-obk
Add a new lint for comparison chains

changelog: Adds a new lint: `comparison_chain`.

`comparison_chain` lints all `if` conditional chains where all the conditions are binary comparisons on the same two operands and will suggest a rewrite with `match`.

Closes #4531.
2019-09-26 07:38:08 +00:00
Lzu Tao
08ce6bc6d9 Fix macro expansion in toplevel_ref_arg lint 2019-09-26 08:46:51 +07:00
Manish Goregaokar
49374a4380 Downgrade op_ref to a MaybeIncorrect suggestion 2019-09-25 14:53:48 -07:00
Manish Goregaokar
d28dacb33a redundant_pattern_matching: make rustfixable 2019-09-25 14:45:18 -07:00
Manish Goregaokar
a83a8dccba redundant_closure_call: split tests into fixable 2019-09-25 14:45:18 -07:00
Manish Goregaokar
ad0e7c8e7f map_unit_fn: fix applicability 2019-09-25 14:45:18 -07:00
Manish Goregaokar
1090509564 non_copy_const: remove incorrect suggestion 2019-09-25 14:45:18 -07:00
Manish Goregaokar
980650eec2 needless_collect: fix suggestion, make test rustfixable 2019-09-25 14:45:18 -07:00