File tree Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change 11use clippy_utils:: diagnostics:: span_lint_and_sugg;
2+ use clippy_utils:: qpath_generic_tys;
23use clippy_utils:: source:: snippet;
34use clippy_utils:: ty:: approx_ty_size;
45use 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
You can’t perform that action at this time.
0 commit comments