diff options
| author | bjorn3 <bjorn3@users.noreply.github.com> | 2018-12-22 17:42:38 +0100 |
|---|---|---|
| committer | bjorn3 <bjorn3@users.noreply.github.com> | 2018-12-22 18:21:30 +0100 |
| commit | 0b4ede39e50aab5f8f262ddd5a821ae699cbd179 (patch) | |
| tree | d46f8bc6b14b22bffbf30decd587a43a0afdac59 /example/example.rs | |
| parent | 988257649752a4b41a819ca415df363893f300be (diff) | |
| download | rust-0b4ede39e50aab5f8f262ddd5a821ae699cbd179.tar.gz rust-0b4ede39e50aab5f8f262ddd5a821ae699cbd179.zip | |
Add pretty param and local info comments to clif
Diffstat (limited to 'example/example.rs')
| -rw-r--r-- | example/example.rs | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/example/example.rs b/example/example.rs index eebc8c126e9..220554550f1 100644 --- a/example/example.rs +++ b/example/example.rs @@ -18,7 +18,6 @@ fn bcd(b: bool, a: u8) -> u8 { } } -// FIXME make calls work fn call() { abc(42); } @@ -33,14 +32,12 @@ enum BoolOption { None, } -/* fn option_unwrap_or(o: BoolOption, d: bool) -> bool { match o { BoolOption::Some(b) => b, BoolOption::None => d, } } -*/ fn ret_42() -> u8 { 42 @@ -62,18 +59,18 @@ fn cmp_raw_ptr(a: *const u8, b: *const u8) -> bool { a == b } -/*fn int_cast(a: u16, b: i16) -> (u8, u16, u32, usize, i8, i16, i32, isize, u8, u32) { +fn int_cast(a: u16, b: i16) -> (u8, u16, u32, usize, i8, i16, i32, isize, u8, u32) { ( a as u8, a as u16, a as u32, a as usize, a as i8, a as i16, a as i32, a as isize, b as u8, b as u32, ) -}*/ +} fn char_cast(c: char) -> u8 { c as u8 } -struct DebugTuple(()); +pub struct DebugTuple(()); fn debug_tuple() -> DebugTuple { DebugTuple(()) @@ -87,14 +84,14 @@ fn use_size_of() -> usize { size_of::<u64>() } -/*unsafe fn use_copy_intrinsic(src: *const u8, dst: *mut u8) { +unsafe fn use_copy_intrinsic(src: *const u8, dst: *mut u8) { intrinsics::copy::<u8>(src, dst, 1); -}*/ +} -/*unsafe fn use_copy_intrinsic_ref(src: *const u8, dst: *mut u8) { - let copy2 = ©::<u8>; +unsafe fn use_copy_intrinsic_ref(src: *const u8, dst: *mut u8) { + let copy2 = &intrinsics::copy::<u8>; copy2(src, dst, 1); -}*/ +} const Abc: u8 = 6 * 7; @@ -102,32 +99,36 @@ fn use_const() -> u8 { Abc } -fn call_closure_3arg() { +pub fn call_closure_3arg() { (|_, _, _| {})(0u8, 42u16, 0u8) } -fn call_closure_2arg() { +pub fn call_closure_2arg() { (|_, _| {})(0u8, 42u16) } struct IsNotEmpty; impl<'a, 'b> FnOnce<(&'a &'b [u16],)> for IsNotEmpty { - type Output = bool; + type Output = (u8, u8); #[inline] - extern "rust-call" fn call_once(mut self, arg: (&'a &'b [u16],)) -> bool { + extern "rust-call" fn call_once(mut self, arg: (&'a &'b [u16],)) -> (u8, u8) { self.call_mut(arg) } } impl<'a, 'b> FnMut<(&'a &'b [u16],)> for IsNotEmpty { #[inline] - extern "rust-call" fn call_mut(&mut self, arg: (&'a &'b [u16],)) -> bool { - true + extern "rust-call" fn call_mut(&mut self, arg: (&'a &'b [u16],)) -> (u8, u8) { + (0, 42) } } +pub fn call_is_not_empty() { + IsNotEmpty.call_once((&(&[0u16] as &[_]),)); +} + fn eq_char(a: char, b: char) -> bool { a == b } @@ -140,7 +141,6 @@ unsafe fn call_uninit() -> u8 { intrinsics::uninit() } -// TODO: enable when fat pointers are supported unsafe fn deref_str_ptr(s: *const str) -> &'static str { &*s } @@ -157,9 +157,9 @@ fn array_as_slice(arr: &[u8; 3]) -> &[u8] { arr } -/*unsafe fn use_ctlz_nonzero(a: u16) -> u16 { +unsafe fn use_ctlz_nonzero(a: u16) -> u16 { intrinsics::ctlz_nonzero(a) -}*/ +} fn ptr_as_usize(ptr: *const u8) -> usize { ptr as usize @@ -169,9 +169,9 @@ fn float_cast(a: f32, b: f64) -> (f64, f32) { (a as f64, b as f32) } -/*fn int_to_float(a: u8, b: i32) -> (f64, f32) { +fn int_to_float(a: u8, b: i32) -> (f64, f32) { (a as f64, b as f32) -}*/ +} fn make_array() -> [u8; 3] { [42, 0, 5] |
