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.
This commit is contained in:
Jonas Schievink 2020-01-25 02:29:09 +01:00
parent 32005fe195
commit 2101a1fec0
6 changed files with 60 additions and 30 deletions

View file

@ -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()
})

View file

@ -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`.

View file

@ -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
};
}

View file

@ -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`.

View file

@ -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]
}
}

View file

@ -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
For more information about this error, try `rustc --explain E0308`.
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0271, E0308.
For more information about an error, try `rustc --explain E0271`.