diff options
| author | Zihan <zihanli0822@gmail.com> | 2025-08-02 12:20:31 -0400 |
|---|---|---|
| committer | Zihan <zihanli0822@gmail.com> | 2025-08-02 13:07:11 -0400 |
| commit | b8c16e47f4a2757992941a421423534be2dc8a87 (patch) | |
| tree | 13ccfb2a25209b7527da2b3ff55002616588affd /clippy_lints | |
| parent | e8185ec091d7fe71b03cacb7846ae1c8323e013a (diff) | |
| download | rust-b8c16e47f4a2757992941a421423534be2dc8a87.tar.gz rust-b8c16e47f4a2757992941a421423534be2dc8a87.zip | |
fix: `option_if_let_else` keep deref op if the inner expr is a raw pointer
closes rust-clippy/issues/15379 Signed-off-by: Zihan <zihanli0822@gmail.com>
Diffstat (limited to 'clippy_lints')
| -rw-r--r-- | clippy_lints/src/option_if_let_else.rs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/clippy_lints/src/option_if_let_else.rs b/clippy_lints/src/option_if_let_else.rs index 9487cec87ef..6c0bf2ad154 100644 --- a/clippy_lints/src/option_if_let_else.rs +++ b/clippy_lints/src/option_if_let_else.rs @@ -127,7 +127,8 @@ fn try_get_option_occurrence<'tcx>( if_else: &'tcx Expr<'_>, ) -> Option<OptionOccurrence> { let cond_expr = match expr.kind { - ExprKind::Unary(UnOp::Deref, inner_expr) | ExprKind::AddrOf(_, _, inner_expr) => inner_expr, + ExprKind::AddrOf(_, _, inner_expr) => inner_expr, + ExprKind::Unary(UnOp::Deref, inner_expr) if !cx.typeck_results().expr_ty(inner_expr).is_raw_ptr() => inner_expr, _ => expr, }; let (inner_pat, is_result) = try_get_inner_pat_and_is_result(cx, pat)?; |
