Skip to content

Commit 3a6ee88

Browse files
committed
s/generator/coroutine/
1 parent e2ecce7 commit 3a6ee88

File tree

9 files changed

+38
-38
lines changed

9 files changed

+38
-38
lines changed

src/helpers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
492492
// `Variants::Multiple`.
493493
match v.layout.variants {
494494
Variants::Multiple { .. } => {
495-
// A multi-variant enum, or generator, or so.
495+
// A multi-variant enum, or coroutine, or so.
496496
// Treat this like a union: without reading from memory,
497497
// we cannot determine the variant we are in. Reading from
498498
// memory would be subject to Stacked Borrows rules, leading

tests/fail/generator-pinned-moved.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//@compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows
2-
#![feature(generators, generator_trait)]
2+
#![feature(coroutines, coroutine_trait)]
33

44
use std::{
55
ops::{Coroutine, CoroutineState},
@@ -35,12 +35,12 @@ where
3535
}
3636

3737
fn main() {
38-
let mut generator_iterator_2 = {
39-
let mut generator_iterator = Box::new(CoroutineIteratorAdapter(firstn()));
40-
generator_iterator.next(); // pin it
38+
let mut coroutine_iterator_2 = {
39+
let mut coroutine_iterator = Box::new(CoroutineIteratorAdapter(firstn()));
40+
coroutine_iterator.next(); // pin it
4141

42-
Box::new(*generator_iterator) // move it
43-
}; // *deallocate* generator_iterator
42+
Box::new(*coroutine_iterator) // move it
43+
}; // *deallocate* coroutine_iterator
4444

45-
generator_iterator_2.next(); // and use moved value
45+
coroutine_iterator_2.next(); // and use moved value
4646
}

tests/fail/generator-pinned-moved.stderr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,25 @@ LL | *num += 1;
99
help: ALLOC was allocated here:
1010
--> $DIR/generator-pinned-moved.rs:LL:CC
1111
|
12-
LL | let mut generator_iterator = Box::new(CoroutineIteratorAdapter(firstn()));
12+
LL | let mut coroutine_iterator = Box::new(CoroutineIteratorAdapter(firstn()));
1313
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1414
help: ALLOC was deallocated here:
1515
--> $DIR/generator-pinned-moved.rs:LL:CC
1616
|
17-
LL | }; // *deallocate* generator_iterator
17+
LL | }; // *deallocate* coroutine_iterator
1818
| ^
1919
= note: BACKTRACE (of the first span):
2020
= note: inside closure at $DIR/generator-pinned-moved.rs:LL:CC
21-
note: inside `<CoroutineIteratorAdapter<{static generator@$DIR/generator-pinned-moved.rs:LL:CC}> as std::iter::Iterator>::next`
21+
note: inside `<CoroutineIteratorAdapter<{static coroutine@$DIR/generator-pinned-moved.rs:LL:CC}> as std::iter::Iterator>::next`
2222
--> $DIR/generator-pinned-moved.rs:LL:CC
2323
|
2424
LL | match me.resume(()) {
2525
| ^^^^^^^^^^^^^
26-
= note: inside `<std::boxed::Box<CoroutineIteratorAdapter<{static generator@$DIR/generator-pinned-moved.rs:LL:CC}>> as std::iter::Iterator>::next` at RUSTLIB/alloc/src/boxed.rs:LL:CC
26+
= note: inside `<std::boxed::Box<CoroutineIteratorAdapter<{static coroutine@$DIR/generator-pinned-moved.rs:LL:CC}>> as std::iter::Iterator>::next` at RUSTLIB/alloc/src/boxed.rs:LL:CC
2727
note: inside `main`
2828
--> $DIR/generator-pinned-moved.rs:LL:CC
2929
|
30-
LL | generator_iterator_2.next(); // and use moved value
30+
LL | coroutine_iterator_2.next(); // and use moved value
3131
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
3232

3333
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

tests/pass/generator.rs renamed to tests/pass/coroutine.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//@revisions: stack tree
22
//@[tree]compile-flags: -Zmiri-tree-borrows
3-
#![feature(generators, generator_trait, never_type)]
3+
#![feature(coroutines, coroutine_trait, never_type)]
44

55
use std::fmt::Debug;
66
use std::mem::ManuallyDrop;
@@ -21,8 +21,8 @@ fn basic() {
2121
let mut t = unsafe { Pin::new_unchecked(&mut t) };
2222
loop {
2323
let state = t.as_mut().resume(());
24-
// Test if the generator is valid (according to type invariants).
25-
// For self-referential generators however this is UB!
24+
// Test if the coroutine is valid (according to type invariants).
25+
// For self-referential coroutines however this is UB!
2626
if !self_referential {
2727
let _ = unsafe { ManuallyDrop::new(ptr::read(t.as_mut().get_unchecked_mut())) };
2828
}
@@ -86,7 +86,7 @@ fn basic() {
8686
yield 1;
8787
});
8888

89-
// also test self-referential generators
89+
// also test self-referential coroutines
9090
assert_eq!(
9191
finish(5, true, static || {
9292
let mut x = 5;
@@ -145,7 +145,7 @@ fn smoke_resume_arg() {
145145

146146
for (input, out) in inout {
147147
assert_eq!(gen.as_mut().resume(input), out);
148-
// Test if the generator is valid (according to type invariants).
148+
// Test if the coroutine is valid (according to type invariants).
149149
let _ = unsafe { ManuallyDrop::new(ptr::read(gen.as_mut().get_unchecked_mut())) };
150150
}
151151
}

tests/pass/move-data-across-await-point.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ async fn data_moved_async() {
1515
// `raw_pointer` points to the original location where the Vec was stored in the caller.
1616
// `data` is where that Vec (to be precise, its ptr+capacity+len on-stack data)
1717
// got moved to. Those will usually not be the same since the Vec got moved twice
18-
// (into the function call, and then into the generator upvar).
18+
// (into the function call, and then into the coroutine upvar).
1919
assert_ne!(raw_pointer, raw_pointer2);
2020
unsafe {
2121
// This writes into the `x` in `data_moved_async`, re-initializing it.

tests/pass/stacked-borrows/generators-self-referential.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// See https://github.com/rust-lang/unsafe-code-guidelines/issues/148:
22
// this fails when Stacked Borrows is strictly applied even to `!Unpin` types.
3-
#![feature(generators, generator_trait)]
3+
#![feature(coroutines, coroutine_trait)]
44

55
use std::{
66
ops::{Coroutine, CoroutineState},
@@ -24,8 +24,8 @@ fn firstn() -> impl Coroutine<Yield = u64, Return = ()> {
2424
}
2525

2626
fn main() {
27-
let mut generator_iterator = firstn();
28-
let mut pin = unsafe { Pin::new_unchecked(&mut generator_iterator) };
27+
let mut coroutine_iterator = firstn();
28+
let mut pin = unsafe { Pin::new_unchecked(&mut coroutine_iterator) };
2929
let mut sum = 0;
3030
while let CoroutineState::Yielded(x) = pin.as_mut().resume(()) {
3131
sum += x;

tests/pass/stacked-borrows/stacked-borrows.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ fn wide_raw_ptr_in_tuple() {
223223
fn not_unpin_not_protected() {
224224
// `&mut !Unpin`, at least for now, does not get `noalias` nor `dereferenceable`, so we also
225225
// don't add protectors. (We could, but until we have a better idea for where we want to go with
226-
// the self-referential-generator situation, it does not seem worth the potential trouble.)
226+
// the self-referential-coroutine situation, it does not seem worth the potential trouble.)
227227
use std::marker::PhantomPinned;
228228

229229
pub struct NotUnpin(i32, PhantomPinned);

tests/pass/track-caller-attribute.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#![feature(core_intrinsics)]
22
#![feature(stmt_expr_attributes)]
33
#![feature(closure_track_caller)]
4-
#![feature(generator_trait)]
5-
#![feature(generators)]
4+
#![feature(coroutine_trait)]
5+
#![feature(coroutines)]
66

77
use std::ops::{Coroutine, CoroutineState};
88
use std::panic::Location;
@@ -210,9 +210,9 @@ fn test_closure() {
210210
assert_eq!(non_tracked_loc.column(), 33);
211211
}
212212

213-
fn test_generator() {
213+
fn test_coroutine() {
214214
#[track_caller]
215-
fn mono_generator<F: Coroutine<String, Yield = (&'static str, String, Loc), Return = ()>>(
215+
fn mono_coroutine<F: Coroutine<String, Yield = (&'static str, String, Loc), Return = ()>>(
216216
val: Pin<&mut F>,
217217
) -> (&'static str, String, Loc) {
218218
match val.resume("Mono".to_string()) {
@@ -222,7 +222,7 @@ fn test_generator() {
222222
}
223223

224224
#[track_caller]
225-
fn dyn_generator(
225+
fn dyn_coroutine(
226226
val: Pin<&mut dyn Coroutine<String, Yield = (&'static str, String, Loc), Return = ()>>,
227227
) -> (&'static str, String, Loc) {
228228
match val.resume("Dyn".to_string()) {
@@ -232,32 +232,32 @@ fn test_generator() {
232232
}
233233

234234
#[rustfmt::skip]
235-
let generator = #[track_caller] |arg: String| {
235+
let coroutine = #[track_caller] |arg: String| {
236236
yield ("first", arg.clone(), Location::caller());
237237
yield ("second", arg.clone(), Location::caller());
238238
};
239239

240-
let mut pinned = Box::pin(generator);
241-
let (dyn_ret, dyn_arg, dyn_loc) = dyn_generator(pinned.as_mut());
240+
let mut pinned = Box::pin(coroutine);
241+
let (dyn_ret, dyn_arg, dyn_loc) = dyn_coroutine(pinned.as_mut());
242242
assert_eq!(dyn_ret, "first");
243243
assert_eq!(dyn_arg, "Dyn".to_string());
244244
// The `Coroutine` trait does not have `#[track_caller]` on `resume`, so
245245
// this will not match.
246246
assert_ne!(dyn_loc.file(), file!());
247247

248-
let (mono_ret, mono_arg, mono_loc) = mono_generator(pinned.as_mut());
248+
let (mono_ret, mono_arg, mono_loc) = mono_coroutine(pinned.as_mut());
249249
let mono_line = line!() - 1;
250250
assert_eq!(mono_ret, "second");
251-
// The generator ignores the argument to the second `resume` call
251+
// The coroutine ignores the argument to the second `resume` call
252252
assert_eq!(mono_arg, "Dyn".to_string());
253253
assert_eq!(mono_loc.file(), file!());
254254
assert_eq!(mono_loc.line(), mono_line);
255255
assert_eq!(mono_loc.column(), 42);
256256

257257
#[rustfmt::skip]
258-
let non_tracked_generator = || { yield Location::caller(); };
259-
let non_tracked_line = line!() - 1; // This is the line of the generator, not its caller
260-
let non_tracked_loc = match Box::pin(non_tracked_generator).as_mut().resume(()) {
258+
let non_tracked_coroutine = || { yield Location::caller(); };
259+
let non_tracked_line = line!() - 1; // This is the line of the coroutine, not its caller
260+
let non_tracked_loc = match Box::pin(non_tracked_coroutine).as_mut().resume(()) {
261261
CoroutineState::Yielded(val) => val,
262262
_ => unreachable!(),
263263
};
@@ -272,5 +272,5 @@ fn main() {
272272
test_trait_obj();
273273
test_trait_obj2();
274274
test_closure();
275-
test_generator();
275+
test_coroutine();
276276
}

tests/pass/tree_borrows/tree-borrows.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ fn wide_raw_ptr_in_tuple() {
315315
fn not_unpin_not_protected() {
316316
// `&mut !Unpin`, at least for now, does not get `noalias` nor `dereferenceable`, so we also
317317
// don't add protectors. (We could, but until we have a better idea for where we want to go with
318-
// the self-referential-generator situation, it does not seem worth the potential trouble.)
318+
// the self-referential-coroutine situation, it does not seem worth the potential trouble.)
319319
use std::marker::PhantomPinned;
320320

321321
pub struct NotUnpin(i32, PhantomPinned);

0 commit comments

Comments
 (0)