Skip to content

Commit 7c69b0d

Browse files
authored
Auto merge of #37491 - Mark-Simulacrum:closure-ice, r=eddyb
Fix ICE when printing closures, and other similar types Follow-up of #37459, further fixes those problems. Potentially actually fixes #36622, though @eddyb may want to not let that close if the rename of RUST_LOG is deemed part of that issue. Potentially should be beta-nominated as well? r? @eddyb
2 parents ea4b94d + 0dfc046 commit 7c69b0d

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/librustc/util/ppaux.rs

+14-3
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,25 @@ fn fn_sig(f: &mut fmt::Formatter,
5959

6060
pub fn parameterized(f: &mut fmt::Formatter,
6161
substs: &subst::Substs,
62-
did: DefId,
62+
mut did: DefId,
6363
projections: &[ty::ProjectionPredicate])
6464
-> fmt::Result {
65+
let key = ty::tls::with(|tcx| tcx.def_key(did));
66+
let mut item_name = if let Some(name) = key.disambiguated_data.data.get_opt_name() {
67+
Some(name)
68+
} else {
69+
did.index = key.parent.unwrap_or_else(
70+
|| bug!("finding type for {:?}, encountered def-id {:?} with no parent",
71+
did, did));
72+
parameterized(f, substs, did, projections)?;
73+
return write!(f, "::{}", key.disambiguated_data.data.as_interned_str());
74+
};
75+
6576
let mut verbose = false;
6677
let mut num_supplied_defaults = 0;
6778
let mut has_self = false;
6879
let mut num_regions = 0;
6980
let mut num_types = 0;
70-
let mut item_name = None;
7181
let mut is_value_path = false;
7282
let fn_trait_kind = ty::tls::with(|tcx| {
7383
// Unfortunately, some kinds of items (e.g., closures) don't have
@@ -113,9 +123,10 @@ pub fn parameterized(f: &mut fmt::Formatter,
113123
write!(f, "<{} as ", substs.type_at(0))?;
114124
}
115125

116-
item_name = Some(tcx.item_name(did));
117126
path_def_id = def_id;
118127
} else {
128+
item_name = None;
129+
119130
if is_value_path {
120131
// Functions.
121132
assert_eq!(has_self, false);

0 commit comments

Comments
 (0)