Skip to content

Lint code that "indexes" generic pointers but doesn't special-case zero-sized types #2260

Open

Description

Basically, it'd be nice to have a lint which checks unsafe code dealing with pointers that indexes them (either by from_raw_parts(...) or *ptr.offset(...)) which doesn't specifically special-case zero-sized types.

This could probably simplified to checking that functions that perform said indexing don't contain any mentions of mem::size_of or similar.

The main idea is that this would lint custom data structures similar to Vec and co. that will not work with zero-sized types. Obviously not a lint that I'd expect to come up very often, but people working in embedded code might run into a problem like this and it's good to point it out and require an #[allow(...)] that acknowledges the risks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-lintArea: New lintsC-an-interesting-projectCategory: Interesting projects, that usually are more involved design/code wise.E-hardCall for participation: This a hard problem and requires more experience or effort to work onT-MIRType: This lint will require working with the MIRT-middleType: Probably requires verifiying types

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions