@@ -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
@@ -924,20 +927,9 @@ fn partition_source(s: &str, edition: Edition) -> (String, String, String) {
924
927
}
925
928
926
929
pub ( 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 ,
934
930
arg_file : PathBuf ,
935
931
outdir : DirState ,
936
- runtool : Option < String > ,
937
- runtool_args : Vec < String > ,
938
- target : TargetTriple ,
939
932
test_id : String ,
940
- maybe_sysroot : Option < PathBuf > ,
941
933
}
942
934
943
935
impl IndividualTestOptions {
@@ -956,22 +948,7 @@ impl IndividualTestOptions {
956
948
DirState :: Temp ( get_doctest_dir ( ) . expect ( "rustdoc needs a tempdir" ) )
957
949
} ;
958
950
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
- }
951
+ Self { arg_file : arg_file. into ( ) , outdir, test_id }
975
952
}
976
953
}
977
954
@@ -995,7 +972,7 @@ pub(crate) trait DoctestVisitor {
995
972
pub ( crate ) struct CreateRunnableDoctests {
996
973
pub ( crate ) tests : Vec < test:: TestDescAndFn > ,
997
974
998
- rustdoc_options : RustdocOptions ,
975
+ rustdoc_options : Arc < RustdocOptions > ,
999
976
crate_name : String ,
1000
977
opts : GlobalTestOptions ,
1001
978
visited_tests : FxHashMap < ( String , usize ) , usize > ,
@@ -1013,7 +990,7 @@ impl CreateRunnableDoctests {
1013
990
) -> CreateRunnableDoctests {
1014
991
CreateRunnableDoctests {
1015
992
tests : Vec :: new ( ) ,
1016
- rustdoc_options,
993
+ rustdoc_options : Arc :: new ( rustdoc_options ) ,
1017
994
crate_name,
1018
995
opts,
1019
996
visited_tests : FxHashMap :: default ( ) ,
@@ -1078,6 +1055,7 @@ impl CreateRunnableDoctests {
1078
1055
} ,
1079
1056
) ;
1080
1057
1058
+ let rustdoc_options = self . rustdoc_options . clone ( ) ;
1081
1059
let rustdoc_test_options =
1082
1060
IndividualTestOptions :: new ( & self . rustdoc_options , & self . arg_file , test_id) ;
1083
1061
@@ -1113,6 +1091,7 @@ impl CreateRunnableDoctests {
1113
1091
path,
1114
1092
scraped_test : test,
1115
1093
} ,
1094
+ rustdoc_options,
1116
1095
unused_externs,
1117
1096
)
1118
1097
} ) ) ,
@@ -1133,6 +1112,7 @@ struct RunnableDoctest {
1133
1112
1134
1113
fn doctest_run_fn (
1135
1114
runnable_test : RunnableDoctest ,
1115
+ rustdoc_options : Arc < RustdocOptions > ,
1136
1116
unused_externs : Arc < Mutex < Vec < UnusedExterns > > > ,
1137
1117
) -> Result < ( ) , String > {
1138
1118
let report_unused_externs = |uext| {
@@ -1142,6 +1122,7 @@ fn doctest_run_fn(
1142
1122
& runnable_test. scraped_test . text ,
1143
1123
& runnable_test. crate_name ,
1144
1124
runnable_test. scraped_test . line ,
1125
+ & rustdoc_options,
1145
1126
runnable_test. rustdoc_test_options ,
1146
1127
runnable_test. scraped_test . langstr ,
1147
1128
runnable_test. no_run ,
0 commit comments