@@ -13,6 +13,7 @@ use std::path::{Path, PathBuf};
13
13
use std:: process:: Command ;
14
14
use std:: str;
15
15
16
+ use rustfmt_lib:: absolute_path;
16
17
use structopt:: StructOpt ;
17
18
18
19
#[ derive( StructOpt , Debug ) ]
@@ -288,7 +289,7 @@ impl Target {
288
289
nested_int_test_files : Option < Vec < PathBuf > > ,
289
290
) -> Self {
290
291
let path = PathBuf :: from ( & target. src_path ) ;
291
- let canonicalized = fs :: canonicalize ( & path) . unwrap_or ( path) ;
292
+ let canonicalized = absolute_path ( & path) . unwrap_or ( path) ;
292
293
let test_files = nested_int_test_files. unwrap_or_else ( Vec :: new) ;
293
294
294
295
Self {
@@ -388,14 +389,14 @@ fn get_targets_root_only(
388
389
include_nested_test_files : bool ,
389
390
) -> Result < ( ) , io:: Error > {
390
391
let metadata = get_cargo_metadata ( manifest_path, false ) ?;
391
- let workspace_root_path = PathBuf :: from ( & metadata. workspace_root ) . canonicalize ( ) ?;
392
+ let workspace_root_path = absolute_path ( PathBuf :: from ( & metadata. workspace_root ) ) ?;
392
393
let ( in_workspace_root, current_dir_manifest) = if let Some ( target_manifest) = manifest_path {
393
394
(
394
395
workspace_root_path == target_manifest,
395
- target_manifest . canonicalize ( ) ?,
396
+ absolute_path ( target_manifest ) ?,
396
397
)
397
398
} else {
398
- let current_dir = env:: current_dir ( ) ?. canonicalize ( ) ?;
399
+ let current_dir = absolute_path ( env:: current_dir ( ) ?) ?;
399
400
(
400
401
workspace_root_path == current_dir,
401
402
current_dir. join ( "Cargo.toml" ) ,
@@ -413,9 +414,7 @@ fn get_targets_root_only(
413
414
. into_iter ( )
414
415
. filter ( |p| {
415
416
in_workspace_root
416
- || PathBuf :: from ( & p. manifest_path )
417
- . canonicalize ( )
418
- . unwrap_or_default ( )
417
+ || absolute_path ( PathBuf :: from ( & p. manifest_path ) ) . unwrap_or_default ( )
419
418
== current_dir_manifest
420
419
} )
421
420
. map ( |p| p. targets )
@@ -1052,7 +1051,7 @@ mod cargo_fmt_tests {
1052
1051
edition : & str ,
1053
1052
) -> Target {
1054
1053
let path = PathBuf :: from ( src_path) ;
1055
- let canonicalized = fs :: canonicalize ( & path) . unwrap_or ( path) ;
1054
+ let canonicalized = absolute_path ( & path) . unwrap_or ( path) ;
1056
1055
Target {
1057
1056
path : canonicalized,
1058
1057
kind : String :: from ( kind) ,
0 commit comments