Rollup merge of #80859 - jsgf:fix-pretty-remap, r=davidtwco
Fix --pretty=expanded with --remap-path-prefix Per https://github.com/rust-lang/rust/issues/80832, using --pretty=expanded and --remap-path-prefix results in an ICE. This is becasue the session source files table is stored in remapped form, whereas --pretty-expanded looks up unremapped files. This remaps the path prefixes before lookup. ~~There don't appear to be any existing tests for --pretty=expanded; I'll look into adding some.~~ Never mind, found the pretty tests. Fixes #80832
This commit is contained in:
commit
7ce8246a23
4 changed files with 43 additions and 3 deletions
|
@ -872,8 +872,10 @@ impl SourceMap {
|
|||
}
|
||||
|
||||
pub fn get_source_file(&self, filename: &FileName) -> Option<Lrc<SourceFile>> {
|
||||
// Remap filename before lookup
|
||||
let filename = self.path_mapping().map_filename_prefix(filename).0;
|
||||
for sf in self.files.borrow().source_files.iter() {
|
||||
if *filename == sf.name {
|
||||
if filename == sf.name {
|
||||
return Some(sf.clone());
|
||||
}
|
||||
}
|
||||
|
@ -1041,4 +1043,15 @@ impl FilePathMapping {
|
|||
|
||||
(path, false)
|
||||
}
|
||||
|
||||
fn map_filename_prefix(&self, file: &FileName) -> (FileName, bool) {
|
||||
match file {
|
||||
FileName::Real(realfile) => {
|
||||
let path = realfile.local_path();
|
||||
let (path, mapped) = self.map_prefix(path.to_path_buf());
|
||||
(FileName::Real(RealFileName::Named(path)), mapped)
|
||||
}
|
||||
other => (other.clone(), false),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue