-
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
unconditional_recursion lint is confused by (at least) blanket PartialEq impls #12181
Comments
This looks like the same underlying issue as #12154, so this will be fixed by #12177. For
This is because the code for Adding this as a test case to the PR. |
A user observed this in @rustbot label +beta-nominated |
...wait, that belongs on the PR, not the issue, sorry. @rustbot label -beta-nominated |
Summary
So, I am writing an hwloc binding and in various circumstances hwloc hands me over C allocations that I am supposed to free using their routine of choice.
Our concern today is a C allocation that contains an XML string, which I model using an RAII type that has an explicit conversion to Rust string, and can be compared with either itself or any other type that can be compared with a Rust string using a pair of PartialEq impls based on the aforementioned explicit conversion.
The second PartialEq impl (which, as it turns out, did not quite do what I want and is going to be fixed) is wrongly flagged as unconditionally recursive by the unconditional_recursion lint, when actually it is fine.
I suspect that happens because the unconditional_recursion lint somehow does not understand that I'm calling the PartialEq impl of
&str
, not recursing into the PartialEq impl ofXML<'_>
. If so, the bug may not lie in PartialEq-specific logic, but in more general trait bound processing. Another thing that fuels my suspicion that this isn't a problem with PartialEq specific code is that the lint is not triggered if I replace the explicit.eq()
call with an equivalent==
operator expression.Lint Name
unconditional_recursion
Reproducer
This simplified reproducer...
...triggers the
unconditional_recursion
lint:Because a different PartialEq implementation is called, the program is actually not unconditionally recursive, as you can check by running it. So I would expect clippy not to trigger this lint, which is incorrect in this particular situation.
Version
Additional Labels
@rustbot label +C-bug +I-false-positive +L-suspicious
The text was updated successfully, but these errors were encountered: