@@ -20,7 +20,6 @@ use rustc_span::source_map::SourceMap;
2020use rustc_span:: symbol:: sym;
2121use rustc_span:: { BytePos , FileName , Pos , Span , DUMMY_SP } ;
2222use rustc_target:: spec:: { Target , TargetTriple } ;
23- use tempfile:: Builder as TempFileBuilder ;
2423
2524use std:: env;
2625use std:: fs:: File ;
@@ -32,7 +31,7 @@ use std::str;
3231use std:: sync:: atomic:: { AtomicUsize , Ordering } ;
3332use std:: sync:: { Arc , Mutex } ;
3433
35- use tempfile:: tempdir ;
34+ use tempfile:: { Builder as TempFileBuilder , TempDir } ;
3635
3736use crate :: clean:: { types:: AttributesExt , Attributes } ;
3837use crate :: config:: Options as RustdocOptions ;
@@ -92,6 +91,10 @@ pub(crate) fn generate_args_file(file_path: &Path, options: &RustdocOptions) ->
9291 Ok ( ( ) )
9392}
9493
94+ fn get_doctest_dir ( ) -> io:: Result < TempDir > {
95+ TempFileBuilder :: new ( ) . prefix ( "rustdoctest" ) . tempdir ( )
96+ }
97+
9598pub ( crate ) fn run (
9699 dcx : & rustc_errors:: DiagCtxt ,
97100 options : RustdocOptions ,
@@ -165,7 +168,7 @@ pub(crate) fn run(
165168 let externs = options. externs . clone ( ) ;
166169 let json_unused_externs = options. json_unused_externs ;
167170
168- let temp_dir = match tempdir ( )
171+ let temp_dir = match get_doctest_dir ( )
169172 . map_err ( |error| format ! ( "failed to create temporary directory: {error:?}" ) )
170173 {
171174 Ok ( temp_dir) => temp_dir,
@@ -962,12 +965,7 @@ impl RustdocTestOptions {
962965
963966 DirState :: Perm ( path)
964967 } else {
965- DirState :: Temp (
966- TempFileBuilder :: new ( )
967- . prefix ( "rustdoctest" )
968- . tempdir ( )
969- . expect ( "rustdoc needs a tempdir" ) ,
970- )
968+ DirState :: Temp ( get_doctest_dir ( ) . expect ( "rustdoc needs a tempdir" ) )
971969 } ;
972970
973971 Self {
0 commit comments