@@ -13,6 +13,7 @@ use std::path::{Path, PathBuf};
1313use std:: process:: Command ;
1414use std:: str;
1515
16+ use rustfmt_lib:: absolute_path;
1617use structopt:: StructOpt ;
1718
1819#[ derive( StructOpt , Debug ) ]
@@ -288,7 +289,7 @@ impl Target {
288289 nested_int_test_files : Option < Vec < PathBuf > > ,
289290 ) -> Self {
290291 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) ;
292293 let test_files = nested_int_test_files. unwrap_or_else ( Vec :: new) ;
293294
294295 Self {
@@ -388,14 +389,14 @@ fn get_targets_root_only(
388389 include_nested_test_files : bool ,
389390) -> Result < ( ) , io:: Error > {
390391 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 ) ) ?;
392393 let ( in_workspace_root, current_dir_manifest) = if let Some ( target_manifest) = manifest_path {
393394 (
394395 workspace_root_path == target_manifest,
395- target_manifest . canonicalize ( ) ?,
396+ absolute_path ( target_manifest ) ?,
396397 )
397398 } else {
398- let current_dir = env:: current_dir ( ) ?. canonicalize ( ) ?;
399+ let current_dir = absolute_path ( env:: current_dir ( ) ?) ?;
399400 (
400401 workspace_root_path == current_dir,
401402 current_dir. join ( "Cargo.toml" ) ,
@@ -413,9 +414,7 @@ fn get_targets_root_only(
413414 . into_iter ( )
414415 . filter ( |p| {
415416 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 ( )
419418 == current_dir_manifest
420419 } )
421420 . map ( |p| p. targets )
@@ -1052,7 +1051,7 @@ mod cargo_fmt_tests {
10521051 edition : & str ,
10531052 ) -> Target {
10541053 let path = PathBuf :: from ( src_path) ;
1055- let canonicalized = fs :: canonicalize ( & path) . unwrap_or ( path) ;
1054+ let canonicalized = absolute_path ( & path) . unwrap_or ( path) ;
10561055 Target {
10571056 path : canonicalized,
10581057 kind : String :: from ( kind) ,
0 commit comments