Skip to content

Commit

Permalink
Auto merge of #1472 - RalfJung:abs, r=RalfJung
Browse files Browse the repository at this point in the history
better way to get an absolute path

suggested by @matklad
  • Loading branch information
bors committed Jul 9, 2020
2 parents b245786 + 2fbc4aa commit eb5ff17
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions cargo-miri/bin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,21 +257,9 @@ fn setup(subcommand: MiriCommand) {

// Determine where the rust sources are located. `XARGO_RUST_SRC` env var trumps everything.
let rust_src = match std::env::var_os("XARGO_RUST_SRC") {
Some(val) => {
let path = PathBuf::from(val);
let path = path.canonicalize().unwrap_or(path);

// On Windows, this produces a path starting with `\\?\`, which xargo cannot deal with.
// Strip that prefix; the resulting path should still be valid.
#[cfg(windows)]
let path = {
let str = path.into_os_string().into_string()
.expect("non-unicode paths are currently not supported");
let str = str.strip_prefix(r"\\?\").map(String::from).unwrap_or(str);
PathBuf::from(str)
};

path
Some(path) => {
// Make path absolute, but not via `canonicalize` (which does not work very well on Windows).
env::current_dir().unwrap().join(path)
}
None => {
// Check for `rust-src` rustup component.
Expand Down

0 comments on commit eb5ff17

Please sign in to comment.