Commit graph

4451 commits

Author SHA1 Message Date
Tomasz Miąsko
9b800b1e92 Rename SpanlessEq::ignore_fn to deny_side_effects
No functional changes intended.
2020-08-16 23:30:33 +02:00
Tomasz Miąsko
6afa4ef60f Introduce function for comparing expression values
Introduce `eq_expr_value(cx, a, b)` as a shortcut for
`SpanlessEq::new(cx).ignore_fn().eq_expr(cx, a, b)`.

No functional changes intended.
2020-08-16 23:30:33 +02:00
bors
8d0d89adc8 Auto merge of #5720 - bugadani:new-lint, r=flip1995,yaahc
Add unnecessary lazy evaluation lint

changelog: Add [`unnecessary_lazy_evaluations`] lint that checks for usages of `unwrap_or_else` and similar functions that can be simplified.

Closes #5715
2020-08-16 20:27:43 +00:00
Dániel Buga
fc1e07e0c1 Rename lint to use plural form 2020-08-16 22:16:39 +02:00
Dániel Buga
b7ee8685ac Fix dogfooding test errors 2020-08-16 21:04:02 +02:00
Dániel Buga
3b52d7f780 run cargo dev fmt 2020-08-16 20:51:16 +02:00
Dániel Buga
8a14c11536 Cleanup, explain return value 2020-08-16 20:50:30 +02:00
Dániel Buga
d71b418ac5 Moved to submodule, don't trigger if map_unwrap_or does 2020-08-16 20:47:50 +02:00
Hactar
d8f0a14da1
Fix typo in description of unnecessary_mut_passed 2020-08-16 14:43:34 -04:00
Dániel Buga
9c41822d34 Apply suggested change
Co-authored-by: Philipp Krones <hello@philkrones.com>
2020-08-16 20:27:54 +02:00
Dániel Buga
94cf90e5a5 Apply suggested change
Co-authored-by: Philipp Krones <hello@philkrones.com>
2020-08-16 20:27:54 +02:00
Dániel Buga
a7083eea1c Removed the extra lifetime parameter 2020-08-16 20:27:54 +02:00
Dániel Buga
75637c1eda Catch function calls in argument lists, add tests that tuples don't get linted 2020-08-16 20:27:54 +02:00
Dániel Buga
d7220dbd91 Run cargo dev update_lints 2020-08-16 20:27:54 +02:00
Dániel Buga
a7cc5d4068 Also simplify if the closure body is an index expression 2020-08-16 20:27:54 +02:00
Dániel Buga
848af39310 Add note to or_fun_call, list checked methods 2020-08-16 20:27:54 +02:00
Dániel Buga
a3ea65c2d9 Implement new lint 2020-08-16 20:27:22 +02:00
bors
3bd98895f1 Auto merge of #5725 - montrivo:should-impl-trait, r=flip1995
should_impl_trait - ignore methods with lifetime params

Fixes: #5617

changelog: don't lint should_implement_trait when an `Iterator::next` case has explicit parameters
2020-08-16 17:51:18 +00:00
bors
78857cc9d3 Auto merge of #5907 - wiomoc:feature/useless-vec-max-size, r=flip1995
appreciative too_large_for_stack in useless `vec!`

Fixes: #5847
changelog: Add `too_large_for_stack ` configuration option for `USELESS_VEC`
2020-08-16 17:30:12 +00:00
bors
dff7e74b27 Auto merge of #5903 - jrqc:needless_return, r=ebroto,flip1995
Needless return

Fixes #5858
changelog: fix false positive [`needless_return`]
2020-08-16 17:08:45 +00:00
bors
c8e05fc1c6 Auto merge of #5881 - wiomoc:feature/single-char-push_str, r=ebroto,flip1995
Lint `push_str` with a single-character string literal

Fixes #5875
changelog:  `* [single_char_push_str]`
2020-08-16 16:41:57 +00:00
bors
e522ca3c8d Auto merge of #5831 - chansuke:to_string_in_display, r=flip1995
Don't use `to_string` in impl Display

fixes #3876

this PR is derived from [Toxyxer's implementation](https://github.com/rust-lang/rust-clippy/pull/5574).
changelog: add [`to_string_in_display`] lint
2020-08-16 16:21:37 +00:00
Eduardo Broto
1a140dcc1c Improve needless_doctest_main by using the parser 2020-08-16 00:25:54 +02:00
jrqc
baa4cb1cdd early return removed 2020-08-16 00:24:27 +03:00
jrqc
96efaee552 cargo dev update_lints 2020-08-16 00:24:27 +03:00
jrqc
a7d5c2f967 Modifications according to the code review 2020-08-16 00:24:27 +03:00
jrqc
cd6ca72e0e Known problems changed 2020-08-16 00:24:27 +03:00
jrqc
65d10c7abf Borrow checker added 2020-08-16 00:24:27 +03:00
jrqc
85f4ef0fbd Visitor added 2020-08-16 00:24:27 +03:00
jrqc
6d18fe730e Make needless_return a late lint pass 2020-08-16 00:24:27 +03:00
bors
f0cc006964 Auto merge of #5910 - flip1995:rustup, r=flip1995
Rustup

r? @ghost

changelog: none
2020-08-15 12:05:11 +00:00
Christoph Walcher
b381ade179
elide lifetimes 2020-08-15 01:40:55 +02:00
Christoph Walcher
ae56e988a2
Merge lint with single_char_pattern 2020-08-15 01:40:55 +02:00
Christoph Walcher
72d2c2eab4
Lint push_str with a single-character string literal
Fixes #5875
2020-08-15 01:40:55 +02:00
Takayuki Nakata
f98ffa271d Fix FP for same_item_push
Don't emit a lint when `pushed_item` was declared as mutable variable.
2020-08-14 22:54:12 +09:00
chansuke
8e549978e5 Don't use to_string in impl Display 2020-08-14 21:38:11 +09:00
Christoph Walcher
8514b8407a
appreciative too_large_for_stack in useless vec!
Fixes: #5847
2020-08-14 14:29:16 +02:00
Erich Gubler
48a142559d
docs: typo in temporary_cstring_as_ptr: s/point/&s 2020-08-13 13:52:21 -06:00
Bastian Kauschke
429a1cedfa merge as_local_hir_id with local_def_id_to_hir_id 2020-08-13 16:55:16 +02:00
bors
d5f5487252 Auto merge of #5899 - JarredAllen:rc-box-suggestion, r=yaahc
Change Rc<Box<T>> recommendation to be Rc<T> instead of Box<T>

Fixes #5722

changelog: Suggest `Rc<Box<T>>` -> `Rc<T>` in [`redundant_allocation`] lint
2020-08-13 13:31:55 +00:00
bors
fc4fd91914 Auto merge of #5900 - ThibsG:ParensUselessConversion4750, r=phansch
Fix: keep parenthesis for suggestion in `useless_conversion` lint

Note: this lint was previously named `identity_conversion`.

fixes: #4750

changelog: fix parenthesis for `useless_conversion` lint suggestion
2020-08-13 05:27:29 +00:00
JarredAllen
4e28d99f41 Replace panics with early returns 2020-08-12 13:24:55 -07:00
ThibsG
5634c8da02 Fix: keep parenthesis for suggestion in useless_conversion lint 2020-08-12 21:44:02 +02:00
bors
dc1e09bdc1 Auto merge of #5897 - matthiaskrgr:no_clone_tts, r=flip1995
write.rs: don't clone TokenStream

changelog: none
2020-08-12 17:36:23 +00:00
JarredAllen
480ccc3dbe Change Rc<Box<T>> recommendation to be Rc<T> instead of Box<T> 2020-08-12 10:35:08 -07:00
bors
439bae62a4 Auto merge of #5884 - Ryan1729:patch-1, r=flip1995
Add the other overloadable operations to suspicious_arithmetic_impl

In #2268 I idly mused that the other user-overloadable operations could be added to this lint. Knowing that the lint was arguably incomplete was gnawing at the back of my mind, so I figured that I might as well make this PR, particularly given the change needed was so small.

changelog: Start warning on suspicious implementations of the `BitAnd`, `BitOr`, `BitXor`, `Rem`, `Shl`, and `Shr` traits.
2020-08-12 17:00:48 +00:00
bors
c73cf9f387 Auto merge of #5893 - matthiaskrgr:lint_msg, r=yaahc
fix remaining lint messages

r? @yaahc

changelog:  make remaining lint messages adhere to rustc dev guide lint message convention.
2020-08-12 16:33:57 +00:00
Ryan Wiedemann
c70581732d trailing comma
Should have actually ran rustfmt on it, rather than attempting to fix it manually
2020-08-12 10:33:16 -06:00
Ryan Wiedemann
616682deb7 formatting 2020-08-12 10:33:16 -06:00
Ryan Wiedemann
0fc61becb5 Add the other overloadable operations to suspicious_arithmetic_impl
In #2268 I idly mused that the other user-overloadable operations could be added to this lint. Knowing that the lint was arguably incomplete was gnawing at the back of my mind, so I figured that I might as well make this PR, particularly given the change needed was so small.
2020-08-12 10:33:16 -06:00
bors
2f4de2fc75 Auto merge of #5885 - Ryan1729:patch-2, r=flip1995
Add example of false positive to PTR_ARG docs.

Addresses #214

changelog: Add example of false positive to `ptr_arg` docs.
2020-08-12 15:51:39 +00:00
flip1995
318c74af2b
Merge remote-tracking branch 'upstream/master' into rustup 2020-08-12 17:03:54 +02:00
Ryan Wiedemann
7d2e42daec
fix typo pointed out in review comment
Co-authored-by: Philipp Krones <hello@philkrones.com>
2020-08-12 08:54:32 -06:00
Matthias Krüger
8a96b9cdfe write.rs: don't clone TokenStream 2020-08-12 14:35:31 +02:00
bors
fdc2f879f1 Auto merge of #75405 - flip1995:clippyup, r=Manishearth
Update Clippy

Biweekly Clippy update (2 days late, since I wanted to wait for https://github.com/rust-lang/rust/pull/75098)

r? @Manishearth
2020-08-12 00:34:19 +00:00
flip1995
027780ca2c Merge commit '09bd400243ed6f7059fedc0c1623aae3792521d6' into clippyup 2020-08-11 17:50:45 +02:00
Matthias Krüger
be3e695b60 if_not_else: make lint adhere to lint message convention 2020-08-11 16:43:53 +02:00
Matthias Krüger
605e027fda if_let_some_result: make lint adhere to lint message convention 2020-08-11 16:40:45 +02:00
Matthias Krüger
89591a78b8 enum-variant-names: make lint adhere to lint message convention 2020-08-11 16:38:20 +02:00
Matthias Krüger
db390f5e6a enum-clike-unportable-variant: tweak message a bit (Clike -> C-like) 2020-08-11 16:35:09 +02:00
Matthias Krüger
2de290d5c5 duration-subsec: make lint adhere to lint message convention 2020-08-11 16:31:02 +02:00
Matthias Krüger
423615693b pub-enum-variant-names: make lint adhere to lint message convention 2020-08-11 16:28:05 +02:00
Matthias Krüger
1f17c3b02b multiple_inherent_impl: make lint adhere to lint message convention 2020-08-11 15:28:51 +02:00
Matthias Krüger
bdf4dc3abd implicit-saturating-sub: make lint adhere to lint message convention 2020-08-11 15:22:59 +02:00
Matthias Krüger
f171f89aed int_plus_one: make lint adhere to lint message convention 2020-08-11 15:15:26 +02:00
Matthias Krüger
6af297f80e iter-next-slice: make lint adhere to lint message convention 2020-08-11 15:15:26 +02:00
Matthias Krüger
04867e004e mutex-atomic: make lint adhere to lint message convention 2020-08-11 15:15:26 +02:00
Matthias Krüger
ac194cafc1 map_clone: make lint adhere to lint message convention 2020-08-11 15:15:26 +02:00
Matthias Krüger
c0a9d64818 stable-sort-primitive: make lint adhere to lint message convention 2020-08-11 15:15:26 +02:00
bors
3337f7956c Auto merge of #5892 - matthiaskrgr:redundant_mut, r=flip1995
unnecessary-mut-passed: make lint message say if fn is a function or a method

changelog: refine "unnecessary-mut-passed" lint message
2020-08-11 12:52:41 +00:00
bors
09bd400243 Auto merge of #5891 - flip1995:rustup, r=flip1995
Rustup

r? @ghost

Sync back rust-lang/rust#75098

changelog: none
2020-08-11 12:32:10 +00:00
flip1995
9311c11d7c
Fix sync fallout 2020-08-11 14:21:27 +02:00
Matthias Krüger
b8713e3854 unnecessary-mut-passed: make lint message say if fn is a function or a method. 2020-08-11 14:16:56 +02:00
Yuki Okushi
91aa55d891 Rollup merge of #75226 - pnadon:miri-undef-uninit, r=RalfJung
Miri: Renamed "undef" to "uninit"

Renamed remaining references to "undef" to "uninit" when referring to Miri.

Impacted directories are:

- `src/librustc_codegen_llvm/consts.rs`
- `src/librustc_middle/mir/interpret/`
- `src/librustc_middle/ty/print/pretty.rs`
- `src/librustc_mir/`
- `src/tools/clippy/clippy_lints/src/consts.rs`

Upon building Miri based on the new changes it was verified that no changes needed to be made with the Miri project.

Related issue #71193
2020-08-11 16:23:47 +09:00
Dylan DPC
9e73d33680 Rollup merge of #75098 - Ryan1729:clippy-pointer-cast-lint-experiment, r=oli-obk
Clippy pointer cast lint experiment

This PR is an experiment about exposing more parts of `rustc_typeck` for use in `clippy`. In particular, the code that checks where a cast is valid or not was exposed, which necessitated exposing [`FnCtxt`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_typeck/check/struct.FnCtxt.html), and figuring out how to create an instance of that type inside `clippy`.

This was prompted by [this clippy issue](https://github.com/rust-lang/rust-clippy/issues/2064).

r? @oli-obk
2020-08-11 01:56:30 +02:00
bors
cc5bfd473c Auto merge of #5888 - matthiaskrgr:lints, r=yaahc
make a bunch of lints texts adhere to rustc dev guide

According to the rustc-dev guide: "The text should be matter of fact and avoid capitalization and periods, unless multiple sentences are needed"

changelog: make some lint output adhere to the rustc-dev guide
2020-08-10 22:40:42 +00:00
Matthias Krüger
1b46e485b2 Update clippy_lints/src/unwrap.rs
Co-authored-by: Jane Lusby <jlusby42@gmail.com>
2020-08-10 23:57:08 +02:00
Matthias Krüger
c514ff0c93 Update clippy_lints/src/neg_cmp_op_on_partial_ord.rs
Co-authored-by: Jane Lusby <jlusby42@gmail.com>
2020-08-10 23:57:08 +02:00
Matthias Krüger
dabf989195 neg-cmp-op-on-partial-ord: make lint adhere to lint message convention 2020-08-10 23:49:06 +02:00
Matthias Krüger
178da9b2ef neg-multiply: make lint adhere to lint message convention 2020-08-10 23:49:06 +02:00
Matthias Krüger
e519bb3c85 overflow-check-conditional: make lint adhere to lint message convention 2020-08-10 23:49:06 +02:00
Matthias Krüger
9178363574 path-buf-push-overwrite: make lint adhere to lint message convention 2020-08-10 23:49:06 +02:00
Matthias Krüger
81f77a411e range-zip-with-len: make lint adhere to lint message convention 2020-08-10 23:49:06 +02:00
Matthias Krüger
3e1e0c9bdb redundant-static-lifetimes: make lint adhere to lint message convention 2020-08-10 23:49:06 +02:00
Matthias Krüger
5d69ca5e11 also change "deprecated-attribute" message 2020-08-10 23:49:06 +02:00
Matthias Krüger
fe37ddbd11 suspicious-arithmetic-impl: make lint adhere to lint message convention 2020-08-10 23:49:06 +02:00
Matthias Krüger
7954c22a99 unknown: make lint adhere to lint message convention 2020-08-10 23:49:06 +02:00
Matthias Krüger
b36a6c9594 ref_in_deref: make lint adhere to lint message convention 2020-08-10 23:49:06 +02:00
Matthias Krüger
4418ff122f unneeded-field-pattern: make lint adhere to lint message convention 2020-08-10 23:49:06 +02:00
Matthias Krüger
2792260636 empty-liner-after-outer-attr: make lint adhere to lint message convention 2020-08-10 23:49:06 +02:00
Matthias Krüger
0db5cb1393 drop_bounds: make lint adhere to lint message convention 2020-08-10 23:49:06 +02:00
Matthias Krüger
590b91d8d4 double-parens: make lint adhere to lint message convention and do minor refactoring 2020-08-10 23:49:06 +02:00
Matthias Krüger
ba7a01a6a8 double-comparisons: make lint adhere to lint message convention 2020-08-10 23:49:06 +02:00
Matthias Krüger
6b0a6a70f8 default-trait-access: make lint adhere to lint message convention 2020-08-10 23:49:06 +02:00
Matthias Krüger
3d592b5154 cmp_null: make lint adhere to lint message convention 2020-08-10 23:49:06 +02:00
Matthias Krüger
8679dd375b unnecessary_unwrap, panicking_unwrap: make lints adhere to lint message convention 2020-08-10 23:49:06 +02:00
Matthias Krüger
9b7ab1d38b checked-conversions: make lint adhere to lint message convention 2020-08-10 23:48:57 +02:00
Eduardo Broto
5d66bd7bb3 Avoid or_fun_call for const_fn with no args 2020-08-10 23:38:58 +02:00
Matthias Krüger
40416c0fa8 naive_bytecount: make lint adhere to lint message convention 2020-08-10 20:55:23 +02:00
Matthias Krüger
fd379a889e builtin-type-shadow: make lint adhere to lint message convention 2020-08-10 20:55:23 +02:00