Skip to content

Commit

Permalink
Replace Session should_remap_filepaths with filename_display_preference
Browse files Browse the repository at this point in the history
  • Loading branch information
Urgau committed Mar 28, 2024
1 parent 6a2b2b4 commit 4d7ded6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 29 deletions.
15 changes: 2 additions & 13 deletions src/debuginfo/line_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,7 @@ impl DebugContext {
match &source_file.name {
FileName::Real(path) => {
let (dir_path, file_name) =
split_path_dir_and_file(if self.should_remap_filepaths {
path.remapped_path_if_available()
} else {
path.local_path_if_available()
});
split_path_dir_and_file(path.to_path(self.filename_display_preference));
let dir_name = osstr_as_utf8_bytes(dir_path.as_os_str());
let file_name = osstr_as_utf8_bytes(file_name);

Expand All @@ -115,14 +111,7 @@ impl DebugContext {
filename => {
let dir_id = line_program.default_directory();
let dummy_file_name = LineString::new(
filename
.display(if self.should_remap_filepaths {
FileNameDisplayPreference::Remapped
} else {
FileNameDisplayPreference::Local
})
.to_string()
.into_bytes(),
filename.display(self.filename_display_preference).to_string().into_bytes(),
line_program.encoding(),
line_strings,
);
Expand Down
23 changes: 7 additions & 16 deletions src/debuginfo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub(crate) struct DebugContext {
namespace_map: DefIdMap<UnitEntryId>,
array_size_type: UnitEntryId,

should_remap_filepaths: bool,
filename_display_preference: FileNameDisplayPreference,
}

pub(crate) struct FunctionDebugContext {
Expand Down Expand Up @@ -85,26 +85,17 @@ impl DebugContext {
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);
let filename_display_preference =
tcx.sess.filename_display_preference(RemapPathScopeComponents::DEBUGINFO);

let producer = producer(tcx.sess);
let comp_dir = tcx
.sess
.opts
.working_dir
.for_scope(tcx.sess, RemapPathScopeComponents::DEBUGINFO)
.to_string_lossy()
.to_string();
let comp_dir =
tcx.sess.opts.working_dir.to_string_lossy(filename_display_preference).to_string();

let (name, file_info) = match tcx.sess.local_crate_source_file() {
Some(path) => {
let name = path
.for_scope(tcx.sess, RemapPathScopeComponents::DEBUGINFO)
.to_string_lossy()
.to_string();
let name = path.to_string_lossy(filename_display_preference).to_string();
(name, None)
}
None => (tcx.crate_name(LOCAL_CRATE).to_string(), None),
Expand Down Expand Up @@ -161,7 +152,7 @@ impl DebugContext {
stack_pointer_register,
namespace_map: DefIdMap::default(),
array_size_type,
should_remap_filepaths,
filename_display_preference,
}
}

Expand Down

0 comments on commit 4d7ded6

Please sign in to comment.