-
Notifications
You must be signed in to change notification settings - Fork 1.7k
WIP: add unnecessary_split_off lint #14814
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
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: André Vennberg <[email protected]>
r? @llogiq |
let &[arg] = args else { | ||
return; | ||
}; | ||
if clippy_utils::is_integer_literal(arg, 0) || clippy_utils::is_integer_const(cx, arg, 0) { |
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.
The latter should be enough. Each literal is also a const
|
||
let vec5: Vec<_> = vec1.split_off(const { 0 }); | ||
//~^ unnecessary_split_off | ||
|
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'd also like to test
let zero = 0;
let vec6 = vec1.split_off(zero);
So you should look into |
This comment has been minimized.
This comment has been minimized.
☔ The latest upstream changes (possibly b379d54) made this pull request unmergeable. Please resolve the merge conflicts. |
Thank you for making Clippy better!
We're collecting our changelog from pull request descriptions.
If your PR only includes internal changes, you can just write
changelog: none
. Otherwise, please write a short commentexplaining your change.
It's also helpful for us that the lint name is put within backticks (
` `
),and then encapsulated by square brackets (
[]
), for example:If your PR fixes an issue, you can add
fixes #issue_number
into thisPR description. This way the issue will be automatically closed when
your PR is merged.
If you added a new lint, here's a checklist for things that will be
checked during review or continuous integration.
.stderr
file)cargo test
passes locallycargo dev update_lints
cargo dev fmt
Note that you can skip the above if you are just opening a WIP PR in
order to get feedback.
Delete this line and everything above before opening your PR.
fixes #4953
Please write a short comment explaining your change (or "none" for internal only changes)
changelog: