Explicitly export core and std macros

Currently all core and std macros are automatically added to the prelude
via #[macro_use]. However a situation arose where we want to add a new macro
`assert_matches` but don't want to pull it into the standard prelude for
compatibility reasons. By explicitly exporting the macros found in the core and
std crates we get to decide on a per macro basis and can later add them via
the rust_20xx preludes.
This commit is contained in:
Lukas Bergdoll 2025-12-28 11:22:41 +01:00
parent 2f1bd3f378
commit 506762f3ff
103 changed files with 770 additions and 123 deletions

View file

@ -65,6 +65,7 @@
#![feature(negative_impls)]
#![feature(never_type)]
#![feature(optimize_attribute)]
#![feature(prelude_import)]
#![feature(rustc_allow_const_fn_unstable)]
#![feature(rustc_attrs)]
#![feature(staged_api)]
@ -74,11 +75,17 @@
// Allow testing this library
extern crate alloc as realalloc;
#[macro_use]
// This is needed to provide macros to the directly imported alloc modules below.
extern crate std;
#[prelude_import]
#[allow(unused_imports)]
use std::prelude::rust_2024::*;
#[cfg(test)]
extern crate test;
mod testing;
use realalloc::*;
// We are directly including collections, raw_vec, and wtf8 here as they use non-public
@ -102,8 +109,7 @@ pub(crate) mod test_helpers {
let mut hasher = std::hash::RandomState::new().build_hasher();
std::panic::Location::caller().hash(&mut hasher);
let hc64 = hasher.finish();
let seed_vec =
hc64.to_le_bytes().into_iter().chain(0u8..8).collect::<crate::vec::Vec<u8>>();
let seed_vec = hc64.to_le_bytes().into_iter().chain(0u8..8).collect::<std::vec::Vec<u8>>();
let seed: [u8; 16] = seed_vec.as_slice().try_into().unwrap();
rand::SeedableRng::from_seed(seed)
}