diff --git a/src/bit_mask.rs b/src/bit_mask.rs index e6665bbbb4d..c8530b92d48 100644 --- a/src/bit_mask.rs +++ b/src/bit_mask.rs @@ -185,7 +185,7 @@ fn fetch_int_literal(cx: &LateContext, lit : &Expr) -> Option { if let &LitInt(value, _) = &lit_ptr.node { Option::Some(value) //TODO: Handle sign } else { Option::None } - }, + } ExprPath(_, _) => { // Important to let the borrow expire before the const lookup to avoid double // borrowing. diff --git a/src/consts.rs b/src/consts.rs index 766d998c256..1750495d1f3 100644 --- a/src/consts.rs +++ b/src/consts.rs @@ -246,7 +246,7 @@ fn constant_not(o: Constant) -> Option { SignedIntLit(ity, Plus) => { if value == ::std::u64::MAX { return None; } (value + 1, SignedIntLit(ity, Minus)) - }, + } SignedIntLit(ity, Minus) => { if value == 0 { (1, SignedIntLit(ity, Minus)) @@ -267,7 +267,7 @@ fn constant_not(o: Constant) -> Option { UnsuffixedIntLit(_) => { return None; } // refuse to guess }; ConstantInt(nvalue, nty) - }, + } _ => { return None; } }) } @@ -279,11 +279,11 @@ fn constant_negate(o: Constant) -> Option { SignedIntLit(ity, sign) => SignedIntLit(ity, neg_sign(sign)), UnsuffixedIntLit(sign) => UnsuffixedIntLit(neg_sign(sign)), - _ => { return None; }, + _ => { return None; } }), ConstantFloat(is, ty) => ConstantFloat(neg_float_str(is), ty), - _ => { return None; }, + _ => { return None; } }) } @@ -461,7 +461,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> { add_neg_int(l64, lty, r64, rty) } } - }, + } // TODO: float (would need bignum library?) _ => None }), @@ -513,7 +513,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> { unify_int_type(lty, rty, if is_negative(lty) == is_negative(rty) { Plus } else { Minus }) .map(|ty| ConstantInt(value, ty))) - }, + } _ => None, }) } diff --git a/src/eta_reduction.rs b/src/eta_reduction.rs index 855ea51ee8e..c4c0912464c 100644 --- a/src/eta_reduction.rs +++ b/src/eta_reduction.rs @@ -26,7 +26,7 @@ impl LateLintPass for EtaPass { for arg in args { check_closure(cx, arg) } - }, + } _ => (), } } diff --git a/src/identity_op.rs b/src/identity_op.rs index aee208d624e..7ed784f00fc 100644 --- a/src/identity_op.rs +++ b/src/identity_op.rs @@ -26,19 +26,19 @@ impl LateLintPass for IdentityOp { BiAdd | BiBitOr | BiBitXor => { check(cx, left, 0, e.span, right.span); check(cx, right, 0, e.span, left.span); - }, + } BiShl | BiShr | BiSub => check(cx, right, 0, e.span, left.span), BiMul => { check(cx, left, 1, e.span, right.span); check(cx, right, 1, e.span, left.span); - }, + } BiDiv => check(cx, right, 1, e.span, left.span), BiBitAnd => { check(cx, left, -1, e.span, right.span); check(cx, right, -1, e.span, left.span); - }, + } _ => () } } diff --git a/src/lifetimes.rs b/src/lifetimes.rs index 229d13401c6..09c5821dd49 100644 --- a/src/lifetimes.rs +++ b/src/lifetimes.rs @@ -196,13 +196,13 @@ impl <'v, 't> RefVisitor<'v, 't> { self.record(&None); } } - }, + } Some(DefTrait(def_id)) => { let trait_def = self.cx.tcx.trait_defs.borrow()[&def_id]; for _ in &trait_def.generics.regions { self.record(&None); } - }, + } _ => {} } } @@ -221,10 +221,10 @@ impl<'v, 't> Visitor<'v> for RefVisitor<'v, 't> { match ty.node { TyRptr(None, _) => { self.record(&None); - }, + } TyPath(_, ref path) => { self.collect_anonymous_lifetimes(path, ty); - }, + } _ => {} } walk_ty(self, ty); diff --git a/src/loops.rs b/src/loops.rs index d056c67c541..60ae2c23f0a 100644 --- a/src/loops.rs +++ b/src/loops.rs @@ -545,13 +545,13 @@ impl<'v, 't> Visitor<'v> for InitializeVisitor<'v, 't> { match parent.node { ExprAssignOp(_, ref lhs, _) if lhs.id == expr.id => { self.state = VarState::DontWarn; - }, + } ExprAssign(ref lhs, ref rhs) if lhs.id == expr.id => { self.state = if is_integer_literal(rhs, 0) && self.depth == 0 { VarState::Warn } else { VarState::DontWarn - }}, + }} ExprAddrOf(mutability,_) if mutability == MutMutable => self.state = VarState::DontWarn, _ => () } diff --git a/src/map_clone.rs b/src/map_clone.rs index b9f677dd03d..ba561fbb167 100644 --- a/src/map_clone.rs +++ b/src/map_clone.rs @@ -55,7 +55,7 @@ impl LateLintPass for MapClonePass { } } } - }, + } ExprPath(_, ref path) => { if match_path(path, &CLONE_PATH) { let type_name = get_type_name(cx, expr, &args[0]).unwrap_or("_"); @@ -77,7 +77,7 @@ fn expr_eq_ident(expr: &Expr, id: Ident) -> bool { ExprPath(None, ref path) => { let arg_segment = [PathSegment { identifier: id, parameters: PathParameters::none() }]; !path.global && path.segments == arg_segment - }, + } _ => false, } } @@ -104,7 +104,7 @@ fn only_derefs(cx: &LateContext, expr: &Expr, id: Ident) -> bool { match expr.node { ExprUnary(UnDeref, ref subexpr) if !is_adjusted(cx, subexpr) => { only_derefs(cx, subexpr, id) - }, + } _ => expr_eq_ident(expr, id), } } diff --git a/src/minmax.rs b/src/minmax.rs index 3171a951422..7ed65184727 100644 --- a/src/minmax.rs +++ b/src/minmax.rs @@ -31,7 +31,7 @@ impl LateLintPass for MinMaxPass { _ => { span_lint(cx, MIN_MAX, expr.span, "this min/max combination leads to constant result") - }, + } } } } diff --git a/src/misc.rs b/src/misc.rs index 85fd03079fe..857ae1cc0c3 100644 --- a/src/misc.rs +++ b/src/misc.rs @@ -187,7 +187,7 @@ fn check_to_owned(cx: &LateContext, expr: &Expr, other_span: Span, left: bool, o } else { return } - }, + } ExprCall(ref path, ref v) if v.len() == 1 => { if let &ExprPath(None, ref path) = &path.node { if match_path(path, &["String", "from_str"]) || @@ -199,7 +199,7 @@ fn check_to_owned(cx: &LateContext, expr: &Expr, other_span: Span, left: bool, o } else { return } - }, + } _ => return }; if left { diff --git a/src/mut_reference.rs b/src/mut_reference.rs index 1cc04e096ba..86c272affb7 100644 --- a/src/mut_reference.rs +++ b/src/mut_reference.rs @@ -32,14 +32,14 @@ impl LateLintPass for UnnecessaryMutPassed { check_arguments(cx, &arguments, function_type, &format!("{}", path)); } - }, + } None => unreachable!(), // A function with unknown type is called. // If this happened the compiler would have aborted the // compilation long ago. }; - }, + } ExprMethodCall(ref name, _, ref arguments) => { let method_call = MethodCall::expr(e.id); match borrowed_table.method_map.get(&method_call) { @@ -47,7 +47,7 @@ impl LateLintPass for UnnecessaryMutPassed { &format!("{}", name.node.as_str())), None => unreachable!(), // Just like above, this should never happen. }; - }, + } _ => {} } } @@ -66,7 +66,7 @@ fn check_arguments(cx: &LateContext, arguments: &[P], type_definition: &Ty doesn't need a mutable reference", name)); } - }, + } _ => {} } } diff --git a/src/needless_bool.rs b/src/needless_bool.rs index c0a99acb71d..52f23c7518a 100644 --- a/src/needless_bool.rs +++ b/src/needless_bool.rs @@ -31,10 +31,10 @@ impl LateLintPass for NeedlessBool { match (fetch_bool_block(then_block), fetch_bool_expr(else_expr)) { (Some(true), Some(true)) => { span_lint(cx, NEEDLESS_BOOL, e.span, - "this if-then-else expression will always return true"); }, + "this if-then-else expression will always return true"); } (Some(false), Some(false)) => { span_lint(cx, NEEDLESS_BOOL, e.span, - "this if-then-else expression will always return false"); }, + "this if-then-else expression will always return false"); } (Some(true), Some(false)) => { let pred_snip = snippet(cx, pred.span, ".."); let hint = if pred_snip == ".." { "its predicate".into() } else { @@ -42,7 +42,7 @@ impl LateLintPass for NeedlessBool { }; span_lint(cx, NEEDLESS_BOOL, e.span, &format!( "you can reduce this if-then-else expression to just {}", hint)); - }, + } (Some(false), Some(true)) => { let pred_snip = snippet(cx, pred.span, ".."); let hint = if pred_snip == ".." { "`!` and its predicate".into() } else { @@ -50,7 +50,7 @@ impl LateLintPass for NeedlessBool { }; span_lint(cx, NEEDLESS_BOOL, e.span, &format!( "you can reduce this if-then-else expression to just {}", hint)); - }, + } _ => () } } diff --git a/src/open_options.rs b/src/open_options.rs index 76a2eeef1ba..732852e1686 100644 --- a/src/open_options.rs +++ b/src/open_options.rs @@ -65,7 +65,7 @@ fn get_open_options(cx: &LateContext, argument: &Expr, options: &mut Vec<(OpenOp // which is not a boolean literal. This is theoretically // possible, but not very likely. } - }, + } _ => { Argument::Unknown } @@ -74,19 +74,19 @@ fn get_open_options(cx: &LateContext, argument: &Expr, options: &mut Vec<(OpenOp match &*name.node.as_str() { "create" => { options.push((OpenOption::Create, argument_option)); - }, + } "append" => { options.push((OpenOption::Append, argument_option)); - }, + } "truncate" => { options.push((OpenOption::Truncate, argument_option)); - }, + } "read" => { options.push((OpenOption::Read, argument_option)); - }, + } "write" => { options.push((OpenOption::Write, argument_option)); - }, + } _ => {} } diff --git a/src/shadow.rs b/src/shadow.rs index ca45ed11ab8..a1e86028752 100644 --- a/src/shadow.rs +++ b/src/shadow.rs @@ -101,7 +101,7 @@ fn check_pat(cx: &LateContext, pat: &Pat, init: &Option<&Expr>, span: Span, } } if let Some(ref p) = *inner { check_pat(cx, p, init, span, bindings); } - }, + } //PatEnum(Path, Option>>), PatStruct(_, ref pfields, _) => if let Some(ref init_struct) = *init { @@ -149,7 +149,7 @@ fn check_pat(cx: &LateContext, pat: &Pat, init: &Option<&Expr>, span: Span, } else { check_pat(cx, inner, init, span, bindings); } - }, + } PatRegion(ref inner, _) => check_pat(cx, inner, init, span, bindings), //PatVec(Vec>, Option>, Vec>), @@ -200,9 +200,9 @@ fn check_expr(cx: &LateContext, expr: &Expr, bindings: &mut Vec<(Name, Span)>) { match expr.node { ExprUnary(_, ref e) | ExprField(ref e, _) | ExprTupField(ref e, _) | ExprAddrOf(_, ref e) | ExprBox(ref e) - => { check_expr(cx, e, bindings) }, + => { check_expr(cx, e, bindings) } ExprBlock(ref block) | ExprLoop(ref block, _) => - { check_block(cx, block, bindings) }, + { check_block(cx, block, bindings) } //ExprCall //ExprMethodCall ExprVec(ref v) | ExprTup(ref v) => @@ -211,11 +211,11 @@ fn check_expr(cx: &LateContext, expr: &Expr, bindings: &mut Vec<(Name, Span)>) { check_expr(cx, cond, bindings); check_block(cx, then, bindings); if let &Some(ref o) = otherwise { check_expr(cx, o, bindings); } - }, + } ExprWhile(ref cond, ref block, _) => { check_expr(cx, cond, bindings); check_block(cx, block, bindings); - }, + } ExprMatch(ref init, ref arms, _) => { check_expr(cx, init, bindings); let len = bindings.len(); @@ -230,7 +230,7 @@ fn check_expr(cx: &LateContext, expr: &Expr, bindings: &mut Vec<(Name, Span)>) { bindings.truncate(len); } } - }, + } _ => () } } @@ -242,10 +242,10 @@ fn check_ty(cx: &LateContext, ty: &Ty, bindings: &mut Vec<(Name, Span)>) { TyFixedLengthVec(ref fty, ref expr) => { check_ty(cx, fty, bindings); check_expr(cx, expr, bindings); - }, + } TyPtr(MutTy{ ty: ref mty, .. }) | TyRptr(_, MutTy{ ty: ref mty, .. }) => check_ty(cx, mty, bindings), - TyTup(ref tup) => { for ref t in tup { check_ty(cx, t, bindings) } }, + TyTup(ref tup) => { for ref t in tup { check_ty(cx, t, bindings) } } TyTypeof(ref expr) => check_expr(cx, expr, bindings), _ => (), } diff --git a/src/types.rs b/src/types.rs index 93962586bc6..68120f65e1f 100644 --- a/src/types.rs +++ b/src/types.rs @@ -229,7 +229,7 @@ impl LateLintPass for CastPass { if is_isize_or_usize(cast_from) || from_nbits >= to_nbits { span_precision_loss_lint(cx, expr, cast_from, to_nbits == 64); } - }, + } (false, true) => { span_lint(cx, CAST_POSSIBLE_TRUNCATION, expr.span, &format!("casting {} to {} may truncate the value", @@ -239,7 +239,7 @@ impl LateLintPass for CastPass { &format!("casting {} to {} may lose the sign of the value", cast_from, cast_to)); } - }, + } (true, true) => { if cast_from.is_signed() && !cast_to.is_signed() { span_lint(cx, CAST_SIGN_LOSS, expr.span, diff --git a/src/utils.rs b/src/utils.rs index e56eab5ad28..3fcfa66259c 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -167,7 +167,7 @@ pub fn get_item_name(cx: &LateContext, expr: &Expr) -> Option { Some(NodeTraitItem(&TraitItem{ id: _, ref name, .. })) | Some(NodeImplItem(&ImplItem{ id: _, ref name, .. })) => { Some(*name) - }, + } _ => None, } } diff --git a/tests/compile-fail/matches.rs b/tests/compile-fail/matches.rs index ff92a67271b..20d7552d77a 100644 --- a/tests/compile-fail/matches.rs +++ b/tests/compile-fail/matches.rs @@ -54,17 +54,17 @@ fn match_bool() { match test { //~ ERROR you seem to be trying to match on a boolean expression true => (), - false => { println!("Noooo!"); }, + false => { println!("Noooo!"); } }; match test { //~ ERROR you seem to be trying to match on a boolean expression - false => { println!("Noooo!"); }, + false => { println!("Noooo!"); } _ => (), }; match test { //~ ERROR you seem to be trying to match on a boolean expression - false => { println!("Noooo!"); }, - true => { println!("Yes!"); }, + false => { println!("Noooo!"); } + true => { println!("Yes!"); } }; // Not linted