about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2021-02-22 18:42:57 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2021-03-05 01:33:43 +0300
commit5bdf81d5fa7ada2274617ebfa97e6bd157ae5a52 (patch)
tree907941d976e6ef4c17e97684f1f0c85763d885ce
parent39052c55bb0259930dd9e6b0fc27a715793b07c8 (diff)
downloadrust-5bdf81d5fa7ada2274617ebfa97e6bd157ae5a52.tar.gz
rust-5bdf81d5fa7ada2274617ebfa97e6bd157ae5a52.zip
expand: Determine module directory path directly instead of relying on span
-rw-r--r--compiler/rustc_expand/src/module.rs11
1 files changed, 3 insertions, 8 deletions
diff --git a/compiler/rustc_expand/src/module.rs b/compiler/rustc_expand/src/module.rs
index 55b48e4f6b2..e744ab27e8f 100644
--- a/compiler/rustc_expand/src/module.rs
+++ b/compiler/rustc_expand/src/module.rs
@@ -4,8 +4,8 @@ use rustc_errors::{struct_span_err, PResult};
 use rustc_parse::new_parser_from_file;
 use rustc_session::parse::ParseSess;
 use rustc_session::Session;
-use rustc_span::source_map::{FileName, Span};
 use rustc_span::symbol::{sym, Ident};
+use rustc_span::Span;
 
 use std::path::{self, Path, PathBuf};
 
@@ -64,13 +64,8 @@ crate fn parse_external_mod(
     // (1) ...instead, we return a dummy module.
     let (items, inner_span, file_path) = result.map_err(|mut err| err.emit()).unwrap_or_default();
 
-    // Extract the directory path for submodules of  the module.
-    let path = sess.source_map().span_to_unmapped_path(inner_span);
-    let mut path = match path {
-        FileName::Real(name) => name.into_local_path(),
-        other => PathBuf::from(other.to_string()),
-    };
-    path.pop();
+    // Extract the directory path for submodules of the module.
+    let path = file_path.parent().unwrap_or(&file_path).to_owned();
 
     (items, inner_span, file_path, Directory { ownership, path })
 }