@@ -81,11 +81,15 @@ impl EarlyProps {
8181}
8282
8383#[ derive( Clone , Debug ) ]
84- pub struct TestProps {
84+ pub ( crate ) struct TestProps {
8585 // Lines that should be expected, in order, on standard out
8686 pub error_patterns : Vec < String > ,
8787 // Regexes that should be expected, in order, on standard out
8888 pub regex_error_patterns : Vec < String > ,
89+ /// Edition selected by an `//@ edition` directive, if any.
90+ ///
91+ /// Automatically added to `compile_flags` during directive processing.
92+ pub edition : Option < Edition > ,
8993 // Extra flags to pass to the compiler
9094 pub compile_flags : Vec < String > ,
9195 // Extra flags to pass when the compiled code is run (such as --bench)
@@ -267,6 +271,7 @@ impl TestProps {
267271 TestProps {
268272 error_patterns : vec ! [ ] ,
269273 regex_error_patterns : vec ! [ ] ,
274+ edition : None ,
270275 compile_flags : vec ! [ ] ,
271276 run_flags : vec ! [ ] ,
272277 doc_flags : vec ! [ ] ,
@@ -355,7 +360,6 @@ impl TestProps {
355360 /// `//@[foo]`), then the property is ignored unless `test_revision` is
356361 /// `Some("foo")`.
357362 fn load_from ( & mut self , testfile : & Utf8Path , test_revision : Option < & str > , config : & Config ) {
358- let mut has_edition = false ;
359363 if !testfile. is_dir ( ) {
360364 let file_contents = fs:: read_to_string ( testfile) . unwrap ( ) ;
361365 let file_directives = FileDirectives :: from_file_contents ( testfile, & file_contents) ;
@@ -423,13 +427,7 @@ impl TestProps {
423427 }
424428
425429 if let Some ( range) = parse_edition_range ( config, ln) {
426- // The edition is added at the start, since flags from //@compile-flags must
427- // be passed to rustc last.
428- self . compile_flags . insert (
429- 0 ,
430- format ! ( "--edition={}" , range. edition_to_test( config. edition) ) ,
431- ) ;
432- has_edition = true ;
430+ self . edition = Some ( range. edition_to_test ( config. edition ) ) ;
433431 }
434432
435433 config. parse_and_update_revisions ( ln, & mut self . revisions ) ;
@@ -678,10 +676,10 @@ impl TestProps {
678676 }
679677 }
680678
681- if let ( Some ( edition) , false ) = ( & config. edition , has_edition ) {
679+ if let Some ( edition) = self . edition . or ( config. edition ) {
682680 // The edition is added at the start, since flags from //@compile-flags must be passed
683681 // to rustc last.
684- self . compile_flags . insert ( 0 , format ! ( "--edition={}" , edition ) ) ;
682+ self . compile_flags . insert ( 0 , format ! ( "--edition={edition}" ) ) ;
685683 }
686684 }
687685
0 commit comments