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

Make async generators fused by default #118764

Merged
merged 1 commit into from
Dec 9, 2023

Conversation

compiler-errors
Copy link
Member

I actually changed my mind about this since the implementation PR landed. I think it's beneficial for async gen blocks to be "fused" by default -- i.e., for them to repeatedly return Poll::Ready(None) -- rather than panic.

We have FusedStream in futures-rs to represent streams with this capability already anyways.

r? eholk
cc @rust-lang/wg-async, would like to know if anyone else has opinions about this.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 8, 2023
@rustbot
Copy link
Collaborator

rustbot commented Dec 8, 2023

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Dec 8, 2023
@eholk
Copy link
Contributor

eholk commented Dec 8, 2023

Out of curiosity, what changed your mind?

I sort of liked having them not be fused by default, but I don't have a good reason or enough experience/intuition to really justify either position.

@eholk
Copy link
Contributor

eholk commented Dec 8, 2023

I guess if generators are already fused by default it makes sense to have the same behavior for async iterators.

Code-wise, the PR looks good to me. I'd like to give @rust-lang/wg-async a little more time to express opinions though.

@compiler-errors
Copy link
Member Author

Out of curiosity, what changed your mind?

The existence of FusedStream trait and StreamExt::fuse() in futures-rs, mostly.

I guess if generators are already fused by default it makes sense to have the same behavior for async iterators.

Yeah, I thought the same.

@eholk
Copy link
Contributor

eholk commented Dec 9, 2023

The general feedback so far has been that fusing by default is the right choice. I'll go ahead and approve this. This feature is experimental so the stakes are pretty low and we can always revisit the decision in the future.

@bors r+

@bors
Copy link
Contributor

bors commented Dec 9, 2023

📌 Commit e987812 has been approved by eholk

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 9, 2023
@eholk
Copy link
Contributor

eholk commented Dec 9, 2023

@bors rollup

workingjubilee added a commit to workingjubilee/rustc that referenced this pull request Dec 9, 2023
…or, r=eholk

Make async generators fused by default

I actually changed my mind about this since the implementation PR landed. I think it's beneficial for `async gen` blocks to be "fused" by default -- i.e., for them to repeatedly return `Poll::Ready(None)` -- rather than panic.

We have [`FusedStream`](https://docs.rs/futures/latest/futures/stream/trait.FusedStream.html) in futures-rs to represent streams with this capability already anyways.

r? eholk
cc `@rust-lang/wg-async,` would like to know if anyone else has opinions about this.
workingjubilee added a commit to workingjubilee/rustc that referenced this pull request Dec 9, 2023
…or, r=eholk

Make async generators fused by default

I actually changed my mind about this since the implementation PR landed. I think it's beneficial for `async gen` blocks to be "fused" by default -- i.e., for them to repeatedly return `Poll::Ready(None)` -- rather than panic.

We have [`FusedStream`](https://docs.rs/futures/latest/futures/stream/trait.FusedStream.html) in futures-rs to represent streams with this capability already anyways.

r? eholk
cc ``@rust-lang/wg-async,`` would like to know if anyone else has opinions about this.
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 9, 2023
…kingjubilee

Rollup of 8 pull requests

Successful merges:

 - rust-lang#118198 (coverage: Use `SpanMarker` to improve coverage spans for `if !` expressions)
 - rust-lang#118512 (Add tests related to normalization in implied bounds)
 - rust-lang#118610 (update target feature following LLVM API change)
 - rust-lang#118666 (coverage: Simplify the heuristic for ignoring `async fn` return spans)
 - rust-lang#118737 (Extend tidy alphabetical checking to `tests/`.)
 - rust-lang#118756 (use bold magenta instead of bold white for highlighting)
 - rust-lang#118762 (Some more minor `async gen`-related nits)
 - rust-lang#118764 (Make async generators fused by default)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 9, 2023
…kingjubilee

Rollup of 7 pull requests

Successful merges:

 - rust-lang#118198 (coverage: Use `SpanMarker` to improve coverage spans for `if !` expressions)
 - rust-lang#118512 (Add tests related to normalization in implied bounds)
 - rust-lang#118610 (update target feature following LLVM API change)
 - rust-lang#118666 (coverage: Simplify the heuristic for ignoring `async fn` return spans)
 - rust-lang#118737 (Extend tidy alphabetical checking to `tests/`.)
 - rust-lang#118762 (Some more minor `async gen`-related nits)
 - rust-lang#118764 (Make async generators fused by default)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 61dfb1f into rust-lang:master Dec 9, 2023
11 checks passed
@rustbot rustbot added this to the 1.76.0 milestone Dec 9, 2023
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Dec 9, 2023
Rollup merge of rust-lang#118764 - compiler-errors:fused-async-iterator, r=eholk

Make async generators fused by default

I actually changed my mind about this since the implementation PR landed. I think it's beneficial for `async gen` blocks to be "fused" by default -- i.e., for them to repeatedly return `Poll::Ready(None)` -- rather than panic.

We have [`FusedStream`](https://docs.rs/futures/latest/futures/stream/trait.FusedStream.html) in futures-rs to represent streams with this capability already anyways.

r? eholk
cc ```@rust-lang/wg-async,``` would like to know if anyone else has opinions about this.
@compiler-errors compiler-errors deleted the fused-async-iterator branch December 10, 2023 03:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants