From 67978d56c11006a10d286153226f18e18367aa32 Mon Sep 17 00:00:00 2001 From: Jeremy Fitzhardinge Date: Sat, 9 Jan 2021 16:04:48 -0800 Subject: 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. --- compiler/rustc_span/src/source_map.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'compiler/rustc_span/src') diff --git a/compiler/rustc_span/src/source_map.rs b/compiler/rustc_span/src/source_map.rs index fefc0cb48dd..c864e0b4637 100644 --- a/compiler/rustc_span/src/source_map.rs +++ b/compiler/rustc_span/src/source_map.rs @@ -870,8 +870,10 @@ impl SourceMap { } pub fn get_source_file(&self, filename: &FileName) -> Option> { + // 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()); } } @@ -1039,4 +1041,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), + } + } } -- cgit 1.4.1-3-g733a5