Skip to content

Commit

Permalink
Auto merge of #37491 - Mark-Simulacrum:closure-ice, r=eddyb
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors authored Nov 1, 2016
2 parents ea4b94d + 0dfc046 commit 7c69b0d
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/librustc/util/ppaux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,25 @@ fn fn_sig(f: &mut fmt::Formatter,

pub fn parameterized(f: &mut fmt::Formatter,
substs: &subst::Substs,
did: DefId,
mut did: DefId,
projections: &[ty::ProjectionPredicate])
-> fmt::Result {
let key = ty::tls::with(|tcx| tcx.def_key(did));
let mut item_name = if let Some(name) = key.disambiguated_data.data.get_opt_name() {
Some(name)
} else {
did.index = key.parent.unwrap_or_else(
|| bug!("finding type for {:?}, encountered def-id {:?} with no parent",
did, did));
parameterized(f, substs, did, projections)?;
return write!(f, "::{}", key.disambiguated_data.data.as_interned_str());
};

let mut verbose = false;
let mut num_supplied_defaults = 0;
let mut has_self = false;
let mut num_regions = 0;
let mut num_types = 0;
let mut item_name = None;
let mut is_value_path = false;
let fn_trait_kind = ty::tls::with(|tcx| {
// Unfortunately, some kinds of items (e.g., closures) don't have
Expand Down Expand Up @@ -113,9 +123,10 @@ pub fn parameterized(f: &mut fmt::Formatter,
write!(f, "<{} as ", substs.type_at(0))?;
}

item_name = Some(tcx.item_name(did));
path_def_id = def_id;
} else {
item_name = None;

if is_value_path {
// Functions.
assert_eq!(has_self, false);
Expand Down

0 comments on commit 7c69b0d

Please sign in to comment.