File tree 3 files changed +12
-1
lines changed
src/tools/compiletest/src
3 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -349,6 +349,9 @@ pub struct Config {
349
349
/// The current Rust channel
350
350
pub channel : String ,
351
351
352
+ /// The default Rust edition
353
+ pub edition : Option < String > ,
354
+
352
355
// Configuration for various run-make tests frobbing things like C compilers
353
356
// or querying about various LLVM component information.
354
357
pub cc : String ,
Original file line number Diff line number Diff line change @@ -222,6 +222,7 @@ impl TestProps {
222
222
/// `//[foo]`), then the property is ignored unless `cfg` is
223
223
/// `Some("foo")`.
224
224
fn load_from ( & mut self , testfile : & Path , cfg : Option < & str > , config : & Config ) {
225
+ let mut has_edition = false ;
225
226
if !testfile. is_dir ( ) {
226
227
let file = File :: open ( testfile) . unwrap ( ) ;
227
228
@@ -240,6 +241,7 @@ impl TestProps {
240
241
241
242
if let Some ( edition) = config. parse_edition ( ln) {
242
243
self . compile_flags . push ( format ! ( "--edition={}" , edition) ) ;
244
+ has_edition = true ;
243
245
if edition == "2021" {
244
246
self . compile_flags . push ( "-Zunstable-options" . to_string ( ) ) ;
245
247
}
@@ -391,6 +393,10 @@ impl TestProps {
391
393
}
392
394
}
393
395
}
396
+
397
+ if let ( Some ( edition) , false ) = ( & config. edition , has_edition) {
398
+ self . compile_flags . push ( format ! ( "--edition={}" , edition) ) ;
399
+ }
394
400
}
395
401
396
402
fn update_fail_mode ( & mut self , ln : & str , config : & Config ) {
Original file line number Diff line number Diff line change @@ -147,7 +147,8 @@ pub fn parse_config(args: Vec<String>) -> Config {
147
147
)
148
148
. optflag ( "" , "force-rerun" , "rerun tests even if the inputs are unchanged" )
149
149
. optflag ( "h" , "help" , "show this message" )
150
- . reqopt ( "" , "channel" , "current Rust channel" , "CHANNEL" ) ;
150
+ . reqopt ( "" , "channel" , "current Rust channel" , "CHANNEL" )
151
+ . optopt ( "" , "edition" , "default Rust edition" , "EDITION" ) ;
151
152
152
153
let ( argv0, args_) = args. split_first ( ) . unwrap ( ) ;
153
154
if args. len ( ) == 1 || args[ 1 ] == "-h" || args[ 1 ] == "--help" {
@@ -282,6 +283,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
282
283
rustfix_coverage : matches. opt_present ( "rustfix-coverage" ) ,
283
284
has_tidy,
284
285
channel : matches. opt_str ( "channel" ) . unwrap ( ) ,
286
+ edition : matches. opt_str ( "edition" ) ,
285
287
286
288
cc : matches. opt_str ( "cc" ) . unwrap ( ) ,
287
289
cxx : matches. opt_str ( "cxx" ) . unwrap ( ) ,
You can’t perform that action at this time.
0 commit comments