Skip to content

Commit 3bb91aa

Browse files
committed
Add a check for uninferred type parameter
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.
1 parent c0b2885 commit 3bb91aa

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/librustc/util/ppaux.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,11 @@ pub fn parameterized<'tcx>(cx: &ctxt<'tcx>,
543543
if cx.lang_items.fn_trait_kind(did).is_some() {
544544
format!("{}({}){}",
545545
base,
546-
strs[0][1 .. strs[0].len() - (strs[0].ends_with(",)") as uint+1)],
546+
if strs[0].starts_with("(") && strs[0].ends_with(",)") {
547+
strs[0][1 .. strs[0].len() - 2] // Remove '(' and ',)'
548+
} else {
549+
strs[0][]
550+
},
547551
if &*strs[1] == "()" { String::new() } else { format!(" -> {}", strs[1]) })
548552
} else if strs.len() > 0 {
549553
format!("{}<{}>", base, strs.connect(", "))

0 commit comments

Comments
 (0)