diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index 222dc56a2b1..b661fa185b8 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -85,6 +85,8 @@ pub(crate) fn new(tcx: TyCtxt<'_>, isa: &dyn TargetIsa, cgu_name: &str) -> Self let mut dwarf = DwarfUnit::new(encoding); use rustc_session::config::RemapPathScopeComponents; + use rustc_session::RemapFileNameExt; + let should_remap_filepaths = tcx.sess.should_prefer_remapped(RemapPathScopeComponents::DEBUGINFO); @@ -93,22 +95,16 @@ pub(crate) fn new(tcx: TyCtxt<'_>, isa: &dyn TargetIsa, cgu_name: &str) -> Self .sess .opts .working_dir - .to_string_lossy(if should_remap_filepaths { - FileNameDisplayPreference::Remapped - } else { - FileNameDisplayPreference::Local - }) - .into_owned(); + .for_scope(tcx.sess, RemapPathScopeComponents::DEBUGINFO) + .to_string_lossy() + .to_string(); let (name, file_info) = match tcx.sess.local_crate_source_file() { Some(path) => { let name = path - .to_string_lossy(if should_remap_filepaths { - FileNameDisplayPreference::Remapped - } else { - FileNameDisplayPreference::Local - }) - .into_owned(); + .for_scope(tcx.sess, RemapPathScopeComponents::DEBUGINFO) + .to_string_lossy() + .to_string(); (name, None) } None => (tcx.crate_name(LOCAL_CRATE).to_string(), None),