@@ -365,7 +365,8 @@ fn run_test(
365
365
test : & str ,
366
366
crate_name : & str ,
367
367
line : usize ,
368
- rustdoc_options : IndividualTestOptions ,
368
+ rustdoc_options : & RustdocOptions ,
369
+ test_options : IndividualTestOptions ,
369
370
mut lang_string : LangString ,
370
371
no_run : bool ,
371
372
opts : & GlobalTestOptions ,
@@ -379,20 +380,20 @@ fn run_test(
379
380
lang_string. test_harness ,
380
381
opts,
381
382
edition,
382
- Some ( & rustdoc_options . test_id ) ,
383
+ Some ( & test_options . test_id ) ,
383
384
) ;
384
385
385
386
// Make sure we emit well-formed executable names for our target.
386
387
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) ;
388
389
389
390
let rustc_binary = rustdoc_options
390
391
. test_builder
391
392
. as_deref ( )
392
393
. unwrap_or_else ( || rustc_interface:: util:: rustc_path ( ) . expect ( "found rustc" ) ) ;
393
394
let mut compiler = wrapped_rustc_command ( & rustdoc_options. test_builder_wrappers , rustc_binary) ;
394
395
395
- compiler. arg ( & format ! ( "@{}" , rustdoc_options . arg_file. display( ) ) ) ;
396
+ compiler. arg ( & format ! ( "@{}" , test_options . arg_file. display( ) ) ) ;
396
397
397
398
if let Some ( sysroot) = & rustdoc_options. maybe_sysroot {
398
399
compiler. arg ( format ! ( "--sysroot={}" , sysroot. display( ) ) ) ;
@@ -405,20 +406,22 @@ fn run_test(
405
406
if lang_string. test_harness {
406
407
compiler. arg ( "--test" ) ;
407
408
}
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 {
409
410
compiler. arg ( "--error-format=json" ) ;
410
411
compiler. arg ( "--json" ) . arg ( "unused-externs" ) ;
411
412
compiler. arg ( "-W" ) . arg ( "unused_crate_dependencies" ) ;
412
413
compiler. arg ( "-Z" ) . arg ( "unstable-options" ) ;
413
414
}
414
415
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?
416
419
compiler. arg ( "--emit=metadata" ) ;
417
420
}
418
- compiler. arg ( "--target" ) . arg ( match rustdoc_options. target {
421
+ compiler. arg ( "--target" ) . arg ( match & rustdoc_options. target {
419
422
TargetTriple :: TargetTriple ( s) => s,
420
423
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" )
422
425
}
423
426
} ) ;
424
427
if let ErrorOutputType :: HumanReadable ( kind) = rustdoc_options. error_format {
@@ -511,15 +514,15 @@ fn run_test(
511
514
let mut cmd;
512
515
513
516
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 {
515
518
let tool = make_maybe_absolute_path ( tool. into ( ) ) ;
516
519
cmd = Command :: new ( tool) ;
517
- cmd. args ( rustdoc_options. runtool_args ) ;
520
+ cmd. args ( & rustdoc_options. runtool_args ) ;
518
521
cmd. arg ( output_file) ;
519
522
} else {
520
523
cmd = Command :: new ( output_file) ;
521
524
}
522
- if let Some ( run_directory) = rustdoc_options. test_run_directory {
525
+ if let Some ( run_directory) = & rustdoc_options. test_run_directory {
523
526
cmd. current_dir ( run_directory) ;
524
527
}
525
528
@@ -923,20 +926,9 @@ fn partition_source(s: &str, edition: Edition) -> (String, String, String) {
923
926
}
924
927
925
928
pub ( 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 ,
933
929
arg_file : PathBuf ,
934
930
outdir : DirState ,
935
- runtool : Option < String > ,
936
- runtool_args : Vec < String > ,
937
- target : TargetTriple ,
938
931
test_id : String ,
939
- maybe_sysroot : Option < PathBuf > ,
940
932
}
941
933
942
934
impl IndividualTestOptions {
@@ -955,22 +947,7 @@ impl IndividualTestOptions {
955
947
DirState :: Temp ( get_doctest_dir ( ) . expect ( "rustdoc needs a tempdir" ) )
956
948
} ;
957
949
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 }
974
951
}
975
952
}
976
953
@@ -994,7 +971,7 @@ pub(crate) trait DoctestVisitor {
994
971
pub ( crate ) struct CreateRunnableDoctests {
995
972
pub ( crate ) tests : Vec < test:: TestDescAndFn > ,
996
973
997
- rustdoc_options : RustdocOptions ,
974
+ rustdoc_options : Arc < RustdocOptions > ,
998
975
crate_name : String ,
999
976
opts : GlobalTestOptions ,
1000
977
visited_tests : FxHashMap < ( String , usize ) , usize > ,
@@ -1012,7 +989,7 @@ impl CreateRunnableDoctests {
1012
989
) -> CreateRunnableDoctests {
1013
990
CreateRunnableDoctests {
1014
991
tests : Vec :: new ( ) ,
1015
- rustdoc_options,
992
+ rustdoc_options : Arc :: new ( rustdoc_options ) ,
1016
993
crate_name,
1017
994
opts,
1018
995
visited_tests : FxHashMap :: default ( ) ,
@@ -1077,6 +1054,7 @@ impl CreateRunnableDoctests {
1077
1054
} ,
1078
1055
) ;
1079
1056
1057
+ let rustdoc_options = self . rustdoc_options . clone ( ) ;
1080
1058
let rustdoc_test_options =
1081
1059
IndividualTestOptions :: new ( & self . rustdoc_options , & self . arg_file , test_id) ;
1082
1060
@@ -1112,6 +1090,7 @@ impl CreateRunnableDoctests {
1112
1090
path,
1113
1091
scraped_test : test,
1114
1092
} ,
1093
+ rustdoc_options,
1115
1094
unused_externs,
1116
1095
)
1117
1096
} ) ) ,
@@ -1132,6 +1111,7 @@ struct RunnableDoctest {
1132
1111
1133
1112
fn doctest_run_fn (
1134
1113
runnable_test : RunnableDoctest ,
1114
+ rustdoc_options : Arc < RustdocOptions > ,
1135
1115
unused_externs : Arc < Mutex < Vec < UnusedExterns > > > ,
1136
1116
) -> Result < ( ) , String > {
1137
1117
let report_unused_externs = |uext| {
@@ -1141,6 +1121,7 @@ fn doctest_run_fn(
1141
1121
& runnable_test. scraped_test . text ,
1142
1122
& runnable_test. crate_name ,
1143
1123
runnable_test. scraped_test . line ,
1124
+ & rustdoc_options,
1144
1125
runnable_test. rustdoc_test_options ,
1145
1126
runnable_test. scraped_test . langstr ,
1146
1127
runnable_test. no_run ,
0 commit comments