diff options
| author | A_A <21040751+Otto-AA@users.noreply.github.com> | 2024-12-31 14:18:43 +0100 |
|---|---|---|
| committer | A_A <21040751+Otto-AA@users.noreply.github.com> | 2024-12-31 14:18:43 +0100 |
| commit | 3bc089e9fed025974a7a859258c8b7a293f4e7c5 (patch) | |
| tree | 7ae88d2877d3a2cd473a44ab6fc70bd31be690f4 | |
| parent | 2a4dadd9854ad2d52dc1c10a860cd4ddb134567f (diff) | |
| download | rust-3bc089e9fed025974a7a859258c8b7a293f4e7c5.tar.gz rust-3bc089e9fed025974a7a859258c8b7a293f4e7c5.zip | |
refactor manual_is_ascii_check to remove unused parameter
| -rw-r--r-- | clippy_lints/src/manual_is_ascii_check.rs | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/clippy_lints/src/manual_is_ascii_check.rs b/clippy_lints/src/manual_is_ascii_check.rs index 2c25f098851..091203184b6 100644 --- a/clippy_lints/src/manual_is_ascii_check.rs +++ b/clippy_lints/src/manual_is_ascii_check.rs @@ -114,7 +114,7 @@ impl<'tcx> LateLintPass<'tcx> for ManualIsAsciiCheck { && !matches!(cx.typeck_results().expr_ty(arg).peel_refs().kind(), ty::Param(_)) { let arg = peel_ref_operators(cx, arg); - let ty_sugg = get_ty_sugg(cx, arg, start); + let ty_sugg = get_ty_sugg(cx, arg); let range = check_range(start, end); check_is_ascii(cx, expr.span, arg, &range, ty_sugg); } @@ -123,10 +123,9 @@ impl<'tcx> LateLintPass<'tcx> for ManualIsAsciiCheck { extract_msrv_attr!(LateContext); } -fn get_ty_sugg(cx: &LateContext<'_>, arg: &Expr<'_>, bound_expr: &Expr<'_>) -> Option<(Span, String)> { - if let ExprKind::Lit(_) = bound_expr.kind - && let local_hid = path_to_local(arg)? - && let Node::Param(Param { ty_span, span, .. }) = cx.tcx.parent_hir_node(local_hid) +fn get_ty_sugg(cx: &LateContext<'_>, arg: &Expr<'_>) -> Option<(Span, String)> { + let local_hid = path_to_local(arg)?; + if let Node::Param(Param { ty_span, span, .. }) = cx.tcx.parent_hir_node(local_hid) // `ty_span` and `span` are the same for inferred type, thus a type suggestion must be given && ty_span == span { |
