Skip to content

Commit 2101a1f

Browse files
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.
1 parent 32005fe commit 2101a1f

6 files changed

+60
-30
lines changed

src/test/ui/generator-yielding-or-returning-itself.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub fn want_cyclic_generator_return<T>(_: T)
1313

1414
fn supply_cyclic_generator_return() {
1515
want_cyclic_generator_return(|| {
16-
//~^ ERROR closure/generator type that references itself
16+
//~^ ERROR type mismatch
1717
if false { yield None.unwrap(); }
1818
None.unwrap()
1919
})

src/test/ui/generator-yielding-or-returning-itself.stderr

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
error[E0644]: closure/generator type that references itself
2-
--> $DIR/generator-yielding-or-returning-itself.rs:15:34
1+
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 _]`
2+
--> $DIR/generator-yielding-or-returning-itself.rs:15:5
33
|
4-
LL | want_cyclic_generator_return(|| {
5-
| __________________________________^
6-
LL | |
7-
LL | | if false { yield None.unwrap(); }
8-
LL | | None.unwrap()
9-
LL | | })
10-
| |_____^ cyclic type of infinite size
4+
LL | pub fn want_cyclic_generator_return<T>(_: T)
5+
| ----------------------------
6+
LL | where T: Generator<Yield = (), Return = T>
7+
| ---------- required by this bound in `want_cyclic_generator_return`
8+
...
9+
LL | want_cyclic_generator_return(|| {
10+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cyclic type of infinite size
1111
|
1212
= note: closures cannot capture themselves or take themselves as argument;
1313
this error may be the result of a recent compiler bug-fix,
@@ -30,5 +30,4 @@ LL | want_cyclic_generator_yield(|| {
3030

3131
error: aborting due to 2 previous errors
3232

33-
Some errors have detailed explanations: E0271, E0644.
34-
For more information about an error, try `rustc --explain E0271`.
33+
For more information about this error, try `rustc --explain E0271`.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#![feature(generators)]
22

33
fn main() {
4-
let gen = |start| { //~ ERROR generators cannot have explicit parameters
4+
let gen = |start| {
55
//~^ ERROR type inside generator must be known in this context
66
yield;
7+
//~^ ERROR type inside generator must be known in this context
8+
//~| ERROR type inside generator must be known in this context
79
};
810
}
Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
error[E0628]: generators cannot have explicit parameters
2-
--> $DIR/no-parameters-on-generators.rs:4:15
3-
|
4-
LL | let gen = |start| {
5-
| ^^^^^^^
6-
71
error[E0698]: type inside generator must be known in this context
82
--> $DIR/no-parameters-on-generators.rs:4:16
93
|
@@ -16,6 +10,30 @@ note: the type is part of the generator because of this `yield`
1610
LL | yield;
1711
| ^^^^^
1812

19-
error: aborting due to 2 previous errors
13+
error[E0698]: type inside generator must be known in this context
14+
--> $DIR/no-parameters-on-generators.rs:6:9
15+
|
16+
LL | yield;
17+
| ^^^^^ cannot infer type
18+
|
19+
note: the type is part of the generator because of this `yield`
20+
--> $DIR/no-parameters-on-generators.rs:6:9
21+
|
22+
LL | yield;
23+
| ^^^^^
24+
25+
error[E0698]: type inside generator must be known in this context
26+
--> $DIR/no-parameters-on-generators.rs:6:9
27+
|
28+
LL | yield;
29+
| ^^^^^ cannot infer type
30+
|
31+
note: the type is part of the generator because of this `yield`
32+
--> $DIR/no-parameters-on-generators.rs:6:9
33+
|
34+
LL | yield;
35+
| ^^^^^
36+
37+
error: aborting due to 3 previous errors
2038

2139
For more information about this error, try `rustc --explain E0698`.

src/test/ui/generator/type-mismatch-signature-deduction.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
use std::ops::Generator;
44

5-
fn foo() -> impl Generator<Return = i32> {
5+
fn foo() -> impl Generator<Return = i32> { //~ ERROR type mismatch
66
|| {
77
if false {
8-
return Ok(6); //~ ERROR mismatched types [E0308]
8+
return Ok(6);
99
}
1010

1111
yield ();
1212

13-
5
13+
5 //~ ERROR mismatched types [E0308]
1414
}
1515
}
1616

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
11
error[E0308]: mismatched types
2-
--> $DIR/type-mismatch-signature-deduction.rs:8:20
2+
--> $DIR/type-mismatch-signature-deduction.rs:13:9
33
|
4-
LL | return Ok(6);
5-
| ^^^^^ expected `i32`, found enum `std::result::Result`
4+
LL | 5
5+
| ^ expected enum `std::result::Result`, found integer
66
|
7-
= note: expected type `i32`
8-
found enum `std::result::Result<{integer}, _>`
7+
= note: expected type `std::result::Result<{integer}, _>`
8+
found type `{integer}`
99

10-
error: aborting due to previous error
10+
error[E0271]: type mismatch resolving `<[generator@$DIR/type-mismatch-signature-deduction.rs:6:5: 14:6 _] as std::ops::Generator>::Return == i32`
11+
--> $DIR/type-mismatch-signature-deduction.rs:5:13
12+
|
13+
LL | fn foo() -> impl Generator<Return = i32> {
14+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected enum `std::result::Result`, found `i32`
15+
|
16+
= note: expected enum `std::result::Result<{integer}, _>`
17+
found type `i32`
18+
= note: the return type of a function must have a statically known size
19+
20+
error: aborting due to 2 previous errors
1121

12-
For more information about this error, try `rustc --explain E0308`.
22+
Some errors have detailed explanations: E0271, E0308.
23+
For more information about an error, try `rustc --explain E0271`.

0 commit comments

Comments
 (0)