Improve only_used_in_recursion lint/testing #8782
Labels
C-enhancement
Category: Enhancement of lints, like adding more cases or adding help messages
E-medium
Call for participation: Medium difficulty level problem and requires some initial experience.
E-needs-test
Call for participation: writing tests
I-false-positive
Issue: The lint was triggered on code it shouldn't have
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 theb
argument changes the semantics of the function (i.e. you won't be able to get the same behavior). PlaygroundI 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)
The text was updated successfully, but these errors were encountered: