diff options
| author | Philipp Krones <hello@philkrones.com> | 2023-11-16 19:13:24 +0100 |
|---|---|---|
| committer | Philipp Krones <hello@philkrones.com> | 2023-11-16 19:13:24 +0100 |
| commit | 6246f0446afbe9abff18e8cc1ebaae7505f7cd9e (patch) | |
| tree | 50ef81f3e7465a1187443aeb40d80d293f664884 /clippy_lints/src/trailing_empty_array.rs | |
| parent | 9aa2330e41b9d6e25fb357b54f5ae98448543752 (diff) | |
| download | rust-6246f0446afbe9abff18e8cc1ebaae7505f7cd9e.tar.gz rust-6246f0446afbe9abff18e8cc1ebaae7505f7cd9e.zip | |
Merge commit 'edb720b199083f4107b858a8761648065bf38d86' into clippyup
Diffstat (limited to 'clippy_lints/src/trailing_empty_array.rs')
| -rw-r--r-- | clippy_lints/src/trailing_empty_array.rs | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/clippy_lints/src/trailing_empty_array.rs b/clippy_lints/src/trailing_empty_array.rs index 87181adc24b..7eef02b3c65 100644 --- a/clippy_lints/src/trailing_empty_array.rs +++ b/clippy_lints/src/trailing_empty_array.rs @@ -54,20 +54,18 @@ impl<'tcx> LateLintPass<'tcx> for TrailingEmptyArray { } fn is_struct_with_trailing_zero_sized_array(cx: &LateContext<'_>, item: &Item<'_>) -> bool { - if_chain! { + if let ItemKind::Struct(data, _) = &item.kind // First check if last field is an array - if let ItemKind::Struct(data, _) = &item.kind; - if let Some(last_field) = data.fields().last(); - if let rustc_hir::TyKind::Array(_, rustc_hir::ArrayLen::Body(length)) = last_field.ty.kind; + && let Some(last_field) = data.fields().last() + && let rustc_hir::TyKind::Array(_, rustc_hir::ArrayLen::Body(length)) = last_field.ty.kind // Then check if that array is zero-sized - let length = Const::from_anon_const(cx.tcx, length.def_id); - let length = length.try_eval_target_usize(cx.tcx, cx.param_env); - if let Some(length) = length; - then { - length == 0 - } else { - false - } + && let length = Const::from_anon_const(cx.tcx, length.def_id) + && let length = length.try_eval_target_usize(cx.tcx, cx.param_env) + && let Some(length) = length + { + length == 0 + } else { + false } } |
