]> git.lizzy.rs Git - rust.git/commitdiff
Code style tweaks.
authorHuon Wilson <dbau.pp+github@gmail.com>
Thu, 13 Aug 2015 23:00:44 +0000 (16:00 -0700)
committerHuon Wilson <dbau.pp+github@gmail.com>
Mon, 17 Aug 2015 21:41:40 +0000 (14:41 -0700)
src/librustc_trans/trans/intrinsic.rs

index 90a85e873645803cdd34125290d9b10db077d666..18ea4387bf22f64e9452361ed85d3366563fee9b 100644 (file)
@@ -918,37 +918,36 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
         }
 
         (_, _) => {
-            match Intrinsic::find(tcx, &name) {
+            let intr = match Intrinsic::find(tcx, &name) {
+                Some(intr) => intr,
                 None => ccx.sess().span_bug(foreign_item.span, "unknown intrinsic"),
-                Some(intr) => {
-                    fn ty_to_type(ccx: &CrateContext, t: &intrinsics::Type) -> Type {
-                        use intrinsics::Type::*;
-                        match *t {
-                            Integer(x) => Type::ix(ccx, x as u64),
-                            Float(x) => {
-                                match x {
-                                    32 => Type::f32(ccx),
-                                    64 => Type::f64(ccx),
-                                    _ => unreachable!()
-                                }
-                            }
-                            Pointer(_) => unimplemented!(),
-                            Vector(ref t, length) => Type::vector(&ty_to_type(ccx, t),
-                                                                  length as u64)
+            };
+            fn ty_to_type(ccx: &CrateContext, t: &intrinsics::Type) -> Type {
+                use intrinsics::Type::*;
+                match *t {
+                    Integer(x) => Type::ix(ccx, x as u64),
+                    Float(x) => {
+                        match x {
+                            32 => Type::f32(ccx),
+                            64 => Type::f64(ccx),
+                            _ => unreachable!()
                         }
                     }
+                    Pointer(_) => unimplemented!(),
+                    Vector(ref t, length) => Type::vector(&ty_to_type(ccx, t),
+                                                          length as u64)
+                }
+            }
 
-                    let inputs = intr.inputs.iter().map(|t| ty_to_type(ccx, t)).collect::<Vec<_>>();
-                    let outputs = ty_to_type(ccx, &intr.output);
-                    match intr.definition {
-                        intrinsics::IntrinsicDef::Named(name) => {
-                            let f = declare::declare_cfn(ccx,
-                                                         name,
-                                                         Type::func(&inputs, &outputs),
-                                                         tcx.mk_nil());
-                            Call(bcx, f, &llargs, None, call_debug_location)
-                        }
-                    }
+            let inputs = intr.inputs.iter().map(|t| ty_to_type(ccx, t)).collect::<Vec<_>>();
+            let outputs = ty_to_type(ccx, &intr.output);
+            match intr.definition {
+                intrinsics::IntrinsicDef::Named(name) => {
+                    let f = declare::declare_cfn(ccx,
+                                                 name,
+                                                 Type::func(&inputs, &outputs),
+                                                 tcx.mk_nil());
+                    Call(bcx, f, &llargs, None, call_debug_location)
                 }
             }
         }
@@ -1330,6 +1329,15 @@ fn generic_simd_intrinsic<'blk, 'tcx, 'a>
      call_debug_location: DebugLoc,
      call_info: NodeIdAndSpan) -> ValueRef
 {
+    macro_rules! require {
+        ($cond: expr, $($fmt: tt)*) => {
+            if !$cond {
+                bcx.sess().span_err(call_info.span, &format!($($fmt)*));
+                return C_null(llret_ty)
+            }
+        }
+    }
+
     let tcx = bcx.tcx();
     let arg_tys = match callee_ty.sty {
         ty::TyBareFn(_, ref f) => {
@@ -1348,15 +1356,6 @@ fn generic_simd_intrinsic<'blk, 'tcx, 'a>
         _ => None
     };
 
-    macro_rules! require {
-        ($cond: expr, $($fmt: tt)*) => {
-            if !$cond {
-                bcx.sess().span_err(call_info.span, &format!($($fmt)*));
-                return C_null(llret_ty)
-            }
-        }
-    }
-
     if let Some(cmp_op) = comparison {
         assert_eq!(arg_tys.len(), 2);
         require!(arg_tys[0].is_simd(tcx),