-
Notifications
You must be signed in to change notification settings - Fork 627
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
206 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#![feature(async_await, generators)] | ||
|
||
use futures::*; | ||
|
||
#[async_stream(item = Option<i32>)] | ||
fn foobar() { | ||
let val = Some(42); | ||
if val.is_none() { | ||
yield None; | ||
return; | ||
} | ||
let val = val.unwrap(); | ||
yield val; | ||
} | ||
|
||
#[async_stream(item = (i32, i32))] | ||
fn tuple() { | ||
if false { | ||
yield 3; | ||
} | ||
yield (1, 2) | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/bad-item-type.rs:13:11 | ||
| | ||
13 | yield val; | ||
| ^^^ | ||
| | | ||
| expected enum `std::option::Option`, found integer | ||
| help: try using a variant of the expected type: `Some(val)` | ||
| | ||
= note: expected type `std::option::Option<_>` | ||
found type `{integer}` | ||
|
||
error[E0698]: type inside generator must be known in this context | ||
--> $DIR/bad-item-type.rs:5:1 | ||
| | ||
5 | #[async_stream(item = Option<i32>)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for `{integer}` | ||
| | ||
note: the type is part of the generator because of this `yield` | ||
--> $DIR/bad-item-type.rs:5:1 | ||
| | ||
5 | #[async_stream(item = Option<i32>)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/bad-item-type.rs:21:11 | ||
| | ||
21 | yield (1, 2) | ||
| ^^^^^^ expected integer, found tuple | ||
| | ||
= note: expected type `{integer}` | ||
found type `({integer}, {integer})` | ||
|
||
error[E0271]: type mismatch resolving `<impl futures_core::stream::Stream as futures_core::stream::Stream>::Item == (i32, i32)` | ||
--> $DIR/bad-item-type.rs:16:23 | ||
| | ||
16 | #[async_stream(item = (i32, i32))] | ||
| ^^^^^^^^^^ expected integer, found tuple | ||
| | ||
= note: expected type `{integer}` | ||
found type `(i32, i32)` | ||
= note: the return type of a function must have a statically known size | ||
|
||
error[E0698]: type inside generator must be known in this context | ||
--> $DIR/bad-item-type.rs:16:1 | ||
| | ||
16 | #[async_stream(item = (i32, i32))] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for `{integer}` | ||
| | ||
note: the type is part of the generator because of this `yield` | ||
--> $DIR/bad-item-type.rs:16:1 | ||
| | ||
16 | #[async_stream(item = (i32, i32))] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 5 previous errors | ||
|
||
Some errors have detailed explanations: E0271, E0308, E0698. | ||
For more information about an error, try `rustc --explain E0271`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,8 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/bad-return-type.rs:13:11 | ||
| | ||
13 | yield val; | ||
| ^^^ | ||
| | | ||
| expected enum `std::option::Option`, found integer | ||
| help: try using a variant of the expected type: `Some(val)` | ||
| | ||
= note: expected type `std::option::Option<_>` | ||
found type `{integer}` | ||
|
||
error[E0698]: type inside generator must be known in this context | ||
--> $DIR/bad-return-type.rs:5:1 | ||
| | ||
5 | #[async_stream] | ||
| ^^^^^^^^^^^^^^^ cannot infer type for `{integer}` | ||
| | ||
note: the type is part of the generator because of this `yield` | ||
--> $DIR/bad-return-type.rs:5:1 | ||
error: async stream functions must return the unit type | ||
--> $DIR/bad-return-type.rs:6:13 | ||
| | ||
5 | #[async_stream] | ||
| ^^^^^^^^^^^^^^^ | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/bad-return-type.rs:21:11 | ||
| | ||
21 | yield (1, 2) | ||
| ^^^^^^ expected integer, found tuple | ||
| | ||
= note: expected type `{integer}` | ||
found type `({integer}, {integer})` | ||
|
||
error[E0271]: type mismatch resolving `<impl futures_core::stream::Stream as futures_core::stream::Stream>::Item == (i32, i32)` | ||
--> $DIR/bad-return-type.rs:17:15 | ||
| | ||
17 | fn tuple() -> (i32, i32) { | ||
| ^^^^^^^^^^ expected integer, found tuple | ||
| | ||
= note: expected type `{integer}` | ||
found type `(i32, i32)` | ||
= note: the return type of a function must have a statically known size | ||
|
||
error[E0698]: type inside generator must be known in this context | ||
--> $DIR/bad-return-type.rs:16:1 | ||
| | ||
16 | #[async_stream] | ||
| ^^^^^^^^^^^^^^^ cannot infer type for `{integer}` | ||
| | ||
note: the type is part of the generator because of this `yield` | ||
--> $DIR/bad-return-type.rs:16:1 | ||
| | ||
16 | #[async_stream] | ||
| ^^^^^^^^^^^^^^^ | ||
6 | fn foo() -> i32 {} // ERROR | ||
| ^^^ | ||
|
||
error: aborting due to 5 previous errors | ||
error: aborting due to previous error | ||
|
||
Some errors have detailed explanations: E0271, E0308, E0698. | ||
For more information about an error, try `rustc --explain E0271`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
use futures::*; | ||
|
||
#[async_stream] | ||
#[async_stream(item = ())] | ||
fn foo() { | ||
yield; | ||
Some(()) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#![feature(async_await, generators)] | ||
|
||
use futures::*; | ||
|
||
#[async_stream] | ||
fn foo(a: String) {} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
error: unexpected end of input, expected `item` | ||
--> $DIR/missing-item.rs:5:1 | ||
| | ||
5 | #[async_stream] | ||
| ^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.