Skip to content

Commit 258af95

Browse files
committed
Replace all uses of generator in markdown documentation with coroutine
1 parent 6fa47e1 commit 258af95

File tree

8 files changed

+52
-52
lines changed

8 files changed

+52
-52
lines changed

compiler/rustc_error_codes/src/error_codes/E0626.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
This error occurs because a borrow in a generator persists across a
1+
This error occurs because a borrow in a coroutine persists across a
22
yield point.
33

44
Erroneous code example:
55

66
```compile_fail,E0626
7-
# #![feature(generators, generator_trait, pin)]
7+
# #![feature(coroutines, coroutine_trait, pin)]
88
# use std::ops::Coroutine;
99
# use std::pin::Pin;
1010
let mut b = || {
@@ -23,7 +23,7 @@ resolve the previous example by removing the borrow and just storing
2323
the integer by value:
2424

2525
```
26-
# #![feature(generators, generator_trait, pin)]
26+
# #![feature(coroutines, coroutine_trait, pin)]
2727
# use std::ops::Coroutine;
2828
# use std::pin::Pin;
2929
let mut b = || {
@@ -41,7 +41,7 @@ in those cases, something like the `Rc` or `Arc` types may be useful.
4141
This error also frequently arises with iteration:
4242

4343
```compile_fail,E0626
44-
# #![feature(generators, generator_trait, pin)]
44+
# #![feature(coroutines, coroutine_trait, pin)]
4545
# use std::ops::Coroutine;
4646
# use std::pin::Pin;
4747
let mut b = || {
@@ -57,7 +57,7 @@ Such cases can sometimes be resolved by iterating "by value" (or using
5757
`into_iter()`) to avoid borrowing:
5858

5959
```
60-
# #![feature(generators, generator_trait, pin)]
60+
# #![feature(coroutines, coroutine_trait, pin)]
6161
# use std::ops::Coroutine;
6262
# use std::pin::Pin;
6363
let mut b = || {
@@ -72,7 +72,7 @@ Pin::new(&mut b).resume(());
7272
If taking ownership is not an option, using indices can work too:
7373

7474
```
75-
# #![feature(generators, generator_trait, pin)]
75+
# #![feature(coroutines, coroutine_trait, pin)]
7676
# use std::ops::Coroutine;
7777
# use std::pin::Pin;
7878
let mut b = || {

compiler/rustc_error_codes/src/error_codes/E0627.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
A yield expression was used outside of the generator literal.
1+
A yield expression was used outside of the coroutine literal.
22

33
Erroneous code example:
44

55
```compile_fail,E0627
6-
#![feature(generators, generator_trait)]
6+
#![feature(coroutines, coroutine_trait)]
77
8-
fn fake_generator() -> &'static str {
8+
fn fake_coroutine() -> &'static str {
99
yield 1;
1010
return "foo"
1111
}
1212
1313
fn main() {
14-
let mut generator = fake_generator;
14+
let mut coroutine = fake_coroutine;
1515
}
1616
```
1717

18-
The error occurs because keyword `yield` can only be used inside the generator
19-
literal. This can be fixed by constructing the generator correctly.
18+
The error occurs because keyword `yield` can only be used inside the coroutine
19+
literal. This can be fixed by constructing the coroutine correctly.
2020

2121
```
22-
#![feature(generators, generator_trait)]
22+
#![feature(coroutines, coroutine_trait)]
2323
2424
fn main() {
25-
let mut generator = || {
25+
let mut coroutine = || {
2626
yield 1;
2727
return "foo"
2828
};

compiler/rustc_error_codes/src/error_codes/E0628.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
1-
More than one parameter was used for a generator.
1+
More than one parameter was used for a coroutine.
22

33
Erroneous code example:
44

55
```compile_fail,E0628
6-
#![feature(generators, generator_trait)]
6+
#![feature(coroutines, coroutine_trait)]
77
88
fn main() {
9-
let generator = |a: i32, b: i32| {
10-
// error: too many parameters for a generator
9+
let coroutine = |a: i32, b: i32| {
10+
// error: too many parameters for a coroutine
1111
// Allowed only 0 or 1 parameter
1212
yield a;
1313
};
1414
}
1515
```
1616

1717
At present, it is not permitted to pass more than one explicit
18-
parameter for a generator.This can be fixed by using
19-
at most 1 parameter for the generator. For example, we might resolve
18+
parameter for a coroutine.This can be fixed by using
19+
at most 1 parameter for the coroutine. For example, we might resolve
2020
the previous example by passing only one parameter.
2121

2222
```
23-
#![feature(generators, generator_trait)]
23+
#![feature(coroutines, coroutine_trait)]
2424
2525
fn main() {
26-
let generator = |a: i32| {
26+
let coroutine = |a: i32| {
2727
yield a;
2828
};
2929
}

compiler/rustc_error_codes/src/error_codes/E0698.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#### Note: this error code is no longer emitted by the compiler.
22

3-
When using generators (or async) all type variables must be bound so a
4-
generator can be constructed.
3+
When using coroutines (or async) all type variables must be bound so a
4+
coroutine can be constructed.
55

66
Erroneous code example:
77

@@ -15,7 +15,7 @@ async fn foo() {
1515

1616
In the above example `T` is unknowable by the compiler.
1717
To fix this you must bind `T` to a concrete type such as `String`
18-
so that a generator can then be constructed:
18+
so that a coroutine can then be constructed:
1919

2020
```edition2018
2121
async fn bar<T>() -> () {}

compiler/rustc_error_codes/src/error_codes/E0727.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ A `yield` clause was used in an `async` context.
33
Erroneous code example:
44

55
```compile_fail,E0727,edition2018
6-
#![feature(generators)]
6+
#![feature(coroutines)]
77
88
fn main() {
9-
let generator = || {
9+
let coroutine = || {
1010
async {
1111
yield;
1212
}
@@ -20,10 +20,10 @@ which is not yet supported.
2020
To fix this error, you have to move `yield` out of the `async` block:
2121

2222
```edition2018
23-
#![feature(generators)]
23+
#![feature(coroutines)]
2424
2525
fn main() {
26-
let generator = || {
26+
let coroutine = || {
2727
yield;
2828
};
2929
}

src/doc/unstable-book/src/language-features/closure-track-caller.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ The tracking issue for this feature is: [#87417]
66

77
------------------------
88

9-
Allows using the `#[track_caller]` attribute on closures and generators.
10-
Calls made to the closure or generator will have caller information
9+
Allows using the `#[track_caller]` attribute on closures and coroutines.
10+
Calls made to the closure or coroutine will have caller information
1111
available through `std::panic::Location::caller()`, just like using
1212
`#[track_caller]` on a function.

src/doc/unstable-book/src/the-unstable-book.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,31 @@ each one organized by a "feature flag." That is, when using an unstable
55
feature of Rust, you must use a flag, like this:
66

77
```rust
8-
#![feature(generators, generator_trait)]
8+
#![feature(coroutines, coroutine_trait)]
99

10-
use std::ops::{Generator, GeneratorState};
10+
use std::ops::{Coroutine, CoroutineState};
1111
use std::pin::Pin;
1212

1313
fn main() {
14-
let mut generator = || {
14+
let mut coroutine = || {
1515
yield 1;
1616
return "foo"
1717
};
1818

19-
match Pin::new(&mut generator).resume(()) {
20-
GeneratorState::Yielded(1) => {}
19+
match Pin::new(&mut coroutine).resume(()) {
20+
CoroutineState::Yielded(1) => {}
2121
_ => panic!("unexpected value from resume"),
2222
}
23-
match Pin::new(&mut generator).resume(()) {
24-
GeneratorState::Complete("foo") => {}
23+
match Pin::new(&mut coroutine).resume(()) {
24+
CoroutineState::Complete("foo") => {}
2525
_ => panic!("unexpected value from resume"),
2626
}
2727
}
2828
```
2929

30-
The `generators` feature [has a chapter][generators] describing how to use it.
30+
The `coroutines` feature [has a chapter][coroutines] describing how to use it.
3131

32-
[generators]: language-features/generators.md
32+
[coroutines]: language-features/coroutines.md
3333

3434
Because this documentation relates to unstable features, we make no guarantees
3535
that what is contained here is accurate or up to date. It's developed on a

tests/run-coverage/yield.coverage

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
1-
LL| |#![feature(generators, generator_trait)]
1+
LL| |#![feature(coroutines, coroutine_trait)]
22
LL| |#![allow(unused_assignments)]
33
LL| |
4-
LL| |use std::ops::{Generator, GeneratorState};
4+
LL| |use std::ops::{Coroutine, CoroutineState};
55
LL| |use std::pin::Pin;
66
LL| |
77
LL| 1|fn main() {
8-
LL| 1| let mut generator = || {
8+
LL| 1| let mut coroutine = || {
99
LL| 1| yield 1;
1010
LL| 1| return "foo";
1111
LL| 1| };
1212
LL| |
13-
LL| 1| match Pin::new(&mut generator).resume(()) {
14-
LL| 1| GeneratorState::Yielded(1) => {}
13+
LL| 1| match Pin::new(&mut coroutine).resume(()) {
14+
LL| 1| CoroutineState::Yielded(1) => {}
1515
LL| 0| _ => panic!("unexpected value from resume"),
1616
LL| | }
17-
LL| 1| match Pin::new(&mut generator).resume(()) {
18-
LL| 1| GeneratorState::Complete("foo") => {}
17+
LL| 1| match Pin::new(&mut coroutine).resume(()) {
18+
LL| 1| CoroutineState::Complete("foo") => {}
1919
LL| 0| _ => panic!("unexpected value from resume"),
2020
LL| | }
2121
LL| |
22-
LL| 1| let mut generator = || {
22+
LL| 1| let mut coroutine = || {
2323
LL| 1| yield 1;
2424
LL| 1| yield 2;
2525
LL| 0| yield 3;
2626
LL| 0| return "foo";
2727
LL| 0| };
2828
LL| |
29-
LL| 1| match Pin::new(&mut generator).resume(()) {
30-
LL| 1| GeneratorState::Yielded(1) => {}
29+
LL| 1| match Pin::new(&mut coroutine).resume(()) {
30+
LL| 1| CoroutineState::Yielded(1) => {}
3131
LL| 0| _ => panic!("unexpected value from resume"),
3232
LL| | }
33-
LL| 1| match Pin::new(&mut generator).resume(()) {
34-
LL| 1| GeneratorState::Yielded(2) => {}
33+
LL| 1| match Pin::new(&mut coroutine).resume(()) {
34+
LL| 1| CoroutineState::Yielded(2) => {}
3535
LL| 0| _ => panic!("unexpected value from resume"),
3636
LL| | }
3737
LL| 1|}

0 commit comments

Comments
 (0)