Skip to content

cast_ptr_alignment should not call out ZST -> to other pointers #4256

Closed
@skade

Description

@skade
(&1u32 as *const u32 as *const ()) as *const u32;

Is currently caught by cast_ptr_alignment.

I discussed this with @Manishearth last night and we came to the conclusion that we don't have enough information at this point to lint this case. It's a common pattern to cast from ZST pointers to larger types and the lint will always trigger here. We have to assume here that the user knows where the pointer was produced. We can't draw any conclusions from the left-hand pointer.

The situation is similar to c_void, which is already ignored.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions