-
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
New lint [iter_skip_zero
]
#11046
New lint [iter_skip_zero
]
#11046
Conversation
r? @xFrednet (rustbot has picked a reviewer for you, use r? to override) |
(xFrednet has picked a reviewer for you, use r? to override) |
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.
Very interesting concept for a lint. It has some things I'd like to talk about, but very good overall ❤️
@@ -257,7 +257,7 @@ fn is_cast_from_ty_alias<'tcx>(cx: &LateContext<'tcx>, expr: impl Visitable<'tcx | |||
// Will this work for more complex types? Probably not! | |||
if !snippet | |||
.split("->") | |||
.skip(0) | |||
.skip(1) |
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.
Are we sure this change doesn't break anything? Won't this cause wrong suggestions? Probably the safest bet is to create a FIXME
pointing to this commit and a brief explaination.
Just tested it, indeed .skip(0)
to .skip(1)
produce different results. Playground link
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.
Yep, .skip(0)
does nothing. It's meant to skip anything before ->
as that's known to not be the return type (and results in FPs if it contains ::std::primitive::u32
or the like). I wrote that code before so :D
/// ```rust | ||
/// let v = vec![1, 2, 3]; | ||
/// let x = v.iter().skip(0).collect::<Vec<_>>(); | ||
/// let y = v.iter().collect::<Vec<_>>(); |
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.
Could you re-write this example section so it follows by the general docs. guidelines? (using "Could be written as" and such)
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.
There's a good few others like that (only example, mostly self-explanatory lints)
☔ The latest upstream changes (presumably #11012) made this pull request unmergeable. Please resolve the merge conflicts. |
877daff
to
2604a06
Compare
☔ The latest upstream changes (presumably #10970) made this pull request unmergeable. Please resolve the merge conflicts. |
9ce8868
to
a0b76d4
Compare
☔ The latest upstream changes (presumably #11052) 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.
LGTM, Thanks ❤️ !
@bors r+ |
@blyxyas: 🔑 Insufficient privileges: Not in reviewers |
Life is hard |
@bors r=xFrednet |
@blyxyas: 🔑 Insufficient privileges: Not in reviewers |
Maybe the second delegation overwrote the first one? @Centri3 could you try? |
Maybe, @bors r=blyxyas |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
WTF? So picky that boy Hey @bors be nicer to our newest members. Honer their new power!!! ✨ |
Just for the record, this lint breaks Alacritty. It has code that skips some non-zero amount of characters in one branch but doesn't skip anything in another. The result is stored in the same structure field of the type
|
This lint can be allowed by using an attribute like I'm not seeing how this is an issue, or how a lint can break a project other than generating some new error messages in the CI. |
Probably the fix that breaks it? We should call |
Thank you for the responses! I didn't mean to say that the issue cannot be ignored in the code. My point is that there are legitimate uses of |
Idea came from my contribution to
unnecessary_cast
recently. Sorry about that 😅Could be an issue if somebody manually implements
skip
, but I don't think anybody will (and this would be an issue with other lints too, afaik)changelog: New lint [
iter_skip_zero
]