]> git.lizzy.rs Git - rust.git/commitdiff
fix path check
authorJay Lee <busyjaylee@gmail.com>
Sun, 9 Apr 2017 21:25:12 +0000 (05:25 +0800)
committerJay Lee <busyjaylee@gmail.com>
Sun, 9 Apr 2017 21:25:12 +0000 (05:25 +0800)
src/bin/rustfmt.rs

index 400ee90702112a5212dfbd5344fc8cf4886cdcef..227ab849b3c4eccd038506e7a695aa06c8ce98cd 100644 (file)
@@ -367,7 +367,16 @@ fn determine_operation(matches: &Matches) -> FmtResult<Operation> {
                   });
     }
 
-    let files: Vec<_> = matches.free.iter().map(PathBuf::from).collect();
+    let files: Vec<_> = matches
+        .free
+        .iter()
+        .map(|s| {
+                 let p = PathBuf::from(s);
+                 // we will do comparison later, so here tries to canonicalize first
+                 // to get the expected behavior.
+                 p.canonicalize().unwrap_or(p)
+             })
+        .collect();
 
     Ok(Operation::Format {
            files: files,