@@ -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,22 @@ 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_none ( ) {
417+ // FIXME: why does this code check if it *shouldn't* persist doctests
418+ // -- shouldn't it be the negation?
416419 compiler. arg ( "--emit=metadata" ) ;
417420 }
418- compiler. arg ( "--target" ) . arg ( match rustdoc_options. target {
421+ compiler. arg ( "--target" ) . arg ( match & rustdoc_options. target {
419422 TargetTriple :: TargetTriple ( s) => s,
420423 TargetTriple :: TargetJson { path_for_rustdoc, .. } => {
421- path_for_rustdoc. to_str ( ) . expect ( "target path must be valid unicode" ) . to_string ( )
424+ path_for_rustdoc. to_str ( ) . expect ( "target path must be valid unicode" )
422425 }
423426 } ) ;
424427 if let ErrorOutputType :: HumanReadable ( kind) = rustdoc_options. error_format {
@@ -511,15 +514,15 @@ fn run_test(
511514 let mut cmd;
512515
513516 let output_file = make_maybe_absolute_path ( output_file) ;
514- if let Some ( tool) = rustdoc_options. runtool {
517+ if let Some ( tool) = & rustdoc_options. runtool {
515518 let tool = make_maybe_absolute_path ( tool. into ( ) ) ;
516519 cmd = Command :: new ( tool) ;
517- cmd. args ( rustdoc_options. runtool_args ) ;
520+ cmd. args ( & rustdoc_options. runtool_args ) ;
518521 cmd. arg ( output_file) ;
519522 } else {
520523 cmd = Command :: new ( output_file) ;
521524 }
522- if let Some ( run_directory) = rustdoc_options. test_run_directory {
525+ if let Some ( run_directory) = & rustdoc_options. test_run_directory {
523526 cmd. current_dir ( run_directory) ;
524527 }
525528
@@ -923,20 +926,9 @@ fn partition_source(s: &str, edition: Edition) -> (String, String, String) {
923926}
924927
925928pub ( crate ) struct IndividualTestOptions {
926- test_builder : Option < PathBuf > ,
927- test_builder_wrappers : Vec < PathBuf > ,
928- is_json_unused_externs_enabled : bool ,
929- should_persist_doctests : bool ,
930- error_format : ErrorOutputType ,
931- test_run_directory : Option < PathBuf > ,
932- nocapture : bool ,
933929 arg_file : PathBuf ,
934930 outdir : DirState ,
935- runtool : Option < String > ,
936- runtool_args : Vec < String > ,
937- target : TargetTriple ,
938931 test_id : String ,
939- maybe_sysroot : Option < PathBuf > ,
940932}
941933
942934impl IndividualTestOptions {
@@ -955,22 +947,7 @@ impl IndividualTestOptions {
955947 DirState :: Temp ( get_doctest_dir ( ) . expect ( "rustdoc needs a tempdir" ) )
956948 } ;
957949
958- Self {
959- test_builder : options. test_builder . clone ( ) ,
960- test_builder_wrappers : options. test_builder_wrappers . clone ( ) ,
961- is_json_unused_externs_enabled : options. json_unused_externs . is_enabled ( ) ,
962- should_persist_doctests : options. persist_doctests . is_none ( ) ,
963- error_format : options. error_format ,
964- test_run_directory : options. test_run_directory . clone ( ) ,
965- nocapture : options. nocapture ,
966- arg_file : arg_file. into ( ) ,
967- outdir,
968- runtool : options. runtool . clone ( ) ,
969- runtool_args : options. runtool_args . clone ( ) ,
970- target : options. target . clone ( ) ,
971- test_id,
972- maybe_sysroot : options. maybe_sysroot . clone ( ) ,
973- }
950+ Self { arg_file : arg_file. into ( ) , outdir, test_id }
974951 }
975952}
976953
@@ -994,7 +971,7 @@ pub(crate) trait DoctestVisitor {
994971pub ( crate ) struct CreateRunnableDoctests {
995972 pub ( crate ) tests : Vec < test:: TestDescAndFn > ,
996973
997- rustdoc_options : RustdocOptions ,
974+ rustdoc_options : Arc < RustdocOptions > ,
998975 crate_name : String ,
999976 opts : GlobalTestOptions ,
1000977 visited_tests : FxHashMap < ( String , usize ) , usize > ,
@@ -1012,7 +989,7 @@ impl CreateRunnableDoctests {
1012989 ) -> CreateRunnableDoctests {
1013990 CreateRunnableDoctests {
1014991 tests : Vec :: new ( ) ,
1015- rustdoc_options,
992+ rustdoc_options : Arc :: new ( rustdoc_options ) ,
1016993 crate_name,
1017994 opts,
1018995 visited_tests : FxHashMap :: default ( ) ,
@@ -1077,6 +1054,7 @@ impl CreateRunnableDoctests {
10771054 } ,
10781055 ) ;
10791056
1057+ let rustdoc_options = self . rustdoc_options . clone ( ) ;
10801058 let rustdoc_test_options =
10811059 IndividualTestOptions :: new ( & self . rustdoc_options , & self . arg_file , test_id) ;
10821060
@@ -1112,6 +1090,7 @@ impl CreateRunnableDoctests {
11121090 path,
11131091 scraped_test : test,
11141092 } ,
1093+ rustdoc_options,
11151094 unused_externs,
11161095 )
11171096 } ) ) ,
@@ -1132,6 +1111,7 @@ struct RunnableDoctest {
11321111
11331112fn doctest_run_fn (
11341113 runnable_test : RunnableDoctest ,
1114+ rustdoc_options : Arc < RustdocOptions > ,
11351115 unused_externs : Arc < Mutex < Vec < UnusedExterns > > > ,
11361116) -> Result < ( ) , String > {
11371117 let report_unused_externs = |uext| {
@@ -1141,6 +1121,7 @@ fn doctest_run_fn(
11411121 & runnable_test. scraped_test . text ,
11421122 & runnable_test. crate_name ,
11431123 runnable_test. scraped_test . line ,
1124+ & rustdoc_options,
11441125 runnable_test. rustdoc_test_options ,
11451126 runnable_test. scraped_test . langstr ,
11461127 runnable_test. no_run ,
0 commit comments