-
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
Fix false positive in write_literal and print_literal (numeric literals) #6408
Conversation
r? @ebroto (rust-highfive has picked a reviewer for you, use r? to override) |
Fixes #6335 |
Error: The feature Please let |
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.
Just some nits.
Also, the reference file for the tests needs to be updated because the stderr
files have changed, as we are not linting if the literals are ints/floats. To do this, you can run the tests/ui/update-all-references.sh
script.
clippy_lints/src/write.rs
Outdated
ExprKind::Lit(lit) | ||
if match lit.kind { | ||
LitKind::Int(_, _) | LitKind::Float(_, _) => false, | ||
_ => 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.
ExprKind::Lit(lit) | |
if match lit.kind { | |
LitKind::Int(_, _) | LitKind::Float(_, _) => false, | |
_ => true, | |
} => | |
ExprKind::Lit(lit) if !matches!(lit.kind, LitKind::Int(..) | LitKind::Float(..)) => { |
We can simplify using matches!()
clippy_lints/src/write.rs
Outdated
if match lit.kind { | ||
LitKind::Int(_, _) | LitKind::Float(_, _) => false, | ||
_ => 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.
if match lit.kind { | |
LitKind::Int(_, _) | LitKind::Float(_, _) => false, | |
_ => true, | |
}; | |
if !matches!(lit.kind, LitKind::Int(..) | LitKind::Float(..)); |
Same here
ping from triage @pro-grammer1. There seems to be some fixes left to be done. Do you have any questions on how to preceed here? |
ping from triage @pro-grammer1. According to the triage procedure, I close this because there has no activity in 2 weeks from previous ping. If you have more time to work on this, feel free to reopen. |
I've made the changes, so I would like to reopen this. |
Thanks for taking time to work on this! I reopen this. |
I've made the suggested changes and updated the tests. Is there anything else I should do? |
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.
Oli was faster, but I have a comment anyway 😄
--> $DIR/ice-3891.rs:2:5 | ||
| | ||
LL | 1x; | ||
| ^^ invalid suffix `x` | ||
| | ||
= help: the suffix must be one of the integral types (`u32`, `isize`, etc) | ||
= help: the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.) |
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.
Why did this change? This is a rustc lint and should be unaffected by a Clippy PR. (rebase gone wrong?)
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 was wondering the same thing... but since CI is passing... I guess this is the lack of a rebase? (master has this change already) Like this change will go away when rebased over master. Though that does make me wonder how git managed to not treat this as a conflict... I guess because the change is exactly the same.
@bors r+ |
📌 Commit 32b2a3f has been approved by |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
changelog: No longer lint numeric literals in [
write_literal
] and [print_literal
].Fixes #6335