rust-clippy icon indicating copy to clipboard operation
rust-clippy copied to clipboard

[WIP] unnecessary_cast: append suffix on `(literal as ty).method(args)`

Open KisaragiEffective opened this issue 2 years ago • 5 comments

Please write a short comment explaining your change (or "none" for internal only changes)

changelog: [unnecessary_cast]: fix handling if it is in method receiver

fix #11882, but it needs help about adding suffix to integral literal. Currently UI tests are not changed, I'll commit it before it become actually reviewable

KisaragiEffective avatar Dec 02 '23 23:12 KisaragiEffective

r? @giraffate

(rustbot has picked a reviewer for you, use r? to override)

rustbot avatar Dec 02 '23 23:12 rustbot

:umbrella: The latest upstream changes (presumably #12365) made this pull request unmergeable. Please resolve the merge conflicts.

bors avatar Feb 27 '24 17:02 bors

@giraffate is currently sadly busy, let's get you a new reviewer

r? clippy

xFrednet avatar Apr 01 '24 10:04 xFrednet

Hey, this is a ping from triage. @y21 can you give this PR a review? It's totally fine if you don't have the time right now, you can reassign the PR to a random team member using r? clippy.

@rustbot ready

xFrednet avatar Jun 20 '24 20:06 xFrednet

I'm not sure what the state of this PR is, it seems like it's not finished yet.

The linked issue mentions that another PR fixed a very similar issue which affects this as well, and the lint today already suggests wrapping it in a block to avoid breaking precedence (I'm not sure why a block was chosen instead of parentheses).

But there's still the problem that { !0 }.overflowing_shr(..) results in an "ambiguous integer type" error, which I assume this PR also fixes by taking a different path in the lint for suggesting (!0_u64) specifically? I checked out your branch and it seems like what's left is expanding the check here to also consider UnOp::Not https://github.com/rust-lang/rust-clippy/blob/0ce07f61db8c9de51e6ecd38aa62eb3145417c0f/clippy_lints/src/casts/unnecessary_cast.rs#L222 With that it seems to make the correct suggestion.

y21 avatar Jun 21 '24 19:06 y21

Hey @KisaragiEffective, this is a ping from triage, since there hasn't been any activity in some time. Are you still planning to continue this implementation?

If you have any questions, you're always welcome to ask them in this PR or on Zulip.

@rustbot author

xFrednet avatar Jul 23 '24 06:07 xFrednet