Skip to content

Commit dd1467a

Browse files
committed
fixup! redundant_box lint
1 parent eebfaff commit dd1467a

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

clippy_lints/src/redundant_box.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use clippy_utils::diagnostics::span_lint_and_sugg;
2+
use clippy_utils::qpath_generic_tys;
23
use clippy_utils::source::snippet;
34
use clippy_utils::ty::approx_ty_size;
45
use rustc_errors::Applicability;
@@ -34,13 +35,10 @@ impl LateLintPass<'_> for RedundantBox {
3435
let ty = clippy_utils::ty::ty_from_hir_ty(cx, hir_ty.as_unambig_ty());
3536
if let Some(boxed_ty) = ty.boxed_ty()
3637
&& is_thin_type(cx, boxed_ty)
37-
// Extract the contained type for the lint suggestion span
38-
// TODO is there a simpler way to do this?:
39-
&& let TyKind::Path(QPath::Resolved(_, Path { segments, .. })) = hir_ty.kind
40-
&& let [PathSegment { args: Some(args), .. }] = segments
41-
&& let [GenericArg::Type(ty)] = args.args
38+
&& let TyKind::Path(path) = hir_ty.kind
39+
&& let Some(boxed_ty) = qpath_generic_tys(&path).next()
4240
{
43-
span_lint_and_sugg_(cx, hir_ty.span, ty.span);
41+
span_lint_and_sugg_(cx, hir_ty.span, boxed_ty.span);
4442
}
4543
}
4644

0 commit comments

Comments
 (0)