@@ -10,6 +10,7 @@ use std::path::{Path, PathBuf};
1010use std:: { env, fs, iter} ;
1111
1212use build_helper:: exit;
13+ use tempfile:: TempDir ;
1314
1415use crate :: core:: build_steps:: compile:: { Std , run_cargo} ;
1516use crate :: core:: build_steps:: doc:: { DocumentationFormat , prepare_doc_compiler} ;
@@ -3224,17 +3225,21 @@ impl Step for Distcheck {
32243225 fn run ( self , builder : & Builder < ' _ > ) {
32253226 // Use a temporary directory completely outside the current checkout, to avoid reusing any
32263227 // local source code, built artifacts or configuration by accident
3227- let root_dir = std :: env :: temp_dir ( ) . join ( "distcheck" ) ;
3228+ let root_dir = TempDir :: with_prefix ( "distcheck-" ) . unwrap ( ) ;
32283229
3229- distcheck_plain_source_tarball ( builder, & root_dir. join ( "distcheck-rustc-src" ) ) ;
3230- distcheck_rust_src ( builder, & root_dir. join ( "distcheck-rust-src" ) ) ;
3231- distcheck_rustc_dev ( builder, & root_dir. join ( "distcheck-rustc-dev" ) ) ;
3230+ distcheck_plain_source_tarball (
3231+ builder,
3232+ TempDir :: with_prefix_in ( "rustc-src-" , & root_dir) . unwrap ( ) ,
3233+ ) ;
3234+ distcheck_rust_src ( builder, TempDir :: with_prefix_in ( "rust-src-" , & root_dir) . unwrap ( ) ) ;
3235+ distcheck_rustc_dev ( builder, TempDir :: with_prefix_in ( "rustc-dev-" , & root_dir) . unwrap ( ) ) ;
32323236 }
32333237}
32343238
32353239/// Check that we can build some basic things from the plain source tarball
3236- fn distcheck_plain_source_tarball ( builder : & Builder < ' _ > , plain_src_dir : & Path ) {
3240+ fn distcheck_plain_source_tarball ( builder : & Builder < ' _ > , plain_src_dir : TempDir ) {
32373241 builder. info ( "Distcheck plain source tarball" ) ;
3242+ let plain_src_dir = plain_src_dir. path ( ) ;
32383243 let plain_src_tarball = builder. ensure ( dist:: PlainSourceTarball ) ;
32393244 builder. clear_dir ( plain_src_dir) ;
32403245
@@ -3265,8 +3270,9 @@ fn distcheck_plain_source_tarball(builder: &Builder<'_>, plain_src_dir: &Path) {
32653270}
32663271
32673272/// Check that rust-src has all of libstd's dependencies
3268- fn distcheck_rust_src ( builder : & Builder < ' _ > , src_dir : & Path ) {
3273+ fn distcheck_rust_src ( builder : & Builder < ' _ > , src_dir : TempDir ) {
32693274 builder. info ( "Distcheck rust-src" ) ;
3275+ let src_dir = src_dir. path ( ) ;
32703276 let src_tarball = builder. ensure ( dist:: Src ) ;
32713277 builder. clear_dir ( src_dir) ;
32723278
@@ -3290,8 +3296,9 @@ fn distcheck_rust_src(builder: &Builder<'_>, src_dir: &Path) {
32903296}
32913297
32923298/// Check that rustc-dev's compiler crate source code can be loaded with `cargo metadata`
3293- fn distcheck_rustc_dev ( builder : & Builder < ' _ > , dir : & Path ) {
3299+ fn distcheck_rustc_dev ( builder : & Builder < ' _ > , dir : TempDir ) {
32943300 builder. info ( "Distcheck rustc-dev" ) ;
3301+ let dir = dir. path ( ) ;
32953302 let tarball = builder. ensure ( dist:: RustcDev :: new ( builder, builder. host_target ) ) . unwrap ( ) ;
32963303 builder. clear_dir ( dir) ;
32973304
0 commit comments