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

Uplift clippy::mem_discriminant_non_enum into rustc #83899

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, which will review and decide on the PR/issue.

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, which will review and decide on the PR/issue. 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.

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-feature-request Category: A feature request, i.e: not implemented / a PR. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants