Commit bcf3c08
authored
### Description
I updated the `useless_conversion` lint to stop applying adjustment
prefixes once it reaches the final target type.
Previously, the lint would continue applying adjustments even after the
type requirements were met, which often resulted in over-borrowed
suggestions like `&**y`. By breaking the loop early once the target type
is reached, we now emit the minimal, idiomatic suggestion (e.g., `*y`).
fixes rust-lang#14847
### Test Plan
I added a targeted UI regression test: `tests/ui/useless_conversion.rs`.
This covers `.into_iter()` usage on nested slice references (`&&[T]`)
and verifies that Clippy now suggests `*items` instead of the previous
incorrect suggestion.
### Checklist
- [x] Added passing UI tests (including committed `.stderr` file)
- [x] `cargo test` passes locally
- [x] Run `cargo dev fmt`
[lint_naming]:
https://rust-lang.github.io/rfcs/0344-conventions-galore.html#lints
---
changelog: [`useless_conversion`]: refine `.into_iter()` suggestions to
stop at the final target type (fixing over-borrowed suggestions like
`&**y`)
File tree
4 files changed
+109
-60
lines changed- clippy_lints/src
- tests/ui
4 files changed
+109
-60
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
456 | 456 | | |
457 | 457 | | |
458 | 458 | | |
459 | | - | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
460 | 466 | | |
461 | 467 | | |
462 | 468 | | |
463 | 469 | | |
464 | 470 | | |
465 | 471 | | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
466 | 478 | | |
467 | 479 | | |
468 | 480 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
131 | 132 | | |
132 | 133 | | |
133 | 134 | | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
134 | 144 | | |
135 | 145 | | |
136 | 146 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
131 | 132 | | |
132 | 133 | | |
133 | 134 | | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
134 | 144 | | |
135 | 145 | | |
136 | 146 | | |
| |||
0 commit comments