Skip to content

Commit 12fa08c

Browse files
authored
Rollup merge of rust-lang#82217 - m-ou-se:edition-prelude, r=nikomatsakis
Edition-specific preludes This changes `{std,core}::prelude` to export edition-specific preludes under `rust_2015`, `rust_2018` and `rust_2021`. (As suggested in rust-lang#51418 (comment).) For now they all just re-export `v1::*`, but this allows us to add things to the 2021edition prelude soon. This also changes the compiler to make the automatically injected prelude import dependent on the selected edition. cc `@rust-lang/libs` `@djc`
2 parents 4ba4212 + ba1ec8a commit 12fa08c

File tree

5 files changed

+74
-5
lines changed

5 files changed

+74
-5
lines changed

core/src/prelude/mod.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,41 @@
11
//! The libcore prelude
2+
//!
3+
//! This module is intended for users of libcore which do not link to libstd as
4+
//! well. This module is imported by default when `#![no_std]` is used in the
5+
//! same manner as the standard library's prelude.
26
37
#![stable(feature = "core_prelude", since = "1.4.0")]
48

59
pub mod v1;
10+
11+
/// The 2015 version of the core prelude.
12+
///
13+
/// See the [module-level documentation](self) for more.
14+
#[unstable(feature = "prelude_2015", issue = "none")]
15+
pub mod rust_2015 {
16+
#[unstable(feature = "prelude_2015", issue = "none")]
17+
#[doc(no_inline)]
18+
pub use super::v1::*;
19+
}
20+
21+
/// The 2018 version of the core prelude.
22+
///
23+
/// See the [module-level documentation](self) for more.
24+
#[unstable(feature = "prelude_2018", issue = "none")]
25+
pub mod rust_2018 {
26+
#[unstable(feature = "prelude_2018", issue = "none")]
27+
#[doc(no_inline)]
28+
pub use super::v1::*;
29+
}
30+
31+
/// The 2021 version of the core prelude.
32+
///
33+
/// See the [module-level documentation](self) for more.
34+
#[unstable(feature = "prelude_2021", issue = "none")]
35+
pub mod rust_2021 {
36+
#[unstable(feature = "prelude_2021", issue = "none")]
37+
#[doc(no_inline)]
38+
pub use super::v1::*;
39+
40+
// FIXME: Add more things.
41+
}

core/src/prelude/v1.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
//! The core prelude
1+
//! The first version of the core prelude.
22
//!
3-
//! This module is intended for users of libcore which do not link to libstd as
4-
//! well. This module is imported by default when `#![no_std]` is used in the
5-
//! same manner as the standard library's prelude.
3+
//! See the [module-level documentation](super) for more.
64
75
#![stable(feature = "core_prelude", since = "1.4.0")]
86

std/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@
302302
#![feature(panic_internals)]
303303
#![feature(panic_unwind)]
304304
#![feature(pin_static_ref)]
305+
#![feature(prelude_2021)]
305306
#![feature(prelude_import)]
306307
#![feature(ptr_internals)]
307308
#![feature(raw)]

std/src/prelude/mod.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,37 @@
8484
#![stable(feature = "rust1", since = "1.0.0")]
8585

8686
pub mod v1;
87+
88+
/// The 2015 version of the prelude of The Rust Standard Library.
89+
///
90+
/// See the [module-level documentation](self) for more.
91+
#[unstable(feature = "prelude_2015", issue = "none")]
92+
pub mod rust_2015 {
93+
#[unstable(feature = "prelude_2015", issue = "none")]
94+
#[doc(no_inline)]
95+
pub use super::v1::*;
96+
}
97+
98+
/// The 2018 version of the prelude of The Rust Standard Library.
99+
///
100+
/// See the [module-level documentation](self) for more.
101+
#[unstable(feature = "prelude_2018", issue = "none")]
102+
pub mod rust_2018 {
103+
#[unstable(feature = "prelude_2018", issue = "none")]
104+
#[doc(no_inline)]
105+
pub use super::v1::*;
106+
}
107+
108+
/// The 2021 version of the prelude of The Rust Standard Library.
109+
///
110+
/// See the [module-level documentation](self) for more.
111+
#[unstable(feature = "prelude_2021", issue = "none")]
112+
pub mod rust_2021 {
113+
#[unstable(feature = "prelude_2021", issue = "none")]
114+
#[doc(no_inline)]
115+
pub use super::v1::*;
116+
117+
#[unstable(feature = "prelude_2021", issue = "none")]
118+
#[doc(no_inline)]
119+
pub use core::prelude::rust_2021::*;
120+
}

std/src/prelude/v1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! The first version of the prelude of The Rust Standard Library.
22
//!
3-
//! See the [module-level documentation](../index.html) for more.
3+
//! See the [module-level documentation](super) for more.
44
55
#![stable(feature = "rust1", since = "1.0.0")]
66

0 commit comments

Comments
 (0)