Skip to content

Commit 4d7ded6

Browse files
committed
Replace Session should_remap_filepaths with filename_display_preference
1 parent 6a2b2b4 commit 4d7ded6

File tree

2 files changed

+9
-29
lines changed

2 files changed

+9
-29
lines changed

src/debuginfo/line_info.rs

+2-13
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,7 @@ impl DebugContext {
8989
match &source_file.name {
9090
FileName::Real(path) => {
9191
let (dir_path, file_name) =
92-
split_path_dir_and_file(if self.should_remap_filepaths {
93-
path.remapped_path_if_available()
94-
} else {
95-
path.local_path_if_available()
96-
});
92+
split_path_dir_and_file(path.to_path(self.filename_display_preference));
9793
let dir_name = osstr_as_utf8_bytes(dir_path.as_os_str());
9894
let file_name = osstr_as_utf8_bytes(file_name);
9995

@@ -115,14 +111,7 @@ impl DebugContext {
115111
filename => {
116112
let dir_id = line_program.default_directory();
117113
let dummy_file_name = LineString::new(
118-
filename
119-
.display(if self.should_remap_filepaths {
120-
FileNameDisplayPreference::Remapped
121-
} else {
122-
FileNameDisplayPreference::Local
123-
})
124-
.to_string()
125-
.into_bytes(),
114+
filename.display(self.filename_display_preference).to_string().into_bytes(),
126115
line_program.encoding(),
127116
line_strings,
128117
);

src/debuginfo/mod.rs

+7-16
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub(crate) struct DebugContext {
4242
namespace_map: DefIdMap<UnitEntryId>,
4343
array_size_type: UnitEntryId,
4444

45-
should_remap_filepaths: bool,
45+
filename_display_preference: FileNameDisplayPreference,
4646
}
4747

4848
pub(crate) struct FunctionDebugContext {
@@ -85,26 +85,17 @@ impl DebugContext {
8585
let mut dwarf = DwarfUnit::new(encoding);
8686

8787
use rustc_session::config::RemapPathScopeComponents;
88-
use rustc_session::RemapFileNameExt;
8988

90-
let should_remap_filepaths =
91-
tcx.sess.should_prefer_remapped(RemapPathScopeComponents::DEBUGINFO);
89+
let filename_display_preference =
90+
tcx.sess.filename_display_preference(RemapPathScopeComponents::DEBUGINFO);
9291

9392
let producer = producer(tcx.sess);
94-
let comp_dir = tcx
95-
.sess
96-
.opts
97-
.working_dir
98-
.for_scope(tcx.sess, RemapPathScopeComponents::DEBUGINFO)
99-
.to_string_lossy()
100-
.to_string();
93+
let comp_dir =
94+
tcx.sess.opts.working_dir.to_string_lossy(filename_display_preference).to_string();
10195

10296
let (name, file_info) = match tcx.sess.local_crate_source_file() {
10397
Some(path) => {
104-
let name = path
105-
.for_scope(tcx.sess, RemapPathScopeComponents::DEBUGINFO)
106-
.to_string_lossy()
107-
.to_string();
98+
let name = path.to_string_lossy(filename_display_preference).to_string();
10899
(name, None)
109100
}
110101
None => (tcx.crate_name(LOCAL_CRATE).to_string(), None),
@@ -161,7 +152,7 @@ impl DebugContext {
161152
stack_pointer_register,
162153
namespace_map: DefIdMap::default(),
163154
array_size_type,
164-
should_remap_filepaths,
155+
filename_display_preference,
165156
}
166157
}
167158

0 commit comments

Comments
 (0)