Commit graph

3706 commits

Author SHA1 Message Date
Cameron Steffen
99861c0e88 Remove initialization note from shadow lint 2021-09-30 13:54:30 -05:00
bors
a893eb993b Auto merge of #7677 - surechen:edit_large_enum_variant, r=camsteffen
fix bug for large_enum_variants

Fix the discussion problem in the issue of https://github.com/rust-lang/rust-clippy/issues/7666#issuecomment-919654291

About the false positive problem of case:
```rust
enum LargeEnum6 {
    A,
    B([u8;255]),
    C([u8;200]),
}
```

changelog: Fix largest_enum_variant wrongly identifying the second largest variant.
2021-09-30 12:45:17 +00:00
bors
ab99eec15f Auto merge of #7684 - surechen:solve_derivable_impls, r=flip1995
fix for issue #7683

Fixes #7683.

For Repeat  [x; y] (x is the type and y is the times to repeat) . When y > 32, the compiler will report an error:

https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=7148558162685e91056e0550797ea74c

Because 6cdd42f9f8/library/std/src/primitive_docs.rs (L538)
/// Arrays of sizes from 0 to 32 (inclusive) implement [`Default`] trait
/// if the element type allows it. As a stopgap, trait implementations are
/// statically generated up to size 32.

So here to detect this situation.

changelog: [`derivable_impls`]: No longer lints when arrays bigger than 32 elements are involved
2021-09-30 08:19:58 +00:00
surechen
a3d3735515 Arrays of sizes from 0 to 32 (inclusive) implement [Default] trait, edit method is_default_equivalent() to satisfy with this. 2021-09-30 10:41:36 +08:00
surechen
56f0c9afdd fix bug for large_enum_variants 2021-09-30 10:07:57 +08:00
bors
fb17671eb0 Auto merge of #7734 - Manishearth:doc-unsafe-trait, r=camsteffen
Make `doc_unsafe` warn on unsafe traits as well

Fixes #7732

changelog: Make [`doc_unsafe`] warn on unsafe traits as well
2021-09-28 17:09:34 +00:00
bors
cb7915b00c Auto merge of #7733 - flip1995:rustup, r=flip1995
Rustup

This needs a review this time. Especially 521bf8f0fa cc `@camsteffen` I think this is necessary now, because `itertools` is no longer a dependency of `clippy_utils` and therefore this path can't be found 🤔

( I forgot about the sync last week. I should get to document this process better, so other people can do it when I'm not around )

changelog: none
2021-09-28 16:42:31 +00:00
Manish Goregaokar
53c534d11b Update clippy_lints/src/doc.rs
Co-authored-by: Cameron Steffen <cam.steffen94@gmail.com>
2021-09-28 09:37:58 -07:00
Manish Goregaokar
25850fc264 Make doc_unsafe lint on unsafe traits as well 2021-09-28 08:40:59 -07:00
flip1995
707494eca9
Merge remote-tracking branch 'upstream/master' into rustup 2021-09-28 10:52:31 +01:00
Andrew Pollack
b7d40bc103 Adding new linting 2021-09-27 22:23:17 -07:00
David Tolnay
e63d69244e
Stop suggesting a float truncation that is not shorter 2021-09-25 22:55:23 -07:00
Labelray
543b638dbe Add new lint if_then_panic 2021-09-24 22:14:20 +08:00
bors
cd3f3cf8a8 Auto merge of #7707 - Jarcho:suspicious_else_proc_mac, r=Manishearth
Don't lint `suspicious_else_formatting` inside proc-macros

fixes: #7650

I'll add a test for this one soon.

changelog: Don't lint `suspicious_else_formatting` inside proc-macros
2021-09-23 16:14:29 +00:00
Jason Newcomb
e69154f370
Add test for #7650 2021-09-23 11:22:38 -04:00
bors
ef2e2f0a0c Auto merge of #7693 - F3real:vec2, r=Manishearth
Expand box_vec lint to box_collection

fixed #7451

changelog: Expand `box_vec` into [`box_collection`], and have it error on all sorts of boxed collections
2021-09-22 22:13:13 +00:00
bors
a4a8ec2d52 Auto merge of #7679 - lengyijun:issue4546, r=xFrednet
add #4546 test

changelog: none
fixed #4546

I notice #4546 was fixed some time, I just add the tests.
2021-09-22 09:00:30 +00:00
lengyijun
b68325ecf6 add #4546 test 2021-09-22 16:04:04 +08:00
bors
8a75002930 Auto merge of #7685 - camsteffen:let-else-needless-ret, r=giraffate
Fix needless_return with let-else

changelog: Fix needless_return FP with `let...else`

Fixes #7637
2021-09-22 00:23:23 +00:00
F3real
63ed2f9eb4 Expand BOX_VEC to BOX_COLLECTION 2021-09-20 10:23:55 +02:00
bors
871ad80bb0 Auto merge of #7690 - Jarcho:while_loop_by_ref, r=xFrednet
Change `while_let_on_iterator` suggestion to use `by_ref()`

It came up in the discussion #7659 that suggesting `iter.by_ref()` is a clearer suggestion than `&mut iter`. I personally think they're equivalent, but if `by_ref()` is clearer to people then that should be the suggestion.

changelog: Change `while_let_on_iterator` suggestion when using `&mut` to use `by_ref()`
2021-09-19 17:37:04 +00:00
Cameron Steffen
b36591217d Fix needless_return with let-else 2021-09-18 09:42:51 -05:00
Jason Newcomb
ee6a6b55c4
Change the suggestion for while_let_on_iterator when the iterator cannot be consumed to iter.by_ref() 2021-09-17 21:44:21 -04:00
bors
59cd77710d Auto merge of #7657 - dswij:needless-borrow-mut, r=llogiq
`needless_borrow` checks for mutable borrow

closes #7635

changelog: [`needless_borrow`] now checks for needless mutable borrow
2021-09-17 22:25:07 +00:00
bors
ed7a82ef05 Auto merge of #7653 - lengyijun:same_name_method_crate, r=llogiq
New lint: `same_name_method`

changelog: ``[`same_name_method`]``
fix: https://github.com/rust-lang/rust-clippy/issues/7632

It only compares a method in `impl` with another in `impl trait for`
It doesn't lint two methods in two traits.

I'm not sure my approach is the best way. I meet difficulty in other approaches.
2021-09-17 22:02:04 +00:00
lyj
fb78365332 add 3414 test 2021-09-16 16:52:57 +08:00
David Tolnay
c2783c1dcb
Downgrade many_single_char_names to pedantic 2021-09-14 09:59:06 -07:00
Kneasle
b2ffb28da5 Fix FN for collections/smart ptrs in std 2021-09-14 16:51:09 +01:00
lengyijun
e2cdaec984 same_name_method 2021-09-14 09:20:27 +08:00
Kneasle
e0090735f1 Fix FP when using raw pointers as hashed keys 2021-09-13 11:08:50 +01:00
dswij
81d57de791 Update needless_borrow test output and expected fix 2021-09-13 12:29:24 +08:00
dswij
6b4b77aa44 Update test for needless-borrow FP for mutable ref 2021-09-13 12:29:24 +08:00
bors
a64b7698a4 Auto merge of #7661 - camsteffen:eta, r=giraffate
Fix various redundant_closure bugs

changelog: Fix various false negatives and false positives for [`redundant_closure`]

Closes #3071
Closes #4002

This lint is full of weird nuances and this is basically a re-write to tighten up the logic.
2021-09-13 00:39:34 +00:00
bors
2636a1b7b5 Auto merge of #7663 - Jarcho:rsplit_once_order, r=llogiq
Fix result order for `manual_split_once` when `rsplitn` is used

fixes: #7656

changelog: Fix result order for `manual_split_once` when `rsplitn` is used
2021-09-11 08:29:52 +00:00
Jason Newcomb
4c1b6a28e4
Fix result order for manual_split_once when rsplitn is used 2021-09-10 13:05:09 -04:00
hamidreza kalbasi
5aff720e1a fix derivable impl false positives 2021-09-10 19:49:02 +04:30
Cameron Steffen
5782dc0eb9 Fix redundant closure bugs 2021-09-09 17:10:59 -05:00
Fabian Wolff
81ce2fb167 Ignore automatically derived impls of Clone and Debug in dead code analysis 2021-09-09 19:49:07 +02:00
bors
1a524783b1 Auto merge of #7610 - Labelray:master, r=camsteffen
Add new lint `iter_not_returning_iterator`

Add new lint [`iter_not_returning_iterator`] to detect method `iter()` or `iter_mut()` returning a type not implementing `Iterator`
changelog: Add new lint [`iter_not_returning_iterator`]
2021-09-09 01:47:08 +00:00
Labelray
8f88acdbfa add new lint iter_not_returning_iterator 2021-09-09 09:21:38 +08:00
flip1995
091ed44b50 Merge commit '27afd6ade4bb1123a8bf82001629b69d23d62aff' into clippyup 2021-09-08 16:31:47 +02:00
bors
5458358461 Auto merge of #7644 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2021-09-08 09:00:54 +00:00
flip1995
4962608ca6
Merge remote-tracking branch 'upstream/master' into rustup 2021-09-08 10:51:27 +02:00
dswij
7515d9c6f7 Update test output for mut_range_bound 2021-09-08 10:41:37 +08:00
dswij
290fb8de66 Add additional test for broken loop in mut_range_bound 2021-09-08 10:41:37 +08:00
Michael Wright
a7a5a5d9b0 Add TAU to approx_constant 2021-09-07 05:50:04 +02:00
bors
f7aaa2a200 Auto merge of #88493 - chenyukang:fix-duplicated-diagnostic, r=estebank
Fix #88256 remove duplicated diagnostics

Fix #88256
2021-09-06 00:14:41 +00:00
bors
7a0d7d8283 Auto merge of #7596 - lengyijun:option_needless_deref, r=llogiq
New lint: option_needless_deref

changelog: [`option_needless_deref`]
fix #7571
2021-09-05 18:11:56 +00:00
bors
e5ae3f5491 Auto merge of #7629 - mikerite:fix-7623-2, r=xFrednet
Make `approx_const` MSRV aware

changelog: [`approx_const`]: Add MRSV checks for LOG10_2 and LOG2_10.

Fixes #7623
2021-09-05 13:17:02 +00:00
Michael Wright
19d8a3e53c Improve approx_constant output 2021-09-05 08:47:45 +02:00