mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-27 15:11:30 +00:00
Auto merge of #11263 - c410-f3r:let-chain, r=Centri3
[`arithmetic_side_effects`] Fix #11262 Fix #11262 Rustc already handles paths that refer literals -> https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=d795058a2e1634c867288c20ff9432c8 ``` changelog: [`arithmetic_side_effects`]: Ignore paths that refer literals ```
This commit is contained in:
commit
5436dba826
2 changed files with 12 additions and 3 deletions
|
@ -1,7 +1,7 @@
|
|||
use super::ARITHMETIC_SIDE_EFFECTS;
|
||||
use clippy_utils::consts::{constant, constant_simple, Constant};
|
||||
use clippy_utils::diagnostics::span_lint;
|
||||
use clippy_utils::{is_from_proc_macro, is_lint_allowed, peel_hir_expr_refs, peel_hir_expr_unary};
|
||||
use clippy_utils::{expr_or_init, is_from_proc_macro, is_lint_allowed, peel_hir_expr_refs, peel_hir_expr_unary};
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_middle::ty::Ty;
|
||||
|
@ -138,8 +138,10 @@ impl ArithmeticSideEffects {
|
|||
) {
|
||||
return;
|
||||
};
|
||||
let (actual_lhs, lhs_ref_counter) = peel_hir_expr_refs(lhs);
|
||||
let (actual_rhs, rhs_ref_counter) = peel_hir_expr_refs(rhs);
|
||||
let (mut actual_lhs, lhs_ref_counter) = peel_hir_expr_refs(lhs);
|
||||
let (mut actual_rhs, rhs_ref_counter) = peel_hir_expr_refs(rhs);
|
||||
actual_lhs = expr_or_init(cx, actual_lhs);
|
||||
actual_rhs = expr_or_init(cx, actual_rhs);
|
||||
let lhs_ty = cx.typeck_results().expr_ty(actual_lhs).peel_refs();
|
||||
let rhs_ty = cx.typeck_results().expr_ty(actual_rhs).peel_refs();
|
||||
if self.has_allowed_binary(lhs_ty, rhs_ty) {
|
||||
|
|
|
@ -486,4 +486,11 @@ pub fn issue_11145() {
|
|||
x += 1;
|
||||
}
|
||||
|
||||
pub fn issue_11262() {
|
||||
let one = 1;
|
||||
let zero = 0;
|
||||
let _ = 2 / one;
|
||||
let _ = 2 / zero;
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
Loading…
Reference in a new issue