}
fn numeric_cast_precast_bounds<'a>(cx: &LateContext<'_>, expr: &'a Expr<'_>) -> Option<(FullInt, FullInt)> {
- if let ExprKind::Cast(ref cast_exp, _) = expr.kind {
+ if let ExprKind::Cast(cast_exp, _) = expr.kind {
let pre_cast_ty = cx.typeck_results().expr_ty(cast_exp);
let cast_ty = cx.typeck_results().expr_ty(expr);
// if it's a cast from i32 to u32 wrapping will invalidate all these checks
}
fn err_upcast_comparison(cx: &LateContext<'_>, span: Span, expr: &Expr<'_>, always: bool) {
- if let ExprKind::Cast(ref cast_val, _) = expr.kind {
+ if let ExprKind::Cast(cast_val, _) = expr.kind {
span_lint(
cx,
INVALID_UPCAST_COMPARISONS,
},
Rel::Eq | Rel::Ne => unreachable!(),
} {
- err_upcast_comparison(cx, span, lhs, true)
+ err_upcast_comparison(cx, span, lhs, true);
} else if match rel {
Rel::Lt => {
if invert {
},
Rel::Eq | Rel::Ne => unreachable!(),
} {
- err_upcast_comparison(cx, span, lhs, false)
+ err_upcast_comparison(cx, span, lhs, false);
}
}
}
impl<'tcx> LateLintPass<'tcx> for InvalidUpcastComparisons {
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
- if let ExprKind::Binary(ref cmp, ref lhs, ref rhs) = expr.kind {
+ if let ExprKind::Binary(ref cmp, lhs, rhs) = expr.kind {
let normalized = comparisons::normalize_comparison(cmp.node, lhs, rhs);
let (rel, normalized_lhs, normalized_rhs) = if let Some(val) = normalized {
val