-
Couldn't load subscription status.
- Fork 1.8k
Add manual_ignore_cast_cmp lint #13334
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
Conversation
|
☔ The latest upstream changes (presumably #13247) 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.
Solid start, let me know if anything is unclear :D
| let ty = ty_raw.peel_refs(); | ||
| if needs_ref_to_cmp(cx, ty) |
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.
Can you explain these lines?
They feel a bit weird. The peel_refs removes all potential references from the type, which means that some ascii types will fail the needs_ref_to_cmp function even if ty_raw would pass it.
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.
@xFrednet what's the better way to do this comparison?
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 thinking some more on this, and tried to come up with a unit test that would fail, but was not able to do that... are you certain this is an issue?
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 think the naming tripped me up. When using this function you should make sure that the raw type is still a reference. (ty_raw.is_ref() && needs_ref_to_cmp(cx, ty)) should do the trick
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.
@xFrednet I tried your suggestion, but it starts to miss half of the test cases like these:
fn string(a: String, b: String) {
a.to_ascii_lowercase() == b.to_ascii_lowercase();
a.to_ascii_lowercase() == "a";
"a" == b.to_ascii_lowercase();
a.to_ascii_lowercase() == "a";
"a" == b.to_ascii_lowercase();
}
fn ref_string(a: String, b: &String) {
a.to_ascii_lowercase() == b.to_ascii_lowercase();
a.to_ascii_lowercase() == "a";
b.to_ascii_lowercase() == a.to_ascii_lowercase();
"a" == a.to_ascii_lowercase();
}|
☔ The latest upstream changes (presumably #12987) made this pull request unmergeable. Please resolve the merge conflicts. |
f1d859e to
c4f6a20
Compare
|
☔ The latest upstream changes (presumably #13322) made this pull request unmergeable. Please resolve the merge conflicts. |
c4f6a20 to
b86410e
Compare
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.
Three small nits, but the rest looks good to me :D
bbcf4bf to
e3b7051
Compare
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.
thx, updated
|
CI is also having some download issues, seems unrelated |
|
@xFrednet hi, anything else left on this one? thx! |
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.
This version looks good to me! I've also checked and we don't need an MSRV check, since eq_ignore_ascii_case and to_ascii_lowercase have the same MSRV
I created an FCP: https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/FCP.20.60manual_ignore_cast_cmp.60/near/474019623
|
It looks like the FCP passed without comments :D Thank you for the implementation: Roses are red, |
|
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
.stderrfile)cargo testpasses locallycargo dev update_lintscargo dev fmtchangelog: New lint: [
manual_ignore_case_cmp]perf#13334
Closes #13204