Don't use remapped path when loading modules and include files
This commit is contained in:
@@ -162,9 +162,16 @@ impl CodeMap {
|
||||
let start_pos = self.next_start_pos();
|
||||
let mut files = self.files.borrow_mut();
|
||||
|
||||
// The path is used to determine the directory for loading submodules and
|
||||
// include files, so it must be before remapping.
|
||||
// Note that filename may not be a valid path, eg it may be `<anon>` etc,
|
||||
// but this is okay because the directory determined by `path.pop()` will
|
||||
// be empty, so the working directory will be used.
|
||||
let path = PathBuf::from(filename.clone());
|
||||
|
||||
let (filename, was_remapped) = self.path_mapping.map_prefix(filename);
|
||||
let filemap =
|
||||
Rc::new(FileMap::new(filename, was_remapped, src, Pos::from_usize(start_pos)));
|
||||
Rc::new(FileMap::new(filename, was_remapped, path, src, Pos::from_usize(start_pos)));
|
||||
|
||||
files.push(filemap.clone());
|
||||
|
||||
@@ -216,6 +223,7 @@ impl CodeMap {
|
||||
let filemap = Rc::new(FileMap {
|
||||
name: filename,
|
||||
name_was_remapped,
|
||||
path: PathBuf::new(),
|
||||
crate_of_origin,
|
||||
src: None,
|
||||
src_hash,
|
||||
@@ -342,7 +350,11 @@ impl CodeMap {
|
||||
}
|
||||
|
||||
pub fn span_to_filename(&self, sp: Span) -> FileName {
|
||||
self.lookup_char_pos(sp.lo()).file.name.to_string()
|
||||
self.lookup_char_pos(sp.lo()).file.name.clone()
|
||||
}
|
||||
|
||||
pub fn span_to_path(&self, sp: Span) -> PathBuf {
|
||||
self.lookup_char_pos(sp.lo()).file.path.clone()
|
||||
}
|
||||
|
||||
pub fn span_to_lines(&self, sp: Span) -> FileLinesResult {
|
||||
|
||||
Reference in New Issue
Block a user