@@ -20,7 +20,6 @@ use rustc_span::source_map::SourceMap;
20
20
use rustc_span::symbol::sym;
21
21
use rustc_span::{BytePos, FileName, Pos, Span, DUMMY_SP};
22
22
use rustc_target::spec::{Target, TargetTriple};
23
- use tempfile::Builder as TempFileBuilder;
24
23
25
24
use std::env;
26
25
use std::fs::File;
@@ -32,7 +31,7 @@ use std::str;
32
31
use std::sync::atomic::{AtomicUsize, Ordering};
33
32
use std::sync::{Arc, Mutex};
34
33
35
- use tempfile::tempdir ;
34
+ use tempfile::{Builder as TempFileBuilder, TempDir} ;
36
35
37
36
use crate::clean::{types::AttributesExt, Attributes};
38
37
use crate::config::Options as RustdocOptions;
@@ -92,6 +91,10 @@ pub(crate) fn generate_args_file(file_path: &Path, options: &RustdocOptions) ->
92
91
Ok(())
93
92
}
94
93
94
+ fn get_doctest_dir() -> io::Result<TempDir> {
95
+ TempFileBuilder::new().prefix("rustdoctest").tempdir()
96
+ }
97
+
95
98
pub(crate) fn run(
96
99
dcx: &rustc_errors::DiagCtxt,
97
100
options: RustdocOptions,
@@ -165,7 +168,7 @@ pub(crate) fn run(
165
168
let externs = options.externs.clone();
166
169
let json_unused_externs = options.json_unused_externs;
167
170
168
- let temp_dir = match tempdir ()
171
+ let temp_dir = match get_doctest_dir ()
169
172
.map_err(|error| format!("failed to create temporary directory: {error:?}"))
170
173
{
171
174
Ok(temp_dir) => temp_dir,
@@ -962,12 +965,7 @@ impl RustdocTestOptions {
962
965
963
966
DirState::Perm(path)
964
967
} 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"))
971
969
};
972
970
973
971
Self {
0 commit comments