-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[unconditional_recursion
]: compare by Ty
s instead of DefId
s
#12177
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
r? @Jarcho (rustbot has picked a reviewer for you, use r? to override) |
☔ The latest upstream changes (presumably #12200) made this pull request unmergeable. Please resolve the merge conflicts. |
Thank you. @bors r+ |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
A user observed the unfixed issue in @rustbot label +beta-nominated |
…ulacrum [beta] Clippy backports Backports included in this PR: - rust-lang/rust-clippy#12276 Fixing the lint on some platforms before hitting stable - rust-lang/rust-clippy#12405 Respect MSRV before hitting stable - rust-lang/rust-clippy#12266 Fixing an (unlikely) ICE - rust-lang/rust-clippy#12177 Fixing FPs before hitting stable Each backport on its own might not warrant a backport, but the collection of those are nice QoL fixes for Clippy users, before those bugs hit stable. All of those commits are already on `master`. r? `@Mark-Simulacrum`
Fixes #12154
Fixes #12181 (this was later edited in, so the rest of the description refers to the first linked issue)
Before this change, the lint would work with
DefId
s and use those to compare types. This PR changes it to compare types directly. It fixes the linked issue, but also other false positives I found in a lintcheck run. For example, one of the issues is that some types don't haveDefId
s (primitives, references, etc., leading to possible FNs), and the helper function used to extract aDefId
didn't handle type parameters.Another issue was that the lint would use
.peel_refs()
in a few places where that could lead to false positives (one such FP was in thehttp
crate). See the doc comment on one of the added functions and also the test case for what I mean.The code in the linked issue was linted because the receiver type is
T
(aty::Param
), which was not handled inget_ty_def_id
and returnedNone
, so this wouldn't actually get to comparingself_arg != ty_id
here, and skip the early-return:rust-clippy/clippy_lints/src/unconditional_recursion.rs
Lines 171 to 178 in 70573af
This alone could be fixed by doing something like
&& get_ty_def_id(ty).map_or(true, |ty_id)| self_arg != ty_id)
, but we don't really need to work withDefId
s in the first place, I don't think.changelog: [
unconditional_recursion
]: avoid linting when the other comparison type is a type parameter