Skip to content

Commit fed4c5d

Browse files
committed
disambiguate filenames of multiple drop shims being dumped
1 parent 2708946 commit fed4c5d

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/librustc_mir/util/pretty.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,29 @@ fn dump_path(
186186
let item_name = tcx
187187
.def_path(source.def_id())
188188
.to_filename_friendly_no_crate();
189+
// All drop shims have the same DefId, so we have to add the type
190+
// to get unique file names.
191+
let shim_disambiguator = match source.instance {
192+
ty::InstanceDef::DropGlue(_, Some(ty)) => {
193+
// Unfortunately, pretty-printed typed are not very filename-friendly.
194+
// We dome some filtering.
195+
let mut s = ".".to_owned();
196+
s.extend(ty.to_string()
197+
.chars()
198+
.filter_map(|c| match c {
199+
' ' => None,
200+
':' => Some('_'),
201+
c => Some(c)
202+
}));
203+
s
204+
}
205+
_ => String::new(),
206+
};
189207

190208
let file_name = format!(
191-
"rustc.{}{}{}.{}.{}.{}",
209+
"rustc.{}{}{}{}.{}.{}.{}",
192210
item_name,
211+
shim_disambiguator,
193212
promotion_id,
194213
pass_num,
195214
pass_name,

0 commit comments

Comments
 (0)