Commit Graph

9587 Commits

Author SHA1 Message Date
Centri3
d2725402a9 [borrow_as_ptr]: Ignore temporaries 2023-06-13 17:53:36 -05:00
bors
72332b2598 Auto merge of #10944 - GuillaumeGomez:cleanup-needless-pass-by-value, r=xFrednet
Remove dead code in `needless_pass_by_value`

The `spans_need_deref` is never used so I removed it alongside all linked code as well.

changelog: none
2023-06-13 15:58:10 +00:00
Guillaume Gomez
bcaf655b70 Remove dead code in needless_pass_by_value 2023-06-13 17:08:51 +02:00
blyxyas
d5b2f11340
Now cargo collect-metadata updates the CHANGELOG.md 2023-06-13 16:52:18 +02:00
bors
8a1f0cd765 Auto merge of #10935 - Alexendoo:needless-if-cases, r=Manishearth
Don't lint non-statement/faux empty `needless_if`s

Also has a basic fall-back for `if` statements that have attributes applied to them and incorporates https://github.com/rust-lang/rust-clippy/pull/10921#pullrequestreview-1474008780 while I was there

r? `@Manishearth`

changelog: none
2023-06-13 04:34:37 +00:00
bors
7c2bf28365 Auto merge of #10358 - pksunkara:unnecessary-unwrap, r=llogiq
Add `unnecessary_literal_unwrap` lint

Add lint for more unnecessary unwraps and suggest fixes for them.

Fixes #10352

- [x] Followed [lint naming conventions][lint_naming]
- [x] Added passing UI tests (including committed `.stderr` file)
- [x] `cargo test` passes locally
- [x] Executed `cargo dev update_lints`
- [x] Added lint documentation
- [x] Run `cargo dev fmt`

r? `@llogiq`

---

changelog: New lint [`unnecessary_literal_unwrap`]
[#10358](https://github.com/rust-lang/rust-clippy/pull/10358)
<!-- changelog_checked -->
2023-06-12 18:04:22 +00:00
bors
da56c3502a Auto merge of #10933 - y21:issue2262-followup, r=Centri3
[`useless_vec`]: lint on `vec![_]` invocations that adjust to a slice

Fixes #2262 (well, actually my PR over at #10901 did do most of the stuff, but this PR implements the one last other case mentioned in the comments that my PR didn't fix)

Before this change, it would lint `(&vec![1]).iter().sum::<i32>()`, but not `vec![1].iter().sum::<i32>()`. This PR handles this case.
This also refactors a few things that I wanted to do in my other PR but forgot about.

changelog: [`useless_vec`]: lint on `vec![_]` invocations that adjust to a slice
2023-06-12 16:25:59 +00:00
Pavan Kumar Sunkara
6e4c5561be Preserve type annotations when present 2023-06-12 16:19:26 +01:00
Pavan Kumar Sunkara
6e4dc93e24 Support suggesting panics 2023-06-12 16:19:26 +01:00
Pavan Kumar Sunkara
69af0e13b2 Recognize Err 2023-06-12 16:19:26 +01:00
rsdy
6e0e09c8f7 Track init and unwrap of expr 2023-06-12 16:19:26 +01:00
Pavan Kumar Sunkara
7ed7283e0f Recognize unwrap_or_else method 2023-06-12 16:19:26 +01:00
Pavan Kumar Sunkara
8f83502989 Recognize unwrap_or methods 2023-06-12 16:19:26 +01:00
rsdy
1d159e7d11 Recognize Ok 2023-06-12 16:19:26 +01:00
Pavan Kumar Sunkara
daf6197481 Implement the suggestion 2023-06-12 16:19:26 +01:00
Pavan Kumar Sunkara
21b88ce290 Implement the lint for expect 2023-06-12 16:19:26 +01:00
Pavan Kumar Sunkara
0b1bb5fbf3 Implement the lint 2023-06-12 16:19:26 +01:00
Pavan Kumar Sunkara
2902359b3c Add the lint to the lib 2023-06-12 16:19:26 +01:00
rsdy
5bb768177e Add hook 2023-06-12 16:19:26 +01:00
Pavan Kumar Sunkara
e707447a86 Boilerplate for the new lint 2023-06-12 16:19:26 +01:00
Alex Macleod
5e20a572ee Don't lint non-statement/faux empty needless_ifs 2023-06-12 15:19:00 +00:00
y21
b309875fd8 [useless_vec]: detect unnecessary vec![_] 2023-06-12 15:48:04 +02: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
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
Centri3
29c1c6e104 refactor and add link to issue 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
Centri3
108c04acf0 Stop visiting once it's found Let 2023-06-11 09:43:26 -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
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
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