Skip to content

undocumented_unsafe_blocks can be broken by rustfmt #13024

Open
@clarfonthey

Description

@clarfonthey

Summary

Consider the following code:

// SAFETY: trust me ok
long_var_name = unsafe {
    /* ... */
};

Normally, rustfmt will either leave the unsafe block as above or convert this into the following, depending on its length:

// SAFETY: trust me ok
long_var_name = unsafe { /* ... */ };

However, in rare cases, if /* ... */ is exactly the right length, rustfmt will emit:

// SAFETY: trust me ok
long_var_name =
    unsafe { /* ... */ };

Which breaks the undocumented_unsafe_blocks lint, since the comment isn't immediately before the line with unsafe. It should accept cases like this.

Lint Name

undocumented_unsafe_blocks

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