@@ -23,11 +23,27 @@ pub enum Edition {
23
23
Edition2021 ,
24
24
/// The 2024 edition
25
25
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 ,
26
37
}
27
38
28
39
// 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
+ ] ;
31
47
32
48
pub const EDITION_NAME_LIST : & str = "2015|2018|2021|2024" ;
33
49
@@ -42,6 +58,7 @@ impl fmt::Display for Edition {
42
58
Edition :: Edition2018 => "2018" ,
43
59
Edition :: Edition2021 => "2021" ,
44
60
Edition :: Edition2024 => "2024" ,
61
+ Edition :: EditionFuture => "future" ,
45
62
} ;
46
63
write ! ( f, "{s}" )
47
64
}
@@ -54,6 +71,7 @@ impl Edition {
54
71
Edition :: Edition2018 => "rust_2018_compatibility" ,
55
72
Edition :: Edition2021 => "rust_2021_compatibility" ,
56
73
Edition :: Edition2024 => "rust_2024_compatibility" ,
74
+ Edition :: EditionFuture => "edition_future_compatibility" ,
57
75
}
58
76
}
59
77
@@ -63,6 +81,7 @@ impl Edition {
63
81
Edition :: Edition2018 => true ,
64
82
Edition :: Edition2021 => true ,
65
83
Edition :: Edition2024 => true ,
84
+ Edition :: EditionFuture => false ,
66
85
}
67
86
}
68
87
@@ -85,6 +104,11 @@ impl Edition {
85
104
pub fn at_least_rust_2024 ( self ) -> bool {
86
105
self >= Edition :: Edition2024
87
106
}
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
+ }
88
112
}
89
113
90
114
impl FromStr for Edition {
@@ -95,6 +119,7 @@ impl FromStr for Edition {
95
119
"2018" => Ok ( Edition :: Edition2018 ) ,
96
120
"2021" => Ok ( Edition :: Edition2021 ) ,
97
121
"2024" => Ok ( Edition :: Edition2024 ) ,
122
+ "future" => Ok ( Edition :: EditionFuture ) ,
98
123
_ => Err ( ( ) ) ,
99
124
}
100
125
}
0 commit comments