Skip to content

Commit 60be925

Browse files
committed
Don't return whether the filename was remapped
It was never used, and it's ambiguous what the answer should be for paths that were remapped in a previous session.
1 parent d3fdf1d commit 60be925

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

compiler/rustc_metadata/src/rmeta/decoder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1730,7 +1730,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
17301730
// Apply the remapping for the current session.
17311731
// NOTE: this does not "undo and redo" the mapping - any existing remapping from the old
17321732
// crate is retained unmodified. Only files which were never remapped are considered.
1733-
name = sess.source_map().path_mapping().map_filename_prefix(&name).0;
1733+
name = sess.source_map().path_mapping().map_filename_prefix(&name);
17341734

17351735
let local_version = sess.source_map().new_imported_source_file(
17361736
name,

compiler/rustc_span/src/source_map.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ impl SourceMap {
320320
// Note that filename may not be a valid path, eg it may be `<anon>` etc,
321321
// but this is okay because the directory determined by `path.pop()` will
322322
// be empty, so the working directory will be used.
323-
let (filename, _) = self.path_mapping.map_filename_prefix(&filename);
323+
let filename = self.path_mapping.map_filename_prefix(&filename);
324324

325325
let file_id = StableSourceFileId::new_from_name(&filename, LOCAL_CRATE);
326326
match self.source_file_by_stable_id(file_id) {
@@ -995,7 +995,7 @@ impl SourceMap {
995995

996996
pub fn get_source_file(&self, filename: &FileName) -> Option<Lrc<SourceFile>> {
997997
// Remap filename before lookup
998-
let filename = self.path_mapping().map_filename_prefix(filename).0;
998+
let filename = self.path_mapping().map_filename_prefix(filename);
999999
for sf in self.files.borrow().source_files.iter() {
10001000
if filename == sf.name {
10011001
return Some(sf.clone());
@@ -1150,7 +1150,7 @@ impl FilePathMapping {
11501150
/// Given a `file`, map it using the `remap-path-prefix` options for the current [`Session`].
11511151
///
11521152
/// Public for use in rustc_metadata::decoder
1153-
pub fn map_filename_prefix(&self, file: &FileName) -> (FileName, bool) {
1153+
pub fn map_filename_prefix(&self, file: &FileName) -> FileName {
11541154
match file {
11551155
FileName::Real(realfile @ RealFileName::LocalPath(local_path)) => {
11561156
let (mapped_path, mapped) = self.map_prefix(local_path);
@@ -1162,16 +1162,16 @@ impl FilePathMapping {
11621162
} else {
11631163
realfile.clone()
11641164
};
1165-
(FileName::Real(realfile), mapped)
1165+
FileName::Real(realfile)
11661166
}
11671167
existing @ FileName::Real(RealFileName::Remapped { .. }) => {
11681168
// This can happen if we are remapping the name of file that was loaded in a
11691169
// different Session, and inconsistent `remap-path-prefix` flags were passed between
11701170
// sessions. It's unclear what to do here. For now, respect the original flag, not
11711171
// the flag from the current session.
1172-
(existing.clone(), false)
1172+
existing.clone()
11731173
}
1174-
other => (other.clone(), false),
1174+
other => other.clone(),
11751175
}
11761176
}
11771177

0 commit comments

Comments
 (0)