2024-07-29 11:50:12 -05:00
|
|
|
// tidy-alphabetical-start
|
2024-11-02 02:25:30 -05:00
|
|
|
#![cfg_attr(bootstrap, feature(const_three_way_compare))]
|
2024-09-14 06:44:02 -05:00
|
|
|
#![cfg_attr(bootstrap, feature(strict_provenance))]
|
|
|
|
#![cfg_attr(not(bootstrap), feature(strict_provenance_lints))]
|
2024-07-29 11:50:12 -05:00
|
|
|
#![cfg_attr(target_has_atomic = "128", feature(integer_atomics))]
|
|
|
|
#![cfg_attr(test, feature(cfg_match))]
|
2020-03-06 19:40:54 -06:00
|
|
|
#![feature(alloc_layout_extra)]
|
2020-05-18 14:24:37 -05:00
|
|
|
#![feature(array_chunks)]
|
2023-12-29 09:32:09 -06:00
|
|
|
#![feature(array_ptr_get)]
|
2024-07-29 11:50:12 -05:00
|
|
|
#![feature(array_try_from_fn)]
|
2020-08-13 14:09:14 -05:00
|
|
|
#![feature(array_windows)]
|
2023-07-03 12:11:39 -05:00
|
|
|
#![feature(ascii_char)]
|
|
|
|
#![feature(ascii_char_variants)]
|
2023-12-08 14:33:14 -06:00
|
|
|
#![feature(async_iter_from_iter)]
|
|
|
|
#![feature(async_iterator)]
|
2022-02-09 23:24:12 -06:00
|
|
|
#![feature(bigint_helper_methods)]
|
2018-04-06 15:45:31 -05:00
|
|
|
#![feature(cell_update)]
|
2023-09-24 10:55:19 -05:00
|
|
|
#![feature(clone_to_uninit)]
|
2022-10-29 08:38:00 -05:00
|
|
|
#![feature(const_align_of_val_raw)]
|
2021-12-23 05:07:41 -06:00
|
|
|
#![feature(const_black_box)]
|
2024-10-14 15:05:01 -05:00
|
|
|
#![feature(const_eval_select)]
|
2022-01-25 22:06:09 -06:00
|
|
|
#![feature(const_heap)]
|
2022-01-28 03:41:35 -06:00
|
|
|
#![feature(const_nonnull_new)]
|
2024-07-29 11:50:12 -05:00
|
|
|
#![feature(const_option_ext)]
|
2024-09-09 02:43:03 -05:00
|
|
|
#![feature(const_pin_2)]
|
2021-03-13 11:40:47 -06:00
|
|
|
#![feature(const_trait_impl)]
|
2020-09-24 09:41:40 -05:00
|
|
|
#![feature(core_intrinsics)]
|
2023-11-07 18:12:01 -06:00
|
|
|
#![feature(core_io_borrowed_buf)]
|
2015-09-20 11:34:33 -05:00
|
|
|
#![feature(core_private_bignum)]
|
|
|
|
#![feature(core_private_diy_float)]
|
2015-08-29 11:30:05 -05:00
|
|
|
#![feature(dec2flt)]
|
2020-08-30 12:31:34 -05:00
|
|
|
#![feature(duration_constants)]
|
2024-01-24 07:14:17 -06:00
|
|
|
#![feature(duration_constructors)]
|
2024-07-29 11:50:12 -05:00
|
|
|
#![feature(error_generic_member_access)]
|
2017-07-06 10:13:29 -05:00
|
|
|
#![feature(exact_size_is_empty)]
|
2020-10-19 08:38:11 -05:00
|
|
|
#![feature(extern_types)]
|
2024-07-29 11:50:12 -05:00
|
|
|
#![feature(float_minimum_maximum)]
|
2015-06-10 15:33:52 -05:00
|
|
|
#![feature(flt2dec)]
|
2017-03-17 09:05:44 -05:00
|
|
|
#![feature(fmt_internals)]
|
2024-07-29 11:50:12 -05:00
|
|
|
#![feature(freeze)]
|
2021-12-07 20:10:39 -06:00
|
|
|
#![feature(future_join)]
|
2022-05-22 05:18:32 -05:00
|
|
|
#![feature(generic_assert_internals)]
|
2024-07-29 11:50:12 -05:00
|
|
|
#![feature(get_many_mut)]
|
2022-03-04 02:17:26 -06:00
|
|
|
#![feature(hasher_prefixfree_extras)]
|
2018-03-17 05:07:50 -05:00
|
|
|
#![feature(hashmap_internals)]
|
2024-10-14 15:05:01 -05:00
|
|
|
#![feature(inline_const_pat)]
|
2024-07-29 11:50:12 -05:00
|
|
|
#![feature(int_roundings)]
|
2022-11-10 14:48:41 -06:00
|
|
|
#![feature(ip)]
|
2024-10-07 09:11:39 -05:00
|
|
|
#![feature(ip_from)]
|
2024-07-29 11:50:12 -05:00
|
|
|
#![feature(is_ascii_octdigit)]
|
2020-09-19 03:26:46 -05:00
|
|
|
#![feature(iter_advance_by)]
|
2022-01-02 10:31:56 -06:00
|
|
|
#![feature(iter_array_chunks)]
|
2024-06-04 03:51:05 -05:00
|
|
|
#![feature(iter_chain)]
|
2022-02-19 18:46:55 -06:00
|
|
|
#![feature(iter_collect_into)]
|
2021-10-07 12:39:36 -05:00
|
|
|
#![feature(iter_intersperse)]
|
2019-07-09 14:39:19 -05:00
|
|
|
#![feature(iter_is_partitioned)]
|
2024-07-29 11:50:12 -05:00
|
|
|
#![feature(iter_map_windows)]
|
2022-06-21 01:57:02 -05:00
|
|
|
#![feature(iter_next_chunk)]
|
2019-06-28 07:43:32 -05:00
|
|
|
#![feature(iter_order_by)]
|
2024-07-29 11:50:12 -05:00
|
|
|
#![feature(iter_partition_in_place)]
|
2022-02-15 20:58:42 -06:00
|
|
|
#![feature(iterator_try_collect)]
|
2021-07-11 00:43:30 -05:00
|
|
|
#![feature(iterator_try_reduce)]
|
2024-07-29 11:50:12 -05:00
|
|
|
#![feature(layout_for_ptr)]
|
2024-09-17 11:31:57 -05:00
|
|
|
#![feature(lazy_get)]
|
2024-07-29 11:50:12 -05:00
|
|
|
#![feature(maybe_uninit_fill)]
|
|
|
|
#![feature(maybe_uninit_uninit_array_transpose)]
|
|
|
|
#![feature(maybe_uninit_write_slice)]
|
|
|
|
#![feature(min_specialization)]
|
2019-11-02 15:12:51 -05:00
|
|
|
#![feature(never_type)]
|
2024-07-29 11:50:12 -05:00
|
|
|
#![feature(noop_waker)]
|
|
|
|
#![feature(num_midpoint)]
|
|
|
|
#![feature(numfmt)]
|
|
|
|
#![feature(pattern)]
|
2024-03-03 13:44:15 -06:00
|
|
|
#![feature(pointer_is_aligned_to)]
|
2021-11-30 09:50:44 -06:00
|
|
|
#![feature(portable_simd)]
|
2021-03-26 15:10:21 -05:00
|
|
|
#![feature(ptr_metadata)]
|
2024-07-29 11:50:12 -05:00
|
|
|
#![feature(slice_from_ptr_range)]
|
|
|
|
#![feature(slice_internals)]
|
|
|
|
#![feature(slice_partition_dedup)]
|
|
|
|
#![feature(slice_split_once)]
|
|
|
|
#![feature(slice_take)]
|
2021-03-17 11:23:09 -05:00
|
|
|
#![feature(split_array)]
|
2024-07-29 11:50:12 -05:00
|
|
|
#![feature(split_as_slice)]
|
|
|
|
#![feature(std_internals)]
|
|
|
|
#![feature(step_trait)]
|
|
|
|
#![feature(str_internals)]
|
2022-05-10 19:04:26 -05:00
|
|
|
#![feature(strict_provenance_atomic_ptr)]
|
2024-07-29 11:50:12 -05:00
|
|
|
#![feature(test)]
|
|
|
|
#![feature(trait_upcasting)]
|
|
|
|
#![feature(trusted_len)]
|
2021-01-03 18:08:13 -06:00
|
|
|
#![feature(trusted_random_access)]
|
2024-07-29 11:50:12 -05:00
|
|
|
#![feature(try_blocks)]
|
|
|
|
#![feature(try_find)]
|
|
|
|
#![feature(try_trait_v2)]
|
|
|
|
#![feature(unsigned_is_multiple_of)]
|
2021-03-26 15:10:21 -05:00
|
|
|
#![feature(unsize)]
|
2024-07-29 11:50:12 -05:00
|
|
|
#![feature(unsized_tuple_coercion)]
|
|
|
|
#![feature(unwrap_infallible)]
|
|
|
|
// tidy-alphabetical-end
|
2023-11-22 00:30:09 -06:00
|
|
|
#![allow(internal_features)]
|
2022-11-20 04:28:08 -06:00
|
|
|
#![deny(fuzzy_provenance_casts)]
|
2024-07-29 11:50:12 -05:00
|
|
|
#![deny(unsafe_op_in_unsafe_fn)]
|
2014-06-28 15:57:36 -05:00
|
|
|
|
2024-10-14 15:05:01 -05:00
|
|
|
/// Version of `assert_matches` that ignores fancy runtime printing in const context and uses structural equality.
|
|
|
|
macro_rules! assert_eq_const_safe {
|
|
|
|
($left:expr, $right:expr$(, $($arg:tt)+)?) => {
|
|
|
|
{
|
|
|
|
fn runtime() {
|
|
|
|
assert_eq!($left, $right, $($arg)*);
|
|
|
|
}
|
|
|
|
const fn compiletime() {
|
|
|
|
assert!(matches!($left, const { $right }));
|
|
|
|
}
|
|
|
|
core::intrinsics::const_eval_select((), compiletime, runtime)
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Creates a test for runtime and a test for constant-time.
|
|
|
|
macro_rules! test_runtime_and_compiletime {
|
|
|
|
($(
|
|
|
|
$(#[$attr:meta])*
|
|
|
|
fn $test:ident() $block:block
|
|
|
|
)*) => {
|
|
|
|
$(
|
|
|
|
$(#[$attr])*
|
|
|
|
#[test]
|
|
|
|
fn $test() $block
|
|
|
|
$(#[$attr])*
|
|
|
|
const _: () = $block;
|
|
|
|
)*
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-30 01:23:14 -05:00
|
|
|
mod alloc;
|
2014-06-28 15:57:36 -05:00
|
|
|
mod any;
|
2015-08-29 11:30:05 -05:00
|
|
|
mod array;
|
2018-03-08 21:55:54 -06:00
|
|
|
mod ascii;
|
2024-01-24 09:48:54 -06:00
|
|
|
mod ascii_char;
|
2022-05-22 05:18:32 -05:00
|
|
|
mod asserting;
|
2023-12-08 14:33:14 -06:00
|
|
|
mod async_iter;
|
2014-08-04 17:42:36 -05:00
|
|
|
mod atomic;
|
2019-09-07 09:49:27 -05:00
|
|
|
mod bool;
|
2014-06-28 15:57:36 -05:00
|
|
|
mod cell;
|
|
|
|
mod char;
|
2015-10-15 14:07:20 -05:00
|
|
|
mod clone;
|
2014-06-28 15:57:36 -05:00
|
|
|
mod cmp;
|
2020-12-25 18:59:08 -06:00
|
|
|
mod const_ptr;
|
2021-12-05 04:46:29 -06:00
|
|
|
mod convert;
|
2024-07-24 07:28:31 -05:00
|
|
|
mod ffi;
|
2014-06-28 15:57:36 -05:00
|
|
|
mod fmt;
|
2021-12-07 20:10:39 -06:00
|
|
|
mod future;
|
2014-12-12 20:43:07 -06:00
|
|
|
mod hash;
|
2015-10-15 14:07:20 -05:00
|
|
|
mod intrinsics;
|
2023-11-07 18:12:01 -06:00
|
|
|
mod io;
|
2014-06-28 15:57:36 -05:00
|
|
|
mod iter;
|
2020-01-13 21:34:23 -06:00
|
|
|
mod lazy;
|
2020-11-22 02:08:04 -06:00
|
|
|
mod macros;
|
2018-07-27 05:12:55 -05:00
|
|
|
mod manually_drop;
|
2014-06-28 15:57:36 -05:00
|
|
|
mod mem;
|
2022-11-10 14:48:41 -06:00
|
|
|
mod net;
|
2014-12-23 14:52:02 -06:00
|
|
|
mod nonzero;
|
2014-06-28 15:57:36 -05:00
|
|
|
mod num;
|
|
|
|
mod ops;
|
|
|
|
mod option;
|
2022-09-27 14:09:32 -05:00
|
|
|
mod panic;
|
2017-12-17 16:44:03 -06:00
|
|
|
mod pattern;
|
2020-09-12 18:55:34 -05:00
|
|
|
mod pin;
|
2022-01-23 18:41:37 -06:00
|
|
|
mod pin_macro;
|
2014-06-28 15:57:36 -05:00
|
|
|
mod ptr;
|
|
|
|
mod result;
|
2021-10-22 02:47:12 -05:00
|
|
|
mod simd;
|
2014-08-06 22:48:25 -05:00
|
|
|
mod slice;
|
2014-08-18 20:43:43 -05:00
|
|
|
mod str;
|
2018-04-05 08:55:28 -05:00
|
|
|
mod str_lossy;
|
2020-09-03 18:04:34 -05:00
|
|
|
mod task;
|
2018-05-01 06:43:05 -05:00
|
|
|
mod time;
|
2014-06-28 15:57:36 -05:00
|
|
|
mod tuple;
|
2020-11-22 02:08:04 -06:00
|
|
|
mod unicode;
|
2021-12-12 03:55:41 -06:00
|
|
|
mod waker;
|
2022-11-20 18:55:41 -06:00
|
|
|
|
|
|
|
/// Copied from `std::test_helpers::test_rng`, see that function for rationale.
|
|
|
|
#[track_caller]
|
|
|
|
#[allow(dead_code)] // Not used in all configurations.
|
|
|
|
pub(crate) fn test_rng() -> rand_xorshift::XorShiftRng {
|
|
|
|
use core::hash::{BuildHasher, Hash, Hasher};
|
2023-10-13 01:44:19 -05:00
|
|
|
let mut hasher = std::hash::RandomState::new().build_hasher();
|
2022-11-20 18:55:41 -06:00
|
|
|
core::panic::Location::caller().hash(&mut hasher);
|
|
|
|
let hc64 = hasher.finish();
|
|
|
|
let seed_vec = hc64.to_le_bytes().into_iter().chain(0u8..8).collect::<Vec<u8>>();
|
|
|
|
let seed: [u8; 16] = seed_vec.as_slice().try_into().unwrap();
|
|
|
|
rand::SeedableRng::from_seed(seed)
|
|
|
|
}
|