Commit Graph

6553 Commits

Author SHA1 Message Date
Nathaniel Hamovitz
7ee8e7a9b8 Implement detecting trailing zero-sized array 2021-10-18 03:05:18 -07:00
Nathaniel Hamovitz
92d3b775bd ayy it compiles! ship it, right? 😎 /s
why was `rustc_lint_defs` not already externed in `lib.rs`?
and how was r-a able to find it but cargo wasn't? 🤔
2021-10-18 03:05:18 -07:00
Nathaniel Hamovitz
c69387a0d5 Well it builds 2021-10-18 03:05:18 -07:00
Nathaniel Hamovitz
797507c583 Add boilerplate and basic tests 2021-10-18 03:05:18 -07:00
Michael Wright
63d715209e Remove unneeded allow 2021-10-18 08:46:11 +02:00
Matthias Krüger
79b73ac98d Rollup merge of #89963 - r00ster91:parenthesisparentheses, r=nagisa
Some "parenthesis" and "parentheses" fixes

"Parenthesis" is the singular (e.g. one `(` or one `)`) and "parentheses" is the plural (multiple `(` or `)`s) and this is not hard to mix up so here are some fixes for that.

Inspired by #89958
2021-10-17 18:18:59 +02:00
Paul Gey
a550133b8f Fix false positive of implicit_saturating_sub with else clause
Fixes #7831
2021-10-17 15:56:59 +02:00
r00ster91
599d9126a2 Some "parenthesis" and "parentheses" fixes 2021-10-17 12:04:01 +02:00
Matthias Kaak
25ff7ce128 Fixed naive doc formatting for #[must_use] lints 2021-10-16 15:26:47 +00:00
bors
e1871ba0da Auto merge of #7743 - smoelius:master, r=camsteffen
Add `format_in_format_args` and `to_string_in_format_args` lints

Fixes #7667 and #7729

I put these in `perf` since that was one of `@jplatte's` suggestions, and `redundant_clone` (which I consider to be similar) lives there as well.

However, I am open to changing the category or anything else.

r? `@camsteffen`

changelog: Add `format_in_format_args` and `to_string_in_format_args` lints
2021-10-15 17:05:13 +00:00
Samuel E. Moelius III
75e9f8cbd6 Remove redundant to_strings 2021-10-15 12:44:49 -04:00
Samuel E. Moelius III
c9599d79a3 Add format_in_format_args and to_string_in_format_args lints
Fixes #7667 and #7729
2021-10-15 12:44:38 -04:00
dswij
ec5071931e unnecessary_sort_by only warns if argument impl Ord trait 2021-10-15 18:10:55 +08:00
Cameron Steffen
0a23fff82d Fix clippy with changed macro statement spans 2021-10-15 02:36:58 -05:00
bors
4996e17b14 Auto merge of #7815 - nhamovitz:patch-1, r=giraffate
Fix typo in example for `match_result_ok`

changelog: Fix typo in example for ``[`match_result_ok`]``
2021-10-13 23:44:42 +00:00
bors
b9b11a96d2 Auto merge of #7805 - aDotInTheVoid:transmute-num-bits, r=camsteffen
Add lint transmute_num_to_bytes

Closes #7803

changelog: [`transmute_num_to_bytes`] new lint
2021-10-13 19:40:33 +00:00
nhamovitz
09aa4ad6dc
Fix typo in example for match_result_ok 2021-10-13 12:12:46 -07:00
Nixon Enraght-Moony
58969807ab Add lint transmute_num_to_bytes
Closes #7803

changelog: [`transmute_num_to_bytes`] new lint
2021-10-13 20:05:05 +01:00
bors
57dc0343bd Auto merge of #7788 - flip1995:eq_if_let_sugg, r=giraffate
Do not expand macros in equatable_if_let suggestion

Fixes #7781

Let's use Hacktoberfest as a motivation to start contributing PRs myself again :)

changelog: [`equatable_if_let`]: No longer expands macros in the suggestion
2021-10-13 12:04:57 +00:00
bors
3d9c4a655b Auto merge of #7682 - Qwaz:uninit_vec, r=xFrednet
Implement uninit_vec lint

changelog: add the new lint [`uninit_vec`]

Fix #7681
2021-10-12 21:04:13 +00:00
Yechan Bae
4ed3a4fe2f Update lint description for new() and default() 2021-10-12 16:02:13 -04:00
bors
d3905af454 Auto merge of #7806 - Serial-ATA:lint-match-case-mismatch, r=llogiq
Add match_str_case_mismatch lint

changelog: Added a new lint [`match_str_case_mismatch`]

Fixes #7440
2021-10-12 18:39:09 +00:00
Serial
0c99de0ab2 Add a suggestion 2021-10-12 07:13:19 -04:00
Lukas Wirth
5adf17cb43
Bring manual_split_once docs in line with other lint docs 2021-10-12 09:42:42 +02:00
Serial
99bfee7201 Don't run examples 2021-10-11 20:40:13 -04:00
Serial
9e0ce14700 Add match_str_case_mismatch lint 2021-10-11 20:19:34 -04:00
bors
77dda9c6b1 Auto merge of #7791 - JamesHinshelwood:reason-in-disallowed-type, r=giraffate
Allow giving reasons for `disallowed_types`

Similar to #7609 but for the `disallowed_type` lint. The permitted form of configuration is the same as for `disallowed_methods`.

changelog: Allow giving reasons for [`disallowed_type`]
2021-10-12 00:17:37 +00:00
flip1995
f44a904a56 Deprecate mem_discriminant_non_enum
This lint has been uplifted and is now included in
enum_intrinsics_non_enums.
2021-10-11 10:10:16 +02:00
James Hinshelwood
886cbb1882
Rename disallowed to conf_disallowed
Co-authored-by: James Hinshelwood <james.hinshelwood@bigpayme.com>
2021-10-11 08:29:56 +01:00
James Hinshelwood
857a4073b8
Add reason config example for disallowed_type
Co-authored-by: James Hinshelwood <james.hinshelwood@bigpayme.com>
2021-10-11 08:29:41 +01:00
bors
bc9ad848eb Auto merge of #7795 - ThibsG:MutMut6922, r=giraffate
Fix FP in external macros for `mut_mut` lint

Fix FP in `mut_mut` lint when type is defined in external macros.

fixes: #6922

changelog: [`mut_mut`] Fix FP when type is defined in external macros
2021-10-11 01:14:53 +00:00
bors
9205e3d800 Auto merge of #7800 - 1nF0rmed:no-lint-in-match-single-amp, r=llogiq
Refactor `clippy::match_ref_pats` to check for multiple reference patterns

fixes #7740

When there is only one pattern, to begin with, i.e. a single deref(`&`), then in such cases we suppress `clippy::match_ref_pats`.
This is done by checking the count of the reference pattern and emitting `clippy::match_ref_pats` when more than one pattern is present.

Removed certain errors in the `stderr` tests as they would not be triggered.

changelog: Refactor `clippy::match_ref_pats` to check for multiple reference patterns
2021-10-10 11:13:05 +00:00
1nF0rmed
fc32425521 Refactor to check for multiple reference patterns 2021-10-09 22:30:12 +05:30
ThibsG
1e18b8a269 Fix FP in external macros for mut_mut lint 2021-10-09 15:54:16 +02:00
ThibsG
7aaed02b8c Fix false positive when Drop and Copy involved 2021-10-09 14:56:33 +02:00
Yechan Bae
03fed75c89 Address internal lints 2021-10-09 05:59:53 -04:00
Yechan Bae
2181387c3a Improved error message for set_len() on empty Vec 2021-10-09 05:47:07 -04:00
Yechan Bae
b1aa3064b6 Address PR comments 2021-10-09 05:47:06 -04:00
Yechan Bae
dd9c8d32f2 Extract get_vec_init_kind and share it 2021-10-09 05:43:58 -04:00
Yechan Bae
fec20bf617 Add #allow attribute to suppress FP #7698 2021-10-09 05:38:19 -04:00
Yechan Bae
fdc06d9b2b Improve error messages 2021-10-09 05:38:19 -04:00
Yechan Bae
759200b699 Handle PR feedbacks first round 2021-10-09 05:38:19 -04:00
Yechan Bae
b8ba7269cd Fix clippy lints 2021-10-09 05:38:19 -04:00
Yechan Bae
452181c69d Implement uninit_vec lint 2021-10-09 05:38:19 -04:00
James Hinshelwood
72078faf91
Allow giving reasons for disallowed_types
Co-authored-by: James Hinshelwood <james.hinshelwood@bigpayme.com>
2021-10-08 20:47:52 +01:00
flip1995
b423b85ca9
Don't trigger semicolon_if_nothing_returned in expanded code
Before this lint didn't trigger on macros. With rust-lang/rust#88175
this isn't enough anymore. In this PR a `WhileLoop` desugaring kind was
introduced. This overrides the span of expanded expressions when
lowering the while loop. So if a while loop is in a macro, the
expressions that it expands to are no longer marked with
`ExpnKind::Macro`, but with `ExpnKind::Desugaring`. In general, this is
the correct behavior and the same that is done for `ForLoop`s. It just
tripped up this lint.
2021-10-08 16:16:56 +02:00
flip1995
28fb591b6e
Do not expand macros in equatable_if_let suggestion 2021-10-08 15:26:10 +02:00
Serial
412b862fba Add undocumented_unsafe_blocks lint 2021-10-07 17:06:21 -04:00
bors
8aff5dd570 Auto merge of #7705 - michaelsproul:fn_to_numeric_cast_any, r=camsteffen
Restriction lint for function pointer casts

The existing lints for function pointer casts cover the cases where a cast is non-portable or would result in truncation, however there's currently no way to forbid numeric function pointer casts entirely.

I've added a new lint `fn_to_numeric_cast_any`, which allows one to ban _all_ numeric function pointer casts, including to `usize`. This is useful if you're writing high-level Rust and want to opt-out of potentially surprising behaviour, avoiding silent bugs from forgotten parentheses, e.g.

```rust
fn foo() -> u32 {
    10
}

fn main() {
    let _ = foo as usize; // oops, forgot to call foo and got a random address instead!
}
```

~~I'm open to suggestions for the naming of the lint, because `fn_to_numeric_cast_any` is a bit clunky. Ideally I'd call this lint `fn_to_numeric_cast`, but that name is already taken for the more specific lint~~. We've stuck with `fn_to_numeric_cast_any` to avoid renaming the existing lint, or choosing a different name that's too generic (like `fn_cast`).

I'm also open to changing the suggestion behaviour, as adding parentheses is only one of many possible ways to fix the lint.

changelog: add ``[`fn_to_numeric_cast_any`]`` restriction lint
2021-10-07 14:14:19 +00:00
Michael Sproul
fbd0fb9aed Restriction lint for function pointer casts 2021-10-07 09:11:47 -05:00
bors
872f3213f2 Auto merge of #7782 - dswij:shadow-unrelated-block, r=flip1995
Make `shadow_reuse` suggestion less verbose

Closes #7764

Make `shadow_reuse` suggestion less verbose.

changelog: [`shadow_reuse`] does not warn shadowing statement
2021-10-07 09:49:19 +00:00
flip1995
5cf4984872 Merge commit 'b7f3f7f6082679da2da9a0b3faf1b5adef3afd3b' into clippyup 2021-10-07 11:21:30 +02:00
flip1995
1f955158dd
Merge remote-tracking branch 'upstream/master' into rustup 2021-10-07 11:11:23 +02:00
dswij
64f8b9d0ea Make shadow_reuse suggestion less verbose 2021-10-07 16:50:13 +08:00
Michael Wright
8f075ec961 Revert update_lints module list generating code
This commit reverts the module list generation code to what it was
before the change to `include!` it and generates better output.
2021-10-07 06:42:21 +02:00
Manish Goregaokar
2a8d7bd0dd Handle intra-doc links in doc_markdown 2021-10-06 08:38:35 -07:00
Manish Goregaokar
d9488c50ce Regen update_lints 2021-10-06 00:12:58 -07:00
Matthias Kaak
320ecb1f0b Mentioned inspect in lint description of suspicious_map 2021-10-05 19:40:15 +00:00
Matthias Kaak
7c82e78f30 improved help message for suspicious_map 2021-10-05 19:09:08 +00:00
hkalbasi
388a3d0983 Implement equatable if let lint 2021-10-04 22:16:42 +03:30
Takayuki Nakata
72f0180f7b Fix ICE in implicit_hasher 2021-10-04 23:31:40 +09:00
bors
63b04f7d7f Auto merge of #7755 - HKalbasi:master, r=xFrednet
exclude enum from derivable impls

fix #7753

changelog: Exclude enum from ``[`derivable_impls`]``
2021-10-03 10:30:16 +00:00
HKalbasi
0ebc656a9a
Change not enum to is struct 2021-10-03 13:01:57 +03:30
hkalbasi
ea8e65f0da exclude enum from derivable impls 2021-10-03 11:58:27 +03:30
Cameron Steffen
e165c12932 Make diangostic item names consistent 2021-10-02 19:38:19 -05:00
Yechan Bae
fb0353b28d Update documentation and name for non_send_fields_in_send_ty lint 2021-10-02 19:22:37 -04:00
Yechan Bae
dfed2e31d5 Do not use full type path in help message 2021-10-01 14:04:20 -04:00
Yechan Bae
4f01656a7d Add ui-test for enable-raw-pointer-heuristic-for-send config 2021-10-01 14:04:20 -04:00
Yechan Bae
08f0aecffd Minor changes from PR feedback 2021-10-01 14:04:20 -04:00
Yechan Bae
427a09ba7b Add configuration for raw pointer heuristic 2021-10-01 14:04:20 -04:00
Yechan Bae
d413e157a5 Look into tuple, array, ADT args in raw pointer heuristic 2021-10-01 14:04:20 -04:00
Yechan Bae
ee74574876 Emit one report for all fields in the same ADT 2021-10-01 14:04:20 -04:00
Yechan Bae
a81a5ad1a8 Update documentation 2021-10-01 14:04:20 -04:00
Yechan Bae
6458630e1a typo 2021-10-01 14:04:20 -04:00
Yechan Bae
d7a9ec2c50 Fix attribute handling 2021-10-01 14:04:20 -04:00
Yechan Bae
e4c3000e5b Initial implementation 2021-10-01 14:04:20 -04:00
bors
fe999e88ed Auto merge of #7741 - surechen:fix_if_then_panic, r=flip1995
Make if_then_panic handle situation of BinOpKind::And || BinOpKind::Or

fixes #7731

Make if_then_panic handle situation of cond.kind = ExprKind::DropTemps(ExprKind::Binary(BinOpKind::And || BinOpKind::Or, left, right), ..) =

changelog: [`if_then_panic`] Fix suggestion for more complex conditions
2021-10-01 10:04:19 +00:00
surechen
41e2c68a6e use sugg::Sugg::maybe_par 2021-10-01 13:13:09 +08:00
Cameron Steffen
8c0e4d5ccf Rewrite shadow lint 2021-09-30 14:07:58 -05:00
Cameron Steffen
99861c0e88 Remove initialization note from shadow lint 2021-09-30 13:54:30 -05:00
Cameron Steffen
89f77f3512 Move shadow_unrelated to restriction 2021-09-30 13:54:28 -05:00
Camille GILLOT
ea60b69ee1 Do not pass hir::Crate to lints. 2021-09-30 17:39:54 +02: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
surechen
4babfae9cb fix issue #7731
Make if_then_else handle situation of cond.kind = ExprKind::DropTemps(ExprKind::Binary(BinOpKind::And || BinOpKind::Or, left, right), ..) =
2021-09-30 19:06:42 +08:00
surechen
56f0c9afdd fix bug for large_enum_variants 2021-09-30 10:07:57 +08:00
Camille GILLOT
3037c40e9a Avoid more invocations of hir_crate query. 2021-09-29 23:16:47 +02:00
Michael Wright
e6747df5cd Fix lint register code format
Also change the generation functions to return `String` instead of
`Vec<String>`. This makes sense now as the updates aren't line oriented
anymore.
2021-09-29 05:46:39 +02:00
Michael Wright
50ea370619 Move code generated by update_lints to includes 2021-09-29 05:43:25 +02:00
vxpm
30ea0a5ebb
Fix typo ("asynx" corrected to "async") 2021-09-28 17:53:12 -03: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
flip1995
23d5457e6d Merge commit 'cb7915b00c235e9b5861564f3be78dba330980ee' into clippyup 2021-09-28 18:03:12 +01: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
flip1995
c2b8882cef
Cleanup of rustup changes 2021-09-28 17:40:06 +01:00
flip1995
d8f453d021
Bump nightly version -> 2021-09-28 2021-09-28 17:39:16 +01: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
flip1995
ec38746b4a
Allow internal lint INVALID_PATHS for itertools path
Since clippy_utils doesn't depend on the itertools crate anymore, the
lint can't find the path.
2021-09-28 17:07:51 +01: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
Manish Goregaokar
13834e6ad2 fmt 2021-09-27 22:33:45 -07:00
Manish Goregaokar
17155c8dca Add renamed lint 2021-09-27 22:26:14 -07:00