Skip to content

Edge case in clippy::multiple_unsafe_ops_per_block #16085

@samueltardieu

Description

@samueltardieu

Summary

The following example identified by @Jarcho in the discussion of #16079 triggers the lint while it probably shouldn't:

#![warn(clippy::multiple_unsafe_ops_per_block)]

union U {
    i: u32,
}

#[clippy::msrv = "1.91"]
fn main() {
    let u = U { i: 0 };
    let pu = &raw const u;
    // The lint should probably not trigger here as we can't break apart the expression
    unsafe {
        _ = (*pu).i;
    }
}

Reproducer

No response

Version

Rust nightly-2025-10-31

Additional Labels

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't have

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions