@@ -211,7 +211,11 @@ impl<'a, 'gctx: 'a> CompilationFiles<'a, 'gctx> {
211211 // Docscrape units need to have doc/ set as the out_dir so sources for reverse-dependencies
212212 // will be put into doc/ and not into deps/ where the *.examples files are stored.
213213 if unit. mode . is_doc ( ) || unit. mode . is_doc_scrape ( ) {
214- self . layout ( unit. kind ) . artifact_dir ( ) . doc ( ) . to_path_buf ( )
214+ self . layout ( unit. kind )
215+ . artifact_dir ( )
216+ . expect ( "artifact-dir was not locked" )
217+ . doc ( )
218+ . to_path_buf ( )
215219 } else if unit. mode . is_doc_test ( ) {
216220 panic ! ( "doc tests do not have an out dir" ) ;
217221 } else if unit. target . is_custom_build ( ) {
@@ -249,8 +253,8 @@ impl<'a, 'gctx: 'a> CompilationFiles<'a, 'gctx> {
249253 }
250254
251255 /// Returns the final artifact path for the host (`/…/target/debug`)
252- pub fn host_dest ( & self ) -> & Path {
253- self . host . artifact_dir ( ) . dest ( )
256+ pub fn host_dest ( & self ) -> Option < & Path > {
257+ self . host . artifact_dir ( ) . map ( |v| v . dest ( ) )
254258 }
255259
256260 /// Returns the root of the build output tree for the host (`/…/build-dir`)
@@ -283,8 +287,8 @@ impl<'a, 'gctx: 'a> CompilationFiles<'a, 'gctx> {
283287 }
284288
285289 /// Directory where timing output should go.
286- pub fn timings_dir ( & self ) -> & Path {
287- self . host . artifact_dir ( ) . timings ( )
290+ pub fn timings_dir ( & self ) -> Option < & Path > {
291+ self . host . artifact_dir ( ) . map ( |v| v . timings ( ) )
288292 }
289293
290294 /// Returns the path for a file in the fingerprint directory.
@@ -378,9 +382,11 @@ impl<'a, 'gctx: 'a> CompilationFiles<'a, 'gctx> {
378382 target : & Target ,
379383 kind : CompileKind ,
380384 bcx : & BuildContext < ' _ , ' _ > ,
381- ) -> CargoResult < PathBuf > {
385+ ) -> CargoResult < Option < PathBuf > > {
382386 assert ! ( target. is_bin( ) ) ;
383- let dest = self . layout ( kind) . artifact_dir ( ) . dest ( ) ;
387+ let Some ( dest) = self . layout ( kind) . artifact_dir ( ) . map ( |v| v. dest ( ) ) else {
388+ return Ok ( None ) ;
389+ } ;
384390 let info = bcx. target_data . info ( kind) ;
385391 let ( file_types, _) = info
386392 . rustc_outputs (
@@ -396,7 +402,7 @@ impl<'a, 'gctx: 'a> CompilationFiles<'a, 'gctx> {
396402 . find ( |file_type| file_type. flavor == FileFlavor :: Normal )
397403 . expect ( "target must support `bin`" ) ;
398404
399- Ok ( dest. join ( file_type. uplift_filename ( target) ) )
405+ Ok ( Some ( dest. join ( file_type. uplift_filename ( target) ) ) )
400406 }
401407
402408 /// Returns the filenames that the given unit will generate.
@@ -450,12 +456,17 @@ impl<'a, 'gctx: 'a> CompilationFiles<'a, 'gctx> {
450456 // Examples live in their own little world.
451457 self . layout ( unit. kind )
452458 . artifact_dir ( )
459+ . expect ( "artifact-dir was not locked" )
453460 . examples ( )
454461 . join ( filename)
455462 } else if unit. target . is_custom_build ( ) {
456463 self . build_script_dir ( unit) . join ( filename)
457464 } else {
458- self . layout ( unit. kind ) . artifact_dir ( ) . dest ( ) . join ( filename)
465+ self . layout ( unit. kind )
466+ . artifact_dir ( )
467+ . expect ( "artifact-dir was not locked" )
468+ . dest ( )
469+ . join ( filename)
459470 } ;
460471 if from_path == uplift_path {
461472 // This can happen with things like examples that reside in the
0 commit comments