]> git.lizzy.rs Git - rust.git/commitdiff
Mostly apply rustfmt
authorOliver Schneider <git-no-reply-9879165716479413131@oli-obk.de>
Sun, 5 Mar 2017 09:27:20 +0000 (10:27 +0100)
committerOliver Schneider <git-no-reply-9879165716479413131@oli-obk.de>
Sun, 5 Mar 2017 09:27:20 +0000 (10:27 +0100)
clippy_lints/src/array_indexing.rs
clippy_lints/src/consts.rs
clippy_lints/src/eta_reduction.rs
clippy_lints/src/matches.rs
clippy_lints/src/misc.rs
clippy_lints/src/utils/mod.rs

index 1cd57e632ca71d2487b23a68b40882b8f8b195ac..dd5baaadca6ce613f147cc6834505c89c6e4c670 100644 (file)
@@ -2,7 +2,7 @@
 use rustc::middle::const_val::ConstVal;
 use rustc::ty;
 use rustc_const_eval::ConstContext;
-use rustc_const_math::{ConstUsize,ConstIsize,ConstInt};
+use rustc_const_math::{ConstUsize, ConstIsize, ConstInt};
 use rustc::hir;
 use syntax::ast::RangeLimits;
 use utils::{self, higher};
@@ -60,7 +60,8 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx hir::Expr) {
             // Array with known size can be checked statically
             let ty = cx.tables.expr_ty(array);
             if let ty::TyArray(_, size) = ty.sty {
-                let size = ConstInt::Usize(ConstUsize::new(size as u64, cx.sess().target.uint_type).expect("array size is invalid"));
+                let size = ConstInt::Usize(ConstUsize::new(size as u64, cx.sess().target.uint_type)
+                    .expect("array size is invalid"));
                 let constcx = ConstContext::with_tables(cx.tcx, cx.tables);
 
                 // Index is a constant uint
@@ -123,23 +124,24 @@ fn to_const_range(
         Some(Some(ConstVal::Integral(x))) => {
             if limits == RangeLimits::Closed {
                 match x {
-                    ConstInt::U8(_) => (x + ConstInt::U8(1)),
-                    ConstInt::U16(_) => (x + ConstInt::U16(1)),
-                    ConstInt::U32(_) => (x + ConstInt::U32(1)),
-                    ConstInt::U64(_) => (x + ConstInt::U64(1)),
-                    ConstInt::U128(_) => (x + ConstInt::U128(1)),
-                    ConstInt::Usize(ConstUsize::Us16(_)) => (x + ConstInt::Usize(ConstUsize::Us16(1))),
-                    ConstInt::Usize(ConstUsize::Us32(_)) => (x + ConstInt::Usize(ConstUsize::Us32(1))),
-                    ConstInt::Usize(ConstUsize::Us64(_)) => (x + ConstInt::Usize(ConstUsize::Us64(1))),
-                    ConstInt::I8(_) => (x + ConstInt::I8(1)),
-                    ConstInt::I16(_) => (x + ConstInt::I16(1)),
-                    ConstInt::I32(_) => (x + ConstInt::I32(1)),
-                    ConstInt::I64(_) => (x + ConstInt::I64(1)),
-                    ConstInt::I128(_) => (x + ConstInt::I128(1)),
-                    ConstInt::Isize(ConstIsize::Is16(_)) => (x + ConstInt::Isize(ConstIsize::Is16(1))),
-                    ConstInt::Isize(ConstIsize::Is32(_)) => (x + ConstInt::Isize(ConstIsize::Is32(1))),
-                    ConstInt::Isize(ConstIsize::Is64(_)) => (x + ConstInt::Isize(ConstIsize::Is64(1))),
-                }.expect("such a big array is not realistic")
+                        ConstInt::U8(_) => (x + ConstInt::U8(1)),
+                        ConstInt::U16(_) => (x + ConstInt::U16(1)),
+                        ConstInt::U32(_) => (x + ConstInt::U32(1)),
+                        ConstInt::U64(_) => (x + ConstInt::U64(1)),
+                        ConstInt::U128(_) => (x + ConstInt::U128(1)),
+                        ConstInt::Usize(ConstUsize::Us16(_)) => (x + ConstInt::Usize(ConstUsize::Us16(1))),
+                        ConstInt::Usize(ConstUsize::Us32(_)) => (x + ConstInt::Usize(ConstUsize::Us32(1))),
+                        ConstInt::Usize(ConstUsize::Us64(_)) => (x + ConstInt::Usize(ConstUsize::Us64(1))),
+                        ConstInt::I8(_) => (x + ConstInt::I8(1)),
+                        ConstInt::I16(_) => (x + ConstInt::I16(1)),
+                        ConstInt::I32(_) => (x + ConstInt::I32(1)),
+                        ConstInt::I64(_) => (x + ConstInt::I64(1)),
+                        ConstInt::I128(_) => (x + ConstInt::I128(1)),
+                        ConstInt::Isize(ConstIsize::Is16(_)) => (x + ConstInt::Isize(ConstIsize::Is16(1))),
+                        ConstInt::Isize(ConstIsize::Is32(_)) => (x + ConstInt::Isize(ConstIsize::Is32(1))),
+                        ConstInt::Isize(ConstIsize::Is64(_)) => (x + ConstInt::Isize(ConstIsize::Is64(1))),
+                    }
+                    .expect("such a big array is not realistic")
             } else {
                 x
             }
index 3b624ff3d6cde0c2d3c12d5bab5bd2a395a991f9..7be6f6bf0d6e365ce3eb4c486c634b5e1541752a 100644 (file)
@@ -5,7 +5,7 @@
 use rustc_const_eval::lookup_const_by_id;
 use rustc_const_math::ConstInt;
 use rustc::hir::*;
-use rustc::ty::{TyCtxt, self};
+use rustc::ty::{self, TyCtxt};
 use std::cmp::Ordering::{self, Equal};
 use std::cmp::PartialOrd;
 use std::hash::{Hash, Hasher};
@@ -179,17 +179,15 @@ pub fn lit_to_constant<'a, 'tcx>(lit: &LitKind, tcx: TyCtxt<'a, 'tcx, 'tcx>, mut
             match (&ty.sty, hint) {
                 (&ty::TyInt(ity), _) |
                 (_, Signed(ity)) => {
-                    Constant::Int(ConstInt::new_signed_truncating(n as i128,
-                        ity, tcx.sess.target.int_type))
-                }
+                    Constant::Int(ConstInt::new_signed_truncating(n as i128, ity, tcx.sess.target.int_type))
+                },
                 (&ty::TyUint(uty), _) |
                 (_, Unsigned(uty)) => {
-                    Constant::Int(ConstInt::new_unsigned_truncating(n as u128,
-                        uty, tcx.sess.target.uint_type))
-                }
-                _ => bug!()
+                    Constant::Int(ConstInt::new_unsigned_truncating(n as u128, uty, tcx.sess.target.uint_type))
+                },
+                _ => bug!(),
             }
-        }
+        },
         LitKind::Float(ref is, ty) => Constant::Float(is.to_string(), ty.into()),
         LitKind::FloatUnsuffixed(ref is) => Constant::Float(is.to_string(), FloatWidth::Any),
         LitKind::Bool(b) => Constant::Bool(b),
@@ -291,7 +289,7 @@ fn fetch_path(&mut self, qpath: &QPath, id: NodeId) -> Option<Constant> {
                 if let Some((const_expr, tables)) = lookup_const_by_id(self.tcx, def_id, substs) {
                     let mut cx = ConstEvalLateContext {
                         tcx: self.tcx,
-                        tables,
+                        tables: tables,
                         needed_resolution: false,
                     };
                     let ret = cx.expr(const_expr);
index 8230fe7313033bb839e05eed1229b1743d5bb184..d2b07661d5b5b2f82e39b08405c8c88a9ddcf3ee 100644 (file)
@@ -66,7 +66,8 @@ fn check_closure(cx: &LateContext, expr: &Expr) {
                 // Is it an unsafe function? They don't implement the closure traits
                 ty::TyFnDef(_, _, fn_ty) |
                 ty::TyFnPtr(fn_ty) => {
-                    if fn_ty.skip_binder().unsafety == Unsafety::Unsafe || fn_ty.skip_binder().output().sty == ty::TyNever {
+                    if fn_ty.skip_binder().unsafety == Unsafety::Unsafe ||
+                       fn_ty.skip_binder().output().sty == ty::TyNever {
                         return;
                     }
                 },
index 8729a39733ac5597bcf11137f85db8c9f6eb0bbe..90b616b20d4b01a098155d14dfa3271f148894ae 100644 (file)
@@ -211,14 +211,14 @@ fn report_single_match_single_pattern(cx: &LateContext, ex: &Expr, arms: &[Arm],
     };
     let els_str = els.map_or(String::new(), |els| format!(" else {}", expr_block(cx, els, None, "..")));
     span_lint_and_then(cx,
-                        lint,
-                        expr.span,
-                        "you seem to be trying to use match for destructuring a single pattern. \
-                        Consider using `if let`",
-                        |db| {
+                       lint,
+                       expr.span,
+                       "you seem to be trying to use match for destructuring a single pattern. Consider using `if \
+                        let`",
+                       |db| {
         db.span_suggestion(expr.span,
-                            "try this",
-                            format!("if let {} = {} {}{}",
+                           "try this",
+                           format!("if let {} = {} {}{}",
                                     snippet(cx, arms[0].pats[0].span, ".."),
                                     snippet(cx, ex.span, ".."),
                                     expr_block(cx, &arms[0].body, None, ".."),
index 3fb9101076dac9ad1fd29550639261db9f5501fd..b4e79a1401de15ec0fd6d33f3c2876de82ea71d5 100644 (file)
@@ -382,7 +382,7 @@ fn is_allowed(cx: &LateContext, expr: &Expr) -> bool {
 
                 val.try_cmp(zero) == Ok(Ordering::Equal) || val.try_cmp(infinity) == Ok(Ordering::Equal) ||
                 val.try_cmp(neg_infinity) == Ok(Ordering::Equal)
-            }
+            },
         }
     } else {
         false
index 32e8c90ad993ef6f5422bd57f5fa57e3e243eeec..693b14d1b9997a028cec7eb61a0778dbc6e3ac63 100644 (file)
@@ -975,7 +975,7 @@ fn is_err(arm: &Arm) -> bool {
 }
 
 pub fn type_size<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: ty::Ty<'tcx>) -> Option<u64> {
-    cx.tcx.infer_ctxt((), Reveal::All).enter(|infcx|
-        ty.layout(&infcx).ok().map(|lay| lay.size(&TargetDataLayout::parse(cx.sess())).bytes())
-    )
+    cx.tcx
+        .infer_ctxt((), Reveal::All)
+        .enter(|infcx| ty.layout(&infcx).ok().map(|lay| lay.size(&TargetDataLayout::parse(cx.sess())).bytes()))
 }