|
17 | 17 | #![feature(const_align_of_val_raw)]
|
18 | 18 | #![feature(const_align_offset)]
|
19 | 19 | #![feature(const_array_from_ref)]
|
| 20 | +#![feature(const_bigint_helper_methods)] |
20 | 21 | #![feature(const_black_box)]
|
| 22 | +#![feature(const_eval_select)] |
21 | 23 | #![feature(const_hash)]
|
22 | 24 | #![feature(const_heap)]
|
23 | 25 | #![feature(const_ip)]
|
24 | 26 | #![feature(const_ipv4)]
|
25 | 27 | #![feature(const_ipv6)]
|
26 | 28 | #![feature(const_likely)]
|
27 | 29 | #![feature(const_nonnull_new)]
|
| 30 | +#![feature(const_num_midpoint)] |
28 | 31 | #![feature(const_option)]
|
29 | 32 | #![feature(const_option_ext)]
|
30 | 33 | #![feature(const_pin)]
|
|
55 | 58 | #![feature(get_many_mut)]
|
56 | 59 | #![feature(hasher_prefixfree_extras)]
|
57 | 60 | #![feature(hashmap_internals)]
|
| 61 | +#![feature(inline_const_pat)] |
58 | 62 | #![feature(int_roundings)]
|
59 | 63 | #![feature(ip)]
|
60 | 64 | #![feature(is_ascii_octdigit)]
|
|
113 | 117 | #![deny(fuzzy_provenance_casts)]
|
114 | 118 | #![deny(unsafe_op_in_unsafe_fn)]
|
115 | 119 |
|
| 120 | +/// Version of `assert_matches` that ignores fancy runtime printing in const context and uses structural equality. |
| 121 | +macro_rules! assert_eq_const_safe { |
| 122 | + ($left:expr, $right:expr$(, $($arg:tt)+)?) => { |
| 123 | + { |
| 124 | + fn runtime() { |
| 125 | + assert_eq!($left, $right, $($arg)*); |
| 126 | + } |
| 127 | + const fn compiletime() { |
| 128 | + assert!(matches!($left, const { $right })); |
| 129 | + } |
| 130 | + core::intrinsics::const_eval_select((), compiletime, runtime) |
| 131 | + } |
| 132 | + }; |
| 133 | +} |
| 134 | + |
| 135 | +/// Creates a test for runtime and a test for constant-time. |
| 136 | +macro_rules! test_runtime_and_compiletime { |
| 137 | + ($( |
| 138 | + $(#[$attr:meta])* |
| 139 | + fn $test:ident() $block:block |
| 140 | + )*) => { |
| 141 | + $( |
| 142 | + $(#[$attr])* |
| 143 | + #[test] |
| 144 | + fn $test() $block |
| 145 | + $(#[$attr])* |
| 146 | + const _: () = $block; |
| 147 | + )* |
| 148 | + } |
| 149 | +} |
| 150 | + |
116 | 151 | mod alloc;
|
117 | 152 | mod any;
|
118 | 153 | mod array;
|
|
0 commit comments