Auto merge of #37491 - Mark-Simulacrum:closure-ice, r=eddyb

Fix ICE when printing closures, and other similar types

Follow-up of https://github.com/rust-lang/rust/pull/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
This commit is contained in:
bors 2016-11-01 12:20:03 -07:00 committed by GitHub
commit 7c69b0d5ae

View file

@ -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
@ -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);