-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Add manual_bits
lint
#8213
Add manual_bits
lint
#8213
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @flip1995 (or someone else) soon. Please see the contribution instructions for more information. |
Oh nice! Thanks for implementing this! (I'm not a clippy reviewer. Just happy to see this getting added. ^^) |
It looks like it triggers for #![warn(clippy::size_of_as_bits)]
use std::mem;
fn main() {
let x = 0u32;
println!("{}", 8 * mem::size_of_val(&x));
}
|
There is also an issue with type aliases. #![warn(clippy::size_of_as_bits)]
use std::mem;
type Word = u32;
fn main() {
println!("{}", 8 * mem::size_of::<Word>());
}
I think the suggestion should be |
The name is a bit funny to me. Perhaps |
I like |
I applied all of the above suggestions |
☔ The latest upstream changes (presumably #8236) made this pull request unmergeable. Please resolve the merge conflicts. |
☔ The latest upstream changes (presumably #8210) made this pull request unmergeable. Please resolve the merge conflicts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also like the manual_bits
name. This is similar to the manual_memcpy
name (and lint).
Small comment for the error message. This will require a cargo dev bless
. Otherwise LGTM.
👍. I also rebased on top of master since #8190 would have broken my code and bumped the |
@bors r+ Thanks! |
📌 Commit 166737f has been approved by |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
I am afraid that in most contexts (especially in match arms), What about using "help: consider using: |
@HaoYang670, what is the point of tacking a comment onto a PR that was merged three months ago? The correct way to get your problem addressed is to create an issue. |
I'll fix the suggestion, that'll probably be faster than creating an issue for it ^^ |
Add `usize` cast to `clippy::manual_bits` suggestion A fix for the suggestion from #8213 changelog: [`manual_bits`]: The suggestion now includes a cast for proper type conversion
Closes #6670
changelog: new lint: [
manual_bits
]