@@ -365,7 +365,8 @@ fn run_test(
365365 test : & str ,
366366 crate_name : & str ,
367367 line : usize ,
368- rustdoc_options : IndividualTestOptions ,
368+ rustdoc_options : & RustdocOptions ,
369+ test_options : IndividualTestOptions ,
369370 mut lang_string : LangString ,
370371 no_run : bool ,
371372 opts : & GlobalTestOptions ,
@@ -379,20 +380,20 @@ fn run_test(
379380 lang_string. test_harness ,
380381 opts,
381382 edition,
382- Some ( & rustdoc_options . test_id ) ,
383+ Some ( & test_options . test_id ) ,
383384 ) ;
384385
385386 // Make sure we emit well-formed executable names for our target.
386387 let rust_out = add_exe_suffix ( "rust_out" . to_owned ( ) , & rustdoc_options. target ) ;
387- let output_file = rustdoc_options . outdir . path ( ) . join ( rust_out) ;
388+ let output_file = test_options . outdir . path ( ) . join ( rust_out) ;
388389
389390 let rustc_binary = rustdoc_options
390391 . test_builder
391392 . as_deref ( )
392393 . unwrap_or_else ( || rustc_interface:: util:: rustc_path ( ) . expect ( "found rustc" ) ) ;
393394 let mut compiler = wrapped_rustc_command ( & rustdoc_options. test_builder_wrappers , rustc_binary) ;
394395
395- compiler. arg ( & format ! ( "@{}" , rustdoc_options . arg_file. display( ) ) ) ;
396+ compiler. arg ( & format ! ( "@{}" , test_options . arg_file. display( ) ) ) ;
396397
397398 if let Some ( sysroot) = & rustdoc_options. maybe_sysroot {
398399 compiler. arg ( format ! ( "--sysroot={}" , sysroot. display( ) ) ) ;
@@ -405,20 +406,21 @@ fn run_test(
405406 if lang_string. test_harness {
406407 compiler. arg ( "--test" ) ;
407408 }
408- if rustdoc_options. is_json_unused_externs_enabled && !lang_string. compile_fail {
409+ if rustdoc_options. json_unused_externs . is_enabled ( ) && !lang_string. compile_fail {
409410 compiler. arg ( "--error-format=json" ) ;
410411 compiler. arg ( "--json" ) . arg ( "unused-externs" ) ;
411412 compiler. arg ( "-W" ) . arg ( "unused_crate_dependencies" ) ;
412413 compiler. arg ( "-Z" ) . arg ( "unstable-options" ) ;
413414 }
414415
415- if no_run && !lang_string. compile_fail && rustdoc_options. should_persist_doctests {
416+ if no_run && !lang_string. compile_fail && rustdoc_options. persist_doctests . is_some ( ) {
417+ // FIXME!!! previously the code checked persisted_doctest.is_none(), but that doesn't make sense
416418 compiler. arg ( "--emit=metadata" ) ;
417419 }
418- compiler. arg ( "--target" ) . arg ( match rustdoc_options. target {
420+ compiler. arg ( "--target" ) . arg ( match & rustdoc_options. target {
419421 TargetTriple :: TargetTriple ( s) => s,
420422 TargetTriple :: TargetJson { path_for_rustdoc, .. } => {
421- path_for_rustdoc. to_str ( ) . expect ( "target path must be valid unicode" ) . to_string ( )
423+ path_for_rustdoc. to_str ( ) . expect ( "target path must be valid unicode" )
422424 }
423425 } ) ;
424426 if let ErrorOutputType :: HumanReadable ( kind) = rustdoc_options. error_format {
@@ -511,15 +513,15 @@ fn run_test(
511513 let mut cmd;
512514
513515 let output_file = make_maybe_absolute_path ( output_file) ;
514- if let Some ( tool) = rustdoc_options. runtool {
516+ if let Some ( tool) = & rustdoc_options. runtool {
515517 let tool = make_maybe_absolute_path ( tool. into ( ) ) ;
516518 cmd = Command :: new ( tool) ;
517- cmd. args ( rustdoc_options. runtool_args ) ;
519+ cmd. args ( & rustdoc_options. runtool_args ) ;
518520 cmd. arg ( output_file) ;
519521 } else {
520522 cmd = Command :: new ( output_file) ;
521523 }
522- if let Some ( run_directory) = rustdoc_options. test_run_directory {
524+ if let Some ( run_directory) = & rustdoc_options. test_run_directory {
523525 cmd. current_dir ( run_directory) ;
524526 }
525527
@@ -924,20 +926,9 @@ fn partition_source(s: &str, edition: Edition) -> (String, String, String) {
924926}
925927
926928pub ( crate ) struct IndividualTestOptions {
927- test_builder : Option < PathBuf > ,
928- test_builder_wrappers : Vec < PathBuf > ,
929- is_json_unused_externs_enabled : bool ,
930- should_persist_doctests : bool ,
931- error_format : ErrorOutputType ,
932- test_run_directory : Option < PathBuf > ,
933- nocapture : bool ,
934929 arg_file : PathBuf ,
935930 outdir : DirState ,
936- runtool : Option < String > ,
937- runtool_args : Vec < String > ,
938- target : TargetTriple ,
939931 test_id : String ,
940- maybe_sysroot : Option < PathBuf > ,
941932}
942933
943934impl IndividualTestOptions {
@@ -956,22 +947,7 @@ impl IndividualTestOptions {
956947 DirState :: Temp ( get_doctest_dir ( ) . expect ( "rustdoc needs a tempdir" ) )
957948 } ;
958949
959- Self {
960- test_builder : options. test_builder . clone ( ) ,
961- test_builder_wrappers : options. test_builder_wrappers . clone ( ) ,
962- is_json_unused_externs_enabled : options. json_unused_externs . is_enabled ( ) ,
963- should_persist_doctests : options. persist_doctests . is_none ( ) ,
964- error_format : options. error_format ,
965- test_run_directory : options. test_run_directory . clone ( ) ,
966- nocapture : options. nocapture ,
967- arg_file : arg_file. into ( ) ,
968- outdir,
969- runtool : options. runtool . clone ( ) ,
970- runtool_args : options. runtool_args . clone ( ) ,
971- target : options. target . clone ( ) ,
972- test_id,
973- maybe_sysroot : options. maybe_sysroot . clone ( ) ,
974- }
950+ Self { arg_file : arg_file. into ( ) , outdir, test_id }
975951 }
976952}
977953
@@ -995,7 +971,7 @@ pub(crate) trait DoctestVisitor {
995971pub ( crate ) struct CreateRunnableDoctests {
996972 pub ( crate ) tests : Vec < test:: TestDescAndFn > ,
997973
998- rustdoc_options : RustdocOptions ,
974+ rustdoc_options : Arc < RustdocOptions > ,
999975 crate_name : String ,
1000976 opts : GlobalTestOptions ,
1001977 visited_tests : FxHashMap < ( String , usize ) , usize > ,
@@ -1013,7 +989,7 @@ impl CreateRunnableDoctests {
1013989 ) -> CreateRunnableDoctests {
1014990 CreateRunnableDoctests {
1015991 tests : Vec :: new ( ) ,
1016- rustdoc_options,
992+ rustdoc_options : Arc :: new ( rustdoc_options ) ,
1017993 crate_name,
1018994 opts,
1019995 visited_tests : FxHashMap :: default ( ) ,
@@ -1078,6 +1054,7 @@ impl CreateRunnableDoctests {
10781054 } ,
10791055 ) ;
10801056
1057+ let rustdoc_options = self . rustdoc_options . clone ( ) ;
10811058 let rustdoc_test_options =
10821059 IndividualTestOptions :: new ( & self . rustdoc_options , & self . arg_file , test_id) ;
10831060
@@ -1113,6 +1090,7 @@ impl CreateRunnableDoctests {
11131090 path,
11141091 scraped_test : test,
11151092 } ,
1093+ rustdoc_options,
11161094 unused_externs,
11171095 )
11181096 } ) ) ,
@@ -1133,6 +1111,7 @@ struct RunnableDoctest {
11331111
11341112fn doctest_run_fn (
11351113 runnable_test : RunnableDoctest ,
1114+ rustdoc_options : Arc < RustdocOptions > ,
11361115 unused_externs : Arc < Mutex < Vec < UnusedExterns > > > ,
11371116) -> Result < ( ) , String > {
11381117 let report_unused_externs = |uext| {
@@ -1142,6 +1121,7 @@ fn doctest_run_fn(
11421121 & runnable_test. scraped_test . text ,
11431122 & runnable_test. crate_name ,
11441123 runnable_test. scraped_test . line ,
1124+ & rustdoc_options,
11451125 runnable_test. rustdoc_test_options ,
11461126 runnable_test. scraped_test . langstr ,
11471127 runnable_test. no_run ,
0 commit comments