diff --git a/src/abi.rs b/src/abi.rs index 0b2b1807099..7c5ff6a809c 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -224,7 +224,10 @@ impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { 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.module.pointer_type(), 0), return_layout) + CValue::ByRef( + self.bcx.ins().iconst(self.module.pointer_type(), 0), + return_layout, + ) } } @@ -570,7 +573,10 @@ fn codegen_intrinsic_call<'a, 'tcx: 'a>( "copy" | "copy_nonoverlapping" => { let elem_ty = substs.type_at(0); let elem_size: u64 = fx.layout_of(elem_ty).size.bytes(); - let elem_size = fx.bcx.ins().iconst(fx.module.pointer_type(), elem_size as i64); + let elem_size = fx + .bcx + .ins() + .iconst(fx.module.pointer_type(), elem_size as i64); assert_eq!(args.len(), 3); let src = args[0]; let dst = args[1]; diff --git a/src/common.rs b/src/common.rs index ffb984c7c11..c015765195d 100644 --- a/src/common.rs +++ b/src/common.rs @@ -39,7 +39,7 @@ pub fn cton_type_from_ty<'a, 'tcx: 'a>( IntTy::I32 => types::I32, IntTy::I64 => types::I64, IntTy::I128 => unimpl!("i128"), - IntTy::Isize => pointer_ty(tcx) + IntTy::Isize => pointer_ty(tcx), }, TypeVariants::TyChar => types::I32, TypeVariants::TyFloat(size) => match size { @@ -68,7 +68,10 @@ fn codegen_field<'a, 'tcx: 'a>( let field_offset = layout.fields.offset(field.index()); let field_ty = layout.field(&*fx, field.index()); if field_offset.bytes() > 0 { - (fx.bcx.ins().iadd_imm(base, field_offset.bytes() as i64), field_ty) + ( + fx.bcx.ins().iadd_imm(base, field_offset.bytes() as i64), + field_ty, + ) } else { (base, field_ty) } @@ -101,7 +104,9 @@ impl<'tcx> CValue<'tcx> { offset: None, }); fx.bcx.ins().stack_store(value, stack_slot, 0); - fx.bcx.ins().stack_addr(fx.module.pointer_type(), stack_slot, 0) + fx.bcx + .ins() + .stack_addr(fx.module.pointer_type(), stack_slot, 0) } } } @@ -187,7 +192,12 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { size: layout.size.bytes() as u32, offset: None, }); - CPlace::Addr(fx.bcx.ins().stack_addr(fx.module.pointer_type(), stack_slot, 0), layout) + CPlace::Addr( + fx.bcx + .ins() + .stack_addr(fx.module.pointer_type(), stack_slot, 0), + layout, + ) } pub fn from_stack_slot( @@ -196,7 +206,12 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { ty: Ty<'tcx>, ) -> CPlace<'tcx> { let layout = fx.layout_of(ty); - CPlace::Addr(fx.bcx.ins().stack_addr(fx.module.pointer_type(), stack_slot, 0), layout) + CPlace::Addr( + fx.bcx + .ins() + .stack_addr(fx.module.pointer_type(), stack_slot, 0), + layout, + ) } pub fn to_cvalue(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> CValue<'tcx> { @@ -254,10 +269,12 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { let from = from.expect_byref(); let mut offset = 0; while size - offset >= 8 { - let byte = fx - .bcx - .ins() - .load(fx.module.pointer_type(), MemFlags::new(), from.0, offset); + let byte = fx.bcx.ins().load( + fx.module.pointer_type(), + MemFlags::new(), + from.0, + offset, + ); fx.bcx.ins().store(MemFlags::new(), byte, addr, offset); offset += 8; } @@ -304,7 +321,10 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { match layout.ty.sty { TypeVariants::TyArray(elem_ty, _) => { let elem_layout = fx.layout_of(elem_ty); - let offset = fx.bcx.ins().imul_imm(index, elem_layout.size.bytes() as i64); + let offset = fx + .bcx + .ins() + .imul_imm(index, elem_layout.size.bytes() as i64); CPlace::Addr(fx.bcx.ins().iadd(addr, offset), elem_layout) } TypeVariants::TySlice(_elem_ty) => unimplemented!("place_index(TySlice)"), diff --git a/src/constant.rs b/src/constant.rs index 5d7971bc235..10a59560ff5 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -134,12 +134,17 @@ fn data_id_for_alloc_id(module: &mut Module, alloc_id: AllocId) - .unwrap() } -fn data_id_for_static<'a, 'tcx: 'a, B: Backend>(tcx: TyCtxt<'a, 'tcx, 'tcx>, module: &mut Module, def_id: DefId) -> DataId { +fn data_id_for_static<'a, 'tcx: 'a, B: Backend>( + tcx: TyCtxt<'a, 'tcx, 'tcx>, + module: &mut Module, + def_id: DefId, +) -> DataId { let symbol_name = tcx.symbol_name(Instance::mono(tcx, def_id)).as_str(); let is_mutable = if let ::rustc::hir::Mutability::MutMutable = tcx.is_static(def_id).unwrap() { true } else { - !tcx.type_of(def_id).is_freeze(tcx, ParamEnv::reveal_all(), DUMMY_SP) + !tcx.type_of(def_id) + .is_freeze(tcx, ParamEnv::reveal_all(), DUMMY_SP) }; module .declare_data(&*symbol_name, Linkage::Export, is_mutable) @@ -152,7 +157,10 @@ 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.module.pointer_type(), local_data_id); + let global_ptr = fx + .bcx + .ins() + .global_value(fx.module.pointer_type(), local_data_id); let layout = fx.layout_of(fx.monomorphize(&ty)); CPlace::Addr(global_ptr, layout) } diff --git a/src/lib.rs b/src/lib.rs index d40c820a4f7..7ea6abe03a4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -215,9 +215,10 @@ impl CodegenBackend for CraneliftCodegenBackend { 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); let mono_items = collector::collect_crate_mono_items(tcx, collector::MonoItemCollectionMode::Eager).0;