@@ -263,7 +263,7 @@ pub struct ToolchainDirectories {
263263}
264264
265265impl ToolchainDirectories {
266- pub fn assemble ( mount_finder : & MountFinder , mut toolchain : QualifiedToolchain ) -> Result < Self > {
266+ pub fn assemble ( mount_finder : & MountFinder , toolchain : QualifiedToolchain ) -> Result < Self > {
267267 let home_dir =
268268 home:: home_dir ( ) . ok_or_else ( || eyre:: eyre!( "could not find home directory" ) ) ?;
269269 let cargo = home:: cargo_home ( ) ?;
@@ -311,8 +311,6 @@ impl ToolchainDirectories {
311311 let cargo = mount_finder. find_mount_path ( cargo) ;
312312 let xargo = mount_finder. find_mount_path ( xargo) ;
313313
314- toolchain. set_sysroot ( |p| mount_finder. find_mount_path ( p) ) ;
315-
316314 // canonicalize these once to avoid syscalls
317315 let sysroot_mount_path = toolchain. get_sysroot ( ) . as_posix_absolute ( ) ?;
318316
@@ -413,30 +411,29 @@ pub struct PackageDirectories {
413411impl PackageDirectories {
414412 pub fn assemble (
415413 mount_finder : & MountFinder ,
416- mut metadata : CargoMetadata ,
414+ metadata : CargoMetadata ,
417415 cwd : & Path ,
418416 ) -> Result < ( Self , CargoMetadata ) > {
419417 let target = & metadata. target_directory ;
420418 // see ToolchainDirectories::assemble for creating directories
421419 create_target_dir ( target) ?;
422420
423- metadata. target_directory = mount_finder. find_mount_path ( target) ;
424-
425421 // root is either workspace_root, or, if we're outside the workspace root, the current directory
426- let host_root = mount_finder . find_mount_path ( if metadata. workspace_root . starts_with ( cwd) {
422+ let host_root = if metadata. workspace_root . starts_with ( cwd) {
427423 cwd
428424 } else {
429425 & metadata. workspace_root
430- } ) ;
426+ }
427+ . to_path_buf ( ) ;
431428
432429 // on Windows, we can not mount the directory name directly. Instead, we use wslpath to convert the path to a linux compatible path.
433430 // NOTE: on unix, host root has already found the mount path
434431 let mount_root = host_root. as_posix_absolute ( ) ?;
435- let mount_cwd = mount_finder . find_path ( cwd , false ) ?;
432+ let mount_cwd = cwd . as_posix_absolute ( ) ?;
436433
437434 Ok ( (
438435 PackageDirectories {
439- target : metadata . target_directory . clone ( ) ,
436+ target : mount_finder . find_mount_path ( target ) ,
440437 host_root,
441438 mount_root,
442439 mount_cwd,
@@ -1193,10 +1190,7 @@ impl DockerCommandExt for Command {
11931190 if let Ok ( val) = value {
11941191 let canonical_path = file:: canonicalize ( & val) ?;
11951192 let host_path = paths. mount_finder . find_path ( & canonical_path, true ) ?;
1196- let absolute_path = Path :: new ( & val) . as_posix_absolute ( ) ?;
1197- let mount_path = paths
1198- . mount_finder
1199- . find_path ( Path :: new ( & absolute_path) , true ) ?;
1193+ let mount_path = Path :: new ( & val) . as_posix_absolute ( ) ?;
12001194 mount_cb ( self , host_path. as_ref ( ) , mount_path. as_ref ( ) ) ?;
12011195 self . args ( [ "-e" , & format ! ( "{}={}" , var, mount_path) ] ) ;
12021196 store_cb ( ( val, mount_path) ) ;
@@ -1209,10 +1203,7 @@ impl DockerCommandExt for Command {
12091203 // to the mounted project directory.
12101204 let canonical_path = file:: canonicalize ( path) ?;
12111205 let host_path = paths. mount_finder . find_path ( & canonical_path, true ) ?;
1212- let absolute_path = Path :: new ( path) . as_posix_absolute ( ) ?;
1213- let mount_path = paths
1214- . mount_finder
1215- . find_path ( Path :: new ( & absolute_path) , true ) ?;
1206+ let mount_path = path. as_posix_absolute ( ) ?;
12161207 mount_cb ( self , host_path. as_ref ( ) , mount_path. as_ref ( ) ) ?;
12171208 store_cb ( ( path. to_utf8 ( ) ?. to_owned ( ) , mount_path) ) ;
12181209 }
@@ -1716,15 +1707,9 @@ mod tests {
17161707
17171708 paths_equal ( toolchain_dirs. cargo ( ) , & mount_path ( home ( ) ?. join ( ".cargo" ) ) ) ?;
17181709 paths_equal ( toolchain_dirs. xargo ( ) , & mount_path ( home ( ) ?. join ( ".xargo" ) ) ) ?;
1719- paths_equal ( package_dirs. host_root ( ) , & mount_path ( get_cwd ( ) ?) ) ?;
1720- assert_eq ! (
1721- package_dirs. mount_root( ) ,
1722- & mount_path( get_cwd( ) ?) . as_posix_absolute( ) ?
1723- ) ;
1724- assert_eq ! (
1725- package_dirs. mount_cwd( ) ,
1726- & mount_path( get_cwd( ) ?) . as_posix_absolute( ) ?
1727- ) ;
1710+ paths_equal ( package_dirs. host_root ( ) , & get_cwd ( ) ?) ?;
1711+ assert_eq ! ( package_dirs. mount_root( ) , & get_cwd( ) ?. as_posix_absolute( ) ?) ;
1712+ assert_eq ! ( package_dirs. mount_cwd( ) , & get_cwd( ) ?. as_posix_absolute( ) ?) ;
17281713
17291714 reset_env ( vars) ;
17301715 Ok ( ( ) )
0 commit comments