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

fix(transmute_ptr_to_ptr): add parens if `transmute` is receiver of a projection

Open ada4a opened this issue 4 months ago • 6 comments

Fixes https://github.com/rust-lang/rust-clippy/issues/15003

changelog: [transmute_ptr_to_ptr]: add parens if transmute is receiver of a projection

ada4a avatar Sep 19 '25 23:09 ada4a

r? @y21

rustbot has assigned @y21. 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

rustbot avatar Sep 19 '25 23:09 rustbot

This really applies to all the transmute lints that suggest as, doesn't it...

ada4a avatar Sep 19 '25 23:09 ada4a

This really applies to all the transmute lints that suggest as, doesn't it...

More than that even. I think we should have, at some point, something like:

  • a function which, given an HirId checks whether inserting something in place of this node might need to be parenthesized (even better if it returns an associativity level)
  • a function which, given a suggestion, checks whether it might need to get parentheses (even better if it returns an associativity level)
  • a function which, given an HirId and a suggestion, returns an updated suggestion with added parentheses if this is necessary

samueltardieu avatar Sep 20 '25 08:09 samueltardieu

:umbrella: The latest upstream changes (possibly 45168a79cda13bbc8de32d6b4e304a75f2afb075) made this pull request unmergeable. Please resolve the merge conflicts.

rustbot avatar Nov 22 '25 08:11 rustbot

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

rustbot avatar Dec 11 '25 09:12 rustbot

I think we should have, at some point, something like

But until that, this PR should be merged, right?..

ada4a avatar Dec 11 '25 09:12 ada4a

Reviewer on vacation, let's reroll

r? clippy

ada4a avatar Dec 18 '25 19:12 ada4a