Skip to content

Commit

Permalink
Add a check for uninferred type parameter
Browse files Browse the repository at this point in the history
This fixes rust-lang#19978. The bug was introduced by 570325d, where if the type
of an Fn has not been inferred (strs[0] is "_") we slice from 1 to
0. We now explicitly check if `strs[0]` is a single element tuple.
  • Loading branch information
Munksgaard committed Dec 19, 2014
1 parent c0b2885 commit 3bb91aa
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/librustc/util/ppaux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,11 @@ pub fn parameterized<'tcx>(cx: &ctxt<'tcx>,
if cx.lang_items.fn_trait_kind(did).is_some() {
format!("{}({}){}",
base,
strs[0][1 .. strs[0].len() - (strs[0].ends_with(",)") as uint+1)],
if strs[0].starts_with("(") && strs[0].ends_with(",)") {
strs[0][1 .. strs[0].len() - 2] // Remove '(' and ',)'
} else {
strs[0][]
},
if &*strs[1] == "()" { String::new() } else { format!(" -> {}", strs[1]) })
} else if strs.len() > 0 {
format!("{}<{}>", base, strs.connect(", "))
Expand Down

1 comment on commit 3bb91aa

@eddyb
Copy link

@eddyb eddyb commented on 3bb91aa Dec 19, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=alexcrichton rollup

Please sign in to comment.