diff options
| author | Pavel Grigorenko <GrigorenkoPV@ya.ru> | 2024-09-05 00:34:04 +0300 |
|---|---|---|
| committer | Pavel Grigorenko <GrigorenkoPV@ya.ru> | 2024-09-06 00:30:36 +0300 |
| commit | 0b8cb4a1ebdf3bb9b03f7befe48b3d5e36ba080b (patch) | |
| tree | 45e590c0de50b6882ffe8dacd6ae1356d90f933e /clippy_lints/src/methods/utils.rs | |
| parent | 663f20086a4b48dcd6d00b3be070bdd1c9c688b2 (diff) | |
| download | rust-0b8cb4a1ebdf3bb9b03f7befe48b3d5e36ba080b.tar.gz rust-0b8cb4a1ebdf3bb9b03f7befe48b3d5e36ba080b.zip | |
Make `Ty::boxed_ty` return an `Option`
Diffstat (limited to 'clippy_lints/src/methods/utils.rs')
| -rw-r--r-- | clippy_lints/src/methods/utils.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/clippy_lints/src/methods/utils.rs b/clippy_lints/src/methods/utils.rs index 0d2b0a31317..fe860e5ae26 100644 --- a/clippy_lints/src/methods/utils.rs +++ b/clippy_lints/src/methods/utils.rs @@ -16,7 +16,7 @@ pub(super) fn derefs_to_slice<'tcx>( fn may_slice<'a>(cx: &LateContext<'a>, ty: Ty<'a>) -> bool { match ty.kind() { ty::Slice(_) => true, - ty::Adt(def, _) if def.is_box() => may_slice(cx, ty.boxed_ty()), + ty::Adt(..) if let Some(boxed) = ty.boxed_ty() => may_slice(cx, boxed), ty::Adt(..) => is_type_diagnostic_item(cx, ty, sym::Vec), ty::Array(_, size) => size.try_eval_target_usize(cx.tcx, cx.param_env).is_some(), ty::Ref(_, inner, _) => may_slice(cx, *inner), @@ -33,7 +33,7 @@ pub(super) fn derefs_to_slice<'tcx>( } else { match ty.kind() { ty::Slice(_) => Some(expr), - ty::Adt(def, _) if def.is_box() && may_slice(cx, ty.boxed_ty()) => Some(expr), + _ if ty.boxed_ty().is_some_and(|boxed| may_slice(cx, boxed)) => Some(expr), ty::Ref(_, inner, _) => { if may_slice(cx, *inner) { Some(expr) |
