KEMBAR78
Workaround for `integer_to_ptr_transmutes` warning by kennykerr · Pull Request #3731 · microsoft/windows-rs · GitHub
Skip to content

Conversation

@kennykerr
Copy link
Collaborator

See https://github.com/microsoft/windows-rs/actions/runs/17277596764/job/49038221132?pr=3730

This new warning seems a little painful.

  • I could use with_exposed_provenance_mut but that requires a higher MSRV.
  • I could allow integer_to_ptr_transmutes but that is an unknown lint to the current MSRV.

So I have to allow both unknown_lints and integer_to_ptr_transmutes.

That does not seem ideal. 🤔

@kennykerr kennykerr merged commit 21708e9 into master Aug 27, 2025
28 checks passed
@kennykerr kennykerr deleted the integer_to_ptr_transmutes branch August 27, 2025 21:59
unsafe { transmute(value << 1) }
#[allow(unknown_lints, integer_to_ptr_transmutes)]
unsafe {
transmute(value << 1)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the documentation of with_exposed_provenance_mut says, it's fully equivalent to an as cast, which I highly recommend using in order to avoid the UB here.

Suggested change
transmute(value << 1)
&mut *((value << 1) as *const Self)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the reminder! #3749

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants