Skip to content

Commit c7b7409

Browse files
authored
Unrolled build for rust-lang#137606
Rollup merge of rust-lang#137606 - davidtwco:next-edition, r=traviscross,ehuss add a "future" edition This idea has been discussed previously [on Zulip](https://rust-lang.zulipchat.com/#narrow/channel/213817-t-lang/topic/Continuous.20edition-like.20changes.3F/near/432559262) (though what I've implemented isn't exactly the "next"/"future" editions proposed in that message, just the "future" edition). I've found myself prototyping changes that involve edition migrations and wanting to target an upcoming edition for those migrations, but none exists. This should be permanently unstable and not removed.
2 parents f5a1ef7 + d6bb98e commit c7b7409

File tree

5 files changed

+67
-2
lines changed

5 files changed

+67
-2
lines changed

compiler/rustc_builtin_macros/src/standard_library_imports.rs

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ pub fn inject(
6060
Edition2018 => sym::rust_2018,
6161
Edition2021 => sym::rust_2021,
6262
Edition2024 => sym::rust_2024,
63+
EditionFuture => sym::rust_future,
6364
}])
6465
.map(|&symbol| Ident::new(symbol, span))
6566
.collect();

compiler/rustc_span/src/edition.rs

+27-2
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,27 @@ pub enum Edition {
2323
Edition2021,
2424
/// The 2024 edition
2525
Edition2024,
26+
/// The future edition - this variant will always exist and features associated with this
27+
/// edition can be moved to the next 20XX edition when it is established and it is confirmed
28+
/// that those features will be part of that edition.
29+
///
30+
/// This variant allows edition changes to be implemented before being assigned to a concrete
31+
/// edition - primarily when there are two different unstable behaviours that need tested across
32+
/// an edition boundary.
33+
///
34+
/// This edition will be permanently unstable and any features associated with this edition
35+
/// must also be behind a feature gate.
36+
EditionFuture,
2637
}
2738

2839
// Must be in order from oldest to newest.
29-
pub const ALL_EDITIONS: &[Edition] =
30-
&[Edition::Edition2015, Edition::Edition2018, Edition::Edition2021, Edition::Edition2024];
40+
pub const ALL_EDITIONS: &[Edition] = &[
41+
Edition::Edition2015,
42+
Edition::Edition2018,
43+
Edition::Edition2021,
44+
Edition::Edition2024,
45+
Edition::EditionFuture,
46+
];
3147

3248
pub const EDITION_NAME_LIST: &str = "2015|2018|2021|2024";
3349

@@ -42,6 +58,7 @@ impl fmt::Display for Edition {
4258
Edition::Edition2018 => "2018",
4359
Edition::Edition2021 => "2021",
4460
Edition::Edition2024 => "2024",
61+
Edition::EditionFuture => "future",
4562
};
4663
write!(f, "{s}")
4764
}
@@ -54,6 +71,7 @@ impl Edition {
5471
Edition::Edition2018 => "rust_2018_compatibility",
5572
Edition::Edition2021 => "rust_2021_compatibility",
5673
Edition::Edition2024 => "rust_2024_compatibility",
74+
Edition::EditionFuture => "edition_future_compatibility",
5775
}
5876
}
5977

@@ -63,6 +81,7 @@ impl Edition {
6381
Edition::Edition2018 => true,
6482
Edition::Edition2021 => true,
6583
Edition::Edition2024 => true,
84+
Edition::EditionFuture => false,
6685
}
6786
}
6887

@@ -85,6 +104,11 @@ impl Edition {
85104
pub fn at_least_rust_2024(self) -> bool {
86105
self >= Edition::Edition2024
87106
}
107+
108+
/// Are we allowed to use features from the future edition?
109+
pub fn at_least_edition_future(self) -> bool {
110+
self >= Edition::EditionFuture
111+
}
88112
}
89113

90114
impl FromStr for Edition {
@@ -95,6 +119,7 @@ impl FromStr for Edition {
95119
"2018" => Ok(Edition::Edition2018),
96120
"2021" => Ok(Edition::Edition2021),
97121
"2024" => Ok(Edition::Edition2024),
122+
"future" => Ok(Edition::EditionFuture),
98123
_ => Err(()),
99124
}
100125
}

compiler/rustc_span/src/symbol.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1718,6 +1718,7 @@ symbols! {
17181718
rust_cold_cc,
17191719
rust_eh_catch_typeinfo,
17201720
rust_eh_personality,
1721+
rust_future,
17211722
rust_logo,
17221723
rust_out,
17231724
rustc,

library/core/src/prelude/mod.rs

+23
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,26 @@ pub mod rust_2024 {
7070
#[doc(no_inline)]
7171
pub use crate::future::{Future, IntoFuture};
7272
}
73+
74+
/// The Future version of the core prelude.
75+
///
76+
/// See the [module-level documentation](self) for more.
77+
#[doc(hidden)]
78+
#[unstable(feature = "prelude_future", issue = "none")]
79+
pub mod rust_future {
80+
#[stable(feature = "rust1", since = "1.0.0")]
81+
#[doc(no_inline)]
82+
pub use super::v1::*;
83+
84+
#[stable(feature = "prelude_2021", since = "1.55.0")]
85+
#[doc(no_inline)]
86+
pub use crate::iter::FromIterator;
87+
88+
#[stable(feature = "prelude_2021", since = "1.55.0")]
89+
#[doc(no_inline)]
90+
pub use crate::convert::{TryFrom, TryInto};
91+
92+
#[stable(feature = "prelude_2024", since = "1.85.0")]
93+
#[doc(no_inline)]
94+
pub use crate::future::{Future, IntoFuture};
95+
}

library/std/src/prelude/mod.rs

+15
Original file line numberDiff line numberDiff line change
@@ -160,3 +160,18 @@ pub mod rust_2024 {
160160
#[doc(no_inline)]
161161
pub use core::prelude::rust_2024::*;
162162
}
163+
164+
/// The Future version of the prelude of The Rust Standard Library.
165+
///
166+
/// See the [module-level documentation](self) for more.
167+
#[doc(hidden)]
168+
#[unstable(feature = "prelude_future", issue = "none")]
169+
pub mod rust_future {
170+
#[stable(feature = "rust1", since = "1.0.0")]
171+
#[doc(no_inline)]
172+
pub use super::v1::*;
173+
174+
#[unstable(feature = "prelude_next", issue = "none")]
175+
#[doc(no_inline)]
176+
pub use core::prelude::rust_future::*;
177+
}

0 commit comments

Comments
 (0)