Takayuki Nakata
9fe0ac36a5
Avoid period in lint message according to convention
2020-08-24 10:11:53 +09:00
Takayuki Nakata
b2c2266792
Fix FP for redundant_closure_call
...
Visit the nested things like function body when checking closure call.
2020-08-24 09:43:16 +09:00
rail
91b200c62b
Fix fp in borrow_interior_mutable_const
...
Fix false positive when referencing a field behind a pointer.
2020-08-23 22:49:08 +12:00
Eduardo Broto
8776db9f6d
Fix ICE in repeat_once
lint
2020-08-23 12:05:34 +02:00
Michael Wright
e8d33d73dc
Fix let_and_return
bad suggestion
...
Add a cast to the suggestion when the return expression has adjustments.
These adjustments are lost when the suggestion is applied.
This is similar to the problem in issue #4437 .
Closes #5729
2020-08-23 07:50:59 +02:00
bors
dd07860b83
Auto merge of #5941 - ThibsG:InlineInCopyPassByRef, r=yaahc
...
Don't lint if it has always inline attribute
Don't trigger the lint `trivially_copy_pass_by_ref` if it has `#[inline(always)]` attribute.
Note: I am not particularly familiar with `inline` impacts, so I implemented this the way that if only `#[inline]` attribute is here (without `always`), the lint will still trigger. Also, it will still trigger if it has `#[inline(never)]`.
Just tell me if it sounds too much conservative.
Fixes : #5876
changelog: none
2020-08-22 18:30:39 +00:00
Christian Stefanescu
53508aeb65
Run sh tests/ui/update-all-references.sh
2020-08-22 14:22:02 +02:00
Christian Stefanescu
5b07b9ed61
Widen understanding of prelude import
...
Prelude imports are exempt from wildcard import warnings. Until now only
imports of the form
```
use ...::prelude::*;
```
were considered. This change makes it so that the segment `prelude` can
show up anywhere, for instance:
```
use ...::prelude::v1::*;
```
Fixes #5917
2020-08-22 14:22:02 +02:00
ThibsG
191b6c798f
Don't lint if it has always inline attribute
2020-08-22 12:58:35 +02:00
ThibsG
03bc7aed44
Add async test case for wrong_self_convention
lint
2020-08-22 08:14:42 +02:00
bors
b57ef14290
Auto merge of #5926 - giraffate:improve_lint_message_in_to_string_in_display, r=yaahc
...
Improve lint message in `to_string_in_display`
This is a follow-up of https://github.com/rust-lang/rust-clippy/pull/5831 .
changelog: none
2020-08-22 04:51:38 +00:00
Michael Wright
11efd75aeb
Fix false negative in option_as_ref_deref
2020-08-21 07:23:04 +02:00
bors
4104611913
Auto merge of #5928 - mikerite:fix-5924, r=ebroto
...
Fix false positive in `PRECEDENCE` lint
Extend the lint to handle chains of methods combined with unary negation.
Closes #5924
changelog: Fix false negative in `PRECEDENCE` lint
2020-08-20 22:09:27 +00:00
Michael Wright
c236c0fb56
Fix false positive in PRECEDENCE
lint
...
Extend the lint to handle chains of methods combined with unary negation.
Closes #5924
2020-08-20 06:34:48 +02:00
Takayuki Nakata
902b28275e
Improve lint message in to_string_in_display
2020-08-19 22:31:34 +09:00
Eduardo Broto
6a12bae194
no from/to bits in const: add tests cases for f64
2020-08-18 22:19:30 +02:00
Eduardo Broto
df4d42fc2d
transmute: avoid suggesting from/to bits in const
2020-08-18 21:55:56 +02:00
flip1995
c680602005
Merge remote-tracking branch 'upstream/master' into rustup
2020-08-18 19:50:23 +02:00
bors
9360ca6dc2
Auto merge of #5908 - giraffate:fix_fp_for_same_item_push, r=flip1995
...
Fix FP for `same_item_push`
Fixes https://github.com/rust-lang/rust-clippy/issues/5902
changelog: Fix FP for `same_item_push` where the pushed variable is mutated.
2020-08-17 16:49:03 +00:00
David Wood
f13d2bfd9b
clippy: support QPath::LangItem
...
This commit updates clippy with the introduction of `QPath::LangItem` so
that it still compiles.
Signed-off-by: David Wood <david@davidtw.co>
2020-08-17 13:55:05 +01:00
Tomasz Miąsko
4f4abf4e06
Warn about explicit self-assignment
...
Warn about assignments where left-hand side place expression is the same
as right-hand side value expression. For example, warn about assignment in:
```rust
pub struct Event {
id: usize,
x: i32,
y: i32,
}
pub fn copy_position(a: &mut Event, b: &Event) {
a.x = b.x;
a.y = a.y;
}
```
2020-08-16 23:31:36 +02:00
Dániel Buga
fc1e07e0c1
Rename lint to use plural form
2020-08-16 22:16:39 +02:00
Dániel Buga
b175642a85
Fix missed rename
2020-08-16 21:33:29 +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
a7cc5d4068
Also simplify if the closure body is an index expression
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
a7d5c2f967
Modifications according to the code review
2020-08-16 00:24:27 +03:00
jrqc
65d10c7abf
Borrow checker added
2020-08-16 00:24:27 +03: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
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
ThibsG
5634c8da02
Fix: keep parenthesis for suggestion in useless_conversion
lint
2020-08-12 21:44:02 +02: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
Ryan1729
7bd7a46331
run tests/ui/update-references.sh to update 'suspicious_arithmetic_impl.rs'
2020-08-12 10:52:20 -06:00
Ryan1729
f4eeff99b6
add tests for Rem, BitAnd, BitOr, BitXor, Shl, and Shr
2020-08-12 10:33:16 -06: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
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
6d0b5e24df
update test stderr
2020-08-11 00:27:55 +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
Matthias Krüger
0876f17d77
bool-comparison: make lint adhere to lint message convention
2020-08-10 20:55:23 +02:00
Matthias Krüger
e57aafe33f
too-many-lines: make lint adhere to lint message convention
2020-08-10 20:55:23 +02:00
Philipp Krones
ee8db50e13
Rollup merge of #5871 - wiomoc:feature/methodcall-minmax, r=flip1995
...
Lint .min(x).max(y) with x < y
Fixes #5854
changelog: Also lint `ord.min(a).max(b)`, where `a < b` in [`min_max`] lint
2020-08-10 14:56:29 +02:00
Philipp Krones
08ab29bed1
Rollup merge of #5870 - ebroto:5789_allow_unsafe_derive_deserialize, r=flip1995
...
enable #[allow(clippy::unsafe_derive_deserialize)]
Before this change this lint could not be allowed as the code we are checking is automatically generated.
changelog: Enable using the `allow` attribute on top of an ADT linted by [`unsafe_derive_deserialize`].
Fixes : #5789
2020-08-10 14:56:27 +02:00
Philipp Krones
8ee57eed79
Rollup merge of #5869 - wiomoc:feature/implicit-self, r=ebroto,flip1995
...
New lint against `Self` as an arbitrary self type
Fixes #5861
changelog: * [`needless_arbitrary_self_type`] [#5869 ](https://github.com/rust-lang/rust-clippy/pull/5869 )
2020-08-10 14:56:26 +02:00
Philipp Krones
9da5b6d1d0
Rollup merge of #5825 - giraffate:same_item_push, r=Manishearth
...
Add the new lint `same_item_push`
changelog: Add the new lint `same_item_push`
Fixed #4078 . As I said in https://github.com/rust-lang/rust-clippy/issues/4078#issuecomment-658184195 , I referrerd to https://github.com/rust-lang/rust-clippy/pull/4647 .
2020-08-10 14:56:25 +02:00
Tim Nielens
166c520e9a
should_impl_trait - pr comments
2020-08-09 15:10:00 +02:00
Tim Nielens
2bc0ecd44b
should_implement_trait - add test cases for every checked trait method
2020-08-09 15:10:00 +02:00
Tim Nielens
a77e881ec9
should_impl_trait - ignore methods with lifetime params
2020-08-09 15:10:00 +02:00
Ryan1729
873e5f5c19
add allow unused_unsafe and allow dead_code
2020-08-09 00:39:14 -06:00