@@ -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
3248pub 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
90114impl 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 }
0 commit comments