()
| 75 | #[inline(never)] |
| 76 | fn opaque_f128(value: f128) -> f128 { |
| 77 | value |
| 78 | } |
| 79 | |
| 80 | #[inline(never)] |
| 81 | fn runtime_needs_drop<T>() -> bool { |
| 82 | core::mem::needs_drop::<T>() |
| 83 | } |
| 84 | |
| 85 | #[derive(Clone, Copy)] |
| 86 | struct LookupPair(u8, u8); |
| 87 | |
| 88 | const fn build_lookup_table() -> [LookupPair; 256] { |
| 89 | let mut table = [LookupPair(0, 0); 256]; |
| 90 | let mut index = 0; |
| 91 | while index < table.len() { |
| 92 | table[index] = LookupPair(index as u8, (index as u8).wrapping_mul(3)); |
| 93 | index += 1; |
| 94 | } |
| 95 | table |
| 96 | } |
| 97 | |
| 98 | const LOOKUP_TABLE: [LookupPair; 256] = build_lookup_table(); |
| 99 | |
| 100 | #[inline(never)] |
| 101 | fn read_large_constant(index: usize) -> (u8, u8) { |
| 102 | (LOOKUP_TABLE[index].0, LOOKUP_TABLE[index].1) |
| 103 | } |
| 104 | |
| 105 | #[inline(never)] |
| 106 | fn mutate_large_constant_copy(index: usize) -> u8 { |
| 107 | let mut table = LOOKUP_TABLE; |
| 108 | assert!(table[index].0 == index as u8); |
| 109 | table[index].0 = 211; |
| 110 | table[index].0 |
| 111 | } |
| 112 | |
| 113 | fn large_constant_value_semantics() { |
| 114 | assert!(read_large_constant(37) == (37, 111)); |
| 115 | assert!(mutate_large_constant_copy(37) == 211); |
| 116 | assert!(mutate_large_constant_copy(37) == 211); |
| 117 | assert!( |
| 118 | read_large_constant(37) == (37, 111), |
| 119 | "a mutable constant copy must not modify a shared read-only table" |
| 120 | ); |
| 121 | } |
| 122 | |
| 123 | fn fixed_array_pattern_checks_every_element() { |
| 124 | let bytes = [0_u8, 0xae, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff, 1, 2, 3, 4]; |
| 125 | assert!(!matches!( |
| 126 | bytes, |
| 127 | [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff, _, _, _, _] |
| 128 | )); |
| 129 | assert!(matches!( |
| 130 | bytes, |
| 131 | [0, 0xae, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff, 1, 2, 3, 4] |
| 132 | )); |
| 133 | } |
| 134 |
nothing calls this directly
no outgoing calls
no test coverage detected