Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

invalid_value misses some clearly bad enum initialization #102043

Closed
RalfJung opened this issue Sep 20, 2022 · 2 comments · Fixed by #102281
Closed

invalid_value misses some clearly bad enum initialization #102043

RalfJung opened this issue Sep 20, 2022 · 2 comments · Fixed by #102281
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug.

Comments

@RalfJung
Copy link
Member

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

@RalfJung
Copy link
Member Author

Will be fixed by #102281

@Rageking8
Copy link
Contributor

@rustbot label +C-bug +A-lint

@rustbot rustbot added A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. labels Sep 26, 2022
@bors bors closed this as completed in 8d2faa2 Sep 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants