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/methods/zst_offset.rs | |
| parent | 9aa2330e41b9d6e25fb357b54f5ae98448543752 (diff) | |
Merge commit 'edb720b199083f4107b858a8761648065bf38d86' into clippyup
Diffstat (limited to 'clippy_lints/src/methods/zst_offset.rs')
| -rw-r--r-- | clippy_lints/src/methods/zst_offset.rs | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/clippy_lints/src/methods/zst_offset.rs b/clippy_lints/src/methods/zst_offset.rs index e9f268da691..0b829d99aef 100644 --- a/clippy_lints/src/methods/zst_offset.rs +++ b/clippy_lints/src/methods/zst_offset.rs @@ -1,5 +1,4 @@ use clippy_utils::diagnostics::span_lint; -use if_chain::if_chain; use rustc_hir as hir; use rustc_lint::LateContext; use rustc_middle::ty; @@ -7,12 +6,10 @@ use rustc_middle::ty; use super::ZST_OFFSET; pub(super) fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>, recv: &hir::Expr<'_>) { - if_chain! { - if let ty::RawPtr(ty::TypeAndMut { ty, .. }) = cx.typeck_results().expr_ty(recv).kind(); - if let Ok(layout) = cx.tcx.layout_of(cx.param_env.and(*ty)); - if layout.is_zst(); - then { - span_lint(cx, ZST_OFFSET, expr.span, "offset calculation on zero-sized value"); - } + if let ty::RawPtr(ty::TypeAndMut { ty, .. }) = cx.typeck_results().expr_ty(recv).kind() + && let Ok(layout) = cx.tcx.layout_of(cx.param_env.and(*ty)) + && layout.is_zst() + { + span_lint(cx, ZST_OFFSET, expr.span, "offset calculation on zero-sized value"); } } |
