Add manual_ignore_cast_cmp lint#13334
Conversation
|
☔ The latest upstream changes (presumably #13247) made this pull request unmergeable. Please resolve the merge conflicts. |
xFrednet
left a comment
There was a problem hiding this comment.
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.
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.
@xFrednet what's the better way to do this comparison?
There was a problem hiding this comment.
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.
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.
@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
xFrednet
left a comment
There was a problem hiding this comment.
Three small nits, but the rest looks good to me :D
bbcf4bf to
e3b7051
Compare
|
CI is also having some download issues, seems unrelated |
|
@xFrednet hi, anything else left on this one? thx! |
xFrednet
left a comment
There was a problem hiding this comment.
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