Commit Graph

17110 Commits

Author SHA1 Message Date
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
y21
bbb9204008 add test 2023-06-09 15:49:35 +02:00
bors
05de787089 Auto merge of #10913 - y21:issue10033, r=Manishearth,Centri3
[`unnecessary_to_owned`]: check that the adjusted type matches target

Fixes #10033.

Before this change, the lint would assume that removing the `.to_string()` in `f(&x.to_string())` would be ok if x is of some type that implements `Deref<Target = str>` and `f` takes a `&str`.
This turns out to not actually be ok if the `to_string` call is some method that exists on `x` directly, which happens if it implements `Display`/`ToString` itself.

changelog: [`unnecessary_to_owned`]: only lint if the adjusted receiver type actually matches
2023-06-09 08:52:44 +00:00
y21
85002b09a1 handle exponent without digits 2023-06-09 05:21:24 +02:00
y21
dd084940de check that the adjusted receiver type matches target 2023-06-09 04:13:00 +02:00
bors
384cf37612 Auto merge of #10910 - Alexendoo:unnecessary-pointer-casts, r=llogiq
Ignore more pointer types in `unnecessary_cast`

Spotted this because

e2c655b4c0/tests/ui/suspicious_to_owned.rs (L9-L10)

currently fails on `aarch64-unknown-linux-gnu` as `c_char` is `u8` there

The current implementation checks for `as alias`, `as _`. This adds things like
- `as *const alias`
- `as *const cfg_dependant`
- `as *const _`

changelog: none
2023-06-08 19:38:12 +00:00
Alex Macleod
4346c992cb Ignore more pointer types in unnecessary_cast 2023-06-08 18:19:35 +00:00
bors
e2c655b4c0 Auto merge of #10909 - Alexendoo:useless-for-in-vec, r=llogiq
Fix `useless_vec` suggestion in `for _ in vec![..]`

Fixes https://github.com/rust-lang/rust/issues/111034
Fixes #2256

changelog: [`useless_vec`]: Fix suggestion in `for _ in vec![..]`
2023-06-08 17:52:25 +00:00
Alex Macleod
96697d2ee7 Fix useless_vec suggestion in for _ in vec![..] 2023-06-08 17:27:12 +00:00
Alex Macleod
46808be16f Direct towards late passes in cargo dev new_lint 2023-06-08 15:56:42 +00:00
Centri3
6afb3555d3 remove revisions 2023-06-08 10:15:58 -05:00
bors
b7c330fc78 Auto merge of #10905 - y21:issue10684, r=Alexendoo
[`redundant_closure`]: special case inclusive ranges

Fixes #10684.

`x..=y` ranges need a bit of special handling in this lint because it desugars to a call to the lang item `RangeInclusiveNew`, where the callee span would be the same as the range expression itself, so the suggestion looked a bit weird. It now correctly suggests `RangeInclusive::new`.

changelog: [`redundant_closure`]: special case `RangeInclusive`
2023-06-08 12:15:35 +00:00