File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -471,22 +471,25 @@ impl Config {
471
471
pub fn target_dir ( & self ) -> CargoResult < Option < Filesystem > > {
472
472
if let Some ( dir) = & self . target_dir {
473
473
Ok ( Some ( dir. clone ( ) ) )
474
- } else if let Some ( dir) = env:: var_os ( "CARGO_TARGET_DIR" ) {
474
+ } else if let Some ( dir) = self . env . get ( "CARGO_TARGET_DIR" ) {
475
475
// Check if the CARGO_TARGET_DIR environment variable is set to an empty string.
476
- if dir. to_string_lossy ( ) == "" {
477
- anyhow:: bail!( "the target directory is set to an empty string in the `CARGO_TARGET_DIR` environment variable" )
476
+ if dir. is_empty ( ) {
477
+ bail ! (
478
+ "the target directory is set to an empty string in the \
479
+ `CARGO_TARGET_DIR` environment variable"
480
+ )
478
481
}
479
482
480
483
Ok ( Some ( Filesystem :: new ( self . cwd . join ( dir) ) ) )
481
484
} else if let Some ( val) = & self . build_config ( ) ?. target_dir {
482
485
let path = val. resolve_path ( self ) ;
483
486
484
487
// Check if the target directory is set to an empty string in the config.toml file.
485
- if val. raw_value ( ) == "" {
486
- anyhow :: bail! ( format !(
488
+ if val. raw_value ( ) . is_empty ( ) {
489
+ bail ! (
487
490
"the target directory is set to an empty string in {}" ,
488
491
val. value( ) . definition
489
- ) , )
492
+ )
490
493
}
491
494
492
495
Ok ( Some ( Filesystem :: new ( path) ) )
You can’t perform that action at this time.
0 commit comments