]> git.lizzy.rs Git - rust.git/commitdiff
Rustfmt
authorbjorn3 <bjorn3@users.noreply.github.com>
Sat, 8 Sep 2018 15:24:52 +0000 (17:24 +0200)
committerbjorn3 <bjorn3@users.noreply.github.com>
Sat, 8 Sep 2018 15:24:52 +0000 (17:24 +0200)
examples/mini_core.rs
src/abi.rs
src/base.rs
src/common.rs
src/lib.rs

index 5925bb6a254e5efb1e6f0db4eca3103831ea064e..318cfe49da184cc4de5f206ec9f3a3d6225bf122 100644 (file)
@@ -194,7 +194,7 @@ pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
 
 #[lang = "exchange_malloc"]
 unsafe fn allocate(size: usize, _align: usize) -> *mut u8 {
-     &mut MY_TINY_HEAP as *mut [u8; 16] as *mut u8
+    &mut MY_TINY_HEAP as *mut [u8; 16] as *mut u8
 }
 
 pub mod intrinsics {
index 3fd161ed6b0864f6d3e2c85d227480e88d2ccfde..f77009be9811add58ed2f37b2bea37c453e21182 100644 (file)
@@ -90,7 +90,8 @@ pub fn cton_sig_from_fn_ty<'a, 'tcx: 'a>(
         ),
         PassMode::ByRef => {
             (
-                Some(pointer_ty(tcx)).into_iter() // First param is place to put return val
+                Some(pointer_ty(tcx)) // First param is place to put return val
+                    .into_iter()
                     .chain(inputs)
                     .map(AbiParam::new)
                     .collect(),
@@ -182,7 +183,9 @@ fn lib_call(
     ) -> Option<Value> {
         let sig = Signature {
             params: input_tys.iter().cloned().map(AbiParam::new).collect(),
-            returns: output_ty.map(|output_ty| vec![AbiParam::new(output_ty)]).unwrap_or(Vec::new()),
+            returns: output_ty
+                .map(|output_ty| vec![AbiParam::new(output_ty)])
+                .unwrap_or(Vec::new()),
             call_conv: CallConv::SystemV,
         };
         let func_id = self
@@ -606,7 +609,7 @@ fn codegen_intrinsic_call<'a, 'tcx: 'a>(
                             let len = args[0].load_value_pair(fx).1;
                             let elem_size = fx.layout_of(elem).size.bytes();
                             fx.bcx.ins().imul_imm(len, elem_size as i64)
-                        },
+                        }
                         ty => unimplemented!("size_of_val for {:?}", ty),
                     };
                     ret.write_cvalue(fx, CValue::ByVal(size, usize_layout));
index dd0aaeaaedb7ac708a565c77e969273d4a215fe7..9e01785416786fc2c97ada2a32e96c9b404e0b12 100644 (file)
@@ -23,7 +23,9 @@ pub fn trans_mono_item<'a, 'tcx: 'a>(
                 match inst.def {
                     InstanceDef::Item(_)
                     | InstanceDef::DropGlue(_, _)
-                    | InstanceDef::Virtual(_, _) if inst.def_id().krate == LOCAL_CRATE => {
+                    | InstanceDef::Virtual(_, _)
+                        if inst.def_id().krate == LOCAL_CRATE =>
+                    {
                         let mut mir = ::std::io::Cursor::new(Vec::new());
                         ::rustc_mir::util::write_mir_pretty(tcx, Some(inst.def_id()), &mut mir)
                             .unwrap();
@@ -35,8 +37,8 @@ pub fn trans_mono_item<'a, 'tcx: 'a>(
                     | InstanceDef::FnPtrShim(_, _)
                     | InstanceDef::ClosureOnceShim { .. }
                     | InstanceDef::CloneShim(_, _) => {
-                       // FIXME fix write_mir_pretty for these instances
-                       format!("{:#?}", tcx.instance_mir(inst.def))
+                        // FIXME fix write_mir_pretty for these instances
+                        format!("{:#?}", tcx.instance_mir(inst.def))
                     }
                     InstanceDef::Intrinsic(_) => bug!("tried to codegen intrinsic"),
                 }
@@ -507,7 +509,9 @@ fn trans_stmt<'a, 'tcx: 'a>(
                     let def_id = match fx.tcx.lang_items().require(ExchangeMallocFnLangItem) {
                         Ok(id) => id,
                         Err(s) => {
-                            fx.tcx.sess.fatal(&format!("allocation of `{}` {}", box_layout.ty, s));
+                            fx.tcx
+                                .sess
+                                .fatal(&format!("allocation of `{}` {}", box_layout.ty, s));
                         }
                     };
                     let instance = ty::Instance::mono(fx.tcx, def_id);
@@ -515,7 +519,7 @@ fn trans_stmt<'a, 'tcx: 'a>(
                     let call = fx.bcx.ins().call(func_ref, &[llsize, llalign]);
                     let ptr = fx.bcx.inst_results(call)[0];
                     lval.write_cvalue(fx, CValue::ByVal(ptr, box_layout));
-                },
+                }
                 Rvalue::NullaryOp(NullOp::SizeOf, ty) => {
                     assert!(
                         lval.layout()
index 7081511b19bdfe1f43154f14bee720893702fc49..a7159c210ea83b0a50370cfd22cc3363e61c2ff9 100644 (file)
@@ -143,16 +143,17 @@ pub fn load_value<'a>(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> Valu
     {
         match self {
             CValue::ByRef(addr, layout) => {
-                let cton_ty = fx
-                    .cton_type(layout.ty)
-                    .unwrap_or_else(|| {
-                        if layout.ty.is_box() && !fx.layout_of(layout.ty.builtin_deref(true).unwrap().ty).is_unsized() {
-                            // Consider sized box to be a ptr
-                            pointer_ty(fx.tcx)
-                        } else {
-                            panic!("load_value of type {:?}", layout.ty);
-                        }
-                    });
+                let cton_ty = fx.cton_type(layout.ty).unwrap_or_else(|| {
+                    if layout.ty.is_box() && !fx
+                        .layout_of(layout.ty.builtin_deref(true).unwrap().ty)
+                        .is_unsized()
+                    {
+                        // Consider sized box to be a ptr
+                        pointer_ty(fx.tcx)
+                    } else {
+                        panic!("load_value of type {:?}", layout.ty);
+                    }
+                });
                 fx.bcx.ins().load(cton_ty, MemFlags::new(), addr, 0)
             }
             CValue::ByVal(value, _layout) => value,
index d4257b8f632ec8b420407263590b9b314d5697a3..c1aea7739b86bedba38072c28613c23bc526e659 100644 (file)
@@ -82,9 +82,7 @@ mod prelude {
     };
     pub use cranelift::codegen::Context;
     pub use cranelift::prelude::*;
-    pub use cranelift_module::{
-        Backend, DataContext, DataId, FuncId, Linkage, Module,
-    };
+    pub use cranelift_module::{Backend, DataContext, DataId, FuncId, Linkage, Module};
     pub use cranelift_simplejit::{SimpleJITBackend, SimpleJITBuilder};
 
     pub use crate::abi::*;