From c352f91b40a3533d49cc1c1ef58f9e656409cce5 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 9 Oct 2020 19:17:52 +0200 Subject: [PATCH] Rustfmt --- src/bin/cg_clif.rs | 4 +--- src/debuginfo/emit.rs | 50 +++++++++++++++++------------------------ src/debuginfo/unwind.rs | 3 ++- src/driver/jit.rs | 2 +- src/trap.rs | 15 +++---------- 5 files changed, 28 insertions(+), 46 deletions(-) diff --git a/src/bin/cg_clif.rs b/src/bin/cg_clif.rs index 8a39e9b0590..8ff1bf271ef 100644 --- a/src/bin/cg_clif.rs +++ b/src/bin/cg_clif.rs @@ -81,9 +81,7 @@ fn main() { None, Some(Box::new(move |_| { Box::new(rustc_codegen_cranelift::CraneliftCodegenBackend { - config: rustc_codegen_cranelift::BackendConfig { - use_jit, - } + config: rustc_codegen_cranelift::BackendConfig { use_jit }, }) })), ) diff --git a/src/debuginfo/emit.rs b/src/debuginfo/emit.rs index 3ad52c2e873..cf8fee2b1d1 100644 --- a/src/debuginfo/emit.rs +++ b/src/debuginfo/emit.rs @@ -84,9 +84,8 @@ impl WriterRelocate { match reloc.name { super::DebugRelocName::Section(_) => unreachable!(), super::DebugRelocName::Symbol(sym) => { - let addr = jit_product.lookup_func( - cranelift_module::FuncId::from_u32(sym.try_into().unwrap()), - ); + let addr = jit_product + .lookup_func(cranelift_module::FuncId::from_u32(sym.try_into().unwrap())); let val = (addr as u64 as i64 + reloc.addend) as u64; self.writer .write_udata_at(reloc.offset as usize, val, reloc.size) @@ -163,12 +162,7 @@ impl Writer for WriterRelocate { self.write_udata_at(offset, 0, size) } - fn write_eh_pointer( - &mut self, - address: Address, - eh_pe: gimli::DwEhPe, - size: u8, - ) -> Result<()> { + fn write_eh_pointer(&mut self, address: Address, eh_pe: gimli::DwEhPe, size: u8) -> Result<()> { match address { // Address::Constant arm copied from gimli Address::Constant(val) => { @@ -186,27 +180,25 @@ impl Writer for WriterRelocate { }; self.write_eh_pointer_data(val, eh_pe.format(), size) } - Address::Symbol { symbol, addend } => { - match eh_pe.application() { - gimli::DW_EH_PE_pcrel => { - let size = match eh_pe.format() { - gimli::DW_EH_PE_sdata4 => 4, - _ => return Err(gimli::write::Error::UnsupportedPointerEncoding(eh_pe)), - }; - self.relocs.push(DebugReloc { - offset: self.len() as u32, - size, - name: DebugRelocName::Symbol(symbol), - addend, - kind: object::RelocationKind::Relative, - }); - self.write_udata(0, size) - } - _ => { - return Err(gimli::write::Error::UnsupportedPointerEncoding(eh_pe)); - } + Address::Symbol { symbol, addend } => match eh_pe.application() { + gimli::DW_EH_PE_pcrel => { + let size = match eh_pe.format() { + gimli::DW_EH_PE_sdata4 => 4, + _ => return Err(gimli::write::Error::UnsupportedPointerEncoding(eh_pe)), + }; + self.relocs.push(DebugReloc { + offset: self.len() as u32, + size, + name: DebugRelocName::Symbol(symbol), + addend, + kind: object::RelocationKind::Relative, + }); + self.write_udata(0, size) } - } + _ => { + return Err(gimli::write::Error::UnsupportedPointerEncoding(eh_pe)); + } + }, } } } diff --git a/src/debuginfo/unwind.rs b/src/debuginfo/unwind.rs index f08dfb60769..61ebd931d2f 100644 --- a/src/debuginfo/unwind.rs +++ b/src/debuginfo/unwind.rs @@ -20,7 +20,8 @@ impl<'tcx> UnwindContext<'tcx> { let cie_id = if let Some(mut cie) = isa.create_systemv_cie() { if isa.flags().is_pic() { - cie.fde_address_encoding = gimli::DwEhPe(gimli::DW_EH_PE_pcrel.0 | gimli::DW_EH_PE_sdata4.0); + cie.fde_address_encoding = + gimli::DwEhPe(gimli::DW_EH_PE_pcrel.0 | gimli::DW_EH_PE_sdata4.0); } Some(frame_table.add_cie(cie)) } else { diff --git a/src/driver/jit.rs b/src/driver/jit.rs index 611a70eae2b..6f398d045b6 100644 --- a/src/driver/jit.rs +++ b/src/driver/jit.rs @@ -9,7 +9,7 @@ use rustc_codegen_ssa::CrateInfo; use crate::prelude::*; pub(super) fn run_jit(tcx: TyCtxt<'_>) -> ! { - use cranelift_simplejit::{SimpleJITModule, SimpleJITBuilder}; + use cranelift_simplejit::{SimpleJITBuilder, SimpleJITModule}; #[cfg(unix)] unsafe { diff --git a/src/trap.rs b/src/trap.rs index 007b6465605..67495c74148 100644 --- a/src/trap.rs +++ b/src/trap.rs @@ -29,10 +29,7 @@ fn codegen_print(fx: &mut FunctionCx<'_, '_, impl Module>, msg: &str) { } /// Trap code: user1 -pub(crate) fn trap_abort( - fx: &mut FunctionCx<'_, '_, impl Module>, - msg: impl AsRef, -) { +pub(crate) fn trap_abort(fx: &mut FunctionCx<'_, '_, impl Module>, msg: impl AsRef) { codegen_print(fx, msg.as_ref()); fx.bcx.ins().trap(TrapCode::User(1)); } @@ -41,10 +38,7 @@ pub(crate) fn trap_abort( /// so you can **not** add instructions to it afterwards. /// /// Trap code: user65535 -pub(crate) fn trap_unreachable( - fx: &mut FunctionCx<'_, '_, impl Module>, - msg: impl AsRef, -) { +pub(crate) fn trap_unreachable(fx: &mut FunctionCx<'_, '_, impl Module>, msg: impl AsRef) { codegen_print(fx, msg.as_ref()); fx.bcx.ins().trap(TrapCode::UnreachableCodeReached); } @@ -68,10 +62,7 @@ pub(crate) fn trap_unreachable_ret_value<'tcx>( /// to it afterwards. /// /// Trap code: user65535 -pub(crate) fn trap_unimplemented( - fx: &mut FunctionCx<'_, '_, impl Module>, - msg: impl AsRef, -) { +pub(crate) fn trap_unimplemented(fx: &mut FunctionCx<'_, '_, impl Module>, msg: impl AsRef) { codegen_print(fx, msg.as_ref()); let true_ = fx.bcx.ins().iconst(types::I32, 1); fx.bcx.ins().trapnz(true_, TrapCode::User(!0));