Remove useless curly braces in else { if .. }
This commit is contained in:
parent
f6f8723c78
commit
375b8168e4
@ -148,11 +148,10 @@ fn check_bit_mask(cx: &LateContext, bit_op: BinOp_, cmp_op: BinOp_, mask_value:
|
|||||||
mask_value,
|
mask_value,
|
||||||
cmp_value));
|
cmp_value));
|
||||||
}
|
}
|
||||||
} else {
|
} else if mask_value == 0 {
|
||||||
if mask_value == 0 {
|
span_lint(cx, BAD_BIT_MASK, *span, "&-masking with zero");
|
||||||
span_lint(cx, BAD_BIT_MASK, *span, "&-masking with zero");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
BiBitOr => {
|
BiBitOr => {
|
||||||
if mask_value | cmp_value != cmp_value {
|
if mask_value | cmp_value != cmp_value {
|
||||||
@ -177,10 +176,8 @@ fn check_bit_mask(cx: &LateContext, bit_op: BinOp_, cmp_op: BinOp_, mask_value:
|
|||||||
&format!("incompatible bit mask: `_ & {}` will always be lower than `{}`",
|
&format!("incompatible bit mask: `_ & {}` will always be lower than `{}`",
|
||||||
mask_value,
|
mask_value,
|
||||||
cmp_value));
|
cmp_value));
|
||||||
} else {
|
} else if mask_value == 0 {
|
||||||
if mask_value == 0 {
|
span_lint(cx, BAD_BIT_MASK, *span, "&-masking with zero");
|
||||||
span_lint(cx, BAD_BIT_MASK, *span, "&-masking with zero");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BiBitOr => {
|
BiBitOr => {
|
||||||
@ -209,10 +206,8 @@ fn check_bit_mask(cx: &LateContext, bit_op: BinOp_, cmp_op: BinOp_, mask_value:
|
|||||||
&format!("incompatible bit mask: `_ & {}` will never be higher than `{}`",
|
&format!("incompatible bit mask: `_ & {}` will never be higher than `{}`",
|
||||||
mask_value,
|
mask_value,
|
||||||
cmp_value));
|
cmp_value));
|
||||||
} else {
|
} else if mask_value == 0 {
|
||||||
if mask_value == 0 {
|
span_lint(cx, BAD_BIT_MASK, *span, "&-masking with zero");
|
||||||
span_lint(cx, BAD_BIT_MASK, *span, "&-masking with zero");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BiBitOr => {
|
BiBitOr => {
|
||||||
|
@ -536,12 +536,10 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
|
|||||||
Plus
|
Plus
|
||||||
})
|
})
|
||||||
.and_then(|ty| l64.checked_add(r64).map(|v| ConstantInt(v, ty)))
|
.and_then(|ty| l64.checked_add(r64).map(|v| ConstantInt(v, ty)))
|
||||||
|
} else if ln {
|
||||||
|
add_neg_int(r64, rty, l64, lty)
|
||||||
} else {
|
} else {
|
||||||
if ln {
|
add_neg_int(l64, lty, r64, rty)
|
||||||
add_neg_int(r64, rty, l64, lty)
|
|
||||||
} else {
|
|
||||||
add_neg_int(l64, lty, r64, rty)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO: float (would need bignum library?)
|
// TODO: float (would need bignum library?)
|
||||||
|
@ -59,12 +59,10 @@ fn min_max<'a>(cx: &LateContext, expr: &'a Expr) -> Option<(MinMax, Constant, &'
|
|||||||
|
|
||||||
if match_def_path(cx, def_id, &["core", "cmp", "min"]) {
|
if match_def_path(cx, def_id, &["core", "cmp", "min"]) {
|
||||||
fetch_const(args, Min)
|
fetch_const(args, Min)
|
||||||
|
} else if match_def_path(cx, def_id, &["core", "cmp", "max"]) {
|
||||||
|
fetch_const(args, Max)
|
||||||
} else {
|
} else {
|
||||||
if match_def_path(cx, def_id, &["core", "cmp", "max"]) {
|
None
|
||||||
fetch_const(args, Max)
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
@ -204,29 +204,28 @@ fn lint_shadow<T>(cx: &LateContext, name: Name, span: Span, lspan: Span, init: &
|
|||||||
snippet(cx, lspan, "_"),
|
snippet(cx, lspan, "_"),
|
||||||
snippet(cx, expr.span, "..")));
|
snippet(cx, expr.span, "..")));
|
||||||
note_orig(cx, db, SHADOW_SAME, prev_span);
|
note_orig(cx, db, SHADOW_SAME, prev_span);
|
||||||
|
} else if contains_self(name, expr) {
|
||||||
|
let db = span_note_and_lint(cx,
|
||||||
|
SHADOW_REUSE,
|
||||||
|
lspan,
|
||||||
|
&format!("{} is shadowed by {} which reuses the original value",
|
||||||
|
snippet(cx, lspan, "_"),
|
||||||
|
snippet(cx, expr.span, "..")),
|
||||||
|
expr.span,
|
||||||
|
"initialization happens here");
|
||||||
|
note_orig(cx, db, SHADOW_REUSE, prev_span);
|
||||||
} else {
|
} else {
|
||||||
if contains_self(name, expr) {
|
let db = span_note_and_lint(cx,
|
||||||
let db = span_note_and_lint(cx,
|
SHADOW_UNRELATED,
|
||||||
SHADOW_REUSE,
|
lspan,
|
||||||
lspan,
|
&format!("{} is shadowed by {}",
|
||||||
&format!("{} is shadowed by {} which reuses the original value",
|
snippet(cx, lspan, "_"),
|
||||||
snippet(cx, lspan, "_"),
|
snippet(cx, expr.span, "..")),
|
||||||
snippet(cx, expr.span, "..")),
|
expr.span,
|
||||||
expr.span,
|
"initialization happens here");
|
||||||
"initialization happens here");
|
note_orig(cx, db, SHADOW_UNRELATED, prev_span);
|
||||||
note_orig(cx, db, SHADOW_REUSE, prev_span);
|
|
||||||
} else {
|
|
||||||
let db = span_note_and_lint(cx,
|
|
||||||
SHADOW_UNRELATED,
|
|
||||||
lspan,
|
|
||||||
&format!("{} is shadowed by {}",
|
|
||||||
snippet(cx, lspan, "_"),
|
|
||||||
snippet(cx, expr.span, "..")),
|
|
||||||
expr.span,
|
|
||||||
"initialization happens here");
|
|
||||||
note_orig(cx, db, SHADOW_UNRELATED, prev_span);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
let db = span_lint(cx,
|
let db = span_lint(cx,
|
||||||
SHADOW_UNRELATED,
|
SHADOW_UNRELATED,
|
||||||
|
Loading…
Reference in New Issue
Block a user