only_used_in_recursion

This commit is contained in:
Johann Hemmann 2024-01-19 15:58:27 +01:00
parent bef355168a
commit 0df30499d0
3 changed files with 6 additions and 8 deletions

View file

@ -179,7 +179,6 @@ needless_doctest_main = "allow"
new_without_default = "allow" new_without_default = "allow"
non_canonical_clone_impl = "allow" non_canonical_clone_impl = "allow"
non_canonical_partial_ord_impl = "allow" non_canonical_partial_ord_impl = "allow"
only_used_in_recursion = "allow"
op_ref = "allow" op_ref = "allow"
option_map_unit_fn = "allow" option_map_unit_fn = "allow"
partialeq_to_none = "allow" partialeq_to_none = "allow"

View file

@ -310,6 +310,7 @@ impl<'db, 'sema> Matcher<'db, 'sema> {
Ok(()) Ok(())
} }
#[allow(clippy::only_used_in_recursion)]
fn check_constraint( fn check_constraint(
&self, &self,
constraint: &Constraint, constraint: &Constraint,

View file

@ -282,9 +282,9 @@ fn expand_subtree<S: Span>(
} }
let res = if ctx.new_meta_vars { let res = if ctx.new_meta_vars {
count(ctx, binding, 0, depth.unwrap_or(0)) count(binding, 0, depth.unwrap_or(0))
} else { } else {
count_old(ctx, binding, 0, *depth) count_old(binding, 0, *depth)
}; };
let c = match res { let c = match res {
@ -537,7 +537,6 @@ fn fix_up_and_push_path_tt<S: Span>(
/// Handles `${count(t, depth)}`. `our_depth` is the recursion depth and `count_depth` is the depth /// Handles `${count(t, depth)}`. `our_depth` is the recursion depth and `count_depth` is the depth
/// defined by the metavar expression. /// defined by the metavar expression.
fn count<S>( fn count<S>(
ctx: &ExpandCtx<'_, S>,
binding: &Binding<S>, binding: &Binding<S>,
depth_curr: usize, depth_curr: usize,
depth_max: usize, depth_max: usize,
@ -547,7 +546,7 @@ fn count<S>(
if depth_curr == depth_max { if depth_curr == depth_max {
Ok(bs.len()) Ok(bs.len())
} else { } else {
bs.iter().map(|b| count(ctx, b, depth_curr + 1, depth_max)).sum() bs.iter().map(|b| count(b, depth_curr + 1, depth_max)).sum()
} }
} }
Binding::Empty => Ok(0), Binding::Empty => Ok(0),
@ -556,16 +555,15 @@ fn count<S>(
} }
fn count_old<S>( fn count_old<S>(
ctx: &ExpandCtx<'_, S>,
binding: &Binding<S>, binding: &Binding<S>,
our_depth: usize, our_depth: usize,
count_depth: Option<usize>, count_depth: Option<usize>,
) -> Result<usize, CountError> { ) -> Result<usize, CountError> {
match binding { match binding {
Binding::Nested(bs) => match count_depth { Binding::Nested(bs) => match count_depth {
None => bs.iter().map(|b| count_old(ctx, b, our_depth + 1, None)).sum(), None => bs.iter().map(|b| count_old(b, our_depth + 1, None)).sum(),
Some(0) => Ok(bs.len()), Some(0) => Ok(bs.len()),
Some(d) => bs.iter().map(|b| count_old(ctx, b, our_depth + 1, Some(d - 1))).sum(), Some(d) => bs.iter().map(|b| count_old(b, our_depth + 1, Some(d - 1))).sum(),
}, },
Binding::Empty => Ok(0), Binding::Empty => Ok(0),
Binding::Fragment(_) | Binding::Missing(_) => { Binding::Fragment(_) | Binding::Missing(_) => {