-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Lint for bool to integer casts in cast_lossless
#7948
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @llogiq (or someone else) soon. Please see the contribution instructions for more information. |
Just realised this lint doesn't seem to check for the MSRV. Looks like all the Worth adding a MSRV check for the bools? |
325f1d5
to
6e84f00
Compare
The linting part looks really thoughtfully done. Great job! However, I think the lint message doesn't exactly fit the cast. I doubt we ever get to the point where we get a So I think we should change the message for bool → int casts. |
True, but then again, I can't really think of a better message. It can become silently lossy if you change the type (of the bool). But yeah, you're right, there's no possible change of the right hand side which would make it invalid.
perhaps? None of those seem obviously better than just leaving the message as is to me. |
I'm currently short on time, but I'll think of something. |
I don't think it's very likely that someone changes a value from bool to some integer type while forgetting some
|
Okay, that's changed. I used a literal |
That's totally OK. No need to duplicate the suggestion. Thank you! @bors r+ |
📌 Commit d4c8cb6 has been approved by |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
The lint description says
Which is strictly speaking being violated here, but it seems within the spirit of the lint. I think it is still a useful lint to have, and having a different lint for just this feels excessive. Thoughts?
Fixes #7947
changelog: Lint for bool to integer casts in [
cast_lossless
]