|
1 | 1 | use super::ARITHMETIC_SIDE_EFFECTS;
|
2 | 2 | use clippy_utils::consts::{constant, constant_simple, Constant};
|
3 | 3 | use clippy_utils::diagnostics::span_lint;
|
4 |
| -use clippy_utils::{is_from_proc_macro, is_lint_allowed, peel_hir_expr_refs, peel_hir_expr_unary}; |
| 4 | +use clippy_utils::{expr_or_init, is_from_proc_macro, is_lint_allowed, peel_hir_expr_refs, peel_hir_expr_unary}; |
5 | 5 | use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
6 | 6 | use rustc_lint::{LateContext, LateLintPass};
|
7 | 7 | use rustc_middle::ty::Ty;
|
@@ -138,8 +138,10 @@ impl ArithmeticSideEffects {
|
138 | 138 | ) {
|
139 | 139 | return;
|
140 | 140 | };
|
141 |
| - let (actual_lhs, lhs_ref_counter) = peel_hir_expr_refs(lhs); |
142 |
| - let (actual_rhs, rhs_ref_counter) = peel_hir_expr_refs(rhs); |
| 141 | + let (mut actual_lhs, lhs_ref_counter) = peel_hir_expr_refs(lhs); |
| 142 | + let (mut actual_rhs, rhs_ref_counter) = peel_hir_expr_refs(rhs); |
| 143 | + actual_lhs = expr_or_init(cx, actual_lhs); |
| 144 | + actual_rhs = expr_or_init(cx, actual_rhs); |
143 | 145 | let lhs_ty = cx.typeck_results().expr_ty(actual_lhs).peel_refs();
|
144 | 146 | let rhs_ty = cx.typeck_results().expr_ty(actual_rhs).peel_refs();
|
145 | 147 | if self.has_allowed_binary(lhs_ty, rhs_ty) {
|
|
0 commit comments