@@ -112,6 +112,31 @@ pub enum OutputType {
112
112
DepInfo ,
113
113
}
114
114
115
+ /// The epoch of the compiler (RFC 2052)
116
+ #[ derive( Clone , Copy , Hash , PartialOrd , Ord , Eq , PartialEq ) ]
117
+ #[ non_exhaustive]
118
+ pub enum Epoch {
119
+ // epochs must be kept in order, newest to oldest
120
+
121
+ /// The 2015 epoch
122
+ Epoch2015 ,
123
+ /// The 2018 epoch
124
+ Epoch2018 ,
125
+
126
+ // when adding new epochs, be sure to update:
127
+ //
128
+ // - the list in the `parse_epoch` static
129
+ // - the match in the `parse_epoch` function
130
+ // - add a `rust_####()` function to the session
131
+ // - update the enum in Cargo's sources as well
132
+ //
133
+ // When -Zepoch becomes --epoch, there will
134
+ // also be a check for the epoch being nightly-only
135
+ // somewhere. That will need to be updated
136
+ // whenever we're stabilizing/introducing a new epoch
137
+ // as well as changing the default Cargo template.
138
+ }
139
+
115
140
impl_stable_hash_for ! ( enum self :: OutputType {
116
141
Bitcode ,
117
142
Assembly ,
@@ -802,11 +827,13 @@ macro_rules! options {
802
827
Some ( "`string` or `string=string`" ) ;
803
828
pub const parse_lto: Option <& ' static str > =
804
829
Some ( "one of `thin`, `fat`, or omitted" ) ;
830
+ pub const parse_epoch: Option <& ' static str > =
831
+ Some ( "one of: `2015`, `2018`" ) ;
805
832
}
806
833
807
834
#[ allow( dead_code) ]
808
835
mod $mod_set {
809
- use super :: { $struct_name, Passes , SomePasses , AllPasses , Sanitizer , Lto } ;
836
+ use super :: { $struct_name, Passes , SomePasses , AllPasses , Sanitizer , Lto , Epoch } ;
810
837
use rustc_back:: { LinkerFlavor , PanicStrategy , RelroLevel } ;
811
838
use std:: path:: PathBuf ;
812
839
@@ -1010,6 +1037,15 @@ macro_rules! options {
1010
1037
} ;
1011
1038
true
1012
1039
}
1040
+
1041
+ fn parse_epoch( slot: & mut Epoch , v: Option <& str >) -> bool {
1042
+ match v {
1043
+ Some ( "2015" ) => * slot = Epoch :: Epoch2015 ,
1044
+ Some ( "2018" ) => * slot = Epoch :: Epoch2018 ,
1045
+ _ => return false ,
1046
+ }
1047
+ true
1048
+ }
1013
1049
}
1014
1050
) }
1015
1051
@@ -1297,6 +1333,10 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
1297
1333
`everybody_loops` (all function bodies replaced with `loop {}`),
1298
1334
`hir` (the HIR), `hir,identified`, or
1299
1335
`hir,typed` (HIR with types for each node)." ) ,
1336
+ epoch: Epoch = ( Epoch :: Epoch2015 , parse_epoch, [ TRACKED ] ,
1337
+ "The epoch to build Rust with. Newer epochs may include features
1338
+ that require breaking changes. The default epoch is 2015 (the first
1339
+ epoch). Crates compiled with different epochs can be linked together." ) ,
1300
1340
}
1301
1341
1302
1342
pub fn default_lib_output ( ) -> CrateType {
@@ -2088,7 +2128,7 @@ mod dep_tracking {
2088
2128
use std:: path:: PathBuf ;
2089
2129
use std:: collections:: hash_map:: DefaultHasher ;
2090
2130
use super :: { Passes , CrateType , OptLevel , DebugInfoLevel , Lto ,
2091
- OutputTypes , Externs , ErrorOutputType , Sanitizer } ;
2131
+ OutputTypes , Externs , ErrorOutputType , Sanitizer , Epoch } ;
2092
2132
use syntax:: feature_gate:: UnstableFeatures ;
2093
2133
use rustc_back:: { PanicStrategy , RelroLevel } ;
2094
2134
@@ -2150,6 +2190,7 @@ mod dep_tracking {
2150
2190
impl_dep_tracking_hash_via_hash ! ( cstore:: NativeLibraryKind ) ;
2151
2191
impl_dep_tracking_hash_via_hash ! ( Sanitizer ) ;
2152
2192
impl_dep_tracking_hash_via_hash ! ( Option <Sanitizer >) ;
2193
+ impl_dep_tracking_hash_via_hash ! ( Epoch ) ;
2153
2194
2154
2195
impl_dep_tracking_hash_for_sortable_vec_of ! ( String ) ;
2155
2196
impl_dep_tracking_hash_for_sortable_vec_of ! ( PathBuf ) ;
0 commit comments