Skip to content

Commit 18d90c1

Browse files
Update design for PR rust-lang#16139: Add needless_type_cast lint
1 parent 4d6fa3c commit 18d90c1

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

pr-analysis-16139.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# PR #16139: Workflow Design Impact Analysis
2+
3+
## Affected Workflows
4+
5+
None.
6+
7+
**Justification:** The repository does not contain a `.exp/workflows.json` file or any `.exp/design-workflow-*.md` files defining workflows and their designs. Searches for "workflows.json", ".exp", "design-workflow", and "mermaid" yielded no relevant results. Therefore, there are no defined workflows impacted by this PR.
8+
9+
## General Summary of PR Changes
10+
11+
This pull request introduces a new lint named `needless_type_cast` to Rust Clippy. The lint identifies unnecessary type casts in const, static, or let bindings where the binding is defined with one integer type but consistently cast to another type at all usage sites, without any usage of the original type. It recommends defining the binding directly with the target cast type to improve code clarity and avoid redundant casts.
12+
13+
### Key Changes:
14+
- **New Lint Implementation:** Added `clippy_lints/src/casts/needless_type_cast.rs` containing the core logic for detecting and reporting the lint. The implementation checks bindings with explicit type annotations, skips generic contexts, macro expansions, unsafe blocks, and handles control flow and generic return types.
15+
- **Module Updates:** Modified `clippy_lints/src/casts/mod.rs` to expose the new lint and `clippy_lints/src/declared_lints.rs` to declare it officially.
16+
- **Testing:** Added UI tests in `tests/ui/needless_type_cast.rs`, along with corresponding `.fixed` and `.stderr` files to verify the lint's behavior.
17+
- **Documentation:** Updated `CHANGELOG.md` with an entry for the new lint, and refreshed `README.md` and `book/src/README.md` (via cargo dev update_lints).
18+
- **Other:** Bumped Clippy version, fixed Clippy warnings in the new code, and committed updated changelog.
19+
20+
### Recent Commits Overview:
21+
- Initial lint implementation for bindings defined with one type but always cast to another.
22+
- Refinements to handle only explicit type annotations, skip generics and macros.
23+
- Additional fixes for control flow, unsafe blocks, generic returns.
24+
- Documentation and version updates.
25+
26+
This PR follows Clippy's standard procedure for adding new lints, enhancing the tool's ability to detect and suggest improvements for redundant type casting patterns in Rust code. No structural changes to Clippy's build, testing, or development workflows are introduced.
27+
28+
[PR #16139](https://github.com/rust-lang/rust-clippy/pull/16139)

0 commit comments

Comments
 (0)