Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ICE when printing closures, and other similar types #37491

Merged
merged 1 commit into from
Nov 2, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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