File tree Expand file tree Collapse file tree 3 files changed +12
-1
lines changed
src/tools/compiletest/src Expand file tree Collapse file tree 3 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -349,6 +349,9 @@ pub struct Config {
349349 /// The current Rust channel
350350 pub channel : String ,
351351
352+ /// The default Rust edition
353+ pub edition : Option < String > ,
354+
352355 // Configuration for various run-make tests frobbing things like C compilers
353356 // or querying about various LLVM component information.
354357 pub cc : String ,
Original file line number Diff line number Diff line change @@ -222,6 +222,7 @@ impl TestProps {
222222 /// `//[foo]`), then the property is ignored unless `cfg` is
223223 /// `Some("foo")`.
224224 fn load_from ( & mut self , testfile : & Path , cfg : Option < & str > , config : & Config ) {
225+ let mut has_edition = false ;
225226 if !testfile. is_dir ( ) {
226227 let file = File :: open ( testfile) . unwrap ( ) ;
227228
@@ -240,6 +241,7 @@ impl TestProps {
240241
241242 if let Some ( edition) = config. parse_edition ( ln) {
242243 self . compile_flags . push ( format ! ( "--edition={}" , edition) ) ;
244+ has_edition = true ;
243245 if edition == "2021" {
244246 self . compile_flags . push ( "-Zunstable-options" . to_string ( ) ) ;
245247 }
@@ -391,6 +393,10 @@ impl TestProps {
391393 }
392394 }
393395 }
396+
397+ if let ( Some ( edition) , false ) = ( & config. edition , has_edition) {
398+ self . compile_flags . push ( format ! ( "--edition={}" , edition) ) ;
399+ }
394400 }
395401
396402 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 {
147147 )
148148 . optflag ( "" , "force-rerun" , "rerun tests even if the inputs are unchanged" )
149149 . 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" ) ;
151152
152153 let ( argv0, args_) = args. split_first ( ) . unwrap ( ) ;
153154 if args. len ( ) == 1 || args[ 1 ] == "-h" || args[ 1 ] == "--help" {
@@ -282,6 +283,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
282283 rustfix_coverage : matches. opt_present ( "rustfix-coverage" ) ,
283284 has_tidy,
284285 channel : matches. opt_str ( "channel" ) . unwrap ( ) ,
286+ edition : matches. opt_str ( "edition" ) ,
285287
286288 cc : matches. opt_str ( "cc" ) . unwrap ( ) ,
287289 cxx : matches. opt_str ( "cxx" ) . unwrap ( ) ,
You can’t perform that action at this time.
0 commit comments