Skip to content

Commit

Permalink
Merge pull request #67 from dtolnay/windows
Browse files Browse the repository at this point in the history
Normalize Windows path separator
  • Loading branch information
dtolnay authored Apr 26, 2020
2 parents 0559927 + 811f568 commit de337f1
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/normalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ pub fn diagnostics(output: Vec<u8>, context: Context) -> Variations {
StripCouldNotCompile2,
StripForMoreInformation,
StripForMoreInformation2,
DirBackslash,
]
.iter()
.map(|normalization| apply(&from_bytes, *normalization, context))
Expand Down Expand Up @@ -71,6 +72,7 @@ enum Normalization {
StripCouldNotCompile2,
StripForMoreInformation,
StripForMoreInformation2,
DirBackslash,
}

use self::Normalization::*;
Expand Down Expand Up @@ -138,7 +140,15 @@ fn filter(line: &str, normalization: Normalization, context: Context) -> Option<
}
}

let line = line
let mut line = line.to_owned();

if normalization >= DirBackslash {
// https://github.com/dtolnay/trybuild/issues/66
let source_dir_with_backslash = context.source_dir.to_string_lossy().into_owned() + "\\";
line = line.replace(&source_dir_with_backslash, "$DIR/");
}

line = line
.replace(context.krate, "$CRATE")
.replace(context.source_dir.to_string_lossy().as_ref(), "$DIR")
.replace(context.workspace.to_string_lossy().as_ref(), "$WORKSPACE");
Expand Down

0 comments on commit de337f1

Please sign in to comment.