From 16e936b93f5318aa34d309a8a3c4904a32b30c95 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 26 Sep 2018 15:40:11 +0200 Subject: [PATCH] Rustfmt --- src/abi.rs | 23 +++++++++++++++-------- src/base.rs | 18 +++++++++++------- src/common.rs | 10 ++++++++-- src/constant.rs | 9 ++++++--- src/vtable.rs | 5 +++-- 5 files changed, 43 insertions(+), 22 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index 82f8257b632..23888070259 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -49,7 +49,11 @@ fn get_pass_mode<'a, 'tcx: 'a>( PassMode::ByVal(ret_ty) } else { if abi == Abi::C { - unimpl!("Non scalars are not yet supported for \"C\" abi ({:?}) is_return: {:?}", ty, is_return); + unimpl!( + "Non scalars are not yet supported for \"C\" abi ({:?}) is_return: {:?}", + ty, + is_return + ); } PassMode::ByRef } @@ -667,9 +671,10 @@ fn codegen_intrinsic_call<'a, 'tcx: 'a>( assert_eq!(args.len(), 1); let layout = fx.layout_of(substs.type_at(0)); let size = match &layout.ty.sty { - _ if !layout.is_unsized() => { - fx.bcx.ins().iconst(fx.module.pointer_type(), layout.size.bytes() as i64) - } + _ if !layout.is_unsized() => fx + .bcx + .ins() + .iconst(fx.module.pointer_type(), layout.size.bytes() as i64), ty::Slice(elem) => { let len = args[0].load_value_pair(fx).1; let elem_size = fx.layout_of(elem).size.bytes(); @@ -690,9 +695,10 @@ fn codegen_intrinsic_call<'a, 'tcx: 'a>( assert_eq!(args.len(), 1); let layout = fx.layout_of(substs.type_at(0)); let align = match &layout.ty.sty { - _ if !layout.is_unsized() => { - fx.bcx.ins().iconst(fx.module.pointer_type(), layout.align.abi() as i64) - } + _ if !layout.is_unsized() => fx + .bcx + .ins() + .iconst(fx.module.pointer_type(), layout.align.abi() as i64), ty::Slice(elem) => { let align = fx.layout_of(elem).align.abi() as i64; fx.bcx.ins().iconst(fx.module.pointer_type(), align) @@ -860,7 +866,8 @@ fn codegen_intrinsic_call<'a, 'tcx: 'a>( _ if intrinsic.starts_with("atomic_fence") => {} _ if intrinsic.starts_with("atomic_load") => { assert_eq!(args.len(), 1); - let inner_layout = fx.layout_of(args[0].layout().ty.builtin_deref(true).unwrap().ty); + let inner_layout = + fx.layout_of(args[0].layout().ty.builtin_deref(true).unwrap().ty); let val = CValue::ByRef(args[0].load_value(fx), inner_layout); ret.write_cvalue(fx, val); } diff --git a/src/base.rs b/src/base.rs index 590f6d63264..f3088da4119 100644 --- a/src/base.rs +++ b/src/base.rs @@ -27,8 +27,11 @@ pub fn trans_mono_item<'a, 'tcx: 'a>( if inst.def_id().krate == LOCAL_CRATE => { let mut mir = ::std::io::Cursor::new(Vec::new()); - crate::rustc_mir::util::write_mir_pretty(tcx, Some(inst.def_id()), &mut mir) - .unwrap(); + crate::rustc_mir::util::write_mir_pretty( + tcx, + Some(inst.def_id()), + &mut mir, + ).unwrap(); String::from_utf8(mir.into_inner()).unwrap() } InstanceDef::Item(_) @@ -436,12 +439,10 @@ fn trans_stmt<'a, 'tcx: 'a>( let res = fx.bcx.ins().icmp_imm(IntCC::Equal, val, 0); fx.bcx.ins().bint(types::I8, res) } - ty::Uint(_) | ty::Int(_) => { - fx.bcx.ins().bnot(val) - } + ty::Uint(_) | ty::Int(_) => fx.bcx.ins().bnot(val), _ => unimplemented!("un op Not for {:?}", layout.ty), } - }, + } UnOp::Neg => match layout.ty.sty { ty::Int(_) => { let clif_ty = fx.cton_type(layout.ty).unwrap(); @@ -1001,7 +1002,10 @@ fn trans_ptr_binop<'a, 'tcx: 'a>( let res = match bin_op { BinOp::Eq => fx.bcx.ins().icmp(IntCC::Equal, lhs, rhs), BinOp::Ne => fx.bcx.ins().icmp(IntCC::NotEqual, lhs, rhs), - _ => unimplemented!("trans_ptr_binop({:?}, , ) not implemented", bin_op), + _ => unimplemented!( + "trans_ptr_binop({:?}, , ) not implemented", + bin_op + ), }; assert_eq!(fx.tcx.types.bool, ret_ty); diff --git a/src/common.rs b/src/common.rs index 9384f8c9b59..51706c888e4 100644 --- a/src/common.rs +++ b/src/common.rs @@ -372,7 +372,9 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { pub fn write_cvalue(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>, from: CValue<'tcx>) { match (&self.layout().ty.sty, &from.layout().ty.sty) { (ty::Ref(_, t, dest_mut), ty::Ref(_, u, src_mut)) - if (if *dest_mut != crate::rustc::hir::Mutability::MutImmutable && src_mut != dest_mut { + if (if *dest_mut != crate::rustc::hir::Mutability::MutImmutable + && src_mut != dest_mut + { false } else if t != u { false @@ -449,7 +451,11 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { ) -> CPlace<'tcx> { match self { CPlace::Var(var, layout) => { - bug!("Tried to project {:?}, which is put in SSA var {:?}", layout.ty, var); + bug!( + "Tried to project {:?}, which is put in SSA var {:?}", + layout.ty, + var + ); } CPlace::Addr(base, extra, layout) => { let (field_ptr, field_layout) = codegen_field(fx, base, layout, field); diff --git a/src/constant.rs b/src/constant.rs index 94c2e85411a..30dab10495f 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -154,7 +154,8 @@ fn data_id_for_static<'a, 'tcx: 'a, B: Backend>( def_id: DefId, ) -> DataId { let symbol_name = tcx.symbol_name(Instance::mono(tcx, def_id)).as_str(); - let is_mutable = if let crate::rustc::hir::Mutability::MutMutable = tcx.is_static(def_id).unwrap() { + let is_mutable = + if let crate::rustc::hir::Mutability::MutMutable = tcx.is_static(def_id).unwrap() { true } else { !tcx.type_of(def_id) @@ -235,11 +236,13 @@ fn define_all_allocs<'a, 'tcx: 'a, B: Backend + 'a>( let data_id = match tcx.alloc_map.lock().get(reloc).unwrap() { AllocType::Function(instance) => { let (func_name, sig) = crate::abi::get_function_name_and_sig(tcx, instance); - let func_id = module.declare_function(&func_name, Linkage::Import, &sig).unwrap(); + let func_id = module + .declare_function(&func_name, Linkage::Import, &sig) + .unwrap(); let local_func_id = module.declare_func_in_data(func_id, &mut data_ctx); data_ctx.write_function_addr(reloc_offset as u32, local_func_id); continue; - }, + } AllocType::Memory(_) => { cx.todo.insert(TodoItem::Alloc(reloc)); data_id_for_alloc_id(module, reloc) diff --git a/src/vtable.rs b/src/vtable.rs index 6b4ae6a0aee..e8e3899e388 100644 --- a/src/vtable.rs +++ b/src/vtable.rs @@ -81,8 +81,9 @@ fn build_vtable<'a, 'tcx: 'a>( .layout_of(ParamEnv::reveal_all().and(ty)) .unwrap() .size_and_align(); - let drop_in_place_fn = - fx.get_function_id(crate::rustc_mir::monomorphize::resolve_drop_in_place(tcx, ty)); + let drop_in_place_fn = fx.get_function_id( + crate::rustc_mir::monomorphize::resolve_drop_in_place(tcx, ty), + ); let mut components: Vec<_> = vec![Some(drop_in_place_fn), None, None];