]> git.lizzy.rs Git - rust.git/commitdiff
Rustfmt
authorbjorn3 <bjorn3@users.noreply.github.com>
Wed, 7 Nov 2018 12:32:02 +0000 (13:32 +0100)
committerbjorn3 <bjorn3@users.noreply.github.com>
Wed, 7 Nov 2018 12:32:02 +0000 (13:32 +0100)
src/abi.rs
src/allocator.rs
src/base.rs
src/common.rs
src/constant.rs
src/lib.rs
src/main_shim.rs
src/metadata.rs
src/vtable.rs

index 217064e51b880912dfd3919aeecf3f6a41cf7cb3..f42707b5f80d1164b116b5a5098c95f6832ae281 100644 (file)
@@ -28,11 +28,10 @@ fn get_pass_mode<'a, 'tcx: 'a>(
     ty: Ty<'tcx>,
     is_return: bool,
 ) -> PassMode {
-    assert!(
-        !tcx.layout_of(ParamEnv::reveal_all().and(ty))
-            .unwrap()
-            .is_unsized()
-    );
+    assert!(!tcx
+        .layout_of(ParamEnv::reveal_all().and(ty))
+        .unwrap()
+        .is_unsized());
     if let ty::Never = ty.sty {
         if is_return {
             PassMode::NoPass
@@ -256,10 +255,7 @@ pub fn easy_call(
         if let Some(val) = self.lib_call(name, input_tys, return_ty, &args) {
             CValue::ByVal(val, return_layout)
         } else {
-            CValue::ByRef(
-                self.bcx.ins().iconst(self.pointer_type, 0),
-                return_layout,
-            )
+            CValue::ByRef(self.bcx.ins().iconst(self.pointer_type, 0), return_layout)
         }
     }
 
index d1bff9ac524bfdcf356a3c812818e4afe4b52ed1..d84838634e79820b0c97273f53d7e94090a60434 100644 (file)
@@ -11,7 +11,7 @@
 use crate::prelude::*;
 
 use rustc::middle::allocator::AllocatorKind;
-use rustc_allocator::{ALLOCATOR_METHODS, AllocatorTy};
+use rustc_allocator::{AllocatorTy, ALLOCATOR_METHODS};
 
 pub fn codegen(module: &mut Module<impl Backend + 'static>, kind: AllocatorKind) {
     let usize_ty = module.target_config().pointer_type();
@@ -27,17 +27,16 @@ pub fn codegen(module: &mut Module<impl Backend + 'static>, kind: AllocatorKind)
                 AllocatorTy::Ptr => arg_tys.push(usize_ty),
                 AllocatorTy::Usize => arg_tys.push(usize_ty),
 
-                AllocatorTy::ResultPtr |
-                AllocatorTy::Unit => panic!("invalid allocator arg"),
+                AllocatorTy::ResultPtr | AllocatorTy::Unit => panic!("invalid allocator arg"),
             }
         }
         let output = match method.output {
             AllocatorTy::ResultPtr => Some(usize_ty),
             AllocatorTy::Unit => None,
 
-            AllocatorTy::Layout |
-            AllocatorTy::Usize |
-            AllocatorTy::Ptr => panic!("invalid allocator output"),
+            AllocatorTy::Layout | AllocatorTy::Usize | AllocatorTy::Ptr => {
+                panic!("invalid allocator output")
+            }
         };
 
         let sig = Signature {
index 6c55e12fde78c3b90db49bfc0279e51c614d3ecf..0b7e657f17f38239f7a9d7ee33534bb2901ae36d 100644 (file)
@@ -630,11 +630,10 @@ fn trans_stmt<'a, 'tcx: 'a>(
                     lval.write_cvalue(fx, CValue::ByVal(ptr, box_layout));
                 }
                 Rvalue::NullaryOp(NullOp::SizeOf, ty) => {
-                    assert!(
-                        lval.layout()
-                            .ty
-                            .is_sized(fx.tcx.at(DUMMY_SP), ParamEnv::reveal_all())
-                    );
+                    assert!(lval
+                        .layout()
+                        .ty
+                        .is_sized(fx.tcx.at(DUMMY_SP), ParamEnv::reveal_all()));
                     let ty_size = fx.layout_of(ty).size.bytes();
                     let val = CValue::const_val(fx, fx.tcx.types.usize, ty_size as i64);
                     lval.write_cvalue(fx, val);
index c4a33695fe25ca40215c74c6f1e082181a6d770f..848f66a48d2bb2d78e115b2eed24460532f59b99 100644 (file)
@@ -131,10 +131,7 @@ pub fn force_stack<'a>(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> Val
                     size: layout.size.bytes() as u32,
                     offset: None,
                 });
-                let addr = fx
-                    .bcx
-                    .ins()
-                    .stack_addr(fx.pointer_type, stack_slot, 0);
+                let addr = fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0);
                 fx.bcx.ins().store(MemFlags::new(), value, addr, 0);
                 addr
             }
@@ -161,9 +158,10 @@ 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()
+                    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)
@@ -190,14 +188,14 @@ pub fn load_value_pair<'a>(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) ->
                 );
                 let val1_offset = layout.fields.offset(0).bytes() as i32;
                 let val2_offset = layout.fields.offset(1).bytes() as i32;
-                let val1 =
-                    fx.bcx
-                        .ins()
-                        .load(fx.pointer_type, MemFlags::new(), addr, val1_offset);
-                let val2 =
-                    fx.bcx
-                        .ins()
-                        .load(fx.pointer_type, MemFlags::new(), addr, val2_offset);
+                let val1 = fx
+                    .bcx
+                    .ins()
+                    .load(fx.pointer_type, MemFlags::new(), addr, val1_offset);
+                let val2 = fx
+                    .bcx
+                    .ins()
+                    .load(fx.pointer_type, MemFlags::new(), addr, val2_offset);
                 (val1, val2)
             }
             CValue::ByVal(_, _layout) => bug!("Please use load_value for ByVal"),
@@ -333,9 +331,7 @@ pub fn temp(fx: &mut FunctionCx<'a, 'tcx, impl Backend>, ty: Ty<'tcx>) -> CPlace
             offset: None,
         });
         CPlace::Addr(
-            fx.bcx
-                .ins()
-                .stack_addr(fx.pointer_type, stack_slot, 0),
+            fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0),
             None,
             layout,
         )
@@ -349,9 +345,7 @@ pub fn from_stack_slot(
         let layout = fx.layout_of(ty);
         assert!(!layout.is_unsized());
         CPlace::Addr(
-            fx.bcx
-                .ins()
-                .stack_addr(fx.pointer_type, stack_slot, 0),
+            fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0),
             None,
             layout,
         )
@@ -426,12 +420,10 @@ pub fn write_cvalue(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>, from: CVa
 
                         let mut offset = 0;
                         while size - offset >= 8 {
-                            let byte = fx.bcx.ins().load(
-                                fx.pointer_type,
-                                MemFlags::new(),
-                                from,
-                                offset,
-                            );
+                            let byte =
+                                fx.bcx
+                                    .ins()
+                                    .load(fx.pointer_type, MemFlags::new(), from, offset);
                             fx.bcx.ins().store(MemFlags::new(), byte, addr, offset);
                             offset += 8;
                         }
index f66abe052a595df23ecc17e5a2ef4c799e92edb6..4dcbf1da82c8bea5827ef3af74639078a926c58c 100644 (file)
@@ -4,7 +4,9 @@
     read_target_uint, AllocId, AllocType, Allocation, ConstValue, EvalResult, GlobalId, Scalar,
 };
 use rustc::ty::Const;
-use rustc_mir::interpret::{EvalContext, Machine, Memory, MemoryKind, MemPlace, OpTy, PlaceTy, Pointer};
+use rustc_mir::interpret::{
+    EvalContext, Machine, MemPlace, Memory, MemoryKind, OpTy, PlaceTy, Pointer,
+};
 
 use cranelift_module::*;
 
@@ -176,10 +178,7 @@ fn cplace_for_dataid<'a, 'tcx: 'a>(
     data_id: DataId,
 ) -> CPlace<'tcx> {
     let local_data_id = fx.module.declare_data_in_func(data_id, &mut fx.bcx.func);
-    let global_ptr = fx
-        .bcx
-        .ins()
-        .global_value(fx.pointer_type, local_data_id);
+    let global_ptr = fx.bcx.ins().global_value(fx.pointer_type, local_data_id);
     let layout = fx.layout_of(fx.monomorphize(&ty));
     assert!(!layout.is_unsized(), "unsized statics aren't supported");
     CPlace::Addr(global_ptr, None, layout)
@@ -336,11 +335,23 @@ fn box_alloc(_: &mut EvalContext<'a, 'mir, 'tcx, Self>, _: PlaceTy<'tcx>) -> Eva
         panic!();
     }
 
-    fn tag_reference(_: &mut EvalContext<'a, 'mir, 'tcx, Self>, _: MemPlace, _: Ty<'tcx>, _: Size, _: Option<crate::rustc::hir::Mutability>) -> EvalResult<'tcx, MemPlace> {
+    fn tag_reference(
+        _: &mut EvalContext<'a, 'mir, 'tcx, Self>,
+        _: MemPlace,
+        _: Ty<'tcx>,
+        _: Size,
+        _: Option<crate::rustc::hir::Mutability>,
+    ) -> EvalResult<'tcx, MemPlace> {
         panic!()
     }
 
-    fn tag_dereference(_: &EvalContext<'a, 'mir, 'tcx, Self>, _: MemPlace, _: Ty<'tcx>, _: Size, _: Option<crate::rustc::hir::Mutability>) -> EvalResult<'tcx, MemPlace> {
+    fn tag_dereference(
+        _: &EvalContext<'a, 'mir, 'tcx, Self>,
+        _: MemPlace,
+        _: Ty<'tcx>,
+        _: Size,
+        _: Option<crate::rustc::hir::Mutability>,
+    ) -> EvalResult<'tcx, MemPlace> {
         panic!();
     }
 
@@ -348,7 +359,11 @@ fn adjust_static_allocation(alloc: &Allocation) -> Cow<'_, Allocation> {
         Cow::Borrowed(alloc)
     }
 
-    fn tag_new_allocation(_: &mut EvalContext<'a, 'mir, 'tcx, Self>, ptr: Pointer, _: MemoryKind<!>) -> EvalResult<'tcx, Pointer> {
+    fn tag_new_allocation(
+        _: &mut EvalContext<'a, 'mir, 'tcx, Self>,
+        ptr: Pointer,
+        _: MemoryKind<!>,
+    ) -> EvalResult<'tcx, Pointer> {
         Ok(ptr)
     }
 }
index 7cce688712338490d250364ce4999d519c793b54..8dccc6e26a846ac5b33ff8b63e1a251cf2d48117 100644 (file)
@@ -1,4 +1,9 @@
-#![feature(rustc_private, macro_at_most_once_rep, never_type, extern_crate_item_prelude)]
+#![feature(
+    rustc_private,
+    macro_at_most_once_rep,
+    never_type,
+    extern_crate_item_prelude
+)]
 #![allow(intra_doc_link_resolution_failure)]
 
 extern crate byteorder;
@@ -80,10 +85,10 @@ mod prelude {
     pub use syntax::ast::{FloatTy, IntTy, UintTy};
     pub use syntax::source_map::DUMMY_SP;
 
-    pub use cranelift::codegen::isa::CallConv;
     pub use cranelift::codegen::ir::{
         condcodes::IntCC, function::Function, ExternalName, FuncRef, Inst, StackSlot,
     };
+    pub use cranelift::codegen::isa::CallConv;
     pub use cranelift::codegen::Context;
     pub use cranelift::prelude::*;
     pub use cranelift_module::{Backend, DataContext, DataId, FuncId, Linkage, Module};
@@ -174,9 +179,10 @@ fn codegen_crate<'a, 'tcx>(
         let mut flags_builder = settings::builder();
         flags_builder.enable("is_pic").unwrap();
         let flags = settings::Flags::new(flags_builder);
-        let isa = cranelift::codegen::isa::lookup(tcx.sess.target.target.llvm_target.parse().unwrap())
-            .unwrap()
-            .finish(flags);
+        let isa =
+            cranelift::codegen::isa::lookup(tcx.sess.target.target.llvm_target.parse().unwrap())
+                .unwrap()
+                .finish(flags);
 
         // TODO: move to the end of this function when compiling libcore doesn't have unimplemented stuff anymore
         save_incremental(tcx);
@@ -197,7 +203,9 @@ fn codegen_crate<'a, 'tcx>(
                     AbiParam::new(jit_module.target_config().pointer_type()),
                     AbiParam::new(jit_module.target_config().pointer_type()),
                 ],
-                returns: vec![AbiParam::new(jit_module.target_config().pointer_type() /*isize*/)],
+                returns: vec![AbiParam::new(
+                    jit_module.target_config().pointer_type(), /*isize*/
+                )],
                 call_conv: CallConv::SystemV,
             };
             let main_func_id = jit_module
@@ -225,7 +233,10 @@ fn codegen_crate<'a, 'tcx>(
                 )
                 .unwrap(),
             );
-            assert_eq!(pointer_ty(tcx), faerie_module.target_config().pointer_type());
+            assert_eq!(
+                pointer_ty(tcx),
+                faerie_module.target_config().pointer_type()
+            );
 
             codegen_mono_items(tcx, &mut faerie_module);
 
@@ -347,9 +358,11 @@ fn codegen_mono_items<'a, 'tcx: 'a>(
     };
 
     let (_, cgus) = tcx.collect_and_partition_mono_items(LOCAL_CRATE);
-    let mono_items = cgus.iter().map(|cgu| {
-        cgu.items().iter()
-    }).flatten().collect::<FxHashSet<(_, _)>>();
+    let mono_items = cgus
+        .iter()
+        .map(|cgu| cgu.items().iter())
+        .flatten()
+        .collect::<FxHashSet<(_, _)>>();
 
     let before = ::std::time::Instant::now();
     println!("[codegen mono items] start");
@@ -374,7 +387,10 @@ fn codegen_mono_items<'a, 'tcx: 'a>(
 
     crate::main_shim::maybe_create_entry_wrapper(tcx, module);
 
-    let any_dynamic_crate = tcx.sess.dependency_formats.borrow()
+    let any_dynamic_crate = tcx
+        .sess
+        .dependency_formats
+        .borrow()
         .iter()
         .any(|(_, list)| {
             use rustc::middle::dependency_format::Linkage;
index ef9409f4bb25d319b6f412e0e7214000973ef36c..5b61ef24cf2e571c64cd04621032d500f7a98ba5 100644 (file)
@@ -41,7 +41,9 @@ fn create_entry_fn<'a, 'tcx: 'a>(
                 AbiParam::new(m.target_config().pointer_type()),
                 AbiParam::new(m.target_config().pointer_type()),
             ],
-            returns: vec![AbiParam::new(m.target_config().pointer_type() /*isize*/)],
+            returns: vec![AbiParam::new(
+                m.target_config().pointer_type(), /*isize*/
+            )],
             call_conv: CallConv::SystemV,
         };
 
@@ -85,7 +87,9 @@ fn create_entry_fn<'a, 'tcx: 'a>(
                     .declare_function(&start_name, Linkage::Import, &start_sig)
                     .unwrap();
 
-                let main_val = bcx.ins().func_addr(m.target_config().pointer_type(), main_func_ref);
+                let main_val = bcx
+                    .ins()
+                    .func_addr(m.target_config().pointer_type(), main_func_ref);
 
                 let func_ref = m.declare_func_in_func(start_func_id, &mut bcx.func);
                 bcx.ins().call(func_ref, &[main_val, arg_argc, arg_argv])
index bbcbd083fa7e16d94f00c0eb2ae0840406488bc5..bef1d7fccda2c7f9e0b2a23f23890371ec2ff8cc 100644 (file)
@@ -17,10 +17,7 @@ fn get_rlib_metadata(
         // Iterate over all entries in the archive:
         while let Some(entry_result) = archive.next_entry() {
             let mut entry = entry_result.map_err(|e| format!("{:?}", e))?;
-            if entry
-                .header()
-                .identifier() == METADATA_FILE
-            {
+            if entry.header().identifier() == METADATA_FILE {
                 let mut buf = Vec::new();
                 ::std::io::copy(&mut entry, &mut buf).map_err(|e| format!("{:?}", e))?;
                 let buf: OwningRef<Vec<u8>, [u8]> = OwningRef::new(buf).into();
index 185ce4abfe0c5dc906d1e9e2893c0fc8de52c051..d0ea60666d180c83b8a3c2085ab0fbe8bef49380 100644 (file)
@@ -64,9 +64,7 @@ pub fn get_vtable<'a, 'tcx: 'a>(
     };
 
     let local_data_id = fx.module.declare_data_in_func(data_id, &mut fx.bcx.func);
-    fx.bcx
-        .ins()
-        .global_value(fx.pointer_type, local_data_id)
+    fx.bcx.ins().global_value(fx.pointer_type, local_data_id)
 }
 
 fn build_vtable<'a, 'tcx: 'a>(