@@ -23,11 +23,20 @@ pub enum Edition {
2323 Edition2021 ,
2424 /// The 2024 edition
2525 Edition2024 ,
26+ /// The next edition - this variant will always exist and features associated with next will be
27+ /// moved to the next 20XX edition when it is established. This allows edition changes to
28+ /// be implemented before the next edition is planned.
29+ EditionNext ,
2630}
2731
2832// Must be in order from oldest to newest.
29- pub const ALL_EDITIONS : & [ Edition ] =
30- & [ Edition :: Edition2015 , Edition :: Edition2018 , Edition :: Edition2021 , Edition :: Edition2024 ] ;
33+ pub const ALL_EDITIONS : & [ Edition ] = & [
34+ Edition :: Edition2015 ,
35+ Edition :: Edition2018 ,
36+ Edition :: Edition2021 ,
37+ Edition :: Edition2024 ,
38+ Edition :: EditionNext ,
39+ ] ;
3140
3241pub const EDITION_NAME_LIST : & str = "2015|2018|2021|2024" ;
3342
@@ -42,6 +51,7 @@ impl fmt::Display for Edition {
4251 Edition :: Edition2018 => "2018" ,
4352 Edition :: Edition2021 => "2021" ,
4453 Edition :: Edition2024 => "2024" ,
54+ Edition :: EditionNext => "next" ,
4555 } ;
4656 write ! ( f, "{s}" )
4757 }
@@ -54,6 +64,7 @@ impl Edition {
5464 Edition :: Edition2018 => "rust_2018_compatibility" ,
5565 Edition :: Edition2021 => "rust_2021_compatibility" ,
5666 Edition :: Edition2024 => "rust_2024_compatibility" ,
67+ Edition :: EditionNext => "edition_next_compatibility" ,
5768 }
5869 }
5970
@@ -63,6 +74,7 @@ impl Edition {
6374 Edition :: Edition2018 => true ,
6475 Edition :: Edition2021 => true ,
6576 Edition :: Edition2024 => true ,
77+ Edition :: EditionNext => false ,
6678 }
6779 }
6880
@@ -85,6 +97,11 @@ impl Edition {
8597 pub fn at_least_rust_2024 ( self ) -> bool {
8698 self >= Edition :: Edition2024
8799 }
100+
101+ /// Are we allowed to use features from the next edition?
102+ pub fn at_least_edition_next ( self ) -> bool {
103+ self >= Edition :: EditionNext
104+ }
88105}
89106
90107impl FromStr for Edition {
@@ -95,6 +112,7 @@ impl FromStr for Edition {
95112 "2018" => Ok ( Edition :: Edition2018 ) ,
96113 "2021" => Ok ( Edition :: Edition2021 ) ,
97114 "2024" => Ok ( Edition :: Edition2024 ) ,
115+ "next" => Ok ( Edition :: EditionNext ) ,
98116 _ => Err ( ( ) ) ,
99117 }
100118 }
0 commit comments