Skip to content

Commit e12409d

Browse files
committed
change lint type to complexity & check ident earlier
1 parent 0f65c84 commit e12409d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

clippy_lints/src/unnecessary_indexing.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ declare_clippy_lint! {
3434
/// ```
3535
#[clippy::version = "1.78.0"]
3636
pub UNNECESSARY_INDEXING,
37-
style,
37+
complexity,
3838
"unnecessary use of `seq.is_empty()` in a conditional when if..let is more appropriate"
3939
}
4040

@@ -48,9 +48,9 @@ impl LateLintPass<'_> for UnnecessaryIndexing {
4848
&& UnOp::Not == op
4949
// check for call of is_empty
5050
&& let ExprKind::MethodCall(method, conditional_receiver, _, _) = unary_inner.kind
51+
&& method.ident.as_str() == "is_empty"
5152
&& let expr_ty = cx.typeck_results().expr_ty(conditional_receiver).peel_refs()
5253
&& (expr_ty.is_array_slice() || expr_ty.is_array() || is_type_diagnostic_item(cx, expr_ty, sym::Vec))
53-
&& method.ident.as_str() == "is_empty"
5454
&& let ExprKind::Block(block, _) = if_expr.then.kind
5555
{
5656
// checked if conditional is calling `is_empty` on a sequence, now check if the first

0 commit comments

Comments
 (0)