Description
I tried to read the code of the lint for over an hour and couldn't really follow what it is doing. I was also able to remove large junks of code from the visitor and the tests kept passing. This signals to me that the logic the lint code is following isn't really tested.
The tests that are there could mostly also be linted with simpler linting code. Also there is a test, that with slight modifications produces a FP:
rust-clippy/tests/ui/only_used_in_recursion.rs
Lines 28 to 38 in b3bd03a
If you add a if c >= 10 { return 4; }
at the top of the function, you still get the lint. But removing the b
argument changes the semantics of the function (i.e. you won't be able to get the same behavior). Playground
I think we should just bail out if the parameter is used anywhere other than directly as its own function argument.
I also have the suspicion that this lint might be a significant perf regression for Clippy.
I think we should move this lint to nursery and not run it if the lint is allowed for now. I like this lint in general, but I think in the current state it is over engineered and not really maintainable.
Originally posted by @flip1995 in #8689 (comment)