- Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
A-lintArea: New lintsArea: New lints
Description
What it does
Arguments that are used only in recursion to itself.
Since it is used, the warning unused_variables
does not come out, but it is useless.
Lint Name
only_used_in_recursion
Category
perf
Advantage
- Lowers the complexity of the function.
- Better performance when the useless argument have some operation (like below example)
Drawbacks
No response
Example
fn f(a: usize, b: usize) -> usize { if a == 0 { 1 } else { f(a - 1, b + 1) } } fn main() { print!("{}", f(1, 1)); }
Could be written as:
fn f(a: usize) -> usize { if a == 0 { 1 } else { f(a - 1) } } fn main() { print!("{}", f(1)); }
Metadata
Metadata
Assignees
Labels
A-lintArea: New lintsArea: New lints