@@ -151,8 +151,6 @@ pub(crate) fn run(dcx: DiagCtxtHandle<'_>, options: RustdocOptions) -> Result<()
151151 expanded_args : options. expanded_args . clone ( ) ,
152152 } ;
153153
154- let test_args = options. test_args . clone ( ) ;
155- let nocapture = options. nocapture ;
156154 let externs = options. externs . clone ( ) ;
157155 let json_unused_externs = options. json_unused_externs ;
158156
@@ -202,15 +200,7 @@ pub(crate) fn run(dcx: DiagCtxtHandle<'_>, options: RustdocOptions) -> Result<()
202200 } )
203201 } ) ?;
204202
205- run_tests (
206- test_args,
207- nocapture,
208- opts,
209- & rustdoc_options,
210- & unused_extern_reports,
211- standalone_tests,
212- mergeable_tests,
213- ) ;
203+ run_tests ( opts, & rustdoc_options, & unused_extern_reports, standalone_tests, mergeable_tests) ;
214204
215205 let compiling_test_count = compiling_test_count. load ( Ordering :: SeqCst ) ;
216206
@@ -256,16 +246,16 @@ pub(crate) fn run(dcx: DiagCtxtHandle<'_>, options: RustdocOptions) -> Result<()
256246}
257247
258248pub ( crate ) fn run_tests (
259- mut test_args : Vec < String > ,
260- nocapture : bool ,
261249 opts : GlobalTestOptions ,
262250 rustdoc_options : & Arc < RustdocOptions > ,
263251 unused_extern_reports : & Arc < Mutex < Vec < UnusedExterns > > > ,
264252 mut standalone_tests : Vec < test:: TestDescAndFn > ,
265253 mergeable_tests : FxHashMap < Edition , Vec < ( DocTest , ScrapedDoctest ) > > ,
266254) {
255+ let mut test_args = Vec :: with_capacity ( rustdoc_options. test_args . len ( ) + 1 ) ;
267256 test_args. insert ( 0 , "rustdoctest" . to_string ( ) ) ;
268- if nocapture {
257+ test_args. extend_from_slice ( & rustdoc_options. test_args ) ;
258+ if rustdoc_options. nocapture {
269259 test_args. push ( "--nocapture" . to_string ( ) ) ;
270260 }
271261
@@ -283,7 +273,7 @@ pub(crate) fn run_tests(
283273
284274 let rustdoc_test_options = IndividualTestOptions :: new (
285275 & rustdoc_options,
286- & format ! ( "merged_doctest_{edition}" ) ,
276+ & Some ( format ! ( "merged_doctest_{edition}" ) ) ,
287277 PathBuf :: from ( format ! ( "doctest_{edition}.rs" ) ) ,
288278 ) ;
289279
@@ -685,10 +675,10 @@ struct IndividualTestOptions {
685675}
686676
687677impl IndividualTestOptions {
688- fn new ( options : & RustdocOptions , test_id : & str , test_path : PathBuf ) -> Self {
678+ fn new ( options : & RustdocOptions , test_id : & Option < String > , test_path : PathBuf ) -> Self {
689679 let outdir = if let Some ( ref path) = options. persist_doctests {
690680 let mut path = path. clone ( ) ;
691- path. push ( & test_id) ;
681+ path. push ( & test_id. as_deref ( ) . unwrap_or_else ( || "<doctest>" ) ) ;
692682
693683 if let Err ( err) = std:: fs:: create_dir_all ( & path) {
694684 eprintln ! ( "Couldn't create directory for doctest executables: {err}" ) ;
@@ -858,11 +848,8 @@ fn generate_test_desc_and_fn(
858848 unused_externs : Arc < Mutex < Vec < UnusedExterns > > > ,
859849) -> test:: TestDescAndFn {
860850 let target_str = rustdoc_options. target . to_string ( ) ;
861- let rustdoc_test_options = IndividualTestOptions :: new (
862- & rustdoc_options,
863- test. test_id . as_deref ( ) . unwrap_or_else ( || "<doctest>" ) ,
864- scraped_test. path ( ) ,
865- ) ;
851+ let rustdoc_test_options =
852+ IndividualTestOptions :: new ( & rustdoc_options, & test. test_id , scraped_test. path ( ) ) ;
866853
867854 debug ! ( "creating test {}: {}" , scraped_test. name, scraped_test. text) ;
868855 test:: TestDescAndFn {
0 commit comments