]> git.lizzy.rs Git - rust.git/commitdiff
Add a check for uninferred type parameter
authorPhilip Munksgaard <pmunksgaard@gmail.com>
Thu, 18 Dec 2014 12:10:41 +0000 (13:10 +0100)
committerPhilip Munksgaard <pmunksgaard@gmail.com>
Fri, 19 Dec 2014 10:06:38 +0000 (11:06 +0100)
This fixes #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.

src/librustc/util/ppaux.rs

index 13b5c262bf7825e00f6df4f80b977597d98ad19b..b534823c2c584842636cbbe186c6a54294794f6f 100644 (file)
@@ -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(", "))