Skip to content

Commit b2f6349

Browse files
committed
Auto merge of rust-lang#122450 - Urgau:simplify-trim-paths-feature, r=michaelwoerister
Simplify trim-paths feature by merging all debuginfo options together This PR simplifies the trim-paths feature by merging all debuginfo options together, as described in rust-lang#111540 (comment). And also do some correctness fixes found during the review. cc `@weihanglo` r? `@michaelwoerister`
2 parents e8c1308 + 4d7ded6 commit b2f6349

File tree

2 files changed

+12
-27
lines changed

2 files changed

+12
-27
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

+10-14
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 {
@@ -84,22 +84,18 @@ impl DebugContext {
8484

8585
let mut dwarf = DwarfUnit::new(encoding);
8686

87-
let should_remap_filepaths = tcx.sess.should_prefer_remapped_for_codegen();
87+
use rustc_session::config::RemapPathScopeComponents;
88+
89+
let filename_display_preference =
90+
tcx.sess.filename_display_preference(RemapPathScopeComponents::DEBUGINFO);
8891

8992
let producer = producer(tcx.sess);
90-
let comp_dir = tcx
91-
.sess
92-
.opts
93-
.working_dir
94-
.to_string_lossy(if should_remap_filepaths {
95-
FileNameDisplayPreference::Remapped
96-
} else {
97-
FileNameDisplayPreference::Local
98-
})
99-
.into_owned();
93+
let comp_dir =
94+
tcx.sess.opts.working_dir.to_string_lossy(filename_display_preference).to_string();
95+
10096
let (name, file_info) = match tcx.sess.local_crate_source_file() {
10197
Some(path) => {
102-
let name = path.to_string_lossy().into_owned();
98+
let name = path.to_string_lossy(filename_display_preference).to_string();
10399
(name, None)
104100
}
105101
None => (tcx.crate_name(LOCAL_CRATE).to_string(), None),
@@ -156,7 +152,7 @@ impl DebugContext {
156152
stack_pointer_register,
157153
namespace_map: DefIdMap::default(),
158154
array_size_type,
159-
should_remap_filepaths,
155+
filename_display_preference,
160156
}
161157
}
162158

0 commit comments

Comments
 (0)