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.rs26
1 files changed, 16 insertions, 10 deletions
diff --git a/crates/test-utils/src/minicore.rs b/crates/test-utils/src/minicore.rs
index bf53e58d70..4bdd791eb1 100644
--- a/crates/test-utils/src/minicore.rs
+++ b/crates/test-utils/src/minicore.rs
@@ -70,6 +70,7 @@
//! unimplemented: panic
//! column:
//! addr_of:
+//! offset_of:
#![rustc_coherence_is_core]
@@ -414,6 +415,13 @@ pub mod mem {
use crate::marker::DiscriminantKind;
pub struct Discriminant<T>(<T as DiscriminantKind>::Discriminant);
// endregion:discriminant
+
+ // region:offset_of
+ pub macro offset_of($Container:ty, $($fields:expr)+ $(,)?) {
+ // The `{}` is for better error messages
+ {builtin # offset_of($Container, $($fields)+)}
+ }
+ // endregion:offset_of
}
pub mod ptr {
@@ -423,10 +431,12 @@ pub mod ptr {
unsafe { drop_in_place(to_drop) }
}
pub const unsafe fn read<T>(src: *const T) -> T {
- *src
+ unsafe { *src }
}
pub const unsafe fn write<T>(dst: *mut T, src: T) {
- *dst = src;
+ unsafe {
+ *dst = src;
+ }
}
// endregion:drop
@@ -1061,7 +1071,7 @@ pub mod cmp {
// region:fmt
pub mod fmt {
pub struct Error;
- pub type Result = Result<(), Error>;
+ pub type Result = crate::result::Result<(), Error>;
pub struct Formatter<'a>;
pub struct DebugTuple;
pub struct DebugStruct;
@@ -1480,9 +1490,9 @@ pub mod iter {
}
}
}
- pub use self::repeat::{repeat, Repeat};
+ pub use self::repeat::{Repeat, repeat};
}
- pub use self::sources::{repeat, Repeat};
+ pub use self::sources::{Repeat, repeat};
// endregion:iterators
mod traits {
@@ -1811,11 +1821,7 @@ pub mod num {
#[lang = "bool"]
impl bool {
pub fn then<T, F: FnOnce() -> T>(self, f: F) -> Option<T> {
- if self {
- Some(f())
- } else {
- None
- }
+ if self { Some(f()) } else { None }
}
}
// endregion:bool_impl