diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2023-10-19 16:06:43 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2023-10-20 21:10:38 +0000 |
| commit | 60956837cfbf22bd8edd80f57a856e141f7deb8c (patch) | |
| tree | 4cc50671566d7fb411d8e933348d6785d6bc55cc /tests | |
| parent | 96027d945b9d8cae622a2fa4e70d8040be2964f3 (diff) | |
| download | rust-60956837cfbf22bd8edd80f57a856e141f7deb8c.tar.gz rust-60956837cfbf22bd8edd80f57a856e141f7deb8c.zip | |
s/Generator/Coroutine/
Diffstat (limited to 'tests')
110 files changed, 349 insertions, 349 deletions
diff --git a/tests/codegen/generator-debug-msvc.rs b/tests/codegen/generator-debug-msvc.rs index 9d70ccdef03..c8e6d19b793 100644 --- a/tests/codegen/generator-debug-msvc.rs +++ b/tests/codegen/generator-debug-msvc.rs @@ -8,9 +8,9 @@ // only-msvc #![feature(generators, generator_trait)] -use std::ops::Generator; +use std::ops::Coroutine; -fn generator_test() -> impl Generator<Yield = i32, Return = ()> { +fn generator_test() -> impl Coroutine<Yield = i32, Return = ()> { || { yield 0; let s = String::from("foo"); diff --git a/tests/codegen/generator-debug.rs b/tests/codegen/generator-debug.rs index 3ec860f2cbc..e87684d6b8b 100644 --- a/tests/codegen/generator-debug.rs +++ b/tests/codegen/generator-debug.rs @@ -8,9 +8,9 @@ // ignore-msvc #![feature(generators, generator_trait)] -use std::ops::Generator; +use std::ops::Coroutine; -fn generator_test() -> impl Generator<Yield = i32, Return = ()> { +fn generator_test() -> impl Coroutine<Yield = i32, Return = ()> { || { yield 0; let s = String::from("foo"); diff --git a/tests/coverage-map/status-quo/generator.rs b/tests/coverage-map/status-quo/generator.rs index 4319991021e..4ae4f71fcf8 100644 --- a/tests/coverage-map/status-quo/generator.rs +++ b/tests/coverage-map/status-quo/generator.rs @@ -1,6 +1,6 @@ #![feature(generators, generator_trait)] -use std::ops::{Generator, GeneratorState}; +use std::ops::{Coroutine, CoroutineState}; use std::pin::Pin; // The following implementation of a function called from a `yield` statement @@ -20,11 +20,11 @@ fn main() { }; match Pin::new(&mut generator).resume(()) { - GeneratorState::Yielded(Ok(1)) => {} + CoroutineState::Yielded(Ok(1)) => {} _ => panic!("unexpected return from resume"), } match Pin::new(&mut generator).resume(()) { - GeneratorState::Complete("foo") => {} + CoroutineState::Complete("foo") => {} _ => panic!("unexpected return from resume"), } } diff --git a/tests/coverage-map/status-quo/yield.rs b/tests/coverage-map/status-quo/yield.rs index 361275c9215..b347d1967e9 100644 --- a/tests/coverage-map/status-quo/yield.rs +++ b/tests/coverage-map/status-quo/yield.rs @@ -1,7 +1,7 @@ #![feature(generators, generator_trait)] #![allow(unused_assignments)] -use std::ops::{Generator, GeneratorState}; +use std::ops::{Coroutine, CoroutineState}; use std::pin::Pin; fn main() { @@ -11,11 +11,11 @@ fn main() { }; match Pin::new(&mut generator).resume(()) { - GeneratorState::Yielded(1) => {} + CoroutineState::Yielded(1) => {} _ => panic!("unexpected value from resume"), } match Pin::new(&mut generator).resume(()) { - GeneratorState::Complete("foo") => {} + CoroutineState::Complete("foo") => {} _ => panic!("unexpected value from resume"), } @@ -27,11 +27,11 @@ fn main() { }; match Pin::new(&mut generator).resume(()) { - GeneratorState::Yielded(1) => {} + CoroutineState::Yielded(1) => {} _ => panic!("unexpected value from resume"), } match Pin::new(&mut generator).resume(()) { - GeneratorState::Yielded(2) => {} + CoroutineState::Yielded(2) => {} _ => panic!("unexpected value from resume"), } } diff --git a/tests/debuginfo/function-names.rs b/tests/debuginfo/function-names.rs index d9aa03fee62..7b138e2b41b 100644 --- a/tests/debuginfo/function-names.rs +++ b/tests/debuginfo/function-names.rs @@ -31,8 +31,8 @@ // gdb-check:[...]static fn function_names::main::{closure#0}(*mut function_names::main::{closure_env#0}); // gdb-check:[...]static fn function_names::{impl#2}::impl_function::{closure#0}<i32, i32>(*mut function_names::{impl#2}::impl_function::{closure_env#0}<i32, i32>); -// Generator -// Generators don't seem to appear in GDB's symbol table. +// Coroutine +// Coroutines don't seem to appear in GDB's symbol table. // Const generic parameter // gdb-command:info functions -q function_names::const_generic_fn.* @@ -69,7 +69,7 @@ // cdb-check:[...] a!function_names::main::closure$0 (void) // cdb-check:[...] a!function_names::generic_func::closure$0<i32> (void) -// Generator +// Coroutine // cdb-command:x a!function_names::*::generator* // cdb-check:[...] a!function_names::main::generator$1 (void) @@ -86,7 +86,7 @@ #![feature(adt_const_params, generators, generator_trait)] #![allow(incomplete_features)] -use std::ops::Generator; +use std::ops::Coroutine; use std::pin::Pin; use Mod1::TestTrait2; @@ -110,7 +110,7 @@ fn main() { let closure = || TestStruct1; closure(); - // Generator + // Coroutine let mut generator = || { yield; return; diff --git a/tests/debuginfo/generator-locals.rs b/tests/debuginfo/generator-locals.rs index fd46c1a8b4d..ca84803d287 100644 --- a/tests/debuginfo/generator-locals.rs +++ b/tests/debuginfo/generator-locals.rs @@ -57,7 +57,7 @@ #![feature(omit_gdb_pretty_printer_section, generators, generator_trait)] #![omit_gdb_pretty_printer_section] -use std::ops::Generator; +use std::ops::Coroutine; use std::pin::Pin; fn main() { diff --git a/tests/debuginfo/generator-objects.rs b/tests/debuginfo/generator-objects.rs index 11c4ae2f659..d36b344a804 100644 --- a/tests/debuginfo/generator-objects.rs +++ b/tests/debuginfo/generator-objects.rs @@ -66,7 +66,7 @@ #![feature(omit_gdb_pretty_printer_section, generators, generator_trait)] #![omit_gdb_pretty_printer_section] -use std::ops::Generator; +use std::ops::Coroutine; use std::pin::Pin; fn main() { diff --git a/tests/debuginfo/issue-57822.rs b/tests/debuginfo/issue-57822.rs index 62e7eb13c2d..23d9ddc19cc 100644 --- a/tests/debuginfo/issue-57822.rs +++ b/tests/debuginfo/issue-57822.rs @@ -29,7 +29,7 @@ #![feature(omit_gdb_pretty_printer_section, generators, generator_trait)] #![omit_gdb_pretty_printer_section] -use std::ops::Generator; +use std::ops::Coroutine; use std::pin::Pin; fn main() { diff --git a/tests/mir-opt/building/async_await.a-{closure#0}.generator_resume.0.mir b/tests/mir-opt/building/async_await.a-{closure#0}.generator_resume.0.mir index bc4ca06c113..c2e5d5cf400 100644 --- a/tests/mir-opt/building/async_await.a-{closure#0}.generator_resume.0.mir +++ b/tests/mir-opt/building/async_await.a-{closure#0}.generator_resume.0.mir @@ -1,5 +1,5 @@ // MIR for `a::{closure#0}` 0 generator_resume -/* generator_layout = GeneratorLayout { +/* generator_layout = CoroutineLayout { field_tys: {}, variant_fields: { Unresumed(0): [], diff --git a/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir b/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir index 4a60e353bf2..9df3c5b7e3a 100644 --- a/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir +++ b/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir @@ -1,14 +1,14 @@ // MIR for `b::{closure#0}` 0 generator_resume -/* generator_layout = GeneratorLayout { +/* generator_layout = CoroutineLayout { field_tys: { - _0: GeneratorSavedTy { - ty: Generator( + _0: CoroutineSavedTy { + ty: Coroutine( DefId(0:4 ~ async_await[ccf8]::a::{closure#0}), [ std::future::ResumeTy, (), (), - GeneratorWitness(DefId(0:4 ~ async_await[ccf8]::a::{closure#0}), []), + CoroutineWitness(DefId(0:4 ~ async_await[ccf8]::a::{closure#0}), []), (), ], Static, @@ -19,14 +19,14 @@ }, ignore_for_traits: false, }, - _1: GeneratorSavedTy { - ty: Generator( + _1: CoroutineSavedTy { + ty: Coroutine( DefId(0:4 ~ async_await[ccf8]::a::{closure#0}), [ std::future::ResumeTy, (), (), - GeneratorWitness(DefId(0:4 ~ async_await[ccf8]::a::{closure#0}), []), + CoroutineWitness(DefId(0:4 ~ async_await[ccf8]::a::{closure#0}), []), (), ], Static, diff --git a/tests/mir-opt/generator_drop_cleanup.main-{closure#0}.generator_drop.0.panic-abort.mir b/tests/mir-opt/generator_drop_cleanup.main-{closure#0}.generator_drop.0.panic-abort.mir index 524fbeb0fea..ccdca02f08e 100644 --- a/tests/mir-opt/generator_drop_cleanup.main-{closure#0}.generator_drop.0.panic-abort.mir +++ b/tests/mir-opt/generator_drop_cleanup.main-{closure#0}.generator_drop.0.panic-abort.mir @@ -1,7 +1,7 @@ // MIR for `main::{closure#0}` 0 generator_drop -/* generator_layout = GeneratorLayout { +/* generator_layout = CoroutineLayout { field_tys: { - _0: GeneratorSavedTy { + _0: CoroutineSavedTy { ty: std::string::String, source_info: SourceInfo { span: $DIR/generator_drop_cleanup.rs:12:13: 12:15 (#0), diff --git a/tests/mir-opt/generator_drop_cleanup.main-{closure#0}.generator_drop.0.panic-unwind.mir b/tests/mir-opt/generator_drop_cleanup.main-{closure#0}.generator_drop.0.panic-unwind.mir index c3f61169bfb..28e4c07cb7a 100644 --- a/tests/mir-opt/generator_drop_cleanup.main-{closure#0}.generator_drop.0.panic-unwind.mir +++ b/tests/mir-opt/generator_drop_cleanup.main-{closure#0}.generator_drop.0.panic-unwind.mir @@ -1,7 +1,7 @@ // MIR for `main::{closure#0}` 0 generator_drop -/* generator_layout = GeneratorLayout { +/* generator_layout = CoroutineLayout { field_tys: { - _0: GeneratorSavedTy { + _0: CoroutineSavedTy { ty: std::string::String, source_info: SourceInfo { span: $DIR/generator_drop_cleanup.rs:12:13: 12:15 (#0), diff --git a/tests/mir-opt/generator_tiny.main-{closure#0}.generator_resume.0.mir b/tests/mir-opt/generator_tiny.main-{closure#0}.generator_resume.0.mir index 7047a5baae5..45253444203 100644 --- a/tests/mir-opt/generator_tiny.main-{closure#0}.generator_resume.0.mir +++ b/tests/mir-opt/generator_tiny.main-{closure#0}.generator_resume.0.mir @@ -1,7 +1,7 @@ // MIR for `main::{closure#0}` 0 generator_resume -/* generator_layout = GeneratorLayout { +/* generator_layout = CoroutineLayout { field_tys: { - _0: GeneratorSavedTy { + _0: CoroutineSavedTy { ty: HasDrop, source_info: SourceInfo { span: $DIR/generator_tiny.rs:21:13: 21:15 (#0), @@ -21,9 +21,9 @@ }, } */ -fn main::{closure#0}(_1: Pin<&mut {generator@$DIR/generator_tiny.rs:20:16: 20:24}>, _2: u8) -> GeneratorState<(), ()> { +fn main::{closure#0}(_1: Pin<&mut {generator@$DIR/generator_tiny.rs:20:16: 20:24}>, _2: u8) -> CoroutineState<(), ()> { debug _x => _10; - let mut _0: std::ops::GeneratorState<(), ()>; + let mut _0: std::ops::CoroutineState<(), ()>; let _3: HasDrop; let mut _4: !; let mut _5: (); @@ -54,7 +54,7 @@ fn main::{closure#0}(_1: Pin<&mut {generator@$DIR/generator_tiny.rs:20:16: 20:24 StorageLive(_6); StorageLive(_7); _7 = (); - _0 = GeneratorState::<(), ()>::Yielded(move _7); + _0 = CoroutineState::<(), ()>::Yielded(move _7); discriminant((*(_1.0: &mut {generator@$DIR/generator_tiny.rs:20:16: 20:24}))) = 3; return; } diff --git a/tests/mir-opt/inline/inline_generator.main.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_generator.main.Inline.panic-abort.diff index 48d908fad88..c497f229b8c 100644 --- a/tests/mir-opt/inline/inline_generator.main.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/inline_generator.main.Inline.panic-abort.diff @@ -3,7 +3,7 @@ fn main() -> () { let mut _0: (); - let _1: std::ops::GeneratorState<i32, bool>; + let _1: std::ops::CoroutineState<i32, bool>; let mut _2: std::pin::Pin<&mut {generator@$DIR/inline_generator.rs:17:5: 17:8}>; let mut _3: &mut {generator@$DIR/inline_generator.rs:17:5: 17:8}; let mut _4: {generator@$DIR/inline_generator.rs:17:5: 17:8}; @@ -59,7 +59,7 @@ bb2: { - StorageDead(_3); -- _1 = <{generator@$DIR/inline_generator.rs:17:5: 17:8} as Generator<bool>>::resume(move _2, const false) -> [return: bb3, unwind unreachable]; +- _1 = <{generator@$DIR/inline_generator.rs:17:5: 17:8} as Coroutine<bool>>::resume(move _2, const false) -> [return: bb3, unwind unreachable]; + StorageDead(_4); + _0 = const (); + StorageDead(_1); @@ -88,7 +88,7 @@ + } + + bb6: { -+ _1 = GeneratorState::<i32, bool>::Yielded(move _8); ++ _1 = CoroutineState::<i32, bool>::Yielded(move _8); + discriminant((*_6)) = 3; + goto -> bb1; + } @@ -100,7 +100,7 @@ + bb8: { + StorageLive(_8); + StorageDead(_8); -+ _1 = GeneratorState::<i32, bool>::Complete(_5); ++ _1 = CoroutineState::<i32, bool>::Complete(_5); + discriminant((*_6)) = 1; + goto -> bb1; + } diff --git a/tests/mir-opt/inline/inline_generator.main.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_generator.main.Inline.panic-unwind.diff index 9cb84b314de..768b52bc539 100644 --- a/tests/mir-opt/inline/inline_generator.main.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/inline_generator.main.Inline.panic-unwind.diff @@ -3,7 +3,7 @@ fn main() -> () { let mut _0: (); - let _1: std::ops::GeneratorState<i32, bool>; + let _1: std::ops::CoroutineState<i32, bool>; let mut _2: std::pin::Pin<&mut {generator@$DIR/inline_generator.rs:17:5: 17:8}>; let mut _3: &mut {generator@$DIR/inline_generator.rs:17:5: 17:8}; let mut _4: {generator@$DIR/inline_generator.rs:17:5: 17:8}; @@ -45,7 +45,7 @@ - bb2: { + _2 = Pin::<&mut {generator@$DIR/inline_generator.rs:17:5: 17:8}> { pointer: move _3 }; StorageDead(_3); -- _1 = <{generator@$DIR/inline_generator.rs:17:5: 17:8} as Generator<bool>>::resume(move _2, const false) -> [return: bb3, unwind: bb5]; +- _1 = <{generator@$DIR/inline_generator.rs:17:5: 17:8} as Coroutine<bool>>::resume(move _2, const false) -> [return: bb3, unwind: bb5]; + StorageLive(_5); + _5 = const false; + StorageLive(_6); @@ -100,7 +100,7 @@ + } + + bb8: { -+ _1 = GeneratorState::<i32, bool>::Yielded(move _8); ++ _1 = CoroutineState::<i32, bool>::Yielded(move _8); + discriminant((*_6)) = 3; + goto -> bb1; + } @@ -112,7 +112,7 @@ + bb10: { + StorageLive(_8); + StorageDead(_8); -+ _1 = GeneratorState::<i32, bool>::Complete(_5); ++ _1 = CoroutineState::<i32, bool>::Complete(_5); + discriminant((*_6)) = 1; + goto -> bb1; + } diff --git a/tests/mir-opt/inline/inline_generator.rs b/tests/mir-opt/inline/inline_generator.rs index d96d1f98f14..a22f08330af 100644 --- a/tests/mir-opt/inline/inline_generator.rs +++ b/tests/mir-opt/inline/inline_generator.rs @@ -3,7 +3,7 @@ // compile-flags: -Zinline-mir-hint-threshold=1000 #![feature(generators, generator_trait)] -use std::ops::Generator; +use std::ops::Coroutine; use std::pin::Pin; // EMIT_MIR inline_generator.main.Inline.diff @@ -12,7 +12,7 @@ fn main() { } #[inline] -pub fn g() -> impl Generator<bool> { +pub fn g() -> impl Coroutine<bool> { #[inline] |a| { yield if a { 7 } else { 13 } } } diff --git a/tests/run-coverage/generator.rs b/tests/run-coverage/generator.rs index 4319991021e..4ae4f71fcf8 100644 --- a/tests/run-coverage/generator.rs +++ b/tests/run-coverage/generator.rs @@ -1,6 +1,6 @@ #![feature(generators, generator_trait)] -use std::ops::{Generator, GeneratorState}; +use std::ops::{Coroutine, CoroutineState}; use std::pin::Pin; // The following implementation of a function called from a `yield` statement @@ -20,11 +20,11 @@ fn main() { }; match Pin::new(&mut generator).resume(()) { - GeneratorState::Yielded(Ok(1)) => {} + CoroutineState::Yielded(Ok(1)) => {} _ => panic!("unexpected return from resume"), } match Pin::new(&mut generator).resume(()) { - GeneratorState::Complete("foo") => {} + CoroutineState::Complete("foo") => {} _ => panic!("unexpected return from resume"), } } diff --git a/tests/run-coverage/yield.rs b/tests/run-coverage/yield.rs index 361275c9215..b347d1967e9 100644 --- a/tests/run-coverage/yield.rs +++ b/tests/run-coverage/yield.rs @@ -1,7 +1,7 @@ #![feature(generators, generator_trait)] #![allow(unused_assignments)] -use std::ops::{Generator, GeneratorState}; +use std::ops::{Coroutine, CoroutineState}; use std::pin::Pin; fn main() { @@ -11,11 +11,11 @@ fn main() { }; match Pin::new(&mut generator).resume(()) { - GeneratorState::Yielded(1) => {} + CoroutineState::Yielded(1) => {} _ => panic!("unexpected value from resume"), } match Pin::new(&mut generator).resume(()) { - GeneratorState::Complete("foo") => {} + CoroutineState::Complete("foo") => {} _ => panic!("unexpected value from resume"), } @@ -27,11 +27,11 @@ fn main() { }; match Pin::new(&mut generator).resume(()) { - GeneratorState::Yielded(1) => {} + CoroutineState::Yielded(1) => {} _ => panic!("unexpected value from resume"), } match Pin::new(&mut generator).resume(()) { - GeneratorState::Yielded(2) => {} + CoroutineState::Yielded(2) => {} _ => panic!("unexpected value from resume"), } } diff --git a/tests/ui-fulldeps/internal-lints/ty_tykind_usage.rs b/tests/ui-fulldeps/internal-lints/ty_tykind_usage.rs index 3f7429a5fcc..ae7f341fe4e 100644 --- a/tests/ui-fulldeps/internal-lints/ty_tykind_usage.rs +++ b/tests/ui-fulldeps/internal-lints/ty_tykind_usage.rs @@ -29,8 +29,8 @@ fn main() { TyKind::FnPtr(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` TyKind::Dynamic(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` TyKind::Closure(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` - TyKind::Generator(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` - TyKind::GeneratorWitness(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` + TyKind::Coroutine(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` + TyKind::CoroutineWitness(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` TyKind::Never => (), //~ ERROR usage of `ty::TyKind::<kind>` TyKind::Tuple(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` TyKind::Alias(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` diff --git a/tests/ui/async-await/generator-not-future.rs b/tests/ui/async-await/generator-not-future.rs index 37d7cfa6fb7..a5b354021bd 100644 --- a/tests/ui/async-await/generator-not-future.rs +++ b/tests/ui/async-await/generator-not-future.rs @@ -2,20 +2,20 @@ #![feature(generators, generator_trait)] use std::future::Future; -use std::ops::Generator; +use std::ops::Coroutine; async fn async_fn() {} fn returns_async_block() -> impl Future<Output = ()> { async {} } -fn returns_generator() -> impl Generator<(), Yield = (), Return = ()> { +fn returns_generator() -> impl Coroutine<(), Yield = (), Return = ()> { || { let _: () = yield (); } } fn takes_future(_f: impl Future<Output = ()>) {} -fn takes_generator<ResumeTy>(_g: impl Generator<ResumeTy, Yield = (), Return = ()>) {} +fn takes_generator<ResumeTy>(_g: impl Coroutine<ResumeTy, Yield = (), Return = ()>) {} fn main() { // okay: diff --git a/tests/ui/async-await/generator-not-future.stderr b/tests/ui/async-await/generator-not-future.stderr index 540501b9826..3fd11b0a269 100644 --- a/tests/ui/async-await/generator-not-future.stderr +++ b/tests/ui/async-await/generator-not-future.stderr @@ -1,55 +1,55 @@ -error[E0277]: the trait bound `impl Future<Output = ()>: Generator<_>` is not satisfied +error[E0277]: the trait bound `impl Future<Output = ()>: Coroutine<_>` is not satisfied --> $DIR/generator-not-future.rs:31:21 | LL | takes_generator(async_fn()); - | --------------- ^^^^^^^^^^ the trait `Generator<_>` is not implemented for `impl Future<Output = ()>` + | --------------- ^^^^^^^^^^ the trait `Coroutine<_>` is not implemented for `impl Future<Output = ()>` | | | required by a bound introduced by this call | note: required by a bound in `takes_generator` --> $DIR/generator-not-future.rs:18:39 | -LL | fn takes_generator<ResumeTy>(_g: impl Generator<ResumeTy, Yield = (), Return = ()>) {} +LL | fn takes_generator<ResumeTy>(_g: impl Coroutine<ResumeTy, Yield = (), Return = ()>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `takes_generator` -error[E0277]: the trait bound `impl Future<Output = ()>: Generator<_>` is not satisfied +error[E0277]: the trait bound `impl Future<Output = ()>: Coroutine<_>` is not satisfied --> $DIR/generator-not-future.rs:33:21 | LL | takes_generator(returns_async_block()); - | --------------- ^^^^^^^^^^^^^^^^^^^^^ the trait `Generator<_>` is not implemented for `impl Future<Output = ()>` + | --------------- ^^^^^^^^^^^^^^^^^^^^^ the trait `Coroutine<_>` is not implemented for `impl Future<Output = ()>` | | | required by a bound introduced by this call | note: required by a bound in `takes_generator` --> $DIR/generator-not-future.rs:18:39 | -LL | fn takes_generator<ResumeTy>(_g: impl Generator<ResumeTy, Yield = (), Return = ()>) {} +LL | fn takes_generator<ResumeTy>(_g: impl Coroutine<ResumeTy, Yield = (), Return = ()>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `takes_generator` -error[E0277]: the trait bound `{async block@$DIR/generator-not-future.rs:35:21: 35:29}: Generator<_>` is not satisfied +error[E0277]: the trait bound `{async block@$DIR/generator-not-future.rs:35:21: 35:29}: Coroutine<_>` is not satisfied --> $DIR/generator-not-future.rs:35:21 | LL | takes_generator(async {}); - | --------------- ^^^^^^^^ the trait `Generator<_>` is not implemented for `{async block@$DIR/generator-not-future.rs:35:21: 35:29}` + | --------------- ^^^^^^^^ the trait `Coroutine<_>` is not implemented for `{async block@$DIR/generator-not-future.rs:35:21: 35:29}` | | | required by a bound introduced by this call | note: required by a bound in `takes_generator` --> $DIR/generator-not-future.rs:18:39 | -LL | fn takes_generator<ResumeTy>(_g: impl Generator<ResumeTy, Yield = (), Return = ()>) {} +LL | fn takes_generator<ResumeTy>(_g: impl Coroutine<ResumeTy, Yield = (), Return = ()>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `takes_generator` -error[E0277]: `impl Generator<Yield = (), Return = ()>` is not a future +error[E0277]: `impl Coroutine<Yield = (), Return = ()>` is not a future --> $DIR/generator-not-future.rs:39:18 | LL | takes_future(returns_generator()); - | ------------ ^^^^^^^^^^^^^^^^^^^ `impl Generator<Yield = (), Return = ()>` is not a future + | ------------ ^^^^^^^^^^^^^^^^^^^ `impl Coroutine<Yield = (), Return = ()>` is not a future | | | required by a bound introduced by this call | - = help: the trait `Future` is not implemented for `impl Generator<Yield = (), Return = ()>` - = note: impl Generator<Yield = (), Return = ()> must be a future or must implement `IntoFuture` to be awaited + = help: the trait `Future` is not implemented for `impl Coroutine<Yield = (), Return = ()>` + = note: impl Coroutine<Yield = (), Return = ()> must be a future or must implement `IntoFuture` to be awaited note: required by a bound in `takes_future` --> $DIR/generator-not-future.rs:17:26 | diff --git a/tests/ui/async-await/issues/issue-65419/issue-65419-generator-resume-after-completion.rs b/tests/ui/async-await/issues/issue-65419/issue-65419-generator-resume-after-completion.rs index 9fc5667d684..2fd7823bd72 100644 --- a/tests/ui/async-await/issues/issue-65419/issue-65419-generator-resume-after-completion.rs +++ b/tests/ui/async-await/issues/issue-65419/issue-65419-generator-resume-after-completion.rs @@ -11,7 +11,7 @@ #![feature(generators, generator_trait)] use std::{ - ops::Generator, + ops::Coroutine, pin::Pin, }; diff --git a/tests/ui/coherence/coherence-with-generator.rs b/tests/ui/coherence/coherence-with-generator.rs index 5eb8dc2a468..4b1cefc3923 100644 --- a/tests/ui/coherence/coherence-with-generator.rs +++ b/tests/ui/coherence/coherence-with-generator.rs @@ -6,8 +6,8 @@ // revisions: stock specialized // [specialized]check-pass -type OpaqueGenerator = impl Sized; -fn defining_use() -> OpaqueGenerator { +type OpaqueCoroutine = impl Sized; +fn defining_use() -> OpaqueCoroutine { || { for i in 0..10 { yield i; @@ -17,8 +17,8 @@ fn defining_use() -> OpaqueGenerator { struct Wrapper<T>(T); trait Trait {} -impl Trait for Wrapper<OpaqueGenerator> {} +impl Trait for Wrapper<OpaqueCoroutine> {} impl<T: Sync> Trait for Wrapper<T> {} -//[stock]~^ ERROR conflicting implementations of trait `Trait` for type `Wrapper<OpaqueGenerator>` +//[stock]~^ ERROR conflicting implementations of trait `Trait` for type `Wrapper<OpaqueCoroutine>` fn main() {} diff --git a/tests/ui/coherence/coherence-with-generator.stock.stderr b/tests/ui/coherence/coherence-with-generator.stock.stderr index 478ac491264..7636227e534 100644 --- a/tests/ui/coherence/coherence-with-generator.stock.stderr +++ b/tests/ui/coherence/coherence-with-generator.stock.stderr @@ -1,10 +1,10 @@ -error[E0119]: conflicting implementations of trait `Trait` for type `Wrapper<OpaqueGenerator>` +error[E0119]: conflicting implementations of trait `Trait` for type `Wrapper<OpaqueCoroutine>` --> $DIR/coherence-with-generator.rs:21:1 | -LL | impl Trait for Wrapper<OpaqueGenerator> {} +LL | impl Trait for Wrapper<OpaqueCoroutine> {} | --------------------------------------- first implementation here LL | impl<T: Sync> Trait for Wrapper<T> {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Wrapper<OpaqueGenerator>` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Wrapper<OpaqueCoroutine>` error: aborting due to previous error diff --git a/tests/ui/drop/dynamic-drop.rs b/tests/ui/drop/dynamic-drop.rs index caef6358ea7..26eb3717948 100644 --- a/tests/ui/drop/dynamic-drop.rs +++ b/tests/ui/drop/dynamic-drop.rs @@ -9,7 +9,7 @@ use std::cell::{Cell, RefCell}; use std::mem::ManuallyDrop; -use std::ops::Generator; +use std::ops::Coroutine; use std::panic; use std::pin::Pin; diff --git a/tests/ui/error-codes/E0283.rs b/tests/ui/error-codes/E0283.rs index 0643af4b7e8..5134660e3f4 100644 --- a/tests/ui/error-codes/E0283.rs +++ b/tests/ui/error-codes/E0283.rs @@ -1,10 +1,10 @@ -trait Generator { +trait Coroutine { fn create() -> u32; } struct Impl; -impl Generator for Impl { +impl Coroutine for Impl { fn create() -> u32 { 1 } } @@ -22,12 +22,12 @@ fn foo(bar: u32) {} struct AnotherImpl; -impl Generator for AnotherImpl { +impl Coroutine for AnotherImpl { fn create() -> u32 { 2 } } fn main() { - let cont: u32 = Generator::create(); //~ ERROR E0790 + let cont: u32 = Coroutine::create(); //~ ERROR E0790 } fn buzz() { diff --git a/tests/ui/error-codes/E0283.stderr b/tests/ui/error-codes/E0283.stderr index fa8d4b6e015..6008809f050 100644 --- a/tests/ui/error-codes/E0283.stderr +++ b/tests/ui/error-codes/E0283.stderr @@ -2,14 +2,14 @@ error[E0790]: cannot call associated function on trait without specifying the co --> $DIR/E0283.rs:30:21 | LL | fn create() -> u32; - | ------------------- `Generator::create` defined here + | ------------------- `Coroutine::create` defined here ... -LL | let cont: u32 = Generator::create(); +LL | let cont: u32 = Coroutine::create(); | ^^^^^^^^^^^^^^^^^ cannot call associated function of trait | help: use a fully-qualified path to a specific available implementation | -LL | let cont: u32 = </* self type */ as Generator>::create(); +LL | let cont: u32 = </* self type */ as Coroutine>::create(); | +++++++++++++++++++ + error[E0283]: type annotations needed diff --git a/tests/ui/generator/auxiliary/metadata-sufficient-for-layout.rs b/tests/ui/generator/auxiliary/metadata-sufficient-for-layout.rs index 207c2735f88..59def4b5564 100644 --- a/tests/ui/generator/auxiliary/metadata-sufficient-for-layout.rs +++ b/tests/ui/generator/auxiliary/metadata-sufficient-for-layout.rs @@ -2,9 +2,9 @@ #![feature(generators, generator_trait)] use std::marker::Unpin; -use std::ops::Generator; +use std::ops::Coroutine; -pub fn g() -> impl Generator<(), Yield = (), Return = ()> { +pub fn g() -> impl Coroutine<(), Yield = (), Return = ()> { || { yield; } diff --git a/tests/ui/generator/auxiliary/xcrate-reachable.rs b/tests/ui/generator/auxiliary/xcrate-reachable.rs index 2dd5ea67523..dd99ce444c6 100644 --- a/tests/ui/generator/auxiliary/xcrate-reachable.rs +++ b/tests/ui/generator/auxiliary/xcrate-reachable.rs @@ -1,12 +1,12 @@ #![feature(generators, generator_trait)] -use std::ops::Generator; +use std::ops::Coroutine; fn msg() -> u32 { 0 } -pub fn foo() -> impl Generator<(), Yield=(), Return=u32> { +pub fn foo() -> impl Coroutine<(), Yield = (), Return = u32> { || { yield; return msg(); diff --git a/tests/ui/generator/auxiliary/xcrate.rs b/tests/ui/generator/auxiliary/xcrate.rs index d07abd0918c..401b3145280 100644 --- a/tests/ui/generator/auxiliary/xcrate.rs +++ b/tests/ui/generator/auxiliary/xcrate.rs @@ -1,9 +1,9 @@ #![feature(generators, generator_trait)] use std::marker::Unpin; -use std::ops::Generator; +use std::ops::Coroutine; -pub fn foo() -> impl Generator<(), Yield = (), Return = ()> { +pub fn foo() -> impl Coroutine<(), Yield = (), Return = ()> { || { if false { yield; @@ -11,7 +11,7 @@ pub fn foo() -> impl Generator<(), Yield = (), Return = ()> { } } -pub fn bar<T: 'static>(t: T) -> Box<Generator<(), Yield = T, Return = ()> + Unpin> { +pub fn bar<T: 'static>(t: T) -> Box<Coroutine<(), Yield = T, Return = ()> + Unpin> { Box::new(|| { yield t; }) diff --git a/tests/ui/generator/borrowing.rs b/tests/ui/generator/borrowing.rs index d36592583cd..612df7e4141 100644 --- a/tests/ui/generator/borrowing.rs +++ b/tests/ui/generator/borrowing.rs @@ -1,6 +1,6 @@ #![feature(generators, generator_trait)] -use std::ops::Generator; +use std::ops::Coroutine; use std::pin::Pin; fn main() { diff --git a/tests/ui/generator/conditional-drop.rs b/tests/ui/generator/conditional-drop.rs index 0927df86927..a56afea768b 100644 --- a/tests/ui/generator/conditional-drop.rs +++ b/tests/ui/generator/conditional-drop.rs @@ -5,7 +5,7 @@ #![feature(generators, generator_trait)] -use std::ops::Generator; +use std::ops::Coroutine; use std::pin::Pin; use std::sync::atomic::{AtomicUsize, Ordering}; diff --git a/tests/ui/generator/control-flow.rs b/tests/ui/generator/control-flow.rs index 4f69c785560..46c21263cc2 100644 --- a/tests/ui/generator/control-flow.rs +++ b/tests/ui/generator/control-flow.rs @@ -6,16 +6,16 @@ #![feature(generators, generator_trait)] use std::marker::Unpin; -use std::ops::{GeneratorState, Generator}; +use std::ops::{CoroutineState, Coroutine}; use std::pin::Pin; fn finish<T>(mut amt: usize, mut t: T) -> T::Return - where T: Generator<(), Yield = ()> + Unpin, + where T: Coroutine<(), Yield = ()> + Unpin, { loop { match Pin::new(&mut t).resume(()) { - GeneratorState::Yielded(()) => amt = amt.checked_sub(1).unwrap(), - GeneratorState::Complete(ret) => { + CoroutineState::Yielded(()) => amt = amt.checked_sub(1).unwrap(), + CoroutineState::Complete(ret) => { assert_eq!(amt, 0); return ret } diff --git a/tests/ui/generator/discriminant.rs b/tests/ui/generator/discriminant.rs index 195e7702299..033bbf79a5f 100644 --- a/tests/ui/generator/discriminant.rs +++ b/tests/ui/generator/discriminant.rs @@ -6,7 +6,7 @@ #![feature(generators, generator_trait, core_intrinsics, discriminant_kind)] use std::intrinsics::discriminant_value; -use std::marker::{Unpin, DiscriminantKind}; +use std::marker::{DiscriminantKind, Unpin}; use std::mem::size_of_val; use std::{cmp, ops::*}; @@ -66,16 +66,16 @@ macro_rules! yield250 { } fn cycle( - gen: impl Generator<()> + Unpin + DiscriminantKind<Discriminant = u32>, - expected_max_discr: u32 + gen: impl Coroutine<()> + Unpin + DiscriminantKind<Discriminant = u32>, + expected_max_discr: u32, ) { let mut gen = Box::pin(gen); let mut max_discr = 0; loop { max_discr = cmp::max(max_discr, discriminant_value(gen.as_mut().get_mut())); match gen.as_mut().resume(()) { - GeneratorState::Yielded(_) => {} - GeneratorState::Complete(_) => { + CoroutineState::Yielded(_) => {} + CoroutineState::Complete(_) => { assert_eq!(max_discr, expected_max_discr); return; } diff --git a/tests/ui/generator/drop-and-replace.rs b/tests/ui/generator/drop-and-replace.rs index a9a50a122a1..4ce35d701a4 100644 --- a/tests/ui/generator/drop-and-replace.rs +++ b/tests/ui/generator/drop-and-replace.rs @@ -6,14 +6,14 @@ #![feature(generators, generator_trait)] -use std::ops::{Generator, GeneratorState}; +use std::ops::{Coroutine, CoroutineState}; use std::pin::Pin; #[derive(Debug, PartialEq)] struct Foo(i32); impl Drop for Foo { - fn drop(&mut self) { } + fn drop(&mut self) {} } fn main() { @@ -38,7 +38,7 @@ fn main() { loop { match Pin::new(&mut a).resume(()) { - GeneratorState::Complete(()) => break, + CoroutineState::Complete(()) => break, _ => (), } } diff --git a/tests/ui/generator/drop-env.rs b/tests/ui/generator/drop-env.rs index 137a407931a..5bbe3486a05 100644 --- a/tests/ui/generator/drop-env.rs +++ b/tests/ui/generator/drop-env.rs @@ -6,7 +6,7 @@ #![feature(generators, generator_trait)] #![allow(dropping_copy_types)] -use std::ops::Generator; +use std::ops::Coroutine; use std::pin::Pin; use std::sync::atomic::{AtomicUsize, Ordering}; diff --git a/tests/ui/generator/dropck-resume.rs b/tests/ui/generator/dropck-resume.rs index 4c18077f335..450d9837c7f 100644 --- a/tests/ui/generator/dropck-resume.rs +++ b/tests/ui/generator/dropck-resume.rs @@ -1,6 +1,6 @@ #![feature(generators, generator_trait)] -use std::ops::{Generator, GeneratorState}; +use std::ops::{Coroutine, CoroutineState}; use std::pin::Pin; struct SetToNone<'a: 'b, 'b>(&'b mut Option<&'a i32>); diff --git a/tests/ui/generator/dropck.rs b/tests/ui/generator/dropck.rs index f82111a76b1..26272336adb 100644 --- a/tests/ui/generator/dropck.rs +++ b/tests/ui/generator/dropck.rs @@ -1,7 +1,7 @@ #![feature(generators, generator_trait)] use std::cell::RefCell; -use std::ops::Generator; +use std::ops::Coroutine; use std::pin::Pin; fn main() { diff --git a/tests/ui/generator/generator-region-requirements.rs b/tests/ui/generator/generator-region-requirements.rs index 7269a79ca3f..79e1b30bbcf 100644 --- a/tests/ui/generator/generator-region-requirements.rs +++ b/tests/ui/generator/generator-region-requirements.rs @@ -1,5 +1,5 @@ #![feature(generators, generator_trait)] -use std::ops::{Generator, GeneratorState}; +use std::ops::{Coroutine, CoroutineState}; use std::pin::Pin; fn dangle(x: &mut i32) -> &'static mut i32 { @@ -9,9 +9,9 @@ fn dangle(x: &mut i32) -> &'static mut i32 { }; loop { match Pin::new(&mut g).resume(()) { - GeneratorState::Complete(c) => return c, + CoroutineState::Complete(c) => return c, //~^ ERROR lifetime may not live long enough - GeneratorState::Yielded(_) => (), + CoroutineState::Yielded(_) => (), } } } diff --git a/tests/ui/generator/generator-region-requirements.stderr b/tests/ui/generator/generator-region-requirements.stderr index 87f60467287..1c47e528905 100644 --- a/tests/ui/generator/generator-region-requirements.stderr +++ b/tests/ui/generator/generator-region-requirements.stderr @@ -4,7 +4,7 @@ error: lifetime may not live long enough LL | fn dangle(x: &mut i32) -> &'static mut i32 { | - let's call the lifetime of this reference `'1` ... -LL | GeneratorState::Complete(c) => return c, +LL | CoroutineState::Complete(c) => return c, | ^ returning this value requires that `'1` must outlive `'static` error: aborting due to previous error diff --git a/tests/ui/generator/generator-resume-after-panic.rs b/tests/ui/generator/generator-resume-after-panic.rs index f2e67f1f750..f790baec055 100644 --- a/tests/ui/generator/generator-resume-after-panic.rs +++ b/tests/ui/generator/generator-resume-after-panic.rs @@ -8,7 +8,7 @@ #![feature(generators, generator_trait)] use std::{ - ops::Generator, + ops::Coroutine, pin::Pin, panic, }; diff --git a/tests/ui/generator/generator-yielding-or-returning-itself.rs b/tests/ui/generator/generator-yielding-or-returning-itself.rs index 30788e3c186..07b24a4e1a0 100644 --- a/tests/ui/generator/generator-yielding-or-returning-itself.rs +++ b/tests/ui/generator/generator-yielding-or-returning-itself.rs @@ -4,10 +4,10 @@ // Test that we cannot create a generator that returns a value of its // own type. -use std::ops::Generator; +use std::ops::Coroutine; pub fn want_cyclic_generator_return<T>(_: T) - where T: Generator<Yield = (), Return = T> + where T: Coroutine<Yield = (), Return = T> { } @@ -20,7 +20,7 @@ fn supply_cyclic_generator_return() { } pub fn want_cyclic_generator_yield<T>(_: T) - where T: Generator<Yield = T, Return = ()> + where T: Coroutine<Yield = T, Return = ()> { } diff --git a/tests/ui/generator/generator-yielding-or-returning-itself.stderr b/tests/ui/generator/generator-yielding-or-returning-itself.stderr index 7841a0854ca..c5b1f5fdf17 100644 --- a/tests/ui/generator/generator-yielding-or-returning-itself.stderr +++ b/tests/ui/generator/generator-yielding-or-returning-itself.stderr @@ -1,4 +1,4 @@ -error[E0271]: type mismatch resolving `<{generator@$DIR/generator-yielding-or-returning-itself.rs:15:34: 15:36} as Generator>::Return == {generator@$DIR/generator-yielding-or-returning-itself.rs:15:34: 15:36}` +error[E0271]: type mismatch resolving `<{generator@$DIR/generator-yielding-or-returning-itself.rs:15:34: 15:36} as Coroutine>::Return == {generator@$DIR/generator-yielding-or-returning-itself.rs:15:34: 15:36}` --> $DIR/generator-yielding-or-returning-itself.rs:15:34 | LL | want_cyclic_generator_return(|| { @@ -20,10 +20,10 @@ note: required by a bound in `want_cyclic_generator_return` | LL | pub fn want_cyclic_generator_return<T>(_: T) | ---------------------------- required by a bound in this function -LL | where T: Generator<Yield = (), Return = T> +LL | where T: Coroutine<Yield = (), Return = T> | ^^^^^^^^^^ required by this bound in `want_cyclic_generator_return` -error[E0271]: type mismatch resolving `<{generator@$DIR/generator-yielding-or-returning-itself.rs:28:33: 28:35} as Generator>::Yield == {generator@$DIR/generator-yielding-or-returning-itself.rs:28:33: 28:35}` +error[E0271]: type mismatch resolving `<{generator@$DIR/generator-yielding-or-returning-itself.rs:28:33: 28:35} as Coroutine>::Yield == {generator@$DIR/generator-yielding-or-returning-itself.rs:28:33: 28:35}` --> $DIR/generator-yielding-or-returning-itself.rs:28:33 | LL | want_cyclic_generator_yield(|| { @@ -45,7 +45,7 @@ note: required by a bound in `want_cyclic_generator_yield` | LL | pub fn want_cyclic_generator_yield<T>(_: T) | --------------------------- required by a bound in this function -LL | where T: Generator<Yield = T, Return = ()> +LL | where T: Coroutine<Yield = T, Return = ()> | ^^^^^^^^^ required by this bound in `want_cyclic_generator_yield` error: aborting due to 2 previous errors diff --git a/tests/ui/generator/issue-102645.rs b/tests/ui/generator/issue-102645.rs index 677cc69d3f2..5e7f54f5aa6 100644 --- a/tests/ui/generator/issue-102645.rs +++ b/tests/ui/generator/issue-102645.rs @@ -1,6 +1,6 @@ #![feature(generators, generator_trait)] -use std::ops::Generator; +use std::ops::Coroutine; use std::pin::Pin; fn main() { diff --git a/tests/ui/generator/issue-105084.rs b/tests/ui/generator/issue-105084.rs index 50b5da6e6ad..bfe2b16cb94 100644 --- a/tests/ui/generator/issue-105084.rs +++ b/tests/ui/generator/issue-105084.rs @@ -3,7 +3,7 @@ #![feature(generator_trait)] #![feature(rustc_attrs, stmt_expr_attributes)] -use std::ops::Generator; +use std::ops::Coroutine; use std::pin::Pin; fn copy<T: Copy>(x: T) -> T { diff --git a/tests/ui/generator/issue-44197.rs b/tests/ui/generator/issue-44197.rs index 389b9d13969..4907d2fe08c 100644 --- a/tests/ui/generator/issue-44197.rs +++ b/tests/ui/generator/issue-44197.rs @@ -2,14 +2,14 @@ #![feature(generators, generator_trait)] -use std::ops::{Generator, GeneratorState}; +use std::ops::{Coroutine, CoroutineState}; use std::pin::Pin; fn foo(_: &str) -> String { String::new() } -fn bar(baz: String) -> impl Generator<(), Yield = String, Return = ()> { +fn bar(baz: String) -> impl Coroutine<(), Yield = String, Return = ()> { move || { yield foo(&baz); } @@ -19,7 +19,7 @@ fn foo2(_: &str) -> Result<String, ()> { Err(()) } -fn bar2(baz: String) -> impl Generator<(), Yield = String, Return = ()> { +fn bar2(baz: String) -> impl Coroutine<(), Yield = String, Return = ()> { move || { if let Ok(quux) = foo2(&baz) { yield quux; @@ -30,7 +30,7 @@ fn bar2(baz: String) -> impl Generator<(), Yield = String, Return = ()> { fn main() { assert_eq!( Pin::new(&mut bar(String::new())).resume(()), - GeneratorState::Yielded(String::new()) + CoroutineState::Yielded(String::new()) ); - assert_eq!(Pin::new(&mut bar2(String::new())).resume(()), GeneratorState::Complete(())); + assert_eq!(Pin::new(&mut bar2(String::new())).resume(()), CoroutineState::Complete(())); } diff --git a/tests/ui/generator/issue-52304.rs b/tests/ui/generator/issue-52304.rs index 3e9de765b12..e92d4b32f72 100644 --- a/tests/ui/generator/issue-52304.rs +++ b/tests/ui/generator/issue-52304.rs @@ -2,9 +2,9 @@ #![feature(generators, generator_trait)] -use std::ops::Generator; +use std::ops::Coroutine; -pub fn example() -> impl Generator { +pub fn example() -> impl Coroutine { || yield &1 } diff --git a/tests/ui/generator/issue-57084.rs b/tests/ui/generator/issue-57084.rs index fbed78ff280..918ed2bae0c 100644 --- a/tests/ui/generator/issue-57084.rs +++ b/tests/ui/generator/issue-57084.rs @@ -3,9 +3,9 @@ // run-pass // edition:2018 #![feature(generators,generator_trait)] -use std::ops::Generator; +use std::ops::Coroutine; -fn with<F>(f: F) -> impl Generator<Yield=(), Return=()> +fn with<F>(f: F) -> impl Coroutine<Yield=(), Return=()> where F: Fn() -> () { move || { diff --git a/tests/ui/generator/issue-58888.rs b/tests/ui/generator/issue-58888.rs index d42d09d401e..f87dbfda420 100644 --- a/tests/ui/generator/issue-58888.rs +++ b/tests/ui/generator/issue-58888.rs @@ -4,7 +4,7 @@ #![feature(generators, generator_trait)] -use std::ops::Generator; +use std::ops::Coroutine; struct Database; @@ -13,7 +13,7 @@ impl Database { Some(()).into_iter() } - fn check_connection(&self) -> impl Generator<Yield = (), Return = ()> + '_ { + fn check_connection(&self) -> impl Coroutine<Yield = (), Return = ()> + '_ { move || { let iter = self.get_connection(); for i in iter { diff --git a/tests/ui/generator/issue-61442-stmt-expr-with-drop.rs b/tests/ui/generator/issue-61442-stmt-expr-with-drop.rs index 187c374021d..6dd3803c283 100644 --- a/tests/ui/generator/issue-61442-stmt-expr-with-drop.rs +++ b/tests/ui/generator/issue-61442-stmt-expr-with-drop.rs @@ -6,7 +6,7 @@ #![feature(generators, generator_trait)] -use std::ops::Generator; +use std::ops::Coroutine; async fn drop_and_await() { async {}; diff --git a/tests/ui/generator/issue-68112.rs b/tests/ui/generator/issue-68112.rs index 9dd68726f92..955c5bc6898 100644 --- a/tests/ui/generator/issue-68112.rs +++ b/tests/ui/generator/issue-68112.rs @@ -4,15 +4,15 @@ use std::{ cell::RefCell, sync::Arc, pin::Pin, - ops::{Generator, GeneratorState}, + ops::{Coroutine, CoroutineState}, }; pub struct Ready<T>(Option<T>); -impl<T: Unpin> Generator<()> for Ready<T> { +impl<T: Unpin> Coroutine<()> for Ready<T> { type Return = T; type Yield = (); - fn resume(mut self: Pin<&mut Self>, _args: ()) -> GeneratorState<(), T> { - GeneratorState::Complete(self.0.take().unwrap()) + fn resume(mut self: Pin<&mut Self>, _args: ()) -> CoroutineState<(), T> { + CoroutineState::Complete(self.0.take().unwrap()) } } pub fn make_gen1<T>(t: T) -> Ready<T> { @@ -25,7 +25,7 @@ fn require_send(_: impl Send) {} //~| NOTE required by this bound //~| NOTE required by this bound -fn make_non_send_generator() -> impl Generator<Return = Arc<RefCell<i32>>> { +fn make_non_send_generator() -> impl Coroutine<Return = Arc<RefCell<i32>>> { make_gen1(Arc::new(RefCell::new(0))) } @@ -43,7 +43,7 @@ fn test1() { //~| NOTE use `std::sync::RwLock` instead } -pub fn make_gen2<T>(t: T) -> impl Generator<Return = T> { +pub fn make_gen2<T>(t: T) -> impl Coroutine<Return = T> { //~^ NOTE appears within the type //~| NOTE expansion of desugaring || { //~ NOTE used within this generator @@ -51,7 +51,7 @@ pub fn make_gen2<T>(t: T) -> impl Generator<Return = T> { t } } -fn make_non_send_generator2() -> impl Generator<Return = Arc<RefCell<i32>>> { //~ NOTE appears within the type +fn make_non_send_generator2() -> impl Coroutine<Return = Arc<RefCell<i32>>> { //~ NOTE appears within the type //~^ NOTE expansion of desugaring make_gen2(Arc::new(RefCell::new(0))) } diff --git a/tests/ui/generator/issue-68112.stderr b/tests/ui/generator/issue-68112.stderr index 8080048222f..5420055557e 100644 --- a/tests/ui/generator/issue-68112.stderr +++ b/tests/ui/generator/issue-68112.stderr @@ -10,7 +10,7 @@ note: generator is not `Send` as this value is used across a yield --> $DIR/issue-68112.rs:36:9 | LL | let _non_send_gen = make_non_send_generator(); - | ------------- has type `impl Generator<Return = Arc<RefCell<i32>>>` which is not `Send` + | ------------- has type `impl Coroutine<Return = Arc<RefCell<i32>>>` which is not `Send` LL | LL | yield; | ^^^^^ yield occurs here, with `_non_send_gen` maybe used later @@ -34,17 +34,17 @@ note: required because it's used within this generator | LL | || { | ^^ -note: required because it appears within the type `impl Generator<Return = Arc<RefCell<i32>>>` +note: required because it appears within the type `impl Coroutine<Return = Arc<RefCell<i32>>>` --> $DIR/issue-68112.rs:46:30 | -LL | pub fn make_gen2<T>(t: T) -> impl Generator<Return = T> { +LL | pub fn make_gen2<T>(t: T) -> impl Coroutine<Return = T> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: required because it appears within the type `impl Generator<Return = Arc<RefCell<i32>>>` +note: required because it appears within the type `impl Coroutine<Return = Arc<RefCell<i32>>>` --> $DIR/issue-68112.rs:54:34 | -LL | fn make_non_send_generator2() -> impl Generator<Return = Arc<RefCell<i32>>> { +LL | fn make_non_send_generator2() -> impl Coroutine<Return = Arc<RefCell<i32>>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: required because it captures the following types: `impl Generator<Return = Arc<RefCell<i32>>>` + = note: required because it captures the following types: `impl Coroutine<Return = Arc<RefCell<i32>>>` note: required because it's used within this generator --> $DIR/issue-68112.rs:60:20 | diff --git a/tests/ui/generator/issue-69017.rs b/tests/ui/generator/issue-69017.rs index 511deb60e45..580370e4e3d 100644 --- a/tests/ui/generator/issue-69017.rs +++ b/tests/ui/generator/issue-69017.rs @@ -7,9 +7,9 @@ #![feature(generator_trait)] #![feature(generators)] -use std::ops::Generator; +use std::ops::Coroutine; -fn gen() -> impl Generator<usize> { +fn gen() -> impl Coroutine<usize> { |_: usize| { println!("-> {}", yield); } diff --git a/tests/ui/generator/issue-69039.rs b/tests/ui/generator/issue-69039.rs index ccc141860aa..1cddd331076 100644 --- a/tests/ui/generator/issue-69039.rs +++ b/tests/ui/generator/issue-69039.rs @@ -2,13 +2,13 @@ #![feature(generators, generator_trait)] -use std::ops::{Generator, GeneratorState}; +use std::ops::{Coroutine, CoroutineState}; fn mkstr(my_name: String, my_mood: String) -> String { format!("{} is {}", my_name.trim(), my_mood.trim()) } -fn my_scenario() -> impl Generator<String, Yield = &'static str, Return = String> { +fn my_scenario() -> impl Coroutine<String, Yield = &'static str, Return = String> { |_arg: String| { let my_name = yield "What is your name?"; let my_mood = yield "How are you feeling?"; @@ -21,14 +21,14 @@ fn main() { assert_eq!( my_session.as_mut().resume("_arg".to_string()), - GeneratorState::Yielded("What is your name?") + CoroutineState::Yielded("What is your name?") ); assert_eq!( my_session.as_mut().resume("Your Name".to_string()), - GeneratorState::Yielded("How are you feeling?") + CoroutineState::Yielded("How are you feeling?") ); assert_eq!( my_session.as_mut().resume("Sensory Organs".to_string()), - GeneratorState::Complete("Your Name is Sensory Organs".to_string()) + CoroutineState::Complete("Your Name is Sensory Organs".to_string()) ); } diff --git a/tests/ui/generator/issue-87142.rs b/tests/ui/generator/issue-87142.rs index 7f670919ed6..bbf611504a4 100644 --- a/tests/ui/generator/issue-87142.rs +++ b/tests/ui/generator/issue-87142.rs @@ -7,20 +7,20 @@ #![feature(impl_trait_in_assoc_type, generator_trait, generators)] #![crate_type = "lib"] -use std::ops::Generator; +use std::ops::Coroutine; -pub trait GeneratorProviderAlt: Sized { - type Gen: Generator<(), Return = (), Yield = ()>; +pub trait CoroutineProviderAlt: Sized { + type Gen: Coroutine<(), Return = (), Yield = ()>; fn start(ctx: Context<Self>) -> Self::Gen; } -pub struct Context<G: 'static + GeneratorProviderAlt> { +pub struct Context<G: 'static + CoroutineProviderAlt> { pub link: Box<G::Gen>, } -impl GeneratorProviderAlt for () { - type Gen = impl Generator<(), Return = (), Yield = ()>; +impl CoroutineProviderAlt for () { + type Gen = impl Coroutine<(), Return = (), Yield = ()>; fn start(ctx: Context<Self>) -> Self::Gen { move || { match ctx { diff --git a/tests/ui/generator/issue-88653.rs b/tests/ui/generator/issue-88653.rs index 1d9377bcef4..6b1b8b79360 100644 --- a/tests/ui/generator/issue-88653.rs +++ b/tests/ui/generator/issue-88653.rs @@ -3,9 +3,9 @@ #![feature(generators, generator_trait)] -use std::ops::Generator; +use std::ops::Coroutine; -fn foo(bar: bool) -> impl Generator<(bool,)> { +fn foo(bar: bool) -> impl Coroutine<(bool,)> { //~^ ERROR: type mismatch in generator arguments [E0631] //~| NOTE: expected due to this //~| NOTE: expected generator signature `fn((bool,)) -> _` diff --git a/tests/ui/generator/issue-88653.stderr b/tests/ui/generator/issue-88653.stderr index b742c6e2f1c..925303a13e1 100644 --- a/tests/ui/generator/issue-88653.stderr +++ b/tests/ui/generator/issue-88653.stderr @@ -1,7 +1,7 @@ error[E0631]: type mismatch in generator arguments --> $DIR/issue-88653.rs:8:22 | -LL | fn foo(bar: bool) -> impl Generator<(bool,)> { +LL | fn foo(bar: bool) -> impl Coroutine<(bool,)> { | ^^^^^^^^^^^^^^^^^^^^^^^ expected due to this ... LL | |bar| { diff --git a/tests/ui/generator/iterator-count.rs b/tests/ui/generator/iterator-count.rs index 90eefe02f66..82cb75c2c85 100644 --- a/tests/ui/generator/iterator-count.rs +++ b/tests/ui/generator/iterator-count.rs @@ -3,25 +3,25 @@ #![feature(generators, generator_trait)] use std::marker::Unpin; -use std::ops::{GeneratorState, Generator}; +use std::ops::{Coroutine, CoroutineState}; use std::pin::Pin; struct W<T>(T); // This impl isn't safe in general, but the generator used in this test is movable // so it won't cause problems. -impl<T: Generator<(), Return = ()> + Unpin> Iterator for W<T> { +impl<T: Coroutine<(), Return = ()> + Unpin> Iterator for W<T> { type Item = T::Yield; fn next(&mut self) -> Option<Self::Item> { match Pin::new(&mut self.0).resume(()) { - GeneratorState::Complete(..) => None, - GeneratorState::Yielded(v) => Some(v), + CoroutineState::Complete(..) => None, + CoroutineState::Yielded(v) => Some(v), } } } -fn test() -> impl Generator<(), Return=(), Yield=u8> + Unpin { +fn test() -> impl Coroutine<(), Return = (), Yield = u8> + Unpin { || { for i in 1..6 { yield i diff --git a/tests/ui/generator/live-upvar-across-yield.rs b/tests/ui/generator/live-upvar-across-yield.rs index 6a2e42a5573..820f0c821f6 100644 --- a/tests/ui/generator/live-upvar-across-yield.rs +++ b/tests/ui/generator/live-upvar-across-yield.rs @@ -2,7 +2,7 @@ #![feature(generators, generator_trait)] -use std::ops::Generator; +use std::ops::Coroutine; use std::pin::Pin; fn main() { diff --git a/tests/ui/generator/metadata-sufficient-for-layout.rs b/tests/ui/generator/metadata-sufficient-for-layout.rs index d0e648ee775..622e3eb3fb7 100644 --- a/tests/ui/generator/metadata-sufficient-for-layout.rs +++ b/tests/ui/generator/metadata-sufficient-for-layout.rs @@ -10,9 +10,9 @@ extern crate metadata_sufficient_for_layout; -use std::ops::Generator; +use std::ops::Coroutine; -type F = impl Generator<(), Yield = (), Return = ()>; +type F = impl Coroutine<(), Yield = (), Return = ()>; // Static queries the layout of the generator. static A: Option<F> = None; diff --git a/tests/ui/generator/nested_generators.rs b/tests/ui/generator/nested_generators.rs index 45519150eec..7aa4706df97 100644 --- a/tests/ui/generator/nested_generators.rs +++ b/tests/ui/generator/nested_generators.rs @@ -2,7 +2,7 @@ #![feature(generators, generator_trait)] -use std::ops::{Generator, GeneratorState}; +use std::ops::{Coroutine, CoroutineState}; use std::pin::Pin; fn main() { @@ -12,7 +12,7 @@ fn main() { }; match Pin::new(&mut sub_generator).resume(()) { - GeneratorState::Yielded(x) => { + CoroutineState::Yielded(x) => { yield x; } _ => panic!(), diff --git a/tests/ui/generator/panic-drops-resume.rs b/tests/ui/generator/panic-drops-resume.rs index 4c3caeb14d6..a70276cace5 100644 --- a/tests/ui/generator/panic-drops-resume.rs +++ b/tests/ui/generator/panic-drops-resume.rs @@ -5,7 +5,7 @@ #![feature(generators, generator_trait)] -use std::ops::Generator; +use std::ops::Coroutine; use std::panic::{catch_unwind, AssertUnwindSafe}; use std::pin::Pin; use std::sync::atomic::{AtomicUsize, Ordering}; diff --git a/tests/ui/generator/panic-drops.rs b/tests/ui/generator/panic-drops.rs index 65001fd879b..6598109f3fe 100644 --- a/tests/ui/generator/panic-drops.rs +++ b/tests/ui/generator/panic-drops.rs @@ -4,7 +4,7 @@ #![feature(generators, generator_trait)] -use std::ops::Generator; +use std::ops::Coroutine; use std::panic; use std::pin::Pin; use std::sync::atomic::{AtomicUsize, Ordering}; diff --git a/tests/ui/generator/panic-safe.rs b/tests/ui/generator/panic-safe.rs index 3db80bb5821..33ccbb3e21a 100644 --- a/tests/ui/generator/panic-safe.rs +++ b/tests/ui/generator/panic-safe.rs @@ -4,7 +4,7 @@ #![feature(generators, generator_trait)] -use std::ops::Generator; +use std::ops::Coroutine; use std::pin::Pin; use std::panic; diff --git a/tests/ui/generator/pin-box-generator.rs b/tests/ui/generator/pin-box-generator.rs index c3136f5c0ec..6cb3006e781 100644 --- a/tests/ui/generator/pin-box-generator.rs +++ b/tests/ui/generator/pin-box-generator.rs @@ -2,9 +2,9 @@ #![feature(generators, generator_trait)] -use std::ops::Generator; +use std::ops::Coroutine; -fn assert_generator<G: Generator>(_: G) { +fn assert_generator<G: Coroutine>(_: G) { } fn main() { diff --git a/tests/ui/generator/print/generator-print-verbose-1.rs b/tests/ui/generator/print/generator-print-verbose-1.rs index e52234c08a3..85b9789e7f8 100644 --- a/tests/ui/generator/print/generator-print-verbose-1.rs +++ b/tests/ui/generator/print/generator-print-verbose-1.rs @@ -8,15 +8,15 @@ use std::{ cell::RefCell, sync::Arc, pin::Pin, - ops::{Generator, GeneratorState}, + ops::{Coroutine, CoroutineState}, }; pub struct Ready<T>(Option<T>); -impl<T: Unpin> Generator<()> for Ready<T> { +impl<T: Unpin> Coroutine<()> for Ready<T> { type Return = T; type Yield = (); - fn resume(mut self: Pin<&mut Self>, _args: ()) -> GeneratorState<(), T> { - GeneratorState::Complete(self.0.take().unwrap()) + fn resume(mut self: Pin<&mut Self>, _args: ()) -> CoroutineState<(), T> { + CoroutineState::Complete(self.0.take().unwrap()) } } pub fn make_gen1<T>(t: T) -> Ready<T> { @@ -25,7 +25,7 @@ pub fn make_gen1<T>(t: T) -> Ready<T> { fn require_send(_: impl Send) {} -fn make_non_send_generator() -> impl Generator<Return = Arc<RefCell<i32>>> { +fn make_non_send_generator() -> impl Coroutine<Return = Arc<RefCell<i32>>> { make_gen1(Arc::new(RefCell::new(0))) } @@ -38,13 +38,13 @@ fn test1() { //~^ ERROR generator cannot be sent between threads } -pub fn make_gen2<T>(t: T) -> impl Generator<Return = T> { +pub fn make_gen2<T>(t: T) -> impl Coroutine<Return = T> { || { yield; t } } -fn make_non_send_generator2() -> impl Generator<Return = Arc<RefCell<i32>>> { +fn make_non_send_generator2() -> impl Coroutine<Return = Arc<RefCell<i32>>> { make_gen2(Arc::new(RefCell::new(0))) } diff --git a/tests/ui/generator/print/generator-print-verbose-1.stderr b/tests/ui/generator/print/generator-print-verbose-1.stderr index d949543de41..1e543ad736b 100644 --- a/tests/ui/generator/print/generator-print-verbose-1.stderr +++ b/tests/ui/generator/print/generator-print-verbose-1.stderr @@ -36,12 +36,12 @@ LL | || { note: required because it appears within the type `Opaque(DefId(0:35 ~ generator_print_verbose_1[7d1d]::make_gen2::{opaque#0}), [Arc<RefCell<i32>>])` --> $DIR/generator-print-verbose-1.rs:41:30 | -LL | pub fn make_gen2<T>(t: T) -> impl Generator<Return = T> { +LL | pub fn make_gen2<T>(t: T) -> impl Coroutine<Return = T> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ note: required because it appears within the type `Opaque(DefId(0:36 ~ generator_print_verbose_1[7d1d]::make_non_send_generator2::{opaque#0}), [])` --> $DIR/generator-print-verbose-1.rs:47:34 | -LL | fn make_non_send_generator2() -> impl Generator<Return = Arc<RefCell<i32>>> { +LL | fn make_non_send_generator2() -> impl Coroutine<Return = Arc<RefCell<i32>>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: required because it captures the following types: `Opaque(DefId(0:36 ~ generator_print_verbose_1[7d1d]::make_non_send_generator2::{opaque#0}), [])` note: required because it's used within this generator diff --git a/tests/ui/generator/resume-after-return.rs b/tests/ui/generator/resume-after-return.rs index 01a059a161c..3c06758acfb 100644 --- a/tests/ui/generator/resume-after-return.rs +++ b/tests/ui/generator/resume-after-return.rs @@ -4,7 +4,7 @@ #![feature(generators, generator_trait)] -use std::ops::{GeneratorState, Generator}; +use std::ops::{CoroutineState, Coroutine}; use std::pin::Pin; use std::panic; @@ -17,7 +17,7 @@ fn main() { }; match Pin::new(&mut foo).resume(()) { - GeneratorState::Complete(()) => {} + CoroutineState::Complete(()) => {} s => panic!("bad state: {:?}", s), } diff --git a/tests/ui/generator/resume-arg-late-bound.rs b/tests/ui/generator/resume-arg-late-bound.rs index 1c35ba80d2b..3c32bf1e0eb 100644 --- a/tests/ui/generator/resume-arg-late-bound.rs +++ b/tests/ui/generator/resume-arg-late-bound.rs @@ -3,9 +3,9 @@ #![feature(generators, generator_trait)] -use std::ops::Generator; +use std::ops::Coroutine; -fn test(a: impl for<'a> Generator<&'a mut bool>) {} +fn test(a: impl for<'a> Coroutine<&'a mut bool>) {} fn main() { let gen = |arg: &mut bool| { diff --git a/tests/ui/generator/resume-arg-late-bound.stderr b/tests/ui/generator/resume-arg-late-bound.stderr index 34ee4036cc5..f1a8a8ed711 100644 --- a/tests/ui/generator/resume-arg-late-bound.stderr +++ b/tests/ui/generator/resume-arg-late-bound.stderr @@ -4,12 +4,12 @@ error[E0308]: mismatched types LL | test(gen); | ^^^^^^^^^ one type is more general than the other | - = note: expected trait `for<'a> Generator<&'a mut bool>` - found trait `Generator<&mut bool>` + = note: expected trait `for<'a> Coroutine<&'a mut bool>` + found trait `Coroutine<&mut bool>` note: the lifetime requirement is introduced here --> $DIR/resume-arg-late-bound.rs:8:17 | -LL | fn test(a: impl for<'a> Generator<&'a mut bool>) {} +LL | fn test(a: impl for<'a> Coroutine<&'a mut bool>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/tests/ui/generator/resume-arg-size.rs b/tests/ui/generator/resume-arg-size.rs index 195166f975b..c8f6e970f67 100644 --- a/tests/ui/generator/resume-arg-size.rs +++ b/tests/ui/generator/resume-arg-size.rs @@ -6,7 +6,7 @@ use std::mem::size_of_val; fn main() { - // Generator taking a `Copy`able resume arg. + // Coroutine taking a `Copy`able resume arg. let gen_copy = |mut x: usize| { loop { drop(x); @@ -14,7 +14,7 @@ fn main() { } }; - // Generator taking a non-`Copy` resume arg. + // Coroutine taking a non-`Copy` resume arg. let gen_move = |mut x: Box<usize>| { loop { drop(x); diff --git a/tests/ui/generator/resume-live-across-yield.rs b/tests/ui/generator/resume-live-across-yield.rs index 4c4cf117a55..9ea102dbfa1 100644 --- a/tests/ui/generator/resume-live-across-yield.rs +++ b/tests/ui/generator/resume-live-across-yield.rs @@ -2,7 +2,7 @@ #![feature(generators, generator_trait)] -use std::ops::{Generator, GeneratorState}; +use std::ops::{Coroutine, CoroutineState}; use std::pin::Pin; use std::sync::atomic::{AtomicUsize, Ordering}; @@ -27,11 +27,11 @@ fn main() { assert_eq!( g.as_mut().resume(Dropper(String::from("Hello world!"))), - GeneratorState::Yielded(()) + CoroutineState::Yielded(()) ); assert_eq!(DROP.load(Ordering::Acquire), 0); match g.as_mut().resume(Dropper(String::from("Number Two"))) { - GeneratorState::Complete(dropper) => { + CoroutineState::Complete(dropper) => { assert_eq!(DROP.load(Ordering::Acquire), 1); assert_eq!(dropper.0, "Number Two"); drop(dropper); diff --git a/tests/ui/generator/retain-resume-ref.rs b/tests/ui/generator/retain-resume-ref.rs index 0606ea71cdf..a1e527dcade 100644 --- a/tests/ui/generator/retain-resume-ref.rs +++ b/tests/ui/generator/retain-resume-ref.rs @@ -4,8 +4,8 @@ use std::marker::Unpin; use std::ops::{ - Generator, - GeneratorState::{self, *}, + Coroutine, + CoroutineState::{self, *}, }; use std::pin::Pin; diff --git a/tests/ui/generator/size-moved-locals.rs b/tests/ui/generator/size-moved-locals.rs index 601a3141828..8abfe28f0fc 100644 --- a/tests/ui/generator/size-moved-locals.rs +++ b/tests/ui/generator/size-moved-locals.rs @@ -16,7 +16,7 @@ #![feature(generators, generator_trait)] -use std::ops::Generator; +use std::ops::Coroutine; const FOO_SIZE: usize = 1024; struct Foo(#[allow(unused_tuple_struct_fields)] [u8; FOO_SIZE]); @@ -25,7 +25,7 @@ impl Drop for Foo { fn drop(&mut self) {} } -fn move_before_yield() -> impl Generator<Yield = (), Return = ()> { +fn move_before_yield() -> impl Coroutine<Yield = (), Return = ()> { static || { let first = Foo([0; FOO_SIZE]); let _second = first; @@ -36,7 +36,7 @@ fn move_before_yield() -> impl Generator<Yield = (), Return = ()> { fn noop() {} -fn move_before_yield_with_noop() -> impl Generator<Yield = (), Return = ()> { +fn move_before_yield_with_noop() -> impl Coroutine<Yield = (), Return = ()> { static || { let first = Foo([0; FOO_SIZE]); noop(); @@ -48,7 +48,7 @@ fn move_before_yield_with_noop() -> impl Generator<Yield = (), Return = ()> { // Today we don't have NRVO (we allocate space for both `first` and `second`,) // but we can overlap `first` with `_third`. -fn overlap_move_points() -> impl Generator<Yield = (), Return = ()> { +fn overlap_move_points() -> impl Coroutine<Yield = (), Return = ()> { static || { let first = Foo([0; FOO_SIZE]); yield; @@ -59,7 +59,7 @@ fn overlap_move_points() -> impl Generator<Yield = (), Return = ()> { } } -fn overlap_x_and_y() -> impl Generator<Yield = (), Return = ()> { +fn overlap_x_and_y() -> impl Coroutine<Yield = (), Return = ()> { static || { let x = Foo([0; FOO_SIZE]); yield; diff --git a/tests/ui/generator/sized-yield.rs b/tests/ui/generator/sized-yield.rs index c6dd738d6ac..abd4a3dd88d 100644 --- a/tests/ui/generator/sized-yield.rs +++ b/tests/ui/generator/sized-yield.rs @@ -1,14 +1,14 @@ #![feature(generators, generator_trait)] -use std::ops::Generator; +use std::ops::Coroutine; use std::pin::Pin; fn main() { - let s = String::from("foo"); - let mut gen = move || { - //~^ ERROR the size for values of type - yield s[..]; - }; - Pin::new(&mut gen).resume(()); - //~^ ERROR the size for values of type + let s = String::from("foo"); + let mut gen = move || { + //~^ ERROR the size for values of type + yield s[..]; + }; + Pin::new(&mut gen).resume(()); + //~^ ERROR the size for values of type } diff --git a/tests/ui/generator/sized-yield.stderr b/tests/ui/generator/sized-yield.stderr index fb34540d969..626c81b3945 100644 --- a/tests/ui/generator/sized-yield.stderr +++ b/tests/ui/generator/sized-yield.stderr @@ -1,24 +1,24 @@ error[E0277]: the size for values of type `str` cannot be known at compilation time - --> $DIR/sized-yield.rs:8:26 + --> $DIR/sized-yield.rs:8:27 | -LL | let mut gen = move || { - | __________________________^ +LL | let mut gen = move || { + | ___________________________^ LL | | -LL | | yield s[..]; -LL | | }; - | |____^ doesn't have a size known at compile-time +LL | | yield s[..]; +LL | | }; + | |_____^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `str` = note: the yield type of a generator must have a statically known size error[E0277]: the size for values of type `str` cannot be known at compilation time - --> $DIR/sized-yield.rs:12:23 + --> $DIR/sized-yield.rs:12:24 | -LL | Pin::new(&mut gen).resume(()); - | ^^^^^^ doesn't have a size known at compile-time +LL | Pin::new(&mut gen).resume(()); + | ^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `str` -note: required by a bound in `GeneratorState` +note: required by a bound in `CoroutineState` --> $SRC_DIR/core/src/ops/generator.rs:LL:COL error: aborting due to 2 previous errors diff --git a/tests/ui/generator/smoke-resume-args.rs b/tests/ui/generator/smoke-resume-args.rs index fa9271c538f..6399446a5fa 100644 --- a/tests/ui/generator/smoke-resume-args.rs +++ b/tests/ui/generator/smoke-resume-args.rs @@ -8,15 +8,15 @@ use std::fmt::Debug; use std::marker::Unpin; use std::ops::{ - Generator, - GeneratorState::{self, *}, + Coroutine, + CoroutineState::{self, *}, }; use std::pin::Pin; use std::sync::atomic::{AtomicUsize, Ordering}; -fn drain<G: Generator<R, Yield = Y> + Unpin, R, Y>( +fn drain<G: Coroutine<R, Yield = Y> + Unpin, R, Y>( gen: &mut G, - inout: Vec<(R, GeneratorState<Y, G::Return>)>, + inout: Vec<(R, CoroutineState<Y, G::Return>)>, ) where Y: Debug + PartialEq, G::Return: Debug + PartialEq, diff --git a/tests/ui/generator/smoke.rs b/tests/ui/generator/smoke.rs index 7a917a05dd9..3e476a86cef 100644 --- a/tests/ui/generator/smoke.rs +++ b/tests/ui/generator/smoke.rs @@ -8,7 +8,7 @@ #![feature(generators, generator_trait)] -use std::ops::{GeneratorState, Generator}; +use std::ops::{CoroutineState, Coroutine}; use std::pin::Pin; use std::thread; @@ -21,7 +21,7 @@ fn simple() { }; match Pin::new(&mut foo).resume(()) { - GeneratorState::Complete(()) => {} + CoroutineState::Complete(()) => {} s => panic!("bad state: {:?}", s), } } @@ -37,7 +37,7 @@ fn return_capture() { }; match Pin::new(&mut foo).resume(()) { - GeneratorState::Complete(ref s) if *s == "foo" => {} + CoroutineState::Complete(ref s) if *s == "foo" => {} s => panic!("bad state: {:?}", s), } } @@ -49,11 +49,11 @@ fn simple_yield() { }; match Pin::new(&mut foo).resume(()) { - GeneratorState::Yielded(()) => {} + CoroutineState::Yielded(()) => {} s => panic!("bad state: {:?}", s), } match Pin::new(&mut foo).resume(()) { - GeneratorState::Complete(()) => {} + CoroutineState::Complete(()) => {} s => panic!("bad state: {:?}", s), } } @@ -66,11 +66,11 @@ fn yield_capture() { }; match Pin::new(&mut foo).resume(()) { - GeneratorState::Yielded(ref s) if *s == "foo" => {} + CoroutineState::Yielded(ref s) if *s == "foo" => {} s => panic!("bad state: {:?}", s), } match Pin::new(&mut foo).resume(()) { - GeneratorState::Complete(()) => {} + CoroutineState::Complete(()) => {} s => panic!("bad state: {:?}", s), } } @@ -83,11 +83,11 @@ fn simple_yield_value() { }; match Pin::new(&mut foo).resume(()) { - GeneratorState::Yielded(ref s) if *s == "bar" => {} + CoroutineState::Yielded(ref s) if *s == "bar" => {} s => panic!("bad state: {:?}", s), } match Pin::new(&mut foo).resume(()) { - GeneratorState::Complete(ref s) if *s == "foo" => {} + CoroutineState::Complete(ref s) if *s == "foo" => {} s => panic!("bad state: {:?}", s), } } @@ -101,11 +101,11 @@ fn return_after_yield() { }; match Pin::new(&mut foo).resume(()) { - GeneratorState::Yielded(()) => {} + CoroutineState::Yielded(()) => {} s => panic!("bad state: {:?}", s), } match Pin::new(&mut foo).resume(()) { - GeneratorState::Complete(ref s) if *s == "foo" => {} + CoroutineState::Complete(ref s) if *s == "foo" => {} s => panic!("bad state: {:?}", s), } } @@ -153,11 +153,11 @@ fn send_over_threads() { let mut foo = || { yield }; thread::spawn(move || { match Pin::new(&mut foo).resume(()) { - GeneratorState::Yielded(()) => {} + CoroutineState::Yielded(()) => {} s => panic!("bad state: {:?}", s), } match Pin::new(&mut foo).resume(()) { - GeneratorState::Complete(()) => {} + CoroutineState::Complete(()) => {} s => panic!("bad state: {:?}", s), } }).join().unwrap(); @@ -166,11 +166,11 @@ fn send_over_threads() { let mut foo = || { yield a }; thread::spawn(move || { match Pin::new(&mut foo).resume(()) { - GeneratorState::Yielded(ref s) if *s == "a" => {} + CoroutineState::Yielded(ref s) if *s == "a" => {} s => panic!("bad state: {:?}", s), } match Pin::new(&mut foo).resume(()) { - GeneratorState::Complete(()) => {} + CoroutineState::Complete(()) => {} s => panic!("bad state: {:?}", s), } }).join().unwrap(); diff --git a/tests/ui/generator/static-generators.rs b/tests/ui/generator/static-generators.rs index d098bf1e688..41a8ce56923 100644 --- a/tests/ui/generator/static-generators.rs +++ b/tests/ui/generator/static-generators.rs @@ -3,7 +3,7 @@ #![feature(generators, generator_trait)] use std::pin::Pin; -use std::ops::{Generator, GeneratorState}; +use std::ops::{Coroutine, CoroutineState}; fn main() { let mut generator = static || { @@ -15,6 +15,6 @@ fn main() { // SAFETY: We shadow the original generator variable so have no safe API to // move it after this point. let mut generator = unsafe { Pin::new_unchecked(&mut generator) }; - assert_eq!(generator.as_mut().resume(()), GeneratorState::Yielded(())); - assert_eq!(generator.as_mut().resume(()), GeneratorState::Complete(())); + assert_eq!(generator.as_mut().resume(()), CoroutineState::Yielded(())); + assert_eq!(generator.as_mut().resume(()), CoroutineState::Complete(())); } diff --git a/tests/ui/generator/type-mismatch-error.rs b/tests/ui/generator/type-mismatch-error.rs index d39c788a84b..3742c1d21bd 100644 --- a/tests/ui/generator/type-mismatch-error.rs +++ b/tests/ui/generator/type-mismatch-error.rs @@ -3,9 +3,9 @@ #![feature(generators, generator_trait)] -use std::ops::Generator; +use std::ops::Coroutine; -fn f<G: Generator>(_: G, _: G::Return) {} +fn f<G: Coroutine>(_: G, _: G::Return) {} fn main() { f( diff --git a/tests/ui/generator/type-mismatch-signature-deduction.rs b/tests/ui/generator/type-mismatch-signature-deduction.rs index 8d1ce6c7a43..7ec3a4ee8d0 100644 --- a/tests/ui/generator/type-mismatch-signature-deduction.rs +++ b/tests/ui/generator/type-mismatch-signature-deduction.rs @@ -1,8 +1,8 @@ #![feature(generators, generator_trait)] -use std::ops::Generator; +use std::ops::Coroutine; -fn foo() -> impl Generator<Return = i32> { +fn foo() -> impl Coroutine<Return = i32> { //~^ ERROR type mismatch || { if false { diff --git a/tests/ui/generator/type-mismatch-signature-deduction.stderr b/tests/ui/generator/type-mismatch-signature-deduction.stderr index fe1bade5577..0c02925ffb6 100644 --- a/tests/ui/generator/type-mismatch-signature-deduction.stderr +++ b/tests/ui/generator/type-mismatch-signature-deduction.stderr @@ -18,10 +18,10 @@ LL | Ok(5) LL | Err(5) | ++++ + -error[E0271]: type mismatch resolving `<{generator@$DIR/type-mismatch-signature-deduction.rs:7:5: 7:7} as Generator>::Return == i32` +error[E0271]: type mismatch resolving `<{generator@$DIR/type-mismatch-signature-deduction.rs:7:5: 7:7} as Coroutine>::Return == i32` --> $DIR/type-mismatch-signature-deduction.rs:5:13 | -LL | fn foo() -> impl Generator<Return = i32> { +LL | fn foo() -> impl Coroutine<Return = i32> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Result<{integer}, _>`, found `i32` | = note: expected enum `Result<{integer}, _>` diff --git a/tests/ui/generator/unsized-capture-across-yield.rs b/tests/ui/generator/unsized-capture-across-yield.rs index 7bcb0800ccf..fdb4ccdf85e 100644 --- a/tests/ui/generator/unsized-capture-across-yield.rs +++ b/tests/ui/generator/unsized-capture-across-yield.rs @@ -3,9 +3,9 @@ #![feature(unsized_locals)] //~^ WARN the feature `unsized_locals` is incomplete and may not be safe to use and/or cause compiler crashes -use std::ops::Generator; +use std::ops::Coroutine; -fn capture() -> impl Generator { +fn capture() -> impl Coroutine { let b: [u8] = *(Box::new([]) as Box<[u8]>); move || { println!("{:?}", &b); diff --git a/tests/ui/generator/unsized-local-across-yield.rs b/tests/ui/generator/unsized-local-across-yield.rs index f761f45c2af..590fa9fcd5f 100644 --- a/tests/ui/generator/unsized-local-across-yield.rs +++ b/tests/ui/generator/unsized-local-across-yield.rs @@ -3,9 +3,9 @@ #![feature(unsized_locals)] //~^ WARN the feature `unsized_locals` is incomplete and may not be safe to use and/or cause compiler crashes -use std::ops::Generator; +use std::ops::Coroutine; -fn across() -> impl Generator { +fn across() -> impl Coroutine { move || { let b: [u8] = *(Box::new([]) as Box<[u8]>); //~^ ERROR the size for values of type `[u8]` cannot be known at compilation time diff --git a/tests/ui/generator/xcrate-reachable.rs b/tests/ui/generator/xcrate-reachable.rs index 1b1cff3387d..1b01bef19da 100644 --- a/tests/ui/generator/xcrate-reachable.rs +++ b/tests/ui/generator/xcrate-reachable.rs @@ -6,7 +6,7 @@ extern crate xcrate_reachable as foo; -use std::ops::Generator; +use std::ops::Coroutine; use std::pin::Pin; fn main() { diff --git a/tests/ui/generator/xcrate.rs b/tests/ui/generator/xcrate.rs index 40986bbeb65..0c900b0b84b 100644 --- a/tests/ui/generator/xcrate.rs +++ b/tests/ui/generator/xcrate.rs @@ -6,25 +6,25 @@ extern crate xcrate; -use std::ops::{GeneratorState, Generator}; +use std::ops::{Coroutine, CoroutineState}; use std::pin::Pin; fn main() { let mut foo = xcrate::foo(); match Pin::new(&mut foo).resume(()) { - GeneratorState::Complete(()) => {} + CoroutineState::Complete(()) => {} s => panic!("bad state: {:?}", s), } let mut foo = xcrate::bar(3); match Pin::new(&mut foo).resume(()) { - GeneratorState::Yielded(3) => {} + CoroutineState::Yielded(3) => {} s => panic!("bad state: {:?}", s), } match Pin::new(&mut foo).resume(()) { - GeneratorState::Complete(()) => {} + CoroutineState::Complete(()) => {} s => panic!("bad state: {:?}", s), } } diff --git a/tests/ui/generator/yield-while-iterating.rs b/tests/ui/generator/yield-while-iterating.rs index 985e5d8bdc8..2e95883b0d4 100644 --- a/tests/ui/generator/yield-while-iterating.rs +++ b/tests/ui/generator/yield-while-iterating.rs @@ -1,6 +1,6 @@ #![feature(generators, generator_trait)] -use std::ops::{GeneratorState, Generator}; +use std::ops::{CoroutineState, Coroutine}; use std::cell::Cell; use std::pin::Pin; diff --git a/tests/ui/generator/yield-while-local-borrowed.rs b/tests/ui/generator/yield-while-local-borrowed.rs index 061a64dbc36..7ce2b18cf44 100644 --- a/tests/ui/generator/yield-while-local-borrowed.rs +++ b/tests/ui/generator/yield-while-local-borrowed.rs @@ -1,7 +1,7 @@ #![feature(generators, generator_trait)] -use std::ops::{GeneratorState, Generator}; use std::cell::Cell; +use std::ops::{Coroutine, CoroutineState}; use std::pin::Pin; fn borrow_local_inline() { @@ -12,7 +12,7 @@ fn borrow_local_inline() { let mut b = move || { let a = &mut 3; //~^ ERROR borrow may still be in use when generator yields - yield(); + yield (); println!("{}", a); }; Pin::new(&mut b).resume(()); @@ -24,7 +24,7 @@ fn borrow_local_inline_done() { { let a = &mut 3; } - yield(); + yield (); }; Pin::new(&mut b).resume(()); } @@ -39,11 +39,11 @@ fn borrow_local() { { let b = &a; //~^ ERROR borrow may still be in use when generator yields - yield(); + yield (); println!("{}", b); } }; Pin::new(&mut b).resume(()); } -fn main() { } +fn main() {} diff --git a/tests/ui/generator/yield-while-local-borrowed.stderr b/tests/ui/generator/yield-while-local-borrowed.stderr index c1513ef9b71..d82a0f16108 100644 --- a/tests/ui/generator/yield-while-local-borrowed.stderr +++ b/tests/ui/generator/yield-while-local-borrowed.stderr @@ -4,8 +4,8 @@ error[E0626]: borrow may still be in use when generator yields LL | let a = &mut 3; | ^^^^^^ LL | -LL | yield(); - | ------- possible yield occurs here +LL | yield (); + | -------- possible yield occurs here error[E0626]: borrow may still be in use when generator yields --> $DIR/yield-while-local-borrowed.rs:40:21 @@ -13,8 +13,8 @@ error[E0626]: borrow may still be in use when generator yields LL | let b = &a; | ^^ LL | -LL | yield(); - | ------- possible yield occurs here +LL | yield (); + | -------- possible yield occurs here error: aborting due to 2 previous errors diff --git a/tests/ui/generator/yield-while-ref-reborrowed.rs b/tests/ui/generator/yield-while-ref-reborrowed.rs index a03ef945dd2..7f8842466ac 100644 --- a/tests/ui/generator/yield-while-ref-reborrowed.rs +++ b/tests/ui/generator/yield-while-ref-reborrowed.rs @@ -1,6 +1,6 @@ #![feature(generators, generator_trait)] -use std::ops::{GeneratorState, Generator}; +use std::ops::{CoroutineState, Coroutine}; use std::cell::Cell; use std::pin::Pin; diff --git a/tests/ui/impl-trait/bounds_regression.rs b/tests/ui/impl-trait/bounds_regression.rs index 31fc46203d3..e73bf68f8f6 100644 --- a/tests/ui/impl-trait/bounds_regression.rs +++ b/tests/ui/impl-trait/bounds_regression.rs @@ -1,6 +1,6 @@ // run-pass -pub trait FakeGenerator { +pub trait FakeCoroutine { type Yield; type Return; } @@ -10,14 +10,14 @@ pub trait FakeFuture { } pub fn future_from_generator< - T: FakeGenerator<Yield = ()> + T: FakeCoroutine<Yield = ()> >(x: T) -> impl FakeFuture<Output = T::Return> { GenFuture(x) } -struct GenFuture<T: FakeGenerator<Yield = ()>>(#[allow(unused_tuple_struct_fields)] T); +struct GenFuture<T: FakeCoroutine<Yield = ()>>(#[allow(unused_tuple_struct_fields)] T); -impl<T: FakeGenerator<Yield = ()>> FakeFuture for GenFuture<T> { +impl<T: FakeCoroutine<Yield = ()>> FakeFuture for GenFuture<T> { type Output = T::Return; } diff --git a/tests/ui/impl-trait/issues/issue-58504.rs b/tests/ui/impl-trait/issues/issue-58504.rs index f1d7b94ef2d..ca890fbe71c 100644 --- a/tests/ui/impl-trait/issues/issue-58504.rs +++ b/tests/ui/impl-trait/issues/issue-58504.rs @@ -1,12 +1,12 @@ #![feature(generators, generator_trait, never_type)] -use std::ops::Generator; +use std::ops::Coroutine; -fn mk_gen() -> impl Generator<Return=!, Yield=()> { +fn mk_gen() -> impl Coroutine<Return=!, Yield=()> { || { loop { yield; } } } fn main() { - let gens: [impl Generator<Return=!, Yield=()>;2] = [ mk_gen(), mk_gen() ]; + let gens: [impl Coroutine<Return=!, Yield=()>;2] = [ mk_gen(), mk_gen() ]; //~^ `impl Trait` only allowed in function and inherent method argument and return types } diff --git a/tests/ui/impl-trait/issues/issue-58504.stderr b/tests/ui/impl-trait/issues/issue-58504.stderr index 1be676ee075..49376f559cf 100644 --- a/tests/ui/impl-trait/issues/issue-58504.stderr +++ b/tests/ui/impl-trait/issues/issue-58504.stderr @@ -1,7 +1,7 @@ error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in variable bindings --> $DIR/issue-58504.rs:10:16 | -LL | let gens: [impl Generator<Return=!, Yield=()>;2] = [ mk_gen(), mk_gen() ]; +LL | let gens: [impl Coroutine<Return=!, Yield=()>;2] = [ mk_gen(), mk_gen() ]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/tests/ui/impl-trait/recursive-generator.rs b/tests/ui/impl-trait/recursive-generator.rs index 000af70c454..a63b2174645 100644 --- a/tests/ui/impl-trait/recursive-generator.rs +++ b/tests/ui/impl-trait/recursive-generator.rs @@ -1,8 +1,8 @@ #![feature(generators, generator_trait)] -use std::ops::{Generator, GeneratorState}; +use std::ops::{Coroutine, CoroutineState}; -fn foo() -> impl Generator<Yield = (), Return = ()> { +fn foo() -> impl Coroutine<Yield = (), Return = ()> { //~^ ERROR cannot resolve opaque type //~| NOTE recursive opaque type //~| NOTE in this expansion of desugaring of @@ -10,7 +10,7 @@ fn foo() -> impl Generator<Yield = (), Return = ()> { let mut gen = Box::pin(foo()); //~^ NOTE generator captures itself here let mut r = gen.as_mut().resume(()); - while let GeneratorState::Yielded(v) = r { + while let CoroutineState::Yielded(v) = r { yield v; r = gen.as_mut().resume(()); } diff --git a/tests/ui/impl-trait/recursive-generator.stderr b/tests/ui/impl-trait/recursive-generator.stderr index 86e193d9599..2480e93bb40 100644 --- a/tests/ui/impl-trait/recursive-generator.stderr +++ b/tests/ui/impl-trait/recursive-generator.stderr @@ -1,7 +1,7 @@ error[E0720]: cannot resolve opaque type --> $DIR/recursive-generator.rs:5:13 | -LL | fn foo() -> impl Generator<Yield = (), Return = ()> { +LL | fn foo() -> impl Coroutine<Yield = (), Return = ()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ recursive opaque type ... LL | let mut gen = Box::pin(foo()); diff --git a/tests/ui/lazy-type-alias-impl-trait/freeze_cycle.rs b/tests/ui/lazy-type-alias-impl-trait/freeze_cycle.rs index f02a93ed41b..e140bc21273 100644 --- a/tests/ui/lazy-type-alias-impl-trait/freeze_cycle.rs +++ b/tests/ui/lazy-type-alias-impl-trait/freeze_cycle.rs @@ -2,7 +2,7 @@ #![feature(generator_trait, negative_impls)] -use std::ops::{Generator, GeneratorState}; +use std::ops::{Coroutine, CoroutineState}; use std::task::{Poll, Context}; use std::future::{Future}; use std::ptr::NonNull; @@ -19,15 +19,15 @@ unsafe impl Sync for ResumeTy {} pub const fn from_generator<T>(gen: T) -> impl Future<Output = T::Return> where - T: Generator<ResumeTy, Yield = ()>, + T: Coroutine<ResumeTy, Yield = ()>, { - struct GenFuture<T: Generator<ResumeTy, Yield = ()>>(T); + struct GenFuture<T: Coroutine<ResumeTy, Yield = ()>>(T); // We rely on the fact that async/await futures are immovable in order to create // self-referential borrows in the underlying generator. - impl<T: Generator<ResumeTy, Yield = ()>> !Unpin for GenFuture<T> {} + impl<T: Coroutine<ResumeTy, Yield = ()>> !Unpin for GenFuture<T> {} - impl<T: Generator<ResumeTy, Yield = ()>> Future for GenFuture<T> { + impl<T: Coroutine<ResumeTy, Yield = ()>> Future for GenFuture<T> { type Output = T::Return; fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { // SAFETY: Safe because we're !Unpin + !Drop, and this is just a field projection. @@ -36,8 +36,8 @@ where // Resume the generator, turning the `&mut Context` into a `NonNull` raw pointer. The // `.await` lowering will safely cast that back to a `&mut Context`. match gen.resume(ResumeTy(NonNull::from(cx).cast::<Context<'static>>())) { - GeneratorState::Yielded(()) => Poll::Pending, - GeneratorState::Complete(x) => Poll::Ready(x), + CoroutineState::Yielded(()) => Poll::Pending, + CoroutineState::Complete(x) => Poll::Ready(x), } } } diff --git a/tests/ui/lint/unused/issue-74883-unused-paren-baren-yield.rs b/tests/ui/lint/unused/issue-74883-unused-paren-baren-yield.rs index 8064c3a88d1..e6c82d957fb 100644 --- a/tests/ui/lint/unused/issue-74883-unused-paren-baren-yield.rs +++ b/tests/ui/lint/unused/issue-74883-unused-paren-baren-yield.rs @@ -2,7 +2,7 @@ #![feature(generators)] #![deny(unused_braces, unused_parens)] -use std::ops::Generator; +use std::ops::Coroutine; use std::pin::Pin; fn main() { diff --git a/tests/ui/nll/issue-55850.rs b/tests/ui/nll/issue-55850.rs index e6279bd028e..fc7d2c4864c 100644 --- a/tests/ui/nll/issue-55850.rs +++ b/tests/ui/nll/issue-55850.rs @@ -2,15 +2,15 @@ #![feature(generators, generator_trait)] use std::marker::Unpin; -use std::ops::Generator; -use std::ops::GeneratorState::Yielded; +use std::ops::Coroutine; +use std::ops::CoroutineState::Yielded; use std::pin::Pin; pub struct GenIter<G>(G); impl <G> Iterator for GenIter<G> where - G: Generator + Unpin, + G: Coroutine + Unpin, { type Item = G::Yield; diff --git a/tests/ui/packed/packed-struct-drop-aligned.rs b/tests/ui/packed/packed-struct-drop-aligned.rs index 9f9f41e2515..f270c4adfe3 100644 --- a/tests/ui/packed/packed-struct-drop-aligned.rs +++ b/tests/ui/packed/packed-struct-drop-aligned.rs @@ -3,7 +3,7 @@ #![feature(generator_trait)] use std::cell::Cell; use std::mem; -use std::ops::Generator; +use std::ops::Coroutine; use std::pin::Pin; struct Aligned<'a> { diff --git a/tests/ui/polymorphization/generators.rs b/tests/ui/polymorphization/generators.rs index 779bac0ace2..1a351a6ac49 100644 --- a/tests/ui/polymorphization/generators.rs +++ b/tests/ui/polymorphization/generators.rs @@ -4,7 +4,7 @@ //~^ WARN the feature `generic_const_exprs` is incomplete use std::marker::Unpin; -use std::ops::{Generator, GeneratorState}; +use std::ops::{Coroutine, CoroutineState}; use std::pin::Pin; enum YieldOrReturn<Y, R> { @@ -14,13 +14,13 @@ enum YieldOrReturn<Y, R> { fn finish<T, Y, R>(mut t: T) -> Vec<YieldOrReturn<Y, R>> where - T: Generator<(), Yield = Y, Return = R> + Unpin, + T: Coroutine<(), Yield = Y, Return = R> + Unpin, { let mut results = Vec::new(); loop { match Pin::new(&mut t).resume(()) { - GeneratorState::Yielded(yielded) => results.push(YieldOrReturn::Yield(yielded)), - GeneratorState::Complete(returned) => { + CoroutineState::Yielded(yielded) => results.push(YieldOrReturn::Yield(yielded)), + CoroutineState::Complete(returned) => { results.push(YieldOrReturn::Return(returned)); return results; } @@ -31,7 +31,7 @@ where // This test checks that the polymorphization analysis functions on generators. #[rustc_polymorphize_error] -pub fn unused_type<T>() -> impl Generator<(), Yield = u32, Return = u32> + Unpin { +pub fn unused_type<T>() -> impl Coroutine<(), Yield = u32, Return = u32> + Unpin { || { //~^ ERROR item has unused generic parameters yield 1; @@ -40,7 +40,7 @@ pub fn unused_type<T>() -> impl Generator<(), Yield = u32, Return = u32> + Unpin } #[rustc_polymorphize_error] -pub fn used_type_in_yield<Y: Default>() -> impl Generator<(), Yield = Y, Return = u32> + Unpin { +pub fn used_type_in_yield<Y: Default>() -> impl Coroutine<(), Yield = Y, Return = u32> + Unpin { || { yield Y::default(); 2 @@ -48,7 +48,7 @@ pub fn used_type_in_yield<Y: Default>() -> impl Generator<(), Yield = Y, Return } #[rustc_polymorphize_error] -pub fn used_type_in_return<R: Default>() -> impl Generator<(), Yield = u32, Return = R> + Unpin { +pub fn used_type_in_return<R: Default>() -> impl Coroutine<(), Yield = u32, Return = R> + Unpin { || { yield 3; R::default() @@ -56,7 +56,7 @@ pub fn used_type_in_return<R: Default>() -> impl Generator<(), Yield = u32, Retu } #[rustc_polymorphize_error] -pub fn unused_const<const T: u32>() -> impl Generator<(), Yield = u32, Return = u32> + Unpin { +pub fn unused_const<const T: u32>() -> impl Coroutine<(), Yield = u32, Return = u32> + Unpin { || { //~^ ERROR item has unused generic parameters yield 1; @@ -65,7 +65,7 @@ pub fn unused_const<const T: u32>() -> impl Generator<(), Yield = u32, Return = } #[rustc_polymorphize_error] -pub fn used_const_in_yield<const Y: u32>() -> impl Generator<(), Yield = u32, Return = u32> + Unpin +pub fn used_const_in_yield<const Y: u32>() -> impl Coroutine<(), Yield = u32, Return = u32> + Unpin { || { yield Y; @@ -74,7 +74,7 @@ pub fn used_const_in_yield<const Y: u32>() -> impl Generator<(), Yield = u32, Re } #[rustc_polymorphize_error] -pub fn used_const_in_return<const R: u32>() -> impl Generator<(), Yield = u32, Return = u32> + Unpin +pub fn used_const_in_return<const R: u32>() -> impl Coroutine<(), Yield = u32, Return = u32> + Unpin { || { yield 4; diff --git a/tests/ui/polymorphization/generators.stderr b/tests/ui/polymorphization/generators.stderr index 32d49d25f02..223cc10165b 100644 --- a/tests/ui/polymorphization/generators.stderr +++ b/tests/ui/polymorphization/generators.stderr @@ -10,7 +10,7 @@ LL | #![feature(generic_const_exprs, generators, generator_trait, rustc_attrs)] error: item has unused generic parameters --> $DIR/generators.rs:35:5 | -LL | pub fn unused_type<T>() -> impl Generator<(), Yield = u32, Return = u32> + Unpin { +LL | pub fn unused_type<T>() -> impl Coroutine<(), Yield = u32, Return = u32> + Unpin { | - generic parameter `T` is unused LL | || { | ^^ @@ -18,7 +18,7 @@ LL | || { error: item has unused generic parameters --> $DIR/generators.rs:60:5 | -LL | pub fn unused_const<const T: u32>() -> impl Generator<(), Yield = u32, Return = u32> + Unpin { +LL | pub fn unused_const<const T: u32>() -> impl Coroutine<(), Yield = u32, Return = u32> + Unpin { | ------------ generic parameter `T` is unused LL | || { | ^^ diff --git a/tests/ui/print_type_sizes/generator.rs b/tests/ui/print_type_sizes/generator.rs index d1cd36274ef..493c538942a 100644 --- a/tests/ui/print_type_sizes/generator.rs +++ b/tests/ui/print_type_sizes/generator.rs @@ -4,9 +4,9 @@ #![feature(generators, generator_trait)] -use std::ops::Generator; +use std::ops::Coroutine; -fn generator<const C: usize>(array: [u8; C]) -> impl Generator<Yield = (), Return = ()> { +fn generator<const C: usize>(array: [u8; C]) -> impl Coroutine<Yield = (), Return = ()> { move |()| { yield (); let _ = array; diff --git a/tests/ui/rfcs/rfc-2091-track-caller/tracked-closure.rs b/tests/ui/rfcs/rfc-2091-track-caller/tracked-closure.rs index 670c423a7e0..7cf5fdc662f 100644 --- a/tests/ui/rfcs/rfc-2091-track-caller/tracked-closure.rs +++ b/tests/ui/rfcs/rfc-2091-track-caller/tracked-closure.rs @@ -5,7 +5,7 @@ #![feature(generator_trait)] #![feature(generators)] -use std::ops::{Generator, GeneratorState}; +use std::ops::{Coroutine, CoroutineState}; use std::pin::Pin; use std::panic::Location; @@ -93,21 +93,21 @@ fn test_closure() { #[track_caller] -fn mono_generator<F: Generator<String, Yield = (&'static str, String, Loc), Return = ()>>( +fn mono_generator<F: Coroutine<String, Yield = (&'static str, String, Loc), Return = ()>>( val: Pin<&mut F> ) -> (&'static str, String, Loc) { match val.resume("Mono".to_string()) { - GeneratorState::Yielded(val) => val, + CoroutineState::Yielded(val) => val, _ => unreachable!() } } #[track_caller] fn dyn_generator( - val: Pin<&mut dyn Generator<String, Yield = (&'static str, String, Loc), Return = ()>> + val: Pin<&mut dyn Coroutine<String, Yield = (&'static str, String, Loc), Return = ()>> ) -> (&'static str, String, Loc) { match val.resume("Dyn".to_string()) { - GeneratorState::Yielded(val) => val, + CoroutineState::Yielded(val) => val, _ => unreachable!() } } @@ -122,7 +122,7 @@ fn test_generator() { let (dyn_ret, dyn_arg, dyn_loc) = dyn_generator(pinned.as_mut()); assert_eq!(dyn_ret, "first"); assert_eq!(dyn_arg, "Dyn".to_string()); - // The `Generator` trait does not have `#[track_caller]` on `resume`, so + // The `Coroutine` trait does not have `#[track_caller]` on `resume`, so // this will not match. assert_ne!(dyn_loc.file(), file!()); @@ -139,7 +139,7 @@ fn test_generator() { let non_tracked_generator = || { yield Location::caller(); }; let non_tracked_line = line!() - 1; // This is the line of the generator, not its caller let non_tracked_loc = match Box::pin(non_tracked_generator).as_mut().resume(()) { - GeneratorState::Yielded(val) => val, + CoroutineState::Yielded(val) => val, _ => unreachable!() }; assert_eq!(non_tracked_loc.file(), file!()); diff --git a/tests/ui/sanitize/issue-111184-generator-witness.rs b/tests/ui/sanitize/issue-111184-generator-witness.rs index d36d8bce561..dffb739f203 100644 --- a/tests/ui/sanitize/issue-111184-generator-witness.rs +++ b/tests/ui/sanitize/issue-111184-generator-witness.rs @@ -1,4 +1,4 @@ -// Regression test for issue 111184, where ty::GeneratorWitness were not expected to occur in +// Regression test for issue 111184, where ty::CoroutineWitness were not expected to occur in // encode_ty and caused the compiler to ICE. // // needs-sanitizer-cfi diff --git a/tests/ui/traits/new-solver/generator.fail.stderr b/tests/ui/traits/new-solver/generator.fail.stderr index e3fe4bf5a6a..a450bf57c4d 100644 --- a/tests/ui/traits/new-solver/generator.fail.stderr +++ b/tests/ui/traits/new-solver/generator.fail.stderr @@ -1,4 +1,4 @@ -error[E0277]: the trait bound `{generator@$DIR/generator.rs:18:21: 18:23}: Generator<A>` is not satisfied +error[E0277]: the trait bound `{generator@$DIR/generator.rs:18:21: 18:23}: Coroutine<A>` is not satisfied --> $DIR/generator.rs:18:21 | LL | needs_generator(|| { @@ -10,15 +10,15 @@ LL | | LL | | LL | | yield (); LL | | }); - | |_____^ the trait `Generator<A>` is not implemented for `{generator@$DIR/generator.rs:18:21: 18:23}` + | |_____^ the trait `Coroutine<A>` is not implemented for `{generator@$DIR/generator.rs:18:21: 18:23}` | note: required by a bound in `needs_generator` --> $DIR/generator.rs:14:28 | -LL | fn needs_generator(_: impl Generator<A, Yield = B, Return = C>) {} +LL | fn needs_generator(_: impl Coroutine<A, Yield = B, Return = C>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `needs_generator` -error[E0271]: type mismatch resolving `<{generator@$DIR/generator.rs:18:21: 18:23} as Generator<A>>::Yield == B` +error[E0271]: type mismatch resolving `<{generator@$DIR/generator.rs:18:21: 18:23} as Coroutine<A>>::Yield == B` --> $DIR/generator.rs:18:21 | LL | needs_generator(|| { @@ -35,10 +35,10 @@ LL | | }); note: required by a bound in `needs_generator` --> $DIR/generator.rs:14:41 | -LL | fn needs_generator(_: impl Generator<A, Yield = B, Return = C>) {} +LL | fn needs_generator(_: impl Coroutine<A, Yield = B, Return = C>) {} | ^^^^^^^^^ required by this bound in `needs_generator` -error[E0271]: type mismatch resolving `<{generator@$DIR/generator.rs:18:21: 18:23} as Generator<A>>::Return == C` +error[E0271]: type mismatch resolving `<{generator@$DIR/generator.rs:18:21: 18:23} as Coroutine<A>>::Return == C` --> $DIR/generator.rs:18:21 | LL | needs_generator(|| { @@ -55,7 +55,7 @@ LL | | }); note: required by a bound in `needs_generator` --> $DIR/generator.rs:14:52 | -LL | fn needs_generator(_: impl Generator<A, Yield = B, Return = C>) {} +LL | fn needs_generator(_: impl Coroutine<A, Yield = B, Return = C>) {} | ^^^^^^^^^^ required by this bound in `needs_generator` error: aborting due to 3 previous errors diff --git a/tests/ui/traits/new-solver/generator.rs b/tests/ui/traits/new-solver/generator.rs index 364373ca8be..aa7eaeacb08 100644 --- a/tests/ui/traits/new-solver/generator.rs +++ b/tests/ui/traits/new-solver/generator.rs @@ -5,20 +5,20 @@ #![feature(generator_trait, generators)] -use std::ops::Generator; +use std::ops::Coroutine; struct A; struct B; struct C; -fn needs_generator(_: impl Generator<A, Yield = B, Return = C>) {} +fn needs_generator(_: impl Coroutine<A, Yield = B, Return = C>) {} #[cfg(fail)] fn main() { needs_generator(|| { - //[fail]~^ ERROR Generator<A>` is not satisfied - //[fail]~| ERROR as Generator<A>>::Yield == B` - //[fail]~| ERROR as Generator<A>>::Return == C` + //[fail]~^ ERROR Coroutine<A>` is not satisfied + //[fail]~| ERROR as Coroutine<A>>::Yield == B` + //[fail]~| ERROR as Coroutine<A>>::Return == C` yield (); }); } diff --git a/tests/ui/type-alias-impl-trait/issue-53678-generator-and-const-fn.rs b/tests/ui/type-alias-impl-trait/issue-53678-generator-and-const-fn.rs index a213dbba4ea..277d9780dfa 100644 --- a/tests/ui/type-alias-impl-trait/issue-53678-generator-and-const-fn.rs +++ b/tests/ui/type-alias-impl-trait/issue-53678-generator-and-const-fn.rs @@ -4,9 +4,9 @@ // check-pass mod gen { - use std::ops::Generator; + use std::ops::Coroutine; - pub type GenOnce<Y, R> = impl Generator<Yield = Y, Return = R>; + pub type GenOnce<Y, R> = impl Coroutine<Yield = Y, Return = R>; pub const fn const_generator<Y, R>(yielding: Y, returning: R) -> GenOnce<Y, R> { move || { diff --git a/tests/ui/type-alias-impl-trait/issue-58662-generator-with-lifetime.rs b/tests/ui/type-alias-impl-trait/issue-58662-generator-with-lifetime.rs index 477b61390ed..e968a5d8262 100644 --- a/tests/ui/type-alias-impl-trait/issue-58662-generator-with-lifetime.rs +++ b/tests/ui/type-alias-impl-trait/issue-58662-generator-with-lifetime.rs @@ -3,11 +3,11 @@ #![feature(generators, generator_trait)] #![feature(type_alias_impl_trait)] -use std::ops::{Generator, GeneratorState}; +use std::ops::{Coroutine, CoroutineState}; use std::pin::Pin; -type RandGenerator<'a> = impl Generator<Return = (), Yield = u64> + 'a; -fn rand_generator<'a>(rng: &'a ()) -> RandGenerator<'a> { +type RandCoroutine<'a> = impl Coroutine<Return = (), Yield = u64> + 'a; +fn rand_generator<'a>(rng: &'a ()) -> RandCoroutine<'a> { move || { let _rng = rng; loop { @@ -16,9 +16,9 @@ fn rand_generator<'a>(rng: &'a ()) -> RandGenerator<'a> { } } -pub type RandGeneratorWithIndirection<'c> = impl Generator<Return = (), Yield = u64> + 'c; -pub fn rand_generator_with_indirection<'a>(rng: &'a ()) -> RandGeneratorWithIndirection<'a> { - fn helper<'b>(rng: &'b ()) -> impl 'b + Generator<Return = (), Yield = u64> { +pub type RandCoroutineWithIndirection<'c> = impl Coroutine<Return = (), Yield = u64> + 'c; +pub fn rand_generator_with_indirection<'a>(rng: &'a ()) -> RandCoroutineWithIndirection<'a> { + fn helper<'b>(rng: &'b ()) -> impl 'b + Coroutine<Return = (), Yield = u64> { move || { let _rng = rng; loop { @@ -33,7 +33,7 @@ pub fn rand_generator_with_indirection<'a>(rng: &'a ()) -> RandGeneratorWithIndi fn main() { let mut gen = rand_generator(&()); match unsafe { Pin::new_unchecked(&mut gen) }.resume(()) { - GeneratorState::Yielded(_) => {} - GeneratorState::Complete(_) => {} + CoroutineState::Yielded(_) => {} + CoroutineState::Complete(_) => {} }; } diff --git a/tests/ui/type-alias-impl-trait/issue-94429.rs b/tests/ui/type-alias-impl-trait/issue-94429.rs index d764545f906..edebbf12ccd 100644 --- a/tests/ui/type-alias-impl-trait/issue-94429.rs +++ b/tests/ui/type-alias-impl-trait/issue-94429.rs @@ -1,8 +1,8 @@ #![feature(impl_trait_in_assoc_type, generator_trait, generators)] -use std::ops::Generator; +use std::ops::Coroutine; trait Runnable { - type Gen: Generator<Yield = (), Return = ()>; + type Gen: Coroutine<Yield = (), Return = ()>; fn run(&mut self) -> Self::Gen; } @@ -10,7 +10,7 @@ trait Runnable { struct Implementor {} impl Runnable for Implementor { - type Gen = impl Generator<Yield = (), Return = ()>; + type Gen = impl Coroutine<Yield = (), Return = ()>; fn run(&mut self) -> Self::Gen { //~^ ERROR: type mismatch resolving diff --git a/tests/ui/type-alias-impl-trait/issue-94429.stderr b/tests/ui/type-alias-impl-trait/issue-94429.stderr index 26605cdd2c2..5f370dded56 100644 --- a/tests/ui/type-alias-impl-trait/issue-94429.stderr +++ b/tests/ui/type-alias-impl-trait/issue-94429.stderr @@ -1,4 +1,4 @@ -error[E0271]: type mismatch resolving `<{generator@$DIR/issue-94429.rs:17:9: 17:16} as Generator>::Yield == ()` +error[E0271]: type mismatch resolving `<{generator@$DIR/issue-94429.rs:17:9: 17:16} as Coroutine>::Yield == ()` --> $DIR/issue-94429.rs:15:26 | LL | fn run(&mut self) -> Self::Gen { |
