summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2017-11-18 14:06:35 +0800
committerJohn Hodge <tpg@mutabah.net>2017-11-18 14:06:35 +0800
commit041a3415865007fde084230d0dd5fcd0c67ce61d (patch)
treedce5f539c85174d405125b71dbbb947339c2938d
parentf8b8db3a31782fcff7a58c6fe8b3849d92619d51 (diff)
downloadmrust-041a3415865007fde084230d0dd5fcd0c67ce61d.tar.gz
HIR From AST - Handle windows paths
-rw-r--r--src/hir/from_ast.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/hir/from_ast.cpp b/src/hir/from_ast.cpp
index ddee6bdb..040d743b 100644
--- a/src/hir/from_ast.cpp
+++ b/src/hir/from_ast.cpp
@@ -1735,7 +1735,9 @@ public:
ERROR(sp, E0000, "Conflicting definitions of lang item '" << name << "'. " << path << " and " << irv.first->second);
}
}
- auto p = ext_crate.second.m_filename.find('/');
+ auto p1 = ext_crate.second.m_filename.rfind('/');
+ auto p2 = ext_crate.second.m_filename.rfind('\\');
+ auto p = (p1 == ::std::string::npos ? p2 : (p2 == ::std::string::npos ? p1 : ::std::max(p1,p2)));
auto crate_file = (p == ::std::string::npos ? ext_crate.second.m_filename : ext_crate.second.m_filename.substr(p+1));
rv.m_ext_crates.insert( ::std::make_pair( ext_crate.first, ::HIR::ExternCrate { mv$(ext_crate.second.m_hir), crate_file, ext_crate.second.m_filename } ) );
}