about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJonas Schievink <jonasschievink@gmail.com>2020-01-25 02:29:09 +0100
committerJonas Schievink <jonasschievink@gmail.com>2020-02-02 13:20:57 +0100
commit2101a1fec0e53677e32d1389b44f70a987a97c8d (patch)
treed66a8daf1554459db79aed07acb4f834cd6fbd55
parent32005fe1957fc163036fbe0da8b12d39a9fb54cb (diff)
downloadrust-2101a1fec0e53677e32d1389b44f70a987a97c8d.tar.gz
rust-2101a1fec0e53677e32d1389b44f70a987a97c8d.zip
Adjust tests to type inference changes
This makes some error messages ungreat, but those seem to be preexisting
bugs that also apply to closures / return position `impl Trait` in
general.
-rw-r--r--src/test/ui/generator-yielding-or-returning-itself.rs2
-rw-r--r--src/test/ui/generator-yielding-or-returning-itself.stderr21
-rw-r--r--src/test/ui/generator/no-parameters-on-generators.rs4
-rw-r--r--src/test/ui/generator/no-parameters-on-generators.stderr32
-rw-r--r--src/test/ui/generator/type-mismatch-signature-deduction.rs6
-rw-r--r--src/test/ui/generator/type-mismatch-signature-deduction.stderr25
6 files changed, 60 insertions, 30 deletions
diff --git a/src/test/ui/generator-yielding-or-returning-itself.rs b/src/test/ui/generator-yielding-or-returning-itself.rs
index fd526679818..30788e3c186 100644
--- a/src/test/ui/generator-yielding-or-returning-itself.rs
+++ b/src/test/ui/generator-yielding-or-returning-itself.rs
@@ -13,7 +13,7 @@ pub fn want_cyclic_generator_return<T>(_: T)
 
 fn supply_cyclic_generator_return() {
     want_cyclic_generator_return(|| {
-        //~^ ERROR closure/generator type that references itself
+        //~^ ERROR type mismatch
         if false { yield None.unwrap(); }
         None.unwrap()
     })
diff --git a/src/test/ui/generator-yielding-or-returning-itself.stderr b/src/test/ui/generator-yielding-or-returning-itself.stderr
index c9a71e03858..1572219cf4a 100644
--- a/src/test/ui/generator-yielding-or-returning-itself.stderr
+++ b/src/test/ui/generator-yielding-or-returning-itself.stderr
@@ -1,13 +1,13 @@
-error[E0644]: closure/generator type that references itself
-  --> $DIR/generator-yielding-or-returning-itself.rs:15:34
+error[E0271]: type mismatch resolving `<[generator@$DIR/generator-yielding-or-returning-itself.rs:15:34: 19:6 _] as std::ops::Generator>::Return == [generator@$DIR/generator-yielding-or-returning-itself.rs:15:34: 19:6 _]`
+  --> $DIR/generator-yielding-or-returning-itself.rs:15:5
    |
-LL |       want_cyclic_generator_return(|| {
-   |  __________________________________^
-LL | |
-LL | |         if false { yield None.unwrap(); }
-LL | |         None.unwrap()
-LL | |     })
-   | |_____^ cyclic type of infinite size
+LL | pub fn want_cyclic_generator_return<T>(_: T)
+   |        ----------------------------
+LL |     where T: Generator<Yield = (), Return = T>
+   |                                    ---------- required by this bound in `want_cyclic_generator_return`
+...
+LL |     want_cyclic_generator_return(|| {
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cyclic type of infinite size
    |
    = note: closures cannot capture themselves or take themselves as argument;
            this error may be the result of a recent compiler bug-fix,
@@ -30,5 +30,4 @@ LL |     want_cyclic_generator_yield(|| {
 
 error: aborting due to 2 previous errors
 
-Some errors have detailed explanations: E0271, E0644.
-For more information about an error, try `rustc --explain E0271`.
+For more information about this error, try `rustc --explain E0271`.
diff --git a/src/test/ui/generator/no-parameters-on-generators.rs b/src/test/ui/generator/no-parameters-on-generators.rs
index 6b5a5579339..cad00489534 100644
--- a/src/test/ui/generator/no-parameters-on-generators.rs
+++ b/src/test/ui/generator/no-parameters-on-generators.rs
@@ -1,8 +1,10 @@
 #![feature(generators)]
 
 fn main() {
-    let gen = |start| { //~ ERROR generators cannot have explicit parameters
+    let gen = |start| {
         //~^ ERROR type inside generator must be known in this context
         yield;
+        //~^ ERROR type inside generator must be known in this context
+        //~| ERROR type inside generator must be known in this context
     };
 }
diff --git a/src/test/ui/generator/no-parameters-on-generators.stderr b/src/test/ui/generator/no-parameters-on-generators.stderr
index 5e8e043a391..f5f83b04769 100644
--- a/src/test/ui/generator/no-parameters-on-generators.stderr
+++ b/src/test/ui/generator/no-parameters-on-generators.stderr
@@ -1,9 +1,3 @@
-error[E0628]: generators cannot have explicit parameters
-  --> $DIR/no-parameters-on-generators.rs:4:15
-   |
-LL |     let gen = |start| {
-   |               ^^^^^^^
-
 error[E0698]: type inside generator must be known in this context
   --> $DIR/no-parameters-on-generators.rs:4:16
    |
@@ -16,6 +10,30 @@ note: the type is part of the generator because of this `yield`
 LL |         yield;
    |         ^^^^^
 
-error: aborting due to 2 previous errors
+error[E0698]: type inside generator must be known in this context
+  --> $DIR/no-parameters-on-generators.rs:6:9
+   |
+LL |         yield;
+   |         ^^^^^ cannot infer type
+   |
+note: the type is part of the generator because of this `yield`
+  --> $DIR/no-parameters-on-generators.rs:6:9
+   |
+LL |         yield;
+   |         ^^^^^
+
+error[E0698]: type inside generator must be known in this context
+  --> $DIR/no-parameters-on-generators.rs:6:9
+   |
+LL |         yield;
+   |         ^^^^^ cannot infer type
+   |
+note: the type is part of the generator because of this `yield`
+  --> $DIR/no-parameters-on-generators.rs:6:9
+   |
+LL |         yield;
+   |         ^^^^^
+
+error: aborting due to 3 previous errors
 
 For more information about this error, try `rustc --explain E0698`.
diff --git a/src/test/ui/generator/type-mismatch-signature-deduction.rs b/src/test/ui/generator/type-mismatch-signature-deduction.rs
index b9c6bc5d079..7774ff48f56 100644
--- a/src/test/ui/generator/type-mismatch-signature-deduction.rs
+++ b/src/test/ui/generator/type-mismatch-signature-deduction.rs
@@ -2,15 +2,15 @@
 
 use std::ops::Generator;
 
-fn foo() -> impl Generator<Return = i32> {
+fn foo() -> impl Generator<Return = i32> { //~ ERROR type mismatch
     || {
         if false {
-            return Ok(6); //~ ERROR mismatched types [E0308]
+            return Ok(6);
         }
 
         yield ();
 
-        5
+        5 //~ ERROR mismatched types [E0308]
     }
 }
 
diff --git a/src/test/ui/generator/type-mismatch-signature-deduction.stderr b/src/test/ui/generator/type-mismatch-signature-deduction.stderr
index 8606ecd33da..8de77798ff4 100644
--- a/src/test/ui/generator/type-mismatch-signature-deduction.stderr
+++ b/src/test/ui/generator/type-mismatch-signature-deduction.stderr
@@ -1,12 +1,23 @@
 error[E0308]: mismatched types
-  --> $DIR/type-mismatch-signature-deduction.rs:8:20
+  --> $DIR/type-mismatch-signature-deduction.rs:13:9
    |
-LL |             return Ok(6);
-   |                    ^^^^^ expected `i32`, found enum `std::result::Result`
+LL |         5
+   |         ^ expected enum `std::result::Result`, found integer
    |
-   = note: expected type `i32`
-              found enum `std::result::Result<{integer}, _>`
+   = note: expected type `std::result::Result<{integer}, _>`
+              found type `{integer}`
 
-error: aborting due to previous error
+error[E0271]: type mismatch resolving `<[generator@$DIR/type-mismatch-signature-deduction.rs:6:5: 14:6 _] as std::ops::Generator>::Return == i32`
+  --> $DIR/type-mismatch-signature-deduction.rs:5:13
+   |
+LL | fn foo() -> impl Generator<Return = i32> {
+   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected enum `std::result::Result`, found `i32`
+   |
+   = note: expected enum `std::result::Result<{integer}, _>`
+              found type `i32`
+   = note: the return type of a function must have a statically known size
+
+error: aborting due to 2 previous errors
 
-For more information about this error, try `rustc --explain E0308`.
+Some errors have detailed explanations: E0271, E0308.
+For more information about an error, try `rustc --explain E0271`.