@@ -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 ,
@@ -783,11 +808,13 @@ macro_rules! options {
783
808
Some ( "`string` or `string=string`" ) ;
784
809
pub const parse_lto: Option <& ' static str > =
785
810
Some ( "one of `thin`, `fat`, or omitted" ) ;
811
+ pub const parse_epoch: Option <& ' static str > =
812
+ Some ( "one of: `2015`, `2018`" ) ;
786
813
}
787
814
788
815
#[ allow( dead_code) ]
789
816
mod $mod_set {
790
- use super :: { $struct_name, Passes , SomePasses , AllPasses , Sanitizer , Lto } ;
817
+ use super :: { $struct_name, Passes , SomePasses , AllPasses , Sanitizer , Lto , Epoch } ;
791
818
use rustc_back:: { LinkerFlavor , PanicStrategy , RelroLevel } ;
792
819
use std:: path:: PathBuf ;
793
820
@@ -991,6 +1018,15 @@ macro_rules! options {
991
1018
} ;
992
1019
true
993
1020
}
1021
+
1022
+ fn parse_epoch( slot: & mut Epoch , v: Option <& str >) -> bool {
1023
+ match v {
1024
+ Some ( "2015" ) => * slot = Epoch :: Epoch2015 ,
1025
+ Some ( "2018" ) => * slot = Epoch :: Epoch2018 ,
1026
+ _ => return false ,
1027
+ }
1028
+ true
1029
+ }
994
1030
}
995
1031
) }
996
1032
@@ -1278,6 +1314,10 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
1278
1314
`everybody_loops` (all function bodies replaced with `loop {}`),
1279
1315
`hir` (the HIR), `hir,identified`, or
1280
1316
`hir,typed` (HIR with types for each node)." ) ,
1317
+ epoch: Epoch = ( Epoch :: Epoch2015 , parse_epoch, [ TRACKED ] ,
1318
+ "The epoch to build Rust with. Newer epochs may include features
1319
+ that require breaking changes. The default epoch is 2015 (the first
1320
+ epoch). Crates compiled with different epochs can be linked together." ) ,
1281
1321
}
1282
1322
1283
1323
pub fn default_lib_output ( ) -> CrateType {
@@ -2069,7 +2109,7 @@ mod dep_tracking {
2069
2109
use std:: path:: PathBuf ;
2070
2110
use std:: collections:: hash_map:: DefaultHasher ;
2071
2111
use super :: { Passes , CrateType , OptLevel , DebugInfoLevel , Lto ,
2072
- OutputTypes , Externs , ErrorOutputType , Sanitizer } ;
2112
+ OutputTypes , Externs , ErrorOutputType , Sanitizer , Epoch } ;
2073
2113
use syntax:: feature_gate:: UnstableFeatures ;
2074
2114
use rustc_back:: { PanicStrategy , RelroLevel } ;
2075
2115
@@ -2131,6 +2171,7 @@ mod dep_tracking {
2131
2171
impl_dep_tracking_hash_via_hash ! ( cstore:: NativeLibraryKind ) ;
2132
2172
impl_dep_tracking_hash_via_hash ! ( Sanitizer ) ;
2133
2173
impl_dep_tracking_hash_via_hash ! ( Option <Sanitizer >) ;
2174
+ impl_dep_tracking_hash_via_hash ! ( Epoch ) ;
2134
2175
2135
2176
impl_dep_tracking_hash_for_sortable_vec_of ! ( String ) ;
2136
2177
impl_dep_tracking_hash_for_sortable_vec_of ! ( PathBuf ) ;
0 commit comments