1
Fork 0

BinOpKind

This commit is contained in:
csmoe 2018-07-12 15:50:09 +08:00 committed by Oliver Schneider
parent 1bd17e4fa2
commit 5d4102ee78
36 changed files with 260 additions and 248 deletions

View file

@ -42,14 +42,14 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for OverflowCheckConditional {
if cx.tables.expr_ty(ident1).is_integral();
if cx.tables.expr_ty(ident2).is_integral();
then {
if let BinOp_::BiLt = op.node {
if let BinOp_::BiAdd = op2.node {
if let BinOpKind::Lt = op.node {
if let BinOpKindAdd = op2.node {
span_lint(cx, OVERFLOW_CHECK_CONDITIONAL, expr.span,
"You are trying to use classic C overflow conditions that will fail in Rust.");
}
}
if let BinOp_::BiGt = op.node {
if let BinOp_::BiSub = op2.node {
if let BinOpKind::Gt = op.node {
if let BinOpKind::Sub = op2.node {
span_lint(cx, OVERFLOW_CHECK_CONDITIONAL, expr.span,
"You are trying to use classic C underflow conditions that will fail in Rust.");
}
@ -67,14 +67,14 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for OverflowCheckConditional {
if cx.tables.expr_ty(ident1).is_integral();
if cx.tables.expr_ty(ident2).is_integral();
then {
if let BinOp_::BiGt = op.node {
if let BinOp_::BiAdd = op2.node {
if let BinOpKind::Gt = op.node {
if let BinOpKindAdd = op2.node {
span_lint(cx, OVERFLOW_CHECK_CONDITIONAL, expr.span,
"You are trying to use classic C overflow conditions that will fail in Rust.");
}
}
if let BinOp_::BiLt = op.node {
if let BinOp_::BiSub = op2.node {
if let BinOpKind::Lt = op.node {
if let BinOpKind::Sub = op2.node {
span_lint(cx, OVERFLOW_CHECK_CONDITIONAL, expr.span,
"You are trying to use classic C underflow conditions that will fail in Rust.");
}