Auto merge of #116447 - oli-obk:gen_fn, r=compiler-errors
Implement `gen` blocks in the 2024 edition Coroutines tracking issue https://github.com/rust-lang/rust/issues/43122 `gen` block tracking issue https://github.com/rust-lang/rust/issues/117078 This PR implements `gen` blocks that implement `Iterator`. Most of the logic with `async` blocks is shared, and thus I renamed various types that were referring to `async` specifically. An example usage of `gen` blocks is ```rust fn foo() -> impl Iterator<Item = i32> { gen { yield 42; for i in 5..18 { if i.is_even() { continue } yield i * 2; } } } ``` The limitations (to be resolved) of the implementation are listed in the tracking issue
This commit is contained in:
commit
2cad938a81
75 changed files with 1096 additions and 148 deletions
|
@ -98,6 +98,7 @@ symbols! {
|
|||
Builtin: "builtin",
|
||||
Catch: "catch",
|
||||
Default: "default",
|
||||
Gen: "gen",
|
||||
MacroRules: "macro_rules",
|
||||
Raw: "raw",
|
||||
Union: "union",
|
||||
|
@ -225,6 +226,7 @@ symbols! {
|
|||
IpAddr,
|
||||
IrTyKind,
|
||||
Is,
|
||||
Item,
|
||||
ItemContext,
|
||||
IterEmpty,
|
||||
IterOnce,
|
||||
|
@ -818,6 +820,7 @@ symbols! {
|
|||
future_trait,
|
||||
gdb_script_file,
|
||||
ge,
|
||||
gen_blocks,
|
||||
gen_future,
|
||||
gen_kill,
|
||||
generator_clone,
|
||||
|
@ -1779,6 +1782,7 @@ symbols! {
|
|||
xmm_reg,
|
||||
yeet_desugar_details,
|
||||
yeet_expr,
|
||||
yield_expr,
|
||||
ymm_reg,
|
||||
zmm_reg,
|
||||
}
|
||||
|
@ -2189,8 +2193,9 @@ impl Symbol {
|
|||
self >= kw::Abstract && self <= kw::Yield
|
||||
}
|
||||
|
||||
fn is_unused_keyword_conditional(self, edition: impl FnOnce() -> Edition) -> bool {
|
||||
self == kw::Try && edition() >= Edition::Edition2018
|
||||
fn is_unused_keyword_conditional(self, edition: impl Copy + FnOnce() -> Edition) -> bool {
|
||||
self == kw::Try && edition().at_least_rust_2018()
|
||||
|| self == kw::Gen && edition().at_least_rust_2024()
|
||||
}
|
||||
|
||||
pub fn is_reserved(self, edition: impl Copy + FnOnce() -> Edition) -> bool {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue