Skip to content

Conversation

@borngraced
Copy link

@borngraced borngraced commented Nov 23, 2025

Clippy should warn when a const, static, or let binding is defined as one integer type but immediately/ consistently cast to another type at usage sites without any usage of the original type. fixes #16137

changelog: [needless_type_cast ]: suggests defining bindings as their cast type

@rustbot rustbot added needs-fcp S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Nov 23, 2025
@rustbot
Copy link
Collaborator

rustbot commented Nov 23, 2025

r? @dswij

rustbot has assigned @dswij.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@github-actions
Copy link

github-actions bot commented Nov 23, 2025

Lintcheck changes for 48f7f36

Lint Added Removed Changed
clippy::needless_type_cast 8 0 0

This comment will be updated if you push new changes

@ada4a
Copy link
Contributor

ada4a commented Nov 25, 2025

Looking at Lintcheck, at least the prost warnings seem to be FPs, let len: usize = iter.sum(); len as u64 is necessary, as iter is an Iterator<Item=usize>, and so can't be .sum()-ed up to a u64.

Judging by the comment in rustix, the warning seems to be a FP as well, because let fd: libc::c_int = fd; is effectively a cast, though I'm not fully sure about this one.

I don't really know how one would go on about recognizing such FPs, so maybe this lint would just need to be pedantic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-fcp S-waiting-on-review Status: Awaiting review from the assignee but also interested parties

Projects

None yet

Development

Successfully merging this pull request may close these issues.

needless_type_cast suggests defining bindings as their cast type

4 participants