Commit Graph

3587 Commits

Author SHA1 Message Date
Eduardo Broto
9fa9208bd5 Restrict unnecessary_sort_by to non-ref copy types 2020-09-07 00:19:17 +02:00
bors
e9440cbcde Auto merge of #5997 - giraffate:fix_fp_about_clone_in_same_item_push, r=ebroto
Fix FP in `same_item_push`

Don't emit a lint when the pushed item doesn't have Clone trait

Fix #5979

changelog: Fix FP in `same_item_push` not to emit a lint when the pushed item doesn't have Clone trait
2020-09-05 20:27:17 +00:00
Takayuki Nakata
96b31a5b36 Fix FP when coercion kicks in 2020-09-06 00:02:35 +09:00
Ryan1729
9e7ce9d385 run the specific script suggested by the error message
```
./tests/ui-toml/update-references.sh './target/debug/test_build_base' 'functions_maxlines/test.rs'
```
2020-09-04 21:12:16 -06:00
Ryan1729
db16fa26ce run tests/ui/update-all-references.sh 2020-09-04 20:16:02 -06:00
Eduardo Broto
23646e6583 Merge remote-tracking branch 'upstream/master' into sync-from-rust 2020-09-04 23:27:01 +02:00
bors
8829214764 Auto merge of #5994 - taiki-e:useless_attribute, r=phansch
useless_attribute: Permit wildcard_imports and enum_glob_use

Fixes #5918

changelog: `useless_attribute`: Permit `wildcard_imports` and `enum_glob_use` on `use` items
2020-09-03 05:33:03 +00:00
Michael Wright
93ce686b5d Update ui stderr with improved rustc output
Related rust pull request: rust-lang/rust#76160
2020-09-03 04:58:14 +02:00
Ricky
2387f68e43 Removed map_err suggestion in lint, and updated lint documentation example 2020-09-02 19:21:34 -04:00
Tim Nielens
b1f0e019fe Merge branch 'master' into unit-arg 2020-09-02 19:39:54 +02:00
bors
7f27b12288 Auto merge of #5996 - Koxiaet:master, r=ebroto
Allow GraphQL in docs without backticks

changelog: Allow "GraphQL" in [`doc_markdown`] without backticks.
2020-09-02 12:24:31 +00:00
Koxiaet
22c9940613 Add tests for allowed non-backticked identifiers in doc 2020-09-02 12:51:44 +01:00
Sasha
246f1f8a8e Improve recovery on malformed format call
If a comma in a format call is replaced with a similar token, then we
emit an error and continue parsing, instead of stopping at this point.
2020-09-02 13:18:19 +02:00
Ricky
202a80c927 Added tests for map_err, ignored map_err lint on drop_ref tests 2020-09-01 16:59:37 -04:00
Takayuki Nakata
aa7ffa5257 Fix FP in same_item_push
Don't emit a lint when the pushed item doesn't have Clone trait
2020-09-01 22:39:09 +09:00
Taiki Endo
2e4b4cebbb useless_attribute: Permit wildcard_imports and enum_glob_use 2020-09-01 12:09:32 +09:00
rail
afeb917fca Fix a fp in transmute_ptr_to_ptr
Avoid firing the lint when `transmute` in const contexts
as dereferencing raw pointers in consts is unstable. cc #5959
2020-09-01 11:51:32 +12:00
bors
67e18c2d5c Auto merge of #5993 - taiki-e:default_trait_access, r=phansch
default_trait_access: Fix wrong suggestion

https://github.com/rust-lang/rust-clippy/issues/5975#issuecomment-683751131
> I think the underlying problem is clippy suggests code with complete parameters, not clippy triggers this lint even for complex types. AFAIK, If code compiles with `Default::default`, it doesn't need to specify any parameters, as type inference is working. (So, in this case, `default_trait_access` should suggest `RefCell::default`.)

Fixes #5975 Fixes #5990

changelog: `default_trait_access`: fixed wrong suggestion
2020-09-01 15:05:16 +00:00
bors
066f105d67 Auto merge of #5992 - giraffate:fix_wrong_seggestion_in_collapsible_if, r=yaahc
Fix the wrong suggestion when using macro in `collapsible_if`

Fix #5962

changelog: Fix the wrong suggestion when using macro in `collapsible_if`
2020-08-31 19:41:13 +00:00
bors
8334a58c2f Auto merge of #5909 - khuey:async_yields_async, r=yaahc
Add a lint for an async block/closure that yields a type that is itself awaitable.

This catches bugs of the form

tokio::spawn(async move {
    let f = some_async_thing();
    f // Oh no I forgot to await f so that work will never complete.
});

See the two XXXkhuey comments and the unfixed `_l` structure for things that need more thought.

*Please keep the line below*
changelog: none
2020-08-31 19:20:30 +00:00
Taiki Endo
8b0aa6a00b default_trait_access: Fix wrong suggestion 2020-09-01 00:31:53 +09:00
Takayuki Nakata
001f9e45f2 Fix the wrong suggestion when using macro in collapsible_if 2020-09-01 00:05:53 +09:00
Hirochika Matsumoto
451ef78803 Use match_def_path instead of match_qpath 2020-08-31 22:40:47 +09:00
Vali Schneider
a424a2c167 changed check_impl_item to check_fn and added a few more test cases 2020-08-29 16:17:53 -07:00
Kyle Huey
c1d2b9376a Add a test for an async function. 2020-08-29 15:33:54 -07:00
Kyle Huey
4972989b61 Add a lint for an async block/closure that yields a type that is itself awaitable.
This catches bugs of the form

tokio::spawn(async move {
    let f = some_async_thing();
    f // Oh no I forgot to await f so that work will never complete.
});
2020-08-29 15:33:54 -07:00
Eduardo Broto
7a66e6502d or_fn_call: ignore nullary associated const fns 2020-08-29 01:20:49 +02:00
flip1995
282c59820b Merge commit '3d0b0e66afdfaa519d8855b338b35b4605775945' into clippyup 2020-08-28 18:43:25 +02:00
bors
3d0b0e66af Auto merge of #5774 - ThibsG:FixNewRetNoSelf, r=ebroto
Fix FP in `new_ret_no_self`: trigger in trait def instead of impl block

Lint in trait def instead of impl block.

Fixes: #5435

changelog: none
2020-08-28 11:54:07 +00:00
Hirochika Matsumoto
5574182b4d Add a new lint to prevent create_dir from being used 2020-08-28 18:45:28 +09:00
Vali Schneider
b006522393 added lint for todo and removed option 2020-08-27 16:55:23 -07:00
bors
07c5e9edb5 Auto merge of #5971 - giraffate:fix_fp_in_to_string_in_display, r=ebroto
Fix FP in `to_string_in_display`

Don't emit a lint when `.to_string()` on anything that is not `self`

Fix #5967

changelog: Fix FP in `to_string_in_display` when calling `.to_string()` on anything that is not `self`
2020-08-27 23:26:52 +00:00
Vali Schneider
459969f88f added restriction lint that prohibits the usage of unimplemented, unreachable or panic in a function of type result or option 2020-08-27 16:18:05 -07:00
Tim Nielens
f3ccbef2af unit-arg - pr comments 2020-08-27 19:36:28 +02:00
ThibsG
3cb75c2e5c Remove expansion restriction + fix doc and tests naming 2020-08-27 18:25:38 +02:00
ThibsG
2a3ee5fa85 Fix FP in new_ret_no_self: trigger in trait def instead of impl block 2020-08-27 18:25:38 +02:00
Takayuki Nakata
04bff17668 Fix FP in to_string_in_display
Don't emit a lint when `.to_string()` on anything that is not `self`
2020-08-27 23:37:47 +09:00
Jane Lusby
91024f1fde Add new lint to prevent usage of unwrap in fns that return result 2020-08-26 16:31:49 -07:00
bors
64c4bb0d2b Auto merge of #5966 - 1c3t3a:1c3t3a-dev-5819-fix, r=Manishearth
Corrects the float_equality_without_abs lint

Fixes an issue in the `float_equality_without_abs` lint. The lint suggestion was configured in a way that it lints the whole error and not just the subtraction part. In the current configuration the lint would suggest to change the expression in a wrong way, e.g.
```rust
let _ = (a - b) < f32::EPSILON; // before
let _ = (a - b).abs(); // after
```
This was dicovered by @flip1995. (See discussion of PR #5952).

Also the suggestion is now formatted via `utils::sugg`.
changelog: none
2020-08-26 18:15:42 +00:00
Bastian
2d853148d7 Changed the location of the suggestion as well as the way the suggestion is assembled 2020-08-26 16:39:30 +02:00
bors
894581b872 Auto merge of #5946 - mikerite:fix-5729, r=flip1995
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

changelog: Fix `let_and_return` bad suggestion
2020-08-26 12:01:32 +00:00
bors
9ef44799bf Auto merge of #5949 - rail-rain:fix_fp_borrow_interior_mutable_const, r=oli-obk
Fix fp in `borrow_interior_mutable_const`

fixes #5796

changelog: fix false positive in `borrow_interior_mutable_const` when referencing a field behind a pointer.
2020-08-26 11:06:37 +00:00
bors
ad7a03cbaa Auto merge of #5951 - ThibsG:FixMacroCloneOnRefPtr2076, r=ebroto
Fix incorrect suggestion when `clone_on_ref_ptr` is triggered in macros

In the lint `clone_on_ref_ptr`, if the `span` is in a macro, don't expand it for suggestion.

Fixes: #2076

changelog: none

r? @ebroto
2020-08-25 21:48:19 +00:00
Scott McMurray
3b1e5d6ff7 Re-enable len_zero for ranges now that is_empty is stable on them 2020-08-25 12:17:03 -07:00
bors
f326668577 Auto merge of #5958 - mikerite:fix-fmt-20200825, r=flip1995
Various fmt test improvements

Various fmt test improvements.

changelog: none
2020-08-25 17:15:51 +00:00
bors
f9015592f3 Auto merge of #5952 - 1c3t3a:1c3t3a-dev-5819, r=Manishearth
Added a lint which corrects expressions like (a - b) < f32::EPSILON, according to #5819

Fixes #5819
changelog: none
2020-08-25 16:54:48 +00:00
bors
5ef345a853 Auto merge of #5960 - flip1995:rustup, r=flip1995
Rustup

r? @ghost

changelog: none
2020-08-25 16:11:17 +00:00
Philipp Krones
acc6b6ce07
Fix typo 2020-08-25 18:01:08 +02:00
Michael Wright
48d4736913 Simplify fmt test by using the clippy dev alias 2020-08-25 05:53:28 +02:00
Michael Wright
9102832692 Fix incorrect comment 2020-08-25 05:53:28 +02:00
bors
64b53f3877 Auto merge of #5920 - giraffate:fix_fp_for_redundant_closure_call, r=mikerite
Fix FP for `redundant_closure_call`

Fix #5916

changelog: Fix FP for `redundant_closure_call` when called in function body
2020-08-25 03:29:59 +00:00
Scott McMurray
48b4aeabf8 Unbreak the clippy test 2020-08-24 16:29:03 -07:00
Matthias Krüger
e9964f2e8a stable_sort_primitive: print the type that is being sorted in the lint message 2020-08-24 20:06:43 +02:00
Bastian
680c68153b Added a lint which corrects expressions like (a - b) < f32::EPSILON 2020-08-24 16:31:51 +02:00
ThibsG
3d820f71fe Fix incorrect suggestion when clone_on_ref_ptr is triggered in macros 2020-08-24 14:05:49 +02:00
rail-rain
ce8915c85c
typo
Co-authored-by: Thibaud <ThibsG@users.noreply.github.com>
2020-08-24 19:08:38 +12:00
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
Tim Nielens
2ecc2ac864 unit-arg - improve suggestion 2020-08-21 00:42:11 +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