Skip to content

Commit 2a8fca5

Browse files
committed
Mostly apply rustfmt
1 parent 484e219 commit 2a8fca5

File tree

6 files changed

+42
-41
lines changed

6 files changed

+42
-41
lines changed

clippy_lints/src/array_indexing.rs

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use rustc::lint::*;
22
use rustc::middle::const_val::ConstVal;
33
use rustc::ty;
44
use rustc_const_eval::ConstContext;
5-
use rustc_const_math::{ConstUsize,ConstIsize,ConstInt};
5+
use rustc_const_math::{ConstUsize, ConstIsize, ConstInt};
66
use rustc::hir;
77
use syntax::ast::RangeLimits;
88
use utils::{self, higher};
@@ -60,7 +60,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ArrayIndexing {
6060
// Array with known size can be checked statically
6161
let ty = cx.tables.expr_ty(array);
6262
if let ty::TyArray(_, size) = ty.sty {
63-
let size = ConstInt::Usize(ConstUsize::new(size as u64, cx.sess().target.uint_type).expect("array size is invalid"));
63+
let size = ConstInt::Usize(ConstUsize::new(size as u64, cx.sess().target.uint_type)
64+
.expect("array size is invalid"));
6465
let constcx = ConstContext::with_tables(cx.tcx, cx.tables);
6566

6667
// Index is a constant uint
@@ -123,23 +124,24 @@ fn to_const_range(
123124
Some(Some(ConstVal::Integral(x))) => {
124125
if limits == RangeLimits::Closed {
125126
match x {
126-
ConstInt::U8(_) => (x + ConstInt::U8(1)),
127-
ConstInt::U16(_) => (x + ConstInt::U16(1)),
128-
ConstInt::U32(_) => (x + ConstInt::U32(1)),
129-
ConstInt::U64(_) => (x + ConstInt::U64(1)),
130-
ConstInt::U128(_) => (x + ConstInt::U128(1)),
131-
ConstInt::Usize(ConstUsize::Us16(_)) => (x + ConstInt::Usize(ConstUsize::Us16(1))),
132-
ConstInt::Usize(ConstUsize::Us32(_)) => (x + ConstInt::Usize(ConstUsize::Us32(1))),
133-
ConstInt::Usize(ConstUsize::Us64(_)) => (x + ConstInt::Usize(ConstUsize::Us64(1))),
134-
ConstInt::I8(_) => (x + ConstInt::I8(1)),
135-
ConstInt::I16(_) => (x + ConstInt::I16(1)),
136-
ConstInt::I32(_) => (x + ConstInt::I32(1)),
137-
ConstInt::I64(_) => (x + ConstInt::I64(1)),
138-
ConstInt::I128(_) => (x + ConstInt::I128(1)),
139-
ConstInt::Isize(ConstIsize::Is16(_)) => (x + ConstInt::Isize(ConstIsize::Is16(1))),
140-
ConstInt::Isize(ConstIsize::Is32(_)) => (x + ConstInt::Isize(ConstIsize::Is32(1))),
141-
ConstInt::Isize(ConstIsize::Is64(_)) => (x + ConstInt::Isize(ConstIsize::Is64(1))),
142-
}.expect("such a big array is not realistic")
127+
ConstInt::U8(_) => (x + ConstInt::U8(1)),
128+
ConstInt::U16(_) => (x + ConstInt::U16(1)),
129+
ConstInt::U32(_) => (x + ConstInt::U32(1)),
130+
ConstInt::U64(_) => (x + ConstInt::U64(1)),
131+
ConstInt::U128(_) => (x + ConstInt::U128(1)),
132+
ConstInt::Usize(ConstUsize::Us16(_)) => (x + ConstInt::Usize(ConstUsize::Us16(1))),
133+
ConstInt::Usize(ConstUsize::Us32(_)) => (x + ConstInt::Usize(ConstUsize::Us32(1))),
134+
ConstInt::Usize(ConstUsize::Us64(_)) => (x + ConstInt::Usize(ConstUsize::Us64(1))),
135+
ConstInt::I8(_) => (x + ConstInt::I8(1)),
136+
ConstInt::I16(_) => (x + ConstInt::I16(1)),
137+
ConstInt::I32(_) => (x + ConstInt::I32(1)),
138+
ConstInt::I64(_) => (x + ConstInt::I64(1)),
139+
ConstInt::I128(_) => (x + ConstInt::I128(1)),
140+
ConstInt::Isize(ConstIsize::Is16(_)) => (x + ConstInt::Isize(ConstIsize::Is16(1))),
141+
ConstInt::Isize(ConstIsize::Is32(_)) => (x + ConstInt::Isize(ConstIsize::Is32(1))),
142+
ConstInt::Isize(ConstIsize::Is64(_)) => (x + ConstInt::Isize(ConstIsize::Is64(1))),
143+
}
144+
.expect("such a big array is not realistic")
143145
} else {
144146
x
145147
}

clippy_lints/src/consts.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc::hir::def::Def;
55
use rustc_const_eval::lookup_const_by_id;
66
use rustc_const_math::ConstInt;
77
use rustc::hir::*;
8-
use rustc::ty::{TyCtxt, self};
8+
use rustc::ty::{self, TyCtxt};
99
use std::cmp::Ordering::{self, Equal};
1010
use std::cmp::PartialOrd;
1111
use std::hash::{Hash, Hasher};
@@ -179,17 +179,15 @@ pub fn lit_to_constant<'a, 'tcx>(lit: &LitKind, tcx: TyCtxt<'a, 'tcx, 'tcx>, mut
179179
match (&ty.sty, hint) {
180180
(&ty::TyInt(ity), _) |
181181
(_, Signed(ity)) => {
182-
Constant::Int(ConstInt::new_signed_truncating(n as i128,
183-
ity, tcx.sess.target.int_type))
184-
}
182+
Constant::Int(ConstInt::new_signed_truncating(n as i128, ity, tcx.sess.target.int_type))
183+
},
185184
(&ty::TyUint(uty), _) |
186185
(_, Unsigned(uty)) => {
187-
Constant::Int(ConstInt::new_unsigned_truncating(n as u128,
188-
uty, tcx.sess.target.uint_type))
189-
}
190-
_ => bug!()
186+
Constant::Int(ConstInt::new_unsigned_truncating(n as u128, uty, tcx.sess.target.uint_type))
187+
},
188+
_ => bug!(),
191189
}
192-
}
190+
},
193191
LitKind::Float(ref is, ty) => Constant::Float(is.to_string(), ty.into()),
194192
LitKind::FloatUnsuffixed(ref is) => Constant::Float(is.to_string(), FloatWidth::Any),
195193
LitKind::Bool(b) => Constant::Bool(b),
@@ -291,7 +289,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
291289
if let Some((const_expr, tables)) = lookup_const_by_id(self.tcx, def_id, substs) {
292290
let mut cx = ConstEvalLateContext {
293291
tcx: self.tcx,
294-
tables,
292+
tables: tables,
295293
needed_resolution: false,
296294
};
297295
let ret = cx.expr(const_expr);

clippy_lints/src/eta_reduction.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ fn check_closure(cx: &LateContext, expr: &Expr) {
6666
// Is it an unsafe function? They don't implement the closure traits
6767
ty::TyFnDef(_, _, fn_ty) |
6868
ty::TyFnPtr(fn_ty) => {
69-
if fn_ty.skip_binder().unsafety == Unsafety::Unsafe || fn_ty.skip_binder().output().sty == ty::TyNever {
69+
if fn_ty.skip_binder().unsafety == Unsafety::Unsafe ||
70+
fn_ty.skip_binder().output().sty == ty::TyNever {
7071
return;
7172
}
7273
},

clippy_lints/src/matches.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -211,14 +211,14 @@ fn report_single_match_single_pattern(cx: &LateContext, ex: &Expr, arms: &[Arm],
211211
};
212212
let els_str = els.map_or(String::new(), |els| format!(" else {}", expr_block(cx, els, None, "..")));
213213
span_lint_and_then(cx,
214-
lint,
215-
expr.span,
216-
"you seem to be trying to use match for destructuring a single pattern. \
217-
Consider using `if let`",
218-
|db| {
214+
lint,
215+
expr.span,
216+
"you seem to be trying to use match for destructuring a single pattern. Consider using `if \
217+
let`",
218+
|db| {
219219
db.span_suggestion(expr.span,
220-
"try this",
221-
format!("if let {} = {} {}{}",
220+
"try this",
221+
format!("if let {} = {} {}{}",
222222
snippet(cx, arms[0].pats[0].span, ".."),
223223
snippet(cx, ex.span, ".."),
224224
expr_block(cx, &arms[0].body, None, ".."),

clippy_lints/src/misc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ fn is_allowed(cx: &LateContext, expr: &Expr) -> bool {
382382

383383
val.try_cmp(zero) == Ok(Ordering::Equal) || val.try_cmp(infinity) == Ok(Ordering::Equal) ||
384384
val.try_cmp(neg_infinity) == Ok(Ordering::Equal)
385-
}
385+
},
386386
}
387387
} else {
388388
false

clippy_lints/src/utils/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -975,7 +975,7 @@ pub fn is_try(expr: &Expr) -> Option<&Expr> {
975975
}
976976

977977
pub fn type_size<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: ty::Ty<'tcx>) -> Option<u64> {
978-
cx.tcx.infer_ctxt((), Reveal::All).enter(|infcx|
979-
ty.layout(&infcx).ok().map(|lay| lay.size(&TargetDataLayout::parse(cx.sess())).bytes())
980-
)
978+
cx.tcx
979+
.infer_ctxt((), Reveal::All)
980+
.enter(|infcx| ty.layout(&infcx).ok().map(|lay| lay.size(&TargetDataLayout::parse(cx.sess())).bytes()))
981981
}

0 commit comments

Comments
 (0)