Skip to content

Commit e4524ac

Browse files
committed
Run nightly rustfmt
1 parent c710ac8 commit e4524ac

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+1791
-2048
lines changed

clippy_lints/src/approx_const.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use rustc::lint::*;
22
use rustc::hir::*;
33
use std::f64::consts as f64;
4-
use syntax::ast::{Lit, LitKind, FloatTy};
4+
use syntax::ast::{FloatTy, Lit, LitKind};
55
use syntax::symbol;
66
use utils::span_lint;
77

@@ -91,7 +91,7 @@ fn check_known_consts(cx: &LateContext, e: &Expr, s: &symbol::Symbol, module: &s
9191
e.span,
9292
&format!(
9393
"approximate value of `{}::consts::{}` found. \
94-
Consider using it directly",
94+
Consider using it directly",
9595
module,
9696
&name
9797
),

clippy_lints/src/arithmetic.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,19 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Arithmetic {
5555
match expr.node {
5656
hir::ExprBinary(ref op, ref l, ref r) => {
5757
match op.node {
58-
hir::BiAnd | hir::BiOr | hir::BiBitAnd | hir::BiBitOr | hir::BiBitXor | hir::BiShl |
59-
hir::BiShr | hir::BiEq | hir::BiLt | hir::BiLe | hir::BiNe | hir::BiGe | hir::BiGt => return,
58+
hir::BiAnd |
59+
hir::BiOr |
60+
hir::BiBitAnd |
61+
hir::BiBitOr |
62+
hir::BiBitXor |
63+
hir::BiShl |
64+
hir::BiShr |
65+
hir::BiEq |
66+
hir::BiLt |
67+
hir::BiLe |
68+
hir::BiNe |
69+
hir::BiGe |
70+
hir::BiGt => return,
6071
_ => (),
6172
}
6273
let (l_ty, r_ty) = (cx.tables.expr_ty(l), cx.tables.expr_ty(r));

clippy_lints/src/array_indexing.rs

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use rustc::middle::const_val::ConstVal;
33
use rustc::ty;
44
use rustc::ty::subst::Substs;
55
use rustc_const_eval::ConstContext;
6-
use rustc_const_math::{ConstUsize, ConstIsize, ConstInt};
6+
use rustc_const_math::{ConstInt, ConstIsize, ConstUsize};
77
use rustc::hir;
88
use syntax::ast::RangeLimits;
99
use utils::{self, higher};
@@ -124,29 +124,27 @@ fn to_const_range(
124124
};
125125

126126
let end = match *end {
127-
Some(Some(ConstVal::Integral(x))) => {
128-
if limits == RangeLimits::Closed {
129-
match x {
130-
ConstInt::U8(_) => (x + ConstInt::U8(1)),
131-
ConstInt::U16(_) => (x + ConstInt::U16(1)),
132-
ConstInt::U32(_) => (x + ConstInt::U32(1)),
133-
ConstInt::U64(_) => (x + ConstInt::U64(1)),
134-
ConstInt::U128(_) => (x + ConstInt::U128(1)),
135-
ConstInt::Usize(ConstUsize::Us16(_)) => (x + ConstInt::Usize(ConstUsize::Us16(1))),
136-
ConstInt::Usize(ConstUsize::Us32(_)) => (x + ConstInt::Usize(ConstUsize::Us32(1))),
137-
ConstInt::Usize(ConstUsize::Us64(_)) => (x + ConstInt::Usize(ConstUsize::Us64(1))),
138-
ConstInt::I8(_) => (x + ConstInt::I8(1)),
139-
ConstInt::I16(_) => (x + ConstInt::I16(1)),
140-
ConstInt::I32(_) => (x + ConstInt::I32(1)),
141-
ConstInt::I64(_) => (x + ConstInt::I64(1)),
142-
ConstInt::I128(_) => (x + ConstInt::I128(1)),
143-
ConstInt::Isize(ConstIsize::Is16(_)) => (x + ConstInt::Isize(ConstIsize::Is16(1))),
144-
ConstInt::Isize(ConstIsize::Is32(_)) => (x + ConstInt::Isize(ConstIsize::Is32(1))),
145-
ConstInt::Isize(ConstIsize::Is64(_)) => (x + ConstInt::Isize(ConstIsize::Is64(1))),
146-
}.expect("such a big array is not realistic")
147-
} else {
148-
x
149-
}
127+
Some(Some(ConstVal::Integral(x))) => if limits == RangeLimits::Closed {
128+
match x {
129+
ConstInt::U8(_) => (x + ConstInt::U8(1)),
130+
ConstInt::U16(_) => (x + ConstInt::U16(1)),
131+
ConstInt::U32(_) => (x + ConstInt::U32(1)),
132+
ConstInt::U64(_) => (x + ConstInt::U64(1)),
133+
ConstInt::U128(_) => (x + ConstInt::U128(1)),
134+
ConstInt::Usize(ConstUsize::Us16(_)) => (x + ConstInt::Usize(ConstUsize::Us16(1))),
135+
ConstInt::Usize(ConstUsize::Us32(_)) => (x + ConstInt::Usize(ConstUsize::Us32(1))),
136+
ConstInt::Usize(ConstUsize::Us64(_)) => (x + ConstInt::Usize(ConstUsize::Us64(1))),
137+
ConstInt::I8(_) => (x + ConstInt::I8(1)),
138+
ConstInt::I16(_) => (x + ConstInt::I16(1)),
139+
ConstInt::I32(_) => (x + ConstInt::I32(1)),
140+
ConstInt::I64(_) => (x + ConstInt::I64(1)),
141+
ConstInt::I128(_) => (x + ConstInt::I128(1)),
142+
ConstInt::Isize(ConstIsize::Is16(_)) => (x + ConstInt::Isize(ConstIsize::Is16(1))),
143+
ConstInt::Isize(ConstIsize::Is32(_)) => (x + ConstInt::Isize(ConstIsize::Is32(1))),
144+
ConstInt::Isize(ConstIsize::Is64(_)) => (x + ConstInt::Isize(ConstIsize::Is64(1))),
145+
}.expect("such a big array is not realistic")
146+
} else {
147+
x
150148
},
151149
Some(_) => return None,
152150
None => array_size,

clippy_lints/src/assign_ops.rs

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use rustc::hir;
22
use rustc::lint::*;
33
use syntax::ast;
4-
use utils::{span_lint_and_then, snippet_opt, SpanlessEq, get_trait_def_id, implements_trait};
4+
use utils::{get_trait_def_id, implements_trait, snippet_opt, span_lint_and_then, SpanlessEq};
55
use utils::{higher, sugg};
66

77
/// **What it does:** Checks for compound assignment operations (`+=` and
@@ -88,19 +88,21 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps {
8888
if let hir::ExprBinary(binop, ref l, ref r) = rhs.node {
8989
if op.node == binop.node {
9090
let lint = |assignee: &hir::Expr, rhs: &hir::Expr| {
91-
span_lint_and_then(cx,
92-
MISREFACTORED_ASSIGN_OP,
93-
expr.span,
94-
"variable appears on both sides of an assignment operation",
95-
|db| if let (Some(snip_a), Some(snip_r)) =
96-
(snippet_opt(cx, assignee.span), snippet_opt(cx, rhs.span)) {
97-
db.span_suggestion(expr.span,
98-
"replace it with",
99-
format!("{} {}= {}",
100-
snip_a,
101-
op.node.as_str(),
102-
snip_r));
103-
});
91+
span_lint_and_then(
92+
cx,
93+
MISREFACTORED_ASSIGN_OP,
94+
expr.span,
95+
"variable appears on both sides of an assignment operation",
96+
|db| if let (Some(snip_a), Some(snip_r)) =
97+
(snippet_opt(cx, assignee.span), snippet_opt(cx, rhs.span))
98+
{
99+
db.span_suggestion(
100+
expr.span,
101+
"replace it with",
102+
format!("{} {}= {}", snip_a, op.node.as_str(), snip_r),
103+
);
104+
},
105+
);
104106
};
105107
// lhs op= l op r
106108
if SpanlessEq::new(cx).ignore_fn().eq_expr(lhs, l) {
@@ -167,8 +169,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps {
167169
BitXor: BiBitXor,
168170
Shr: BiShr,
169171
Shl: BiShl
170-
)
171-
{
172+
) {
172173
span_lint_and_then(
173174
cx,
174175
ASSIGN_OP_PATTERN,
@@ -193,7 +194,12 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps {
193194
// a = b commutative_op a
194195
if SpanlessEq::new(cx).ignore_fn().eq_expr(assignee, r) {
195196
match op.node {
196-
hir::BiAdd | hir::BiMul | hir::BiAnd | hir::BiOr | hir::BiBitXor | hir::BiBitAnd |
197+
hir::BiAdd |
198+
hir::BiMul |
199+
hir::BiAnd |
200+
hir::BiOr |
201+
hir::BiBitXor |
202+
hir::BiBitAnd |
197203
hir::BiBitOr => {
198204
lint(assignee, l);
199205
},

clippy_lints/src/attrs.rs

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc::ty::{self, TyCtxt};
77
use semver::Version;
88
use syntax::ast::{Attribute, Lit, LitKind, MetaItemKind, NestedMetaItem, NestedMetaItemKind};
99
use syntax::codemap::Span;
10-
use utils::{in_macro, match_def_path, paths, span_lint, span_lint_and_then, snippet_opt};
10+
use utils::{in_macro, match_def_path, paths, snippet_opt, span_lint, span_lint_and_then};
1111

1212
/// **What it does:** Checks for items annotated with `#[inline(always)]`,
1313
/// unless the annotated function is empty or simply panics.
@@ -110,8 +110,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass {
110110
check_attrs(cx, item.span, &item.name, &item.attrs)
111111
}
112112
match item.node {
113-
ItemExternCrate(_) |
114-
ItemUse(_, _) => {
113+
ItemExternCrate(_) | ItemUse(_, _) => {
115114
for attr in &item.attrs {
116115
if let Some(ref lint_list) = attr.meta_item_list() {
117116
if let Some(name) = attr.name() {
@@ -196,30 +195,26 @@ fn is_relevant_block(tcx: TyCtxt, tables: &ty::TypeckTables, block: &Block) -> b
196195
if let Some(stmt) = block.stmts.first() {
197196
match stmt.node {
198197
StmtDecl(_, _) => true,
199-
StmtExpr(ref expr, _) |
200-
StmtSemi(ref expr, _) => is_relevant_expr(tcx, tables, expr),
198+
StmtExpr(ref expr, _) | StmtSemi(ref expr, _) => is_relevant_expr(tcx, tables, expr),
201199
}
202200
} else {
203-
block.expr.as_ref().map_or(
204-
false,
205-
|e| is_relevant_expr(tcx, tables, e),
206-
)
201+
block
202+
.expr
203+
.as_ref()
204+
.map_or(false, |e| is_relevant_expr(tcx, tables, e))
207205
}
208206
}
209207

210208
fn is_relevant_expr(tcx: TyCtxt, tables: &ty::TypeckTables, expr: &Expr) -> bool {
211209
match expr.node {
212210
ExprBlock(ref block) => is_relevant_block(tcx, tables, block),
213211
ExprRet(Some(ref e)) => is_relevant_expr(tcx, tables, e),
214-
ExprRet(None) |
215-
ExprBreak(_, None) => false,
216-
ExprCall(ref path_expr, _) => {
217-
if let ExprPath(ref qpath) = path_expr.node {
218-
let fun_id = tables.qpath_def(qpath, path_expr.hir_id).def_id();
219-
!match_def_path(tcx, fun_id, &paths::BEGIN_PANIC)
220-
} else {
221-
true
222-
}
212+
ExprRet(None) | ExprBreak(_, None) => false,
213+
ExprCall(ref path_expr, _) => if let ExprPath(ref qpath) = path_expr.node {
214+
let fun_id = tables.qpath_def(qpath, path_expr.hir_id).def_id();
215+
!match_def_path(tcx, fun_id, &paths::BEGIN_PANIC)
216+
} else {
217+
true
223218
},
224219
_ => true,
225220
}

0 commit comments

Comments
 (0)