-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add gen
blocks and reserve keyword in Rust 2024
#3513
Commits on Oct 11, 2023
-
Configuration menu - View commit details
-
Copy full SHA for 1cbbe3c - Browse repository at this point
Copy the full SHA 1cbbe3cView commit details -
Configuration menu - View commit details
-
Copy full SHA for 6b3726e - Browse repository at this point
Copy the full SHA 6b3726eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 585afb9 - Browse repository at this point
Copy the full SHA 585afb9View commit details -
Configuration menu - View commit details
-
Copy full SHA for c905ce0 - Browse repository at this point
Copy the full SHA c905ce0View commit details
Commits on Oct 12, 2023
-
Configuration menu - View commit details
-
Copy full SHA for e10c2a6 - Browse repository at this point
Copy the full SHA e10c2a6View commit details -
Configuration menu - View commit details
-
Copy full SHA for 625826d - Browse repository at this point
Copy the full SHA 625826dView commit details -
Configuration menu - View commit details
-
Copy full SHA for 3f3799a - Browse repository at this point
Copy the full SHA 3f3799aView commit details -
Configuration menu - View commit details
-
Copy full SHA for 4146a83 - Browse repository at this point
Copy the full SHA 4146a83View commit details -
Configuration menu - View commit details
-
Copy full SHA for ca7bb01 - Browse repository at this point
Copy the full SHA ca7bb01View commit details -
Configuration menu - View commit details
-
Copy full SHA for e07b766 - Browse repository at this point
Copy the full SHA e07b766View commit details -
Actually, the
async gen
troubles aren't anything beyond the `self-r……eferential` `gen` block issues
1Configuration menu - View commit details
-
Copy full SHA for 1bb969f - Browse repository at this point
Copy the full SHA 1bb969fView commit details -
* minor typos * intro * motivation * guide * reference * implementation * alternates * rationale * future * whitespace
Configuration menu - View commit details
-
Copy full SHA for 7d06af4 - Browse repository at this point
Copy the full SHA 7d06af4View commit details
Commits on Oct 13, 2023
-
Configuration menu - View commit details
-
Copy full SHA for 08c07d2 - Browse repository at this point
Copy the full SHA 08c07d2View commit details -
Configuration menu - View commit details
-
Copy full SHA for d89eb26 - Browse repository at this point
Copy the full SHA d89eb26View commit details -
Configuration menu - View commit details
-
Copy full SHA for e06745e - Browse repository at this point
Copy the full SHA e06745eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 09c3ff1 - Browse repository at this point
Copy the full SHA 09c3ff1View commit details -
Configuration menu - View commit details
-
Copy full SHA for 45ce4db - Browse repository at this point
Copy the full SHA 45ce4dbView commit details
Commits on Oct 14, 2023
-
Fix and improve capitalization and punctuation
There were some places with erroneous or unclear punctuation and capitalization. Let's fix those and make some related typographic and linguistic improvements.
Configuration menu - View commit details
-
Copy full SHA for e9bbc6e - Browse repository at this point
Copy the full SHA e9bbc6eView commit details -
Fix links to the unresolved questions section
We had said `[text][#foo]` when we had meant to say `[text][foo]`, leading to broken internal link elements when referencing the unresolved questions section. Let's fix that.
Configuration menu - View commit details
-
Copy full SHA for 118b777 - Browse repository at this point
Copy the full SHA 118b777View commit details -
Add section noting C# prior art
The C# (CSharp) language has a `yield` statement. Let's describe this in a new prior art section. (Thanks to @scottmcm for pointing this out.)
Configuration menu - View commit details
-
Copy full SHA for 00335a2 - Browse repository at this point
Copy the full SHA 00335a2View commit details -
Add example and mention of
std::iter::from_fn
In the motivation, we enumerate some ways that people can create an iterator. One way we didn't demonstrate was the use of `std::iter::from_fn`. Let's do that, and let's add a mention of this in the section about the ever-present option of doing nothing. (Thanks to @estebank for pointing this out.)
Configuration menu - View commit details
-
Copy full SHA for 94096d5 - Browse repository at this point
Copy the full SHA 94096d5View commit details -
Clarify rules on the valid return type of a
gen
blockWe're specifying that `gen` blocks must diverge or return the unit type. Let's articulate exactly what that means. (Thanks to @scottmcm for pointing this out.)
Configuration menu - View commit details
-
Copy full SHA for a8295c8 - Browse repository at this point
Copy the full SHA a8295c8View commit details -
Clarify section on error handling
The section on error handling discussed very specifically the behavior with `Option` and `Result` in a way that may have made the general case less clear. E.g., it did not discuss the handling of `ControlFlow`, leaving unclear whether arbitrary types that implement the `Try` trait could be used. It also did not discuss whether `From::from` was called as usual in case of short-circuiting. Let's simplify this section a bit by first discussing the desugaring, discussing the non-effect on the required type of trailing elements or arguments to `return` in the block, and discussing the effect on the type of the arguments required by `yield`. Notably, we won't discuss here the details of how `None` is returned to end iteration. This behavior is the same as when `?` is not used, and the desugaring we describe fills in all of the needed details. (Thanks to @scottmcm for pointing out the ambiguous nature of this section.)
Configuration menu - View commit details
-
Copy full SHA for e5c803c - Browse repository at this point
Copy the full SHA e5c803cView commit details
Commits on Oct 17, 2023
-
Add more full history of generators in prior art
Generators, iterators, and the `yield` keyword have a long history in the programming language literature. Let's describe some of this history in the prior art section and add more examples of languages with these features.
Configuration menu - View commit details
-
Copy full SHA for b949fec - Browse repository at this point
Copy the full SHA b949fecView commit details
Commits on Oct 18, 2023
-
Switch back to using
gen
keyword throughout RFCIn the 2023-10-18 T-lang triage meeting, the team decided that this RFC should settle of the question of the keyword. Consequently, let's commit to the `gen` keyword and use it throughout the document rather than using an attribute placeholder.
Configuration menu - View commit details
-
Copy full SHA for c982935 - Browse repository at this point
Copy the full SHA c982935View commit details -
Remove language about an experiment
Some of the language in this RFC implied that this is an experiment and that another RFC would be required. This isn't how we want to frame things. Another RFC could always be required, but it's also possible that stabilization could occur on the basis of this RFC. This is a normal RFC. Let's remove all language about this being an experiment.
Configuration menu - View commit details
-
Copy full SHA for ffcf881 - Browse repository at this point
Copy the full SHA ffcf881View commit details
Commits on Feb 29, 2024
-
Configuration menu - View commit details
-
Copy full SHA for b524348 - Browse repository at this point
Copy the full SHA b524348View commit details -
Configuration menu - View commit details
-
Copy full SHA for 349c517 - Browse repository at this point
Copy the full SHA 349c517View commit details
Commits on Mar 13, 2024
-
Make self-referential
gen
blocks an open questionWe had listed self-referential `gen` blocks as a future possibility, but in discussion with T-lang, it's become clear that this should instead be listed as an open question, so let's do that.
Configuration menu - View commit details
-
Copy full SHA for b836635 - Browse repository at this point
Copy the full SHA b836635View commit details
Commits on Mar 14, 2024
-
Adjust for
Generator -> Coroutine
renameFor many years, we had a trait in nightly Rust called `Generator`. We've now renamed this to `Coroutine`, but this RFC still referred to it as `Generator`. Let's use the new name and make a note of the old one.
Configuration menu - View commit details
-
Copy full SHA for 6478947 - Browse repository at this point
Copy the full SHA 6478947View commit details
Commits on Mar 15, 2024
-
Add unresolved question about implemented traits
To give us better options for supporting self-referential generators we may not want the type returned by `gen` blocks to implement `Iterator` directly. Let's call this out as an open question and weaken claims throughout the document related to this.
Configuration menu - View commit details
-
Copy full SHA for a2bf473 - Browse repository at this point
Copy the full SHA a2bf473View commit details -
The language about how to refer to the `gen` keyword in older editions was changed in a recent commit from `k#gen` to `r#gen`. This was probably a search/replace error. Let's fix that.
Configuration menu - View commit details
-
Copy full SHA for caf93ba - Browse repository at this point
Copy the full SHA caf93baView commit details -
We meant to change `r#gen` to `k#gen` on one line to fix an apparent earlier search/replace error, and we erroneously changed it on a different line. Let's fix the correct line and fix the mistaken fix.
Configuration menu - View commit details
-
Copy full SHA for 8846955 - Browse repository at this point
Copy the full SHA 8846955View commit details
Commits on Mar 27, 2024
-
Add tracking issue for RFC 3513
We had already opened a tracking issue for this work, so let's fill that in here.
Configuration menu - View commit details
-
Copy full SHA for 32ffb27 - Browse repository at this point
Copy the full SHA 32ffb27View commit details -
In addition to giving the file the correct number, let's call this `gen-blocks` rather than `gen-fn` since we removed `gen fn` from the main body of this RFC.
Configuration menu - View commit details
-
Copy full SHA for 3f0159d - Browse repository at this point
Copy the full SHA 3f0159dView commit details -
Update feature name to
gen_blocks
The feature name in the draft was a placeholder. Let's update this to the actual feature name now in use.
Configuration menu - View commit details
-
Copy full SHA for 787e0e9 - Browse repository at this point
Copy the full SHA 787e0e9View commit details -
We had a mix between hard wrapped lines of various widths and unwrapped lines. Let's unwrap all lines.
Configuration menu - View commit details
-
Copy full SHA for ad74905 - Browse repository at this point
Copy the full SHA ad74905View commit details -
Add future possibility of implementing
FusedIterator
The main body of the RFC discusses how we might implement `FusedIterator` for the iterators produced by `gen` blocks, but this was not listed as a future possibility. Let's do that.
Configuration menu - View commit details
-
Copy full SHA for f6cd712 - Browse repository at this point
Copy the full SHA f6cd712View commit details -
Remove incorrect statement about pinning
There was a statement in the draft about, as a downside, something needing to be pinned for the entire iteration rather than just for each call to `next`. But, of course, under the pinning guarantees, these are equivalent. Once something is pinned, unless it is `Unpin`, it must be treated as pinned until it is destructed. Let's remove this statement.
Configuration menu - View commit details
-
Copy full SHA for 4bf6106 - Browse repository at this point
Copy the full SHA 4bf6106View commit details
Commits on Mar 28, 2024
-
Add open question about Rust 2015 and Rust 2018
In RFC 3101 we reserved in Rust 2021 prefixed identifiers such as `prefix#ident`. For this reason, we can make `gen` blocks available in Rust 2021 using `k#gen` as was anticipated in the (currently pending) RFC 3098. It's less clear what to do about Rust 2015 and Rust 2018, however, so let's mark this as an open question. (Thanks to tmandry for raising this point.)
Configuration menu - View commit details
-
Copy full SHA for 59be7f9 - Browse repository at this point
Copy the full SHA 59be7f9View commit details
Commits on Mar 29, 2024
-
We had been meaning to do some final copyediting prior to this RFC being merged, so let's do that. In addition to making the text a bit more regular and precise, fixing some minor errors, removing outdated information, and adding references between sections, we've tried to "tighten it up" a bit where possible. We've been careful to not change anything of semantic significance or otherwise of significance to the consensus.
Configuration menu - View commit details
-
Copy full SHA for 31c7b28 - Browse repository at this point
Copy the full SHA 31c7b28View commit details -
The Koka language provides an interesting alternative data point for how generators and other powerful control flow constructs could work in a typed language such as Rust. Let's include an example in the prior art section. (Thanks to zesterer for asking for this.)
Configuration menu - View commit details
-
Copy full SHA for 7eacd06 - Browse repository at this point
Copy the full SHA 7eacd06View commit details -
Using the no-op `Waker`, we can express generators and coroutines in Rust. Let's close our list of prior art examples with that.
Configuration menu - View commit details
-
Copy full SHA for a021905 - Browse repository at this point
Copy the full SHA a021905View commit details -
Add note about
return yield EXPR
Under this RFC, it's possible to yield one last value concisely with `return yield EXPR`. Let's make a note of that. (Thanks to Nemo157 for pointing this out and to pnkfelix for suggesting that this be noted in the RFC.)
Configuration menu - View commit details
-
Copy full SHA for 354abf6 - Browse repository at this point
Copy the full SHA 354abf6View commit details
Commits on Mar 30, 2024
-
Use RLE as a stronger motivating example
The motivating example we had given for `gen` blocks admitted too easy an implementation with existing stable iterator combinators. Let's make the example more *motivating* by showing a simple algorithm, run-length encoding, that's more difficult to implement in other ways. (Thanks to Ralf Jung for pointing out the need for a better example.)
Configuration menu - View commit details
-
Copy full SHA for 22f7267 - Browse repository at this point
Copy the full SHA 22f7267View commit details