Commit graph

17122 commits

Author SHA1 Message Date
Centri3
830d307d0a refactor a bit 2023-06-14 08:41:20 -05:00
Centri3
6702c7a7a6 Add lint [single_range_in_vec_init] 2023-06-12 11:09:52 -05:00
bors
b095247ab6 Auto merge of #10911 - lochetti:fix_9657, r=Alexendoo
Don't linting `as_conversions` in proc macros

Don't linting `as_conversions` if code was generated by procedural macro.

This PR fixes https://github.com/rust-lang/rust-clippy/issues/9657

I implemented the fix changing the lint code to be a `LateLintPass` in order to be able to use the `is_from_proc_macro` out of the box. If the reviwer thinks that it would be better to do the other way (implementing `WithSearchPat`) just let me know. I might need some help in implementing it for the `ustc_ast::ast::Expr`

changelog: [`as_conversions`] avoiding warnings in macro-generated code
2023-06-12 12:28:36 +00:00
bors
ebafbfcf35 Auto merge of #10827 - y21:large-stack-frames, r=dswij
new lint: `large_stack_frames`

This implements a lint that looks for functions that use a lot of stack space.

It uses the MIR because conveniently every temporary gets its own local and I think it maps best to stack space used in a function.
It's probably going to be quite inaccurate in release builds, but at least for debug builds where opts are less aggressive on LLVM's side I think this is accurate "enough".

(This does not work for generic functions yet. Not sure if I should try to get it working in this PR or if it could land without it for now and be added in a followup PR.)

I also put it under the nursery category because this probably needs more work...

changelog: new lint: [`large_stack_frames`]
2023-06-12 12:16:28 +00:00
y21
6ad7c6f4e6 update lint_configuration.md 2023-06-12 12:21:38 +02:00
y21
c8c7a3c79c fix rebase weirdness 2023-06-12 12:21:38 +02:00
y21
de7d43bc61 make lint description easier to read, prevent ICE 2023-06-12 12:21:38 +02:00
y21
7aa4babb5c rename "drawbacks" to "known issues" 2023-06-12 12:21:38 +02:00
y21
6b232fdee9 use span_lint_and_note 2023-06-12 12:21:38 +02:00
y21
52c6ef77fd fmt 2023-06-12 12:21:38 +02:00
y21
760f91f895 cargo dev update_lints 2023-06-12 12:21:38 +02:00
y21
7312a93a06 new lint: large_stack_frames 2023-06-12 12:21:38 +02:00
bors
a3b185b60a Auto merge of #10916 - Centri3:single_letter_idents, r=blyxyas,xFrednet
New lint [`min_ident_chars`]

Closes #10915

This also implements `WithSearchPat` for `Ident`, as I was going to rewrite this as a late lint to optionally ignore fields and/or generics but this was more complex than anticipated

changelog: New lint [`min_ident_chars`]
[#10916](https://github.com/rust-lang/rust-clippy/pull/10916)
2023-06-12 08:40:17 +00:00
Centri3
29c1c6e104 refactor and add link to issue 2023-06-12 03:22:01 -05:00
Centri3
203e875189 cargo collect-metadata 2023-06-12 03:22:01 -05:00
Centri3
95d1bff225 add to tests and configuration 2023-06-12 03:22:01 -05:00
Centri3
243943ff56 make it work for locals as well
oopos
2023-06-12 03:22:01 -05:00
Centri3
7cdd87ca4a ignore generics and allow arbitrary threshold 2023-06-12 03:22:01 -05:00
Centri3
03c8db048e make cargo test pass + example 2023-06-12 03:21:43 -05:00
Centri3
e2ecb132a5 rename the lint 2023-06-12 03:21:43 -05:00
Centri3
52cfc997af Add lint single_letter_idents 2023-06-12 03:21:43 -05:00
bors
903fe3b9f2 Auto merge of #10894 - Centri3:type_repetition_in_bounds, r=blyxyas,xFrednet
[`type_repetition_in_bounds`]: Don't lint on derived code

fixes #10504.

changelog: [`type_repetition_in_bounds`]: Don't lint on derived code
2023-06-12 07:18:39 +00:00
bors
841f2199e0 Auto merge of #10416 - Jarcho:explicit_iter_loop_ext, r=Manishearth
Extend `explicit_iter_loop` and `explicit_into_iter_loop`

fixes #1518

Some included cleanups
* Split `for_loop` test into different files for each lint (partially).
* Move handling of some `into_iter` cases from `explicit_into_iter`.

---

changelog: Enhancement: [`explicit_iter_loop`]: Now also handles types that implement `IntoIterator`.
[#10416](https://github.com/rust-lang/rust-clippy/pull/10416)

changelog: Sugg: [`explicit_into_iter_loop`]: The suggestion now works on mutable references.
[#10416](https://github.com/rust-lang/rust-clippy/pull/10416)
<!-- changelog_checked -->
2023-06-12 05:30:32 +00:00
bors
21e6235b4c Auto merge of #10921 - Centri3:needless_if, r=blyxyas,Manishearth
Add `needless_if` lint

first off: Sorry about the large diff. Seems a ton of tests do this (understandably so).

this is basically everything I wanted in #10868, while it doesn't lint *all* unnecessary empty blocks, it lints needless if statements; which are basically the crux of the issue (for me) anyway. I've committed code that includes this far too many times 😅 hopefully clippy can help me out soon

closes #10868

changelog: New lint [`needless_if`]
2023-06-12 04:18:50 +00:00
bors
edaf7401e4 Auto merge of #10927 - Centri3:unnecessary_cast, r=Manishearth
Ignore more type aliases in unnecessary_cast

Fixes #10555

changelog: [`unnecessary_cast`]: No longer lints cast from locals that are type aliases
2023-06-12 03:48:37 +00:00
Centri3
4191de3303 Update check_proc_macro.rs 2023-06-11 14:52:26 -05:00
Centri3
108c04acf0 Stop visiting once it's found Let 2023-06-11 09:43:26 -05:00
Centri3
d989f432a4 Update needless_if.fixed 2023-06-11 07:12:46 -05:00
Centri3
3822441335 Update unnecessary_cast.stderr 2023-06-11 07:06:44 -05:00
Centri3
59bca098f9 don't lint on if let
don't lint on `if let`
2023-06-11 07:02:20 -05:00
Centri3
4c7bc1785d ignore more type aliases in unnecessary_cast
ignore more type aliases in unnecessary_cast
2023-06-11 06:59:01 -05:00
Centri3
b2bdc37a55 add description
add description
2023-06-11 05:46:18 -05:00
bors
f93df98b84 Auto merge of #10914 - y21:issue10912, r=giraffate
handle exponent without digits in `numeric_literal`

Fixes #10912

The numeric literal util module didn't check for exponents with no digits.
So:
384cf37612/clippy_utils/src/numeric_literal.rs (L163-L168)

`exponent` here would be the empty string, which passed the `!= "0"` check (when it shouldn't have, it should probably be treated as if the user wrote `E0`), then later fails when counting the digits and subtracting one (0 - 1 = overflow).

Also, interestingly I can't even write a test for this because exponents with no digits is some kind of error by itself and `cargo dev fmt` fails on it.

changelog: [`unreadable_literal`]: don't (debug) ICE on numeric literal with empty exponent
2023-06-11 02:43:45 +00:00
bors
ff3b49cfcb Auto merge of #10907 - Alexendoo:dev-new-lint-late-passes, r=Jarcho
Direct towards late passes in `cargo dev new_lint`

changelog: none

This would be the tooling part of #9311

- `--pass late` is now the default
- It prints a message recommending the use of a late pass if you choose `--pass early`
2023-06-10 18:29:29 +00:00
Centri3
7ba904245d make cargo test pass 2023-06-10 09:39:53 -05:00
bors
e986b6444e Auto merge of #10917 - Centri3:module_inception, r=xFrednet
allow disabling module inception on private modules

Fixes #10842

changelog: Enhancement [`module_inception`]: Added `allow-private-module-inception` configuration.
[#10917](https://github.com/rust-lang/rust-clippy/pull/10917)
<!-- changelog_checked -->
2023-06-10 13:21:48 +00:00
Centri3
b303e2053c allow disabling module inception on private modules
allow disabling module inception on private modules
2023-06-10 08:09:07 -05:00
bors
9011c4d248 Auto merge of #10918 - Centri3:patch-2, r=xFrednet
Fix `excessive_nesting` example

whoops 😅

changelog: none
2023-06-10 13:06:44 +00:00
Centri3
26f50395ba Add needless_if lint 2023-06-10 06:51:03 -05:00
Jason Newcomb
949712c90a Reborrow mutable references in explicit_iter_loop 2023-06-09 21:40:03 -04:00
Jason Newcomb
482baf2bcc Fix explicit_into_iter_loop with mutable references 2023-06-09 21:40:03 -04:00
Jason Newcomb
974900b50e Split for_loops tests 2023-06-09 21:39:58 -04:00
bors
d44ea7c5c5 Auto merge of #10785 - Centri3:diverting_sub_expression, r=Jarcho
Fix `diverging_sub_expression` not checking body of block

Fixes #10776

This also adds a warning to the test `ui/never_loop.rs`, not sure if this is correct or not.

changelog: [`diverging_sub_expression`]: Fix false negatives with body of block
2023-06-10 00:16:43 +00:00
Jason Newcomb
b6fa4d43d3 Extend explicit_iter_loop to all types 2023-06-09 19:24:55 -04:00
Catherine
d1957b87c8
Update excessive_nesting.rs 2023-06-09 16:29:34 -05:00
Catherine
b7fedb88cf
Update excessive_nesting.rs 2023-06-09 16:28:01 -05:00
bors
476efe92e7 Auto merge of #10672 - Centri3:excessive-width-lints, r=Alexendoo
Add `excessive_nesting` lint

changelog: new lint [`excessive_nesting`]
2023-06-09 20:47:06 +00:00
Centri3
35aff1ae86 refactor 2023-06-09 15:32:42 -05:00
Centri3
c1c134a288 ensure there are no stmts for expr check 2023-06-09 11:44:59 -05:00
Centri3
0c545c7bcc also lint single expression blocks
Update mixed_read_write_in_expression.rs

Update diverging_sub_expression.stderr
2023-06-09 11:44:59 -05:00