-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Warn on repr
without hints
#51401
Warn on repr
without hints
#51401
Changes from 1 commit
36381fa
2c7099b
3580de8
48e45ee
451eb66
9a80c2b
b3810f6
3cc09c8
0e3f19d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -696,7 +696,9 @@ impl EarlyLintPass for BadRepr { | |
let mut warn = if let Some(ref lit) = attr.value_str() { | ||
// avoid warning about empty `repr` on `#[repr = "foo"]` | ||
let sp = match format!("{}", lit).as_ref() { | ||
"C" | "packed" | "rust" | "u*" | "i*" | "transparent" => { | ||
| "C" | "packed" | "rust" | "transparent" | ||
| "u8" | "u16" | "u32" | "u64" | "u128" | ||
| "i8" | "i16" | "i32" | "i64" | "i128" => { | ||
let lo = attr.span.lo() + BytePos(2); | ||
let hi = attr.span.hi() - BytePos(1); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So, this skips the leading There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that such span operations break down in the presence of macros. We've had some pain with those in clippy. It's usually better to have less prettier ^^^^^^^^^ in the non-macro case than to throw up a bunch of macro internals at the user. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's to be 100% confident that the suggested code will be correct like in the following case:
In the cases where we're not suggesting anything
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't really follow. I guess it might explain why these calculations are only done in one branch, but why are they done at all? Why try to exclude the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I though that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think |
||
suggested = true; | ||
|
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.
usize, isize, too
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.
Done