rustfmt a little

This commit is contained in:
Seo Sanghyeon 2015-11-17 14:22:57 +09:00
parent 51a25295fd
commit 1d602d0f12
7 changed files with 16 additions and 14 deletions

View file

@ -17,7 +17,7 @@ pub struct MinMaxPass;
impl LintPass for MinMaxPass {
fn get_lints(&self) -> LintArray {
lint_array!(MIN_MAX)
lint_array!(MIN_MAX)
}
}

View file

@ -19,7 +19,7 @@ impl LintPass for MutMut {
impl LateLintPass for MutMut {
fn check_expr(&mut self, cx: &LateContext, expr: &Expr) {
check_expr_mut(cx, expr)
check_expr_mut(cx, expr)
}
fn check_ty(&mut self, cx: &LateContext, ty: &Ty) {
@ -31,7 +31,7 @@ impl LateLintPass for MutMut {
fn check_expr_mut(cx: &LateContext, expr: &Expr) {
if in_external_macro(cx, expr.span) { return; }
fn unwrap_addr(expr : &Expr) -> Option<&Expr> {
fn unwrap_addr(expr: &Expr) -> Option<&Expr> {
match expr.node {
ExprAddrOf(MutMutable, ref e) => Option::Some(e),
_ => Option::None
@ -53,7 +53,7 @@ fn check_expr_mut(cx: &LateContext, expr: &Expr) {
})
}
fn unwrap_mut(ty : &Ty) -> Option<&Ty> {
fn unwrap_mut(ty: &Ty) -> Option<&Ty> {
match ty.node {
TyRptr(_, MutTy{ ty: ref pty, mutbl: MutMutable }) => Option::Some(pty),
_ => Option::None

View file

@ -31,10 +31,12 @@ 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 {

View file

@ -5,7 +5,7 @@
use rustc::lint::*;
use rustc_front::hir::*;
use utils::{span_lint};
use utils::span_lint;
use utils;
declare_lint! {
@ -27,7 +27,7 @@ pub struct NeedlessFeaturesPass;
impl LintPass for NeedlessFeaturesPass {
fn get_lints(&self) -> LintArray {
lint_array!(UNSTABLE_AS_SLICE,UNSTABLE_AS_MUT_SLICE)
lint_array!(UNSTABLE_AS_SLICE, UNSTABLE_AS_MUT_SLICE)
}
}

View file

@ -53,7 +53,7 @@ impl EarlyLintPass for Precedence {
method call. Consider adding parentheses \
to clarify your intent: -({})",
snippet(cx, rhs.span, ".."))),
_ => ()
_ => ()
}
}
}
@ -62,21 +62,21 @@ impl EarlyLintPass for Precedence {
}
}
fn is_arith_expr(expr : &Expr) -> bool {
fn is_arith_expr(expr: &Expr) -> bool {
match expr.node {
ExprBinary(Spanned { node: op, ..}, _, _) => is_arith_op(op),
_ => false
}
}
fn is_bit_op(op : BinOp_) -> bool {
fn is_bit_op(op: BinOp_) -> bool {
match op {
BiBitXor | BiBitAnd | BiBitOr | BiShl | BiShr => true,
_ => false
}
}
fn is_arith_op(op : BinOp_) -> bool {
fn is_arith_op(op: BinOp_) -> bool {
match op {
BiAdd | BiSub | BiMul | BiDiv | BiRem => true,
_ => false

View file

@ -51,7 +51,7 @@ impl LateLintPass for StringAdd {
"you added something to a string. \
Consider using `String::push_str()` instead")
}
} else if let &ExprAssign(ref target, ref src) = &e.node {
} else if let &ExprAssign(ref target, ref src) = &e.node {
if is_string(cx, target) && is_add(cx, src, target) {
span_lint(cx, STRING_ADD_ASSIGN, e.span,
"you assigned the result of adding something to this string. \

View file

@ -1,7 +1,7 @@
use rustc::lint::*;
use rustc_front::hir::*;
use utils::{span_help_and_lint};
use utils::span_help_and_lint;
use consts::{Constant, constant_simple, FloatWidth};
/// ZeroDivZeroPass is a pass that checks for a binary expression that consists