Make local_crate_source_file return a RealFileName

so it can be remapped (or not) by callers
This commit is contained in:
Urgau 2024-03-19 13:51:22 +01:00
parent 5de668acb0
commit d6a817a7d9

View File

@ -99,9 +99,16 @@ pub(crate) fn new(tcx: TyCtxt<'_>, isa: &dyn TargetIsa, cgu_name: &str) -> Self
FileNameDisplayPreference::Local
})
.into_owned();
let (name, file_info) = match tcx.sess.local_crate_source_file() {
Some(path) => {
let name = path.to_string_lossy().into_owned();
let name = path
.to_string_lossy(if should_remap_filepaths {
FileNameDisplayPreference::Remapped
} else {
FileNameDisplayPreference::Local
})
.into_owned();
(name, None)
}
None => (tcx.crate_name(LOCAL_CRATE).to_string(), None),