Skip to content

Uplift clippy::mem_discriminant_non_enum into rustc #83899

New issue

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

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

Already on GitHub? # to your account

Closed
Flying-Toast opened this issue Apr 5, 2021 · 4 comments · Fixed by #83908
Closed

Uplift clippy::mem_discriminant_non_enum into rustc #83899

Flying-Toast opened this issue Apr 5, 2021 · 4 comments · Fixed by #83908
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-feature-request Category: A feature request, i.e: not implemented / a PR. T-lang Relevant to the language team

Comments

@Flying-Toast
Copy link
Contributor

The clippy::mem_discriminant_non_enum lint seems like it should be directly in rustc. The lint prevents doing something like:

core::mem::discriminant::<i32>(&4)

which causes unspecified behavior.

@jonas-schievink jonas-schievink added A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-feature-request Category: A feature request, i.e: not implemented / a PR. T-lang Relevant to the language team labels Apr 5, 2021
@Flying-Toast
Copy link
Contributor Author

I'd like to try implementing this myself, if would be likely to be accepted - do people think this would this be useful?

@jyn514
Copy link
Member

jyn514 commented Apr 5, 2021

I think this is a great idea, it's clearly wrong code with no false positives.

@Flying-Toast
Copy link
Contributor Author

Should I make this a hard error instead of a lint?

@jyn514
Copy link
Member

jyn514 commented Apr 5, 2021

No, I think this should be a lint. Hard errors are a breaking change and are almost never accepted except at edition boundaries, and the 2021 edition is not taking new ideas right now.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-feature-request Category: A feature request, i.e: not implemented / a PR. T-lang Relevant to the language team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants