We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3a090c9 commit 8faa938Copy full SHA for 8faa938
clippy_lints/src/only_used_in_recursion.rs
@@ -126,8 +126,20 @@ impl<'tcx> LateLintPass<'tcx> for OnlyUsedInRecursion {
126
}
127
128
129
+ let mut pre_order = FxHashMap::default();
130
+
131
+ visitor.graph.iter().for_each(|(_, next)| {
132
+ next.iter().for_each(|i| {
133
+ *pre_order.entry(*i).or_insert(0) += 1;
134
+ });
135
136
137
for (id, span, ident) in param_span {
- if !visitor.has_side_effect.contains(&id) {
138
+ // if the variable is not used in recursion, it would be marked as unused
139
+ if !visitor.has_side_effect.contains(&id)
140
+ && *pre_order.get(&id).unwrap_or(&0) > 0
141
+ && visitor.graph.contains_key(&id)
142
+ {
143
span_lint_and_sugg(
144
cx,
145
ONLY_USED_IN_RECURSION,
0 commit comments