From fed4c5d9e13e7cde3399336342a64ba23308d4f5 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 3 Feb 2019 13:31:50 +0100 Subject: [PATCH] disambiguate filenames of multiple drop shims being dumped --- src/librustc_mir/util/pretty.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/librustc_mir/util/pretty.rs b/src/librustc_mir/util/pretty.rs index 120055ad39764..48a6fd3a95df6 100644 --- a/src/librustc_mir/util/pretty.rs +++ b/src/librustc_mir/util/pretty.rs @@ -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,