Improved fix for the issue #1942
authormseri <mseri@users.noreply.github.com>
Fri, 28 Aug 2015 09:28:17 +0000 (10:28 +0100)
committermseri <mseri@users.noreply.github.com>
Fri, 28 Aug 2015 09:28:17 +0000 (10:28 +0100)
src/cargo/ops/cargo_run.rs

index 6b9d285d7b5df045eebaad7abaebea75d30edc9e..419a7ab155a79ff9fd58a6ccde8c9cac091669e8 100644 (file)
@@ -48,10 +48,10 @@ pub fn run(manifest_path: &Path,
     let compile = try!(ops::compile(manifest_path, options));
     let exe = &compile.binaries[0];
     let exe = match util::without_prefix(&exe, config.cwd()) {
-        Some(path) => if path.as_os_str() == path.file_name().unwrap() { &**exe } 
-                      else { path }, // workaround for being able to use
-                                     // `cargo run` from the executable path itself
-        None => &**exe,
+        Some(path) if path.file_name() == Some(path.as_os_str())
+                   => Path::new(".").join(path).to_path_buf(),
+        Some(path) => path.to_path_buf(),
+        None => exe.to_path_buf(),
     };
     let mut process = try!(compile.target_process(exe, &root))
                                   .into_process_builder();