Skip to content

invalid_value misses some clearly bad enum initialization #102043

Closed
@RalfJung

Description

@RalfJung

The invalid_value lint has no issue with the following type being zero-initialized or left uninit:

enum OneFruitNonzero {
    Apple(!),
    Banana(NonZeroU32),
}

That seems like a case we should be able to handle.

I think for non-is_multi_variant enums, we probably can compute the variant that does exist, and then we can recursively check if that one is valid? We'd also need a smarter is_multi_variant that can handle some dataful variants (ensuring they are definitely inhabited).

Cc @5225225

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions