From bd6c81aebbda2cc1dfcfa83047db81b358b01a92 Mon Sep 17 00:00:00 2001 From: Evgenii Pashkin Date: Fri, 1 Jun 2018 19:56:33 +0300 Subject: Fix processing mod with multi-level path on Windows --- src/libsyntax/parse/parser.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/libsyntax/parse') diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 28f93328e95..91bf1f6a953 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -6149,7 +6149,14 @@ impl<'a> Parser<'a> { } pub fn submod_path_from_attr(attrs: &[Attribute], dir_path: &Path) -> Option { - 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(); + #[cfg(windows)] + let s = s.replace("/", "\\"); + Some(dir_path.join(s)) + } else { + None + } } /// Returns either a path to a module, or . -- cgit 1.4.1-3-g733a5 From b417701ac118d4864e3bd07b700f3c8af724b199 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Wed, 6 Jun 2018 16:20:47 -0400 Subject: add an explanatory comment --- src/libsyntax/parse/parser.rs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/libsyntax/parse') diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 91bf1f6a953..f6692a30491 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -6151,6 +6151,11 @@ impl<'a> Parser<'a> { pub fn submod_path_from_attr(attrs: &[Attribute], dir_path: &Path) -> Option { 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)) -- cgit 1.4.1-3-g733a5