Skip to content

Commit

Permalink
disambiguate filenames of multiple drop shims being dumped
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Feb 9, 2019
1 parent 2708946 commit fed4c5d
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/librustc_mir/util/pretty.rs
Expand Up @@ -186,10 +186,29 @@ fn dump_path(
let item_name = tcx
.def_path(source.def_id())
.to_filename_friendly_no_crate();
// All drop shims have the same DefId, so we have to add the type
// to get unique file names.
let shim_disambiguator = match source.instance {
ty::InstanceDef::DropGlue(_, Some(ty)) => {
// Unfortunately, pretty-printed typed are not very filename-friendly.
// We dome some filtering.
let mut s = ".".to_owned();
s.extend(ty.to_string()
.chars()
.filter_map(|c| match c {
' ' => None,
':' => Some('_'),
c => Some(c)
}));
s
}
_ => String::new(),
};

let file_name = format!(
"rustc.{}{}{}.{}.{}.{}",
"rustc.{}{}{}{}.{}.{}.{}",
item_name,
shim_disambiguator,
promotion_id,
pass_num,
pass_name,
Expand Down

0 comments on commit fed4c5d

Please sign in to comment.