diff options
| author | bors <bors@rust-lang.org> | 2018-06-19 02:17:52 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-06-19 02:17:52 +0000 |
| commit | ed39523406fea9d4c82f87f4ac9ad92388084123 (patch) | |
| tree | eb5cf65827108b80b8ea440696b778e151c950b2 /src/libsyntax/parse | |
| parent | fc19590297d211bb395a16b8ecdc82bab5c00bd3 (diff) | |
| parent | cb5e9731bb17eb7ecd81c72b09b036e5420d3ea7 (diff) | |
| download | rust-ed39523406fea9d4c82f87f4ac9ad92388084123.tar.gz rust-ed39523406fea9d4c82f87f4ac9ad92388084123.zip | |
Auto merge of #51278 - EPashkin:fix_mod_with_multilevel_paths_on_windows, r=nikomatsakis
Fix processing mod with multi-level path on Windows Fix error in [rustfmt](https://github.com/rust-lang-nursery/rustfmt/issues/1754) because libsyntax can not handle `mod` with multilevel path on Windows. Alternative is do almost same in https://github.com/rust-lang/rust/blob/master/src/libstd/sys/windows/fs.rs#L717 to allow work on paths with different separators, Ex. "\\\\?\\c:\\windows/temp"
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 530094e22f2..1735951da2f 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -6128,7 +6128,19 @@ impl<'a> Parser<'a> { } pub fn submod_path_from_attr(attrs: &[Attribute], dir_path: &Path) -> Option<PathBuf> { - attr::first_attr_value_str_by_name(attrs, "path").map(|d| dir_path.join(&d.as_str())) + if let Some(s) = attr::first_attr_value_str_by_name(attrs, "path") { + let s = s.as_str(); + + // On windows, the base path might have the form + // `\\?\foo\bar` in which case it does not tolerate + // mixed `/` and `\` separators, so canonicalize + // `/` to `\`. + #[cfg(windows)] + let s = s.replace("/", "\\"); + Some(dir_path.join(s)) + } else { + None + } } /// Returns either a path to a module, or . |
