Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/test-utils/src/minicore.rs')
-rw-r--r--crates/test-utils/src/minicore.rs73
1 files changed, 67 insertions, 6 deletions
diff --git a/crates/test-utils/src/minicore.rs b/crates/test-utils/src/minicore.rs
index 960934cb69..22cef04983 100644
--- a/crates/test-utils/src/minicore.rs
+++ b/crates/test-utils/src/minicore.rs
@@ -23,7 +23,7 @@
//! drop:
//! eq: sized
//! error: fmt
-//! fmt: result
+//! fmt: result, transmute, coerce_unsized
//! fn:
//! from: sized
//! future: pin
@@ -37,7 +37,7 @@
//! non_zero:
//! option: panic
//! ord: eq, option
-//! panic:
+//! panic: fmt
//! pin:
//! range:
//! result:
@@ -45,6 +45,7 @@
//! sized:
//! slice:
//! sync: sized
+//! transmute:
//! try: infallible
//! unsize: sized
@@ -289,8 +290,8 @@ pub mod convert {
// endregion:infallible
}
-// region:drop
pub mod mem {
+ // region:drop
// region:manually_drop
#[lang = "manually_drop"]
#[repr(transparent)]
@@ -323,15 +324,23 @@ pub mod mem {
result
}
}
+ // endregion:drop
+
+ // region:transmute
+ extern "rust-intrinsic" {
+ pub fn transmute<Src, Dst>(src: Src) -> Dst;
+ }
+ // endregion:transmute
}
pub mod ptr {
+ // region:drop
#[lang = "drop_in_place"]
pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
unsafe { drop_in_place(to_drop) }
}
+ // endregion:drop
}
-// endregion:drop
pub mod ops {
// region:coerce_unsized
@@ -812,6 +821,38 @@ pub mod fmt {
fn fmt(&self, f: &mut Formatter<'_>) -> Result;
}
+ extern "C" {
+ type Opaque;
+ }
+
+ #[lang = "format_argument"]
+ pub struct ArgumentV1<'a> {
+ value: &'a Opaque,
+ formatter: fn(&Opaque, &mut Formatter<'_>) -> Result,
+ }
+
+ impl<'a> ArgumentV1<'a> {
+ pub fn new<'b, T>(x: &'b T, f: fn(&T, &mut Formatter<'_>) -> Result) -> ArgumentV1<'b> {
+ use crate::mem::transmute;
+ unsafe { ArgumentV1 { formatter: transmute(f), value: transmute(x) } }
+ }
+ }
+
+ #[lang = "format_arguments"]
+ pub struct Arguments<'a> {
+ pieces: &'a [&'static str],
+ args: &'a [ArgumentV1<'a>],
+ }
+
+ impl<'a> Arguments<'a> {
+ pub const fn new_v1(
+ pieces: &'a [&'static str],
+ args: &'a [ArgumentV1<'a>],
+ ) -> Arguments<'a> {
+ Arguments { pieces, args }
+ }
+ }
+
// region:derive
#[rustc_builtin_macro]
pub macro Debug($item:item) {}
@@ -1147,8 +1188,17 @@ pub mod iter {
// region:panic
mod panic {
- pub macro panic_2021($($t:tt)+) {
- /* Nothing yet */
+ pub macro panic_2021 {
+ ($($t:tt)+) => (
+ $crate::panicking::panic_fmt($crate::const_format_args!($($t)+))
+ ),
+ }
+}
+
+mod panicking {
+ #[lang = "panic_fmt"]
+ pub const fn panic_fmt(fmt: crate::fmt::Arguments<'_>) -> ! {
+ loop {}
}
}
// endregion:panic
@@ -1166,6 +1216,17 @@ mod macros {
pub(crate) use panic;
// endregion:panic
+ // region:fmt
+ #[macro_export]
+ #[rustc_builtin_macro]
+ macro_rules! const_format_args {
+ ($fmt:expr) => {{ /* compiler built-in */ }};
+ ($fmt:expr, $($args:tt)*) => {{ /* compiler built-in */ }};
+ }
+
+ pub(crate) use const_format_args;
+ // endregion:fmt
+
// region:derive
pub(crate) mod builtin {
#[rustc_builtin_macro]