Skip to content

linkme::distributed_slice: unsafe-attr-outside-unsafe 2024 compat lint is unfixable #101

@smalis-msft

Description

@smalis-msft

Attempting to combine linkme::distributed_slice and the Rust 2024 compat lint currently results in warnings from the distributed_slice attribute. There also doesn't seem to be a way to fix this currently as applying the suggestion, or just wrapping everything in unsafe, simply results in this more comical output:

warning: unsafe attribute used without unsafe
    --> flowey/flowey_core/src/node.rs:2274:5
     |
2274 |     #[unsafe(linkme::distributed_slice)]
     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ usage of unsafe attribute
...
2279 |     #[unsafe(linkme::distributed_slice(FLOW_NODES))]
     |     ------------------------------------------------ in this procedural macro expansion
     |
     = warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024!
     = note: for more information, see issue #123757 <https://github.com/rust-lang/rust/issues/123757>
     = note: `-W unsafe-attr-outside-unsafe` implied by `-W rust-2024-compatibility`
     = help: to override `-W rust-2024-compatibility` add `#[allow(unsafe_attr_outside_unsafe)]`
     = note: this warning originates in the macro `FLOW_NODES` which comes from the expansion of the attribute macro `linkme::distributed_slice` (in Nightly builds, run with -Z macro-backtrace for more info)
help: wrap the attribute in `unsafe(...)`
     |
2274 |     #[unsafe(unsafe(linkme::distributed_slice))]
     |       +++++++                                 +

Link to the code in question: https://github.com/microsoft/openvmm/blob/4623aef65c6726ee491423eb050d1fa2e11210e0/flowey/flowey_core/src/node.rs#L2274

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions