Merge remote-tracking branch 'upstream/master' into rustup

This commit is contained in:
Philipp Krones 2025-01-28 18:28:57 +01:00
commit 145d5adf04
No known key found for this signature in database
GPG key ID: 1CA0DF2AF59D68A5
282 changed files with 5798 additions and 885 deletions

View file

@ -104,7 +104,7 @@ impl ArithmeticSideEffects {
if !tcx.is_diagnostic_item(sym::NonZero, adt.did()) {
return false;
};
}
let int_type = substs.type_at(0);
let unsigned_int_types = [
@ -214,13 +214,13 @@ impl ArithmeticSideEffects {
| hir::BinOpKind::Sub
) {
return;
};
}
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();
let rhs_ty = cx.typeck_results().expr_ty_adjusted(actual_rhs).peel_refs();
if self.has_allowed_binary(lhs_ty, rhs_ty) {
return;
}
@ -283,7 +283,7 @@ impl ArithmeticSideEffects {
if ConstEvalCtxt::new(cx).eval_simple(receiver).is_some() {
return;
}
let instance_ty = cx.typeck_results().expr_ty(receiver);
let instance_ty = cx.typeck_results().expr_ty_adjusted(receiver);
if !Self::is_integral(instance_ty) {
return;
}
@ -311,7 +311,7 @@ impl ArithmeticSideEffects {
if ConstEvalCtxt::new(cx).eval(un_expr).is_some() {
return;
}
let ty = cx.typeck_results().expr_ty(expr).peel_refs();
let ty = cx.typeck_results().expr_ty_adjusted(expr).peel_refs();
if self.has_allowed_unary(ty) {
return;
}

View file

@ -104,7 +104,7 @@ fn check_op(cx: &LateContext<'_>, expr: &Expr<'_>, other: &Expr<'_>, left: bool)
} else {
expr_snip = arg_snip.to_string();
eq_impl = without_deref;
};
}
let span;
let hint;

View file

@ -127,7 +127,7 @@ pub(super) fn check<'tcx>(
None,
note,
);
};
}
}
}

View file

@ -49,5 +49,5 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, op: BinOpKind, lhs: &'tcx Expr
lint_double_comparison!(==);
},
_ => (),
};
}
}

View file

@ -120,7 +120,7 @@ fn is_float(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
if let ty::Array(arr_ty, _) = value {
return matches!(arr_ty.kind(), ty::Float(_));
};
}
matches!(value, ty::Float(_))
}

View file

@ -262,7 +262,7 @@ declare_clippy_lint! {
/// to `trailing_zeros`
///
/// ### Why is this bad?
/// `x.trailing_zeros() > 4` is much clearer than `x & 15
/// `x.trailing_zeros() >= 4` is much clearer than `x & 15
/// == 0`
///
/// ### Known problems
@ -278,7 +278,7 @@ declare_clippy_lint! {
///
/// ```no_run
/// # let x: i32 = 1;
/// if x.trailing_zeros() > 4 { }
/// if x.trailing_zeros() >= 4 { }
/// ```
#[clippy::version = "pre 1.29.0"]
pub VERBOSE_BIT_MASK,

View file

@ -30,7 +30,7 @@ pub(super) fn check<'tcx>(
} else {
check_non_const_operands(cx, e, lhs);
}
};
}
}
fn used_in_comparison_with_zero(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {

View file

@ -21,6 +21,6 @@ pub(crate) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, op: BinOpKind, right:
"any number modulo -1 will panic/overflow or result in 0",
);
}
};
}
}
}