|
16 | 16 | #![feature(clone_to_uninit)]
|
17 | 17 | #![feature(const_align_of_val_raw)]
|
18 | 18 | #![feature(const_align_offset)]
|
| 19 | +#![feature(const_bigint_helper_methods)] |
19 | 20 | #![feature(const_black_box)]
|
| 21 | +#![feature(const_eval_select)] |
20 | 22 | #![feature(const_hash)]
|
21 | 23 | #![feature(const_heap)]
|
22 | 24 | #![feature(const_likely)]
|
23 | 25 | #![feature(const_nonnull_new)]
|
| 26 | +#![feature(const_num_midpoint)] |
24 | 27 | #![feature(const_option_ext)]
|
25 | 28 | #![feature(const_pin)]
|
26 | 29 | #![feature(const_pointer_is_aligned)]
|
|
45 | 48 | #![feature(get_many_mut)]
|
46 | 49 | #![feature(hasher_prefixfree_extras)]
|
47 | 50 | #![feature(hashmap_internals)]
|
| 51 | +#![feature(inline_const_pat)] |
48 | 52 | #![feature(int_roundings)]
|
49 | 53 | #![feature(ip)]
|
50 | 54 | #![feature(ip_from)]
|
|
104 | 108 | #![deny(fuzzy_provenance_casts)]
|
105 | 109 | #![deny(unsafe_op_in_unsafe_fn)]
|
106 | 110 |
|
| 111 | +/// Version of `assert_matches` that ignores fancy runtime printing in const context and uses structural equality. |
| 112 | +macro_rules! assert_eq_const_safe { |
| 113 | + ($left:expr, $right:expr$(, $($arg:tt)+)?) => { |
| 114 | + { |
| 115 | + fn runtime() { |
| 116 | + assert_eq!($left, $right, $($arg)*); |
| 117 | + } |
| 118 | + const fn compiletime() { |
| 119 | + assert!(matches!($left, const { $right })); |
| 120 | + } |
| 121 | + core::intrinsics::const_eval_select((), compiletime, runtime) |
| 122 | + } |
| 123 | + }; |
| 124 | +} |
| 125 | + |
| 126 | +/// Creates a test for runtime and a test for constant-time. |
| 127 | +macro_rules! test_runtime_and_compiletime { |
| 128 | + ($( |
| 129 | + $(#[$attr:meta])* |
| 130 | + fn $test:ident() $block:block |
| 131 | + )*) => { |
| 132 | + $( |
| 133 | + $(#[$attr])* |
| 134 | + #[test] |
| 135 | + fn $test() $block |
| 136 | + $(#[$attr])* |
| 137 | + const _: () = $block; |
| 138 | + )* |
| 139 | + } |
| 140 | +} |
| 141 | + |
107 | 142 | mod alloc;
|
108 | 143 | mod any;
|
109 | 144 | mod array;
|
|
0 commit comments