Commit graph

2837 commits

Author SHA1 Message Date
Ryan Sullivant
fd303132a2 Cleaned up message and suggestion for lint_search_is_some 2020-11-10 23:18:48 -07:00
Ryan Sullivant
ee1b959054 Added period back to lint search_is_some and ran
`update-all-references.sh`
2020-11-10 23:18:47 -07:00
Ryan Sullivant
55dc822062 Ran tests/ui/update-all-references.sh" and cargo dev fmt` 2020-11-10 23:18:47 -07:00
Ryan Sullivant
431fcbcc00 Moved the tests for lint search_is_some to new files
`search_is_some.rs` and `search_is_some_fixable.rs`
2020-11-10 23:18:47 -07:00
Ryan Sullivant
a1cf2d334d Added a lint as suggested in 6010 which recommends using contains()
instead of `find()` follows by `is_some()` on strings

Update clippy_lints/src/find_is_some_on_strs.rs
Co-authored-by: Takayuki Nakata <f.seasons017@gmail.com>

Update clippy_lints/src/methods/mod.rs
Co-authored-by: Philipp Krones <hello@philkrones.com>
2020-11-10 23:18:47 -07:00
bors
c4fc076e11 Auto merge of #6269 - camsteffen:map-clone-deref, r=ebroto
Fix map_clone with deref and clone

changelog: Fix map_clone false positive with deref coercion

Fixes #6239
2020-11-11 00:48:33 +00:00
Cameron Steffen
769094410a Fix map_clone with deref and clone 2020-11-10 18:37:17 -06:00
bors
d0858d0f36 Auto merge of #6303 - ThibsG:OptionOptionSerde, r=ebroto
Remove `allow` in `option_option` lint test

As it is not triggering locally anymore, I propose to remove `#[allow(clippy::option_option)]` from the test.

The goal is also to see what happens on CI.

closes: #4298

changelog: none
2020-11-10 22:39:10 +00:00
bors
dd826b4626 Auto merge of #6305 - smoelius:master, r=flip1995
Add `let_underscore_drop`

This line generalizes `let_underscore_lock` (#5101) to warn about any initializer expression that implements `Drop`.

So, for example, the following would generate a warning:
```rust
struct Droppable;
impl Drop for Droppable {
    fn drop(&mut self) {}
}
let _ = Droppable;
```

I tried to preserve the original `let_underscore_lock` functionality in the sense that the warning generated for
```rust
let _ = mutex.lock();
```
should be unchanged.

*Please keep the line below*
changelog: Add lint [`let_underscore_drop`]
2020-11-09 19:13:26 +00:00
Samuel E. Moelius III
4852cca61b Allow let_underscore_drop in filter_methods test 2020-11-09 07:49:14 -05:00
bors
d212c382c3 Auto merge of #6278 - ThibsG:DerefAddrOf, r=llogiq
Fix bad suggestions for `deref_addrof` and `try_err` lints

Fix bad suggestions when in macro expansion for `deref_addrof` and `try_err` lints.

Fixes: #6234
Fixes: #6242
Fixes: #6237

changelog: none

r? `@llogiq`
2020-11-09 05:25:04 +00:00
Samuel E. Moelius III
06e81bb493 Update references 2020-11-08 18:32:12 -05:00
Cameron Steffen
9cab08465b Fix or_fun_call for index operator 2020-11-08 14:49:42 -06:00
Samuel E. Moelius III
9c6a0b9c34 Update references 2020-11-08 07:07:49 -05:00
bors
b1faa7f002 Auto merge of #6271 - camsteffen:vec-box-import, r=flip1995
Fix vec_box scope error

changelog: Fix vec_box suggestion with wrong type scope

Fixes #6236
2020-11-08 12:02:30 +00:00
Samuel E. Moelius III
f1f780c942 Add let_underscore_drop 2020-11-08 07:00:35 -05:00
flip1995
00dee9d916
Update reference files 2020-11-08 12:40:41 +01:00
Joe Richey
c6a91df838
Enable empty_loop lint for no_std crates
We skip the lint if the `loop {}` is in the `#[panic_handler]` as the
main recommendation we give is to panic, which obviously isn't
possible in a panic handler.

Signed-off-by: Joe Richey <joerichey@google.com>
2020-11-08 12:38:10 +01:00
bors
96d5f45ade Auto merge of #6301 - alex-700:fix-map-clone, r=matthiaskrgr
do not trigger map_clone in the case of &mut

fixes #6299
changelog: do not trigger map_clone in the case of &mut
2020-11-08 01:28:27 +00:00
bors
92ba07582e Auto merge of #6134 - patrickelectric:as_utf8, r=llogiq
Check when `from_utf8` is called from sliced byte array from string

---

*Please keep the line below*
changelog: Fix #5487: Add linter to check when `from_utf8` is called from sliced byte array from string.
2020-11-07 17:06:27 +00:00
bors
694cec12be Auto merge of #6110 - rail-rain:care_enums_non_copy_const, r=llogiq
"Respect" enums in `interior_mutable_const`

fixes #3962
fixes #3825

Hello,

It might not be a good idea to submit another relatively large PR while I have an opened PR; but, I've finished this anyway. This may be able to wait for months.

Note: the code uses the MIR interpreter, which the author of #3962 thought unlikely to be a solution. This might be over-engineering; but, I think it's important to be able to work with the 'http' crate (#3825). (And, I don't want to write a MIR visitor)

---

changelog: fix a false positive in two `interior_mutable_const` lints where a constant with enums gets linted
even if it uses a clearly unfrozen variant
2020-11-07 15:51:13 +00:00
bors
4bbef42c48 Auto merge of #6272 - camsteffen:unnecesary-lazy-eval-type, r=llogiq
Fix unnecessary_lazy_eval suggestion applicability

changelog: Fix unnecessary_lazy_eval suggestion applicability when breaking type inference

Fixes #6240
2020-11-07 10:01:46 +00:00
ThibsG
8242b2f0a4 Remove needless allow 2020-11-06 18:11:58 +01:00
Aleksei Latyshev
5f57608604
do not trigger map_clone in the case of &mut 2020-11-06 14:38:46 +03:00
Takayuki Nakata
1624b00bde Fix suggestion to add unneeded space in manual_async 2020-11-06 08:40:43 +09:00
ThibsG
83e75f9207 Fix incorrect suggestion for try_err lint when Err arg is itself a macro 2020-11-05 18:00:34 +01:00
ThibsG
f83762b79c Skip rustfmt as it is wanted for this test 2020-11-05 09:14:20 +01:00
Patrick José Pereira
bc27d1492d Add string_from_utf8_as_bytes linter
Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
2020-11-04 21:17:46 -03:00
bors
0d2f1aef02 Auto merge of #6247 - giraffate:fix_suggestion_to_add_space_in_unused_unit, r=ebroto
Fix suggestion to add unneeded space in `unused_unit`

Fix https://github.com/rust-lang/rust-clippy/issues/6230

changelog: Fix suggestion to add unneeded space in `unused_unit`
2020-11-04 22:42:10 +00:00
bors
5b52474ae6 Auto merge of #5911 - hegza:issue-568, r=ebroto
Add lint for 'field_reassign_with_default` #568

changelog: Add lint for field_reassign_with_default that checks if mutable object + field modification is used to edit a binding initialized with Default::default() instead of struct constructor.

Fixes #568

Notes:
- Checks for reassignment of one or more fields of a binding initialized with Default::default().
- Implemented using EarlyLintPass, might be future proofed better with LateLintPass.
- Does not trigger if Default::default() is used via another type implementing Default.
- This is a re-open of [PR#4761](https://github.com/rust-lang/rust-clippy/pull/4761), but I couldn't figure out how to re-open that one so here's a new one with the requested changes :S
2020-11-04 22:21:44 +00:00
bors
c2cf40cdcd Auto merge of #6284 - camsteffen:rustc-sym, r=flip1995
Use const sym where possible

I ran a regex search and replace to use const `sym` values where possible. This should give some performance boost by avoiding string interning at runtime.

Con: It is not as consistent as always using `sym!`.

I also changed an internal lint to suggest using `sym::{}`, making an assumption that this will always work for diagnostic items.

changelog: none
2020-11-04 09:22:54 +00:00
bors
225ce5ff58 Auto merge of #6233 - montrivo:manual_ok_or, r=flip1995
add manual_ok_or lint

Implements partially #5923

changelog: add lint manual_ok_or
2020-11-03 16:42:59 +00:00
bors
2fe87a89c9 Auto merge of #6165 - dvermd:ref_option_ref, r=flip1995
Add lint 'ref_option_ref' #1377

This lint checks for usage of `&Option<&T>` which can be simplified as `Option<&T>` as suggested in #1377.

This WIP PR is here to get feedback on the lint as there's more cases to be handled:
* statics/consts,
* associated types,
* type alias,
* function/method parameter/return,
* ADT definitions (struct/tuple struct fields, enum variants)

changelog: Add 'ref_option_ref' lint
2020-11-03 16:21:51 +00:00
bors
a2bf404d34 Auto merge of #6101 - pitiK3U:from_iter_instead_of_collect, r=flip1995
Add lint: from_iter_instead_of_collect

Fixes #5679

This implements lint for `::from_iter()` from #5679 not the general issue (`std::ops::Add::add`, etc.).
This lint checks if expression is function call with `from_iter` name and if it's implementation of the `std::iter::FromIterator` trait.

changelog: Introduce  from_iter_instead_of_collect lint
2020-11-03 15:59:16 +00:00
Piti the little Light
52d1ea3c9a
Fix: Don't show lint for types that doesn't implement Iterator 2020-11-03 16:44:24 +01:00
Piti the little Light
f359fb872b
Improve error message 2020-11-03 16:44:24 +01:00
Piti the little Light
abdb7aeb55
Remove backticks 2020-11-03 16:44:24 +01:00
Piti the little Light
e320dd3042
Improve: error message 2020-11-03 16:44:23 +01:00
Piti the little Light
0ab96ba2c0
Allow lint 2020-11-03 16:44:23 +01:00
Piti the little Light
8906040445
Improvements from PR feedback 2020-11-03 16:44:21 +01:00
Piti the little Light
a85670652a
Update: stderr message format 2020-11-03 16:42:30 +01:00
Piti the little Light
1b117f4629
Add tests for from_iter_instead_of_collect 2020-11-03 16:42:30 +01:00
bors
3ee9c2e1a0 Auto merge of #6037 - matthiaskrgr:single_char_insert, r=flip1995
single_char_insert_str: lint using insert_str() on single-char literals and suggest insert()

Fixes #6026

changelog: add single_char_insert_str lint which lints using string.insert_str() with single char literals and suggests string.insert() with a char
2020-11-03 15:36:33 +00:00
Cameron Steffen
b2332a7357 Change lint to use const sym 2020-11-02 11:52:17 -06:00
ThibsG
ce98468158 Fix incorrect suggestion when from expansion in try_err lint 2020-11-02 18:08:38 +01:00
ThibsG
343bdb3364 Give better suggestion by working on span on deref_addrof lint 2020-11-02 18:08:38 +01:00
ThibsG
158bf9aa44 Fix incorrect suggestion for macro expansion in deref_addrof lint 2020-11-02 18:08:38 +01:00
Henri Lunnikivi
7b203f3da6 Implement field_reassign_with_default
- Implement `field_reassign_with_default` as a `LateLintPass`
- Avoid triggering `default_trait_access` on a span already linted by
`field_reassigned_with_default`
- Merge `default_trait_access` and `field_reassign_with_default` into
`Default`
- Co-authored-by: Eduardo Broto <ebroto@tutanota.com>
- Fixes #568
2020-10-31 15:49:58 +02:00
Eduardo Broto
f8ac1f99ef Address suggestions in PR review 2020-10-30 23:47:22 +01:00
Eduardo Broto
d958269fe5 Rename single_char_push_str to single_char_add_str 2020-10-30 23:29:44 +01:00