()
| 113 | } |
| 114 | |
| 115 | type ErasedFormatter = unsafe fn(core::ptr::NonNull<()>, &mut i32) -> i32; |
| 116 | |
| 117 | #[derive(Copy, Clone)] |
| 118 | struct FormatRecord { |
| 119 | value: i32, |
| 120 | } |
| 121 | |
| 122 | fn format_i32(value: &i32, state: &mut i32) -> i32 { |
| 123 | *state += *value; |
| 124 | *state |
| 125 | } |
| 126 | |
| 127 | fn format_i64(value: &i64, state: &mut i32) -> i32 { |
| 128 | *state += (*value / 10) as i32; |
| 129 | *state |
| 130 | } |
| 131 | |
| 132 | fn format_u128(value: &u128, state: &mut i32) -> i32 { |
| 133 | *state += (*value / 100) as i32; |
| 134 | *state |
| 135 | } |
| 136 | |
| 137 | fn format_record(value: &FormatRecord, state: &mut i32) -> i32 { |
| 138 | *state += value.value; |
| 139 | *state |
| 140 | } |
| 141 | |
| 142 | fn format_str(value: &&str, state: &mut i32) -> i32 { |
| 143 | *state += value.len() as i32; |
| 144 | *state |
| 145 | } |
| 146 | |
| 147 | fn call_erased<T>(value: &T, formatter: fn(&T, &mut i32) -> i32, initial: i32) -> i32 { |
| 148 | let erased: ErasedFormatter = unsafe { core::mem::transmute(formatter) }; |
| 149 | let pointer: core::ptr::NonNull<()> = unsafe { core::mem::transmute(value) }; |
| 150 | let mut state = initial; |
| 151 | unsafe { erased(pointer, &mut state) } |
| 152 | } |
| 153 | |
| 154 | fn dummy() {} |
| 155 | |
| 156 | #[inline(never)] |
| 157 | fn function_pointer_slot_is_null(pointer: *const fn()) -> bool { |
| 158 | pointer.is_null() |
| 159 | } |
| 160 | |
| 161 | struct Ops { |
| 162 | unary: fn(i32) -> i32, |
| 163 | binary: fn(i32, i32) -> i32, |
| 164 | } |
| 165 | |
| 166 | fn named_add_one(x: i32) -> i32 { |
| 167 | x + 1 |
| 168 | } |
| 169 | |
| 170 | // Const-eval path: closures inside a const initializer. |
| 171 | const CLOSURE_OPS: Ops = Ops { |
| 172 | unary: |x| x * 3, |
nothing calls this directly
no test coverage detected