Skip to content

Commit 62a0203

Browse files
committed
Rustfmt
1 parent 252607a commit 62a0203

File tree

5 files changed

+28
-22
lines changed

5 files changed

+28
-22
lines changed

examples/mini_core.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ static mut MY_TINY_HEAP: [u8; 16] = [0; 16];
194194

195195
#[lang = "exchange_malloc"]
196196
unsafe fn allocate(size: usize, _align: usize) -> *mut u8 {
197-
&mut MY_TINY_HEAP as *mut [u8; 16] as *mut u8
197+
&mut MY_TINY_HEAP as *mut [u8; 16] as *mut u8
198198
}
199199

200200
pub mod intrinsics {

src/abi.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ pub fn cton_sig_from_fn_ty<'a, 'tcx: 'a>(
9090
),
9191
PassMode::ByRef => {
9292
(
93-
Some(pointer_ty(tcx)).into_iter() // First param is place to put return val
93+
Some(pointer_ty(tcx)) // First param is place to put return val
94+
.into_iter()
9495
.chain(inputs)
9596
.map(AbiParam::new)
9697
.collect(),
@@ -182,7 +183,9 @@ impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> {
182183
) -> Option<Value> {
183184
let sig = Signature {
184185
params: input_tys.iter().cloned().map(AbiParam::new).collect(),
185-
returns: output_ty.map(|output_ty| vec![AbiParam::new(output_ty)]).unwrap_or(Vec::new()),
186+
returns: output_ty
187+
.map(|output_ty| vec![AbiParam::new(output_ty)])
188+
.unwrap_or(Vec::new()),
186189
call_conv: CallConv::SystemV,
187190
};
188191
let func_id = self
@@ -606,7 +609,7 @@ fn codegen_intrinsic_call<'a, 'tcx: 'a>(
606609
let len = args[0].load_value_pair(fx).1;
607610
let elem_size = fx.layout_of(elem).size.bytes();
608611
fx.bcx.ins().imul_imm(len, elem_size as i64)
609-
},
612+
}
610613
ty => unimplemented!("size_of_val for {:?}", ty),
611614
};
612615
ret.write_cvalue(fx, CValue::ByVal(size, usize_layout));

src/base.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ pub fn trans_mono_item<'a, 'tcx: 'a>(
2323
match inst.def {
2424
InstanceDef::Item(_)
2525
| InstanceDef::DropGlue(_, _)
26-
| InstanceDef::Virtual(_, _) if inst.def_id().krate == LOCAL_CRATE => {
26+
| InstanceDef::Virtual(_, _)
27+
if inst.def_id().krate == LOCAL_CRATE =>
28+
{
2729
let mut mir = ::std::io::Cursor::new(Vec::new());
2830
::rustc_mir::util::write_mir_pretty(tcx, Some(inst.def_id()), &mut mir)
2931
.unwrap();
@@ -35,8 +37,8 @@ pub fn trans_mono_item<'a, 'tcx: 'a>(
3537
| InstanceDef::FnPtrShim(_, _)
3638
| InstanceDef::ClosureOnceShim { .. }
3739
| InstanceDef::CloneShim(_, _) => {
38-
// FIXME fix write_mir_pretty for these instances
39-
format!("{:#?}", tcx.instance_mir(inst.def))
40+
// FIXME fix write_mir_pretty for these instances
41+
format!("{:#?}", tcx.instance_mir(inst.def))
4042
}
4143
InstanceDef::Intrinsic(_) => bug!("tried to codegen intrinsic"),
4244
}
@@ -507,15 +509,17 @@ fn trans_stmt<'a, 'tcx: 'a>(
507509
let def_id = match fx.tcx.lang_items().require(ExchangeMallocFnLangItem) {
508510
Ok(id) => id,
509511
Err(s) => {
510-
fx.tcx.sess.fatal(&format!("allocation of `{}` {}", box_layout.ty, s));
512+
fx.tcx
513+
.sess
514+
.fatal(&format!("allocation of `{}` {}", box_layout.ty, s));
511515
}
512516
};
513517
let instance = ty::Instance::mono(fx.tcx, def_id);
514518
let func_ref = fx.get_function_ref(instance);
515519
let call = fx.bcx.ins().call(func_ref, &[llsize, llalign]);
516520
let ptr = fx.bcx.inst_results(call)[0];
517521
lval.write_cvalue(fx, CValue::ByVal(ptr, box_layout));
518-
},
522+
}
519523
Rvalue::NullaryOp(NullOp::SizeOf, ty) => {
520524
assert!(
521525
lval.layout()

src/common.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -143,16 +143,17 @@ impl<'tcx> CValue<'tcx> {
143143
{
144144
match self {
145145
CValue::ByRef(addr, layout) => {
146-
let cton_ty = fx
147-
.cton_type(layout.ty)
148-
.unwrap_or_else(|| {
149-
if layout.ty.is_box() && !fx.layout_of(layout.ty.builtin_deref(true).unwrap().ty).is_unsized() {
150-
// Consider sized box to be a ptr
151-
pointer_ty(fx.tcx)
152-
} else {
153-
panic!("load_value of type {:?}", layout.ty);
154-
}
155-
});
146+
let cton_ty = fx.cton_type(layout.ty).unwrap_or_else(|| {
147+
if layout.ty.is_box() && !fx
148+
.layout_of(layout.ty.builtin_deref(true).unwrap().ty)
149+
.is_unsized()
150+
{
151+
// Consider sized box to be a ptr
152+
pointer_ty(fx.tcx)
153+
} else {
154+
panic!("load_value of type {:?}", layout.ty);
155+
}
156+
});
156157
fx.bcx.ins().load(cton_ty, MemFlags::new(), addr, 0)
157158
}
158159
CValue::ByVal(value, _layout) => value,

src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,7 @@ mod prelude {
8282
};
8383
pub use cranelift::codegen::Context;
8484
pub use cranelift::prelude::*;
85-
pub use cranelift_module::{
86-
Backend, DataContext, DataId, FuncId, Linkage, Module,
87-
};
85+
pub use cranelift_module::{Backend, DataContext, DataId, FuncId, Linkage, Module};
8886
pub use cranelift_simplejit::{SimpleJITBackend, SimpleJITBuilder};
8987

9088
pub use crate::abi::*;

0 commit comments

Comments
 (0)