about summary refs log tree commit diff
diff options
context:
space:
mode:
authorkennytm <kennytm@gmail.com>2018-07-22 22:10:11 +0800
committerGitHub <noreply@github.com>2018-07-22 22:10:11 +0800
commit82cdbf1d3ac67b4d1abf37ce748465a6ed97888c (patch)
tree9916de6dacb4788d8de6e306cdcad3b1b59da73a
parent180ad53576dac2455d48ba9e57678f51e6bc8808 (diff)
parent70e7e7d409e9282ae738de6473559af8c47fddf9 (diff)
downloadrust-82cdbf1d3ac67b4d1abf37ce748465a6ed97888c.tar.gz
rust-82cdbf1d3ac67b4d1abf37ce748465a6ed97888c.zip
Rollup merge of #52507 - estebank:infer-type, r=nikomatsakis
Reword when `_` couldn't be inferred

r? @nikomatsakis
-rw-r--r--src/librustc/infer/error_reporting/need_type_info.rs9
-rw-r--r--src/test/ui/error-codes/E0282.stderr2
-rw-r--r--src/test/ui/issue-12187-1.stderr2
-rw-r--r--src/test/ui/issue-12187-2.stderr2
-rw-r--r--src/test/ui/issue-15965.stderr2
-rw-r--r--src/test/ui/issue-18159.stderr2
-rw-r--r--src/test/ui/issue-20261.stderr2
-rw-r--r--src/test/ui/issue-2151.stderr2
-rw-r--r--src/test/ui/issue-23041.stderr2
-rw-r--r--src/test/ui/issue-24013.stderr2
-rw-r--r--src/test/ui/issue-51116.rs2
-rw-r--r--src/test/ui/issue-51116.stderr2
-rw-r--r--src/test/ui/issue-7813.stderr2
-rw-r--r--src/test/ui/span/issue-42234-unknown-receiver-type.stderr2
-rw-r--r--src/test/ui/span/method-and-field-eager-resolution.stderr4
-rw-r--r--src/test/ui/type-check/cannot_infer_local_or_array.stderr2
16 files changed, 24 insertions, 17 deletions
diff --git a/src/librustc/infer/error_reporting/need_type_info.rs b/src/librustc/infer/error_reporting/need_type_info.rs
index 04d14f40b85..dbcb63addb8 100644
--- a/src/librustc/infer/error_reporting/need_type_info.rs
+++ b/src/librustc/infer/error_reporting/need_type_info.rs
@@ -97,7 +97,14 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
         let name = self.extract_type_name(&ty);
 
         let mut err_span = span;
-        let mut labels = vec![(span, format!("cannot infer type for `{}`", name))];
+        let mut labels = vec![(
+            span,
+            if &name == "_" {
+                "cannot infer type".to_string()
+            } else {
+                format!("cannot infer type for `{}`", name)
+            },
+        )];
 
         let mut local_visitor = FindLocalByTypeVisitor {
             infcx: &self,
diff --git a/src/test/ui/error-codes/E0282.stderr b/src/test/ui/error-codes/E0282.stderr
index f1319f41395..6862e2d8688 100644
--- a/src/test/ui/error-codes/E0282.stderr
+++ b/src/test/ui/error-codes/E0282.stderr
@@ -4,7 +4,7 @@ error[E0282]: type annotations needed
 LL |     let x = "hello".chars().rev().collect(); //~ ERROR E0282
    |         ^
    |         |
-   |         cannot infer type for `_`
+   |         cannot infer type
    |         consider giving `x` a type
 
 error: aborting due to previous error
diff --git a/src/test/ui/issue-12187-1.stderr b/src/test/ui/issue-12187-1.stderr
index 7d4df2901fe..94afd6aab57 100644
--- a/src/test/ui/issue-12187-1.stderr
+++ b/src/test/ui/issue-12187-1.stderr
@@ -4,7 +4,7 @@ error[E0282]: type annotations needed
 LL |     let &v = new();
    |         -^
    |         ||
-   |         |cannot infer type for `_`
+   |         |cannot infer type
    |         consider giving the pattern a type
 
 error: aborting due to previous error
diff --git a/src/test/ui/issue-12187-2.stderr b/src/test/ui/issue-12187-2.stderr
index f7ecbd44772..90b41e397c6 100644
--- a/src/test/ui/issue-12187-2.stderr
+++ b/src/test/ui/issue-12187-2.stderr
@@ -4,7 +4,7 @@ error[E0282]: type annotations needed
 LL |     let &v = new();
    |         -^
    |         ||
-   |         |cannot infer type for `_`
+   |         |cannot infer type
    |         consider giving the pattern a type
 
 error: aborting due to previous error
diff --git a/src/test/ui/issue-15965.stderr b/src/test/ui/issue-15965.stderr
index 216c6460c77..3162556986e 100644
--- a/src/test/ui/issue-15965.stderr
+++ b/src/test/ui/issue-15965.stderr
@@ -4,7 +4,7 @@ error[E0282]: type annotations needed
 LL | /         { return () }
 LL | | //~^ ERROR type annotations needed [E0282]
 LL | |     ()
-   | |______^ cannot infer type for `_`
+   | |______^ cannot infer type
    |
    = note: type must be known at this point
 
diff --git a/src/test/ui/issue-18159.stderr b/src/test/ui/issue-18159.stderr
index 894660f1ebf..084e859111b 100644
--- a/src/test/ui/issue-18159.stderr
+++ b/src/test/ui/issue-18159.stderr
@@ -4,7 +4,7 @@ error[E0282]: type annotations needed
 LL |     let x; //~ ERROR type annotations needed
    |         ^
    |         |
-   |         cannot infer type for `_`
+   |         cannot infer type
    |         consider giving `x` a type
 
 error: aborting due to previous error
diff --git a/src/test/ui/issue-20261.stderr b/src/test/ui/issue-20261.stderr
index a7a7ea7c69b..6cdddcff929 100644
--- a/src/test/ui/issue-20261.stderr
+++ b/src/test/ui/issue-20261.stderr
@@ -4,7 +4,7 @@ error[E0282]: type annotations needed
 LL |     for (ref i,) in [].iter() {
    |                     --------- the element type for this iterator is not specified
 LL |         i.clone();
-   |           ^^^^^ cannot infer type for `_`
+   |           ^^^^^ cannot infer type
    |
    = note: type must be known at this point
 
diff --git a/src/test/ui/issue-2151.stderr b/src/test/ui/issue-2151.stderr
index 592c4f424b0..516c5287b31 100644
--- a/src/test/ui/issue-2151.stderr
+++ b/src/test/ui/issue-2151.stderr
@@ -4,7 +4,7 @@ error[E0282]: type annotations needed
 LL |     let x = panic!();
    |         - consider giving `x` a type
 LL |     x.clone(); //~ ERROR type annotations needed
-   |     ^ cannot infer type for `_`
+   |     ^ cannot infer type
    |
    = note: type must be known at this point
 
diff --git a/src/test/ui/issue-23041.stderr b/src/test/ui/issue-23041.stderr
index f89bce09c7e..e97a97fec09 100644
--- a/src/test/ui/issue-23041.stderr
+++ b/src/test/ui/issue-23041.stderr
@@ -2,7 +2,7 @@ error[E0282]: type annotations needed
   --> $DIR/issue-23041.rs:16:22
    |
 LL |     b.downcast_ref::<fn(_)->_>(); //~ ERROR E0282
-   |                      ^^^^^^^^ cannot infer type for `_`
+   |                      ^^^^^^^^ cannot infer type
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/issue-24013.stderr b/src/test/ui/issue-24013.stderr
index 324e705e5a1..5729bdf2064 100644
--- a/src/test/ui/issue-24013.stderr
+++ b/src/test/ui/issue-24013.stderr
@@ -2,7 +2,7 @@ error[E0282]: type annotations needed
   --> $DIR/issue-24013.rs:15:20
    |
 LL |     unsafe {swap::<&mut _>(transmute(&a), transmute(&b))};
-   |                    ^^^^^^ cannot infer type for `_`
+   |                    ^^^^^^ cannot infer type
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/issue-51116.rs b/src/test/ui/issue-51116.rs
index 34217c6236c..c01559b1126 100644
--- a/src/test/ui/issue-51116.rs
+++ b/src/test/ui/issue-51116.rs
@@ -15,7 +15,7 @@ fn main() {
             //~^ NOTE the element type for this iterator is not specified
             *tile = 0;
             //~^ ERROR type annotations needed
-            //~| NOTE cannot infer type for `_`
+            //~| NOTE cannot infer type
             //~| NOTE type must be known at this point
         }
     }
diff --git a/src/test/ui/issue-51116.stderr b/src/test/ui/issue-51116.stderr
index 0c38688340b..fc84ee9028d 100644
--- a/src/test/ui/issue-51116.stderr
+++ b/src/test/ui/issue-51116.stderr
@@ -5,7 +5,7 @@ LL |         for tile in row {
    |                     --- the element type for this iterator is not specified
 LL |             //~^ NOTE the element type for this iterator is not specified
 LL |             *tile = 0;
-   |             ^^^^^ cannot infer type for `_`
+   |             ^^^^^ cannot infer type
    |
    = note: type must be known at this point
 
diff --git a/src/test/ui/issue-7813.stderr b/src/test/ui/issue-7813.stderr
index 34837e90e4f..3ab01982057 100644
--- a/src/test/ui/issue-7813.stderr
+++ b/src/test/ui/issue-7813.stderr
@@ -2,7 +2,7 @@ error[E0282]: type annotations needed
   --> $DIR/issue-7813.rs:12:13
    |
 LL |     let v = &[]; //~ ERROR type annotations needed
-   |         -   ^^^ cannot infer type for `_`
+   |         -   ^^^ cannot infer type
    |         |
    |         consider giving `v` a type
 
diff --git a/src/test/ui/span/issue-42234-unknown-receiver-type.stderr b/src/test/ui/span/issue-42234-unknown-receiver-type.stderr
index e1e13e9256d..d2d5a4a4b12 100644
--- a/src/test/ui/span/issue-42234-unknown-receiver-type.stderr
+++ b/src/test/ui/span/issue-42234-unknown-receiver-type.stderr
@@ -13,7 +13,7 @@ error[E0282]: type annotations needed
    |
 LL | /     data.iter() //~ ERROR 22:5: 23:20: type annotations needed
 LL | |         .sum::<_>()
-   | |___________________^ cannot infer type for `_`
+   | |___________________^ cannot infer type
    |
    = note: type must be known at this point
 
diff --git a/src/test/ui/span/method-and-field-eager-resolution.stderr b/src/test/ui/span/method-and-field-eager-resolution.stderr
index 21e19828a99..8a8c1e467b9 100644
--- a/src/test/ui/span/method-and-field-eager-resolution.stderr
+++ b/src/test/ui/span/method-and-field-eager-resolution.stderr
@@ -4,7 +4,7 @@ error[E0282]: type annotations needed
 LL |     let mut x = Default::default();
    |         ----- consider giving `x` a type
 LL |     x.0;
-   |     ^ cannot infer type for `_`
+   |     ^ cannot infer type
    |
    = note: type must be known at this point
 
@@ -14,7 +14,7 @@ error[E0282]: type annotations needed
 LL |     let mut x = Default::default();
    |         ----- consider giving `x` a type
 LL |     x[0];
-   |     ^ cannot infer type for `_`
+   |     ^ cannot infer type
    |
    = note: type must be known at this point
 
diff --git a/src/test/ui/type-check/cannot_infer_local_or_array.stderr b/src/test/ui/type-check/cannot_infer_local_or_array.stderr
index 90191ae6745..bfdd614e50d 100644
--- a/src/test/ui/type-check/cannot_infer_local_or_array.stderr
+++ b/src/test/ui/type-check/cannot_infer_local_or_array.stderr
@@ -2,7 +2,7 @@ error[E0282]: type annotations needed
   --> $DIR/cannot_infer_local_or_array.rs:12:13
    |
 LL |     let x = []; //~ ERROR type annotations needed
-   |         -   ^^ cannot infer type for `_`
+   |         -   ^^ cannot infer type
    |         |
    |         consider giving `x` a type