Skip to content

chore: Fix 1.88.0 clippy lints #4872

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 27, 2025
Merged

Conversation

tobias-wilfert
Copy link
Member

@tobias-wilfert tobias-wilfert commented Jun 27, 2025

@tobias-wilfert tobias-wilfert self-assigned this Jun 27, 2025
@@ -135,7 +135,7 @@ impl From<Uuid> for RelayUuid {
#[unsafe(no_mangle)]
#[relay_ffi::catch_unwind]
pub unsafe extern "C" fn relay_uuid_is_nil(uuid: *const RelayUuid) -> bool {
if let Ok(uuid) = Uuid::from_slice(unsafe { &(*uuid).data[..] }) {
if let Ok(uuid) = Uuid::from_slice(unsafe { &(&(*uuid).data)[..] }) {
Copy link
Member

Choose a reason for hiding this comment

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

This looks like the wrong fix, as the lint suggets:

       --> relay-cabi/src/core.rs:138:50
        |
    138 |     if let Ok(uuid) = Uuid::from_slice(unsafe { &(*uuid).data[..] }) {
        |                                                  ^^^^^^^^^^^^^^^^
        |
        = note: creating a reference requires the pointer target to be valid and imposes aliasing requirements
        = note: `#[warn(dangerous_implicit_autorefs)]` on by default
    help: try using a raw pointer method instead; or if this reference is intentional, make it explicit
        |
    138 |     if let Ok(uuid) = Uuid::from_slice(unsafe { &(&(*uuid).data)[..] }) {
        |                                                  ++            +

Can we not avoid the reference?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think replacing the from_slice calls with

Uuid::from_bytes(unsafe { (*uuid).data })

should do the trick. Also simplifies things a bit because from_bytes is not fallible (it takes the correct length by definition).

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh nice, was trying to use u128 but that turns out does not have a stable ABI (today I learned)

@tobias-wilfert tobias-wilfert changed the title fix: Lints chore: Fix 1.88.0 clippy lints Jun 27, 2025
@tobias-wilfert tobias-wilfert force-pushed the tobias-wilfert/fix/lints branch from dcd043e to 03fd8ea Compare June 27, 2025 07:58
@tobias-wilfert tobias-wilfert marked this pull request as ready for review June 27, 2025 08:55
@tobias-wilfert tobias-wilfert requested a review from a team as a code owner June 27, 2025 08:55
@tobias-wilfert tobias-wilfert added this pull request to the merge queue Jun 27, 2025
Merged via the queue into master with commit db3be2b Jun 27, 2025
30 checks passed
@tobias-wilfert tobias-wilfert deleted the tobias-wilfert/fix/lints branch June 27, 2025 09:17
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.

3 participants