diff --git a/sgx_tstd/build.rs b/sgx_tstd/build.rs index ddc7ab988..2dc266414 100644 --- a/sgx_tstd/build.rs +++ b/sgx_tstd/build.rs @@ -51,6 +51,12 @@ fn main() { if let Some(true) = is_min_date("2021-02-07") { println!("cargo:rustc-cfg=derive_macros"); } + + // nightly-2021-03-11 (rustc 2021-03-10) + // https://github.com/rust-lang/rust/commit/1ab9fe5d44860050232438967bbbf9bdc35dbde1 + if let Some(true) = is_min_date("2021-03-10") { + println!("cargo:rustc-cfg=enable_prelude_version"); + } } // code below copied from crate version_check diff --git a/sgx_tstd/src/lib.rs b/sgx_tstd/src/lib.rs index 44db0f9f5..856b5ce7b 100644 --- a/sgx_tstd/src/lib.rs +++ b/sgx_tstd/src/lib.rs @@ -81,6 +81,7 @@ #![feature(needs_panic_runtime)] #![feature(once_cell)] #![feature(panic_unwind)] +#![cfg_attr(enable_prelude_version, feature(prelude_2021))] #![feature(prelude_import)] #![feature(ptr_internals)] #![feature(raw)] diff --git a/sgx_tstd/src/prelude/mod.rs b/sgx_tstd/src/prelude/mod.rs index ff66b282b..cb8353f0c 100644 --- a/sgx_tstd/src/prelude/mod.rs +++ b/sgx_tstd/src/prelude/mod.rs @@ -30,3 +30,33 @@ //! On a technical level, Rust inserts //! pub mod v1; + +/// The 2015 version of the prelude of The Rust Standard Library. +/// +/// See the [module-level documentation](self) for more. +#[cfg(enable_prelude_version)] +pub mod rust_2015 { + #[doc(no_inline)] + pub use super::v1::*; +} + +/// The 2018 version of the prelude of The Rust Standard Library. +/// +/// See the [module-level documentation](self) for more. +#[cfg(enable_prelude_version)] +pub mod rust_2018 { + #[doc(no_inline)] + pub use super::v1::*; +} + +/// The 2021 version of the prelude of The Rust Standard Library. +/// +/// See the [module-level documentation](self) for more. +#[cfg(enable_prelude_version)] +pub mod rust_2021 { + #[doc(no_inline)] + pub use super::v1::*; + + #[doc(no_inline)] + pub use core::prelude::rust_2021::*; +} diff --git a/xargo/sgx_tstd/build.rs b/xargo/sgx_tstd/build.rs index 8d9976320..a3ef7e24c 100644 --- a/xargo/sgx_tstd/build.rs +++ b/xargo/sgx_tstd/build.rs @@ -52,6 +52,12 @@ fn main() { if let Some(true) = is_min_date("2021-02-07") { println!("cargo:rustc-cfg=derive_macros"); } + + // nightly-2021-03-11 (rustc 2021-03-10) + // https://github.com/rust-lang/rust/commit/1ab9fe5d44860050232438967bbbf9bdc35dbde1 + if let Some(true) = is_min_date("2021-03-10") { + println!("cargo:rustc-cfg=enable_prelude_version"); + } } // code below copied from crate version_check