Skip to content

Commit 5bdf81d

Browse files
committed
expand: Determine module directory path directly instead of relying on span
1 parent 39052c5 commit 5bdf81d

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

compiler/rustc_expand/src/module.rs

+3-8
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use rustc_errors::{struct_span_err, PResult};
44
use rustc_parse::new_parser_from_file;
55
use rustc_session::parse::ParseSess;
66
use rustc_session::Session;
7-
use rustc_span::source_map::{FileName, Span};
87
use rustc_span::symbol::{sym, Ident};
8+
use rustc_span::Span;
99

1010
use std::path::{self, Path, PathBuf};
1111

@@ -64,13 +64,8 @@ crate fn parse_external_mod(
6464
// (1) ...instead, we return a dummy module.
6565
let (items, inner_span, file_path) = result.map_err(|mut err| err.emit()).unwrap_or_default();
6666

67-
// Extract the directory path for submodules of the module.
68-
let path = sess.source_map().span_to_unmapped_path(inner_span);
69-
let mut path = match path {
70-
FileName::Real(name) => name.into_local_path(),
71-
other => PathBuf::from(other.to_string()),
72-
};
73-
path.pop();
67+
// Extract the directory path for submodules of the module.
68+
let path = file_path.parent().unwrap_or(&file_path).to_owned();
7469

7570
(items, inner_span, file_path, Directory { ownership, path })
7671
}

0 commit comments

Comments
 (0)