Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transform the inner expression of yield expressions #66

Merged
merged 7 commits into from
Mar 12, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions async-stream-impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ impl VisitMut for Scrub<'_> {
syn::Expr::Yield(yield_expr) => {
self.has_yielded = true;

syn::visit_mut::visit_expr_yield_mut(self, yield_expr);

let value_expr = yield_expr.expr.as_ref().unwrap_or(&self.unit);

// let ident = &self.yielder;
Expand Down
7 changes: 7 additions & 0 deletions async-stream/tests/try_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,10 @@ async fn multi_try() {
values
);
}

#[allow(unused)]
fn issue_65() -> impl Stream<Item = Result<u32, ()>> {
try_stream! {
yield Err(())?;
}
}
57 changes: 7 additions & 50 deletions async-stream/tests/ui/yield_in_async.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -22,54 +22,11 @@ error[E0271]: type mismatch resolving `<[static generator@$DIR/src/lib.rs:201:9:
8 | |
9 | | let v = f.await;
10 | | };
| |______^ expected `()`, found integer
| |_____^ expected `()`, found integer
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0698]: type inside `async` block must be known in this context
--> $DIR/yield_in_async.rs:6:19
|
6 | yield 123;
| ^^^ cannot infer type for type `{integer}`
|
note: the type is part of the `async` block because of this `yield`
--> $DIR/yield_in_async.rs:6:13
|
6 | yield 123;
| ^^^^^^^^^

error[E0698]: type inside `async` block must be known in this context
--> $DIR/yield_in_async.rs:5:13
|
5 | let f = async {
| ^ cannot infer type for type `{integer}`
|
note: the type is part of the `async` block because of this `await`
--> $DIR/yield_in_async.rs:9:17
|
9 | let v = f.await;
| ^^^^^^^

error[E0698]: type inside `async` block must be known in this context
--> $DIR/yield_in_async.rs:9:17
|
9 | let v = f.await;
| ^ cannot infer type for type `{integer}`
|
note: the type is part of the `async` block because of this `await`
--> $DIR/yield_in_async.rs:9:17
|
9 | let v = f.await;
| ^^^^^^^

error[E0698]: type inside `async` block must be known in this context
--> $DIR/yield_in_async.rs:9:17
|
9 | let v = f.await;
| ^^^^^^^ cannot infer type for type `{integer}`
|
note: the type is part of the `async` block because of this `await`
--> $DIR/yield_in_async.rs:9:17
|
9 | let v = f.await;
| ^^^^^^^
note: required by a bound in `from_generator`
--> $RUST/core/src/future/mod.rs
|
| T: Generator<ResumeTy, Yield = ()>,
| ^^^^^^^^^^ required by this bound in `from_generator`
= note: this error originates in the macro `stream` (in Nightly builds, run with -Z macro-backtrace for more info)