From 60956837cfbf22bd8edd80f57a856e141f7deb8c Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Thu, 19 Oct 2023 16:06:43 +0000 Subject: [PATCH] s/Generator/Coroutine/ --- compiler/rustc_ast_lowering/src/errors.rs | 4 +- compiler/rustc_ast_lowering/src/expr.rs | 36 ++--- compiler/rustc_ast_lowering/src/item.rs | 2 +- compiler/rustc_ast_lowering/src/lib.rs | 2 +- .../src/diagnostics/conflict_errors.rs | 30 ++-- .../src/diagnostics/explain_borrow.rs | 2 +- .../rustc_borrowck/src/diagnostics/mod.rs | 26 ++-- .../src/diagnostics/region_errors.rs | 4 +- .../src/diagnostics/region_name.rs | 10 +- compiler/rustc_borrowck/src/invalidation.rs | 2 +- compiler/rustc_borrowck/src/lib.rs | 8 +- .../rustc_borrowck/src/session_diagnostics.rs | 20 +-- compiler/rustc_borrowck/src/type_check/mod.rs | 16 +-- .../rustc_borrowck/src/universal_regions.rs | 20 +-- .../example/std_example.rs | 2 +- .../scripts/test_rustc_tests.sh | 2 +- compiler/rustc_codegen_cranelift/src/base.rs | 2 +- .../rustc_codegen_cranelift/src/constant.rs | 2 +- .../rustc_codegen_gcc/example/std_example.rs | 2 +- compiler/rustc_codegen_gcc/src/type_of.rs | 6 +- .../src/coverageinfo/mapgen.rs | 2 +- .../src/debuginfo/metadata.rs | 4 +- .../src/debuginfo/metadata/enums/cpp_like.rs | 6 +- .../src/debuginfo/metadata/enums/mod.rs | 12 +- .../src/debuginfo/metadata/enums/native.rs | 6 +- compiler/rustc_codegen_llvm/src/type_of.rs | 6 +- .../src/debuginfo/type_names.rs | 16 +-- compiler/rustc_codegen_ssa/src/mir/analyze.rs | 2 +- compiler/rustc_codegen_ssa/src/mir/block.rs | 2 +- .../src/const_eval/valtrees.rs | 8 +- .../src/interpret/discriminant.rs | 2 +- .../src/interpret/eval_context.rs | 4 +- .../src/interpret/intrinsics.rs | 4 +- .../src/interpret/terminator.rs | 2 +- .../rustc_const_eval/src/interpret/util.rs | 2 +- .../src/interpret/validity.rs | 20 +-- .../src/transform/check_consts/check.rs | 10 +- .../src/transform/check_consts/ops.rs | 8 +- .../check_consts/post_drop_elaboration.rs | 2 +- .../src/transform/validate.rs | 14 +- .../rustc_const_eval/src/util/type_name.rs | 4 +- .../src/error_codes/E0626.md | 10 +- .../src/error_codes/E0790.md | 16 +-- compiler/rustc_hir/src/def.rs | 10 +- compiler/rustc_hir/src/hir.rs | 46 +++--- compiler/rustc_hir/src/lang_items.rs | 4 +- .../rustc_hir_analysis/src/check/check.rs | 8 +- .../src/coherence/inherent_impls.rs | 4 +- .../src/coherence/orphan.rs | 4 +- compiler/rustc_hir_analysis/src/collect.rs | 2 +- .../src/variance/constraints.rs | 4 +- compiler/rustc_hir_typeck/src/callee.rs | 2 +- compiler/rustc_hir_typeck/src/cast.rs | 4 +- compiler/rustc_hir_typeck/src/check.rs | 8 +- compiler/rustc_hir_typeck/src/closure.rs | 16 +-- compiler/rustc_hir_typeck/src/errors.rs | 2 +- compiler/rustc_hir_typeck/src/expr.rs | 4 +- .../rustc_hir_typeck/src/fn_ctxt/_impl.rs | 2 +- .../src/fn_ctxt/adjust_fulfillment_errors.rs | 2 +- .../src/fn_ctxt/suggestions.rs | 6 +- compiler/rustc_hir_typeck/src/inherited.rs | 2 +- compiler/rustc_hir_typeck/src/lib.rs | 4 +- compiler/rustc_hir_typeck/src/upvar.rs | 2 +- .../src/infer/canonical/canonicalizer.rs | 4 +- .../src/infer/error_reporting/mod.rs | 8 +- .../infer/error_reporting/need_type_info.rs | 2 +- .../infer/error_reporting/note_and_explain.rs | 2 +- .../rustc_infer/src/infer/opaque_types.rs | 2 +- .../src/infer/outlives/components.rs | 4 +- compiler/rustc_interface/src/passes.rs | 2 +- compiler/rustc_lint/src/foreign_modules.rs | 4 +- compiler/rustc_lint/src/lints.rs | 2 +- compiler/rustc_lint/src/types.rs | 4 +- compiler/rustc_lint/src/unused.rs | 14 +- compiler/rustc_metadata/src/rmeta/encoder.rs | 32 ++--- compiler/rustc_metadata/src/rmeta/mod.rs | 4 +- compiler/rustc_metadata/src/rmeta/table.rs | 2 +- compiler/rustc_middle/src/hir/map/mod.rs | 4 +- compiler/rustc_middle/src/mir/mod.rs | 20 +-- compiler/rustc_middle/src/mir/pretty.rs | 8 +- compiler/rustc_middle/src/mir/query.rs | 20 +-- compiler/rustc_middle/src/mir/syntax.rs | 24 ++-- compiler/rustc_middle/src/mir/tcx.rs | 2 +- compiler/rustc_middle/src/mir/terminator.rs | 26 ++-- .../rustc_middle/src/mir/type_foldable.rs | 4 +- compiler/rustc_middle/src/mir/visit.rs | 4 +- compiler/rustc_middle/src/query/erase.rs | 4 +- compiler/rustc_middle/src/query/mod.rs | 4 +- compiler/rustc_middle/src/traits/mod.rs | 2 +- compiler/rustc_middle/src/traits/select.rs | 4 +- compiler/rustc_middle/src/ty/context.rs | 6 +- compiler/rustc_middle/src/ty/diagnostics.rs | 8 +- compiler/rustc_middle/src/ty/error.rs | 8 +- compiler/rustc_middle/src/ty/fast_reject.rs | 20 +-- compiler/rustc_middle/src/ty/flags.rs | 4 +- compiler/rustc_middle/src/ty/generic_args.rs | 10 +- compiler/rustc_middle/src/ty/instance.rs | 2 +- compiler/rustc_middle/src/ty/layout.rs | 4 +- compiler/rustc_middle/src/ty/mod.rs | 8 +- compiler/rustc_middle/src/ty/opaque_types.rs | 4 +- compiler/rustc_middle/src/ty/parameterized.rs | 4 +- compiler/rustc_middle/src/ty/print/mod.rs | 4 +- compiler/rustc_middle/src/ty/print/pretty.rs | 10 +- compiler/rustc_middle/src/ty/relate.rs | 30 ++-- .../rustc_middle/src/ty/structural_impls.rs | 12 +- compiler/rustc_middle/src/ty/sty.rs | 72 +++++----- compiler/rustc_middle/src/ty/util.rs | 36 ++--- compiler/rustc_middle/src/ty/walk.rs | 4 +- .../src/build/expr/as_rvalue.rs | 4 +- compiler/rustc_mir_build/src/build/mod.rs | 12 +- compiler/rustc_mir_build/src/build/scope.rs | 14 +- compiler/rustc_mir_build/src/lints.rs | 2 +- compiler/rustc_mir_build/src/thir/cx/expr.rs | 4 +- compiler/rustc_mir_build/src/thir/cx/mod.rs | 4 +- .../rustc_mir_dataflow/src/elaborate_drops.rs | 2 +- .../src/impls/borrowed_locals.rs | 2 +- .../src/impls/initialized.rs | 2 +- .../src/impls/storage_liveness.rs | 4 +- .../src/move_paths/builder.rs | 10 +- .../rustc_mir_dataflow/src/value_analysis.rs | 2 +- .../src/abort_unwinding_calls.rs | 2 +- .../rustc_mir_transform/src/check_unsafety.rs | 4 +- .../rustc_mir_transform/src/const_prop.rs | 2 +- .../src/const_prop_lint.rs | 4 +- .../rustc_mir_transform/src/coverage/graph.rs | 2 +- .../rustc_mir_transform/src/coverage/spans.rs | 2 +- .../src/coverage/spans/from_mir.rs | 2 +- compiler/rustc_mir_transform/src/dest_prop.rs | 2 +- .../src/ffi_unwind_calls.rs | 2 +- compiler/rustc_mir_transform/src/generator.rs | 134 +++++++++--------- compiler/rustc_mir_transform/src/gvn.rs | 2 +- compiler/rustc_mir_transform/src/inline.rs | 2 +- compiler/rustc_mir_transform/src/lib.rs | 2 +- .../src/remove_noop_landing_pads.rs | 2 +- .../src/separate_const_switch.rs | 4 +- compiler/rustc_mir_transform/src/shim.rs | 8 +- compiler/rustc_monomorphize/src/collector.rs | 2 +- .../rustc_monomorphize/src/polymorphize.rs | 6 +- compiler/rustc_passes/src/liveness.rs | 4 +- compiler/rustc_privacy/src/lib.rs | 6 +- .../rustc_resolve/src/build_reduced_graph.rs | 2 +- compiler/rustc_session/src/code_stats.rs | 12 +- compiler/rustc_smir/src/rustc_internal/mod.rs | 4 +- compiler/rustc_smir/src/rustc_smir/mod.rs | 28 ++-- compiler/rustc_symbol_mangling/src/legacy.rs | 4 +- compiler/rustc_symbol_mangling/src/lib.rs | 2 +- .../src/typeid/typeid_itanium_cxx_abi.rs | 8 +- compiler/rustc_symbol_mangling/src/v0.rs | 4 +- .../src/solve/assembly/mod.rs | 14 +- .../src/solve/assembly/structural_traits.rs | 18 +-- .../src/solve/canonicalize.rs | 4 +- .../src/solve/project_goals/mod.rs | 16 +-- .../src/solve/trait_goals.rs | 14 +- .../src/traits/coherence.rs | 4 +- .../src/traits/error_reporting/suggestions.rs | 62 ++++---- .../error_reporting/type_err_ctxt_ext.rs | 14 +- .../src/traits/project.rs | 14 +- .../src/traits/query/dropck_outlives.rs | 10 +- .../src/traits/select/candidate_assembly.rs | 30 ++-- .../src/traits/select/confirmation.rs | 10 +- .../src/traits/select/mod.rs | 26 ++-- .../src/traits/structural_match.rs | 2 +- .../rustc_trait_selection/src/traits/wf.rs | 4 +- compiler/rustc_ty_utils/src/abi.rs | 8 +- compiler/rustc_ty_utils/src/implied_bounds.rs | 2 +- compiler/rustc_ty_utils/src/instance.rs | 12 +- compiler/rustc_ty_utils/src/layout.rs | 28 ++-- compiler/rustc_ty_utils/src/needs_drop.rs | 4 +- compiler/rustc_ty_utils/src/opaque_types.rs | 2 +- compiler/rustc_ty_utils/src/ty.rs | 4 +- compiler/rustc_type_ir/src/ty_kind.rs | 48 +++---- compiler/stable_mir/src/fold.rs | 2 +- compiler/stable_mir/src/mir/body.rs | 20 +-- compiler/stable_mir/src/ty.rs | 4 +- compiler/stable_mir/src/visitor.rs | 2 +- library/alloc/src/boxed.rs | 10 +- library/core/src/future/mod.rs | 2 +- .../core/src/iter/sources/from_generator.rs | 18 +-- library/core/src/ops/generator.rs | 30 ++-- library/core/src/ops/mod.rs | 2 +- library/core/src/pin.rs | 14 +- library/core/src/sync/exclusive.rs | 8 +- src/librustdoc/clean/mod.rs | 4 +- src/librustdoc/formats/item_type.rs | 2 +- .../passes/collect_intra_doc_links.rs | 6 +- .../clippy_lints/src/async_yields_async.rs | 6 +- .../clippy_lints/src/await_holding_invalid.rs | 10 +- .../clippy/clippy_lints/src/dereference.rs | 4 +- src/tools/clippy/clippy_lints/src/doc.rs | 2 +- .../clippy/clippy_lints/src/large_futures.rs | 2 +- .../clippy_lints/src/manual_async_fn.rs | 4 +- .../src/needless_question_mark.rs | 4 +- .../clippy_lints/src/redundant_async_block.rs | 4 +- .../clippy/clippy_lints/src/unused_async.rs | 2 +- .../clippy_utils/src/qualify_min_const_fn.rs | 2 +- .../miri/tests/fail/generator-pinned-moved.rs | 16 +-- .../tests/fail/generator-pinned-moved.stderr | 6 +- src/tools/miri/tests/pass/generator.rs | 14 +- .../generators-self-referential.rs | 6 +- .../miri/tests/pass/track-caller-attribute.rs | 14 +- tests/codegen/generator-debug-msvc.rs | 4 +- tests/codegen/generator-debug.rs | 4 +- tests/coverage-map/status-quo/generator.rs | 6 +- tests/coverage-map/status-quo/yield.rs | 10 +- tests/debuginfo/function-names.rs | 10 +- tests/debuginfo/generator-locals.rs | 2 +- tests/debuginfo/generator-objects.rs | 2 +- tests/debuginfo/issue-57822.rs | 2 +- ...await.a-{closure#0}.generator_resume.0.mir | 2 +- ...await.b-{closure#0}.generator_resume.0.mir | 14 +- ...losure#0}.generator_drop.0.panic-abort.mir | 4 +- ...osure#0}.generator_drop.0.panic-unwind.mir | 4 +- ...ny.main-{closure#0}.generator_resume.0.mir | 10 +- ...ine_generator.main.Inline.panic-abort.diff | 8 +- ...ne_generator.main.Inline.panic-unwind.diff | 8 +- tests/mir-opt/inline/inline_generator.rs | 4 +- tests/run-coverage/generator.rs | 6 +- tests/run-coverage/yield.rs | 10 +- .../internal-lints/ty_tykind_usage.rs | 4 +- tests/ui/async-await/generator-not-future.rs | 6 +- .../async-await/generator-not-future.stderr | 26 ++-- ...65419-generator-resume-after-completion.rs | 2 +- .../ui/coherence/coherence-with-generator.rs | 8 +- .../coherence-with-generator.stock.stderr | 6 +- tests/ui/drop/dynamic-drop.rs | 2 +- tests/ui/error-codes/E0283.rs | 8 +- tests/ui/error-codes/E0283.stderr | 6 +- .../metadata-sufficient-for-layout.rs | 4 +- .../generator/auxiliary/xcrate-reachable.rs | 4 +- tests/ui/generator/auxiliary/xcrate.rs | 6 +- tests/ui/generator/borrowing.rs | 2 +- tests/ui/generator/conditional-drop.rs | 2 +- tests/ui/generator/control-flow.rs | 8 +- tests/ui/generator/discriminant.rs | 10 +- tests/ui/generator/drop-and-replace.rs | 6 +- tests/ui/generator/drop-env.rs | 2 +- tests/ui/generator/dropck-resume.rs | 2 +- tests/ui/generator/dropck.rs | 2 +- .../generator-region-requirements.rs | 6 +- .../generator-region-requirements.stderr | 2 +- .../generator/generator-resume-after-panic.rs | 2 +- .../generator-yielding-or-returning-itself.rs | 6 +- ...erator-yielding-or-returning-itself.stderr | 8 +- tests/ui/generator/issue-102645.rs | 2 +- tests/ui/generator/issue-105084.rs | 2 +- tests/ui/generator/issue-44197.rs | 10 +- tests/ui/generator/issue-52304.rs | 4 +- tests/ui/generator/issue-57084.rs | 4 +- tests/ui/generator/issue-58888.rs | 4 +- .../issue-61442-stmt-expr-with-drop.rs | 2 +- tests/ui/generator/issue-68112.rs | 14 +- tests/ui/generator/issue-68112.stderr | 12 +- tests/ui/generator/issue-69017.rs | 4 +- tests/ui/generator/issue-69039.rs | 10 +- tests/ui/generator/issue-87142.rs | 12 +- tests/ui/generator/issue-88653.rs | 4 +- tests/ui/generator/issue-88653.stderr | 2 +- tests/ui/generator/iterator-count.rs | 10 +- tests/ui/generator/live-upvar-across-yield.rs | 2 +- .../metadata-sufficient-for-layout.rs | 4 +- tests/ui/generator/nested_generators.rs | 4 +- tests/ui/generator/panic-drops-resume.rs | 2 +- tests/ui/generator/panic-drops.rs | 2 +- tests/ui/generator/panic-safe.rs | 2 +- tests/ui/generator/pin-box-generator.rs | 4 +- .../print/generator-print-verbose-1.rs | 14 +- .../print/generator-print-verbose-1.stderr | 4 +- tests/ui/generator/resume-after-return.rs | 4 +- tests/ui/generator/resume-arg-late-bound.rs | 4 +- .../ui/generator/resume-arg-late-bound.stderr | 6 +- tests/ui/generator/resume-arg-size.rs | 4 +- .../ui/generator/resume-live-across-yield.rs | 6 +- tests/ui/generator/retain-resume-ref.rs | 4 +- tests/ui/generator/size-moved-locals.rs | 10 +- tests/ui/generator/sized-yield.rs | 16 +-- tests/ui/generator/sized-yield.stderr | 20 +-- tests/ui/generator/smoke-resume-args.rs | 8 +- tests/ui/generator/smoke.rs | 30 ++-- tests/ui/generator/static-generators.rs | 6 +- tests/ui/generator/type-mismatch-error.rs | 4 +- .../type-mismatch-signature-deduction.rs | 4 +- .../type-mismatch-signature-deduction.stderr | 4 +- .../generator/unsized-capture-across-yield.rs | 4 +- .../generator/unsized-local-across-yield.rs | 4 +- tests/ui/generator/xcrate-reachable.rs | 2 +- tests/ui/generator/xcrate.rs | 8 +- tests/ui/generator/yield-while-iterating.rs | 2 +- .../generator/yield-while-local-borrowed.rs | 10 +- .../yield-while-local-borrowed.stderr | 8 +- .../generator/yield-while-ref-reborrowed.rs | 2 +- tests/ui/impl-trait/bounds_regression.rs | 8 +- tests/ui/impl-trait/issues/issue-58504.rs | 6 +- tests/ui/impl-trait/issues/issue-58504.stderr | 2 +- tests/ui/impl-trait/recursive-generator.rs | 6 +- .../ui/impl-trait/recursive-generator.stderr | 2 +- .../freeze_cycle.rs | 14 +- .../issue-74883-unused-paren-baren-yield.rs | 2 +- tests/ui/nll/issue-55850.rs | 6 +- tests/ui/packed/packed-struct-drop-aligned.rs | 2 +- tests/ui/polymorphization/generators.rs | 20 +-- tests/ui/polymorphization/generators.stderr | 4 +- tests/ui/print_type_sizes/generator.rs | 4 +- .../rfc-2091-track-caller/tracked-closure.rs | 14 +- .../issue-111184-generator-witness.rs | 2 +- .../traits/new-solver/generator.fail.stderr | 14 +- tests/ui/traits/new-solver/generator.rs | 10 +- .../issue-53678-generator-and-const-fn.rs | 4 +- .../issue-58662-generator-with-lifetime.rs | 16 +-- tests/ui/type-alias-impl-trait/issue-94429.rs | 6 +- .../type-alias-impl-trait/issue-94429.stderr | 2 +- 310 files changed, 1271 insertions(+), 1271 deletions(-) diff --git a/compiler/rustc_ast_lowering/src/errors.rs b/compiler/rustc_ast_lowering/src/errors.rs index fe0c7d101c1..9e8326de5d0 100644 --- a/compiler/rustc_ast_lowering/src/errors.rs +++ b/compiler/rustc_ast_lowering/src/errors.rs @@ -132,7 +132,7 @@ pub struct AwaitOnlyInAsyncFnAndBlocks { #[derive(Diagnostic, Clone, Copy)] #[diag(ast_lowering_generator_too_many_parameters, code = "E0628")] -pub struct GeneratorTooManyParameters { +pub struct CoroutineTooManyParameters { #[primary_span] pub fn_decl_span: Span, } @@ -162,7 +162,7 @@ pub struct FunctionalRecordUpdateDestructuringAssignment { #[derive(Diagnostic, Clone, Copy)] #[diag(ast_lowering_async_generators_not_supported, code = "E0727")] -pub struct AsyncGeneratorsNotSupported { +pub struct AsyncCoroutinesNotSupported { #[primary_span] pub span: Span, } diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs index dda23028222..b127eeed1a4 100644 --- a/compiler/rustc_ast_lowering/src/expr.rs +++ b/compiler/rustc_ast_lowering/src/expr.rs @@ -1,8 +1,8 @@ use super::errors::{ - AsyncGeneratorsNotSupported, AsyncNonMoveClosureNotSupported, AwaitOnlyInAsyncFnAndBlocks, - BaseExpressionDoubleDot, ClosureCannotBeStatic, FunctionalRecordUpdateDestructuringAssignment, - GeneratorTooManyParameters, InclusiveRangeWithNoEnd, NotSupportedForLifetimeBinderAsyncClosure, - UnderscoreExprLhsAssign, + AsyncCoroutinesNotSupported, AsyncNonMoveClosureNotSupported, AwaitOnlyInAsyncFnAndBlocks, + BaseExpressionDoubleDot, ClosureCannotBeStatic, CoroutineTooManyParameters, + FunctionalRecordUpdateDestructuringAssignment, InclusiveRangeWithNoEnd, + NotSupportedForLifetimeBinderAsyncClosure, UnderscoreExprLhsAssign, }; use super::ResolverAstLoweringExt; use super::{ImplTraitContext, LoweringContext, ParamMode, ParenthesizedGenericArgs}; @@ -188,7 +188,7 @@ pub(super) fn lower_expr_mut(&mut self, e: &Expr) -> hir::Expr<'hir> { e.id, None, e.span, - hir::AsyncGeneratorKind::Block, + hir::AsyncCoroutineKind::Block, |this| this.with_new_scopes(|this| this.lower_block_expr(block)), ), ExprKind::Await(expr, await_kw_span) => self.lower_expr_await(*await_kw_span, expr), @@ -598,7 +598,7 @@ pub(super) fn make_async_expr( closure_node_id: NodeId, ret_ty: Option>, span: Span, - async_gen_kind: hir::AsyncGeneratorKind, + async_gen_kind: hir::AsyncCoroutineKind, body: impl FnOnce(&mut Self) -> hir::Expr<'hir>, ) -> hir::ExprKind<'hir> { let output = ret_ty.unwrap_or_else(|| hir::FnRetTy::DefaultReturn(self.lower_span(span))); @@ -637,7 +637,7 @@ pub(super) fn make_async_expr( let params = arena_vec![self; param]; let body = self.lower_body(move |this| { - this.generator_kind = Some(hir::GeneratorKind::Async(async_gen_kind)); + this.generator_kind = Some(hir::CoroutineKind::Async(async_gen_kind)); let old_ctx = this.task_context; this.task_context = Some(task_context_hid); @@ -711,8 +711,8 @@ pub(super) fn maybe_forward_track_caller( fn lower_expr_await(&mut self, await_kw_span: Span, expr: &Expr) -> hir::ExprKind<'hir> { let full_span = expr.span.to(await_kw_span); match self.generator_kind { - Some(hir::GeneratorKind::Async(_)) => {} - Some(hir::GeneratorKind::Gen) | None => { + Some(hir::CoroutineKind::Async(_)) => {} + Some(hir::CoroutineKind::Gen) | None => { self.tcx.sess.emit_err(AwaitOnlyInAsyncFnAndBlocks { await_kw_span, item_span: self.current_item, @@ -926,17 +926,17 @@ fn generator_movability_for_fn( &mut self, decl: &FnDecl, fn_decl_span: Span, - generator_kind: Option, + generator_kind: Option, movability: Movability, ) -> Option { match generator_kind { - Some(hir::GeneratorKind::Gen) => { + Some(hir::CoroutineKind::Gen) => { if decl.inputs.len() > 1 { - self.tcx.sess.emit_err(GeneratorTooManyParameters { fn_decl_span }); + self.tcx.sess.emit_err(CoroutineTooManyParameters { fn_decl_span }); } Some(movability) } - Some(hir::GeneratorKind::Async(_)) => { + Some(hir::CoroutineKind::Async(_)) => { panic!("non-`async` closure body turned `async` during lowering"); } None => { @@ -1005,7 +1005,7 @@ fn lower_expr_async_closure( inner_closure_id, async_ret_ty, body.span, - hir::AsyncGeneratorKind::Closure, + hir::AsyncCoroutineKind::Closure, |this| this.with_new_scopes(|this| this.lower_expr_mut(body)), ); let hir_id = this.lower_node_id(inner_closure_id); @@ -1445,11 +1445,11 @@ fn lower_expr_field(&mut self, f: &ExprField) -> hir::ExprField<'hir> { fn lower_expr_yield(&mut self, span: Span, opt_expr: Option<&Expr>) -> hir::ExprKind<'hir> { match self.generator_kind { - Some(hir::GeneratorKind::Gen) => {} - Some(hir::GeneratorKind::Async(_)) => { - self.tcx.sess.emit_err(AsyncGeneratorsNotSupported { span }); + Some(hir::CoroutineKind::Gen) => {} + Some(hir::CoroutineKind::Async(_)) => { + self.tcx.sess.emit_err(AsyncCoroutinesNotSupported { span }); } - None => self.generator_kind = Some(hir::GeneratorKind::Gen), + None => self.generator_kind = Some(hir::CoroutineKind::Gen), } let expr = diff --git a/compiler/rustc_ast_lowering/src/item.rs b/compiler/rustc_ast_lowering/src/item.rs index b73f21433e1..f363676cbdf 100644 --- a/compiler/rustc_ast_lowering/src/item.rs +++ b/compiler/rustc_ast_lowering/src/item.rs @@ -1206,7 +1206,7 @@ fn lower_maybe_async_body( closure_id, None, body.span, - hir::AsyncGeneratorKind::Fn, + hir::AsyncCoroutineKind::Fn, |this| { // Create a block from the user's function body: let user_body = this.lower_block_expr(body); diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 68567f97eab..c4557e55784 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -111,7 +111,7 @@ struct LoweringContext<'a, 'hir> { /// Collect items that were created by lowering the current owner. children: Vec<(LocalDefId, hir::MaybeOwner<&'hir hir::OwnerInfo<'hir>>)>, - generator_kind: Option, + generator_kind: Option, /// When inside an `async` context, this is the `HirId` of the /// `task_context` local bound to the resume argument of the generator. diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs index 20a4402f6f6..d9f87f80aea 100644 --- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs @@ -8,7 +8,7 @@ use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; use rustc_hir::intravisit::{walk_block, walk_expr, Visitor}; -use rustc_hir::{AsyncGeneratorKind, GeneratorKind, LangItem}; +use rustc_hir::{AsyncCoroutineKind, CoroutineKind, LangItem}; use rustc_infer::traits::ObligationCause; use rustc_middle::hir::nested_filter::OnlyBodies; use rustc_middle::mir::tcx::PlaceTy; @@ -848,7 +848,7 @@ pub(crate) fn report_move_out_while_borrowed( move_spans.var_subdiag(None, &mut err, None, |kind, var_span| { use crate::session_diagnostics::CaptureVarCause::*; match kind { - Some(_) => MoveUseInGenerator { var_span }, + Some(_) => MoveUseInCoroutine { var_span }, None => MoveUseInClosure { var_span }, } }); @@ -894,7 +894,7 @@ pub(crate) fn report_use_while_mutably_borrowed( let desc_place = self.describe_any_place(place.as_ref()); match kind { Some(_) => { - BorrowUsePlaceGenerator { place: desc_place, var_span, is_single_var: true } + BorrowUsePlaceCoroutine { place: desc_place, var_span, is_single_var: true } } None => BorrowUsePlaceClosure { place: desc_place, var_span, is_single_var: true }, } @@ -1040,7 +1040,7 @@ pub(crate) fn report_conflicting_borrow( |kind, var_span| { use crate::session_diagnostics::CaptureVarCause::*; match kind { - Some(_) => BorrowUsePlaceGenerator { + Some(_) => BorrowUsePlaceCoroutine { place: desc_place, var_span, is_single_var: true, @@ -1125,7 +1125,7 @@ pub(crate) fn report_conflicting_borrow( borrow_spans.var_subdiag(None, &mut err, Some(gen_borrow_kind), |kind, var_span| { use crate::session_diagnostics::CaptureVarCause::*; match kind { - Some(_) => BorrowUsePlaceGenerator { + Some(_) => BorrowUsePlaceCoroutine { place: desc_place, var_span, is_single_var: false, @@ -1146,7 +1146,7 @@ pub(crate) fn report_conflicting_borrow( let borrow_place_desc = self.describe_any_place(borrow_place.as_ref()); match kind { Some(_) => { - FirstBorrowUsePlaceGenerator { place: borrow_place_desc, var_span } + FirstBorrowUsePlaceCoroutine { place: borrow_place_desc, var_span } } None => FirstBorrowUsePlaceClosure { place: borrow_place_desc, var_span }, } @@ -1160,7 +1160,7 @@ pub(crate) fn report_conflicting_borrow( |kind, var_span| { use crate::session_diagnostics::CaptureVarCause::*; match kind { - Some(_) => SecondBorrowUsePlaceGenerator { place: desc_place, var_span }, + Some(_) => SecondBorrowUsePlaceCoroutine { place: desc_place, var_span }, None => SecondBorrowUsePlaceClosure { place: desc_place, var_span }, } }, @@ -2077,7 +2077,7 @@ fn report_local_value_does_not_live_long_enough( .unwrap_or_else(|| { match &self.infcx.tcx.def_kind(self.mir_def_id()) { DefKind::Closure => "enclosing closure", - DefKind::Generator => "enclosing generator", + DefKind::Coroutine => "enclosing generator", kind => bug!("expected closure or generator, found {:?}", kind), } .to_string() @@ -2483,12 +2483,12 @@ fn report_escaping_closure_capture( }; let kind = match use_span.generator_kind() { Some(generator_kind) => match generator_kind { - GeneratorKind::Async(async_kind) => match async_kind { - AsyncGeneratorKind::Block => "async block", - AsyncGeneratorKind::Closure => "async closure", + CoroutineKind::Async(async_kind) => match async_kind { + AsyncCoroutineKind::Block => "async block", + AsyncCoroutineKind::Closure => "async closure", _ => bug!("async block/closure expected, but async function found."), }, - GeneratorKind::Gen => "generator", + CoroutineKind::Gen => "generator", }, None => "closure", }; @@ -2517,7 +2517,7 @@ fn report_escaping_closure_capture( } ConstraintCategory::CallArgument(_) => { fr_name.highlight_region_name(&mut err); - if matches!(use_span.generator_kind(), Some(GeneratorKind::Async(_))) { + if matches!(use_span.generator_kind(), Some(CoroutineKind::Async(_))) { err.note( "async blocks are not executed immediately and must either take a \ reference or ownership of outside variables they use", @@ -2785,7 +2785,7 @@ pub(crate) fn report_illegal_mutation_of_borrowed( loan_spans.var_subdiag(None, &mut err, Some(loan.kind), |kind, var_span| { use crate::session_diagnostics::CaptureVarCause::*; match kind { - Some(_) => BorrowUseInGenerator { var_span }, + Some(_) => BorrowUseInCoroutine { var_span }, None => BorrowUseInClosure { var_span }, } }); @@ -2801,7 +2801,7 @@ pub(crate) fn report_illegal_mutation_of_borrowed( loan_spans.var_subdiag(None, &mut err, Some(loan.kind), |kind, var_span| { use crate::session_diagnostics::CaptureVarCause::*; match kind { - Some(_) => BorrowUseInGenerator { var_span }, + Some(_) => BorrowUseInCoroutine { var_span }, None => BorrowUseInClosure { var_span }, } }); diff --git a/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs b/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs index c9514f5604c..f1b9f5f823d 100644 --- a/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs +++ b/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs @@ -182,7 +182,7 @@ pub(crate) fn add_explanation_to_diagnostic( // Otherwise, just report the whole type (and use // the intentionally fuzzy phrase "destructor") ty::Closure(..) => ("destructor", "closure".to_owned()), - ty::Generator(..) => ("destructor", "generator".to_owned()), + ty::Coroutine(..) => ("destructor", "generator".to_owned()), _ => ("destructor", format!("type `{}`", local_decl.ty)), }; diff --git a/compiler/rustc_borrowck/src/diagnostics/mod.rs b/compiler/rustc_borrowck/src/diagnostics/mod.rs index 8f5d5e67a7a..8104e05e754 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mod.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mod.rs @@ -8,7 +8,7 @@ use rustc_errors::{Applicability, Diagnostic}; use rustc_hir as hir; use rustc_hir::def::{CtorKind, Namespace}; -use rustc_hir::GeneratorKind; +use rustc_hir::CoroutineKind; use rustc_index::IndexSlice; use rustc_infer::infer::LateBoundRegionConversionTime; use rustc_middle::mir::tcx::PlaceTy; @@ -369,7 +369,7 @@ fn describe_field_from_ty( ty::Array(ty, _) | ty::Slice(ty) => { self.describe_field_from_ty(ty, field, variant_index, including_tuple_field) } - ty::Closure(def_id, _) | ty::Generator(def_id, _, _) => { + ty::Closure(def_id, _) | ty::Coroutine(def_id, _, _) => { // We won't be borrowck'ing here if the closure came from another crate, // so it's safe to call `expect_local`. // @@ -502,7 +502,7 @@ pub(super) enum UseSpans<'tcx> { /// The access is caused by capturing a variable for a closure. ClosureUse { /// This is true if the captured variable was from a generator. - generator_kind: Option, + generator_kind: Option, /// The span of the args of the closure, including the `move` keyword if /// it's present. args_span: Span, @@ -569,7 +569,7 @@ pub(super) fn var_or_use(self) -> Span { } } - pub(super) fn generator_kind(self) -> Option { + pub(super) fn generator_kind(self) -> Option { match self { UseSpans::ClosureUse { generator_kind, .. } => generator_kind, _ => None, @@ -600,10 +600,10 @@ pub(super) fn var_path_only_subdiag( match generator_kind { Some(_) => { err.subdiagnostic(match action { - Borrow => BorrowInGenerator { path_span }, - MatchOn | Use => UseInGenerator { path_span }, - Assignment => AssignInGenerator { path_span }, - PartialAssignment => AssignPartInGenerator { path_span }, + Borrow => BorrowInCoroutine { path_span }, + MatchOn | Use => UseInCoroutine { path_span }, + Assignment => AssignInCoroutine { path_span }, + PartialAssignment => AssignPartInCoroutine { path_span }, }); } None => { @@ -624,7 +624,7 @@ pub(super) fn var_subdiag( handler: Option<&rustc_errors::Handler>, err: &mut Diagnostic, kind: Option, - f: impl FnOnce(Option, Span) -> CaptureVarCause, + f: impl FnOnce(Option, Span) -> CaptureVarCause, ) { if let UseSpans::ClosureUse { generator_kind, capture_kind_span, path_span, .. } = self { if capture_kind_span != path_span { @@ -780,7 +780,7 @@ pub(super) fn move_spans( debug!("move_spans: moved_place={:?} location={:?} stmt={:?}", moved_place, location, stmt); if let StatementKind::Assign(box (_, Rvalue::Aggregate(kind, places))) = &stmt.kind - && let AggregateKind::Closure(def_id, _) | AggregateKind::Generator(def_id, _, _) = + && let AggregateKind::Closure(def_id, _) | AggregateKind::Coroutine(def_id, _, _) = **kind { debug!("move_spans: def_id={:?} places={:?}", def_id, places); @@ -916,7 +916,7 @@ pub(super) fn borrow_spans(&self, use_span: Span, location: Location) -> UseSpan if let StatementKind::Assign(box (_, Rvalue::Aggregate(kind, places))) = &stmt.kind { let (&def_id, is_generator) = match kind { box AggregateKind::Closure(def_id, _) => (def_id, false), - box AggregateKind::Generator(def_id, _, _) => (def_id, true), + box AggregateKind::Coroutine(def_id, _, _) => (def_id, true), _ => continue, }; let def_id = def_id.expect_local(); @@ -950,7 +950,7 @@ fn closure_span( def_id: LocalDefId, target_place: PlaceRef<'tcx>, places: &IndexSlice>, - ) -> Option<(Span, Option, Span, Span)> { + ) -> Option<(Span, Option, Span, Span)> { debug!( "closure_span: def_id={:?} target_place={:?} places={:?}", def_id, target_place, places @@ -1188,7 +1188,7 @@ fn explain_captures( // another message for the same span if !is_loop_message { move_spans.var_subdiag(None, err, None, |kind, var_span| match kind { - Some(_) => CaptureVarCause::PartialMoveUseInGenerator { var_span, is_partial }, + Some(_) => CaptureVarCause::PartialMoveUseInCoroutine { var_span, is_partial }, None => CaptureVarCause::PartialMoveUseInClosure { var_span, is_partial }, }) } diff --git a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs index 27072a60f65..d8b89e64606 100644 --- a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs @@ -580,7 +580,7 @@ fn report_fnmut_error( let err = FnMutError { span: *span, ty_err: match output_ty.kind() { - ty::Generator(def, ..) if self.infcx.tcx.generator_is_async(*def) => { + ty::Coroutine(def, ..) if self.infcx.tcx.generator_is_async(*def) => { FnMutReturnTypeErr::ReturnAsyncBlock { span: *span } } _ if output_ty.contains_closure() => { @@ -1036,7 +1036,7 @@ fn suggest_move_on_borrowing_closure(&self, diag: &mut Diagnostic) { .. }) => { let body = map.body(*body); - if !matches!(body.generator_kind, Some(hir::GeneratorKind::Async(..))) { + if !matches!(body.generator_kind, Some(hir::CoroutineKind::Async(..))) { closure_span = Some(expr.span.shrink_to_lo()); } } diff --git a/compiler/rustc_borrowck/src/diagnostics/region_name.rs b/compiler/rustc_borrowck/src/diagnostics/region_name.rs index f8883c53d57..7756dbf53a7 100644 --- a/compiler/rustc_borrowck/src/diagnostics/region_name.rs +++ b/compiler/rustc_borrowck/src/diagnostics/region_name.rs @@ -681,10 +681,10 @@ fn give_name_if_anonymous_region_appears_in_output(&self, fr: RegionVid) -> Opti hir::FnRetTy::Return(hir_ty) => (fn_decl.output.span(), Some(hir_ty)), }; let mir_description = match hir.body(body).generator_kind { - Some(hir::GeneratorKind::Async(gen)) => match gen { - hir::AsyncGeneratorKind::Block => " of async block", - hir::AsyncGeneratorKind::Closure => " of async closure", - hir::AsyncGeneratorKind::Fn => { + Some(hir::CoroutineKind::Async(gen)) => match gen { + hir::AsyncCoroutineKind::Block => " of async block", + hir::AsyncCoroutineKind::Closure => " of async closure", + hir::AsyncCoroutineKind::Fn => { let parent_item = hir.get_by_def_id(hir.get_parent_item(mir_hir_id).def_id); let output = &parent_item @@ -698,7 +698,7 @@ fn give_name_if_anonymous_region_appears_in_output(&self, fr: RegionVid) -> Opti " of async function" } }, - Some(hir::GeneratorKind::Gen) => " of generator", + Some(hir::CoroutineKind::Gen) => " of generator", None => " of closure", }; (span, mir_description, hir_ty) diff --git a/compiler/rustc_borrowck/src/invalidation.rs b/compiler/rustc_borrowck/src/invalidation.rs index 84be50a6416..7b5b52e39b1 100644 --- a/compiler/rustc_borrowck/src/invalidation.rs +++ b/compiler/rustc_borrowck/src/invalidation.rs @@ -161,7 +161,7 @@ fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location } TerminatorKind::UnwindResume | TerminatorKind::Return - | TerminatorKind::GeneratorDrop => { + | TerminatorKind::CoroutineDrop => { // Invalidate all borrows of local places let borrow_set = self.borrow_set; let start = self.location_table.start_index(location); diff --git a/compiler/rustc_borrowck/src/lib.rs b/compiler/rustc_borrowck/src/lib.rs index d274a3eea6c..26abd2542c8 100644 --- a/compiler/rustc_borrowck/src/lib.rs +++ b/compiler/rustc_borrowck/src/lib.rs @@ -306,7 +306,7 @@ fn do_mir_borrowck<'tcx>( // The first argument is the generator type passed by value if let Some(local) = body.local_decls.raw.get(1) // Get the interior types and args which typeck computed - && let ty::Generator(_, _, hir::Movability::Static) = local.ty.kind() + && let ty::Coroutine(_, _, hir::Movability::Static) = local.ty.kind() { false } else { @@ -778,7 +778,7 @@ fn visit_terminator_before_primary_effect( | TerminatorKind::Unreachable | TerminatorKind::UnwindResume | TerminatorKind::Return - | TerminatorKind::GeneratorDrop + | TerminatorKind::CoroutineDrop | TerminatorKind::FalseEdge { real_target: _, imaginary_target: _ } | TerminatorKind::FalseUnwind { real_target: _, unwind: _ } => { // no data used, thus irrelevant to borrowck @@ -809,7 +809,7 @@ fn visit_terminator_after_primary_effect( TerminatorKind::UnwindResume | TerminatorKind::Return - | TerminatorKind::GeneratorDrop => { + | TerminatorKind::CoroutineDrop => { // Returning from the function implicitly kills storage for all locals and statics. // Often, the storage will already have been killed by an explicit // StorageDead, but we don't always emit those (notably on unwind paths), @@ -1326,7 +1326,7 @@ fn consume_rvalue( // moved into the closure and subsequently used by the closure, // in order to populate our used_mut set. match **aggregate_kind { - AggregateKind::Closure(def_id, _) | AggregateKind::Generator(def_id, _, _) => { + AggregateKind::Closure(def_id, _) | AggregateKind::Coroutine(def_id, _, _) => { let def_id = def_id.expect_local(); let BorrowCheckResult { used_mut_upvars, .. } = self.infcx.tcx.mir_borrowck(def_id); diff --git a/compiler/rustc_borrowck/src/session_diagnostics.rs b/compiler/rustc_borrowck/src/session_diagnostics.rs index ca3ccf439f2..31502b336d4 100644 --- a/compiler/rustc_borrowck/src/session_diagnostics.rs +++ b/compiler/rustc_borrowck/src/session_diagnostics.rs @@ -140,22 +140,22 @@ pub(crate) enum RequireStaticErr { #[derive(Subdiagnostic)] pub(crate) enum CaptureVarPathUseCause { #[label(borrowck_borrow_due_to_use_generator)] - BorrowInGenerator { + BorrowInCoroutine { #[primary_span] path_span: Span, }, #[label(borrowck_use_due_to_use_generator)] - UseInGenerator { + UseInCoroutine { #[primary_span] path_span: Span, }, #[label(borrowck_assign_due_to_use_generator)] - AssignInGenerator { + AssignInCoroutine { #[primary_span] path_span: Span, }, #[label(borrowck_assign_part_due_to_use_generator)] - AssignPartInGenerator { + AssignPartInCoroutine { #[primary_span] path_span: Span, }, @@ -203,7 +203,7 @@ pub(crate) enum CaptureVarKind { #[derive(Subdiagnostic)] pub(crate) enum CaptureVarCause { #[label(borrowck_var_borrow_by_use_place_in_generator)] - BorrowUsePlaceGenerator { + BorrowUsePlaceCoroutine { is_single_var: bool, place: String, #[primary_span] @@ -217,7 +217,7 @@ pub(crate) enum CaptureVarCause { var_span: Span, }, #[label(borrowck_var_borrow_by_use_in_generator)] - BorrowUseInGenerator { + BorrowUseInCoroutine { #[primary_span] var_span: Span, }, @@ -227,7 +227,7 @@ pub(crate) enum CaptureVarCause { var_span: Span, }, #[label(borrowck_var_move_by_use_in_generator)] - MoveUseInGenerator { + MoveUseInCoroutine { #[primary_span] var_span: Span, }, @@ -237,7 +237,7 @@ pub(crate) enum CaptureVarCause { var_span: Span, }, #[label(borrowck_var_first_borrow_by_use_place_in_generator)] - FirstBorrowUsePlaceGenerator { + FirstBorrowUsePlaceCoroutine { place: String, #[primary_span] var_span: Span, @@ -249,7 +249,7 @@ pub(crate) enum CaptureVarCause { var_span: Span, }, #[label(borrowck_var_second_borrow_by_use_place_in_generator)] - SecondBorrowUsePlaceGenerator { + SecondBorrowUsePlaceCoroutine { place: String, #[primary_span] var_span: Span, @@ -267,7 +267,7 @@ pub(crate) enum CaptureVarCause { var_span: Span, }, #[label(borrowck_partial_var_move_by_use_in_generator)] - PartialMoveUseInGenerator { + PartialMoveUseInCoroutine { #[primary_span] var_span: Span, is_partial: bool, diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs index 1ec0e62d16a..c8b58dafc7f 100644 --- a/compiler/rustc_borrowck/src/type_check/mod.rs +++ b/compiler/rustc_borrowck/src/type_check/mod.rs @@ -774,7 +774,7 @@ fn field_ty( let (variant, args) = match base_ty { PlaceTy { ty, variant_index: Some(variant_index) } => match *ty.kind() { ty::Adt(adt_def, args) => (adt_def.variant(variant_index), args), - ty::Generator(def_id, args, _) => { + ty::Coroutine(def_id, args, _) => { let mut variants = args.as_generator().state_tys(def_id, tcx); let Some(mut variant) = variants.nth(variant_index.into()) else { bug!( @@ -802,7 +802,7 @@ fn field_ty( }), }; } - ty::Generator(_, args, _) => { + ty::Coroutine(_, args, _) => { // Only prefix fields (upvars and current state) are // accessible without a variant index. return match args.as_generator().prefix_tys().get(field.index()) { @@ -1351,7 +1351,7 @@ fn check_terminator( | TerminatorKind::UnwindResume | TerminatorKind::UnwindTerminate(_) | TerminatorKind::Return - | TerminatorKind::GeneratorDrop + | TerminatorKind::CoroutineDrop | TerminatorKind::Unreachable | TerminatorKind::Drop { .. } | TerminatorKind::FalseEdge { .. } @@ -1648,7 +1648,7 @@ fn check_iscleanup(&mut self, body: &Body<'tcx>, block_data: &BasicBlockData<'tc span_mirbug!(self, block_data, "return on cleanup block") } } - TerminatorKind::GeneratorDrop { .. } => { + TerminatorKind::CoroutineDrop { .. } => { if is_cleanup { span_mirbug!(self, block_data, "generator_drop in cleanup block") } @@ -1797,7 +1797,7 @@ fn aggregate_field_ty( }), } } - AggregateKind::Generator(_, args, _) => { + AggregateKind::Coroutine(_, args, _) => { // It doesn't make sense to look at a field beyond the prefix; // these require a variant index, and are not initialized in // aggregate rvalues. @@ -2397,7 +2397,7 @@ fn rvalue_user_ty(&self, rvalue: &Rvalue<'tcx>) -> Option None, AggregateKind::Tuple => None, AggregateKind::Closure(_, _) => None, - AggregateKind::Generator(_, _, _) => None, + AggregateKind::Coroutine(_, _, _) => None, }, } } @@ -2625,7 +2625,7 @@ fn prove_aggregate_predicates( // desugaring. A closure gets desugared to a struct, and // these extra requirements are basically like where // clauses on the struct. - AggregateKind::Closure(def_id, args) | AggregateKind::Generator(def_id, args, _) => { + AggregateKind::Closure(def_id, args) | AggregateKind::Coroutine(def_id, args, _) => { (def_id, self.prove_closure_bounds(tcx, def_id.expect_local(), args, location)) } @@ -2673,7 +2673,7 @@ fn prove_closure_bounds( let parent_args = match tcx.def_kind(def_id) { DefKind::Closure => args.as_closure().parent_args(), - DefKind::Generator => args.as_generator().parent_args(), + DefKind::Coroutine => args.as_generator().parent_args(), DefKind::InlineConst => args.as_inline_const().parent_args(), other => bug!("unexpected item {:?}", other), }; diff --git a/compiler/rustc_borrowck/src/universal_regions.rs b/compiler/rustc_borrowck/src/universal_regions.rs index c73192f4404..ef793757162 100644 --- a/compiler/rustc_borrowck/src/universal_regions.rs +++ b/compiler/rustc_borrowck/src/universal_regions.rs @@ -94,7 +94,7 @@ pub enum DefiningTy<'tcx> { /// The MIR is a generator. The signature is that generators take /// no parameters and return the result of /// `ClosureArgs::generator_return_ty`. - Generator(DefId, GenericArgsRef<'tcx>, hir::Movability), + Coroutine(DefId, GenericArgsRef<'tcx>, hir::Movability), /// The MIR is a fn item with the given `DefId` and args. The signature /// of the function can be bound then with the `fn_sig` query. @@ -118,7 +118,7 @@ impl<'tcx> DefiningTy<'tcx> { pub fn upvar_tys(self) -> &'tcx ty::List> { match self { DefiningTy::Closure(_, args) => args.as_closure().upvar_tys(), - DefiningTy::Generator(_, args, _) => args.as_generator().upvar_tys(), + DefiningTy::Coroutine(_, args, _) => args.as_generator().upvar_tys(), DefiningTy::FnDef(..) | DefiningTy::Const(..) | DefiningTy::InlineConst(..) => { ty::List::empty() } @@ -130,7 +130,7 @@ pub fn upvar_tys(self) -> &'tcx ty::List> { /// user's code. pub fn implicit_inputs(self) -> usize { match self { - DefiningTy::Closure(..) | DefiningTy::Generator(..) => 1, + DefiningTy::Closure(..) | DefiningTy::Coroutine(..) => 1, DefiningTy::FnDef(..) | DefiningTy::Const(..) | DefiningTy::InlineConst(..) => 0, } } @@ -146,7 +146,7 @@ pub fn is_const(&self) -> bool { pub fn def_id(&self) -> DefId { match *self { DefiningTy::Closure(def_id, ..) - | DefiningTy::Generator(def_id, ..) + | DefiningTy::Coroutine(def_id, ..) | DefiningTy::FnDef(def_id, ..) | DefiningTy::Const(def_id, ..) | DefiningTy::InlineConst(def_id, ..) => def_id, @@ -354,7 +354,7 @@ pub(crate) fn annotate(&self, tcx: TyCtxt<'tcx>, err: &mut Diagnostic) { err.note(format!("late-bound region is {:?}", self.to_region_vid(r))); }); } - DefiningTy::Generator(def_id, args, _) => { + DefiningTy::Coroutine(def_id, args, _) => { let v = with_no_trimmed_paths!( args[tcx.generics_of(def_id).parent_count..] .iter() @@ -528,7 +528,7 @@ fn build(self) -> UniversalRegions<'tcx> { debug!("build: local regions = {}..{}", first_local_index, num_universals); let yield_ty = match defining_ty { - DefiningTy::Generator(_, args, _) => Some(args.as_generator().yield_ty()), + DefiningTy::Coroutine(_, args, _) => Some(args.as_generator().yield_ty()), _ => None, }; @@ -563,8 +563,8 @@ fn defining_ty(&self) -> DefiningTy<'tcx> { match *defining_ty.kind() { ty::Closure(def_id, args) => DefiningTy::Closure(def_id, args), - ty::Generator(def_id, args, movability) => { - DefiningTy::Generator(def_id, args, movability) + ty::Coroutine(def_id, args, movability) => { + DefiningTy::Coroutine(def_id, args, movability) } ty::FnDef(def_id, args) => DefiningTy::FnDef(def_id, args), _ => span_bug!( @@ -621,7 +621,7 @@ fn compute_indices( let identity_args = GenericArgs::identity_for_item(tcx, typeck_root_def_id); let fr_args = match defining_ty { DefiningTy::Closure(_, args) - | DefiningTy::Generator(_, args, _) + | DefiningTy::Coroutine(_, args, _) | DefiningTy::InlineConst(_, args) => { // In the case of closures, we rely on the fact that // the first N elements in the ClosureArgs are @@ -686,7 +686,7 @@ fn compute_inputs_and_output( ) } - DefiningTy::Generator(def_id, args, movability) => { + DefiningTy::Coroutine(def_id, args, movability) => { assert_eq!(self.mir_def.to_def_id(), def_id); let resume_ty = args.as_generator().resume_ty(); let output = args.as_generator().return_ty(); diff --git a/compiler/rustc_codegen_cranelift/example/std_example.rs b/compiler/rustc_codegen_cranelift/example/std_example.rs index 490cc2404f6..edebc3d4c4d 100644 --- a/compiler/rustc_codegen_cranelift/example/std_example.rs +++ b/compiler/rustc_codegen_cranelift/example/std_example.rs @@ -12,7 +12,7 @@ use std::arch::x86_64::*; use std::hint::black_box; use std::io::Write; -use std::ops::Generator; +use std::ops::Coroutine; fn main() { println!("{:?}", std::env::args().collect::>()); diff --git a/compiler/rustc_codegen_cranelift/scripts/test_rustc_tests.sh b/compiler/rustc_codegen_cranelift/scripts/test_rustc_tests.sh index 3b2a12ec028..c83efa51e9e 100755 --- a/compiler/rustc_codegen_cranelift/scripts/test_rustc_tests.sh +++ b/compiler/rustc_codegen_cranelift/scripts/test_rustc_tests.sh @@ -157,7 +157,7 @@ rm -r tests/run-make/compressed-debuginfo rm -r tests/run-make/extern-fn-explicit-align # argument alignment not yet supported -rm tests/ui/codegen/subtyping-enforces-type-equality.rs # assert_assignable bug with Generator's +rm tests/ui/codegen/subtyping-enforces-type-equality.rs # assert_assignable bug with Coroutine's # bugs in the test suite # ====================== diff --git a/compiler/rustc_codegen_cranelift/src/base.rs b/compiler/rustc_codegen_cranelift/src/base.rs index ac7389792c8..80e7c5bd9ed 100644 --- a/compiler/rustc_codegen_cranelift/src/base.rs +++ b/compiler/rustc_codegen_cranelift/src/base.rs @@ -478,7 +478,7 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) { TerminatorKind::Yield { .. } | TerminatorKind::FalseEdge { .. } | TerminatorKind::FalseUnwind { .. } - | TerminatorKind::GeneratorDrop => { + | TerminatorKind::CoroutineDrop => { bug!("shouldn't exist at codegen {:?}", bb_data.terminator()); } TerminatorKind::Drop { place, target, unwind: _, replace: _ } => { diff --git a/compiler/rustc_codegen_cranelift/src/constant.rs b/compiler/rustc_codegen_cranelift/src/constant.rs index 1cb6fa07723..b0853d30e03 100644 --- a/compiler/rustc_codegen_cranelift/src/constant.rs +++ b/compiler/rustc_codegen_cranelift/src/constant.rs @@ -510,7 +510,7 @@ pub(crate) fn mir_operand_get_const_val<'tcx>( | TerminatorKind::Drop { .. } | TerminatorKind::Assert { .. } => {} TerminatorKind::Yield { .. } - | TerminatorKind::GeneratorDrop + | TerminatorKind::CoroutineDrop | TerminatorKind::FalseEdge { .. } | TerminatorKind::FalseUnwind { .. } => unreachable!(), TerminatorKind::InlineAsm { .. } => return None, diff --git a/compiler/rustc_codegen_gcc/example/std_example.rs b/compiler/rustc_codegen_gcc/example/std_example.rs index 18f2ddcde12..5bcc2c3315c 100644 --- a/compiler/rustc_codegen_gcc/example/std_example.rs +++ b/compiler/rustc_codegen_gcc/example/std_example.rs @@ -3,7 +3,7 @@ #[cfg(feature="master")] use std::arch::x86_64::*; use std::io::Write; -use std::ops::Generator; +use std::ops::Coroutine; extern { pub fn printf(format: *const i8, ...) -> i32; diff --git a/compiler/rustc_codegen_gcc/src/type_of.rs b/compiler/rustc_codegen_gcc/src/type_of.rs index c2eab295acd..357ce622659 100644 --- a/compiler/rustc_codegen_gcc/src/type_of.rs +++ b/compiler/rustc_codegen_gcc/src/type_of.rs @@ -87,7 +87,7 @@ fn uncached_gcc_type<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, layout: TyAndLayout // FIXME(eddyb) producing readable type names for trait objects can result // in problematically distinct types due to HRTB and subtyping (see #47638). // ty::Dynamic(..) | - ty::Adt(..) | ty::Closure(..) | ty::Foreign(..) | ty::Generator(..) | ty::Str + ty::Adt(..) | ty::Closure(..) | ty::Foreign(..) | ty::Coroutine(..) | ty::Str if !cx.sess().fewer_names() => { let mut name = with_no_trimmed_paths!(layout.ty.to_string()); @@ -98,10 +98,10 @@ fn uncached_gcc_type<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, layout: TyAndLayout write!(&mut name, "::{}", def.variant(index).name).unwrap(); } } - if let (&ty::Generator(_, _, _), &Variants::Single { index }) = + if let (&ty::Coroutine(_, _, _), &Variants::Single { index }) = (layout.ty.kind(), &layout.variants) { - write!(&mut name, "::{}", ty::GeneratorArgs::variant_name(index)).unwrap(); + write!(&mut name, "::{}", ty::CoroutineArgs::variant_name(index)).unwrap(); } Some(name) } diff --git a/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs b/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs index 411620c9e49..f75add90aa2 100644 --- a/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs +++ b/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs @@ -313,7 +313,7 @@ fn add_unused_functions(cx: &CodegenCx<'_, '_>) { // generic functions from consideration as well. if !matches!( kind, - DefKind::Fn | DefKind::AssocFn | DefKind::Closure | DefKind::Generator + DefKind::Fn | DefKind::AssocFn | DefKind::Closure | DefKind::Coroutine ) { return None; } diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs index 4f8ae2ddb8f..9186f685ff0 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs @@ -460,7 +460,7 @@ pub fn type_di_node<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'ll D } ty::FnDef(..) | ty::FnPtr(_) => build_subroutine_type_di_node(cx, unique_type_id), ty::Closure(..) => build_closure_env_di_node(cx, unique_type_id), - ty::Generator(..) => enums::build_generator_di_node(cx, unique_type_id), + ty::Coroutine(..) => enums::build_generator_di_node(cx, unique_type_id), ty::Adt(def, ..) => match def.adt_kind() { AdtKind::Struct => build_struct_type_di_node(cx, unique_type_id), AdtKind::Union => build_union_type_di_node(cx, unique_type_id), @@ -1034,7 +1034,7 @@ fn build_upvar_field_di_nodes<'ll, 'tcx>( closure_or_generator_di_node: &'ll DIType, ) -> SmallVec<&'ll DIType> { let (&def_id, up_var_tys) = match closure_or_generator_ty.kind() { - ty::Generator(def_id, args, _) => (def_id, args.as_generator().prefix_tys()), + ty::Coroutine(def_id, args, _) => (def_id, args.as_generator().prefix_tys()), ty::Closure(def_id, args) => (def_id, args.as_closure().upvar_tys()), _ => { bug!( diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/cpp_like.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/cpp_like.rs index 88040557a9b..cebaeb1611c 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/cpp_like.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/cpp_like.rs @@ -12,7 +12,7 @@ ty::{ self, layout::{LayoutOf, TyAndLayout}, - AdtDef, GeneratorArgs, Ty, + AdtDef, CoroutineArgs, Ty, }, }; use rustc_target::abi::{Align, Endian, Size, TagEncoding, VariantIdx, Variants}; @@ -674,7 +674,7 @@ fn build_union_fields_for_direct_tag_generator<'ll, 'tcx>( }; let (generator_def_id, generator_args) = match generator_type_and_layout.ty.kind() { - &ty::Generator(def_id, args, _) => (def_id, args.as_generator()), + &ty::Coroutine(def_id, args, _) => (def_id, args.as_generator()), _ => unreachable!(), }; @@ -691,7 +691,7 @@ fn build_union_fields_for_direct_tag_generator<'ll, 'tcx>( generator_type_di_node, variant_range .clone() - .map(|variant_index| (variant_index, GeneratorArgs::variant_name(variant_index))), + .map(|variant_index| (variant_index, CoroutineArgs::variant_name(variant_index))), ); let discriminants: IndexVec = { diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/mod.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/mod.rs index d3239d5c358..9fccd925292 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/mod.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/mod.rs @@ -6,11 +6,11 @@ use rustc_index::IndexSlice; use rustc_middle::{ bug, - mir::GeneratorLayout, + mir::CoroutineLayout, ty::{ self, layout::{IntegerExt, LayoutOf, PrimitiveExt, TyAndLayout}, - AdtDef, GeneratorArgs, Ty, VariantDef, + AdtDef, CoroutineArgs, Ty, VariantDef, }, }; use rustc_span::Symbol; @@ -107,7 +107,7 @@ fn tag_base_type<'ll, 'tcx>( enum_type_and_layout: TyAndLayout<'tcx>, ) -> Ty<'tcx> { debug_assert!(match enum_type_and_layout.ty.kind() { - ty::Generator(..) => true, + ty::Coroutine(..) => true, ty::Adt(adt_def, _) => adt_def.is_enum(), _ => false, }); @@ -322,10 +322,10 @@ pub fn build_generator_variant_struct_type_di_node<'ll, 'tcx>( variant_index: VariantIdx, generator_type_and_layout: TyAndLayout<'tcx>, generator_type_di_node: &'ll DIType, - generator_layout: &GeneratorLayout<'tcx>, + generator_layout: &CoroutineLayout<'tcx>, common_upvar_names: &IndexSlice, ) -> &'ll DIType { - let variant_name = GeneratorArgs::variant_name(variant_index); + let variant_name = CoroutineArgs::variant_name(variant_index); let unique_type_id = UniqueTypeId::for_enum_variant_struct_type( cx.tcx, generator_type_and_layout.ty, @@ -335,7 +335,7 @@ pub fn build_generator_variant_struct_type_di_node<'ll, 'tcx>( let variant_layout = generator_type_and_layout.for_variant(cx, variant_index); let generator_args = match generator_type_and_layout.ty.kind() { - ty::Generator(_, args, _) => args.as_generator(), + ty::Coroutine(_, args, _) => args.as_generator(), _ => unreachable!(), }; diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/native.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/native.rs index feac40d8c30..9588a7ec128 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/native.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/native.rs @@ -132,7 +132,7 @@ pub(super) fn build_generator_di_node<'ll, 'tcx>( unique_type_id: UniqueTypeId<'tcx>, ) -> DINodeCreationResult<'ll> { let generator_type = unique_type_id.expect_ty(); - let &ty::Generator(generator_def_id, _, _) = generator_type.kind() else { + let &ty::Coroutine(generator_def_id, _, _) = generator_type.kind() else { bug!("build_generator_di_node() called with non-generator type: `{:?}`", generator_type) }; @@ -175,7 +175,7 @@ pub(super) fn build_generator_di_node<'ll, 'tcx>( .indices() .map(|variant_index| { // FIXME: This is problematic because just a number is not a valid identifier. - // GeneratorArgs::variant_name(variant_index), would be consistent + // CoroutineArgs::variant_name(variant_index), would be consistent // with enums? let variant_name = format!("{}", variant_index.as_usize()).into(); @@ -310,7 +310,7 @@ fn build_discr_member_di_node<'ll, 'tcx>( enum_or_generator_type_di_node: &'ll DIType, ) -> Option<&'ll DIType> { let tag_name = match enum_or_generator_type_and_layout.ty.kind() { - ty::Generator(..) => "__state", + ty::Coroutine(..) => "__state", _ => "", }; diff --git a/compiler/rustc_codegen_llvm/src/type_of.rs b/compiler/rustc_codegen_llvm/src/type_of.rs index fd4c9572af2..712b6ed5333 100644 --- a/compiler/rustc_codegen_llvm/src/type_of.rs +++ b/compiler/rustc_codegen_llvm/src/type_of.rs @@ -42,7 +42,7 @@ fn uncached_llvm_type<'a, 'tcx>( // FIXME(eddyb) producing readable type names for trait objects can result // in problematically distinct types due to HRTB and subtyping (see #47638). // ty::Dynamic(..) | - ty::Adt(..) | ty::Closure(..) | ty::Foreign(..) | ty::Generator(..) | ty::Str + ty::Adt(..) | ty::Closure(..) | ty::Foreign(..) | ty::Coroutine(..) | ty::Str // For performance reasons we use names only when emitting LLVM IR. if !cx.sess().fewer_names() => { @@ -54,10 +54,10 @@ fn uncached_llvm_type<'a, 'tcx>( write!(&mut name, "::{}", def.variant(index).name).unwrap(); } } - if let (&ty::Generator(_, _, _), &Variants::Single { index }) = + if let (&ty::Coroutine(_, _, _), &Variants::Single { index }) = (layout.ty.kind(), &layout.variants) { - write!(&mut name, "::{}", ty::GeneratorArgs::variant_name(index)).unwrap(); + write!(&mut name, "::{}", ty::CoroutineArgs::variant_name(index)).unwrap(); } Some(name) } diff --git a/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs b/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs index 989df448a31..8cd627fc619 100644 --- a/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs +++ b/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs @@ -15,7 +15,7 @@ use rustc_data_structures::stable_hasher::{Hash64, HashStable, StableHasher}; use rustc_hir::def_id::DefId; use rustc_hir::definitions::{DefPathData, DefPathDataName, DisambiguatedDefPathData}; -use rustc_hir::{AsyncGeneratorKind, GeneratorKind, Mutability}; +use rustc_hir::{AsyncCoroutineKind, CoroutineKind, Mutability}; use rustc_middle::ty::layout::{IntegerExt, TyAndLayout}; use rustc_middle::ty::{self, ExistentialProjection, ParamEnv, Ty, TyCtxt}; use rustc_middle::ty::{GenericArgKind, GenericArgsRef}; @@ -398,7 +398,7 @@ fn push_debuginfo_type_name<'tcx>( // processing visited.remove(&t); } - ty::Closure(def_id, args) | ty::Generator(def_id, args, ..) => { + ty::Closure(def_id, args) | ty::Coroutine(def_id, args, ..) => { // Name will be "{closure_env#0}", "{generator_env#0}", or // "{async_fn_env#0}", etc. // In the case of cpp-like debuginfo, the name additionally gets wrapped inside of @@ -426,7 +426,7 @@ fn push_debuginfo_type_name<'tcx>( | ty::Placeholder(..) | ty::Alias(..) | ty::Bound(..) - | ty::GeneratorWitness(..) => { + | ty::CoroutineWitness(..) => { bug!( "debuginfo: Trying to create type name for \ unexpected type: {:?}", @@ -558,12 +558,12 @@ pub fn push_item_name(tcx: TyCtxt<'_>, def_id: DefId, qualified: bool, output: & push_unqualified_item_name(tcx, def_id, def_key.disambiguated_data, output); } -fn generator_kind_label(generator_kind: Option) -> &'static str { +fn generator_kind_label(generator_kind: Option) -> &'static str { match generator_kind { - Some(GeneratorKind::Async(AsyncGeneratorKind::Block)) => "async_block", - Some(GeneratorKind::Async(AsyncGeneratorKind::Closure)) => "async_closure", - Some(GeneratorKind::Async(AsyncGeneratorKind::Fn)) => "async_fn", - Some(GeneratorKind::Gen) => "generator", + Some(CoroutineKind::Async(AsyncCoroutineKind::Block)) => "async_block", + Some(CoroutineKind::Async(AsyncCoroutineKind::Closure)) => "async_closure", + Some(CoroutineKind::Async(AsyncCoroutineKind::Fn)) => "async_fn", + Some(CoroutineKind::Gen) => "generator", None => "closure", } } diff --git a/compiler/rustc_codegen_ssa/src/mir/analyze.rs b/compiler/rustc_codegen_ssa/src/mir/analyze.rs index 62e997e5cfa..53cc063e55a 100644 --- a/compiler/rustc_codegen_ssa/src/mir/analyze.rs +++ b/compiler/rustc_codegen_ssa/src/mir/analyze.rs @@ -272,7 +272,7 @@ fn discover_masters<'tcx>( | TerminatorKind::UnwindResume | TerminatorKind::UnwindTerminate(_) | TerminatorKind::Return - | TerminatorKind::GeneratorDrop + | TerminatorKind::CoroutineDrop | TerminatorKind::Unreachable | TerminatorKind::SwitchInt { .. } | TerminatorKind::Yield { .. } diff --git a/compiler/rustc_codegen_ssa/src/mir/block.rs b/compiler/rustc_codegen_ssa/src/mir/block.rs index 68f22aaf990..f35cf282072 100644 --- a/compiler/rustc_codegen_ssa/src/mir/block.rs +++ b/compiler/rustc_codegen_ssa/src/mir/block.rs @@ -1265,7 +1265,7 @@ fn codegen_terminator( fn_span, mergeable_succ(), ), - mir::TerminatorKind::GeneratorDrop | mir::TerminatorKind::Yield { .. } => { + mir::TerminatorKind::CoroutineDrop | mir::TerminatorKind::Yield { .. } => { bug!("generator ops in codegen") } mir::TerminatorKind::FalseEdge { .. } | mir::TerminatorKind::FalseUnwind { .. } => { diff --git a/compiler/rustc_const_eval/src/const_eval/valtrees.rs b/compiler/rustc_const_eval/src/const_eval/valtrees.rs index 7436ea6ae57..d6dc1a62f4d 100644 --- a/compiler/rustc_const_eval/src/const_eval/valtrees.rs +++ b/compiler/rustc_const_eval/src/const_eval/valtrees.rs @@ -151,8 +151,8 @@ pub(crate) fn const_to_valtree_inner<'tcx>( | ty::Infer(_) // FIXME(oli-obk): we can probably encode closures just like structs | ty::Closure(..) - | ty::Generator(..) - | ty::GeneratorWitness(..) => Err(ValTreeCreationError::NonSupportedType), + | ty::Coroutine(..) + | ty::CoroutineWitness(..) => Err(ValTreeCreationError::NonSupportedType), } } @@ -278,8 +278,8 @@ pub fn valtree_to_const_value<'tcx>( | ty::Placeholder(..) | ty::Infer(_) | ty::Closure(..) - | ty::Generator(..) - | ty::GeneratorWitness(..) + | ty::Coroutine(..) + | ty::CoroutineWitness(..) | ty::FnPtr(_) | ty::RawPtr(_) | ty::Str diff --git a/compiler/rustc_const_eval/src/interpret/discriminant.rs b/compiler/rustc_const_eval/src/interpret/discriminant.rs index 49e01728ff4..1f347aca65f 100644 --- a/compiler/rustc_const_eval/src/interpret/discriminant.rs +++ b/compiler/rustc_const_eval/src/interpret/discriminant.rs @@ -170,7 +170,7 @@ pub fn read_discriminant( ty::Adt(adt, _) => { adt.discriminants(*self.tcx).find(|(_, var)| var.val == discr_bits) } - ty::Generator(def_id, args, _) => { + ty::Coroutine(def_id, args, _) => { let args = args.as_generator(); args.discriminants(def_id, *self.tcx).find(|(_, var)| var.val == discr_bits) } diff --git a/compiler/rustc_const_eval/src/interpret/eval_context.rs b/compiler/rustc_const_eval/src/interpret/eval_context.rs index 1c2e8d807f4..791370660fe 100644 --- a/compiler/rustc_const_eval/src/interpret/eval_context.rs +++ b/compiler/rustc_const_eval/src/interpret/eval_context.rs @@ -963,8 +963,8 @@ fn is_very_trivially_sized(ty: Ty<'_>) -> bool { | ty::RawPtr(..) | ty::Char | ty::Ref(..) - | ty::Generator(..) - | ty::GeneratorWitness(..) + | ty::Coroutine(..) + | ty::CoroutineWitness(..) | ty::Array(..) | ty::Closure(..) | ty::Never diff --git a/compiler/rustc_const_eval/src/interpret/intrinsics.rs b/compiler/rustc_const_eval/src/interpret/intrinsics.rs index b7106c37c7b..c97207a61ac 100644 --- a/compiler/rustc_const_eval/src/interpret/intrinsics.rs +++ b/compiler/rustc_const_eval/src/interpret/intrinsics.rs @@ -99,8 +99,8 @@ pub(crate) fn eval_nullary_intrinsic<'tcx>( | ty::FnPtr(_) | ty::Dynamic(_, _, _) | ty::Closure(_, _) - | ty::Generator(_, _, _) - | ty::GeneratorWitness(..) + | ty::Coroutine(_, _, _) + | ty::CoroutineWitness(..) | ty::Never | ty::Tuple(_) | ty::Error(_) => ConstValue::from_target_usize(0u64, &tcx), diff --git a/compiler/rustc_const_eval/src/interpret/terminator.rs b/compiler/rustc_const_eval/src/interpret/terminator.rs index 59e89819880..b54c6681456 100644 --- a/compiler/rustc_const_eval/src/interpret/terminator.rs +++ b/compiler/rustc_const_eval/src/interpret/terminator.rs @@ -218,7 +218,7 @@ pub(super) fn eval_terminator( Unreachable => throw_ub!(Unreachable), // These should never occur for MIR we actually run. - FalseEdge { .. } | FalseUnwind { .. } | Yield { .. } | GeneratorDrop => span_bug!( + FalseEdge { .. } | FalseUnwind { .. } | Yield { .. } | CoroutineDrop => span_bug!( terminator.source_info.span, "{:#?} should have been eliminated by MIR pass", terminator.kind diff --git a/compiler/rustc_const_eval/src/interpret/util.rs b/compiler/rustc_const_eval/src/interpret/util.rs index eb639ded70f..a087d0ac70d 100644 --- a/compiler/rustc_const_eval/src/interpret/util.rs +++ b/compiler/rustc_const_eval/src/interpret/util.rs @@ -34,7 +34,7 @@ fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow { match *ty.kind() { ty::Param(_) => ControlFlow::Break(FoundParam), ty::Closure(def_id, args) - | ty::Generator(def_id, args, ..) + | ty::Coroutine(def_id, args, ..) | ty::FnDef(def_id, args) => { let instance = ty::InstanceDef::Item(def_id); let unused_params = self.tcx.unused_generic_params(instance); diff --git a/compiler/rustc_const_eval/src/interpret/validity.rs b/compiler/rustc_const_eval/src/interpret/validity.rs index 082e5466fe2..6c541d0868a 100644 --- a/compiler/rustc_const_eval/src/interpret/validity.rs +++ b/compiler/rustc_const_eval/src/interpret/validity.rs @@ -112,13 +112,13 @@ macro_rules! try_validation { pub enum PathElem { Field(Symbol), Variant(Symbol), - GeneratorState(VariantIdx), + CoroutineState(VariantIdx), CapturedVar(Symbol), ArrayElem(usize), TupleElem(usize), Deref, EnumTag, - GeneratorTag, + CoroutineTag, DynDowncast, } @@ -171,8 +171,8 @@ fn write_path(out: &mut String, path: &[PathElem]) { Field(name) => write!(out, ".{name}"), EnumTag => write!(out, "."), Variant(name) => write!(out, "."), - GeneratorTag => write!(out, "."), - GeneratorState(idx) => write!(out, ".", idx.index()), + CoroutineTag => write!(out, "."), + CoroutineState(idx) => write!(out, ".", idx.index()), CapturedVar(name) => write!(out, "."), TupleElem(idx) => write!(out, ".{idx}"), ArrayElem(idx) => write!(out, "[{idx}]"), @@ -206,7 +206,7 @@ fn aggregate_field_path_elem(&mut self, layout: TyAndLayout<'tcx>, field: usize) if tag_field == field { return match layout.ty.kind() { ty::Adt(def, ..) if def.is_enum() => PathElem::EnumTag, - ty::Generator(..) => PathElem::GeneratorTag, + ty::Coroutine(..) => PathElem::CoroutineTag, _ => bug!("non-variant type {:?}", layout.ty), }; } @@ -217,7 +217,7 @@ fn aggregate_field_path_elem(&mut self, layout: TyAndLayout<'tcx>, field: usize) // Now we know we are projecting to a field, so figure out which one. match layout.ty.kind() { // generators and closures. - ty::Closure(def_id, _) | ty::Generator(def_id, _, _) => { + ty::Closure(def_id, _) | ty::Coroutine(def_id, _, _) => { let mut name = None; // FIXME this should be more descriptive i.e. CapturePlace instead of CapturedVar // https://github.com/rust-lang/project-rfc-2229/issues/46 @@ -580,7 +580,7 @@ fn try_visit_primitive( | ty::Str | ty::Dynamic(..) | ty::Closure(..) - | ty::Generator(..) => Ok(false), + | ty::Coroutine(..) => Ok(false), // Some types only occur during typechecking, they have no layout. // We should not see them here and we could not check them anyway. ty::Error(_) @@ -589,7 +589,7 @@ fn try_visit_primitive( | ty::Bound(..) | ty::Param(..) | ty::Alias(..) - | ty::GeneratorWitness(..) => bug!("Encountered invalid type {:?}", ty), + | ty::CoroutineWitness(..) => bug!("Encountered invalid type {:?}", ty), } } @@ -692,8 +692,8 @@ fn visit_variant( ) -> InterpResult<'tcx> { let name = match old_op.layout.ty.kind() { ty::Adt(adt, _) => PathElem::Variant(adt.variant(variant_id).name), - // Generators also have variants - ty::Generator(..) => PathElem::GeneratorState(variant_id), + // Coroutines also have variants + ty::Coroutine(..) => PathElem::CoroutineState(variant_id), _ => bug!("Unexpected type with variant: {:?}", old_op.layout.ty), }; self.with_elem(name, move |this| this.visit_value(new_op)) diff --git a/compiler/rustc_const_eval/src/transform/check_consts/check.rs b/compiler/rustc_const_eval/src/transform/check_consts/check.rs index 92e7922ad3b..e0acd695b34 100644 --- a/compiler/rustc_const_eval/src/transform/check_consts/check.rs +++ b/compiler/rustc_const_eval/src/transform/check_consts/check.rs @@ -463,11 +463,11 @@ fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, location: Location) { | Rvalue::Len(_) => {} Rvalue::Aggregate(kind, ..) => { - if let AggregateKind::Generator(def_id, ..) = kind.as_ref() - && let Some(generator_kind @ hir::GeneratorKind::Async(..)) = + if let AggregateKind::Coroutine(def_id, ..) = kind.as_ref() + && let Some(generator_kind @ hir::CoroutineKind::Async(..)) = self.tcx.generator_kind(def_id) { - self.check_op(ops::Generator(generator_kind)); + self.check_op(ops::Coroutine(generator_kind)); } } @@ -1042,8 +1042,8 @@ fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location TerminatorKind::InlineAsm { .. } => self.check_op(ops::InlineAsm), - TerminatorKind::GeneratorDrop | TerminatorKind::Yield { .. } => { - self.check_op(ops::Generator(hir::GeneratorKind::Gen)) + TerminatorKind::CoroutineDrop | TerminatorKind::Yield { .. } => { + self.check_op(ops::Coroutine(hir::CoroutineKind::Gen)) } TerminatorKind::UnwindTerminate(_) => { diff --git a/compiler/rustc_const_eval/src/transform/check_consts/ops.rs b/compiler/rustc_const_eval/src/transform/check_consts/ops.rs index e8d1d595820..616fab8fe7d 100644 --- a/compiler/rustc_const_eval/src/transform/check_consts/ops.rs +++ b/compiler/rustc_const_eval/src/transform/check_consts/ops.rs @@ -357,10 +357,10 @@ fn build_error( } #[derive(Debug)] -pub struct Generator(pub hir::GeneratorKind); -impl<'tcx> NonConstOp<'tcx> for Generator { +pub struct Coroutine(pub hir::CoroutineKind); +impl<'tcx> NonConstOp<'tcx> for Coroutine { fn status_in_item(&self, _: &ConstCx<'_, 'tcx>) -> Status { - if let hir::GeneratorKind::Async(hir::AsyncGeneratorKind::Block) = self.0 { + if let hir::CoroutineKind::Async(hir::AsyncCoroutineKind::Block) = self.0 { Status::Unstable(sym::const_async_blocks) } else { Status::Forbidden @@ -373,7 +373,7 @@ fn build_error( span: Span, ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> { let msg = format!("{}s are not allowed in {}s", self.0.descr(), ccx.const_kind()); - if let hir::GeneratorKind::Async(hir::AsyncGeneratorKind::Block) = self.0 { + if let hir::CoroutineKind::Async(hir::AsyncCoroutineKind::Block) = self.0 { ccx.tcx.sess.create_feature_err( errors::UnallowedOpInConstContext { span, msg }, sym::const_async_blocks, diff --git a/compiler/rustc_const_eval/src/transform/check_consts/post_drop_elaboration.rs b/compiler/rustc_const_eval/src/transform/check_consts/post_drop_elaboration.rs index fd6bc2ee9af..aff256b3ead 100644 --- a/compiler/rustc_const_eval/src/transform/check_consts/post_drop_elaboration.rs +++ b/compiler/rustc_const_eval/src/transform/check_consts/post_drop_elaboration.rs @@ -111,7 +111,7 @@ fn visit_terminator(&mut self, terminator: &mir::Terminator<'tcx>, location: Loc | mir::TerminatorKind::Assert { .. } | mir::TerminatorKind::FalseEdge { .. } | mir::TerminatorKind::FalseUnwind { .. } - | mir::TerminatorKind::GeneratorDrop + | mir::TerminatorKind::CoroutineDrop | mir::TerminatorKind::Goto { .. } | mir::TerminatorKind::InlineAsm { .. } | mir::TerminatorKind::UnwindResume diff --git a/compiler/rustc_const_eval/src/transform/validate.rs b/compiler/rustc_const_eval/src/transform/validate.rs index 4711f7b47cc..480327503ea 100644 --- a/compiler/rustc_const_eval/src/transform/validate.rs +++ b/compiler/rustc_const_eval/src/transform/validate.rs @@ -67,7 +67,7 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { let body_abi = match body_ty.kind() { ty::FnDef(..) => body_ty.fn_sig(tcx).abi(), ty::Closure(..) => Abi::RustCall, - ty::Generator(..) => Abi::Rust, + ty::Coroutine(..) => Abi::Rust, _ => { span_bug!(body.span, "unexpected body ty: {:?} phase {:?}", body_ty, mir_phase) } @@ -509,14 +509,14 @@ fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location } self.check_unwind_edge(location, *unwind); } - TerminatorKind::GeneratorDrop => { + TerminatorKind::CoroutineDrop => { if self.body.generator.is_none() { - self.fail(location, "`GeneratorDrop` cannot appear outside generator bodies"); + self.fail(location, "`CoroutineDrop` cannot appear outside generator bodies"); } if self.mir_phase >= MirPhase::Runtime(RuntimePhase::Initial) { self.fail( location, - "`GeneratorDrop` should have been replaced by generator lowering", + "`CoroutineDrop` should have been replaced by generator lowering", ); } } @@ -716,7 +716,7 @@ fn visit_projection_elem( }; check_equal(self, location, f_ty); } - &ty::Generator(def_id, args, _) => { + &ty::Coroutine(def_id, args, _) => { let f_ty = if let Some(var) = parent_ty.variant_index { let gen_body = if def_id == self.body.source.def_id() { self.body @@ -1211,7 +1211,7 @@ fn visit_statement(&mut self, statement: &Statement<'tcx>, location: Location) { self.fail(location, "`SetDiscriminant`is not allowed until deaggregation"); } let pty = place.ty(&self.body.local_decls, self.tcx).ty.kind(); - if !matches!(pty, ty::Adt(..) | ty::Generator(..) | ty::Alias(ty::Opaque, ..)) { + if !matches!(pty, ty::Adt(..) | ty::Coroutine(..) | ty::Alias(ty::Opaque, ..)) { self.fail( location, format!( @@ -1295,7 +1295,7 @@ fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location | TerminatorKind::FalseEdge { .. } | TerminatorKind::FalseUnwind { .. } | TerminatorKind::InlineAsm { .. } - | TerminatorKind::GeneratorDrop + | TerminatorKind::CoroutineDrop | TerminatorKind::UnwindResume | TerminatorKind::UnwindTerminate(_) | TerminatorKind::Return diff --git a/compiler/rustc_const_eval/src/util/type_name.rs b/compiler/rustc_const_eval/src/util/type_name.rs index 54eb14ae8fc..8c7c360acbf 100644 --- a/compiler/rustc_const_eval/src/util/type_name.rs +++ b/compiler/rustc_const_eval/src/util/type_name.rs @@ -51,12 +51,12 @@ fn print_type(mut self, ty: Ty<'tcx>) -> Result { | ty::FnDef(def_id, args) | ty::Alias(ty::Projection | ty::Opaque, ty::AliasTy { def_id, args, .. }) | ty::Closure(def_id, args) - | ty::Generator(def_id, args, _) => self.print_def_path(def_id, args), + | ty::Coroutine(def_id, args, _) => self.print_def_path(def_id, args), ty::Foreign(def_id) => self.print_def_path(def_id, &[]), ty::Alias(ty::Weak, _) => bug!("type_name: unexpected weak projection"), ty::Alias(ty::Inherent, _) => bug!("type_name: unexpected inherent projection"), - ty::GeneratorWitness(..) => bug!("type_name: unexpected `GeneratorWitness`"), + ty::CoroutineWitness(..) => bug!("type_name: unexpected `CoroutineWitness`"), } } diff --git a/compiler/rustc_error_codes/src/error_codes/E0626.md b/compiler/rustc_error_codes/src/error_codes/E0626.md index cc6e03d1ca7..e64dec79972 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0626.md +++ b/compiler/rustc_error_codes/src/error_codes/E0626.md @@ -5,7 +5,7 @@ Erroneous code example: ```compile_fail,E0626 # #![feature(generators, generator_trait, pin)] -# use std::ops::Generator; +# use std::ops::Coroutine; # use std::pin::Pin; let mut b = || { let a = &String::new(); // <-- This borrow... @@ -24,7 +24,7 @@ the integer by value: ``` # #![feature(generators, generator_trait, pin)] -# use std::ops::Generator; +# use std::ops::Coroutine; # use std::pin::Pin; let mut b = || { let a = 3; @@ -42,7 +42,7 @@ This error also frequently arises with iteration: ```compile_fail,E0626 # #![feature(generators, generator_trait, pin)] -# use std::ops::Generator; +# use std::ops::Coroutine; # use std::pin::Pin; let mut b = || { let v = vec![1,2,3]; @@ -58,7 +58,7 @@ Such cases can sometimes be resolved by iterating "by value" (or using ``` # #![feature(generators, generator_trait, pin)] -# use std::ops::Generator; +# use std::ops::Coroutine; # use std::pin::Pin; let mut b = || { let v = vec![1,2,3]; @@ -73,7 +73,7 @@ If taking ownership is not an option, using indices can work too: ``` # #![feature(generators, generator_trait, pin)] -# use std::ops::Generator; +# use std::ops::Coroutine; # use std::pin::Pin; let mut b = || { let v = vec![1,2,3]; diff --git a/compiler/rustc_error_codes/src/error_codes/E0790.md b/compiler/rustc_error_codes/src/error_codes/E0790.md index 2aee9dfbdbd..b52543c48d8 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0790.md +++ b/compiler/rustc_error_codes/src/error_codes/E0790.md @@ -4,24 +4,24 @@ method. Erroneous code example: ```compile_fail,E0790 -trait Generator { +trait Coroutine { fn create() -> u32; } struct Impl; -impl Generator for Impl { +impl Coroutine for Impl { fn create() -> u32 { 1 } } struct AnotherImpl; -impl Generator for AnotherImpl { +impl Coroutine for AnotherImpl { fn create() -> u32 { 2 } } -let cont: u32 = Generator::create(); -// error, impossible to choose one of Generator trait implementation +let cont: u32 = Coroutine::create(); +// error, impossible to choose one of Coroutine trait implementation // Should it be Impl or AnotherImpl, maybe something else? ``` @@ -30,18 +30,18 @@ information to the compiler. In this case, the solution is to use a concrete type: ``` -trait Generator { +trait Coroutine { fn create() -> u32; } struct AnotherImpl; -impl Generator for AnotherImpl { +impl Coroutine for AnotherImpl { fn create() -> u32 { 2 } } let gen1 = AnotherImpl::create(); // if there are multiple methods with same name (different traits) -let gen2 = ::create(); +let gen2 = ::create(); ``` diff --git a/compiler/rustc_hir/src/def.rs b/compiler/rustc_hir/src/def.rs index 3a4eb90f7f9..3c7d158c9ad 100644 --- a/compiler/rustc_hir/src/def.rs +++ b/compiler/rustc_hir/src/def.rs @@ -118,7 +118,7 @@ pub enum DefKind { of_trait: bool, }, Closure, - Generator, + Coroutine, } impl DefKind { @@ -161,7 +161,7 @@ pub fn descr(self, def_id: DefId) -> &'static str { DefKind::Field => "field", DefKind::Impl { .. } => "implementation", DefKind::Closure => "closure", - DefKind::Generator => "generator", + DefKind::Coroutine => "generator", DefKind::ExternCrate => "extern crate", DefKind::GlobalAsm => "global assembly block", } @@ -220,7 +220,7 @@ pub fn ns(&self) -> Option { | DefKind::LifetimeParam | DefKind::ExternCrate | DefKind::Closure - | DefKind::Generator + | DefKind::Coroutine | DefKind::Use | DefKind::ForeignMod | DefKind::GlobalAsm @@ -230,7 +230,7 @@ pub fn ns(&self) -> Option { #[inline] pub fn is_fn_like(self) -> bool { - matches!(self, DefKind::Fn | DefKind::AssocFn | DefKind::Closure | DefKind::Generator) + matches!(self, DefKind::Fn | DefKind::AssocFn | DefKind::Closure | DefKind::Coroutine) } /// Whether `query get_codegen_attrs` should be used with this definition. @@ -240,7 +240,7 @@ pub fn has_codegen_attrs(self) -> bool { | DefKind::AssocFn | DefKind::Ctor(..) | DefKind::Closure - | DefKind::Generator + | DefKind::Coroutine | DefKind::Static(_) => true, DefKind::Mod | DefKind::Struct diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index 3eec66611ed..f60e312937c 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -1493,7 +1493,7 @@ pub struct BodyId { pub struct Body<'hir> { pub params: &'hir [Param<'hir>], pub value: &'hir Expr<'hir>, - pub generator_kind: Option, + pub generator_kind: Option, } impl<'hir> Body<'hir> { @@ -1501,7 +1501,7 @@ pub fn id(&self) -> BodyId { BodyId { hir_id: self.value.hir_id } } - pub fn generator_kind(&self) -> Option { + pub fn generator_kind(&self) -> Option { self.generator_kind } } @@ -1509,28 +1509,28 @@ pub fn generator_kind(&self) -> Option { /// The type of source expression that caused this generator to be created. #[derive(Clone, PartialEq, Eq, Debug, Copy, Hash)] #[derive(HashStable_Generic, Encodable, Decodable)] -pub enum GeneratorKind { +pub enum CoroutineKind { /// An explicit `async` block or the body of an async function. - Async(AsyncGeneratorKind), + Async(AsyncCoroutineKind), /// A generator literal created via a `yield` inside a closure. Gen, } -impl fmt::Display for GeneratorKind { +impl fmt::Display for CoroutineKind { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - GeneratorKind::Async(k) => fmt::Display::fmt(k, f), - GeneratorKind::Gen => f.write_str("generator"), + CoroutineKind::Async(k) => fmt::Display::fmt(k, f), + CoroutineKind::Gen => f.write_str("generator"), } } } -impl GeneratorKind { +impl CoroutineKind { pub fn descr(&self) -> &'static str { match self { - GeneratorKind::Async(ask) => ask.descr(), - GeneratorKind::Gen => "generator", + CoroutineKind::Async(ask) => ask.descr(), + CoroutineKind::Gen => "generator", } } } @@ -1542,7 +1542,7 @@ pub fn descr(&self) -> &'static str { /// type-checking (see #60424). #[derive(Clone, PartialEq, Eq, Hash, Debug, Copy)] #[derive(HashStable_Generic, Encodable, Decodable)] -pub enum AsyncGeneratorKind { +pub enum AsyncCoroutineKind { /// An explicit `async` block written by the user. Block, @@ -1553,22 +1553,22 @@ pub enum AsyncGeneratorKind { Fn, } -impl fmt::Display for AsyncGeneratorKind { +impl fmt::Display for AsyncCoroutineKind { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(match self { - AsyncGeneratorKind::Block => "async block", - AsyncGeneratorKind::Closure => "async closure body", - AsyncGeneratorKind::Fn => "async fn body", + AsyncCoroutineKind::Block => "async block", + AsyncCoroutineKind::Closure => "async closure body", + AsyncCoroutineKind::Fn => "async fn body", }) } } -impl AsyncGeneratorKind { +impl AsyncCoroutineKind { pub fn descr(&self) -> &'static str { match self { - AsyncGeneratorKind::Block => "`async` block", - AsyncGeneratorKind::Closure => "`async` closure body", - AsyncGeneratorKind::Fn => "`async fn` body", + AsyncCoroutineKind::Block => "`async` block", + AsyncCoroutineKind::Closure => "`async` closure body", + AsyncCoroutineKind::Fn => "`async fn` body", } } } @@ -2247,12 +2247,12 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { } } -impl From for YieldSource { - fn from(kind: GeneratorKind) -> Self { +impl From for YieldSource { + fn from(kind: CoroutineKind) -> Self { match kind { // Guess based on the kind of the current generator. - GeneratorKind::Gen => Self::Yield, - GeneratorKind::Async(_) => Self::Await { expr: None }, + CoroutineKind::Gen => Self::Yield, + CoroutineKind::Async(_) => Self::Await { expr: None }, } } } diff --git a/compiler/rustc_hir/src/lang_items.rs b/compiler/rustc_hir/src/lang_items.rs index 4a89a6f7e39..b13eb3b5e7a 100644 --- a/compiler/rustc_hir/src/lang_items.rs +++ b/compiler/rustc_hir/src/lang_items.rs @@ -211,8 +211,8 @@ pub fn extract(attrs: &[ast::Attribute]) -> Option<(Symbol, Span)> { FnOnceOutput, sym::fn_once_output, fn_once_output, Target::AssocTy, GenericRequirement::None; Future, sym::future_trait, future_trait, Target::Trait, GenericRequirement::Exact(0); - GeneratorState, sym::generator_state, gen_state, Target::Enum, GenericRequirement::None; - Generator, sym::generator, gen_trait, Target::Trait, GenericRequirement::Minimum(1); + CoroutineState, sym::generator_state, gen_state, Target::Enum, GenericRequirement::None; + Coroutine, sym::generator, gen_trait, Target::Trait, GenericRequirement::Minimum(1); Unpin, sym::unpin, unpin_trait, Target::Trait, GenericRequirement::None; Pin, sym::pin, pin_type, Target::Struct, GenericRequirement::None; diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs index 1745488dfd3..0b410e26add 100644 --- a/compiler/rustc_hir_analysis/src/check/check.rs +++ b/compiler/rustc_hir_analysis/src/check/check.rs @@ -1394,7 +1394,7 @@ fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow { self.opaques.push(def); ControlFlow::Continue(()) } - ty::Closure(def_id, ..) | ty::Generator(def_id, ..) => { + ty::Closure(def_id, ..) | ty::Coroutine(def_id, ..) => { self.closures.push(def_id); t.super_visit_with(self) } @@ -1447,7 +1447,7 @@ fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow { label_match(capture.place.ty(), capture.get_path_span(tcx)); } // Label any generator locals that capture the opaque - if let DefKind::Generator = tcx.def_kind(closure_def_id) + if let DefKind::Coroutine = tcx.def_kind(closure_def_id) && let Some(generator_layout) = tcx.mir_generator_witnesses(closure_def_id) { for interior_ty in &generator_layout.field_tys { @@ -1465,7 +1465,7 @@ fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow { } pub(super) fn check_generator_obligations(tcx: TyCtxt<'_>, def_id: LocalDefId) { - debug_assert!(matches!(tcx.def_kind(def_id), DefKind::Generator)); + debug_assert!(matches!(tcx.def_kind(def_id), DefKind::Coroutine)); let typeck = tcx.typeck(def_id); let param_env = tcx.param_env(def_id); @@ -1500,7 +1500,7 @@ pub(super) fn check_generator_obligations(tcx: TyCtxt<'_>, def_id: LocalDefId) { ObligationCause::new( field_ty.source_info.span, def_id, - ObligationCauseCode::SizedGeneratorInterior(def_id), + ObligationCauseCode::SizedCoroutineInterior(def_id), ), ); } diff --git a/compiler/rustc_hir_analysis/src/coherence/inherent_impls.rs b/compiler/rustc_hir_analysis/src/coherence/inherent_impls.rs index 0042d683b19..1b4df31b50c 100644 --- a/compiler/rustc_hir_analysis/src/coherence/inherent_impls.rs +++ b/compiler/rustc_hir_analysis/src/coherence/inherent_impls.rs @@ -155,8 +155,8 @@ fn check_item(&mut self, id: hir::ItemId) { } ty::FnDef(..) | ty::Closure(..) - | ty::Generator(..) - | ty::GeneratorWitness(..) + | ty::Coroutine(..) + | ty::CoroutineWitness(..) | ty::Bound(..) | ty::Placeholder(_) | ty::Infer(_) => { diff --git a/compiler/rustc_hir_analysis/src/coherence/orphan.rs b/compiler/rustc_hir_analysis/src/coherence/orphan.rs index 69020b1f11d..faddb0c3829 100644 --- a/compiler/rustc_hir_analysis/src/coherence/orphan.rs +++ b/compiler/rustc_hir_analysis/src/coherence/orphan.rs @@ -243,8 +243,8 @@ enum NonlocalImpl { | ty::Tuple(..) => (LocalImpl::Allow, NonlocalImpl::DisallowOther), ty::Closure(..) - | ty::Generator(..) - | ty::GeneratorWitness(..) + | ty::Coroutine(..) + | ty::CoroutineWitness(..) | ty::Bound(..) | ty::Placeholder(..) | ty::Infer(..) => { diff --git a/compiler/rustc_hir_analysis/src/collect.rs b/compiler/rustc_hir_analysis/src/collect.rs index 8e124d8eb1a..e5908413150 100644 --- a/compiler/rustc_hir_analysis/src/collect.rs +++ b/compiler/rustc_hir_analysis/src/collect.rs @@ -1548,7 +1548,7 @@ fn compute_sig_of_foreign_fn_decl<'tcx>( fty } -fn generator_kind(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option { +fn generator_kind(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option { match tcx.hir().get_by_def_id(def_id) { Node::Expr(&rustc_hir::Expr { kind: rustc_hir::ExprKind::Closure(&rustc_hir::Closure { body, .. }), diff --git a/compiler/rustc_hir_analysis/src/variance/constraints.rs b/compiler/rustc_hir_analysis/src/variance/constraints.rs index 61d9c989e2f..5f8b1ace68b 100644 --- a/compiler/rustc_hir_analysis/src/variance/constraints.rs +++ b/compiler/rustc_hir_analysis/src/variance/constraints.rs @@ -235,7 +235,7 @@ fn add_constraints_from_ty( // leaf type -- noop } - ty::FnDef(..) | ty::Generator(..) | ty::Closure(..) => { + ty::FnDef(..) | ty::Coroutine(..) | ty::Closure(..) => { bug!("Unexpected closure type in variance computation"); } @@ -312,7 +312,7 @@ fn add_constraints_from_ty( // types, where we use Error as the Self type } - ty::Placeholder(..) | ty::GeneratorWitness(..) | ty::Bound(..) | ty::Infer(..) => { + ty::Placeholder(..) | ty::CoroutineWitness(..) | ty::Bound(..) | ty::Infer(..) => { bug!("unexpected type encountered in variance inference: {}", ty); } } diff --git a/compiler/rustc_hir_typeck/src/callee.rs b/compiler/rustc_hir_typeck/src/callee.rs index 78d30f3aa12..3f6809cf72d 100644 --- a/compiler/rustc_hir_typeck/src/callee.rs +++ b/compiler/rustc_hir_typeck/src/callee.rs @@ -305,7 +305,7 @@ fn identify_bad_closure_def_and_call( ) = (parent_node, callee_node) { let fn_decl_span = if hir.body(body).generator_kind - == Some(hir::GeneratorKind::Async(hir::AsyncGeneratorKind::Closure)) + == Some(hir::CoroutineKind::Async(hir::AsyncCoroutineKind::Closure)) { // Actually need to unwrap one more layer of HIR to get to // the _real_ closure... diff --git a/compiler/rustc_hir_typeck/src/cast.rs b/compiler/rustc_hir_typeck/src/cast.rs index 419e154a17a..a834ea15047 100644 --- a/compiler/rustc_hir_typeck/src/cast.rs +++ b/compiler/rustc_hir_typeck/src/cast.rs @@ -128,13 +128,13 @@ fn pointer_kind( | ty::Uint(..) | ty::Float(_) | ty::Array(..) - | ty::GeneratorWitness(..) + | ty::CoroutineWitness(..) | ty::RawPtr(_) | ty::Ref(..) | ty::FnDef(..) | ty::FnPtr(..) | ty::Closure(..) - | ty::Generator(..) + | ty::Coroutine(..) | ty::Adt(..) | ty::Never | ty::Dynamic(_, _, ty::DynStar) diff --git a/compiler/rustc_hir_typeck/src/check.rs b/compiler/rustc_hir_typeck/src/check.rs index 26ea7b0fdb9..a040e2ee9e0 100644 --- a/compiler/rustc_hir_typeck/src/check.rs +++ b/compiler/rustc_hir_typeck/src/check.rs @@ -2,8 +2,8 @@ use crate::coercion::CoerceMany; use crate::gather_locals::GatherLocalsVisitor; +use crate::CoroutineTypes; use crate::FnCtxt; -use crate::GeneratorTypes; use rustc_hir as hir; use rustc_hir::def::DefKind; use rustc_hir::intravisit::Visitor; @@ -33,7 +33,7 @@ pub(super) fn check_fn<'a, 'tcx>( body: &'tcx hir::Body<'tcx>, can_be_generator: Option, params_can_be_unsized: bool, -) -> Option> { +) -> Option> { let fn_id = fcx.tcx.hir().local_def_id_to_hir_id(fn_def_id); let tcx = fcx.tcx; @@ -58,7 +58,7 @@ pub(super) fn check_fn<'a, 'tcx>( if let Some(kind) = body.generator_kind && can_be_generator.is_some() { - let yield_ty = if kind == hir::GeneratorKind::Gen { + let yield_ty = if kind == hir::CoroutineKind::Gen { let yield_ty = fcx.next_ty_var(TypeVariableOrigin { kind: TypeVariableOriginKind::TypeInference, span, @@ -138,7 +138,7 @@ pub(super) fn check_fn<'a, 'tcx>( )); let (resume_ty, yield_ty) = fcx.resume_yield_tys.unwrap(); - Some(GeneratorTypes { + Some(CoroutineTypes { resume_ty, yield_ty, interior, diff --git a/compiler/rustc_hir_typeck/src/closure.rs b/compiler/rustc_hir_typeck/src/closure.rs index 06542b0cc24..9c6b128dd8d 100644 --- a/compiler/rustc_hir_typeck/src/closure.rs +++ b/compiler/rustc_hir_typeck/src/closure.rs @@ -1,6 +1,6 @@ //! Code for type-checking closure expressions. -use super::{check_fn, Expectation, FnCtxt, GeneratorTypes}; +use super::{check_fn, CoroutineTypes, Expectation, FnCtxt}; use rustc_errors::ErrorGuaranteed; use rustc_hir as hir; @@ -105,11 +105,11 @@ fn check_closure( span: self.tcx.def_span(expr_def_id), }); - if let Some(GeneratorTypes { resume_ty, yield_ty, interior, movability }) = generator_types + if let Some(CoroutineTypes { resume_ty, yield_ty, interior, movability }) = generator_types { - let generator_args = ty::GeneratorArgs::new( + let generator_args = ty::CoroutineArgs::new( self.tcx, - ty::GeneratorArgsParts { + ty::CoroutineArgsParts { parent_args, resume_ty, yield_ty, @@ -310,10 +310,10 @@ fn deduce_sig_from_projection( return None; } - // Check that we deduce the signature from the `<_ as std::ops::Generator>::Return` + // Check that we deduce the signature from the `<_ as std::ops::Coroutine>::Return` // associated item and not yield. if is_gen && self.tcx.associated_item(projection.projection_def_id()).name != sym::Return { - debug!("not `Return` assoc item of `Generator`"); + debug!("not `Return` assoc item of `Coroutine`"); return None; } @@ -327,7 +327,7 @@ fn deduce_sig_from_projection( _ => return None, } } else { - // Generators with a `()` resume type may be defined with 0 or 1 explicit arguments, + // Coroutines with a `()` resume type may be defined with 0 or 1 explicit arguments, // else they must have exactly 1 argument. For now though, just give up in this case. return None; }; @@ -636,7 +636,7 @@ fn supplied_sig_of_closure( // In the case of the async block that we create for a function body, // we expect the return type of the block to match that of the enclosing // function. - Some(hir::GeneratorKind::Async(hir::AsyncGeneratorKind::Fn)) => { + Some(hir::CoroutineKind::Async(hir::AsyncCoroutineKind::Fn)) => { debug!("closure is async fn body"); let def_id = self.tcx.hir().body_owner_def_id(body.id()); self.deduce_future_output_from_obligations(expr_def_id, def_id).unwrap_or_else( diff --git a/compiler/rustc_hir_typeck/src/errors.rs b/compiler/rustc_hir_typeck/src/errors.rs index 8efccd5ba3e..d518f79a8db 100644 --- a/compiler/rustc_hir_typeck/src/errors.rs +++ b/compiler/rustc_hir_typeck/src/errors.rs @@ -63,7 +63,7 @@ pub struct RustCallIncorrectArgs { #[derive(Diagnostic)] #[diag(hir_typeck_yield_expr_outside_of_generator, code = "E0627")] -pub struct YieldExprOutsideOfGenerator { +pub struct YieldExprOutsideOfCoroutine { #[primary_span] pub span: Span, } diff --git a/compiler/rustc_hir_typeck/src/expr.rs b/compiler/rustc_hir_typeck/src/expr.rs index 96df0346ac6..be225ceb843 100644 --- a/compiler/rustc_hir_typeck/src/expr.rs +++ b/compiler/rustc_hir_typeck/src/expr.rs @@ -10,7 +10,7 @@ use crate::errors::{AddressOfTemporaryTaken, ReturnStmtOutsideOfFnBody, StructExprNonExhaustive}; use crate::errors::{ FieldMultiplySpecifiedInInitializer, FunctionalRecordUpdateOnNonStruct, HelpUseLatestEdition, - YieldExprOutsideOfGenerator, + YieldExprOutsideOfCoroutine, }; use crate::fatally_break_rust; use crate::method::{MethodCallComponents, SelfSource}; @@ -3019,7 +3019,7 @@ fn check_expr_yield( Ty::new_unit(self.tcx) } _ => { - self.tcx.sess.emit_err(YieldExprOutsideOfGenerator { span: expr.span }); + self.tcx.sess.emit_err(YieldExprOutsideOfCoroutine { span: expr.span }); // Avoid expressions without types during writeback (#78653). self.check_expr(value); Ty::new_unit(self.tcx) diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs index 6e0e02b7814..dbee98b88ba 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs @@ -530,7 +530,7 @@ pub(in super::super) fn resolve_generator_interiors(&self, def_id: DefId) { for &(expr_def_id, body_id, interior, _) in generators.iter() { debug!(?expr_def_id); - // Create the `GeneratorWitness` type that we will unify with `interior`. + // Create the `CoroutineWitness` type that we will unify with `interior`. let args = ty::GenericArgs::identity_for_item( self.tcx, self.tcx.typeck_root_def_id(expr_def_id.to_def_id()), diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/adjust_fulfillment_errors.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/adjust_fulfillment_errors.rs index 522d0e2616b..facbeb8badf 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/adjust_fulfillment_errors.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/adjust_fulfillment_errors.rs @@ -366,7 +366,7 @@ fn closure_span_overlaps_error( box traits::SelectionOutputTypeParameterMismatch { expected_trait_ref, .. }, ), ) = error.code - && let ty::Closure(def_id, _) | ty::Generator(def_id, ..) = + && let ty::Closure(def_id, _) | ty::Coroutine(def_id, ..) = expected_trait_ref.skip_binder().self_ty().kind() && span.overlaps(self.tcx.def_span(*def_id)) { diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs index 14d69141343..6dbee3f3936 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs @@ -9,7 +9,7 @@ use rustc_hir::def::{CtorKind, CtorOf, DefKind}; use rustc_hir::lang_items::LangItem; use rustc_hir::{ - AsyncGeneratorKind, Expr, ExprKind, GeneratorKind, GenericBound, HirId, Node, Path, QPath, + AsyncCoroutineKind, CoroutineKind, Expr, ExprKind, GenericBound, HirId, Node, Path, QPath, Stmt, StmtKind, TyKind, WherePredicate, }; use rustc_hir_analysis::astconv::AstConv; @@ -532,10 +532,10 @@ pub(in super::super) fn suggest_boxing_when_appropriate( ty::Tuple(tuple) if tuple.is_empty() => { errors::SuggestBoxing::Unit { start: span.shrink_to_lo(), end: span } } - ty::Generator(def_id, ..) + ty::Coroutine(def_id, ..) if matches!( self.tcx.generator_kind(def_id), - Some(GeneratorKind::Async(AsyncGeneratorKind::Closure)) + Some(CoroutineKind::Async(AsyncCoroutineKind::Closure)) ) => { errors::SuggestBoxing::AsyncBody diff --git a/compiler/rustc_hir_typeck/src/inherited.rs b/compiler/rustc_hir_typeck/src/inherited.rs index bee79242fd1..16462be758f 100644 --- a/compiler/rustc_hir_typeck/src/inherited.rs +++ b/compiler/rustc_hir_typeck/src/inherited.rs @@ -56,7 +56,7 @@ pub struct Inherited<'tcx> { pub(super) deferred_asm_checks: RefCell, hir::HirId)>>, pub(super) deferred_generator_interiors: - RefCell, hir::GeneratorKind)>>, + RefCell, hir::CoroutineKind)>>, /// Whenever we introduce an adjustment from `!` into a type variable, /// we record that type variable here. This is later used to inform diff --git a/compiler/rustc_hir_typeck/src/lib.rs b/compiler/rustc_hir_typeck/src/lib.rs index cd6adb345e7..98778d6b98d 100644 --- a/compiler/rustc_hir_typeck/src/lib.rs +++ b/compiler/rustc_hir_typeck/src/lib.rs @@ -301,14 +301,14 @@ fn typeck_with_fallback<'tcx>( /// When `check_fn` is invoked on a generator (i.e., a body that /// includes yield), it returns back some information about the yield /// points. -struct GeneratorTypes<'tcx> { +struct CoroutineTypes<'tcx> { /// Type of generator argument / values returned by `yield`. resume_ty: Ty<'tcx>, /// Type of value that is yielded. yield_ty: Ty<'tcx>, - /// Types that are captured (see `GeneratorInterior` for more). + /// Types that are captured (see `CoroutineInterior` for more). interior: Ty<'tcx>, /// Indicates if the generator is movable or static (immovable). diff --git a/compiler/rustc_hir_typeck/src/upvar.rs b/compiler/rustc_hir_typeck/src/upvar.rs index 4d641390368..a3a93141f42 100644 --- a/compiler/rustc_hir_typeck/src/upvar.rs +++ b/compiler/rustc_hir_typeck/src/upvar.rs @@ -172,7 +172,7 @@ fn analyze_closure( let ty = self.node_ty(closure_hir_id); let (closure_def_id, args) = match *ty.kind() { ty::Closure(def_id, args) => (def_id, UpvarArgs::Closure(args)), - ty::Generator(def_id, args, _) => (def_id, UpvarArgs::Generator(args)), + ty::Coroutine(def_id, args, _) => (def_id, UpvarArgs::Coroutine(args)), ty::Error(_) => { // #51714: skip analysis when we have already encountered type errors return; diff --git a/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs b/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs index 4124c9eada9..0e2f9ba70fe 100644 --- a/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs +++ b/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs @@ -457,8 +457,8 @@ fn fold_ty(&mut self, mut t: Ty<'tcx>) -> Ty<'tcx> { } ty::Closure(..) - | ty::Generator(..) - | ty::GeneratorWitness(..) + | ty::Coroutine(..) + | ty::CoroutineWitness(..) | ty::Bool | ty::Char | ty::Int(..) diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs index 496bb1766a7..60d48c62481 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs @@ -2936,7 +2936,7 @@ pub enum TyCategory { Closure, Opaque, OpaqueFuture, - Generator(hir::GeneratorKind), + Coroutine(hir::CoroutineKind), Foreign, } @@ -2946,7 +2946,7 @@ fn descr(&self) -> &'static str { Self::Closure => "closure", Self::Opaque => "opaque type", Self::OpaqueFuture => "future", - Self::Generator(gk) => gk.descr(), + Self::Coroutine(gk) => gk.descr(), Self::Foreign => "foreign type", } } @@ -2959,8 +2959,8 @@ pub fn from_ty(tcx: TyCtxt<'_>, ty: Ty<'_>) -> Option<(Self, DefId)> { if tcx.ty_is_opaque_future(ty) { Self::OpaqueFuture } else { Self::Opaque }; Some((kind, def_id)) } - ty::Generator(def_id, ..) => { - Some((Self::Generator(tcx.generator_kind(def_id).unwrap()), def_id)) + ty::Coroutine(def_id, ..) => { + Some((Self::Coroutine(tcx.generator_kind(def_id).unwrap()), def_id)) } ty::Foreign(def_id) => Some((Self::Foreign, def_id)), _ => None, diff --git a/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs b/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs index 5408b99235d..8809b967aee 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs @@ -864,7 +864,7 @@ fn generic_arg_contains_target(&self, arg: GenericArg<'tcx>) -> bool { GenericArgKind::Type(ty) => { if matches!( ty.kind(), - ty::Alias(ty::Opaque, ..) | ty::Closure(..) | ty::Generator(..) + ty::Alias(ty::Opaque, ..) | ty::Closure(..) | ty::Coroutine(..) ) { // Opaque types can't be named by the user right now. // diff --git a/compiler/rustc_infer/src/infer/error_reporting/note_and_explain.rs b/compiler/rustc_infer/src/infer/error_reporting/note_and_explain.rs index 3da6d8a89e1..ca620aafc5c 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/note_and_explain.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/note_and_explain.rs @@ -215,7 +215,7 @@ fn foo(&self, x: T) -> T { x } #traits-as-parameters", ); } - (ty::Param(p), ty::Closure(..) | ty::Generator(..)) => { + (ty::Param(p), ty::Closure(..) | ty::Coroutine(..)) => { let generics = tcx.generics_of(body_owner_def_id); let p_span = tcx.def_span(generics.type_param(p, tcx).def_id); if !sp.contains(p_span) { diff --git a/compiler/rustc_infer/src/infer/opaque_types.rs b/compiler/rustc_infer/src/infer/opaque_types.rs index 1c3a5c36076..3812cc9cd46 100644 --- a/compiler/rustc_infer/src/infer/opaque_types.rs +++ b/compiler/rustc_infer/src/infer/opaque_types.rs @@ -454,7 +454,7 @@ fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow { args.as_closure().sig_as_fn_ptr_ty().visit_with(self); } - ty::Generator(_, ref args, _) => { + ty::Coroutine(_, ref args, _) => { // Skip lifetime parameters of the enclosing item(s) // Also skip the witness type, because that has no free regions. diff --git a/compiler/rustc_infer/src/infer/outlives/components.rs b/compiler/rustc_infer/src/infer/outlives/components.rs index 6a9d40daab6..9a8e7ab68f9 100644 --- a/compiler/rustc_infer/src/infer/outlives/components.rs +++ b/compiler/rustc_infer/src/infer/outlives/components.rs @@ -102,7 +102,7 @@ fn compute_components<'tcx>( compute_components(tcx, tupled_ty, out, visited); } - ty::Generator(_, ref args, _) => { + ty::Coroutine(_, ref args, _) => { // Same as the closure case let tupled_ty = args.as_generator().tupled_upvars_ty(); compute_components(tcx, tupled_ty, out, visited); @@ -112,7 +112,7 @@ fn compute_components<'tcx>( } // All regions are bound inside a witness - ty::GeneratorWitness(..) => (), + ty::CoroutineWitness(..) => (), // OutlivesTypeParameterEnv -- the actual checking that `X:'a` // is implied by the environment is done in regionck. diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index 718dbaaafcc..2c8d32450be 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -799,7 +799,7 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> { }); tcx.hir().par_body_owners(|def_id| { - if let rustc_hir::def::DefKind::Generator = tcx.def_kind(def_id) { + if let rustc_hir::def::DefKind::Coroutine = tcx.def_kind(def_id) { tcx.ensure().mir_generator_witnesses(def_id); tcx.ensure().check_generator_obligations(def_id); } diff --git a/compiler/rustc_lint/src/foreign_modules.rs b/compiler/rustc_lint/src/foreign_modules.rs index b81e84fafac..86b3b4ad0ca 100644 --- a/compiler/rustc_lint/src/foreign_modules.rs +++ b/compiler/rustc_lint/src/foreign_modules.rs @@ -369,8 +369,8 @@ fn structurally_same_type_impl<'tcx>( (Dynamic(..), Dynamic(..)) | (Error(..), Error(..)) | (Closure(..), Closure(..)) - | (Generator(..), Generator(..)) - | (GeneratorWitness(..), GeneratorWitness(..)) + | (Coroutine(..), Coroutine(..)) + | (CoroutineWitness(..), CoroutineWitness(..)) | (Alias(ty::Projection, ..), Alias(ty::Projection, ..)) | (Alias(ty::Inherent, ..), Alias(ty::Inherent, ..)) | (Alias(ty::Opaque, ..), Alias(ty::Opaque, ..)) => false, diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs index 4eaf8bbf5de..ce52e95e0f1 100644 --- a/compiler/rustc_lint/src/lints.rs +++ b/compiler/rustc_lint/src/lints.rs @@ -1702,7 +1702,7 @@ pub struct UnusedClosure<'a> { #[derive(LintDiagnostic)] #[diag(lint_unused_generator)] #[note] -pub struct UnusedGenerator<'a> { +pub struct UnusedCoroutine<'a> { pub count: usize, pub pre: &'a str, pub post: &'a str, diff --git a/compiler/rustc_lint/src/types.rs b/compiler/rustc_lint/src/types.rs index f89b63e6f9f..c04053d1865 100644 --- a/compiler/rustc_lint/src/types.rs +++ b/compiler/rustc_lint/src/types.rs @@ -1272,8 +1272,8 @@ fn check_type_for_ffi(&self, cache: &mut FxHashSet>, ty: Ty<'tcx>) -> F | ty::Bound(..) | ty::Error(_) | ty::Closure(..) - | ty::Generator(..) - | ty::GeneratorWitness(..) + | ty::Coroutine(..) + | ty::CoroutineWitness(..) | ty::Placeholder(..) | ty::FnDef(..) => bug!("unexpected type in foreign function: {:?}", ty), } diff --git a/compiler/rustc_lint/src/unused.rs b/compiler/rustc_lint/src/unused.rs index 65de7e10272..c757bc85021 100644 --- a/compiler/rustc_lint/src/unused.rs +++ b/compiler/rustc_lint/src/unused.rs @@ -1,7 +1,7 @@ use crate::lints::{ PathStatementDrop, PathStatementDropSub, PathStatementNoEffect, UnusedAllocationDiag, - UnusedAllocationMutDiag, UnusedClosure, UnusedDef, UnusedDefSuggestion, UnusedDelim, - UnusedDelimSuggestion, UnusedGenerator, UnusedImportBracesDiag, UnusedOp, UnusedOpSuggestion, + UnusedAllocationMutDiag, UnusedClosure, UnusedCoroutine, UnusedDef, UnusedDefSuggestion, + UnusedDelim, UnusedDelimSuggestion, UnusedImportBracesDiag, UnusedOp, UnusedOpSuggestion, UnusedResult, }; use crate::Lint; @@ -258,7 +258,7 @@ enum MustUsePath { /// The root of the unused_closures lint. Closure(Span), /// The root of the unused_generators lint. - Generator(Span), + Coroutine(Span), } #[instrument(skip(cx, expr), level = "debug", ret)] @@ -350,7 +350,7 @@ fn is_ty_must_use<'tcx>( .map(|inner| MustUsePath::Array(Box::new(inner), len)), }, ty::Closure(..) => Some(MustUsePath::Closure(span)), - ty::Generator(def_id, ..) => { + ty::Coroutine(def_id, ..) => { // async fn should be treated as "implementor of `Future`" let must_use = if cx.tcx.generator_is_async(def_id) { let def_id = cx.tcx.lang_items().future_trait()?; @@ -359,7 +359,7 @@ fn is_ty_must_use<'tcx>( } else { None }; - must_use.or(Some(MustUsePath::Generator(span))) + must_use.or(Some(MustUsePath::Coroutine(span))) } _ => None, } @@ -482,11 +482,11 @@ fn emit_must_use_untranslated( UnusedClosure { count: plural_len, pre: descr_pre, post: descr_post }, ); } - MustUsePath::Generator(span) => { + MustUsePath::Coroutine(span) => { cx.emit_spanned_lint( UNUSED_MUST_USE, *span, - UnusedGenerator { count: plural_len, pre: descr_pre, post: descr_post }, + UnusedCoroutine { count: plural_len, pre: descr_pre, post: descr_post }, ); } MustUsePath::Def(span, def_id, reason) => { diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index 345b3d5e57f..de17462130d 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -856,7 +856,7 @@ fn should_encode_span(def_kind: DefKind) -> bool { | DefKind::Field | DefKind::Impl { .. } | DefKind::Closure - | DefKind::Generator => true, + | DefKind::Coroutine => true, DefKind::ForeignMod | DefKind::GlobalAsm => false, } } @@ -897,7 +897,7 @@ fn should_encode_attrs(def_kind: DefKind) -> bool { | DefKind::OpaqueTy | DefKind::LifetimeParam | DefKind::GlobalAsm - | DefKind::Generator => false, + | DefKind::Coroutine => false, } } @@ -933,7 +933,7 @@ fn should_encode_expn_that_defined(def_kind: DefKind) -> bool { | DefKind::LifetimeParam | DefKind::GlobalAsm | DefKind::Closure - | DefKind::Generator => false, + | DefKind::Coroutine => false, } } @@ -968,7 +968,7 @@ fn should_encode_visibility(def_kind: DefKind) -> bool { | DefKind::GlobalAsm | DefKind::Impl { .. } | DefKind::Closure - | DefKind::Generator + | DefKind::Coroutine | DefKind::ExternCrate => false, } } @@ -1004,7 +1004,7 @@ fn should_encode_stability(def_kind: DefKind) -> bool { | DefKind::InlineConst | DefKind::GlobalAsm | DefKind::Closure - | DefKind::Generator + | DefKind::Coroutine | DefKind::ExternCrate => false, } } @@ -1060,8 +1060,8 @@ fn should_encode_mir( || tcx.is_const_default_method(def_id.to_def_id()); (is_const_fn, opt) } - // Generators require optimized MIR to compute layout. - DefKind::Generator => (false, true), + // Coroutines require optimized MIR to compute layout. + DefKind::Coroutine => (false, true), // The others don't have MIR. _ => (false, false), } @@ -1097,7 +1097,7 @@ fn should_encode_variances<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, def_kind: Def | DefKind::InlineConst | DefKind::GlobalAsm | DefKind::Closure - | DefKind::Generator + | DefKind::Coroutine | DefKind::ExternCrate => false, DefKind::TyAlias => tcx.type_alias_is_lazy(def_id), } @@ -1127,7 +1127,7 @@ fn should_encode_generics(def_kind: DefKind) -> bool { | DefKind::Field | DefKind::TyParam | DefKind::Closure - | DefKind::Generator => true, + | DefKind::Coroutine => true, DefKind::Mod | DefKind::ForeignMod | DefKind::ConstParam @@ -1156,7 +1156,7 @@ fn should_encode_type(tcx: TyCtxt<'_>, def_id: LocalDefId, def_kind: DefKind) -> | DefKind::AssocFn | DefKind::AssocConst | DefKind::Closure - | DefKind::Generator + | DefKind::Coroutine | DefKind::ConstParam | DefKind::AnonConst | DefKind::InlineConst => true, @@ -1217,7 +1217,7 @@ fn should_encode_fn_sig(def_kind: DefKind) -> bool { | DefKind::Impl { .. } | DefKind::AssocConst | DefKind::Closure - | DefKind::Generator + | DefKind::Coroutine | DefKind::ConstParam | DefKind::AnonConst | DefKind::InlineConst @@ -1256,7 +1256,7 @@ fn should_encode_constness(def_kind: DefKind) -> bool { | DefKind::OpaqueTy | DefKind::Impl { of_trait: false } | DefKind::ForeignTy - | DefKind::Generator + | DefKind::Coroutine | DefKind::ConstParam | DefKind::InlineConst | DefKind::AssocTy @@ -1291,7 +1291,7 @@ fn should_encode_const(def_kind: DefKind) -> bool { | DefKind::Impl { .. } | DefKind::AssocFn | DefKind::Closure - | DefKind::Generator + | DefKind::Coroutine | DefKind::ConstParam | DefKind::AssocTy | DefKind::TyParam @@ -1446,7 +1446,7 @@ fn encode_def_ids(&mut self) { self.encode_info_for_assoc_item(def_id); } } - if let DefKind::Generator = def_kind { + if let DefKind::Coroutine = def_kind { let data = self.tcx.generator_kind(def_id).unwrap(); record!(self.tables.generator_kind[def_id] <- data); } @@ -1629,7 +1629,7 @@ fn encode_mir(&mut self) { record!(self.tables.closure_saved_names_of_captured_variables[def_id.to_def_id()] <- tcx.closure_saved_names_of_captured_variables(def_id)); - if let DefKind::Generator = self.tcx.def_kind(def_id) + if let DefKind::Coroutine = self.tcx.def_kind(def_id) && let Some(witnesses) = tcx.mir_generator_witnesses(def_id) { record!(self.tables.mir_generator_witnesses[def_id.to_def_id()] <- witnesses); @@ -1656,7 +1656,7 @@ fn encode_mir(&mut self) { } record!(self.tables.promoted_mir[def_id.to_def_id()] <- tcx.promoted_mir(def_id)); - if let DefKind::Generator = self.tcx.def_kind(def_id) + if let DefKind::Coroutine = self.tcx.def_kind(def_id) && let Some(witnesses) = tcx.mir_generator_witnesses(def_id) { record!(self.tables.mir_generator_witnesses[def_id.to_def_id()] <- witnesses); diff --git a/compiler/rustc_metadata/src/rmeta/mod.rs b/compiler/rustc_metadata/src/rmeta/mod.rs index 2609767a85c..1e0fcfa239d 100644 --- a/compiler/rustc_metadata/src/rmeta/mod.rs +++ b/compiler/rustc_metadata/src/rmeta/mod.rs @@ -429,7 +429,7 @@ fn encode(&self, buf: &mut FileEncoder) -> LazyTables { mir_for_ctfe: Table>>, cross_crate_inlinable: Table, closure_saved_names_of_captured_variables: Table>>, - mir_generator_witnesses: Table>>, + mir_generator_witnesses: Table>>, promoted_mir: Table>>>, thir_abstract_const: Table>>>, impl_parent: Table, @@ -442,7 +442,7 @@ fn encode(&self, buf: &mut FileEncoder) -> LazyTables { rendered_const: Table>, asyncness: Table, fn_arg_names: Table>, - generator_kind: Table>, + generator_kind: Table>, trait_def: Table>, trait_item_def_id: Table, expn_that_defined: Table>, diff --git a/compiler/rustc_metadata/src/rmeta/table.rs b/compiler/rustc_metadata/src/rmeta/table.rs index 34118e9e8a3..027994c40ab 100644 --- a/compiler/rustc_metadata/src/rmeta/table.rs +++ b/compiler/rustc_metadata/src/rmeta/table.rs @@ -167,7 +167,7 @@ impl FixedSizeEncoding for Option<$ty> { ( Impl { of_trait: false } ) ( Impl { of_trait: true } ) ( Closure ) - ( Generator ) + ( Coroutine ) ( Static(ast::Mutability::Not) ) ( Static(ast::Mutability::Mut) ) ( Ctor(CtorOf::Struct, CtorKind::Fn) ) diff --git a/compiler/rustc_middle/src/hir/map/mod.rs b/compiler/rustc_middle/src/hir/map/mod.rs index 77643715fff..3ca26ec98c6 100644 --- a/compiler/rustc_middle/src/hir/map/mod.rs +++ b/compiler/rustc_middle/src/hir/map/mod.rs @@ -240,7 +240,7 @@ pub(super) fn opt_def_kind(self, local_def_id: LocalDefId) -> Option { Node::Field(_) => DefKind::Field, Node::Expr(expr) => match expr.kind { ExprKind::Closure(Closure { movability: None, .. }) => DefKind::Closure, - ExprKind::Closure(Closure { movability: Some(_), .. }) => DefKind::Generator, + ExprKind::Closure(Closure { movability: Some(_), .. }) => DefKind::Coroutine, _ => bug!("def_kind: unsupported node: {}", self.node_to_string(hir_id)), }, Node::GenericParam(param) => match param.kind { @@ -445,7 +445,7 @@ pub fn body_owner_kind(self, def_id: LocalDefId) -> BodyOwnerKind { } DefKind::InlineConst => BodyOwnerKind::Const { inline: true }, DefKind::Ctor(..) | DefKind::Fn | DefKind::AssocFn => BodyOwnerKind::Fn, - DefKind::Closure | DefKind::Generator => BodyOwnerKind::Closure, + DefKind::Closure | DefKind::Coroutine => BodyOwnerKind::Closure, DefKind::Static(mt) => BodyOwnerKind::Static(mt), dk => bug!("{:?} is not a body node: {:?}", def_id, dk), } diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs index 3a5ff4dc91f..01846ccf883 100644 --- a/compiler/rustc_middle/src/mir/mod.rs +++ b/compiler/rustc_middle/src/mir/mod.rs @@ -17,7 +17,7 @@ use rustc_errors::{DiagnosticArgValue, DiagnosticMessage, ErrorGuaranteed, IntoDiagnosticArg}; use rustc_hir::def::{CtorKind, Namespace}; use rustc_hir::def_id::{DefId, CRATE_DEF_ID}; -use rustc_hir::{self, GeneratorKind, ImplicitSelfKind}; +use rustc_hir::{self, CoroutineKind, ImplicitSelfKind}; use rustc_hir::{self as hir, HirId}; use rustc_session::Session; use rustc_target::abi::{FieldIdx, VariantIdx}; @@ -246,19 +246,19 @@ pub fn def_id(&self) -> DefId { } #[derive(Clone, TyEncodable, TyDecodable, Debug, HashStable, TypeFoldable, TypeVisitable)] -pub struct GeneratorInfo<'tcx> { +pub struct CoroutineInfo<'tcx> { /// The yield type of the function, if it is a generator. pub yield_ty: Option>, - /// Generator drop glue. + /// Coroutine drop glue. pub generator_drop: Option>, /// The layout of a generator. Produced by the state transformation. - pub generator_layout: Option>, + pub generator_layout: Option>, /// If this is a generator then record the type of source expression that caused this generator /// to be created. - pub generator_kind: GeneratorKind, + pub generator_kind: CoroutineKind, } /// The lowered representation of a single function. @@ -284,7 +284,7 @@ pub struct Body<'tcx> { /// and used for debuginfo. Indexed by a `SourceScope`. pub source_scopes: IndexVec>, - pub generator: Option>>, + pub generator: Option>>, /// Declarations of locals. /// @@ -365,7 +365,7 @@ pub fn new( arg_count: usize, var_debug_info: Vec>, span: Span, - generator_kind: Option, + generator_kind: Option, tainted_by_errors: Option, ) -> Self { // We need `arg_count` locals, and one for the return place. @@ -383,7 +383,7 @@ pub fn new( basic_blocks: BasicBlocks::new(basic_blocks), source_scopes, generator: generator_kind.map(|generator_kind| { - Box::new(GeneratorInfo { + Box::new(CoroutineInfo { yield_ty: None, generator_drop: None, generator_layout: None, @@ -552,7 +552,7 @@ pub fn yield_ty(&self) -> Option> { } #[inline] - pub fn generator_layout(&self) -> Option<&GeneratorLayout<'tcx>> { + pub fn generator_layout(&self) -> Option<&CoroutineLayout<'tcx>> { self.generator.as_ref().and_then(|generator| generator.generator_layout.as_ref()) } @@ -562,7 +562,7 @@ pub fn generator_drop(&self) -> Option<&Body<'tcx>> { } #[inline] - pub fn generator_kind(&self) -> Option { + pub fn generator_kind(&self) -> Option { self.generator.as_ref().map(|generator| generator.generator_kind) } diff --git a/compiler/rustc_middle/src/mir/pretty.rs b/compiler/rustc_middle/src/mir/pretty.rs index 3b3b61e4e21..9ec0401b4fb 100644 --- a/compiler/rustc_middle/src/mir/pretty.rs +++ b/compiler/rustc_middle/src/mir/pretty.rs @@ -782,7 +782,7 @@ pub fn fmt_head(&self, fmt: &mut W) -> fmt::Result { Goto { .. } => write!(fmt, "goto"), SwitchInt { discr, .. } => write!(fmt, "switchInt({discr:?})"), Return => write!(fmt, "return"), - GeneratorDrop => write!(fmt, "generator_drop"), + CoroutineDrop => write!(fmt, "generator_drop"), UnwindResume => write!(fmt, "resume"), UnwindTerminate(reason) => { write!(fmt, "abort({})", reason.as_short_str()) @@ -865,7 +865,7 @@ pub fn fmt_head(&self, fmt: &mut W) -> fmt::Result { pub fn fmt_successor_labels(&self) -> Vec> { use self::TerminatorKind::*; match *self { - Return | UnwindResume | UnwindTerminate(_) | Unreachable | GeneratorDrop => vec![], + Return | UnwindResume | UnwindTerminate(_) | Unreachable | CoroutineDrop => vec![], Goto { .. } => vec!["".into()], SwitchInt { ref targets, .. } => targets .values @@ -1046,7 +1046,7 @@ fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result { struct_fmt.finish() }), - AggregateKind::Generator(def_id, _, _) => ty::tls::with(|tcx| { + AggregateKind::Coroutine(def_id, _, _) => ty::tls::with(|tcx| { let name = format!("{{generator@{:?}}}", tcx.def_span(def_id)); let mut struct_fmt = fmt.debug_struct(&name); @@ -1301,7 +1301,7 @@ fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, location: Location) { self.push(&format!("+ args: {args:#?}")); } - AggregateKind::Generator(def_id, args, movability) => { + AggregateKind::Coroutine(def_id, args, movability) => { self.push("generator"); self.push(&format!("+ def_id: {def_id:?}")); self.push(&format!("+ args: {args:#?}")); diff --git a/compiler/rustc_middle/src/mir/query.rs b/compiler/rustc_middle/src/mir/query.rs index f407dc4d7ae..97588ae77c2 100644 --- a/compiler/rustc_middle/src/mir/query.rs +++ b/compiler/rustc_middle/src/mir/query.rs @@ -133,11 +133,11 @@ pub struct UnsafetyCheckResult { rustc_index::newtype_index! { #[derive(HashStable)] #[debug_format = "_{}"] - pub struct GeneratorSavedLocal {} + pub struct CoroutineSavedLocal {} } #[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable, TypeFoldable, TypeVisitable)] -pub struct GeneratorSavedTy<'tcx> { +pub struct CoroutineSavedTy<'tcx> { pub ty: Ty<'tcx>, /// Source info corresponding to the local in the original MIR body. pub source_info: SourceInfo, @@ -147,16 +147,16 @@ pub struct GeneratorSavedTy<'tcx> { /// The layout of generator state. #[derive(Clone, TyEncodable, TyDecodable, HashStable, TypeFoldable, TypeVisitable)] -pub struct GeneratorLayout<'tcx> { +pub struct CoroutineLayout<'tcx> { /// The type of every local stored inside the generator. - pub field_tys: IndexVec>, + pub field_tys: IndexVec>, /// The name for debuginfo. - pub field_names: IndexVec>, + pub field_names: IndexVec>, /// Which of the above fields are in each variant. Note that one field may /// be stored in multiple variants. - pub variant_fields: IndexVec>, + pub variant_fields: IndexVec>, /// The source that led to each variant being created (usually, a yield or /// await). @@ -167,10 +167,10 @@ pub struct GeneratorLayout<'tcx> { /// layout. #[type_foldable(identity)] #[type_visitable(ignore)] - pub storage_conflicts: BitMatrix, + pub storage_conflicts: BitMatrix, } -impl Debug for GeneratorLayout<'_> { +impl Debug for CoroutineLayout<'_> { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { /// Prints an iterator of (key, value) tuples as a map. struct MapPrinter<'a, K, V>(Cell + 'a>>>); @@ -194,7 +194,7 @@ fn from(idx: VariantIdx) -> Self { } impl Debug for GenVariantPrinter { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { - let variant_name = ty::GeneratorArgs::variant_name(self.0); + let variant_name = ty::CoroutineArgs::variant_name(self.0); if fmt.alternate() { write!(fmt, "{:9}({:?})", variant_name, self.0) } else { @@ -211,7 +211,7 @@ fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { } } - fmt.debug_struct("GeneratorLayout") + fmt.debug_struct("CoroutineLayout") .field("field_tys", &MapPrinter::new(self.field_tys.iter_enumerated())) .field( "variant_fields", diff --git a/compiler/rustc_middle/src/mir/syntax.rs b/compiler/rustc_middle/src/mir/syntax.rs index 7a645fb5d62..23e323a4820 100644 --- a/compiler/rustc_middle/src/mir/syntax.rs +++ b/compiler/rustc_middle/src/mir/syntax.rs @@ -15,7 +15,7 @@ use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece}; use rustc_hir::def_id::DefId; use rustc_hir::{self as hir}; -use rustc_hir::{self, GeneratorKind}; +use rustc_hir::{self, CoroutineKind}; use rustc_index::IndexVec; use rustc_target::abi::{FieldIdx, VariantIdx}; @@ -82,7 +82,7 @@ pub enum MirPhase { /// that Rust itself has them. Where exactly these are is generally subject to change, and so we /// don't document this here. Runtime MIR has most retags explicit (though implicit retags /// can still occur at `Rvalue::{Ref,AddrOf}`). - /// - Generator bodies: In analysis MIR, locals may actually be behind a pointer that user code has + /// - Coroutine bodies: In analysis MIR, locals may actually be behind a pointer that user code has /// access to. This occurs in generator bodies. Such locals do not behave like other locals, /// because they eg may be aliased in surprising ways. Runtime MIR has no such special locals - /// all generator bodies are lowered and so all places that look like locals really are locals. @@ -137,7 +137,7 @@ pub enum RuntimePhase { /// In addition to the semantic changes, beginning with this phase, the following variants are /// disallowed: /// * [`TerminatorKind::Yield`] - /// * [`TerminatorKind::GeneratorDrop`] + /// * [`TerminatorKind::CoroutineDrop`] /// * [`Rvalue::Aggregate`] for any `AggregateKind` except `Array` /// * [`PlaceElem::OpaqueCast`] /// @@ -627,7 +627,7 @@ pub enum TerminatorKind<'tcx> { /// aliasing model. /// /// If the body is a generator body, this has slightly different semantics; it instead causes a - /// `GeneratorState::Returned(_0)` to be created (as if by an `Aggregate` rvalue) and assigned + /// `CoroutineState::Returned(_0)` to be created (as if by an `Aggregate` rvalue) and assigned /// to the return place. Return, @@ -710,7 +710,7 @@ pub enum TerminatorKind<'tcx> { /// Marks a suspend point. /// /// Like `Return` terminators in generator bodies, this computes `value` and then a - /// `GeneratorState::Yielded(value)` as if by `Aggregate` rvalue. That value is then assigned to + /// `CoroutineState::Yielded(value)` as if by `Aggregate` rvalue. That value is then assigned to /// the return place of the function calling this one, and execution continues in the calling /// function. When next invoked with the same first argument, execution of this function /// continues at the `resume` basic block, with the second argument written to the `resume_arg` @@ -740,7 +740,7 @@ pub enum TerminatorKind<'tcx> { /// /// **Needs clarification**: Are there type system constraints on these terminators? Should /// there be a "block type" like `cleanup` blocks for them? - GeneratorDrop, + CoroutineDrop, /// A block where control flow only ever takes one real path, but borrowck needs to be more /// conservative. @@ -815,7 +815,7 @@ pub const fn name(&self) -> &'static str { TerminatorKind::Call { .. } => "Call", TerminatorKind::Assert { .. } => "Assert", TerminatorKind::Yield { .. } => "Yield", - TerminatorKind::GeneratorDrop => "GeneratorDrop", + TerminatorKind::CoroutineDrop => "CoroutineDrop", TerminatorKind::FalseEdge { .. } => "FalseEdge", TerminatorKind::FalseUnwind { .. } => "FalseUnwind", TerminatorKind::InlineAsm { .. } => "InlineAsm", @@ -883,8 +883,8 @@ pub enum AssertKind { OverflowNeg(O), DivisionByZero(O), RemainderByZero(O), - ResumedAfterReturn(GeneratorKind), - ResumedAfterPanic(GeneratorKind), + ResumedAfterReturn(CoroutineKind), + ResumedAfterPanic(CoroutineKind), MisalignedPointerDereference { required: O, found: O }, } @@ -1278,8 +1278,8 @@ pub enum Rvalue<'tcx> { /// `dest = Foo { x: ..., y: ... }` from `dest.x = ...; dest.y = ...;` in the case that `Foo` /// has a destructor. /// - /// Disallowed after deaggregation for all aggregate kinds except `Array` and `Generator`. After - /// generator lowering, `Generator` aggregate kinds are disallowed too. + /// Disallowed after deaggregation for all aggregate kinds except `Array` and `Coroutine`. After + /// generator lowering, `Coroutine` aggregate kinds are disallowed too. Aggregate(Box>, IndexVec>), /// Transmutes a `*mut u8` into shallow-initialized `Box`. @@ -1344,7 +1344,7 @@ pub enum AggregateKind<'tcx> { Adt(DefId, VariantIdx, GenericArgsRef<'tcx>, Option, Option), Closure(DefId, GenericArgsRef<'tcx>), - Generator(DefId, GenericArgsRef<'tcx>, hir::Movability), + Coroutine(DefId, GenericArgsRef<'tcx>, hir::Movability), } #[derive(Copy, Clone, Debug, PartialEq, Eq, TyEncodable, TyDecodable, Hash, HashStable)] diff --git a/compiler/rustc_middle/src/mir/tcx.rs b/compiler/rustc_middle/src/mir/tcx.rs index 44ae75e2de7..27f0715dffb 100644 --- a/compiler/rustc_middle/src/mir/tcx.rs +++ b/compiler/rustc_middle/src/mir/tcx.rs @@ -205,7 +205,7 @@ pub fn ty(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> Ty<'tcx> } AggregateKind::Adt(did, _, args, _, _) => tcx.type_of(did).instantiate(tcx, args), AggregateKind::Closure(did, args) => Ty::new_closure(tcx, did, args), - AggregateKind::Generator(did, args, movability) => { + AggregateKind::Coroutine(did, args, movability) => { Ty::new_generator(tcx, did, args, movability) } }, diff --git a/compiler/rustc_middle/src/mir/terminator.rs b/compiler/rustc_middle/src/mir/terminator.rs index 02aab4a892d..86515b14fed 100644 --- a/compiler/rustc_middle/src/mir/terminator.rs +++ b/compiler/rustc_middle/src/mir/terminator.rs @@ -139,10 +139,10 @@ pub fn description(&self) -> &'static str { Overflow(op, _, _) => bug!("{:?} cannot overflow", op), DivisionByZero(_) => "attempt to divide by zero", RemainderByZero(_) => "attempt to calculate the remainder with a divisor of zero", - ResumedAfterReturn(GeneratorKind::Gen) => "generator resumed after completion", - ResumedAfterReturn(GeneratorKind::Async(_)) => "`async fn` resumed after completion", - ResumedAfterPanic(GeneratorKind::Gen) => "generator resumed after panicking", - ResumedAfterPanic(GeneratorKind::Async(_)) => "`async fn` resumed after panicking", + ResumedAfterReturn(CoroutineKind::Gen) => "generator resumed after completion", + ResumedAfterReturn(CoroutineKind::Async(_)) => "`async fn` resumed after completion", + ResumedAfterPanic(CoroutineKind::Gen) => "generator resumed after panicking", + ResumedAfterPanic(CoroutineKind::Async(_)) => "`async fn` resumed after panicking", BoundsCheck { .. } | MisalignedPointerDereference { .. } => { bug!("Unexpected AssertKind") } @@ -228,10 +228,10 @@ pub fn diagnostic_message(&self) -> DiagnosticMessage { OverflowNeg(_) => middle_assert_overflow_neg, DivisionByZero(_) => middle_assert_divide_by_zero, RemainderByZero(_) => middle_assert_remainder_by_zero, - ResumedAfterReturn(GeneratorKind::Async(_)) => middle_assert_async_resume_after_return, - ResumedAfterReturn(GeneratorKind::Gen) => middle_assert_generator_resume_after_return, - ResumedAfterPanic(GeneratorKind::Async(_)) => middle_assert_async_resume_after_panic, - ResumedAfterPanic(GeneratorKind::Gen) => middle_assert_generator_resume_after_panic, + ResumedAfterReturn(CoroutineKind::Async(_)) => middle_assert_async_resume_after_return, + ResumedAfterReturn(CoroutineKind::Gen) => middle_assert_generator_resume_after_return, + ResumedAfterPanic(CoroutineKind::Async(_)) => middle_assert_async_resume_after_panic, + ResumedAfterPanic(CoroutineKind::Gen) => middle_assert_generator_resume_after_panic, MisalignedPointerDereference { .. } => middle_assert_misaligned_ptr_deref, } @@ -331,7 +331,7 @@ pub fn successors(&self) -> Successors<'_> { } UnwindResume | UnwindTerminate(_) - | GeneratorDrop + | CoroutineDrop | Return | Unreachable | Call { target: None, unwind: _, .. } @@ -373,7 +373,7 @@ pub fn successors_mut(&mut self) -> SuccessorsMut<'_> { } UnwindResume | UnwindTerminate(_) - | GeneratorDrop + | CoroutineDrop | Return | Unreachable | Call { target: None, unwind: _, .. } @@ -392,7 +392,7 @@ pub fn unwind(&self) -> Option<&UnwindAction> { | TerminatorKind::UnwindTerminate(_) | TerminatorKind::Return | TerminatorKind::Unreachable - | TerminatorKind::GeneratorDrop + | TerminatorKind::CoroutineDrop | TerminatorKind::Yield { .. } | TerminatorKind::SwitchInt { .. } | TerminatorKind::FalseEdge { .. } => None, @@ -411,7 +411,7 @@ pub fn unwind_mut(&mut self) -> Option<&mut UnwindAction> { | TerminatorKind::UnwindTerminate(_) | TerminatorKind::Return | TerminatorKind::Unreachable - | TerminatorKind::GeneratorDrop + | TerminatorKind::CoroutineDrop | TerminatorKind::Yield { .. } | TerminatorKind::SwitchInt { .. } | TerminatorKind::FalseEdge { .. } => None, @@ -493,7 +493,7 @@ impl<'tcx> TerminatorKind<'tcx> { pub fn edges(&self) -> TerminatorEdges<'_, 'tcx> { use TerminatorKind::*; match *self { - Return | UnwindResume | UnwindTerminate(_) | GeneratorDrop | Unreachable => { + Return | UnwindResume | UnwindTerminate(_) | CoroutineDrop | Unreachable => { TerminatorEdges::None } diff --git a/compiler/rustc_middle/src/mir/type_foldable.rs b/compiler/rustc_middle/src/mir/type_foldable.rs index 8d427fdb6f5..d5c81b6cd79 100644 --- a/compiler/rustc_middle/src/mir/type_foldable.rs +++ b/compiler/rustc_middle/src/mir/type_foldable.rs @@ -19,8 +19,8 @@ hir::Movability, BasicBlock, SwitchTargets, - GeneratorKind, - GeneratorSavedLocal, + CoroutineKind, + CoroutineSavedLocal, } TrivialTypeTraversalImpls! { diff --git a/compiler/rustc_middle/src/mir/visit.rs b/compiler/rustc_middle/src/mir/visit.rs index 95c1848bc9b..805d368397b 100644 --- a/compiler/rustc_middle/src/mir/visit.rs +++ b/compiler/rustc_middle/src/mir/visit.rs @@ -473,7 +473,7 @@ fn super_terminator(&mut self, TerminatorKind::Goto { .. } | TerminatorKind::UnwindResume | TerminatorKind::UnwindTerminate(_) | - TerminatorKind::GeneratorDrop | + TerminatorKind::CoroutineDrop | TerminatorKind::Unreachable | TerminatorKind::FalseEdge { .. } | TerminatorKind::FalseUnwind { .. } => {} @@ -735,7 +735,7 @@ fn super_rvalue(&mut self, ) => { self.visit_args(closure_args, location); } - AggregateKind::Generator( + AggregateKind::Coroutine( _, generator_args, _movability, diff --git a/compiler/rustc_middle/src/query/erase.rs b/compiler/rustc_middle/src/query/erase.rs index 8ba3764bcc3..e20e9d9312c 100644 --- a/compiler/rustc_middle/src/query/erase.rs +++ b/compiler/rustc_middle/src/query/erase.rs @@ -210,7 +210,7 @@ impl EraseType for $ty { Option, Option, Option, - Option, + Option, Option, Option, Option, @@ -239,7 +239,7 @@ impl EraseType for $ty { rustc_hir::def::DefKind, rustc_hir::Defaultness, rustc_hir::definitions::DefKey, - rustc_hir::GeneratorKind, + rustc_hir::CoroutineKind, rustc_hir::HirId, rustc_hir::IsAsync, rustc_hir::ItemLocalId, diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs index afe94d10752..3c1e67d1846 100644 --- a/compiler/rustc_middle/src/query/mod.rs +++ b/compiler/rustc_middle/src/query/mod.rs @@ -554,7 +554,7 @@ separate_provide_extern } - query mir_generator_witnesses(key: DefId) -> &'tcx Option> { + query mir_generator_witnesses(key: DefId) -> &'tcx Option> { arena_cache desc { |tcx| "generator witness types for `{}`", tcx.def_path_str(key) } cache_on_disk_if { key.is_local() } @@ -744,7 +744,7 @@ } /// Returns `Some(generator_kind)` if the node pointed to by `def_id` is a generator. - query generator_kind(def_id: DefId) -> Option { + query generator_kind(def_id: DefId) -> Option { desc { |tcx| "looking up generator kind of `{}`", tcx.def_path_str(def_id) } separate_provide_extern } diff --git a/compiler/rustc_middle/src/traits/mod.rs b/compiler/rustc_middle/src/traits/mod.rs index 99b750c9afc..43803dc406b 100644 --- a/compiler/rustc_middle/src/traits/mod.rs +++ b/compiler/rustc_middle/src/traits/mod.rs @@ -302,7 +302,7 @@ pub enum ObligationCauseCode<'tcx> { /// Captured closure type must be `Sized`. SizedClosureCapture(LocalDefId), /// Types live across generator yields must be `Sized`. - SizedGeneratorInterior(LocalDefId), + SizedCoroutineInterior(LocalDefId), /// `[expr; N]` requires `type_of(expr): Copy`. RepeatElementCopy { /// If element is a `const fn` we display a help message suggesting to move the diff --git a/compiler/rustc_middle/src/traits/select.rs b/compiler/rustc_middle/src/traits/select.rs index 90bc5dd8f69..d3995c91714 100644 --- a/compiler/rustc_middle/src/traits/select.rs +++ b/compiler/rustc_middle/src/traits/select.rs @@ -136,9 +136,9 @@ pub enum SelectionCandidate<'tcx> { is_const: bool, }, - /// Implementation of a `Generator` trait by one of the anonymous types + /// Implementation of a `Coroutine` trait by one of the anonymous types /// generated for a generator. - GeneratorCandidate, + CoroutineCandidate, /// Implementation of a `Future` trait by one of the generator types /// generated for an async construct. diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 600fd626fb1..69cfb99186b 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -763,7 +763,7 @@ pub fn is_diagnostic_item(self, name: Symbol, did: DefId) -> bool { /// Returns `true` if the node pointed to by `def_id` is a generator for an async construct. pub fn generator_is_async(self, def_id: DefId) -> bool { - matches!(self.generator_kind(def_id), Some(hir::GeneratorKind::Async(_))) + matches!(self.generator_kind(def_id), Some(hir::CoroutineKind::Async(_))) } pub fn stability(self) -> &'tcx stability::Index { @@ -1382,8 +1382,8 @@ fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { FnDef, FnPtr, Placeholder, - Generator, - GeneratorWitness, + Coroutine, + CoroutineWitness, Dynamic, Closure, Tuple, diff --git a/compiler/rustc_middle/src/ty/diagnostics.rs b/compiler/rustc_middle/src/ty/diagnostics.rs index 8500c43a17f..7a782b2c249 100644 --- a/compiler/rustc_middle/src/ty/diagnostics.rs +++ b/compiler/rustc_middle/src/ty/diagnostics.rs @@ -482,8 +482,8 @@ fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow { FnDef(..) | Closure(..) | Infer(..) - | Generator(..) - | GeneratorWitness(..) + | Coroutine(..) + | CoroutineWitness(..) | Bound(_, _) | Placeholder(_) | Error(_) => { @@ -567,8 +567,8 @@ fn try_fold_ty(&mut self, t: Ty<'tcx>) -> Result, Self::Error> { // FIXME(compiler-errors): We could replace these with infer, I guess. Closure(..) | Infer(..) - | Generator(..) - | GeneratorWitness(..) + | Coroutine(..) + | CoroutineWitness(..) | Bound(_, _) | Placeholder(_) | Error(_) => { diff --git a/compiler/rustc_middle/src/ty/error.rs b/compiler/rustc_middle/src/ty/error.rs index 0fe1284eed9..8a21d1d2e31 100644 --- a/compiler/rustc_middle/src/ty/error.rs +++ b/compiler/rustc_middle/src/ty/error.rs @@ -241,8 +241,8 @@ pub fn sort_string(self, tcx: TyCtxt<'tcx>) -> Cow<'static, str> { } ty::Dynamic(..) => "trait object".into(), ty::Closure(..) => "closure".into(), - ty::Generator(def_id, ..) => tcx.generator_kind(def_id).unwrap().descr().into(), - ty::GeneratorWitness(..) => "generator witness".into(), + ty::Coroutine(def_id, ..) => tcx.generator_kind(def_id).unwrap().descr().into(), + ty::CoroutineWitness(..) => "generator witness".into(), ty::Infer(ty::TyVar(_)) => "inferred type".into(), ty::Infer(ty::IntVar(_)) => "integer".into(), ty::Infer(ty::FloatVar(_)) => "floating-point number".into(), @@ -299,8 +299,8 @@ pub fn prefix_string(self, tcx: TyCtxt<'_>) -> Cow<'static, str> { ty::FnPtr(_) => "fn pointer".into(), ty::Dynamic(..) => "trait object".into(), ty::Closure(..) => "closure".into(), - ty::Generator(def_id, ..) => tcx.generator_kind(def_id).unwrap().descr().into(), - ty::GeneratorWitness(..) => "generator witness".into(), + ty::Coroutine(def_id, ..) => tcx.generator_kind(def_id).unwrap().descr().into(), + ty::CoroutineWitness(..) => "generator witness".into(), ty::Tuple(..) => "tuple".into(), ty::Placeholder(..) => "higher-ranked type".into(), ty::Bound(..) => "bound type variable".into(), diff --git a/compiler/rustc_middle/src/ty/fast_reject.rs b/compiler/rustc_middle/src/ty/fast_reject.rs index 16935d5b380..75ea53195a3 100644 --- a/compiler/rustc_middle/src/ty/fast_reject.rs +++ b/compiler/rustc_middle/src/ty/fast_reject.rs @@ -28,8 +28,8 @@ pub enum SimplifiedType { MarkerTraitObject, Trait(DefId), Closure(DefId), - Generator(DefId), - GeneratorWitness(DefId), + Coroutine(DefId), + CoroutineWitness(DefId), Function(usize), Placeholder, } @@ -128,8 +128,8 @@ pub fn simplify_type<'tcx>( }, ty::Ref(_, _, mutbl) => Some(SimplifiedType::Ref(mutbl)), ty::FnDef(def_id, _) | ty::Closure(def_id, _) => Some(SimplifiedType::Closure(def_id)), - ty::Generator(def_id, _, _) => Some(SimplifiedType::Generator(def_id)), - ty::GeneratorWitness(def_id, _) => Some(SimplifiedType::GeneratorWitness(def_id)), + ty::Coroutine(def_id, _, _) => Some(SimplifiedType::Coroutine(def_id)), + ty::CoroutineWitness(def_id, _) => Some(SimplifiedType::CoroutineWitness(def_id)), ty::Never => Some(SimplifiedType::Never), ty::Tuple(tys) => Some(SimplifiedType::Tuple(tys.len())), ty::FnPtr(f) => Some(SimplifiedType::Function(f.skip_binder().inputs().len())), @@ -164,8 +164,8 @@ pub fn def(self) -> Option { | SimplifiedType::Foreign(d) | SimplifiedType::Trait(d) | SimplifiedType::Closure(d) - | SimplifiedType::Generator(d) - | SimplifiedType::GeneratorWitness(d) => Some(d), + | SimplifiedType::Coroutine(d) + | SimplifiedType::CoroutineWitness(d) => Some(d), _ => None, } } @@ -234,8 +234,8 @@ pub fn types_may_unify<'tcx>(self, obligation_ty: Ty<'tcx>, impl_ty: Ty<'tcx>) - | ty::Foreign(..) => {} ty::FnDef(..) | ty::Closure(..) - | ty::Generator(..) - | ty::GeneratorWitness(..) + | ty::Coroutine(..) + | ty::CoroutineWitness(..) | ty::Placeholder(..) | ty::Bound(..) | ty::Infer(_) => bug!("unexpected impl_ty: {impl_ty}"), @@ -310,7 +310,7 @@ pub fn types_may_unify<'tcx>(self, obligation_ty: Ty<'tcx>, impl_ty: Ty<'tcx>) - }, // Impls cannot contain these types as these cannot be named directly. - ty::FnDef(..) | ty::Closure(..) | ty::Generator(..) => false, + ty::FnDef(..) | ty::Closure(..) | ty::Coroutine(..) => false, // Placeholder types don't unify with anything on their own ty::Placeholder(..) | ty::Bound(..) => false, @@ -337,7 +337,7 @@ pub fn types_may_unify<'tcx>(self, obligation_ty: Ty<'tcx>, impl_ty: Ty<'tcx>) - ty::Error(_) => true, - ty::GeneratorWitness(..) => { + ty::CoroutineWitness(..) => { bug!("unexpected obligation type: {:?}", obligation_ty) } } diff --git a/compiler/rustc_middle/src/ty/flags.rs b/compiler/rustc_middle/src/ty/flags.rs index 7ed31fbbfd8..93a4ff0a279 100644 --- a/compiler/rustc_middle/src/ty/flags.rs +++ b/compiler/rustc_middle/src/ty/flags.rs @@ -111,7 +111,7 @@ fn add_kind(&mut self, kind: &ty::TyKind<'_>) { self.add_flags(TypeFlags::STILL_FURTHER_SPECIALIZABLE); } - ty::Generator(_, args, _) => { + ty::Coroutine(_, args, _) => { let args = args.as_generator(); let should_remove_further_specializable = !self.flags.contains(TypeFlags::STILL_FURTHER_SPECIALIZABLE); @@ -127,7 +127,7 @@ fn add_kind(&mut self, kind: &ty::TyKind<'_>) { self.add_ty(args.tupled_upvars_ty()); } - ty::GeneratorWitness(_, args) => { + ty::CoroutineWitness(_, args) => { let should_remove_further_specializable = !self.flags.contains(TypeFlags::STILL_FURTHER_SPECIALIZABLE); self.add_args(args); diff --git a/compiler/rustc_middle/src/ty/generic_args.rs b/compiler/rustc_middle/src/ty/generic_args.rs index a861af47859..35478f2008c 100644 --- a/compiler/rustc_middle/src/ty/generic_args.rs +++ b/compiler/rustc_middle/src/ty/generic_args.rs @@ -2,7 +2,7 @@ use crate::ty::codec::{TyDecoder, TyEncoder}; use crate::ty::fold::{FallibleTypeFolder, TypeFoldable, TypeFolder, TypeSuperFoldable}; -use crate::ty::sty::{ClosureArgs, GeneratorArgs, InlineConstArgs}; +use crate::ty::sty::{ClosureArgs, CoroutineArgs, InlineConstArgs}; use crate::ty::visit::{TypeVisitable, TypeVisitableExt, TypeVisitor}; use crate::ty::{self, Lift, List, ParamConst, Ty, TyCtxt}; @@ -267,11 +267,11 @@ pub fn as_closure(&'tcx self) -> ClosureArgs<'tcx> { } /// Interpret these generic args as the args of a generator type. - /// Generator args have a particular structure controlled by the + /// Coroutine args have a particular structure controlled by the /// compiler that encodes information like the signature and generator kind; - /// see `ty::GeneratorArgs` struct for more comments. - pub fn as_generator(&'tcx self) -> GeneratorArgs<'tcx> { - GeneratorArgs { args: self } + /// see `ty::CoroutineArgs` struct for more comments. + pub fn as_generator(&'tcx self) -> CoroutineArgs<'tcx> { + CoroutineArgs { args: self } } /// Interpret these generic args as the args of an inline const. diff --git a/compiler/rustc_middle/src/ty/instance.rs b/compiler/rustc_middle/src/ty/instance.rs index 0b308d5dec1..d4a0cc40ac6 100644 --- a/compiler/rustc_middle/src/ty/instance.rs +++ b/compiler/rustc_middle/src/ty/instance.rs @@ -689,7 +689,7 @@ fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> { Ty::new_closure(self.tcx, def_id, polymorphized_args) } } - ty::Generator(def_id, args, movability) => { + ty::Coroutine(def_id, args, movability) => { let polymorphized_args = polymorphize(self.tcx, ty::InstanceDef::Item(def_id), args); if args == polymorphized_args { diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index 5ef7ee52636..077c32b4274 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -809,7 +809,7 @@ fn field_ty_or_layout<'tcx>( | ty::FnPtr(_) | ty::Never | ty::FnDef(..) - | ty::GeneratorWitness(..) + | ty::CoroutineWitness(..) | ty::Foreign(..) | ty::Dynamic(_, _, ty::Dyn) => { bug!("TyAndLayout::field({:?}): not applicable", this) @@ -905,7 +905,7 @@ fn field_ty_or_layout<'tcx>( i, ), - ty::Generator(def_id, ref args, _) => match this.variants { + ty::Coroutine(def_id, ref args, _) => match this.variants { Variants::Single { index } => TyMaybeWithLayout::Ty( args.as_generator() .state_tys(def_id, tcx) diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index e6cd3dd4d82..be0e41d89d3 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -20,7 +20,7 @@ use crate::error::{OpaqueHiddenTypeMismatch, TypeMismatchReason}; use crate::metadata::ModChild; use crate::middle::privacy::EffectiveVisibilities; -use crate::mir::{Body, GeneratorLayout}; +use crate::mir::{Body, CoroutineLayout}; use crate::query::Providers; use crate::traits::{self, Reveal}; use crate::ty; @@ -98,8 +98,8 @@ pub use self::sty::{ AliasTy, Article, Binder, BoundRegion, BoundRegionKind, BoundTy, BoundTyKind, BoundVar, BoundVariableKind, CanonicalPolyFnSig, ClosureArgs, ClosureArgsParts, ConstKind, ConstVid, - EarlyBoundRegion, EffectVid, ExistentialPredicate, ExistentialProjection, ExistentialTraitRef, - FnSig, FreeRegion, GenSig, GeneratorArgs, GeneratorArgsParts, InlineConstArgs, + CoroutineArgs, CoroutineArgsParts, EarlyBoundRegion, EffectVid, ExistentialPredicate, + ExistentialProjection, ExistentialTraitRef, FnSig, FreeRegion, GenSig, InlineConstArgs, InlineConstArgsParts, ParamConst, ParamTy, PolyExistentialPredicate, PolyExistentialProjection, PolyExistentialTraitRef, PolyFnSig, PolyGenSig, PolyTraitRef, Region, RegionKind, RegionVid, TraitRef, TyKind, TypeAndMut, UpvarArgs, VarianceDiagInfo, @@ -2423,7 +2423,7 @@ pub fn trait_is_alias(self, trait_def_id: DefId) -> bool { /// Returns layout of a generator. Layout might be unavailable if the /// generator is tainted by errors. - pub fn generator_layout(self, def_id: DefId) -> Option<&'tcx GeneratorLayout<'tcx>> { + pub fn generator_layout(self, def_id: DefId) -> Option<&'tcx CoroutineLayout<'tcx>> { self.optimized_mir(def_id).generator_layout() } diff --git a/compiler/rustc_middle/src/ty/opaque_types.rs b/compiler/rustc_middle/src/ty/opaque_types.rs index 6491936c219..2f62bd3ca7a 100644 --- a/compiler/rustc_middle/src/ty/opaque_types.rs +++ b/compiler/rustc_middle/src/ty/opaque_types.rs @@ -152,12 +152,12 @@ fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> { Ty::new_closure(self.tcx, def_id, args) } - ty::Generator(def_id, args, movability) => { + ty::Coroutine(def_id, args, movability) => { let args = self.fold_closure_args(def_id, args); Ty::new_generator(self.tcx, def_id, args, movability) } - ty::GeneratorWitness(def_id, args) => { + ty::CoroutineWitness(def_id, args) => { let args = self.fold_closure_args(def_id, args); Ty::new_generator_witness(self.tcx, def_id, args) } diff --git a/compiler/rustc_middle/src/ty/parameterized.rs b/compiler/rustc_middle/src/ty/parameterized.rs index 9aa673e4418..9afa50cf584 100644 --- a/compiler/rustc_middle/src/ty/parameterized.rs +++ b/compiler/rustc_middle/src/ty/parameterized.rs @@ -82,7 +82,7 @@ impl $crate::ty::ParameterizedOverTcx for $ty { rustc_attr::Stability, rustc_hir::Constness, rustc_hir::Defaultness, - rustc_hir::GeneratorKind, + rustc_hir::CoroutineKind, rustc_hir::IsAsync, rustc_hir::LangItem, rustc_hir::def::DefKind, @@ -123,7 +123,7 @@ impl $crate::ty::ParameterizedOverTcx for $($fake_path)::+<'static> { parameterized_over_tcx! { crate::middle::exported_symbols::ExportedSymbol, crate::mir::Body, - crate::mir::GeneratorLayout, + crate::mir::CoroutineLayout, ty::Ty, ty::FnSig, ty::GenericPredicates, diff --git a/compiler/rustc_middle/src/ty/print/mod.rs b/compiler/rustc_middle/src/ty/print/mod.rs index 107b44285ac..164e4232e4c 100644 --- a/compiler/rustc_middle/src/ty/print/mod.rs +++ b/compiler/rustc_middle/src/ty/print/mod.rs @@ -261,8 +261,8 @@ fn characteristic_def_id_of_type_cached<'a>( ty::FnDef(def_id, _) | ty::Closure(def_id, _) - | ty::Generator(def_id, _, _) - | ty::GeneratorWitness(def_id, _) + | ty::Coroutine(def_id, _, _) + | ty::CoroutineWitness(def_id, _) | ty::Foreign(def_id) => Some(def_id), ty::Bool diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index 117aa69596c..0b5a04c9ec6 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -784,11 +784,11 @@ fn pretty_print_type(mut self, ty: Ty<'tcx>) -> Result { } } ty::Str => p!("str"), - ty::Generator(did, args, movability) => { + ty::Coroutine(did, args, movability) => { p!(write("{{")); let generator_kind = self.tcx().generator_kind(did).unwrap(); let should_print_movability = - self.should_print_verbose() || generator_kind == hir::GeneratorKind::Gen; + self.should_print_verbose() || generator_kind == hir::CoroutineKind::Gen; if should_print_movability { match movability { @@ -828,7 +828,7 @@ fn pretty_print_type(mut self, ty: Ty<'tcx>) -> Result { p!("}}") } - ty::GeneratorWitness(did, args) => { + ty::CoroutineWitness(did, args) => { p!(write("{{")); if !self.tcx().sess.verbose() { p!("generator witness"); @@ -1048,7 +1048,7 @@ fn pretty_print_opaque_impl_type( } for (assoc_item_def_id, term) in assoc_items { - // Skip printing `<{generator@} as Generator<_>>::Return` from async blocks, + // Skip printing `<{generator@} as Coroutine<_>>::Return` from async blocks, // unless we can find out what generator return type it comes from. let term = if let Some(ty) = term.skip_binder().ty() && let ty::Alias(ty::Projection, proj) = ty.kind() @@ -1056,7 +1056,7 @@ fn pretty_print_opaque_impl_type( && assoc.trait_container(tcx) == tcx.lang_items().gen_trait() && assoc.name == rustc_span::sym::Return { - if let ty::Generator(_, args, _) = args.type_at(0).kind() { + if let ty::Coroutine(_, args, _) = args.type_at(0).kind() { let return_ty = args.as_generator().return_ty(); if !return_ty.is_ty_var() { return_ty.into() diff --git a/compiler/rustc_middle/src/ty/relate.rs b/compiler/rustc_middle/src/ty/relate.rs index fdfdd6cc8d6..af6127f0dbb 100644 --- a/compiler/rustc_middle/src/ty/relate.rs +++ b/compiler/rustc_middle/src/ty/relate.rs @@ -352,19 +352,19 @@ fn relate>( } #[derive(PartialEq, Copy, Debug, Clone, TypeFoldable, TypeVisitable)] -struct GeneratorWitness<'tcx>(&'tcx ty::List>); +struct CoroutineWitness<'tcx>(&'tcx ty::List>); -impl<'tcx> Relate<'tcx> for GeneratorWitness<'tcx> { +impl<'tcx> Relate<'tcx> for CoroutineWitness<'tcx> { fn relate>( relation: &mut R, - a: GeneratorWitness<'tcx>, - b: GeneratorWitness<'tcx>, - ) -> RelateResult<'tcx, GeneratorWitness<'tcx>> { + a: CoroutineWitness<'tcx>, + b: CoroutineWitness<'tcx>, + ) -> RelateResult<'tcx, CoroutineWitness<'tcx>> { assert_eq!(a.0.len(), b.0.len()); let tcx = relation.tcx(); let types = tcx.mk_type_list_from_iter(iter::zip(a.0, b.0).map(|(a, b)| relation.relate(a, b)))?; - Ok(GeneratorWitness(types)) + Ok(CoroutineWitness(types)) } } @@ -457,20 +457,20 @@ pub fn structurally_relate_tys<'tcx, R: TypeRelation<'tcx>>( Ok(Ty::new_dynamic(tcx, relation.relate(a_obj, b_obj)?, region_bound, a_repr)) } - (&ty::Generator(a_id, a_args, movability), &ty::Generator(b_id, b_args, _)) + (&ty::Coroutine(a_id, a_args, movability), &ty::Coroutine(b_id, b_args, _)) if a_id == b_id => { - // All Generator types with the same id represent + // All Coroutine types with the same id represent // the (anonymous) type of the same generator expression. So // all of their regions should be equated. let args = relate_args_invariantly(relation, a_args, b_args)?; Ok(Ty::new_generator(tcx, a_id, args, movability)) } - (&ty::GeneratorWitness(a_id, a_args), &ty::GeneratorWitness(b_id, b_args)) + (&ty::CoroutineWitness(a_id, a_args), &ty::CoroutineWitness(b_id, b_args)) if a_id == b_id => { - // All GeneratorWitness types with the same id represent + // All CoroutineWitness types with the same id represent // the (anonymous) type of the same generator expression. So // all of their regions should be equated. let args = relate_args_invariantly(relation, a_args, b_args)?; @@ -710,14 +710,14 @@ fn relate>( } } -impl<'tcx> Relate<'tcx> for ty::GeneratorArgs<'tcx> { +impl<'tcx> Relate<'tcx> for ty::CoroutineArgs<'tcx> { fn relate>( relation: &mut R, - a: ty::GeneratorArgs<'tcx>, - b: ty::GeneratorArgs<'tcx>, - ) -> RelateResult<'tcx, ty::GeneratorArgs<'tcx>> { + a: ty::CoroutineArgs<'tcx>, + b: ty::CoroutineArgs<'tcx>, + ) -> RelateResult<'tcx, ty::CoroutineArgs<'tcx>> { let args = relate_args_invariantly(relation, a.args, b.args)?; - Ok(ty::GeneratorArgs { args }) + Ok(ty::CoroutineArgs { args }) } } diff --git a/compiler/rustc_middle/src/ty/structural_impls.rs b/compiler/rustc_middle/src/ty/structural_impls.rs index 2adbe9e0309..012bb749412 100644 --- a/compiler/rustc_middle/src/ty/structural_impls.rs +++ b/compiler/rustc_middle/src/ty/structural_impls.rs @@ -654,11 +654,11 @@ fn try_super_fold_with>>( ty::Ref(r, ty, mutbl) => { ty::Ref(r.try_fold_with(folder)?, ty.try_fold_with(folder)?, mutbl) } - ty::Generator(did, args, movability) => { - ty::Generator(did, args.try_fold_with(folder)?, movability) + ty::Coroutine(did, args, movability) => { + ty::Coroutine(did, args.try_fold_with(folder)?, movability) } - ty::GeneratorWitness(did, args) => { - ty::GeneratorWitness(did, args.try_fold_with(folder)?) + ty::CoroutineWitness(did, args) => { + ty::CoroutineWitness(did, args.try_fold_with(folder)?) } ty::Closure(did, args) => ty::Closure(did, args.try_fold_with(folder)?), ty::Alias(kind, data) => ty::Alias(kind, data.try_fold_with(folder)?), @@ -706,8 +706,8 @@ fn super_visit_with>>( r.visit_with(visitor)?; ty.visit_with(visitor) } - ty::Generator(_did, ref args, _) => args.visit_with(visitor), - ty::GeneratorWitness(_did, ref args) => args.visit_with(visitor), + ty::Coroutine(_did, ref args, _) => args.visit_with(visitor), + ty::CoroutineWitness(_did, ref args) => args.visit_with(visitor), ty::Closure(_did, ref args) => args.visit_with(visitor), ty::Alias(_, ref data) => data.visit_with(visitor), diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index f06dfc9708c..7af2996d3a3 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -215,9 +215,9 @@ fn article(&self) -> &'static str { /// closure C (which would then require fixed point iteration to /// handle). Plus it fixes an ICE. :P /// -/// ## Generators +/// ## Coroutines /// -/// Generators are handled similarly in `GeneratorArgs`. The set of +/// Coroutines are handled similarly in `CoroutineArgs`. The set of /// type parameters is similar, but `CK` and `CS` are replaced by the /// following type parameters: /// @@ -352,11 +352,11 @@ pub fn print_as_impl_trait(self) -> ty::print::PrintClosureAsImpl<'tcx> { /// Similar to `ClosureArgs`; see the above documentation for more. #[derive(Copy, Clone, PartialEq, Eq, Debug, TypeFoldable, TypeVisitable)] -pub struct GeneratorArgs<'tcx> { +pub struct CoroutineArgs<'tcx> { pub args: GenericArgsRef<'tcx>, } -pub struct GeneratorArgsParts<'tcx, T> { +pub struct CoroutineArgsParts<'tcx, T> { pub parent_args: &'tcx [GenericArg<'tcx>], pub resume_ty: T, pub yield_ty: T, @@ -365,14 +365,14 @@ pub struct GeneratorArgsParts<'tcx, T> { pub tupled_upvars_ty: T, } -impl<'tcx> GeneratorArgs<'tcx> { - /// Construct `GeneratorArgs` from `GeneratorArgsParts`, containing `Args` +impl<'tcx> CoroutineArgs<'tcx> { + /// Construct `CoroutineArgs` from `CoroutineArgsParts`, containing `Args` /// for the generator parent, alongside additional generator-specific components. pub fn new( tcx: TyCtxt<'tcx>, - parts: GeneratorArgsParts<'tcx, Ty<'tcx>>, - ) -> GeneratorArgs<'tcx> { - GeneratorArgs { + parts: CoroutineArgsParts<'tcx, Ty<'tcx>>, + ) -> CoroutineArgs<'tcx> { + CoroutineArgs { args: tcx.mk_args_from_iter( parts.parent_args.iter().copied().chain( [ @@ -390,11 +390,11 @@ pub fn new( } /// Divides the generator args into their respective components. - /// The ordering assumed here must match that used by `GeneratorArgs::new` above. - fn split(self) -> GeneratorArgsParts<'tcx, GenericArg<'tcx>> { + /// The ordering assumed here must match that used by `CoroutineArgs::new` above. + fn split(self) -> CoroutineArgsParts<'tcx, GenericArg<'tcx>> { match self.args[..] { [ref parent_args @ .., resume_ty, yield_ty, return_ty, witness, tupled_upvars_ty] => { - GeneratorArgsParts { + CoroutineArgsParts { parent_args, resume_ty, yield_ty, @@ -408,7 +408,7 @@ fn split(self) -> GeneratorArgsParts<'tcx, GenericArg<'tcx>> { } /// Returns `true` only if enough of the synthetic types are known to - /// allow using all of the methods on `GeneratorArgs` without panicking. + /// allow using all of the methods on `CoroutineArgs` without panicking. /// /// Used primarily by `ty::print::pretty` to be able to handle generator /// types that haven't had their synthetic types substituted in. @@ -485,12 +485,12 @@ pub fn sig(self) -> GenSig<'tcx> { } } -impl<'tcx> GeneratorArgs<'tcx> { - /// Generator has not been resumed yet. +impl<'tcx> CoroutineArgs<'tcx> { + /// Coroutine has not been resumed yet. pub const UNRESUMED: usize = 0; - /// Generator has returned or is completed. + /// Coroutine has returned or is completed. pub const RETURNED: usize = 1; - /// Generator has been poisoned. + /// Coroutine has been poisoned. pub const POISONED: usize = 2; const UNRESUMED_NAME: &'static str = "Unresumed"; @@ -513,7 +513,7 @@ pub fn discriminant_for_variant( tcx: TyCtxt<'tcx>, variant_index: VariantIdx, ) -> Discr<'tcx> { - // Generators don't support explicit discriminant values, so they are + // Coroutines don't support explicit discriminant values, so they are // the same as the variant index. assert!(self.variant_range(def_id, tcx).contains(&variant_index)); Discr { val: variant_index.as_usize() as u128, ty: self.discr_ty(tcx) } @@ -551,7 +551,7 @@ pub fn discr_ty(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> { /// This returns the types of the MIR locals which had to be stored across suspension points. /// It is calculated in rustc_mir_transform::generator::StateTransform. - /// All the types here must be in the tuple in GeneratorInterior. + /// All the types here must be in the tuple in CoroutineInterior. /// /// The locals are grouped by their variant number. Note that some locals may /// be repeated in multiple variants. @@ -580,7 +580,7 @@ pub fn prefix_tys(self) -> &'tcx List> { #[derive(Debug, Copy, Clone, HashStable)] pub enum UpvarArgs<'tcx> { Closure(GenericArgsRef<'tcx>), - Generator(GenericArgsRef<'tcx>), + Coroutine(GenericArgsRef<'tcx>), } impl<'tcx> UpvarArgs<'tcx> { @@ -591,7 +591,7 @@ impl<'tcx> UpvarArgs<'tcx> { pub fn upvar_tys(self) -> &'tcx List> { let tupled_tys = match self { UpvarArgs::Closure(args) => args.as_closure().tupled_upvars_ty(), - UpvarArgs::Generator(args) => args.as_generator().tupled_upvars_ty(), + UpvarArgs::Coroutine(args) => args.as_generator().tupled_upvars_ty(), }; match tupled_tys.kind() { @@ -606,7 +606,7 @@ pub fn upvar_tys(self) -> &'tcx List> { pub fn tupled_upvars_ty(self) -> Ty<'tcx> { match self { UpvarArgs::Closure(args) => args.as_closure().tupled_upvars_ty(), - UpvarArgs::Generator(args) => args.as_generator().tupled_upvars_ty(), + UpvarArgs::Coroutine(args) => args.as_generator().tupled_upvars_ty(), } } } @@ -2176,7 +2176,7 @@ pub fn new_generator( tcx.generics_of(tcx.typeck_root_def_id(def_id)).count() + 5, "generator constructed with incorrect number of substitutions" ); - Ty::new(tcx, Generator(def_id, generator_args, movability)) + Ty::new(tcx, Coroutine(def_id, generator_args, movability)) } #[inline] @@ -2185,7 +2185,7 @@ pub fn new_generator_witness( id: DefId, args: GenericArgsRef<'tcx>, ) -> Ty<'tcx> { - Ty::new(tcx, GeneratorWitness(id, args)) + Ty::new(tcx, CoroutineWitness(id, args)) } // misc @@ -2496,7 +2496,7 @@ pub fn is_closure(self) -> bool { #[inline] pub fn is_generator(self) -> bool { - matches!(self.kind(), Generator(..)) + matches!(self.kind(), Coroutine(..)) } #[inline] @@ -2657,7 +2657,7 @@ pub fn tuple_fields(self) -> &'tcx List> { pub fn variant_range(self, tcx: TyCtxt<'tcx>) -> Option> { match self.kind() { TyKind::Adt(adt, _) => Some(adt.variant_range()), - TyKind::Generator(def_id, args, _) => { + TyKind::Coroutine(def_id, args, _) => { Some(args.as_generator().variant_range(*def_id, tcx)) } _ => None, @@ -2678,7 +2678,7 @@ pub fn discriminant_for_variant( TyKind::Adt(adt, _) if adt.is_enum() => { Some(adt.discriminant_for_variant(tcx, variant_index)) } - TyKind::Generator(def_id, args, _) => { + TyKind::Coroutine(def_id, args, _) => { Some(args.as_generator().discriminant_for_variant(*def_id, tcx, variant_index)) } _ => None, @@ -2689,7 +2689,7 @@ pub fn discriminant_for_variant( pub fn discriminant_ty(self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> { match self.kind() { ty::Adt(adt, _) if adt.is_enum() => adt.repr().discr_type().to_ty(tcx), - ty::Generator(_, args, _) => args.as_generator().discr_ty(tcx), + ty::Coroutine(_, args, _) => args.as_generator().discr_ty(tcx), ty::Param(_) | ty::Alias(..) | ty::Infer(ty::TyVar(_)) => { let assoc_items = tcx.associated_item_def_ids( @@ -2714,7 +2714,7 @@ pub fn discriminant_ty(self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> { | ty::FnPtr(..) | ty::Dynamic(..) | ty::Closure(..) - | ty::GeneratorWitness(..) + | ty::CoroutineWitness(..) | ty::Never | ty::Tuple(_) | ty::Error(_) @@ -2748,8 +2748,8 @@ pub fn ptr_metadata_ty( | ty::RawPtr(..) | ty::Char | ty::Ref(..) - | ty::Generator(..) - | ty::GeneratorWitness(..) + | ty::Coroutine(..) + | ty::CoroutineWitness(..) | ty::Array(..) | ty::Closure(..) | ty::Never @@ -2836,8 +2836,8 @@ pub fn is_trivially_sized(self, tcx: TyCtxt<'tcx>) -> bool { | ty::RawPtr(..) | ty::Char | ty::Ref(..) - | ty::Generator(..) - | ty::GeneratorWitness(..) + | ty::Coroutine(..) + | ty::CoroutineWitness(..) | ty::Array(..) | ty::Closure(..) | ty::Never @@ -2900,7 +2900,7 @@ pub fn is_trivially_pure_clone_copy(self) -> bool { // anything with custom metadata it might be more complicated. ty::Ref(_, _, hir::Mutability::Not) | ty::RawPtr(..) => false, - ty::Generator(..) | ty::GeneratorWitness(..) => false, + ty::Coroutine(..) | ty::CoroutineWitness(..) => false, // Might be, but not "trivial" so just giving the safe answer. ty::Adt(..) | ty::Closure(..) => false, @@ -2975,8 +2975,8 @@ pub fn is_known_rigid(self) -> bool { | FnPtr(_) | Dynamic(_, _, _) | Closure(_, _) - | Generator(_, _, _) - | GeneratorWitness(..) + | Coroutine(_, _, _) + | CoroutineWitness(..) | Never | Tuple(_) => true, Error(_) | Infer(_) | Alias(_, _) | Param(_) | Bound(_, _) | Placeholder(_) => false, diff --git a/compiler/rustc_middle/src/ty/util.rs b/compiler/rustc_middle/src/ty/util.rs index 31b52677b27..ffa45e481ae 100644 --- a/compiler/rustc_middle/src/ty/util.rs +++ b/compiler/rustc_middle/src/ty/util.rs @@ -548,7 +548,7 @@ pub fn uses_unique_placeholders_ignoring_regions( /// those are not yet phased out). The parent of the closure's /// `DefId` will also be the context where it appears. pub fn is_closure(self, def_id: DefId) -> bool { - matches!(self.def_kind(def_id), DefKind::Closure | DefKind::Generator) + matches!(self.def_kind(def_id), DefKind::Closure | DefKind::Coroutine) } /// Returns `true` if `def_id` refers to a definition that does not have its own @@ -556,7 +556,7 @@ pub fn is_closure(self, def_id: DefId) -> bool { pub fn is_typeck_child(self, def_id: DefId) -> bool { matches!( self.def_kind(def_id), - DefKind::Closure | DefKind::Generator | DefKind::InlineConst + DefKind::Closure | DefKind::Coroutine | DefKind::InlineConst ) } @@ -746,9 +746,9 @@ pub fn def_descr(self, def_id: DefId) -> &'static str { pub fn def_kind_descr(self, def_kind: DefKind, def_id: DefId) -> &'static str { match def_kind { DefKind::AssocFn if self.associated_item(def_id).fn_has_self_parameter => "method", - DefKind::Generator => match self.generator_kind(def_id).unwrap() { - rustc_hir::GeneratorKind::Async(..) => "async closure", - rustc_hir::GeneratorKind::Gen => "generator", + DefKind::Coroutine => match self.generator_kind(def_id).unwrap() { + rustc_hir::CoroutineKind::Async(..) => "async closure", + rustc_hir::CoroutineKind::Gen => "generator", }, _ => def_kind.descr(def_id), } @@ -763,9 +763,9 @@ pub fn def_descr_article(self, def_id: DefId) -> &'static str { pub fn def_kind_descr_article(self, def_kind: DefKind, def_id: DefId) -> &'static str { match def_kind { DefKind::AssocFn if self.associated_item(def_id).fn_has_self_parameter => "a", - DefKind::Generator => match self.generator_kind(def_id).unwrap() { - rustc_hir::GeneratorKind::Async(..) => "an", - rustc_hir::GeneratorKind::Gen => "a", + DefKind::Coroutine => match self.generator_kind(def_id).unwrap() { + rustc_hir::CoroutineKind::Async(..) => "an", + rustc_hir::CoroutineKind::Gen => "a", }, _ => def_kind.article(), } @@ -888,7 +888,7 @@ fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> { t }; if self.expand_generators { - if let ty::GeneratorWitness(def_id, args) = *t.kind() { + if let ty::CoroutineWitness(def_id, args) = *t.kind() { t = self.expand_generator(def_id, args).unwrap_or(t); } } @@ -1024,8 +1024,8 @@ fn is_trivially_freeze(self) -> bool { | ty::Closure(..) | ty::Dynamic(..) | ty::Foreign(_) - | ty::Generator(..) - | ty::GeneratorWitness(..) + | ty::Coroutine(..) + | ty::CoroutineWitness(..) | ty::Infer(_) | ty::Alias(..) | ty::Param(_) @@ -1063,8 +1063,8 @@ fn is_trivially_unpin(self) -> bool { | ty::Closure(..) | ty::Dynamic(..) | ty::Foreign(_) - | ty::Generator(..) - | ty::GeneratorWitness(..) + | ty::Coroutine(..) + | ty::CoroutineWitness(..) | ty::Infer(_) | ty::Alias(..) | ty::Param(_) @@ -1182,7 +1182,7 @@ pub fn is_structural_eq_shallow(self, tcx: TyCtxt<'tcx>) -> bool { // Conservatively return `false` for all others... // Anonymous function types - ty::FnDef(..) | ty::Closure(..) | ty::Dynamic(..) | ty::Generator(..) => false, + ty::FnDef(..) | ty::Closure(..) | ty::Dynamic(..) | ty::Coroutine(..) => false, // Generic or inferred types // @@ -1192,7 +1192,7 @@ pub fn is_structural_eq_shallow(self, tcx: TyCtxt<'tcx>) -> bool { false } - ty::Foreign(_) | ty::GeneratorWitness(..) | ty::Error(_) => false, + ty::Foreign(_) | ty::CoroutineWitness(..) | ty::Error(_) => false, } } @@ -1287,7 +1287,7 @@ pub fn needs_drop_components<'tcx>( | ty::FnDef(..) | ty::FnPtr(_) | ty::Char - | ty::GeneratorWitness(..) + | ty::CoroutineWitness(..) | ty::RawPtr(_) | ty::Ref(..) | ty::Str => Ok(SmallVec::new()), @@ -1327,7 +1327,7 @@ pub fn needs_drop_components<'tcx>( | ty::Placeholder(..) | ty::Infer(_) | ty::Closure(..) - | ty::Generator(..) => Ok(smallvec![ty]), + | ty::Coroutine(..) => Ok(smallvec![ty]), } } @@ -1358,7 +1358,7 @@ pub fn is_trivially_const_drop(ty: Ty<'_>) -> bool { // Not trivial because they have components, and instead of looking inside, // we'll just perform trait selection. - ty::Closure(..) | ty::Generator(..) | ty::GeneratorWitness(..) | ty::Adt(..) => false, + ty::Closure(..) | ty::Coroutine(..) | ty::CoroutineWitness(..) | ty::Adt(..) => false, ty::Array(ty, _) | ty::Slice(ty) => is_trivially_const_drop(ty), diff --git a/compiler/rustc_middle/src/ty/walk.rs b/compiler/rustc_middle/src/ty/walk.rs index a86ff64bd0c..20bdbcb5b7b 100644 --- a/compiler/rustc_middle/src/ty/walk.rs +++ b/compiler/rustc_middle/src/ty/walk.rs @@ -189,8 +189,8 @@ fn push_inner<'tcx>(stack: &mut TypeWalkerStack<'tcx>, parent: GenericArg<'tcx>) } ty::Adt(_, args) | ty::Closure(_, args) - | ty::Generator(_, args, _) - | ty::GeneratorWitness(_, args) + | ty::Coroutine(_, args, _) + | ty::CoroutineWitness(_, args) | ty::FnDef(_, args) => { stack.extend(args.iter().rev()); } diff --git a/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs b/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs index 7d7542a9a6a..d9858a66aa8 100644 --- a/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs +++ b/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs @@ -487,11 +487,11 @@ pub(crate) fn as_rvalue( .collect(); let result = match args { - UpvarArgs::Generator(args) => { + UpvarArgs::Coroutine(args) => { // We implicitly set the discriminant to 0. See // librustc_mir/transform/deaggregator.rs for details. let movability = movability.unwrap(); - Box::new(AggregateKind::Generator(closure_id.to_def_id(), args, movability)) + Box::new(AggregateKind::Coroutine(closure_id.to_def_id(), args, movability)) } UpvarArgs::Closure(args) => { Box::new(AggregateKind::Closure(closure_id.to_def_id(), args)) diff --git a/compiler/rustc_mir_build/src/build/mod.rs b/compiler/rustc_mir_build/src/build/mod.rs index d9098bac1c2..aaea10f3d62 100644 --- a/compiler/rustc_mir_build/src/build/mod.rs +++ b/compiler/rustc_mir_build/src/build/mod.rs @@ -9,7 +9,7 @@ use rustc_hir as hir; use rustc_hir::def::DefKind; use rustc_hir::def_id::{DefId, LocalDefId}; -use rustc_hir::{GeneratorKind, Node}; +use rustc_hir::{CoroutineKind, Node}; use rustc_index::bit_set::GrowableBitSet; use rustc_index::{Idx, IndexSlice, IndexVec}; use rustc_infer::infer::{InferCtxt, TyCtxtInferExt}; @@ -173,7 +173,7 @@ struct Builder<'a, 'tcx> { check_overflow: bool, fn_span: Span, arg_count: usize, - generator_kind: Option, + generator_kind: Option, /// The current set of scopes, updated as we traverse; /// see the `scope` module for more details. @@ -481,7 +481,7 @@ fn construct_fn<'tcx>( let (yield_ty, return_ty) = if generator_kind.is_some() { let gen_ty = arguments[thir::UPVAR_ENV_PARAM].ty; let gen_sig = match gen_ty.kind() { - ty::Generator(_, gen_args, ..) => gen_args.as_generator().sig(), + ty::Coroutine(_, gen_args, ..) => gen_args.as_generator().sig(), _ => { span_bug!(span, "generator w/o generator type: {:?}", gen_ty) } @@ -629,7 +629,7 @@ fn construct_error(tcx: TyCtxt<'_>, def: LocalDefId, err: ErrorGuaranteed) -> Bo let ty = tcx.type_of(def).instantiate_identity(); match ty.kind() { ty::Closure(_, args) => 1 + args.as_closure().sig().inputs().skip_binder().len(), - ty::Generator(..) => 2, + ty::Coroutine(..) => 2, _ => bug!("expected closure or generator, found {ty:?}"), } } @@ -687,7 +687,7 @@ fn new( safety: Safety, return_ty: Ty<'tcx>, return_span: Span, - generator_kind: Option, + generator_kind: Option, ) -> Builder<'a, 'tcx> { let tcx = infcx.tcx; let attrs = tcx.hir().attrs(hir_id); @@ -777,7 +777,7 @@ fn insert_upvar_arg(&mut self) { let upvar_args = match closure_ty.kind() { ty::Closure(_, args) => ty::UpvarArgs::Closure(args), - ty::Generator(_, args, _) => ty::UpvarArgs::Generator(args), + ty::Coroutine(_, args, _) => ty::UpvarArgs::Coroutine(args), _ => return, }; diff --git a/compiler/rustc_mir_build/src/build/scope.rs b/compiler/rustc_mir_build/src/build/scope.rs index bc151cc7058..4ccd2ecaac1 100644 --- a/compiler/rustc_mir_build/src/build/scope.rs +++ b/compiler/rustc_mir_build/src/build/scope.rs @@ -108,7 +108,7 @@ pub struct Scopes<'tcx> { /// [DropTree] for more details. unwind_drops: DropTree, - /// Drops that need to be done on paths to the `GeneratorDrop` terminator. + /// Drops that need to be done on paths to the `CoroutineDrop` terminator. generator_drops: DropTree, } @@ -1140,7 +1140,7 @@ pub(crate) fn diverge_from(&mut self, start: BasicBlock) { /// generator, starting from the given block that ends in /// [TerminatorKind::Yield]. /// - /// This path terminates in GeneratorDrop. + /// This path terminates in CoroutineDrop. pub(crate) fn generator_drop_cleanup(&mut self, yield_block: BasicBlock) { debug_assert!( matches!( @@ -1401,12 +1401,12 @@ fn build_generator_drop_trees(&mut self) { let cfg = &mut self.cfg; let fn_span = self.fn_span; let mut blocks = IndexVec::from_elem(None, &drops.drops); - drops.build_mir::(cfg, &mut blocks); + drops.build_mir::(cfg, &mut blocks); if let Some(root_block) = blocks[ROOT_NODE] { cfg.terminate( root_block, SourceInfo::outermost(fn_span), - TerminatorKind::GeneratorDrop, + TerminatorKind::CoroutineDrop, ); } @@ -1461,9 +1461,9 @@ fn add_entry(cfg: &mut CFG<'tcx>, from: BasicBlock, to: BasicBlock) { } } -struct GeneratorDrop; +struct CoroutineDrop; -impl<'tcx> DropTreeBuilder<'tcx> for GeneratorDrop { +impl<'tcx> DropTreeBuilder<'tcx> for CoroutineDrop { fn make_block(cfg: &mut CFG<'tcx>) -> BasicBlock { cfg.start_new_block() } @@ -1511,7 +1511,7 @@ fn add_entry(cfg: &mut CFG<'tcx>, from: BasicBlock, to: BasicBlock) { | TerminatorKind::Return | TerminatorKind::Unreachable | TerminatorKind::Yield { .. } - | TerminatorKind::GeneratorDrop + | TerminatorKind::CoroutineDrop | TerminatorKind::FalseEdge { .. } => { span_bug!(term.source_info.span, "cannot unwind from {:?}", term.kind) } diff --git a/compiler/rustc_mir_build/src/lints.rs b/compiler/rustc_mir_build/src/lints.rs index e78274b4284..acf4d6bc2a0 100644 --- a/compiler/rustc_mir_build/src/lints.rs +++ b/compiler/rustc_mir_build/src/lints.rs @@ -192,7 +192,7 @@ fn node_examined( match self.body[bb].terminator().kind { // These terminators return control flow to the caller. TerminatorKind::UnwindTerminate(_) - | TerminatorKind::GeneratorDrop + | TerminatorKind::CoroutineDrop | TerminatorKind::UnwindResume | TerminatorKind::Return | TerminatorKind::Unreachable diff --git a/compiler/rustc_mir_build/src/thir/cx/expr.rs b/compiler/rustc_mir_build/src/thir/cx/expr.rs index 0535ea24b82..840c6e13bef 100644 --- a/compiler/rustc_mir_build/src/thir/cx/expr.rs +++ b/compiler/rustc_mir_build/src/thir/cx/expr.rs @@ -574,8 +574,8 @@ fn make_mirror_unadjusted(&mut self, expr: &'tcx hir::Expr<'tcx>) -> Expr<'tcx> let closure_ty = self.typeck_results().expr_ty(expr); let (def_id, args, movability) = match *closure_ty.kind() { ty::Closure(def_id, args) => (def_id, UpvarArgs::Closure(args), None), - ty::Generator(def_id, args, movability) => { - (def_id, UpvarArgs::Generator(args), Some(movability)) + ty::Coroutine(def_id, args, movability) => { + (def_id, UpvarArgs::Coroutine(args), Some(movability)) } _ => { span_bug!(expr.span, "closure expr w/o closure type: {:?}", closure_ty); diff --git a/compiler/rustc_mir_build/src/thir/cx/mod.rs b/compiler/rustc_mir_build/src/thir/cx/mod.rs index d98cc76adfb..8bc4cbb9532 100644 --- a/compiler/rustc_mir_build/src/thir/cx/mod.rs +++ b/compiler/rustc_mir_build/src/thir/cx/mod.rs @@ -37,7 +37,7 @@ pub(crate) fn thir_body( // The resume argument may be missing, in that case we need to provide it here. // It will always be `()` in this case. - if tcx.def_kind(owner_def) == DefKind::Generator && body.params.is_empty() { + if tcx.def_kind(owner_def) == DefKind::Coroutine && body.params.is_empty() { cx.thir.params.push(Param { ty: Ty::new_unit(tcx), pat: None, @@ -148,7 +148,7 @@ fn closure_env_param(&self, owner_def: LocalDefId, owner_id: HirId) -> Option { + DefKind::Coroutine => { let gen_ty = self.typeck_results.node_type(owner_id); let gen_param = Param { ty: gen_ty, pat: None, ty_span: None, self_kind: None, hir_id: None }; diff --git a/compiler/rustc_mir_dataflow/src/elaborate_drops.rs b/compiler/rustc_mir_dataflow/src/elaborate_drops.rs index c9991e499b3..8bd4af02484 100644 --- a/compiler/rustc_mir_dataflow/src/elaborate_drops.rs +++ b/compiler/rustc_mir_dataflow/src/elaborate_drops.rs @@ -866,7 +866,7 @@ fn open_drop(&mut self) -> BasicBlock { // This should only happen for the self argument on the resume function. // It effectively only contains upvars until the generator transformation runs. // See librustc_body/transform/generator.rs for more details. - ty::Generator(_, args, _) => self.open_drop_for_tuple(&args.as_generator().upvar_tys()), + ty::Coroutine(_, args, _) => self.open_drop_for_tuple(&args.as_generator().upvar_tys()), ty::Tuple(fields) => self.open_drop_for_tuple(fields), ty::Adt(def, args) => self.open_drop_for_adt(*def, args), ty::Dynamic(..) => self.complete_drop(self.succ, self.unwind), diff --git a/compiler/rustc_mir_dataflow/src/impls/borrowed_locals.rs b/compiler/rustc_mir_dataflow/src/impls/borrowed_locals.rs index 3ad9d3d4264..20d1edbc35b 100644 --- a/compiler/rustc_mir_dataflow/src/impls/borrowed_locals.rs +++ b/compiler/rustc_mir_dataflow/src/impls/borrowed_locals.rs @@ -136,7 +136,7 @@ fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location | TerminatorKind::Call { .. } | TerminatorKind::FalseEdge { .. } | TerminatorKind::FalseUnwind { .. } - | TerminatorKind::GeneratorDrop + | TerminatorKind::CoroutineDrop | TerminatorKind::Goto { .. } | TerminatorKind::InlineAsm { .. } | TerminatorKind::UnwindResume diff --git a/compiler/rustc_mir_dataflow/src/impls/initialized.rs b/compiler/rustc_mir_dataflow/src/impls/initialized.rs index e6d383d626a..118ae87e1f1 100644 --- a/compiler/rustc_mir_dataflow/src/impls/initialized.rs +++ b/compiler/rustc_mir_dataflow/src/impls/initialized.rs @@ -765,7 +765,7 @@ fn switch_on_enum_discriminant<'mir, 'tcx>( // `Rvalue::Discriminant` is also used to get the active yield point for a // generator, but we do not need edge-specific effects in that case. This may // change in the future. - ty::Generator(..) => return None, + ty::Coroutine(..) => return None, t => bug!("`discriminant` called on unexpected type {:?}", t), } diff --git a/compiler/rustc_mir_dataflow/src/impls/storage_liveness.rs b/compiler/rustc_mir_dataflow/src/impls/storage_liveness.rs index 94d6eb67d49..8d37f50ed8d 100644 --- a/compiler/rustc_mir_dataflow/src/impls/storage_liveness.rs +++ b/compiler/rustc_mir_dataflow/src/impls/storage_liveness.rs @@ -296,7 +296,7 @@ fn before_terminator_effect( | TerminatorKind::Drop { .. } | TerminatorKind::FalseEdge { .. } | TerminatorKind::FalseUnwind { .. } - | TerminatorKind::GeneratorDrop + | TerminatorKind::CoroutineDrop | TerminatorKind::Goto { .. } | TerminatorKind::UnwindResume | TerminatorKind::Return @@ -333,7 +333,7 @@ fn terminator_effect<'t>( | TerminatorKind::Drop { .. } | TerminatorKind::FalseEdge { .. } | TerminatorKind::FalseUnwind { .. } - | TerminatorKind::GeneratorDrop + | TerminatorKind::CoroutineDrop | TerminatorKind::Goto { .. } | TerminatorKind::UnwindResume | TerminatorKind::Return diff --git a/compiler/rustc_mir_dataflow/src/move_paths/builder.rs b/compiler/rustc_mir_dataflow/src/move_paths/builder.rs index 7a5b3585d59..91a96593173 100644 --- a/compiler/rustc_mir_dataflow/src/move_paths/builder.rs +++ b/compiler/rustc_mir_dataflow/src/move_paths/builder.rs @@ -143,8 +143,8 @@ fn move_path_for(&mut self, place: Place<'tcx>) -> Result) -> Result (), + ty::Closure(_, _) | ty::Coroutine(_, _, _) | ty::Tuple(_) => (), ty::Bool | ty::Char | ty::Int(_) @@ -183,7 +183,7 @@ fn move_path_for(&mut self, place: Place<'tcx>) -> Result) { | TerminatorKind::Return | TerminatorKind::UnwindResume | TerminatorKind::UnwindTerminate(_) - | TerminatorKind::GeneratorDrop + | TerminatorKind::CoroutineDrop | TerminatorKind::Unreachable | TerminatorKind::Drop { .. } => {} diff --git a/compiler/rustc_mir_dataflow/src/value_analysis.rs b/compiler/rustc_mir_dataflow/src/value_analysis.rs index 44bbb8374dc..47926e63eda 100644 --- a/compiler/rustc_mir_dataflow/src/value_analysis.rs +++ b/compiler/rustc_mir_dataflow/src/value_analysis.rs @@ -274,7 +274,7 @@ fn super_terminator<'mir>( | TerminatorKind::Return | TerminatorKind::Unreachable | TerminatorKind::Assert { .. } - | TerminatorKind::GeneratorDrop + | TerminatorKind::CoroutineDrop | TerminatorKind::FalseEdge { .. } | TerminatorKind::FalseUnwind { .. } => { // These terminators have no effect on the analysis. diff --git a/compiler/rustc_mir_transform/src/abort_unwinding_calls.rs b/compiler/rustc_mir_transform/src/abort_unwinding_calls.rs index 74243f1f8f2..2b3d423ea61 100644 --- a/compiler/rustc_mir_transform/src/abort_unwinding_calls.rs +++ b/compiler/rustc_mir_transform/src/abort_unwinding_calls.rs @@ -40,7 +40,7 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { let body_abi = match body_ty.kind() { ty::FnDef(..) => body_ty.fn_sig(tcx).abi(), ty::Closure(..) => Abi::RustCall, - ty::Generator(..) => Abi::Rust, + ty::Coroutine(..) => Abi::Rust, _ => span_bug!(body.span, "unexpected body ty: {:?}", body_ty), }; let body_can_unwind = layout::fn_can_unwind(tcx, Some(def_id), body_abi); diff --git a/compiler/rustc_mir_transform/src/check_unsafety.rs b/compiler/rustc_mir_transform/src/check_unsafety.rs index 7e4731f5d8a..8872f9a97d7 100644 --- a/compiler/rustc_mir_transform/src/check_unsafety.rs +++ b/compiler/rustc_mir_transform/src/check_unsafety.rs @@ -56,7 +56,7 @@ fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location | TerminatorKind::Drop { .. } | TerminatorKind::Yield { .. } | TerminatorKind::Assert { .. } - | TerminatorKind::GeneratorDrop + | TerminatorKind::CoroutineDrop | TerminatorKind::UnwindResume | TerminatorKind::UnwindTerminate(_) | TerminatorKind::Return @@ -128,7 +128,7 @@ fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, location: Location) { ), } } - &AggregateKind::Closure(def_id, _) | &AggregateKind::Generator(def_id, _, _) => { + &AggregateKind::Closure(def_id, _) | &AggregateKind::Coroutine(def_id, _, _) => { let def_id = def_id.expect_local(); let UnsafetyCheckResult { violations, used_unsafe_blocks, .. } = self.tcx.unsafety_check_result(def_id); diff --git a/compiler/rustc_mir_transform/src/const_prop.rs b/compiler/rustc_mir_transform/src/const_prop.rs index 3450a0f3686..0a48e0d3fdf 100644 --- a/compiler/rustc_mir_transform/src/const_prop.rs +++ b/compiler/rustc_mir_transform/src/const_prop.rs @@ -84,7 +84,7 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { // FIXME(welseywiser) const prop doesn't work on generators because of query cycles // computing their layout. - let is_generator = def_kind == DefKind::Generator; + let is_generator = def_kind == DefKind::Coroutine; if is_generator { trace!("ConstProp skipped for generator {:?}", def_id); return; diff --git a/compiler/rustc_mir_transform/src/const_prop_lint.rs b/compiler/rustc_mir_transform/src/const_prop_lint.rs index aad513d7355..22f84e37637 100644 --- a/compiler/rustc_mir_transform/src/const_prop_lint.rs +++ b/compiler/rustc_mir_transform/src/const_prop_lint.rs @@ -61,7 +61,7 @@ fn run_lint(&self, tcx: TyCtxt<'tcx>, body: &Body<'tcx>) { // FIXME(welseywiser) const prop doesn't work on generators because of query cycles // computing their layout. - if let DefKind::Generator = def_kind { + if let DefKind::Coroutine = def_kind { trace!("ConstPropLint skipped for generator {:?}", def_id); return; } @@ -648,7 +648,7 @@ fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location | TerminatorKind::Unreachable | TerminatorKind::Drop { .. } | TerminatorKind::Yield { .. } - | TerminatorKind::GeneratorDrop + | TerminatorKind::CoroutineDrop | TerminatorKind::FalseEdge { .. } | TerminatorKind::FalseUnwind { .. } | TerminatorKind::Call { .. } diff --git a/compiler/rustc_mir_transform/src/coverage/graph.rs b/compiler/rustc_mir_transform/src/coverage/graph.rs index 9a7adaada09..6bab62aa854 100644 --- a/compiler/rustc_mir_transform/src/coverage/graph.rs +++ b/compiler/rustc_mir_transform/src/coverage/graph.rs @@ -147,7 +147,7 @@ fn compute_basic_coverage_blocks( | TerminatorKind::Unreachable | TerminatorKind::Drop { .. } | TerminatorKind::Call { .. } - | TerminatorKind::GeneratorDrop + | TerminatorKind::CoroutineDrop | TerminatorKind::Assert { .. } | TerminatorKind::FalseEdge { .. } | TerminatorKind::FalseUnwind { .. } diff --git a/compiler/rustc_mir_transform/src/coverage/spans.rs b/compiler/rustc_mir_transform/src/coverage/spans.rs index f1a0f762041..3f7ba572510 100644 --- a/compiler/rustc_mir_transform/src/coverage/spans.rs +++ b/compiler/rustc_mir_transform/src/coverage/spans.rs @@ -93,7 +93,7 @@ pub fn for_statement( ) -> Self { let is_closure = match statement.kind { StatementKind::Assign(box (_, Rvalue::Aggregate(box ref kind, _))) => { - matches!(kind, AggregateKind::Closure(_, _) | AggregateKind::Generator(_, _, _)) + matches!(kind, AggregateKind::Closure(_, _) | AggregateKind::Coroutine(_, _, _)) } _ => false, }; diff --git a/compiler/rustc_mir_transform/src/coverage/spans/from_mir.rs b/compiler/rustc_mir_transform/src/coverage/spans/from_mir.rs index 4c20997e633..02e2cf6b05e 100644 --- a/compiler/rustc_mir_transform/src/coverage/spans/from_mir.rs +++ b/compiler/rustc_mir_transform/src/coverage/spans/from_mir.rs @@ -160,7 +160,7 @@ fn filtered_terminator_span(terminator: &Terminator<'_>) -> Option { | TerminatorKind::UnwindTerminate(_) | TerminatorKind::Return | TerminatorKind::Yield { .. } - | TerminatorKind::GeneratorDrop + | TerminatorKind::CoroutineDrop | TerminatorKind::FalseUnwind { .. } | TerminatorKind::InlineAsm { .. } => { Some(terminator.source_info.span) diff --git a/compiler/rustc_mir_transform/src/dest_prop.rs b/compiler/rustc_mir_transform/src/dest_prop.rs index 99b070c018e..9789c0b70e6 100644 --- a/compiler/rustc_mir_transform/src/dest_prop.rs +++ b/compiler/rustc_mir_transform/src/dest_prop.rs @@ -655,7 +655,7 @@ fn for_terminator<'tcx>(&mut self, terminator: &TerminatorKind<'tcx>) { // `Drop`s create a `&mut` and so are not considered } TerminatorKind::Yield { .. } - | TerminatorKind::GeneratorDrop + | TerminatorKind::CoroutineDrop | TerminatorKind::FalseEdge { .. } | TerminatorKind::FalseUnwind { .. } => { bug!("{:?} not found in this MIR phase", terminator) diff --git a/compiler/rustc_mir_transform/src/ffi_unwind_calls.rs b/compiler/rustc_mir_transform/src/ffi_unwind_calls.rs index d202860840c..26fcfad8287 100644 --- a/compiler/rustc_mir_transform/src/ffi_unwind_calls.rs +++ b/compiler/rustc_mir_transform/src/ffi_unwind_calls.rs @@ -58,7 +58,7 @@ fn has_ffi_unwind_calls(tcx: TyCtxt<'_>, local_def_id: LocalDefId) -> bool { let body_abi = match body_ty.kind() { ty::FnDef(..) => body_ty.fn_sig(tcx).abi(), ty::Closure(..) => Abi::RustCall, - ty::Generator(..) => Abi::Rust, + ty::Coroutine(..) => Abi::Rust, _ => span_bug!(body.span, "unexpected body ty: {:?}", body_ty), }; let body_can_unwind = layout::fn_can_unwind(tcx, Some(def_id), body_abi); diff --git a/compiler/rustc_mir_transform/src/generator.rs b/compiler/rustc_mir_transform/src/generator.rs index a6693519e54..696cb4e644b 100644 --- a/compiler/rustc_mir_transform/src/generator.rs +++ b/compiler/rustc_mir_transform/src/generator.rs @@ -11,7 +11,7 @@ //! generator in the MIR, since it is used to create the drop glue for the generator. We'd get //! infinite recursion otherwise. //! -//! This pass creates the implementation for either the `Generator::resume` or `Future::poll` +//! This pass creates the implementation for either the `Coroutine::resume` or `Future::poll` //! function and the drop shim for the generator based on the MIR input. //! It converts the generator argument from Self to &mut Self adding derefs in the MIR as needed. //! It computes the final layout of the generator struct which looks like this: @@ -19,7 +19,7 @@ //! It is followed by the generator state field. //! Then finally the MIR locals which are live across a suspension point are stored. //! ```ignore (illustrative) -//! struct Generator { +//! struct Coroutine { //! upvars..., //! state: u32, //! mir_locals..., @@ -27,12 +27,12 @@ //! ``` //! This pass computes the meaning of the state field and the MIR locals which are live //! across a suspension point. There are however three hardcoded generator states: -//! 0 - Generator have not been resumed yet -//! 1 - Generator has returned / is completed -//! 2 - Generator has been poisoned +//! 0 - Coroutine have not been resumed yet +//! 1 - Coroutine has returned / is completed +//! 2 - Coroutine has been poisoned //! //! It also rewrites `return x` and `yield y` as setting a new generator state and returning -//! `GeneratorState::Complete(x)` and `GeneratorState::Yielded(y)`, +//! `CoroutineState::Complete(x)` and `CoroutineState::Yielded(y)`, //! or `Poll::Ready(x)` and `Poll::Pending` respectively. //! MIR locals which are live across a suspension point are moved to the generator struct //! with references to them being updated with references to the generator struct. @@ -40,7 +40,7 @@ //! The pass creates two functions which have a switch on the generator state giving //! the action to take. //! -//! One of them is the implementation of `Generator::resume` / `Future::poll`. +//! One of them is the implementation of `Coroutine::resume` / `Future::poll`. //! For generators with state 0 (unresumed) it starts the execution of the generator. //! For generators with state 1 (returned) and state 2 (poisoned) it panics. //! Otherwise it continues the execution from the last suspension point. @@ -60,7 +60,7 @@ use rustc_errors::pluralize; use rustc_hir as hir; use rustc_hir::lang_items::LangItem; -use rustc_hir::GeneratorKind; +use rustc_hir::CoroutineKind; use rustc_index::bit_set::{BitMatrix, BitSet, GrowableBitSet}; use rustc_index::{Idx, IndexVec}; use rustc_middle::mir::dump_mir; @@ -68,7 +68,7 @@ use rustc_middle::mir::*; use rustc_middle::ty::InstanceDef; use rustc_middle::ty::{self, AdtDef, Ty, TyCtxt}; -use rustc_middle::ty::{GeneratorArgs, GenericArgsRef}; +use rustc_middle::ty::{CoroutineArgs, GenericArgsRef}; use rustc_mir_dataflow::impls::{ MaybeBorrowedLocals, MaybeLiveLocals, MaybeRequiresStorage, MaybeStorageLive, }; @@ -196,12 +196,12 @@ fn replace_base<'tcx>(place: &mut Place<'tcx>, new_base: Place<'tcx>, tcx: TyCtx const SELF_ARG: Local = Local::from_u32(1); -/// Generator has not been resumed yet. -const UNRESUMED: usize = GeneratorArgs::UNRESUMED; -/// Generator has returned / is completed. -const RETURNED: usize = GeneratorArgs::RETURNED; -/// Generator has panicked and is poisoned. -const POISONED: usize = GeneratorArgs::POISONED; +/// Coroutine has not been resumed yet. +const UNRESUMED: usize = CoroutineArgs::UNRESUMED; +/// Coroutine has returned / is completed. +const RETURNED: usize = CoroutineArgs::RETURNED; +/// Coroutine has panicked and is poisoned. +const POISONED: usize = CoroutineArgs::POISONED; /// Number of variants to reserve in generator state. Corresponds to /// `UNRESUMED` (beginning of a generator) and `RETURNED`/`POISONED` @@ -249,9 +249,9 @@ struct TransformVisitor<'tcx> { } impl<'tcx> TransformVisitor<'tcx> { - // Make a `GeneratorState` or `Poll` variant assignment. + // Make a `CoroutineState` or `Poll` variant assignment. // - // `core::ops::GeneratorState` only has single element tuple variants, + // `core::ops::CoroutineState` only has single element tuple variants, // so we can just write to the downcasted first field and then set the // discriminant to the appropriate variant. fn make_state( @@ -262,8 +262,8 @@ fn make_state( statements: &mut Vec>, ) { let idx = VariantIdx::new(match (is_return, self.is_async_kind) { - (true, false) => 1, // GeneratorState::Complete - (false, false) => 0, // GeneratorState::Yielded + (true, false) => 1, // CoroutineState::Complete + (false, false) => 0, // CoroutineState::Yielded (true, true) => 0, // Poll::Ready (false, true) => 1, // Poll::Pending }); @@ -285,7 +285,7 @@ fn make_state( return; } - // else: `Poll::Ready(x)`, `GeneratorState::Yielded(x)` or `GeneratorState::Complete(x)` + // else: `Poll::Ready(x)`, `CoroutineState::Yielded(x)` or `CoroutineState::Complete(x)` assert_eq!(self.state_adt_ref.variant(idx).fields.len(), 1); statements.push(Statement { @@ -565,10 +565,10 @@ fn replace_resume_ty_local<'tcx>( struct LivenessInfo { /// Which locals are live across any suspension point. - saved_locals: GeneratorSavedLocals, + saved_locals: CoroutineSavedLocals, /// The set of saved locals live at each suspension point. - live_locals_at_suspension_points: Vec>, + live_locals_at_suspension_points: Vec>, /// Parallel vec to the above with SourceInfo for each yield terminator. source_info_at_suspension_points: Vec, @@ -576,7 +576,7 @@ struct LivenessInfo { /// For every saved local, the set of other saved locals that are /// storage-live at the same time as this local. We cannot overlap locals in /// the layout which have conflicting storage. - storage_conflicts: BitMatrix, + storage_conflicts: BitMatrix, /// For every suspending block, the locals which are storage-live across /// that suspension point. @@ -674,7 +674,7 @@ fn locals_live_across_suspend_points<'tcx>( } debug!("live_locals_anywhere = {:?}", live_locals_at_any_suspension_point); - let saved_locals = GeneratorSavedLocals(live_locals_at_any_suspension_point); + let saved_locals = CoroutineSavedLocals(live_locals_at_any_suspension_point); // Renumber our liveness_map bitsets to include only the locals we are // saving. @@ -701,21 +701,21 @@ fn locals_live_across_suspend_points<'tcx>( /// The set of `Local`s that must be saved across yield points. /// -/// `GeneratorSavedLocal` is indexed in terms of the elements in this set; -/// i.e. `GeneratorSavedLocal::new(1)` corresponds to the second local +/// `CoroutineSavedLocal` is indexed in terms of the elements in this set; +/// i.e. `CoroutineSavedLocal::new(1)` corresponds to the second local /// included in this set. -struct GeneratorSavedLocals(BitSet); +struct CoroutineSavedLocals(BitSet); -impl GeneratorSavedLocals { - /// Returns an iterator over each `GeneratorSavedLocal` along with the `Local` it corresponds +impl CoroutineSavedLocals { + /// Returns an iterator over each `CoroutineSavedLocal` along with the `Local` it corresponds /// to. - fn iter_enumerated(&self) -> impl '_ + Iterator { - self.iter().enumerate().map(|(i, l)| (GeneratorSavedLocal::from(i), l)) + fn iter_enumerated(&self) -> impl '_ + Iterator { + self.iter().enumerate().map(|(i, l)| (CoroutineSavedLocal::from(i), l)) } /// Transforms a `BitSet` that contains only locals saved across yield points to the - /// equivalent `BitSet`. - fn renumber_bitset(&self, input: &BitSet) -> BitSet { + /// equivalent `BitSet`. + fn renumber_bitset(&self, input: &BitSet) -> BitSet { assert!(self.superset(&input), "{:?} not a superset of {:?}", self.0, input); let mut out = BitSet::new_empty(self.count()); for (saved_local, local) in self.iter_enumerated() { @@ -726,17 +726,17 @@ fn renumber_bitset(&self, input: &BitSet) -> BitSet out } - fn get(&self, local: Local) -> Option { + fn get(&self, local: Local) -> Option { if !self.contains(local) { return None; } let idx = self.iter().take_while(|&l| l < local).count(); - Some(GeneratorSavedLocal::new(idx)) + Some(CoroutineSavedLocal::new(idx)) } } -impl ops::Deref for GeneratorSavedLocals { +impl ops::Deref for CoroutineSavedLocals { type Target = BitSet; fn deref(&self) -> &Self::Target { @@ -747,13 +747,13 @@ fn deref(&self) -> &Self::Target { /// For every saved local, looks for which locals are StorageLive at the same /// time. Generates a bitset for every local of all the other locals that may be /// StorageLive simultaneously with that local. This is used in the layout -/// computation; see `GeneratorLayout` for more. +/// computation; see `CoroutineLayout` for more. fn compute_storage_conflicts<'mir, 'tcx>( body: &'mir Body<'tcx>, - saved_locals: &GeneratorSavedLocals, + saved_locals: &CoroutineSavedLocals, always_live_locals: BitSet, mut requires_storage: rustc_mir_dataflow::Results<'tcx, MaybeRequiresStorage<'_, 'mir, 'tcx>>, -) -> BitMatrix { +) -> BitMatrix { assert_eq!(body.local_decls.len(), saved_locals.domain_size()); debug!("compute_storage_conflicts({:?})", body.span); @@ -775,7 +775,7 @@ fn compute_storage_conflicts<'mir, 'tcx>( let local_conflicts = visitor.local_conflicts; - // Compress the matrix using only stored locals (Local -> GeneratorSavedLocal). + // Compress the matrix using only stored locals (Local -> CoroutineSavedLocal). // // NOTE: Today we store a full conflict bitset for every local. Technically // this is twice as many bits as we need, since the relation is symmetric. @@ -801,7 +801,7 @@ fn compute_storage_conflicts<'mir, 'tcx>( struct StorageConflictVisitor<'mir, 'tcx, 's> { body: &'mir Body<'tcx>, - saved_locals: &'s GeneratorSavedLocals, + saved_locals: &'s CoroutineSavedLocals, // FIXME(tmandry): Consider using sparse bitsets here once we have good // benchmarks for generators. local_conflicts: BitMatrix, @@ -858,7 +858,7 @@ fn compute_layout<'tcx>( body: &Body<'tcx>, ) -> ( FxHashMap, VariantIdx, FieldIdx)>, - GeneratorLayout<'tcx>, + CoroutineLayout<'tcx>, IndexVec>>, ) { let LivenessInfo { @@ -870,8 +870,8 @@ fn compute_layout<'tcx>( } = liveness; // Gather live local types and their indices. - let mut locals = IndexVec::::new(); - let mut tys = IndexVec::::new(); + let mut locals = IndexVec::::new(); + let mut tys = IndexVec::::new(); for (saved_local, local) in saved_locals.iter_enumerated() { debug!("generator saved local {:?} => {:?}", saved_local, local); @@ -895,7 +895,7 @@ fn compute_layout<'tcx>( _ => false, }; let decl = - GeneratorSavedTy { ty: decl.ty, source_info: decl.source_info, ignore_for_traits }; + CoroutineSavedTy { ty: decl.ty, source_info: decl.source_info, ignore_for_traits }; debug!(?decl); tys.push(decl); @@ -916,7 +916,7 @@ fn compute_layout<'tcx>( // Build the generator variant field list. // Create a map from local indices to generator struct indices. - let mut variant_fields: IndexVec> = + let mut variant_fields: IndexVec> = iter::repeat(IndexVec::new()).take(RESERVED_VARIANTS).collect(); let mut remap = FxHashMap::default(); for (suspension_point_idx, live_locals) in live_locals_at_suspension_points.iter().enumerate() { @@ -947,7 +947,7 @@ fn compute_layout<'tcx>( field_names.get_or_insert_with(saved_local, || var.name); } - let layout = GeneratorLayout { + let layout = CoroutineLayout { field_tys: tys, field_names, variant_fields, @@ -1070,7 +1070,7 @@ fn create_generator_drop_shim<'tcx>( for block in body.basic_blocks_mut() { let kind = &mut block.terminator_mut().kind; - if let TerminatorKind::GeneratorDrop = *kind { + if let TerminatorKind::CoroutineDrop = *kind { *kind = TerminatorKind::Return; } } @@ -1182,7 +1182,7 @@ fn can_unwind<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>) -> bool { | TerminatorKind::UnwindTerminate(_) | TerminatorKind::Return | TerminatorKind::Unreachable - | TerminatorKind::GeneratorDrop + | TerminatorKind::CoroutineDrop | TerminatorKind::FalseEdge { .. } | TerminatorKind::FalseUnwind { .. } => {} @@ -1384,7 +1384,7 @@ fn create_cases<'tcx>( pub(crate) fn mir_generator_witnesses<'tcx>( tcx: TyCtxt<'tcx>, def_id: LocalDefId, -) -> Option> { +) -> Option> { let (body, _) = tcx.mir_promoted(def_id); let body = body.borrow(); let body = &*body; @@ -1394,7 +1394,7 @@ pub(crate) fn mir_generator_witnesses<'tcx>( // Get the interior types and args which typeck computed let movable = match *gen_ty.kind() { - ty::Generator(_, _, movability) => movability == hir::Movability::Movable, + ty::Coroutine(_, _, movability) => movability == hir::Movability::Movable, ty::Error(_) => return None, _ => span_bug!(body.span, "unexpected generator type {}", gen_ty), }; @@ -1428,7 +1428,7 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { // Get the discriminant type and args which typeck computed let (discr_ty, movable) = match *gen_ty.kind() { - ty::Generator(_, args, movability) => { + ty::Coroutine(_, args, movability) => { let args = args.as_generator(); (args.discr_ty(tcx), movability == hir::Movability::Movable) } @@ -1438,7 +1438,7 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { } }; - let is_async_kind = matches!(body.generator_kind(), Some(GeneratorKind::Async(_))); + let is_async_kind = matches!(body.generator_kind(), Some(CoroutineKind::Async(_))); let (state_adt_ref, state_args) = if is_async_kind { // Compute Poll let poll_did = tcx.require_lang_item(LangItem::Poll, None); @@ -1446,8 +1446,8 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { let poll_args = tcx.mk_args(&[body.return_ty().into()]); (poll_adt_ref, poll_args) } else { - // Compute GeneratorState - let state_did = tcx.require_lang_item(LangItem::GeneratorState, None); + // Compute CoroutineState + let state_did = tcx.require_lang_item(LangItem::CoroutineState, None); let state_adt_ref = tcx.adt_def(state_did); let state_args = tcx.mk_args(&[yield_ty.into(), body.return_ty().into()]); (state_adt_ref, state_args) @@ -1495,7 +1495,7 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { locals_live_across_suspend_points(tcx, body, &always_live_locals, movable); if tcx.sess.opts.unstable_opts.validate_mir { - let mut vis = EnsureGeneratorFieldAssignmentsNeverAlias { + let mut vis = EnsureCoroutineFieldAssignmentsNeverAlias { assigned_local: None, saved_locals: &liveness_info.saved_locals, storage_conflicts: &liveness_info.storage_conflicts, @@ -1514,7 +1514,7 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { // Run the transformation which converts Places from Local to generator struct // accesses for locals in `remap`. // It also rewrites `return x` and `yield y` as writing a new generator state and returning - // either GeneratorState::Complete(x) and GeneratorState::Yielded(y), + // either CoroutineState::Complete(x) and CoroutineState::Yielded(y), // or Poll::Ready(x) and Poll::Pending respectively depending on `is_async_kind`. let mut transform = TransformVisitor { tcx, @@ -1563,7 +1563,7 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { body.generator.as_mut().unwrap().generator_drop = Some(drop_shim); - // Create the Generator::resume / Future::poll function + // Create the Coroutine::resume / Future::poll function create_generator_resume_function(tcx, transform, body, can_return); // Run derefer to fix Derefs that are not in the first place @@ -1583,14 +1583,14 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { /// sides of an assignment may not alias. This caused a miscompilation in [#73137]. /// /// [#73137]: https://github.com/rust-lang/rust/issues/73137 -struct EnsureGeneratorFieldAssignmentsNeverAlias<'a> { - saved_locals: &'a GeneratorSavedLocals, - storage_conflicts: &'a BitMatrix, - assigned_local: Option, +struct EnsureCoroutineFieldAssignmentsNeverAlias<'a> { + saved_locals: &'a CoroutineSavedLocals, + storage_conflicts: &'a BitMatrix, + assigned_local: Option, } -impl EnsureGeneratorFieldAssignmentsNeverAlias<'_> { - fn saved_local_for_direct_place(&self, place: Place<'_>) -> Option { +impl EnsureCoroutineFieldAssignmentsNeverAlias<'_> { + fn saved_local_for_direct_place(&self, place: Place<'_>) -> Option { if place.is_indirect() { return None; } @@ -1609,7 +1609,7 @@ fn check_assigned_place(&mut self, place: Place<'_>, f: impl FnOnce(&mut Self)) } } -impl<'tcx> Visitor<'tcx> for EnsureGeneratorFieldAssignmentsNeverAlias<'_> { +impl<'tcx> Visitor<'tcx> for EnsureCoroutineFieldAssignmentsNeverAlias<'_> { fn visit_place(&mut self, place: &Place<'tcx>, context: PlaceContext, location: Location) { let Some(lhs) = self.assigned_local else { // This visitor only invokes `visit_place` for the right-hand side of an assignment @@ -1691,14 +1691,14 @@ fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location | TerminatorKind::Unreachable | TerminatorKind::Drop { .. } | TerminatorKind::Assert { .. } - | TerminatorKind::GeneratorDrop + | TerminatorKind::CoroutineDrop | TerminatorKind::FalseEdge { .. } | TerminatorKind::FalseUnwind { .. } => {} } } } -fn check_suspend_tys<'tcx>(tcx: TyCtxt<'tcx>, layout: &GeneratorLayout<'tcx>, body: &Body<'tcx>) { +fn check_suspend_tys<'tcx>(tcx: TyCtxt<'tcx>, layout: &CoroutineLayout<'tcx>, body: &Body<'tcx>) { let mut linted_tys = FxHashSet::default(); // We want a user-facing param-env. diff --git a/compiler/rustc_mir_transform/src/gvn.rs b/compiler/rustc_mir_transform/src/gvn.rs index c710e460dcb..eece7c3e834 100644 --- a/compiler/rustc_mir_transform/src/gvn.rs +++ b/compiler/rustc_mir_transform/src/gvn.rs @@ -383,7 +383,7 @@ fn simplify_rvalue( AggregateKind::Array(..) | AggregateKind::Tuple | AggregateKind::Closure(..) - | AggregateKind::Generator(..) => FIRST_VARIANT, + | AggregateKind::Coroutine(..) => FIRST_VARIANT, AggregateKind::Adt(_, variant_index, _, _, None) => variant_index, // Do not track unions. AggregateKind::Adt(_, _, _, _, Some(_)) => return None, diff --git a/compiler/rustc_mir_transform/src/inline.rs b/compiler/rustc_mir_transform/src/inline.rs index 8f578b69694..60837cb4773 100644 --- a/compiler/rustc_mir_transform/src/inline.rs +++ b/compiler/rustc_mir_transform/src/inline.rs @@ -1014,7 +1014,7 @@ fn visit_terminator(&mut self, terminator: &mut Terminator<'tcx>, loc: Location) } match terminator.kind { - TerminatorKind::GeneratorDrop | TerminatorKind::Yield { .. } => bug!(), + TerminatorKind::CoroutineDrop | TerminatorKind::Yield { .. } => bug!(), TerminatorKind::Goto { ref mut target } => { *target = self.map_block(*target); } diff --git a/compiler/rustc_mir_transform/src/lib.rs b/compiler/rustc_mir_transform/src/lib.rs index d579420ecb8..ad2803b8c51 100644 --- a/compiler/rustc_mir_transform/src/lib.rs +++ b/compiler/rustc_mir_transform/src/lib.rs @@ -375,7 +375,7 @@ fn inner_mir_for_ctfe(tcx: TyCtxt<'_>, def: LocalDefId) -> Body<'_> { /// mir borrowck *before* doing so in order to ensure that borrowck can be run and doesn't /// end up missing the source MIR due to stealing happening. fn mir_drops_elaborated_and_const_checked(tcx: TyCtxt<'_>, def: LocalDefId) -> &Steal> { - if let DefKind::Generator = tcx.def_kind(def) { + if let DefKind::Coroutine = tcx.def_kind(def) { tcx.ensure_with_value().mir_generator_witnesses(def); } let mir_borrowck = tcx.mir_borrowck(def); diff --git a/compiler/rustc_mir_transform/src/remove_noop_landing_pads.rs b/compiler/rustc_mir_transform/src/remove_noop_landing_pads.rs index 8c48a667786..54892442c87 100644 --- a/compiler/rustc_mir_transform/src/remove_noop_landing_pads.rs +++ b/compiler/rustc_mir_transform/src/remove_noop_landing_pads.rs @@ -69,7 +69,7 @@ fn is_nop_landing_pad( | TerminatorKind::FalseUnwind { .. } => { terminator.successors().all(|succ| nop_landing_pads.contains(succ)) } - TerminatorKind::GeneratorDrop + TerminatorKind::CoroutineDrop | TerminatorKind::Yield { .. } | TerminatorKind::Return | TerminatorKind::UnwindTerminate(_) diff --git a/compiler/rustc_mir_transform/src/separate_const_switch.rs b/compiler/rustc_mir_transform/src/separate_const_switch.rs index e1e4acccccd..907cfe7581a 100644 --- a/compiler/rustc_mir_transform/src/separate_const_switch.rs +++ b/compiler/rustc_mir_transform/src/separate_const_switch.rs @@ -118,7 +118,7 @@ pub fn separate_const_switch(body: &mut Body<'_>) -> usize { | TerminatorKind::Return | TerminatorKind::Unreachable | TerminatorKind::InlineAsm { .. } - | TerminatorKind::GeneratorDrop => { + | TerminatorKind::CoroutineDrop => { continue 'predec_iter; } } @@ -169,7 +169,7 @@ pub fn separate_const_switch(body: &mut Body<'_>) -> usize { | TerminatorKind::UnwindTerminate(_) | TerminatorKind::Return | TerminatorKind::Unreachable - | TerminatorKind::GeneratorDrop + | TerminatorKind::CoroutineDrop | TerminatorKind::Assert { .. } | TerminatorKind::FalseUnwind { .. } | TerminatorKind::Drop { .. } diff --git a/compiler/rustc_mir_transform/src/shim.rs b/compiler/rustc_mir_transform/src/shim.rs index e9895d97dfe..3cf4430824a 100644 --- a/compiler/rustc_mir_transform/src/shim.rs +++ b/compiler/rustc_mir_transform/src/shim.rs @@ -4,7 +4,7 @@ use rustc_middle::mir::*; use rustc_middle::query::Providers; use rustc_middle::ty::GenericArgs; -use rustc_middle::ty::{self, EarlyBinder, GeneratorArgs, Ty, TyCtxt}; +use rustc_middle::ty::{self, CoroutineArgs, EarlyBinder, Ty, TyCtxt}; use rustc_target::abi::{FieldIdx, VariantIdx, FIRST_VARIANT}; use rustc_index::{Idx, IndexVec}; @@ -69,7 +69,7 @@ fn make_shim<'tcx>(tcx: TyCtxt<'tcx>, instance: ty::InstanceDef<'tcx>) -> Body<' ty::InstanceDef::DropGlue(def_id, ty) => { // FIXME(#91576): Drop shims for generators aren't subject to the MIR passes at the end // of this function. Is this intentional? - if let Some(ty::Generator(gen_def_id, args, _)) = ty.map(Ty::kind) { + if let Some(ty::Coroutine(gen_def_id, args, _)) = ty.map(Ty::kind) { let body = tcx.optimized_mir(*gen_def_id).generator_drop().unwrap(); let mut body = EarlyBinder::bind(body.clone()).instantiate(tcx, args); debug!("make_shim({:?}) = {:?}", instance, body); @@ -392,7 +392,7 @@ fn build_clone_shim<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, self_ty: Ty<'tcx>) - _ if is_copy => builder.copy_shim(), ty::Closure(_, args) => builder.tuple_like_shim(dest, src, args.as_closure().upvar_tys()), ty::Tuple(..) => builder.tuple_like_shim(dest, src, self_ty.tuple_fields()), - ty::Generator(gen_def_id, args, hir::Movability::Movable) => { + ty::Coroutine(gen_def_id, args, hir::Movability::Movable) => { builder.generator_shim(dest, src, *gen_def_id, args.as_generator()) } _ => bug!("clone shim for `{:?}` which is not `Copy` and is not an aggregate", self_ty), @@ -598,7 +598,7 @@ fn generator_shim( dest: Place<'tcx>, src: Place<'tcx>, gen_def_id: DefId, - args: GeneratorArgs<'tcx>, + args: CoroutineArgs<'tcx>, ) { self.block(vec![], TerminatorKind::Goto { target: self.block_index_offset(3) }, false); let unwind = self.block(vec![], TerminatorKind::UnwindResume, true); diff --git a/compiler/rustc_monomorphize/src/collector.rs b/compiler/rustc_monomorphize/src/collector.rs index eb1c7db026e..82fee7c8dfe 100644 --- a/compiler/rustc_monomorphize/src/collector.rs +++ b/compiler/rustc_monomorphize/src/collector.rs @@ -855,7 +855,7 @@ fn visit_terminator(&mut self, terminator: &mir::Terminator<'tcx>, location: Loc | mir::TerminatorKind::UnwindResume | mir::TerminatorKind::Return | mir::TerminatorKind::Unreachable => {} - mir::TerminatorKind::GeneratorDrop + mir::TerminatorKind::CoroutineDrop | mir::TerminatorKind::Yield { .. } | mir::TerminatorKind::FalseEdge { .. } | mir::TerminatorKind::FalseUnwind { .. } => bug!(), diff --git a/compiler/rustc_monomorphize/src/polymorphize.rs b/compiler/rustc_monomorphize/src/polymorphize.rs index 6c206a6bac8..33c167930a7 100644 --- a/compiler/rustc_monomorphize/src/polymorphize.rs +++ b/compiler/rustc_monomorphize/src/polymorphize.rs @@ -131,7 +131,7 @@ fn mark_used_by_default_parameters<'tcx>( unused_parameters: &mut UnusedGenericParams, ) { match tcx.def_kind(def_id) { - DefKind::Closure | DefKind::Generator => { + DefKind::Closure | DefKind::Coroutine => { for param in &generics.params { debug!(?param, "(closure/gen)"); unused_parameters.mark_used(param.index); @@ -248,7 +248,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MarkUsedGenericParams<'a, 'tcx> { fn visit_local_decl(&mut self, local: Local, local_decl: &LocalDecl<'tcx>) { if local == Local::from_usize(1) { let def_kind = self.tcx.def_kind(self.def_id); - if matches!(def_kind, DefKind::Closure | DefKind::Generator) { + if matches!(def_kind, DefKind::Closure | DefKind::Coroutine) { // Skip visiting the closure/generator that is currently being processed. This only // happens because the first argument to the closure is a reference to itself and // that will call `visit_args`, resulting in each generic parameter captured being @@ -319,7 +319,7 @@ fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow { } match *ty.kind() { - ty::Closure(def_id, args) | ty::Generator(def_id, args, ..) => { + ty::Closure(def_id, args) | ty::Coroutine(def_id, args, ..) => { debug!(?def_id); // Avoid cycle errors with generators. if def_id == self.def_id { diff --git a/compiler/rustc_passes/src/liveness.rs b/compiler/rustc_passes/src/liveness.rs index 1fe44b2b877..d068fe62473 100644 --- a/compiler/rustc_passes/src/liveness.rs +++ b/compiler/rustc_passes/src/liveness.rs @@ -706,7 +706,7 @@ fn compute(&mut self, body: &hir::Body<'_>, hir_id: HirId) -> LiveNode { // // When computing the liveness for captured variables we take into // account how variable is captured (ByRef vs ByValue) and what is the - // closure kind (Generator / FnOnce vs Fn / FnMut). + // closure kind (Coroutine / FnOnce vs Fn / FnMut). // // Variables captured by reference are assumed to be used on the exit // from the closure. @@ -752,7 +752,7 @@ fn compute(&mut self, body: &hir::Body<'_>, hir_id: HirId) -> LiveNode { ty::ClosureKind::FnMut => {} ty::ClosureKind::FnOnce => return succ, }, - ty::Generator(..) => return succ, + ty::Coroutine(..) => return succ, _ => { span_bug!( body.value.span, diff --git a/compiler/rustc_privacy/src/lib.rs b/compiler/rustc_privacy/src/lib.rs index 5599c6100a5..f2d6a0dff9c 100644 --- a/compiler/rustc_privacy/src/lib.rs +++ b/compiler/rustc_privacy/src/lib.rs @@ -188,7 +188,7 @@ fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow { | ty::Foreign(def_id) | ty::FnDef(def_id, ..) | ty::Closure(def_id, ..) - | ty::Generator(def_id, ..) => { + | ty::Coroutine(def_id, ..) => { self.def_id_visitor.visit_def_id(def_id, "type", &ty)?; if V::SHALLOW { return ControlFlow::Continue(()); @@ -294,7 +294,7 @@ fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow { | ty::Param(..) | ty::Bound(..) | ty::Error(_) - | ty::GeneratorWitness(..) => {} + | ty::CoroutineWitness(..) => {} ty::Placeholder(..) | ty::Infer(..) => { bug!("unexpected type: {:?}", ty) } @@ -666,7 +666,7 @@ fn update_macro_reachable_def( | DefKind::GlobalAsm | DefKind::Impl { .. } | DefKind::Closure - | DefKind::Generator => (), + | DefKind::Coroutine => (), } } } diff --git a/compiler/rustc_resolve/src/build_reduced_graph.rs b/compiler/rustc_resolve/src/build_reduced_graph.rs index a18109574fe..0407db528af 100644 --- a/compiler/rustc_resolve/src/build_reduced_graph.rs +++ b/compiler/rustc_resolve/src/build_reduced_graph.rs @@ -981,7 +981,7 @@ fn build_reduced_graph_for_external_crate_res(&mut self, child: &ModChild) { | DefKind::GlobalAsm | DefKind::Closure | DefKind::Impl { .. } - | DefKind::Generator, + | DefKind::Coroutine, _, ) | Res::Local(..) diff --git a/compiler/rustc_session/src/code_stats.rs b/compiler/rustc_session/src/code_stats.rs index df81e1f8305..0caa4453993 100644 --- a/compiler/rustc_session/src/code_stats.rs +++ b/compiler/rustc_session/src/code_stats.rs @@ -24,7 +24,7 @@ pub enum SizeKind { pub enum FieldKind { AdtField, Upvar, - GeneratorLocal, + CoroutineLocal, } impl std::fmt::Display for FieldKind { @@ -32,7 +32,7 @@ fn fmt(&self, w: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { FieldKind::AdtField => write!(w, "field"), FieldKind::Upvar => write!(w, "upvar"), - FieldKind::GeneratorLocal => write!(w, "local"), + FieldKind::CoroutineLocal => write!(w, "local"), } } } @@ -52,7 +52,7 @@ pub enum DataTypeKind { Union, Enum, Closure, - Generator, + Coroutine, } #[derive(PartialEq, Eq, Hash, Debug)] @@ -105,9 +105,9 @@ pub fn record_type_size( // Sort variants so the largest ones are shown first. A stable sort is // used here so that source code order is preserved for all variants // that have the same size. - // Except for Generators, whose variants are already sorted according to + // Except for Coroutines, whose variants are already sorted according to // their yield points in `variant_info_for_generator`. - if kind != DataTypeKind::Generator { + if kind != DataTypeKind::Coroutine { variants.sort_by_key(|info| cmp::Reverse(info.size)); } let info = TypeSizeInfo { @@ -160,7 +160,7 @@ pub fn print_type_sizes(&self) { let struct_like = match kind { DataTypeKind::Struct | DataTypeKind::Closure => true, - DataTypeKind::Enum | DataTypeKind::Union | DataTypeKind::Generator => false, + DataTypeKind::Enum | DataTypeKind::Union | DataTypeKind::Coroutine => false, }; for (i, variant_info) in variants.into_iter().enumerate() { let VariantInfo { ref name, kind: _, align: _, size, ref fields } = *variant_info; diff --git a/compiler/rustc_smir/src/rustc_internal/mod.rs b/compiler/rustc_smir/src/rustc_internal/mod.rs index 5ea805e5739..7feeb63c23a 100644 --- a/compiler/rustc_smir/src/rustc_internal/mod.rs +++ b/compiler/rustc_smir/src/rustc_internal/mod.rs @@ -59,8 +59,8 @@ pub fn closure_def(&mut self, did: DefId) -> stable_mir::ty::ClosureDef { stable_mir::ty::ClosureDef(self.create_def_id(did)) } - pub fn generator_def(&mut self, did: DefId) -> stable_mir::ty::GeneratorDef { - stable_mir::ty::GeneratorDef(self.create_def_id(did)) + pub fn generator_def(&mut self, did: DefId) -> stable_mir::ty::CoroutineDef { + stable_mir::ty::CoroutineDef(self.create_def_id(did)) } pub fn alias_def(&mut self, did: DefId) -> stable_mir::ty::AliasDef { diff --git a/compiler/rustc_smir/src/rustc_smir/mod.rs b/compiler/rustc_smir/src/rustc_smir/mod.rs index 94dc15b4767..cb5f50e1cfc 100644 --- a/compiler/rustc_smir/src/rustc_smir/mod.rs +++ b/compiler/rustc_smir/src/rustc_smir/mod.rs @@ -849,8 +849,8 @@ fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T { generic_arg.stable(tables), ) } - mir::AggregateKind::Generator(def_id, generic_arg, movability) => { - stable_mir::mir::AggregateKind::Generator( + mir::AggregateKind::Coroutine(def_id, generic_arg, movability) => { + stable_mir::mir::AggregateKind::Coroutine( tables.generator_def(*def_id), generic_arg.stable(tables), movability.stable(tables), @@ -860,20 +860,20 @@ fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T { } } -impl<'tcx> Stable<'tcx> for rustc_hir::GeneratorKind { - type T = stable_mir::mir::GeneratorKind; +impl<'tcx> Stable<'tcx> for rustc_hir::CoroutineKind { + type T = stable_mir::mir::CoroutineKind; fn stable(&self, _: &mut Tables<'tcx>) -> Self::T { - use rustc_hir::{AsyncGeneratorKind, GeneratorKind}; + use rustc_hir::{AsyncCoroutineKind, CoroutineKind}; match self { - GeneratorKind::Async(async_gen) => { + CoroutineKind::Async(async_gen) => { let async_gen = match async_gen { - AsyncGeneratorKind::Block => stable_mir::mir::AsyncGeneratorKind::Block, - AsyncGeneratorKind::Closure => stable_mir::mir::AsyncGeneratorKind::Closure, - AsyncGeneratorKind::Fn => stable_mir::mir::AsyncGeneratorKind::Fn, + AsyncCoroutineKind::Block => stable_mir::mir::AsyncCoroutineKind::Block, + AsyncCoroutineKind::Closure => stable_mir::mir::AsyncCoroutineKind::Closure, + AsyncCoroutineKind::Fn => stable_mir::mir::AsyncCoroutineKind::Fn, }; - stable_mir::mir::GeneratorKind::Async(async_gen) + stable_mir::mir::CoroutineKind::Async(async_gen) } - GeneratorKind::Gen => stable_mir::mir::GeneratorKind::Gen, + CoroutineKind::Gen => stable_mir::mir::CoroutineKind::Gen, } } } @@ -976,7 +976,7 @@ fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T { unwind: unwind.stable(tables), }, mir::TerminatorKind::Yield { .. } - | mir::TerminatorKind::GeneratorDrop + | mir::TerminatorKind::CoroutineDrop | mir::TerminatorKind::FalseEdge { .. } | mir::TerminatorKind::FalseUnwind { .. } => unreachable!(), } @@ -1231,7 +1231,7 @@ fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T { tables.closure_def(*def_id), generic_args.stable(tables), )), - ty::Generator(def_id, generic_args, movability) => TyKind::RigidTy(RigidTy::Generator( + ty::Coroutine(def_id, generic_args, movability) => TyKind::RigidTy(RigidTy::Coroutine( tables.generator_def(*def_id), generic_args.stable(tables), movability.stable(tables), @@ -1247,7 +1247,7 @@ fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T { ty::Bound(debruijn_idx, bound_ty) => { TyKind::Bound(debruijn_idx.as_usize(), bound_ty.stable(tables)) } - ty::Placeholder(..) | ty::GeneratorWitness(..) | ty::Infer(_) | ty::Error(_) => { + ty::Placeholder(..) | ty::CoroutineWitness(..) | ty::Infer(_) | ty::Error(_) => { unreachable!(); } } diff --git a/compiler/rustc_symbol_mangling/src/legacy.rs b/compiler/rustc_symbol_mangling/src/legacy.rs index 5290da9a25b..5f22b89ea49 100644 --- a/compiler/rustc_symbol_mangling/src/legacy.rs +++ b/compiler/rustc_symbol_mangling/src/legacy.rs @@ -214,7 +214,7 @@ fn print_type(mut self, ty: Ty<'tcx>) -> Result { ty::FnDef(def_id, args) | ty::Alias(ty::Projection | ty::Opaque, ty::AliasTy { def_id, args, .. }) | ty::Closure(def_id, args) - | ty::Generator(def_id, args, _) => self.print_def_path(def_id, args), + | ty::Coroutine(def_id, args, _) => self.print_def_path(def_id, args), // The `pretty_print_type` formatting of array size depends on // -Zverbose flag, so we cannot reuse it here. @@ -284,7 +284,7 @@ fn path_qualified( // Similar to `pretty_path_qualified`, but for the other // types that are printed as paths (see `print_type` above). match self_ty.kind() { - ty::FnDef(..) | ty::Alias(..) | ty::Closure(..) | ty::Generator(..) + ty::FnDef(..) | ty::Alias(..) | ty::Closure(..) | ty::Coroutine(..) if trait_ref.is_none() => { self.print_type(self_ty) diff --git a/compiler/rustc_symbol_mangling/src/lib.rs b/compiler/rustc_symbol_mangling/src/lib.rs index 6ade2d777c7..7b4ab67a24d 100644 --- a/compiler/rustc_symbol_mangling/src/lib.rs +++ b/compiler/rustc_symbol_mangling/src/lib.rs @@ -238,7 +238,7 @@ fn compute_symbol_name<'tcx>( // and we want to be sure to avoid any symbol conflicts here. let is_globally_shared_function = matches!( tcx.def_kind(instance.def_id()), - DefKind::Fn | DefKind::AssocFn | DefKind::Closure | DefKind::Generator | DefKind::Ctor(..) + DefKind::Fn | DefKind::AssocFn | DefKind::Closure | DefKind::Coroutine | DefKind::Ctor(..) ) && matches!( MonoItem::Fn(instance).instantiation_mode(tcx), InstantiationMode::GloballyShared { may_conflict: true } diff --git a/compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs b/compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs index 6ad3e7155e8..fc186462a26 100644 --- a/compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs +++ b/compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs @@ -639,7 +639,7 @@ fn encode_ty<'tcx>( typeid.push_str(&s); } - ty::Generator(def_id, args, ..) => { + ty::Coroutine(def_id, args, ..) => { // u[IE], where is , // as vendor extended type. let mut s = String::new(); @@ -719,7 +719,7 @@ fn encode_ty<'tcx>( ty::Alias(..) | ty::Bound(..) | ty::Error(..) - | ty::GeneratorWitness(..) + | ty::CoroutineWitness(..) | ty::Infer(..) | ty::Placeholder(..) => { bug!("encode_ty: unexpected `{:?}`", ty.kind()); @@ -778,7 +778,7 @@ fn transform_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, options: TransformTyOptio | ty::Str | ty::Never | ty::Foreign(..) - | ty::GeneratorWitness(..) => {} + | ty::CoroutineWitness(..) => {} ty::Bool => { if options.contains(EncodeTyOptions::NORMALIZE_INTEGERS) { @@ -892,7 +892,7 @@ fn transform_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, options: TransformTyOptio ty = Ty::new_closure(tcx, *def_id, transform_args(tcx, args, options)); } - ty::Generator(def_id, args, movability) => { + ty::Coroutine(def_id, args, movability) => { ty = Ty::new_generator(tcx, *def_id, transform_args(tcx, args, options), *movability); } diff --git a/compiler/rustc_symbol_mangling/src/v0.rs b/compiler/rustc_symbol_mangling/src/v0.rs index 99c5d016439..89b8b1518b0 100644 --- a/compiler/rustc_symbol_mangling/src/v0.rs +++ b/compiler/rustc_symbol_mangling/src/v0.rs @@ -427,7 +427,7 @@ fn print_type(mut self, ty: Ty<'tcx>) -> Result { | ty::FnDef(def_id, args) | ty::Alias(ty::Projection | ty::Opaque, ty::AliasTy { def_id, args, .. }) | ty::Closure(def_id, args) - | ty::Generator(def_id, args, _) => { + | ty::Coroutine(def_id, args, _) => { self = self.print_def_path(def_id, args)?; } ty::Foreign(def_id) => { @@ -476,7 +476,7 @@ fn print_type(mut self, ty: Ty<'tcx>) -> Result { ty::Alias(ty::Inherent, _) => bug!("symbol_names: unexpected inherent projection"), ty::Alias(ty::Weak, _) => bug!("symbol_names: unexpected weak projection"), - ty::GeneratorWitness(..) => bug!("symbol_names: unexpected `GeneratorWitness`"), + ty::CoroutineWitness(..) => bug!("symbol_names: unexpected `CoroutineWitness`"), } // Only cache types that do not refer to an enclosing diff --git a/compiler/rustc_trait_selection/src/solve/assembly/mod.rs b/compiler/rustc_trait_selection/src/solve/assembly/mod.rs index 23d2c0c4ea0..68f872308a7 100644 --- a/compiler/rustc_trait_selection/src/solve/assembly/mod.rs +++ b/compiler/rustc_trait_selection/src/solve/assembly/mod.rs @@ -200,7 +200,7 @@ fn consider_builtin_future_candidate( ) -> QueryResult<'tcx>; /// A generator (that doesn't come from an `async` desugaring) is known to - /// implement `Generator`, given the resume, yield, + /// implement `Coroutine`, given the resume, yield, /// and return types of the generator computed during type-checking. fn consider_builtin_generator_candidate( ecx: &mut EvalCtxt<'_, 'tcx>, @@ -410,7 +410,7 @@ fn assemble_non_blanket_impl_candidates>( | ty::FnPtr(_) | ty::Dynamic(_, _, _) | ty::Closure(_, _) - | ty::Generator(_, _, _) + | ty::Coroutine(_, _, _) | ty::Never | ty::Tuple(_) => { let simp = @@ -469,7 +469,7 @@ fn assemble_non_blanket_impl_candidates>( // FIXME: These should ideally not exist as a self type. It would be nice for // the builtin auto trait impls of generators to instead directly recurse // into the witness. - ty::GeneratorWitness(..) => (), + ty::CoroutineWitness(..) => (), // These variants should not exist as a self type. ty::Infer(ty::TyVar(_) | ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) @@ -620,8 +620,8 @@ fn assemble_alias_bound_candidates>( | ty::FnPtr(_) | ty::Dynamic(..) | ty::Closure(..) - | ty::Generator(..) - | ty::GeneratorWitness(..) + | ty::Coroutine(..) + | ty::CoroutineWitness(..) | ty::Never | ty::Tuple(_) | ty::Param(_) @@ -776,8 +776,8 @@ fn assemble_object_bound_candidates>( | ty::FnPtr(_) | ty::Alias(..) | ty::Closure(..) - | ty::Generator(..) - | ty::GeneratorWitness(..) + | ty::Coroutine(..) + | ty::CoroutineWitness(..) | ty::Never | ty::Tuple(_) | ty::Param(_) diff --git a/compiler/rustc_trait_selection/src/solve/assembly/structural_traits.rs b/compiler/rustc_trait_selection/src/solve/assembly/structural_traits.rs index 26c68acddff..afe1424daca 100644 --- a/compiler/rustc_trait_selection/src/solve/assembly/structural_traits.rs +++ b/compiler/rustc_trait_selection/src/solve/assembly/structural_traits.rs @@ -56,12 +56,12 @@ pub(in crate::solve) fn instantiate_constituent_tys_for_auto_trait<'tcx>( ty::Closure(_, ref args) => Ok(vec![args.as_closure().tupled_upvars_ty()]), - ty::Generator(_, ref args, _) => { + ty::Coroutine(_, ref args, _) => { let generator_args = args.as_generator(); Ok(vec![generator_args.tupled_upvars_ty(), generator_args.witness()]) } - ty::GeneratorWitness(def_id, args) => Ok(ecx + ty::CoroutineWitness(def_id, args) => Ok(ecx .tcx() .generator_hidden_types(def_id) .map(|bty| { @@ -122,8 +122,8 @@ pub(in crate::solve) fn instantiate_constituent_tys_for_sized_trait<'tcx>( | ty::RawPtr(..) | ty::Char | ty::Ref(..) - | ty::Generator(..) - | ty::GeneratorWitness(..) + | ty::Coroutine(..) + | ty::CoroutineWitness(..) | ty::Array(..) | ty::Closure(..) | ty::Never @@ -174,7 +174,7 @@ pub(in crate::solve) fn instantiate_constituent_tys_for_copy_clone_trait<'tcx>( ty::Dynamic(..) | ty::Str | ty::Slice(_) - | ty::Generator(_, _, Movability::Static) + | ty::Coroutine(_, _, Movability::Static) | ty::Foreign(..) | ty::Ref(_, _, Mutability::Mut) | ty::Adt(_, _) @@ -191,7 +191,7 @@ pub(in crate::solve) fn instantiate_constituent_tys_for_copy_clone_trait<'tcx>( ty::Closure(_, args) => Ok(vec![args.as_closure().tupled_upvars_ty()]), - ty::Generator(_, args, Movability::Movable) => { + ty::Coroutine(_, args, Movability::Movable) => { if ecx.tcx().features().generator_clone { let generator = args.as_generator(); Ok(vec![generator.tupled_upvars_ty(), generator.witness()]) @@ -200,7 +200,7 @@ pub(in crate::solve) fn instantiate_constituent_tys_for_copy_clone_trait<'tcx>( } } - ty::GeneratorWitness(def_id, args) => Ok(ecx + ty::CoroutineWitness(def_id, args) => Ok(ecx .tcx() .generator_hidden_types(def_id) .map(|bty| { @@ -275,8 +275,8 @@ pub(in crate::solve) fn extract_tupled_inputs_and_output_from_callable<'tcx>( | ty::RawPtr(_) | ty::Ref(_, _, _) | ty::Dynamic(_, _, _) - | ty::Generator(_, _, _) - | ty::GeneratorWitness(..) + | ty::Coroutine(_, _, _) + | ty::CoroutineWitness(..) | ty::Never | ty::Tuple(_) | ty::Alias(_, _) diff --git a/compiler/rustc_trait_selection/src/solve/canonicalize.rs b/compiler/rustc_trait_selection/src/solve/canonicalize.rs index aa92b924ef2..19f0c9fe826 100644 --- a/compiler/rustc_trait_selection/src/solve/canonicalize.rs +++ b/compiler/rustc_trait_selection/src/solve/canonicalize.rs @@ -329,8 +329,8 @@ fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> { | ty::FnPtr(_) | ty::Dynamic(_, _, _) | ty::Closure(_, _) - | ty::Generator(_, _, _) - | ty::GeneratorWitness(..) + | ty::Coroutine(_, _, _) + | ty::CoroutineWitness(..) | ty::Never | ty::Tuple(_) | ty::Alias(_, _) diff --git a/compiler/rustc_trait_selection/src/solve/project_goals/mod.rs b/compiler/rustc_trait_selection/src/solve/project_goals/mod.rs index 73c8d0c85dd..d5f22a2e5f2 100644 --- a/compiler/rustc_trait_selection/src/solve/project_goals/mod.rs +++ b/compiler/rustc_trait_selection/src/solve/project_goals/mod.rs @@ -392,8 +392,8 @@ fn consider_builtin_pointee_candidate( | ty::FnPtr(..) | ty::Closure(..) | ty::Infer(ty::IntVar(..) | ty::FloatVar(..)) - | ty::Generator(..) - | ty::GeneratorWitness(..) + | ty::Coroutine(..) + | ty::CoroutineWitness(..) | ty::Never | ty::Foreign(..) => tcx.types.unit, @@ -459,11 +459,11 @@ fn consider_builtin_future_candidate( goal: Goal<'tcx, Self>, ) -> QueryResult<'tcx> { let self_ty = goal.predicate.self_ty(); - let ty::Generator(def_id, args, _) = *self_ty.kind() else { + let ty::Coroutine(def_id, args, _) = *self_ty.kind() else { return Err(NoSolution); }; - // Generators are not futures unless they come from `async` desugaring + // Coroutines are not futures unless they come from `async` desugaring let tcx = ecx.tcx(); if !tcx.generator_is_async(def_id) { return Err(NoSolution); @@ -490,7 +490,7 @@ fn consider_builtin_generator_candidate( goal: Goal<'tcx, Self>, ) -> QueryResult<'tcx> { let self_ty = goal.predicate.self_ty(); - let ty::Generator(def_id, args, _) = *self_ty.kind() else { + let ty::Coroutine(def_id, args, _) = *self_ty.kind() else { return Err(NoSolution); }; @@ -508,7 +508,7 @@ fn consider_builtin_generator_candidate( } else if name == sym::Yield { generator.yield_ty().into() } else { - bug!("unexpected associated item `<{self_ty} as Generator>::{name}`") + bug!("unexpected associated item `<{self_ty} as Coroutine>::{name}`") }; Self::consider_implied_clause( @@ -561,8 +561,8 @@ fn consider_builtin_discriminant_kind_candidate( | ty::FnPtr(..) | ty::Closure(..) | ty::Infer(ty::IntVar(..) | ty::FloatVar(..)) - | ty::Generator(..) - | ty::GeneratorWitness(..) + | ty::Coroutine(..) + | ty::CoroutineWitness(..) | ty::Never | ty::Foreign(..) | ty::Adt(_, _) diff --git a/compiler/rustc_trait_selection/src/solve/trait_goals.rs b/compiler/rustc_trait_selection/src/solve/trait_goals.rs index d87e05ad02f..3aac24f82e7 100644 --- a/compiler/rustc_trait_selection/src/solve/trait_goals.rs +++ b/compiler/rustc_trait_selection/src/solve/trait_goals.rs @@ -319,11 +319,11 @@ fn consider_builtin_future_candidate( return Err(NoSolution); } - let ty::Generator(def_id, _, _) = *goal.predicate.self_ty().kind() else { + let ty::Coroutine(def_id, _, _) = *goal.predicate.self_ty().kind() else { return Err(NoSolution); }; - // Generators are not futures unless they come from `async` desugaring + // Coroutines are not futures unless they come from `async` desugaring let tcx = ecx.tcx(); if !tcx.generator_is_async(def_id) { return Err(NoSolution); @@ -344,7 +344,7 @@ fn consider_builtin_generator_candidate( } let self_ty = goal.predicate.self_ty(); - let ty::Generator(def_id, args, _) = *self_ty.kind() else { + let ty::Coroutine(def_id, args, _) = *self_ty.kind() else { return Err(NoSolution); }; @@ -844,10 +844,10 @@ fn disqualify_auto_trait_candidate_due_to_possible_impl( ty::Infer(_) | ty::Bound(_, _) => bug!("unexpected type `{self_ty}`"), - // Generators have one special built-in candidate, `Unpin`, which + // Coroutines have one special built-in candidate, `Unpin`, which // takes precedence over the structural auto trait candidate being // assembled. - ty::Generator(_, _, movability) + ty::Coroutine(_, _, movability) if Some(goal.predicate.def_id()) == self.tcx().lang_items().unpin_trait() => { match movability { @@ -879,8 +879,8 @@ fn disqualify_auto_trait_candidate_due_to_possible_impl( | ty::FnDef(_, _) | ty::FnPtr(_) | ty::Closure(_, _) - | ty::Generator(_, _, _) - | ty::GeneratorWitness(..) + | ty::Coroutine(_, _, _) + | ty::CoroutineWitness(..) | ty::Never | ty::Tuple(_) | ty::Adt(_, _) diff --git a/compiler/rustc_trait_selection/src/traits/coherence.rs b/compiler/rustc_trait_selection/src/traits/coherence.rs index acab4498a09..29b0c7189f9 100644 --- a/compiler/rustc_trait_selection/src/traits/coherence.rs +++ b/compiler/rustc_trait_selection/src/traits/coherence.rs @@ -817,7 +817,7 @@ fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow { } } ty::Error(_) => ControlFlow::Break(OrphanCheckEarlyExit::LocalTy(ty)), - ty::Closure(did, ..) | ty::Generator(did, ..) => { + ty::Closure(did, ..) | ty::Coroutine(did, ..) => { if self.def_id_is_local(did) { ControlFlow::Break(OrphanCheckEarlyExit::LocalTy(ty)) } else { @@ -827,7 +827,7 @@ fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow { // This should only be created when checking whether we have to check whether some // auto trait impl applies. There will never be multiple impls, so we can just // act as if it were a local type here. - ty::GeneratorWitness(..) => ControlFlow::Break(OrphanCheckEarlyExit::LocalTy(ty)), + ty::CoroutineWitness(..) => ControlFlow::Break(OrphanCheckEarlyExit::LocalTy(ty)), ty::Alias(ty::Opaque, ..) => { // This merits some explanation. // Normally, opaque types are not involved when performing diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index 66529b67c17..ab965357cf2 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -22,7 +22,7 @@ use rustc_hir::intravisit::Visitor; use rustc_hir::is_range_literal; use rustc_hir::lang_items::LangItem; -use rustc_hir::{AsyncGeneratorKind, GeneratorKind, Node}; +use rustc_hir::{AsyncCoroutineKind, CoroutineKind, Node}; use rustc_hir::{Expr, HirId}; use rustc_infer::infer::error_reporting::TypeErrCtxt; use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind}; @@ -47,7 +47,7 @@ use rustc_middle::ty::print::{with_forced_trimmed_paths, with_no_trimmed_paths}; #[derive(Debug)] -pub enum GeneratorInteriorOrUpvar { +pub enum CoroutineInteriorOrUpvar { // span of interior type Interior(Span, Option<(Span, Option)>), // span of upvar @@ -57,9 +57,9 @@ pub enum GeneratorInteriorOrUpvar { // This type provides a uniform interface to retrieve data on generators, whether it originated from // the local crate being compiled or from a foreign crate. #[derive(Debug)] -struct GeneratorData<'tcx, 'a>(&'a TypeckResults<'tcx>); +struct CoroutineData<'tcx, 'a>(&'a TypeckResults<'tcx>); -impl<'tcx, 'a> GeneratorData<'tcx, 'a> { +impl<'tcx, 'a> CoroutineData<'tcx, 'a> { /// Try to get information about variables captured by the generator that matches a type we are /// looking for with `ty_matches` function. We uses it to find upvar which causes a failure to /// meet an obligation @@ -68,7 +68,7 @@ fn try_get_upvar_span( infer_context: &InferCtxt<'tcx>, generator_did: DefId, ty_matches: F, - ) -> Option + ) -> Option where F: Fn(ty::Binder<'tcx, Ty<'tcx>>) -> bool, { @@ -77,7 +77,7 @@ fn try_get_upvar_span( let upvar_ty = self.0.node_type(*upvar_id); let upvar_ty = infer_context.resolve_vars_if_possible(upvar_ty); ty_matches(ty::Binder::dummy(upvar_ty)) - .then(|| GeneratorInteriorOrUpvar::Upvar(upvar.span)) + .then(|| CoroutineInteriorOrUpvar::Upvar(upvar.span)) }) }) } @@ -244,7 +244,7 @@ fn maybe_note_obligation_cause_for_async_await( fn note_obligation_cause_for_async_await( &self, err: &mut Diagnostic, - interior_or_upvar_span: GeneratorInteriorOrUpvar, + interior_or_upvar_span: CoroutineInteriorOrUpvar, is_async: bool, outer_generator: Option, trait_pred: ty::TraitPredicate<'tcx>, @@ -1982,7 +1982,7 @@ pub(crate) fn build_fn_sig_ty<'tcx>( let argument_kind = match expected.skip_binder().self_ty().kind() { ty::Closure(..) => "closure", - ty::Generator(..) => "generator", + ty::Coroutine(..) => "generator", _ => "function", }; let mut err = struct_span_err!( @@ -2190,7 +2190,7 @@ fn maybe_note_obligation_cause_for_async_await( ); match *ty.kind() { - ty::Generator(did, ..) | ty::GeneratorWitness(did, _) => { + ty::Coroutine(did, ..) | ty::CoroutineWitness(did, _) => { generator = generator.or(Some(did)); outer_generator = Some(did); } @@ -2219,7 +2219,7 @@ fn maybe_note_obligation_cause_for_async_await( ); match *ty.kind() { - ty::Generator(did, ..) | ty::GeneratorWitness(did, ..) => { + ty::Coroutine(did, ..) | ty::CoroutineWitness(did, ..) => { generator = generator.or(Some(did)); outer_generator = Some(did); } @@ -2299,9 +2299,9 @@ fn maybe_note_obligation_cause_for_async_await( // cycles. If we can't use resolved types because the generator comes from another crate, // we still provide a targeted error but without all the relevant spans. let generator_data = match &self.typeck_results { - Some(t) if t.hir_owner.to_def_id() == generator_did_root => GeneratorData(&t), + Some(t) if t.hir_owner.to_def_id() == generator_did_root => CoroutineData(&t), _ if generator_did.is_local() => { - GeneratorData(self.tcx.typeck(generator_did.expect_local())) + CoroutineData(self.tcx.typeck(generator_did.expect_local())) } _ => return false, }; @@ -2331,7 +2331,7 @@ fn maybe_note_obligation_cause_for_async_await( let decl = &generator_info.field_tys[local]; debug!(?decl); if ty_matches(ty::Binder::dummy(decl.ty)) && !decl.ignore_for_traits { - interior_or_upvar_span = Some(GeneratorInteriorOrUpvar::Interior( + interior_or_upvar_span = Some(CoroutineInteriorOrUpvar::Interior( decl.source_info.span, Some((source_info.span, from_awaited_ty)), )); @@ -2347,7 +2347,7 @@ fn maybe_note_obligation_cause_for_async_await( } if interior_or_upvar_span.is_none() && !generator_did.is_local() { - interior_or_upvar_span = Some(GeneratorInteriorOrUpvar::Interior(span, None)); + interior_or_upvar_span = Some(CoroutineInteriorOrUpvar::Interior(span, None)); } debug!(?interior_or_upvar_span); @@ -2375,7 +2375,7 @@ fn maybe_note_obligation_cause_for_async_await( fn note_obligation_cause_for_async_await( &self, err: &mut Diagnostic, - interior_or_upvar_span: GeneratorInteriorOrUpvar, + interior_or_upvar_span: CoroutineInteriorOrUpvar, is_async: bool, outer_generator: Option, trait_pred: ty::TraitPredicate<'tcx>, @@ -2409,8 +2409,8 @@ fn note_obligation_cause_for_async_await( let message = outer_generator .and_then(|generator_did| { Some(match self.tcx.generator_kind(generator_did).unwrap() { - GeneratorKind::Gen => format!("generator is not {trait_name}"), - GeneratorKind::Async(AsyncGeneratorKind::Fn) => self + CoroutineKind::Gen => format!("generator is not {trait_name}"), + CoroutineKind::Async(AsyncCoroutineKind::Fn) => self .tcx .parent(generator_did) .as_local() @@ -2419,10 +2419,10 @@ fn note_obligation_cause_for_async_await( .map(|name| { format!("future returned by `{name}` is not {trait_name}") })?, - GeneratorKind::Async(AsyncGeneratorKind::Block) => { + CoroutineKind::Async(AsyncCoroutineKind::Block) => { format!("future created by async block is not {trait_name}") } - GeneratorKind::Async(AsyncGeneratorKind::Closure) => { + CoroutineKind::Async(AsyncCoroutineKind::Closure) => { format!("future created by async closure is not {trait_name}") } }) @@ -2475,7 +2475,7 @@ fn note_obligation_cause_for_async_await( ); }; match interior_or_upvar_span { - GeneratorInteriorOrUpvar::Interior(interior_span, interior_extra_info) => { + CoroutineInteriorOrUpvar::Interior(interior_span, interior_extra_info) => { if let Some((yield_span, from_awaited_ty)) = interior_extra_info { if let Some(await_span) = from_awaited_ty { // The type causing this obligation is one being awaited at await_span. @@ -2498,7 +2498,7 @@ fn note_obligation_cause_for_async_await( } } } - GeneratorInteriorOrUpvar::Upvar(upvar_span) => { + CoroutineInteriorOrUpvar::Upvar(upvar_span) => { // `Some((ref_ty, is_mut))` if `target_ty` is `&T` or `&mut T` and fails to impl `Send` let non_send = match target_ty.kind() { ty::Ref(_, ref_ty, mutability) => match self.evaluate_obligation(&obligation) { @@ -2880,10 +2880,10 @@ fn note_obligation_cause_code( err.span_label(span, "this closure captures all values by move"); } } - ObligationCauseCode::SizedGeneratorInterior(generator_def_id) => { + ObligationCauseCode::SizedCoroutineInterior(generator_def_id) => { let what = match self.tcx.generator_kind(generator_def_id) { - None | Some(hir::GeneratorKind::Gen) => "yield", - Some(hir::GeneratorKind::Async(..)) => "await", + None | Some(hir::CoroutineKind::Gen) => "yield", + Some(hir::CoroutineKind::Async(..)) => "await", }; err.note(format!( "all values live across `{what}` must have a statically known size" @@ -2905,7 +2905,7 @@ fn note_obligation_cause_code( return; } - // If the obligation for a tuple is set directly by a Generator or Closure, + // If the obligation for a tuple is set directly by a Coroutine or Closure, // then the tuple must be the one containing capture types. let is_upvar_tys_infer_tuple = if !matches!(ty.kind(), ty::Tuple(..)) { false @@ -2915,7 +2915,7 @@ fn note_obligation_cause_code( let parent_trait_ref = self.resolve_vars_if_possible(data.parent_trait_pred); let nested_ty = parent_trait_ref.skip_binder().self_ty(); - matches!(nested_ty.kind(), ty::Generator(..)) + matches!(nested_ty.kind(), ty::Coroutine(..)) || matches!(nested_ty.kind(), ty::Closure(..)) } else { false @@ -2935,7 +2935,7 @@ fn note_obligation_cause_code( }, ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) => { // If the previous type is async fn, this is the future generated by the body of an async function. - // Avoid printing it twice (it was already printed in the `ty::Generator` arm below). + // Avoid printing it twice (it was already printed in the `ty::Coroutine` arm below). let is_future = tcx.ty_is_opaque_future(ty); debug!( ?obligated_types, @@ -2944,7 +2944,7 @@ fn note_obligation_cause_code( ); if is_future && obligated_types.last().is_some_and(|ty| match ty.kind() { - ty::Generator(last_def_id, ..) => { + ty::Coroutine(last_def_id, ..) => { tcx.generator_is_async(*last_def_id) } _ => false, @@ -2954,7 +2954,7 @@ fn note_obligation_cause_code( } err.span_note(self.tcx.def_span(def_id), msg) } - ty::GeneratorWitness(def_id, args) => { + ty::CoroutineWitness(def_id, args) => { use std::fmt::Write; // FIXME: this is kind of an unusual format for rustc, can we make it more clear? @@ -2968,7 +2968,7 @@ fn note_obligation_cause_code( } err.note(msg.trim_end_matches(", ").to_string()) } - ty::Generator(def_id, _, _) => { + ty::Coroutine(def_id, _, _) => { let sp = self.tcx.def_span(def_id); // Special-case this to say "async block" instead of `[static generator]`. @@ -3271,7 +3271,7 @@ fn suggest_await_before_try( ) { if let Some(body_id) = self.tcx.hir().maybe_body_owned_by(obligation.cause.body_id) { let body = self.tcx.hir().body(body_id); - if let Some(hir::GeneratorKind::Async(_)) = body.generator_kind { + if let Some(hir::CoroutineKind::Async(_)) = body.generator_kind { let future_trait = self.tcx.require_lang_item(LangItem::Future, None); let self_ty = self.resolve_vars_if_possible(trait_pred.self_ty()); diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs index 640bd3fad7c..fe182c1fe09 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs @@ -1564,9 +1564,9 @@ fn type_category(tcx: TyCtxt<'_>, t: Ty<'_>) -> Option { ty::Alias(ty::Weak, ..) => Some(15), ty::Never => Some(16), ty::Adt(..) => Some(17), - ty::Generator(..) => Some(18), + ty::Coroutine(..) => Some(18), ty::Foreign(..) => Some(19), - ty::GeneratorWitness(..) => Some(20), + ty::CoroutineWitness(..) => Some(20), ty::Placeholder(..) | ty::Bound(..) | ty::Infer(..) | ty::Error(_) => None, } } @@ -1615,10 +1615,10 @@ fn type_category(tcx: TyCtxt<'_>, t: Ty<'_>) -> Option { fn describe_generator(&self, body_id: hir::BodyId) -> Option<&'static str> { self.tcx.hir().body(body_id).generator_kind.map(|gen_kind| match gen_kind { - hir::GeneratorKind::Gen => "a generator", - hir::GeneratorKind::Async(hir::AsyncGeneratorKind::Block) => "an async block", - hir::GeneratorKind::Async(hir::AsyncGeneratorKind::Fn) => "an async function", - hir::GeneratorKind::Async(hir::AsyncGeneratorKind::Closure) => "an async closure", + hir::CoroutineKind::Gen => "a generator", + hir::CoroutineKind::Async(hir::AsyncCoroutineKind::Block) => "an async block", + hir::CoroutineKind::Async(hir::AsyncCoroutineKind::Fn) => "an async function", + hir::CoroutineKind::Async(hir::AsyncCoroutineKind::Closure) => "an async closure", }) } @@ -3098,7 +3098,7 @@ fn report_type_parameter_mismatch_error( }; let found_did = match *found_trait_ty.kind() { - ty::Closure(did, _) | ty::Foreign(did) | ty::FnDef(did, _) | ty::Generator(did, ..) => { + ty::Closure(did, _) | ty::Foreign(did) | ty::FnDef(did, _) | ty::Coroutine(did, ..) => { Some(did) } ty::Adt(def, _) => Some(def.did()), diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs index b923926d28d..56a005297a8 100644 --- a/compiler/rustc_trait_selection/src/traits/project.rs +++ b/compiler/rustc_trait_selection/src/traits/project.rs @@ -1811,8 +1811,8 @@ fn assemble_candidates_from_impls<'cx, 'tcx>( | ty::FnPtr(..) | ty::Dynamic(..) | ty::Closure(..) - | ty::Generator(..) - | ty::GeneratorWitness(..) + | ty::Coroutine(..) + | ty::CoroutineWitness(..) | ty::Never | ty::Tuple(..) // Integers and floats always have `u8` as their discriminant. @@ -1860,8 +1860,8 @@ fn assemble_candidates_from_impls<'cx, 'tcx>( | ty::FnPtr(..) | ty::Dynamic(..) | ty::Closure(..) - | ty::Generator(..) - | ty::GeneratorWitness(..) + | ty::Coroutine(..) + | ty::CoroutineWitness(..) | ty::Never // Extern types have unit metadata, according to RFC 2850 | ty::Foreign(_) @@ -2035,7 +2035,7 @@ fn confirm_generator_candidate<'cx, 'tcx>( obligation: &ProjectionTyObligation<'tcx>, nested: Vec>, ) -> Progress<'tcx> { - let ty::Generator(_, args, _) = + let ty::Coroutine(_, args, _) = selcx.infcx.shallow_resolve(obligation.predicate.self_ty()).kind() else { unreachable!() @@ -2053,7 +2053,7 @@ fn confirm_generator_candidate<'cx, 'tcx>( let tcx = selcx.tcx(); - let gen_def_id = tcx.require_lang_item(LangItem::Generator, None); + let gen_def_id = tcx.require_lang_item(LangItem::Coroutine, None); let predicate = super::util::generator_trait_ref_and_outputs( tcx, @@ -2087,7 +2087,7 @@ fn confirm_future_candidate<'cx, 'tcx>( obligation: &ProjectionTyObligation<'tcx>, nested: Vec>, ) -> Progress<'tcx> { - let ty::Generator(_, args, _) = + let ty::Coroutine(_, args, _) = selcx.infcx.shallow_resolve(obligation.predicate.self_ty()).kind() else { unreachable!() diff --git a/compiler/rustc_trait_selection/src/traits/query/dropck_outlives.rs b/compiler/rustc_trait_selection/src/traits/query/dropck_outlives.rs index 86ea7a2bf83..2b39b1e1f90 100644 --- a/compiler/rustc_trait_selection/src/traits/query/dropck_outlives.rs +++ b/compiler/rustc_trait_selection/src/traits/query/dropck_outlives.rs @@ -35,7 +35,7 @@ pub fn trivial_dropck_outlives<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool { | ty::FnDef(..) | ty::FnPtr(_) | ty::Char - | ty::GeneratorWitness(..) + | ty::CoroutineWitness(..) | ty::RawPtr(_) | ty::Ref(..) | ty::Str @@ -72,7 +72,7 @@ pub fn trivial_dropck_outlives<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool { | ty::Placeholder(..) | ty::Infer(_) | ty::Bound(..) - | ty::Generator(..) => false, + | ty::Coroutine(..) => false, } } @@ -217,7 +217,7 @@ pub fn dtorck_constraint_for_ty_inner<'tcx>( | ty::Ref(..) | ty::FnDef(..) | ty::FnPtr(_) - | ty::GeneratorWitness(..) => { + | ty::CoroutineWitness(..) => { // these types never have a destructor } @@ -255,7 +255,7 @@ pub fn dtorck_constraint_for_ty_inner<'tcx>( })? } - ty::Generator(_, args, _movability) => { + ty::Coroutine(_, args, _movability) => { // rust-lang/rust#49918: types can be constructed, stored // in the interior, and sit idle when generator yields // (and is subsequently dropped). @@ -266,7 +266,7 @@ pub fn dtorck_constraint_for_ty_inner<'tcx>( // its interior). // // However, the interior's representation uses things like - // GeneratorWitness that explicitly assume they are not + // CoroutineWitness that explicitly assume they are not // traversed in such a manner. So instead, we will // simplify things for now by treating all generators as // if they were like trait objects, where its upvars must diff --git a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs index a8001577bcd..4059fb5004e 100644 --- a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs +++ b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs @@ -212,11 +212,11 @@ fn assemble_generator_candidates( let self_ty = obligation.self_ty().skip_binder(); match self_ty.kind() { // async constructs get lowered to a special kind of generator that - // should *not* `impl Generator`. - ty::Generator(did, ..) if !self.tcx().generator_is_async(*did) => { + // should *not* `impl Coroutine`. + ty::Coroutine(did, ..) if !self.tcx().generator_is_async(*did) => { debug!(?self_ty, ?obligation, "assemble_generator_candidates",); - candidates.vec.push(GeneratorCandidate); + candidates.vec.push(CoroutineCandidate); } ty::Infer(ty::TyVar(_)) => { debug!("assemble_generator_candidates: ambiguous self-type"); @@ -232,7 +232,7 @@ fn assemble_future_candidates( candidates: &mut SelectionCandidateSet<'tcx>, ) { let self_ty = obligation.self_ty().skip_binder(); - if let ty::Generator(did, ..) = self_ty.kind() { + if let ty::Coroutine(did, ..) = self_ty.kind() { // async constructs get lowered to a special kind of generator that // should directly `impl Future`. if self.tcx().generator_is_async(*did) { @@ -435,8 +435,8 @@ fn reject_fn_ptr_impls( | ty::RawPtr(_) | ty::Ref(_, _, _) | ty::Closure(_, _) - | ty::Generator(_, _, _) - | ty::GeneratorWitness(..) + | ty::Coroutine(_, _, _) + | ty::CoroutineWitness(..) | ty::Never | ty::Tuple(_) | ty::Error(_) => return true, @@ -513,7 +513,7 @@ fn assemble_candidates_from_auto_impls( // The auto impl might apply; we don't know. candidates.ambiguous = true; } - ty::Generator(_, _, movability) + ty::Coroutine(_, _, movability) if self.tcx().lang_items().unpin_trait() == Some(def_id) => { match movability { @@ -570,10 +570,10 @@ fn assemble_candidates_from_auto_impls( | ty::FnDef(..) | ty::FnPtr(_) | ty::Closure(_, _) - | ty::Generator(..) + | ty::Coroutine(..) | ty::Never | ty::Tuple(_) - | ty::GeneratorWitness(..) => { + | ty::CoroutineWitness(..) => { // Only consider auto impls if there are no manual impls for the root of `self_ty`. // // For example, we only consider auto candidates for `&i32: Auto` if no explicit impl @@ -947,9 +947,9 @@ fn assemble_const_destruct_candidates( | ty::Array(..) | ty::Slice(_) | ty::Closure(..) - | ty::Generator(..) + | ty::Coroutine(..) | ty::Tuple(_) - | ty::GeneratorWitness(..) => { + | ty::CoroutineWitness(..) => { // These are built-in, and cannot have a custom `impl const Destruct`. candidates.vec.push(ConstDestructCandidate(None)); } @@ -1021,8 +1021,8 @@ fn assemble_candidate_for_tuple( | ty::FnPtr(_) | ty::Dynamic(_, _, _) | ty::Closure(_, _) - | ty::Generator(_, _, _) - | ty::GeneratorWitness(..) + | ty::Coroutine(_, _, _) + | ty::CoroutineWitness(..) | ty::Never | ty::Alias(..) | ty::Param(_) @@ -1082,8 +1082,8 @@ fn assemble_candidates_for_fn_ptr_trait( | ty::Placeholder(..) | ty::Dynamic(..) | ty::Closure(..) - | ty::Generator(..) - | ty::GeneratorWitness(..) + | ty::Coroutine(..) + | ty::CoroutineWitness(..) | ty::Never | ty::Tuple(..) | ty::Alias(..) diff --git a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs index 08ee9c73bf8..bc918d76aaa 100644 --- a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs +++ b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs @@ -83,7 +83,7 @@ pub(super) fn confirm_candidate( ImplSource::Builtin(BuiltinImplSource::Misc, vtable_closure) } - GeneratorCandidate => { + CoroutineCandidate => { let vtable_generator = self.confirm_generator_candidate(obligation)?; ImplSource::Builtin(BuiltinImplSource::Misc, vtable_generator) } @@ -719,7 +719,7 @@ fn confirm_generator_candidate( // touch bound regions, they just capture the in-scope // type/region parameters. let self_ty = self.infcx.shallow_resolve(obligation.self_ty().skip_binder()); - let ty::Generator(generator_def_id, args, _) = *self_ty.kind() else { + let ty::Coroutine(generator_def_id, args, _) = *self_ty.kind() else { bug!("closure candidate for non-closure {:?}", obligation); }; @@ -758,7 +758,7 @@ fn confirm_future_candidate( // touch bound regions, they just capture the in-scope // type/region parameters. let self_ty = self.infcx.shallow_resolve(obligation.self_ty().skip_binder()); - let ty::Generator(generator_def_id, args, _) = *self_ty.kind() else { + let ty::Coroutine(generator_def_id, args, _) = *self_ty.kind() else { bug!("closure candidate for non-closure {:?}", obligation); }; @@ -1234,11 +1234,11 @@ fn confirm_const_destruct_candidate( ty::Closure(_, args) => { stack.push(args.as_closure().tupled_upvars_ty()); } - ty::Generator(_, args, _) => { + ty::Coroutine(_, args, _) => { let generator = args.as_generator(); stack.extend([generator.tupled_upvars_ty(), generator.witness()]); } - ty::GeneratorWitness(def_id, args) => { + ty::CoroutineWitness(def_id, args) => { let tcx = self.tcx(); stack.extend(tcx.generator_hidden_types(def_id).map(|bty| { let ty = bty.instantiate(tcx, args); diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs index 940ceca50d2..6592abd4388 100644 --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs @@ -1886,7 +1886,7 @@ fn candidate_should_be_dropped_in_favor_of( ImplCandidate(..) | AutoImplCandidate | ClosureCandidate { .. } - | GeneratorCandidate + | CoroutineCandidate | FutureCandidate | FnPointerCandidate { .. } | BuiltinObjectCandidate @@ -1914,7 +1914,7 @@ fn candidate_should_be_dropped_in_favor_of( ImplCandidate(_) | AutoImplCandidate | ClosureCandidate { .. } - | GeneratorCandidate + | CoroutineCandidate | FutureCandidate | FnPointerCandidate { .. } | BuiltinObjectCandidate @@ -1948,7 +1948,7 @@ fn candidate_should_be_dropped_in_favor_of( ImplCandidate(..) | AutoImplCandidate | ClosureCandidate { .. } - | GeneratorCandidate + | CoroutineCandidate | FutureCandidate | FnPointerCandidate { .. } | BuiltinObjectCandidate @@ -1962,7 +1962,7 @@ fn candidate_should_be_dropped_in_favor_of( ImplCandidate(..) | AutoImplCandidate | ClosureCandidate { .. } - | GeneratorCandidate + | CoroutineCandidate | FutureCandidate | FnPointerCandidate { .. } | BuiltinObjectCandidate @@ -2068,7 +2068,7 @@ fn candidate_should_be_dropped_in_favor_of( ( ImplCandidate(_) | ClosureCandidate { .. } - | GeneratorCandidate + | CoroutineCandidate | FutureCandidate | FnPointerCandidate { .. } | BuiltinObjectCandidate @@ -2078,7 +2078,7 @@ fn candidate_should_be_dropped_in_favor_of( | TraitAliasCandidate, ImplCandidate(_) | ClosureCandidate { .. } - | GeneratorCandidate + | CoroutineCandidate | FutureCandidate | FnPointerCandidate { .. } | BuiltinObjectCandidate @@ -2112,8 +2112,8 @@ fn sized_conditions( | ty::RawPtr(..) | ty::Char | ty::Ref(..) - | ty::Generator(..) - | ty::GeneratorWitness(..) + | ty::Coroutine(..) + | ty::CoroutineWitness(..) | ty::Array(..) | ty::Closure(..) | ty::Never @@ -2180,7 +2180,7 @@ fn copy_clone_conditions( ty::Dynamic(..) | ty::Str | ty::Slice(..) - | ty::Generator(_, _, hir::Movability::Static) + | ty::Coroutine(_, _, hir::Movability::Static) | ty::Foreign(..) | ty::Ref(_, _, hir::Mutability::Mut) => None, @@ -2189,7 +2189,7 @@ fn copy_clone_conditions( Where(obligation.predicate.rebind(tys.iter().collect())) } - ty::Generator(_, args, hir::Movability::Movable) => { + ty::Coroutine(_, args, hir::Movability::Movable) => { if self.tcx().features().generator_clone { let resolved_upvars = self.infcx.shallow_resolve(args.as_generator().tupled_upvars_ty()); @@ -2212,7 +2212,7 @@ fn copy_clone_conditions( } } - ty::GeneratorWitness(def_id, ref args) => { + ty::CoroutineWitness(def_id, ref args) => { let hidden_types = bind_generator_hidden_types_above( self.infcx, def_id, @@ -2311,13 +2311,13 @@ fn constituent_types_for_ty( t.rebind(vec![ty]) } - ty::Generator(_, ref args, _) => { + ty::Coroutine(_, ref args, _) => { let ty = self.infcx.shallow_resolve(args.as_generator().tupled_upvars_ty()); let witness = args.as_generator().witness(); t.rebind([ty].into_iter().chain(iter::once(witness)).collect()) } - ty::GeneratorWitness(def_id, ref args) => { + ty::CoroutineWitness(def_id, ref args) => { bind_generator_hidden_types_above(self.infcx, def_id, args, t.bound_vars()) } diff --git a/compiler/rustc_trait_selection/src/traits/structural_match.rs b/compiler/rustc_trait_selection/src/traits/structural_match.rs index fc9b424369a..5960415a88d 100644 --- a/compiler/rustc_trait_selection/src/traits/structural_match.rs +++ b/compiler/rustc_trait_selection/src/traits/structural_match.rs @@ -79,7 +79,7 @@ fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow { ty::Closure(..) => { return ControlFlow::Break(ty); } - ty::Generator(..) | ty::GeneratorWitness(..) => { + ty::Coroutine(..) | ty::CoroutineWitness(..) => { return ControlFlow::Break(ty); } ty::FnDef(..) => { diff --git a/compiler/rustc_trait_selection/src/traits/wf.rs b/compiler/rustc_trait_selection/src/traits/wf.rs index e7e4ee983fb..b78794f335a 100644 --- a/compiler/rustc_trait_selection/src/traits/wf.rs +++ b/compiler/rustc_trait_selection/src/traits/wf.rs @@ -600,7 +600,7 @@ fn compute(&mut self, arg: GenericArg<'tcx>) { | ty::Float(..) | ty::Error(_) | ty::Str - | ty::GeneratorWitness(..) + | ty::CoroutineWitness(..) | ty::Never | ty::Param(_) | ty::Bound(..) @@ -672,7 +672,7 @@ fn compute(&mut self, arg: GenericArg<'tcx>) { } } - ty::Generator(did, args, ..) => { + ty::Coroutine(did, args, ..) => { // Walk ALL the types in the generator: this will // include the upvar types as well as the yield // type. Note that this is mildly distinct from diff --git a/compiler/rustc_ty_utils/src/abi.rs b/compiler/rustc_ty_utils/src/abi.rs index b118ddaab2b..f6eec38af7b 100644 --- a/compiler/rustc_ty_utils/src/abi.rs +++ b/compiler/rustc_ty_utils/src/abi.rs @@ -97,7 +97,7 @@ fn fn_sig_for_fn_abi<'tcx>( bound_vars, ) } - ty::Generator(did, args, _) => { + ty::Coroutine(did, args, _) => { let sig = args.as_generator().poly_sig(); let bound_vars = tcx.mk_bound_variable_kinds_from_iter( @@ -117,7 +117,7 @@ fn fn_sig_for_fn_abi<'tcx>( let sig = sig.skip_binder(); // The `FnSig` and the `ret_ty` here is for a generators main - // `Generator::resume(...) -> GeneratorState` function in case we + // `Coroutine::resume(...) -> CoroutineState` function in case we // have an ordinary generator, or the `Future::poll(...) -> Poll` // function in case this is a special generator backing an async construct. let (resume_ty, ret_ty) = if tcx.generator_is_async(did) { @@ -143,8 +143,8 @@ fn fn_sig_for_fn_abi<'tcx>( (context_mut_ref, ret_ty) } else { - // The signature should be `Generator::resume(_, Resume) -> GeneratorState` - let state_did = tcx.require_lang_item(LangItem::GeneratorState, None); + // The signature should be `Coroutine::resume(_, Resume) -> CoroutineState` + let state_did = tcx.require_lang_item(LangItem::CoroutineState, None); let state_adt_ref = tcx.adt_def(state_did); let state_args = tcx.mk_args(&[sig.yield_ty.into(), sig.return_ty.into()]); let ret_ty = Ty::new_adt(tcx, state_adt_ref, state_args); diff --git a/compiler/rustc_ty_utils/src/implied_bounds.rs b/compiler/rustc_ty_utils/src/implied_bounds.rs index 0ca7d43f6d5..5c34df1ed50 100644 --- a/compiler/rustc_ty_utils/src/implied_bounds.rs +++ b/compiler/rustc_ty_utils/src/implied_bounds.rs @@ -157,7 +157,7 @@ fn assumed_wf_types<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> &'tcx [(Ty<' | DefKind::LifetimeParam | DefKind::GlobalAsm | DefKind::Closure - | DefKind::Generator => ty::List::empty(), + | DefKind::Coroutine => ty::List::empty(), } } diff --git a/compiler/rustc_ty_utils/src/instance.rs b/compiler/rustc_ty_utils/src/instance.rs index 2fbf87800bb..7f3e2cefd02 100644 --- a/compiler/rustc_ty_utils/src/instance.rs +++ b/compiler/rustc_ty_utils/src/instance.rs @@ -38,7 +38,7 @@ fn resolve_instance<'tcx>( debug!(" => nontrivial drop glue"); match *ty.kind() { ty::Closure(..) - | ty::Generator(..) + | ty::Coroutine(..) | ty::Tuple(..) | ty::Adt(..) | ty::Dynamic(..) @@ -212,8 +212,8 @@ fn resolve_associated_item<'tcx>( let is_copy = self_ty.is_copy_modulo_regions(tcx, param_env); match self_ty.kind() { _ if is_copy => (), - ty::Generator(..) - | ty::GeneratorWitness(..) + ty::Coroutine(..) + | ty::CoroutineWitness(..) | ty::Closure(..) | ty::Tuple(..) => {} _ => return Ok(None), @@ -246,7 +246,7 @@ fn resolve_associated_item<'tcx>( }) } } else if Some(trait_ref.def_id) == lang_items.future_trait() { - let ty::Generator(generator_def_id, args, _) = *rcvr_args.type_at(0).kind() else { + let ty::Coroutine(generator_def_id, args, _) = *rcvr_args.type_at(0).kind() else { bug!() }; if Some(trait_item_id) == tcx.lang_items().future_poll_fn() { @@ -259,11 +259,11 @@ fn resolve_associated_item<'tcx>( Some(Instance::new(trait_item_id, rcvr_args)) } } else if Some(trait_ref.def_id) == lang_items.gen_trait() { - let ty::Generator(generator_def_id, args, _) = *rcvr_args.type_at(0).kind() else { + let ty::Coroutine(generator_def_id, args, _) = *rcvr_args.type_at(0).kind() else { bug!() }; if cfg!(debug_assertions) && tcx.item_name(trait_item_id) != sym::resume { - // For compiler developers who'd like to add new items to `Generator`, + // For compiler developers who'd like to add new items to `Coroutine`, // you either need to generate a shim body, or perhaps return // `InstanceDef::Item` pointing to a trait default method body if // it is given a default implementation by the trait. diff --git a/compiler/rustc_ty_utils/src/layout.rs b/compiler/rustc_ty_utils/src/layout.rs index cc6c8478785..8cb4162563e 100644 --- a/compiler/rustc_ty_utils/src/layout.rs +++ b/compiler/rustc_ty_utils/src/layout.rs @@ -2,7 +2,7 @@ use rustc_hir as hir; use rustc_index::bit_set::BitSet; use rustc_index::{IndexSlice, IndexVec}; -use rustc_middle::mir::{GeneratorLayout, GeneratorSavedLocal}; +use rustc_middle::mir::{CoroutineLayout, CoroutineSavedLocal}; use rustc_middle::query::Providers; use rustc_middle::ty::layout::{ IntegerExt, LayoutCx, LayoutError, LayoutOf, TyAndLayout, MAX_SIMD_LANES, @@ -314,7 +314,7 @@ fn layout_of_uncached<'tcx>( tcx.mk_layout(unit) } - ty::Generator(def_id, args, _) => generator_layout(cx, ty, def_id, args)?, + ty::Coroutine(def_id, args, _) => generator_layout(cx, ty, def_id, args)?, ty::Closure(_, ref args) => { let tys = args.as_closure().upvar_tys(); @@ -575,7 +575,7 @@ fn layout_of_uncached<'tcx>( return Err(error(cx, LayoutError::Unknown(ty))); } - ty::Bound(..) | ty::GeneratorWitness(..) | ty::Infer(_) | ty::Error(_) => { + ty::Bound(..) | ty::CoroutineWitness(..) | ty::Infer(_) | ty::Error(_) => { bug!("Layout::compute: unexpected type `{}`", ty) } @@ -585,7 +585,7 @@ fn layout_of_uncached<'tcx>( }) } -/// Overlap eligibility and variant assignment for each GeneratorSavedLocal. +/// Overlap eligibility and variant assignment for each CoroutineSavedLocal. #[derive(Clone, Debug, PartialEq)] enum SavedLocalEligibility { Unassigned, @@ -614,11 +614,11 @@ enum SavedLocalEligibility { /// Compute the eligibility and assignment of each local. fn generator_saved_local_eligibility( - info: &GeneratorLayout<'_>, -) -> (BitSet, IndexVec) { + info: &CoroutineLayout<'_>, +) -> (BitSet, IndexVec) { use SavedLocalEligibility::*; - let mut assignments: IndexVec = + let mut assignments: IndexVec = IndexVec::from_elem(Unassigned, &info.field_tys); // The saved locals not eligible for overlap. These will get @@ -766,7 +766,7 @@ fn generator_layout<'tcx>( // Split the prefix layout into the "outer" fields (upvars and // discriminant) and the "promoted" fields. Promoted fields will // get included in each variant that requested them in - // GeneratorLayout. + // CoroutineLayout. debug!("prefix = {:#?}", prefix); let (outer_fields, promoted_offsets, promoted_memory_index) = match prefix.fields { FieldsShape::Arbitrary { mut offsets, memory_index } => { @@ -833,7 +833,7 @@ fn generator_layout<'tcx>( }; // Now, stitch the promoted and variant-only fields back together in - // the order they are mentioned by our GeneratorLayout. + // the order they are mentioned by our CoroutineLayout. // Because we only use some subset (that can differ between variants) // of the promoted fields, we can't just pick those elements of the // `promoted_memory_index` (as we'd end up with gaps). @@ -956,12 +956,12 @@ fn record_layout_for_printing_outlined<'tcx>( record(adt_kind.into(), adt_packed, opt_discr_size, variant_infos); } - ty::Generator(def_id, args, _) => { + ty::Coroutine(def_id, args, _) => { debug!("print-type-size t: `{:?}` record generator", layout.ty); - // Generators always have a begin/poisoned/end state with additional suspend points + // Coroutines always have a begin/poisoned/end state with additional suspend points let (variant_infos, opt_discr_size) = variant_info_for_generator(cx, layout, def_id, args); - record(DataTypeKind::Generator, false, opt_discr_size, variant_infos); + record(DataTypeKind::Coroutine, false, opt_discr_size, variant_infos); } ty::Closure(..) => { @@ -1095,7 +1095,7 @@ fn variant_info_for_generator<'tcx>( // The struct is as large as the last field's end variant_size = variant_size.max(offset + field_layout.size); FieldInfo { - kind: FieldKind::GeneratorLocal, + kind: FieldKind::CoroutineLocal, name: generator.field_names[*local].unwrap_or(Symbol::intern(&format!( ".generator_field{}", local.as_usize() @@ -1136,7 +1136,7 @@ fn variant_info_for_generator<'tcx>( } VariantInfo { - name: Some(Symbol::intern(&ty::GeneratorArgs::variant_name(variant_idx))), + name: Some(Symbol::intern(&ty::CoroutineArgs::variant_name(variant_idx))), kind: SizeKind::Exact, size: variant_size.bytes(), align: variant_layout.align.abi.bytes(), diff --git a/compiler/rustc_ty_utils/src/needs_drop.rs b/compiler/rustc_ty_utils/src/needs_drop.rs index 6dcbc4470e6..c2190118b2e 100644 --- a/compiler/rustc_ty_utils/src/needs_drop.rs +++ b/compiler/rustc_ty_utils/src/needs_drop.rs @@ -133,7 +133,7 @@ fn next(&mut self) -> Option>> { // The information required to determine whether a generator has drop is // computed on MIR, while this very method is used to build MIR. // To avoid cycles, we consider that generators always require drop. - ty::Generator(..) => { + ty::Coroutine(..) => { return Some(Err(AlwaysRequiresDrop)); } @@ -191,7 +191,7 @@ fn next(&mut self) -> Option>> { | ty::FnPtr(..) | ty::Tuple(_) | ty::Bound(..) - | ty::GeneratorWitness(..) + | ty::CoroutineWitness(..) | ty::Never | ty::Infer(_) | ty::Error(_) => { diff --git a/compiler/rustc_ty_utils/src/opaque_types.rs b/compiler/rustc_ty_utils/src/opaque_types.rs index 06a30677d20..a297f9af56a 100644 --- a/compiler/rustc_ty_utils/src/opaque_types.rs +++ b/compiler/rustc_ty_utils/src/opaque_types.rs @@ -323,7 +323,7 @@ fn opaque_types_defined_by<'tcx>(tcx: TyCtxt<'tcx>, item: LocalDefId) -> &'tcx [ | DefKind::GlobalAsm | DefKind::Impl { .. } => {} // Closures and generators are type checked with their parent, so there is no difference here. - DefKind::Closure | DefKind::Generator | DefKind::InlineConst => { + DefKind::Closure | DefKind::Coroutine | DefKind::InlineConst => { return tcx.opaque_types_defined_by(tcx.local_parent(item)); } } diff --git a/compiler/rustc_ty_utils/src/ty.rs b/compiler/rustc_ty_utils/src/ty.rs index 3c0184aba22..abf3e108ed4 100644 --- a/compiler/rustc_ty_utils/src/ty.rs +++ b/compiler/rustc_ty_utils/src/ty.rs @@ -18,9 +18,9 @@ fn sized_constraint_for_ty<'tcx>( let result = match ty.kind() { Bool | Char | Int(..) | Uint(..) | Float(..) | RawPtr(..) | Ref(..) | FnDef(..) - | FnPtr(_) | Array(..) | Closure(..) | Generator(..) | Never => vec![], + | FnPtr(_) | Array(..) | Closure(..) | Coroutine(..) | Never => vec![], - Str | Dynamic(..) | Slice(_) | Foreign(..) | Error(_) | GeneratorWitness(..) => { + Str | Dynamic(..) | Slice(_) | Foreign(..) | Error(_) | CoroutineWitness(..) => { // these are never sized - return the target type vec![ty] } diff --git a/compiler/rustc_type_ir/src/ty_kind.rs b/compiler/rustc_type_ir/src/ty_kind.rs index 064645740e3..954972bad26 100644 --- a/compiler/rustc_type_ir/src/ty_kind.rs +++ b/compiler/rustc_type_ir/src/ty_kind.rs @@ -199,11 +199,11 @@ pub enum TyKind { /// `|a| yield a`. /// /// For more info about generator args, visit the documentation for - /// `GeneratorArgs`. - Generator(I::DefId, I::GenericArgs, Movability), + /// `CoroutineArgs`. + Coroutine(I::DefId, I::GenericArgs, Movability), /// A type representing the types stored inside a generator. - /// This should only appear as part of the `GeneratorArgs`. + /// This should only appear as part of the `CoroutineArgs`. /// /// Unlike upvars, the witness can reference lifetimes from /// inside of the generator itself. To deal with them in @@ -226,7 +226,7 @@ pub enum TyKind { /// } /// # ; /// ``` - GeneratorWitness(I::DefId, I::GenericArgs), + CoroutineWitness(I::DefId, I::GenericArgs), /// The never type `!`. Never, @@ -311,8 +311,8 @@ const fn tykind_discriminant(value: &TyKind) -> usize { FnPtr(_) => 13, Dynamic(..) => 14, Closure(_, _) => 15, - Generator(_, _, _) => 16, - GeneratorWitness(_, _) => 17, + Coroutine(_, _, _) => 16, + CoroutineWitness(_, _) => 17, Never => 18, Tuple(_) => 19, Alias(_, _) => 20, @@ -344,8 +344,8 @@ fn clone(&self) -> Self { FnPtr(s) => FnPtr(s.clone()), Dynamic(p, r, repr) => Dynamic(p.clone(), r.clone(), *repr), Closure(d, s) => Closure(d.clone(), s.clone()), - Generator(d, s, m) => Generator(d.clone(), s.clone(), m.clone()), - GeneratorWitness(d, s) => GeneratorWitness(d.clone(), s.clone()), + Coroutine(d, s, m) => Coroutine(d.clone(), s.clone(), m.clone()), + CoroutineWitness(d, s) => CoroutineWitness(d.clone(), s.clone()), Never => Never, Tuple(t) => Tuple(t.clone()), Alias(k, p) => Alias(*k, p.clone()), @@ -384,10 +384,10 @@ fn eq(&self, other: &TyKind) -> bool { a_p == b_p && a_r == b_r && a_repr == b_repr } (Closure(a_d, a_s), Closure(b_d, b_s)) => a_d == b_d && a_s == b_s, - (Generator(a_d, a_s, a_m), Generator(b_d, b_s, b_m)) => { + (Coroutine(a_d, a_s, a_m), Coroutine(b_d, b_s, b_m)) => { a_d == b_d && a_s == b_s && a_m == b_m } - (GeneratorWitness(a_d, a_s), GeneratorWitness(b_d, b_s)) => a_d == b_d && a_s == b_s, + (CoroutineWitness(a_d, a_s), CoroutineWitness(b_d, b_s)) => a_d == b_d && a_s == b_s, (Tuple(a_t), Tuple(b_t)) => a_t == b_t, (Alias(a_i, a_p), Alias(b_i, b_p)) => a_i == b_i && a_p == b_p, (Param(a_p), Param(b_p)) => a_p == b_p, @@ -441,12 +441,12 @@ fn cmp(&self, other: &TyKind) -> Ordering { a_p.cmp(b_p).then_with(|| a_r.cmp(b_r).then_with(|| a_repr.cmp(b_repr))) } (Closure(a_p, a_s), Closure(b_p, b_s)) => a_p.cmp(b_p).then_with(|| a_s.cmp(b_s)), - (Generator(a_d, a_s, a_m), Generator(b_d, b_s, b_m)) => { + (Coroutine(a_d, a_s, a_m), Coroutine(b_d, b_s, b_m)) => { a_d.cmp(b_d).then_with(|| a_s.cmp(b_s).then_with(|| a_m.cmp(b_m))) } ( - GeneratorWitness(a_d, a_s), - GeneratorWitness(b_d, b_s), + CoroutineWitness(a_d, a_s), + CoroutineWitness(b_d, b_s), ) => match Ord::cmp(a_d, b_d) { Ordering::Equal => Ord::cmp(a_s, b_s), cmp => cmp, @@ -506,12 +506,12 @@ fn hash<__H: hash::Hasher>(&self, state: &mut __H) -> () { d.hash(state); s.hash(state) } - Generator(d, s, m) => { + Coroutine(d, s, m) => { d.hash(state); s.hash(state); m.hash(state) } - GeneratorWitness(d, s) => { + CoroutineWitness(d, s) => { d.hash(state); s.hash(state); } @@ -584,9 +584,9 @@ fn fmt>( } }, Closure(d, s) => f.debug_tuple_field2_finish("Closure", d, &this.wrap(s)), - Generator(d, s, m) => f.debug_tuple_field3_finish("Generator", d, &this.wrap(s), m), - GeneratorWitness(d, s) => { - f.debug_tuple_field2_finish("GeneratorWitness", d, &this.wrap(s)) + Coroutine(d, s, m) => f.debug_tuple_field3_finish("Coroutine", d, &this.wrap(s), m), + CoroutineWitness(d, s) => { + f.debug_tuple_field2_finish("CoroutineWitness", d, &this.wrap(s)) } Never => write!(f, "!"), Tuple(t) => { @@ -696,12 +696,12 @@ fn encode(&self, e: &mut E) { def_id.encode(e); args.encode(e); }), - Generator(def_id, args, m) => e.emit_enum_variant(disc, |e| { + Coroutine(def_id, args, m) => e.emit_enum_variant(disc, |e| { def_id.encode(e); args.encode(e); m.encode(e); }), - GeneratorWitness(def_id, args) => e.emit_enum_variant(disc, |e| { + CoroutineWitness(def_id, args) => e.emit_enum_variant(disc, |e| { def_id.encode(e); args.encode(e); }), @@ -774,8 +774,8 @@ fn decode(d: &mut D) -> Self { 13 => FnPtr(Decodable::decode(d)), 14 => Dynamic(Decodable::decode(d), Decodable::decode(d), Decodable::decode(d)), 15 => Closure(Decodable::decode(d), Decodable::decode(d)), - 16 => Generator(Decodable::decode(d), Decodable::decode(d), Decodable::decode(d)), - 17 => GeneratorWitness(Decodable::decode(d), Decodable::decode(d)), + 16 => Coroutine(Decodable::decode(d), Decodable::decode(d), Decodable::decode(d)), + 17 => CoroutineWitness(Decodable::decode(d), Decodable::decode(d)), 18 => Never, 19 => Tuple(Decodable::decode(d)), 20 => Alias(Decodable::decode(d), Decodable::decode(d)), @@ -874,12 +874,12 @@ fn hash_stable( def_id.hash_stable(__hcx, __hasher); args.hash_stable(__hcx, __hasher); } - Generator(def_id, args, m) => { + Coroutine(def_id, args, m) => { def_id.hash_stable(__hcx, __hasher); args.hash_stable(__hcx, __hasher); m.hash_stable(__hcx, __hasher); } - GeneratorWitness(def_id, args) => { + CoroutineWitness(def_id, args) => { def_id.hash_stable(__hcx, __hasher); args.hash_stable(__hcx, __hasher); } diff --git a/compiler/stable_mir/src/fold.rs b/compiler/stable_mir/src/fold.rs index 6471b2c2a3a..ca6ea92c4a1 100644 --- a/compiler/stable_mir/src/fold.rs +++ b/compiler/stable_mir/src/fold.rs @@ -155,7 +155,7 @@ fn super_fold(&self, folder: &mut V) -> ControlFlow { RigidTy::FnDef(_, args) => *args = args.fold(folder)?, RigidTy::FnPtr(sig) => *sig = sig.fold(folder)?, RigidTy::Closure(_, args) => *args = args.fold(folder)?, - RigidTy::Generator(_, args, _) => *args = args.fold(folder)?, + RigidTy::Coroutine(_, args, _) => *args = args.fold(folder)?, RigidTy::Dynamic(pred, r, _) => { *pred = pred.fold(folder)?; *r = r.fold(folder)?; diff --git a/compiler/stable_mir/src/mir/body.rs b/compiler/stable_mir/src/mir/body.rs index 72f026ee8de..4de1f8940d9 100644 --- a/compiler/stable_mir/src/mir/body.rs +++ b/compiler/stable_mir/src/mir/body.rs @@ -1,4 +1,4 @@ -use crate::ty::{AdtDef, ClosureDef, Const, GeneratorDef, GenericArgs, Movability, Region}; +use crate::ty::{AdtDef, ClosureDef, Const, CoroutineDef, GenericArgs, Movability, Region}; use crate::Opaque; use crate::{ty::Ty, Span}; @@ -59,7 +59,7 @@ pub enum TerminatorKind { target: usize, unwind: UnwindAction, }, - GeneratorDrop, + CoroutineDrop, InlineAsm { template: String, operands: Vec, @@ -94,8 +94,8 @@ pub enum AssertMessage { OverflowNeg(Operand), DivisionByZero(Operand), RemainderByZero(Operand), - ResumedAfterReturn(GeneratorKind), - ResumedAfterPanic(GeneratorKind), + ResumedAfterReturn(CoroutineKind), + ResumedAfterPanic(CoroutineKind), MisalignedPointerDereference { required: Operand, found: Operand }, } @@ -132,13 +132,13 @@ pub enum UnOp { } #[derive(Clone, Debug)] -pub enum GeneratorKind { - Async(AsyncGeneratorKind), +pub enum CoroutineKind { + Async(AsyncCoroutineKind), Gen, } #[derive(Clone, Debug)] -pub enum AsyncGeneratorKind { +pub enum AsyncCoroutineKind { Block, Closure, Fn, @@ -227,8 +227,8 @@ pub enum Rvalue { /// `dest = Foo { x: ..., y: ... }` from `dest.x = ...; dest.y = ...;` in the case that `Foo` /// has a destructor. /// - /// Disallowed after deaggregation for all aggregate kinds except `Array` and `Generator`. After - /// generator lowering, `Generator` aggregate kinds are disallowed too. + /// Disallowed after deaggregation for all aggregate kinds except `Array` and `Coroutine`. After + /// generator lowering, `Coroutine` aggregate kinds are disallowed too. Aggregate(AggregateKind, Vec), /// * `Offset` has the same semantics as `<*const T>::offset`, except that the second @@ -331,7 +331,7 @@ pub enum AggregateKind { Tuple, Adt(AdtDef, VariantIdx, GenericArgs, Option, Option), Closure(ClosureDef, GenericArgs), - Generator(GeneratorDef, GenericArgs, Movability), + Coroutine(CoroutineDef, GenericArgs, Movability), } #[derive(Clone, Debug)] diff --git a/compiler/stable_mir/src/ty.rs b/compiler/stable_mir/src/ty.rs index 003045a4696..0ed2813bccf 100644 --- a/compiler/stable_mir/src/ty.rs +++ b/compiler/stable_mir/src/ty.rs @@ -142,7 +142,7 @@ pub enum RigidTy { FnDef(FnDef, GenericArgs), FnPtr(PolyFnSig), Closure(ClosureDef, GenericArgs), - Generator(GeneratorDef, GenericArgs, Movability), + Coroutine(CoroutineDef, GenericArgs, Movability), Dynamic(Vec>, Region, DynKind), Never, Tuple(Vec), @@ -196,7 +196,7 @@ pub fn body(&self) -> Body { pub struct ClosureDef(pub DefId); #[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub struct GeneratorDef(pub DefId); +pub struct CoroutineDef(pub DefId); #[derive(Clone, Copy, PartialEq, Eq, Debug)] pub struct ParamDef(pub DefId); diff --git a/compiler/stable_mir/src/visitor.rs b/compiler/stable_mir/src/visitor.rs index 96100958138..a6020cc5bd9 100644 --- a/compiler/stable_mir/src/visitor.rs +++ b/compiler/stable_mir/src/visitor.rs @@ -148,7 +148,7 @@ fn super_visit(&self, visitor: &mut V) -> ControlFlow { RigidTy::FnDef(_, args) => args.visit(visitor), RigidTy::FnPtr(sig) => sig.visit(visitor), RigidTy::Closure(_, args) => args.visit(visitor), - RigidTy::Generator(_, args, _) => args.visit(visitor), + RigidTy::Coroutine(_, args, _) => args.visit(visitor), RigidTy::Dynamic(pred, r, _) => { pred.visit(visitor)?; r.visit(visitor) diff --git a/library/alloc/src/boxed.rs b/library/alloc/src/boxed.rs index 96b93830f96..d14a6188085 100644 --- a/library/alloc/src/boxed.rs +++ b/library/alloc/src/boxed.rs @@ -159,7 +159,7 @@ use core::marker::Unsize; use core::mem::{self, SizedTypeProperties}; use core::ops::{ - CoerceUnsized, Deref, DerefMut, DispatchFromDyn, Generator, GeneratorState, Receiver, + CoerceUnsized, Coroutine, CoroutineState, Deref, DerefMut, DispatchFromDyn, Receiver, }; use core::pin::Pin; use core::ptr::{self, NonNull, Unique}; @@ -2107,27 +2107,27 @@ fn as_mut(&mut self) -> &mut T { impl Unpin for Box where A: 'static {} #[unstable(feature = "generator_trait", issue = "43122")] -impl + Unpin, R, A: Allocator> Generator for Box +impl + Unpin, R, A: Allocator> Coroutine for Box where A: 'static, { type Yield = G::Yield; type Return = G::Return; - fn resume(mut self: Pin<&mut Self>, arg: R) -> GeneratorState { + fn resume(mut self: Pin<&mut Self>, arg: R) -> CoroutineState { G::resume(Pin::new(&mut *self), arg) } } #[unstable(feature = "generator_trait", issue = "43122")] -impl, R, A: Allocator> Generator for Pin> +impl, R, A: Allocator> Coroutine for Pin> where A: 'static, { type Yield = G::Yield; type Return = G::Return; - fn resume(mut self: Pin<&mut Self>, arg: R) -> GeneratorState { + fn resume(mut self: Pin<&mut Self>, arg: R) -> CoroutineState { G::resume((*self).as_mut(), arg) } } diff --git a/library/core/src/future/mod.rs b/library/core/src/future/mod.rs index 089493d3766..0f77a2d8343 100644 --- a/library/core/src/future/mod.rs +++ b/library/core/src/future/mod.rs @@ -38,7 +38,7 @@ /// This type is needed because: /// -/// a) Generators cannot implement `for<'a, 'b> Generator<&'a mut Context<'b>>`, so we need to pass +/// a) Coroutines cannot implement `for<'a, 'b> Coroutine<&'a mut Context<'b>>`, so we need to pass /// a raw pointer (see ). /// b) Raw pointers and `NonNull` aren't `Send` or `Sync`, so that would make every single future /// non-Send/Sync as well, and we don't want that. diff --git a/library/core/src/iter/sources/from_generator.rs b/library/core/src/iter/sources/from_generator.rs index 4cbe731b222..b512f4f162c 100644 --- a/library/core/src/iter/sources/from_generator.rs +++ b/library/core/src/iter/sources/from_generator.rs @@ -1,5 +1,5 @@ use crate::fmt; -use crate::ops::{Generator, GeneratorState}; +use crate::ops::{Coroutine, CoroutineState}; use crate::pin::Pin; /// Creates a new iterator where each iteration calls the provided generator. @@ -24,8 +24,8 @@ /// ``` #[inline] #[unstable(feature = "iter_from_generator", issue = "43122", reason = "generators are unstable")] -pub fn from_generator + Unpin>(generator: G) -> FromGenerator { - FromGenerator(generator) +pub fn from_generator + Unpin>(generator: G) -> FromCoroutine { + FromCoroutine(generator) } /// An iterator over the values yielded by an underlying generator. @@ -36,23 +36,23 @@ pub fn from_generator + Unpin>(generator: G) -> FromGe /// [`iter::from_generator()`]: from_generator #[unstable(feature = "iter_from_generator", issue = "43122", reason = "generators are unstable")] #[derive(Clone)] -pub struct FromGenerator(G); +pub struct FromCoroutine(G); #[unstable(feature = "iter_from_generator", issue = "43122", reason = "generators are unstable")] -impl + Unpin> Iterator for FromGenerator { +impl + Unpin> Iterator for FromCoroutine { type Item = G::Yield; fn next(&mut self) -> Option { match Pin::new(&mut self.0).resume(()) { - GeneratorState::Yielded(n) => Some(n), - GeneratorState::Complete(()) => None, + CoroutineState::Yielded(n) => Some(n), + CoroutineState::Complete(()) => None, } } } #[unstable(feature = "iter_from_generator", issue = "43122", reason = "generators are unstable")] -impl fmt::Debug for FromGenerator { +impl fmt::Debug for FromCoroutine { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("FromGenerator").finish() + f.debug_struct("FromCoroutine").finish() } } diff --git a/library/core/src/ops/generator.rs b/library/core/src/ops/generator.rs index fee4beb1e84..f1fe55760ad 100644 --- a/library/core/src/ops/generator.rs +++ b/library/core/src/ops/generator.rs @@ -3,13 +3,13 @@ /// The result of a generator resumption. /// -/// This enum is returned from the `Generator::resume` method and indicates the +/// This enum is returned from the `Coroutine::resume` method and indicates the /// possible return values of a generator. Currently this corresponds to either /// a suspension point (`Yielded`) or a termination point (`Complete`). #[derive(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)] #[lang = "generator_state"] #[unstable(feature = "generator_trait", issue = "43122")] -pub enum GeneratorState { +pub enum CoroutineState { /// The generator suspended with a value. /// /// This state indicates that a generator has been suspended, and typically @@ -28,7 +28,7 @@ pub enum GeneratorState { /// The trait implemented by builtin generator types. /// -/// Generators, also commonly referred to as coroutines, are currently an +/// Coroutines, also commonly referred to as coroutines, are currently an /// experimental language feature in Rust. Added in [RFC 2033] generators are /// currently intended to primarily provide a building block for async/await /// syntax but will likely extend to also providing an ergonomic definition for @@ -41,7 +41,7 @@ pub enum GeneratorState { /// ```rust /// #![feature(generators, generator_trait)] /// -/// use std::ops::{Generator, GeneratorState}; +/// use std::ops::{Coroutine, CoroutineState}; /// use std::pin::Pin; /// /// fn main() { @@ -51,11 +51,11 @@ pub enum GeneratorState { /// }; /// /// match Pin::new(&mut generator).resume(()) { -/// GeneratorState::Yielded(1) => {} +/// CoroutineState::Yielded(1) => {} /// _ => panic!("unexpected return from resume"), /// } /// match Pin::new(&mut generator).resume(()) { -/// GeneratorState::Complete("foo") => {} +/// CoroutineState::Complete("foo") => {} /// _ => panic!("unexpected return from resume"), /// } /// } @@ -68,7 +68,7 @@ pub enum GeneratorState { #[lang = "generator"] #[unstable(feature = "generator_trait", issue = "43122")] #[fundamental] -pub trait Generator { +pub trait Coroutine { /// The type of value this generator yields. /// /// This associated type corresponds to the `yield` expression and the @@ -95,10 +95,10 @@ pub trait Generator { /// /// # Return value /// - /// The `GeneratorState` enum returned from this function indicates what + /// The `CoroutineState` enum returned from this function indicates what /// state the generator is in upon returning. If the `Yielded` variant is /// returned then the generator has reached a suspension point and a value - /// has been yielded out. Generators in this state are available for + /// has been yielded out. Coroutines in this state are available for /// resumption at a later point. /// /// If `Complete` is returned then the generator has completely finished @@ -110,26 +110,26 @@ pub trait Generator { /// This function may panic if it is called after the `Complete` variant has /// been returned previously. While generator literals in the language are /// guaranteed to panic on resuming after `Complete`, this is not guaranteed - /// for all implementations of the `Generator` trait. - fn resume(self: Pin<&mut Self>, arg: R) -> GeneratorState; + /// for all implementations of the `Coroutine` trait. + fn resume(self: Pin<&mut Self>, arg: R) -> CoroutineState; } #[unstable(feature = "generator_trait", issue = "43122")] -impl, R> Generator for Pin<&mut G> { +impl, R> Coroutine for Pin<&mut G> { type Yield = G::Yield; type Return = G::Return; - fn resume(mut self: Pin<&mut Self>, arg: R) -> GeneratorState { + fn resume(mut self: Pin<&mut Self>, arg: R) -> CoroutineState { G::resume((*self).as_mut(), arg) } } #[unstable(feature = "generator_trait", issue = "43122")] -impl + Unpin, R> Generator for &mut G { +impl + Unpin, R> Coroutine for &mut G { type Yield = G::Yield; type Return = G::Return; - fn resume(mut self: Pin<&mut Self>, arg: R) -> GeneratorState { + fn resume(mut self: Pin<&mut Self>, arg: R) -> CoroutineState { G::resume(Pin::new(&mut *self), arg) } } diff --git a/library/core/src/ops/mod.rs b/library/core/src/ops/mod.rs index 97d9b750d92..eb972e9f6c5 100644 --- a/library/core/src/ops/mod.rs +++ b/library/core/src/ops/mod.rs @@ -199,7 +199,7 @@ pub(crate) use self::try_trait::{ChangeOutputType, NeverShortCircuit}; #[unstable(feature = "generator_trait", issue = "43122")] -pub use self::generator::{Generator, GeneratorState}; +pub use self::generator::{Coroutine, CoroutineState}; #[unstable(feature = "coerce_unsized", issue = "18598")] pub use self::unsize::CoerceUnsized; diff --git a/library/core/src/pin.rs b/library/core/src/pin.rs index 94c682b615a..14344e3890b 100644 --- a/library/core/src/pin.rs +++ b/library/core/src/pin.rs @@ -1085,16 +1085,16 @@ impl DispatchFromDyn> for Pin

where P: DispatchFromDyn {} /// # assert_eq!(42, block_on(async { 42 })); /// ``` /// -/// ### With `Generator`s +/// ### With `Coroutine`s /// /// ```rust /// #![feature(generators, generator_trait)] /// use core::{ -/// ops::{Generator, GeneratorState}, +/// ops::{Coroutine, CoroutineState}, /// pin::pin, /// }; /// -/// fn generator_fn() -> impl Generator /* not Unpin */ { +/// fn generator_fn() -> impl Coroutine /* not Unpin */ { /// // Allow generator to be self-referential (not `Unpin`) /// // vvvvvv so that locals can cross yield points. /// static || { @@ -1109,16 +1109,16 @@ impl DispatchFromDyn> for Pin

where P: DispatchFromDyn {} /// fn main() { /// let mut generator = pin!(generator_fn()); /// match generator.as_mut().resume(()) { -/// GeneratorState::Yielded(0) => {}, +/// CoroutineState::Yielded(0) => {}, /// _ => unreachable!(), /// } /// match generator.as_mut().resume(()) { -/// GeneratorState::Yielded(3) => {}, +/// CoroutineState::Yielded(3) => {}, /// _ => unreachable!(), /// } /// match generator.resume(()) { -/// GeneratorState::Yielded(_) => unreachable!(), -/// GeneratorState::Complete(()) => {}, +/// CoroutineState::Yielded(_) => unreachable!(), +/// CoroutineState::Complete(()) => {}, /// } /// } /// ``` diff --git a/library/core/src/sync/exclusive.rs b/library/core/src/sync/exclusive.rs index ff538d55c60..5aa45610197 100644 --- a/library/core/src/sync/exclusive.rs +++ b/library/core/src/sync/exclusive.rs @@ -3,7 +3,7 @@ use core::fmt; use core::future::Future; use core::marker::Tuple; -use core::ops::{Generator, GeneratorState}; +use core::ops::{Coroutine, CoroutineState}; use core::pin::Pin; use core::task::{Context, Poll}; @@ -207,15 +207,15 @@ fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { } #[unstable(feature = "generator_trait", issue = "43122")] // also #98407 -impl Generator for Exclusive +impl Coroutine for Exclusive where - G: Generator + ?Sized, + G: Coroutine + ?Sized, { type Yield = G::Yield; type Return = G::Return; #[inline] - fn resume(self: Pin<&mut Self>, arg: R) -> GeneratorState { + fn resume(self: Pin<&mut Self>, arg: R) -> CoroutineState { G::resume(self.get_pin_mut(), arg) } } diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index e08318e4f54..7becc156142 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -2266,9 +2266,9 @@ pub(crate) fn clean_middle_ty<'tcx>( } ty::Closure(..) => panic!("Closure"), - ty::Generator(..) => panic!("Generator"), + ty::Coroutine(..) => panic!("Coroutine"), ty::Placeholder(..) => panic!("Placeholder"), - ty::GeneratorWitness(..) => panic!("GeneratorWitness"), + ty::CoroutineWitness(..) => panic!("CoroutineWitness"), ty::Infer(..) => panic!("Infer"), ty::Error(_) => rustc_errors::FatalError.raise(), } diff --git a/src/librustdoc/formats/item_type.rs b/src/librustdoc/formats/item_type.rs index be2ee791588..e37d16f5bd0 100644 --- a/src/librustdoc/formats/item_type.rs +++ b/src/librustdoc/formats/item_type.rs @@ -141,7 +141,7 @@ fn from(other: DefKind) -> Self { | DefKind::GlobalAsm | DefKind::Impl { .. } | DefKind::Closure - | DefKind::Generator => Self::ForeignType, + | DefKind::Coroutine => Self::ForeignType, } } } diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index d216305e6a9..fcd07885894 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -521,8 +521,8 @@ fn def_id_to_res(&self, ty_id: DefId) -> Option { } ty::Alias(..) | ty::Closure(..) - | ty::Generator(..) - | ty::GeneratorWitness(..) + | ty::Coroutine(..) + | ty::CoroutineWitness(..) | ty::Dynamic(..) | ty::Param(_) | ty::Bound(..) @@ -1918,7 +1918,7 @@ fn split(path: &str) -> Option<(&str, &str)> { Variant | Field | Closure - | Generator + | Coroutine | AssocTy | AssocConst | AssocFn diff --git a/src/tools/clippy/clippy_lints/src/async_yields_async.rs b/src/tools/clippy/clippy_lints/src/async_yields_async.rs index 9464694a3b5..99daec560e7 100644 --- a/src/tools/clippy/clippy_lints/src/async_yields_async.rs +++ b/src/tools/clippy/clippy_lints/src/async_yields_async.rs @@ -2,7 +2,7 @@ use clippy_utils::source::snippet; use clippy_utils::ty::implements_trait; use rustc_errors::Applicability; -use rustc_hir::{AsyncGeneratorKind, Body, BodyId, ExprKind, GeneratorKind, QPath}; +use rustc_hir::{AsyncCoroutineKind, Body, BodyId, ExprKind, CoroutineKind, QPath}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; @@ -45,10 +45,10 @@ impl<'tcx> LateLintPass<'tcx> for AsyncYieldsAsync { fn check_body(&mut self, cx: &LateContext<'tcx>, body: &'tcx Body<'_>) { - use AsyncGeneratorKind::{Block, Closure}; + use AsyncCoroutineKind::{Block, Closure}; // For functions, with explicitly defined types, don't warn. // XXXkhuey maybe we should? - if let Some(GeneratorKind::Async(Block | Closure)) = body.generator_kind { + if let Some(CoroutineKind::Async(Block | Closure)) = body.generator_kind { if let Some(future_trait_def_id) = cx.tcx.lang_items().future_trait() { let body_id = BodyId { hir_id: body.value.hir_id, diff --git a/src/tools/clippy/clippy_lints/src/await_holding_invalid.rs b/src/tools/clippy/clippy_lints/src/await_holding_invalid.rs index accff9b0a34..65d131c5751 100644 --- a/src/tools/clippy/clippy_lints/src/await_holding_invalid.rs +++ b/src/tools/clippy/clippy_lints/src/await_holding_invalid.rs @@ -2,9 +2,9 @@ use clippy_utils::{match_def_path, paths}; use rustc_data_structures::fx::FxHashMap; use rustc_hir::def_id::DefId; -use rustc_hir::{AsyncGeneratorKind, Body, GeneratorKind}; +use rustc_hir::{AsyncCoroutineKind, Body, CoroutineKind}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_middle::mir::GeneratorLayout; +use rustc_middle::mir::CoroutineLayout; use rustc_session::{declare_tool_lint, impl_lint_pass}; use rustc_span::{sym, Span}; @@ -195,8 +195,8 @@ fn check_crate(&mut self, cx: &LateContext<'_>) { } fn check_body(&mut self, cx: &LateContext<'_>, body: &'_ Body<'_>) { - use AsyncGeneratorKind::{Block, Closure, Fn}; - if let Some(GeneratorKind::Async(Block | Closure | Fn)) = body.generator_kind { + use AsyncCoroutineKind::{Block, Closure, Fn}; + if let Some(CoroutineKind::Async(Block | Closure | Fn)) = body.generator_kind { let def_id = cx.tcx.hir().body_owner_def_id(body.id()); if let Some(generator_layout) = cx.tcx.mir_generator_witnesses(def_id) { self.check_interior_types(cx, generator_layout); @@ -206,7 +206,7 @@ fn check_body(&mut self, cx: &LateContext<'_>, body: &'_ Body<'_>) { } impl AwaitHolding { - fn check_interior_types(&self, cx: &LateContext<'_>, generator: &GeneratorLayout<'_>) { + fn check_interior_types(&self, cx: &LateContext<'_>, generator: &CoroutineLayout<'_>) { for (ty_index, ty_cause) in generator.field_tys.iter_enumerated() { if let rustc_middle::ty::Adt(adt, _) = ty_cause.ty.kind() { let await_points = || { diff --git a/src/tools/clippy/clippy_lints/src/dereference.rs b/src/tools/clippy/clippy_lints/src/dereference.rs index 5134cf66050..efe82036dc8 100644 --- a/src/tools/clippy/clippy_lints/src/dereference.rs +++ b/src/tools/clippy/clippy_lints/src/dereference.rs @@ -842,8 +842,8 @@ fn for_mir_ty<'tcx>(tcx: TyCtxt<'tcx>, param_env: ParamEnv<'tcx>, ty: Ty<'tcx>, | ty::Adt(..) | ty::Foreign(_) | ty::FnDef(..) - | ty::Generator(..) - | ty::GeneratorWitness(..) + | ty::Coroutine(..) + | ty::CoroutineWitness(..) | ty::Closure(..) | ty::Never | ty::Tuple(_) diff --git a/src/tools/clippy/clippy_lints/src/doc.rs b/src/tools/clippy/clippy_lints/src/doc.rs index e789e0da679..ca9defc2bf3 100644 --- a/src/tools/clippy/clippy_lints/src/doc.rs +++ b/src/tools/clippy/clippy_lints/src/doc.rs @@ -436,7 +436,7 @@ fn lint_for_missing_headers( let body = cx.tcx.hir().body(body_id); let ret_ty = typeck.expr_ty(body.value); if implements_trait(cx, ret_ty, future, &[]); - if let ty::Generator(_, subs, _) = ret_ty.kind(); + if let ty::Coroutine(_, subs, _) = ret_ty.kind(); if is_type_diagnostic_item(cx, subs.as_generator().return_ty(), sym::Result); then { span_lint( diff --git a/src/tools/clippy/clippy_lints/src/large_futures.rs b/src/tools/clippy/clippy_lints/src/large_futures.rs index 19f1e08b57a..90096f0f506 100644 --- a/src/tools/clippy/clippy_lints/src/large_futures.rs +++ b/src/tools/clippy/clippy_lints/src/large_futures.rs @@ -12,7 +12,7 @@ /// It checks for the size of a `Future` created by `async fn` or `async {}`. /// /// ### Why is this bad? - /// Due to the current [unideal implementation](https://github.com/rust-lang/rust/issues/69826) of `Generator`, + /// Due to the current [unideal implementation](https://github.com/rust-lang/rust/issues/69826) of `Coroutine`, /// large size of a `Future` may cause stack overflows. /// /// ### Example diff --git a/src/tools/clippy/clippy_lints/src/manual_async_fn.rs b/src/tools/clippy/clippy_lints/src/manual_async_fn.rs index 577bc1d661d..49976334751 100644 --- a/src/tools/clippy/clippy_lints/src/manual_async_fn.rs +++ b/src/tools/clippy/clippy_lints/src/manual_async_fn.rs @@ -4,7 +4,7 @@ use rustc_errors::Applicability; use rustc_hir::intravisit::FnKind; use rustc_hir::{ - AsyncGeneratorKind, Block, Body, Closure, Expr, ExprKind, FnDecl, FnRetTy, GeneratorKind, GenericArg, GenericBound, + AsyncCoroutineKind, Block, Body, Closure, Expr, ExprKind, FnDecl, FnRetTy, CoroutineKind, GenericArg, GenericBound, ImplItem, Item, ItemKind, LifetimeName, Node, Term, TraitRef, Ty, TyKind, TypeBindingKind, }; use rustc_lint::{LateContext, LateLintPass}; @@ -188,7 +188,7 @@ fn desugared_async_block<'tcx>(cx: &LateContext<'tcx>, block: &'tcx Block<'tcx>) .. } = block_expr; let closure_body = cx.tcx.hir().body(body); - if closure_body.generator_kind == Some(GeneratorKind::Async(AsyncGeneratorKind::Block)); + if closure_body.generator_kind == Some(CoroutineKind::Async(AsyncCoroutineKind::Block)); then { return Some(closure_body); } diff --git a/src/tools/clippy/clippy_lints/src/needless_question_mark.rs b/src/tools/clippy/clippy_lints/src/needless_question_mark.rs index 0e834fb3ac7..f2c823323bb 100644 --- a/src/tools/clippy/clippy_lints/src/needless_question_mark.rs +++ b/src/tools/clippy/clippy_lints/src/needless_question_mark.rs @@ -4,7 +4,7 @@ use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir::def::{DefKind, Res}; -use rustc_hir::{AsyncGeneratorKind, Block, Body, Expr, ExprKind, GeneratorKind, LangItem, MatchSource, QPath}; +use rustc_hir::{AsyncCoroutineKind, Block, Body, Expr, ExprKind, CoroutineKind, LangItem, MatchSource, QPath}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; @@ -87,7 +87,7 @@ fn check_expr(&mut self, cx: &LateContext<'_>, expr: &'_ Expr<'_>) { } fn check_body(&mut self, cx: &LateContext<'_>, body: &'_ Body<'_>) { - if let Some(GeneratorKind::Async(AsyncGeneratorKind::Fn)) = body.generator_kind { + if let Some(CoroutineKind::Async(AsyncCoroutineKind::Fn)) = body.generator_kind { if let ExprKind::Block( Block { expr: diff --git a/src/tools/clippy/clippy_lints/src/redundant_async_block.rs b/src/tools/clippy/clippy_lints/src/redundant_async_block.rs index 8193057a6eb..59aecd23278 100644 --- a/src/tools/clippy/clippy_lints/src/redundant_async_block.rs +++ b/src/tools/clippy/clippy_lints/src/redundant_async_block.rs @@ -5,7 +5,7 @@ use clippy_utils::source::{snippet, walk_span_to_context}; use clippy_utils::visitors::for_each_expr; use rustc_errors::Applicability; -use rustc_hir::{AsyncGeneratorKind, Closure, Expr, ExprKind, GeneratorKind, MatchSource}; +use rustc_hir::{AsyncCoroutineKind, Closure, Expr, ExprKind, CoroutineKind, MatchSource}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::lint::in_external_macro; use rustc_middle::ty::UpvarCapture; @@ -71,7 +71,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) { fn desugar_async_block<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) -> Option<&'tcx Expr<'tcx>> { if let ExprKind::Closure(Closure { body, def_id, .. }) = expr.kind && let body = cx.tcx.hir().body(*body) && - matches!(body.generator_kind, Some(GeneratorKind::Async(AsyncGeneratorKind::Block))) + matches!(body.generator_kind, Some(CoroutineKind::Async(AsyncCoroutineKind::Block))) { cx .typeck_results() diff --git a/src/tools/clippy/clippy_lints/src/unused_async.rs b/src/tools/clippy/clippy_lints/src/unused_async.rs index bc7c3897a6e..5e1ba1b0dc0 100644 --- a/src/tools/clippy/clippy_lints/src/unused_async.rs +++ b/src/tools/clippy/clippy_lints/src/unused_async.rs @@ -86,7 +86,7 @@ fn nested_visit_map(&mut self) -> Self::Map { } fn visit_body(&mut self, b: &'tcx Body<'tcx>) { - let is_async_block = matches!(b.generator_kind, Some(rustc_hir::GeneratorKind::Async(_))); + let is_async_block = matches!(b.generator_kind, Some(rustc_hir::CoroutineKind::Async(_))); if is_async_block { self.async_depth += 1; diff --git a/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs b/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs index 55f9cb27ad4..0d8fd9d2adf 100644 --- a/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs +++ b/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs @@ -305,7 +305,7 @@ fn check_terminator<'tcx>( Ok(()) }, TerminatorKind::SwitchInt { discr, targets: _ } => check_operand(tcx, discr, span, body), - TerminatorKind::GeneratorDrop | TerminatorKind::Yield { .. } => { + TerminatorKind::CoroutineDrop | TerminatorKind::Yield { .. } => { Err((span, "const fn generators are unstable".into())) }, TerminatorKind::Call { diff --git a/src/tools/miri/tests/fail/generator-pinned-moved.rs b/src/tools/miri/tests/fail/generator-pinned-moved.rs index 33348ace9c4..5a1dbc8a0ed 100644 --- a/src/tools/miri/tests/fail/generator-pinned-moved.rs +++ b/src/tools/miri/tests/fail/generator-pinned-moved.rs @@ -2,11 +2,11 @@ #![feature(generators, generator_trait)] use std::{ - ops::{Generator, GeneratorState}, + ops::{Coroutine, CoroutineState}, pin::Pin, }; -fn firstn() -> impl Generator { +fn firstn() -> impl Coroutine { static move || { let mut num = 0; let num = &mut num; @@ -17,26 +17,26 @@ fn firstn() -> impl Generator { } } -struct GeneratorIteratorAdapter(G); +struct CoroutineIteratorAdapter(G); -impl Iterator for GeneratorIteratorAdapter +impl Iterator for CoroutineIteratorAdapter where - G: Generator, + G: Coroutine, { type Item = G::Yield; fn next(&mut self) -> Option { let me = unsafe { Pin::new_unchecked(&mut self.0) }; match me.resume(()) { - GeneratorState::Yielded(x) => Some(x), - GeneratorState::Complete(_) => None, + CoroutineState::Yielded(x) => Some(x), + CoroutineState::Complete(_) => None, } } } fn main() { let mut generator_iterator_2 = { - let mut generator_iterator = Box::new(GeneratorIteratorAdapter(firstn())); + let mut generator_iterator = Box::new(CoroutineIteratorAdapter(firstn())); generator_iterator.next(); // pin it Box::new(*generator_iterator) // move it diff --git a/src/tools/miri/tests/fail/generator-pinned-moved.stderr b/src/tools/miri/tests/fail/generator-pinned-moved.stderr index 8ad0ce8cc32..7465ec2bc83 100644 --- a/src/tools/miri/tests/fail/generator-pinned-moved.stderr +++ b/src/tools/miri/tests/fail/generator-pinned-moved.stderr @@ -9,7 +9,7 @@ LL | *num += 1; help: ALLOC was allocated here: --> $DIR/generator-pinned-moved.rs:LL:CC | -LL | let mut generator_iterator = Box::new(GeneratorIteratorAdapter(firstn())); +LL | let mut generator_iterator = Box::new(CoroutineIteratorAdapter(firstn())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: ALLOC was deallocated here: --> $DIR/generator-pinned-moved.rs:LL:CC @@ -18,12 +18,12 @@ LL | }; // *deallocate* generator_iterator | ^ = note: BACKTRACE (of the first span): = note: inside closure at $DIR/generator-pinned-moved.rs:LL:CC -note: inside ` as std::iter::Iterator>::next` +note: inside ` as std::iter::Iterator>::next` --> $DIR/generator-pinned-moved.rs:LL:CC | LL | match me.resume(()) { | ^^^^^^^^^^^^^ - = note: inside `> as std::iter::Iterator>::next` at RUSTLIB/alloc/src/boxed.rs:LL:CC + = note: inside `> as std::iter::Iterator>::next` at RUSTLIB/alloc/src/boxed.rs:LL:CC note: inside `main` --> $DIR/generator-pinned-moved.rs:LL:CC | diff --git a/src/tools/miri/tests/pass/generator.rs b/src/tools/miri/tests/pass/generator.rs index 20099603455..a1d3e9462bf 100644 --- a/src/tools/miri/tests/pass/generator.rs +++ b/src/tools/miri/tests/pass/generator.rs @@ -5,8 +5,8 @@ use std::fmt::Debug; use std::mem::ManuallyDrop; use std::ops::{ - Generator, - GeneratorState::{self, *}, + Coroutine, + CoroutineState::{self, *}, }; use std::pin::Pin; use std::ptr; @@ -15,7 +15,7 @@ fn basic() { fn finish(mut amt: usize, self_referential: bool, mut t: T) -> T::Return where - T: Generator, + T: Coroutine, { // We are not moving the `t` around until it gets dropped, so this is okay. let mut t = unsafe { Pin::new_unchecked(&mut t) }; @@ -27,10 +27,10 @@ fn finish(mut amt: usize, self_referential: bool, mut t: T) -> T::Return let _ = unsafe { ManuallyDrop::new(ptr::read(t.as_mut().get_unchecked_mut())) }; } match state { - GeneratorState::Yielded(y) => { + CoroutineState::Yielded(y) => { amt -= y; } - GeneratorState::Complete(ret) => { + CoroutineState::Complete(ret) => { assert_eq!(amt, 0); return ret; } @@ -134,9 +134,9 @@ fn never() -> Never { } fn smoke_resume_arg() { - fn drain + Unpin, R, Y>( + fn drain + Unpin, R, Y>( gen: &mut G, - inout: Vec<(R, GeneratorState)>, + inout: Vec<(R, CoroutineState)>, ) where Y: Debug + PartialEq, G::Return: Debug + PartialEq, diff --git a/src/tools/miri/tests/pass/stacked-borrows/generators-self-referential.rs b/src/tools/miri/tests/pass/stacked-borrows/generators-self-referential.rs index b71912882dd..d727cf6e886 100644 --- a/src/tools/miri/tests/pass/stacked-borrows/generators-self-referential.rs +++ b/src/tools/miri/tests/pass/stacked-borrows/generators-self-referential.rs @@ -3,11 +3,11 @@ #![feature(generators, generator_trait)] use std::{ - ops::{Generator, GeneratorState}, + ops::{Coroutine, CoroutineState}, pin::Pin, }; -fn firstn() -> impl Generator { +fn firstn() -> impl Coroutine { static move || { let mut num = 0; let num = &mut num; @@ -27,7 +27,7 @@ fn main() { let mut generator_iterator = firstn(); let mut pin = unsafe { Pin::new_unchecked(&mut generator_iterator) }; let mut sum = 0; - while let GeneratorState::Yielded(x) = pin.as_mut().resume(()) { + while let CoroutineState::Yielded(x) = pin.as_mut().resume(()) { sum += x; } assert_eq!(sum, 3); diff --git a/src/tools/miri/tests/pass/track-caller-attribute.rs b/src/tools/miri/tests/pass/track-caller-attribute.rs index 1b0226e61b5..bf59617d80f 100644 --- a/src/tools/miri/tests/pass/track-caller-attribute.rs +++ b/src/tools/miri/tests/pass/track-caller-attribute.rs @@ -4,7 +4,7 @@ #![feature(generator_trait)] #![feature(generators)] -use std::ops::{Generator, GeneratorState}; +use std::ops::{Coroutine, CoroutineState}; use std::panic::Location; use std::pin::Pin; @@ -212,21 +212,21 @@ fn dyn_invoke_fn_once( fn test_generator() { #[track_caller] - fn mono_generator>( + fn mono_generator>( 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>, + val: Pin<&mut dyn Coroutine>, ) -> (&'static str, String, Loc) { match val.resume("Dyn".to_string()) { - GeneratorState::Yielded(val) => val, + CoroutineState::Yielded(val) => val, _ => unreachable!(), } } @@ -241,7 +241,7 @@ fn dyn_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!()); @@ -258,7 +258,7 @@ fn dyn_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/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 { +fn generator_test() -> impl Coroutine { || { 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 { +fn generator_test() -> impl Coroutine { || { 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}(*mut function_names::{impl#2}::impl_function::{closure_env#0}); -// 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 (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; + let _1: std::ops::CoroutineState; 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>::resume(move _2, const false) -> [return: bb3, unwind unreachable]; +- _1 = <{generator@$DIR/inline_generator.rs:17:5: 17:8} as Coroutine>::resume(move _2, const false) -> [return: bb3, unwind unreachable]; + StorageDead(_4); + _0 = const (); + StorageDead(_1); @@ -88,7 +88,7 @@ + } + + bb6: { -+ _1 = GeneratorState::::Yielded(move _8); ++ _1 = CoroutineState::::Yielded(move _8); + discriminant((*_6)) = 3; + goto -> bb1; + } @@ -100,7 +100,7 @@ + bb8: { + StorageLive(_8); + StorageDead(_8); -+ _1 = GeneratorState::::Complete(_5); ++ _1 = CoroutineState::::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; + let _1: std::ops::CoroutineState; 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>::resume(move _2, const false) -> [return: bb3, unwind: bb5]; +- _1 = <{generator@$DIR/inline_generator.rs:17:5: 17:8} as Coroutine>::resume(move _2, const false) -> [return: bb3, unwind: bb5]; + StorageLive(_5); + _5 = const false; + StorageLive(_6); @@ -100,7 +100,7 @@ + } + + bb8: { -+ _1 = GeneratorState::::Yielded(move _8); ++ _1 = CoroutineState::::Yielded(move _8); + discriminant((*_6)) = 3; + goto -> bb1; + } @@ -112,7 +112,7 @@ + bb10: { + StorageLive(_8); + StorageDead(_8); -+ _1 = GeneratorState::::Complete(_5); ++ _1 = CoroutineState::::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 { +pub fn g() -> impl Coroutine { #[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::` TyKind::Dynamic(..) => (), //~ ERROR usage of `ty::TyKind::` TyKind::Closure(..) => (), //~ ERROR usage of `ty::TyKind::` - TyKind::Generator(..) => (), //~ ERROR usage of `ty::TyKind::` - TyKind::GeneratorWitness(..) => (), //~ ERROR usage of `ty::TyKind::` + TyKind::Coroutine(..) => (), //~ ERROR usage of `ty::TyKind::` + TyKind::CoroutineWitness(..) => (), //~ ERROR usage of `ty::TyKind::` TyKind::Never => (), //~ ERROR usage of `ty::TyKind::` TyKind::Tuple(..) => (), //~ ERROR usage of `ty::TyKind::` TyKind::Alias(..) => (), //~ ERROR usage of `ty::TyKind::` 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 { async {} } -fn returns_generator() -> impl Generator<(), Yield = (), Return = ()> { +fn returns_generator() -> impl Coroutine<(), Yield = (), Return = ()> { || { let _: () = yield (); } } fn takes_future(_f: impl Future) {} -fn takes_generator(_g: impl Generator) {} +fn takes_generator(_g: impl Coroutine) {} 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: Generator<_>` is not satisfied +error[E0277]: the trait bound `impl Future: 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` + | --------------- ^^^^^^^^^^ the trait `Coroutine<_>` is not implemented for `impl Future` | | | 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(_g: impl Generator) {} +LL | fn takes_generator(_g: impl Coroutine) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `takes_generator` -error[E0277]: the trait bound `impl Future: Generator<_>` is not satisfied +error[E0277]: the trait bound `impl Future: 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` + | --------------- ^^^^^^^^^^^^^^^^^^^^^ the trait `Coroutine<_>` is not implemented for `impl Future` | | | 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(_g: impl Generator) {} +LL | fn takes_generator(_g: impl Coroutine) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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(_g: impl Generator) {} +LL | fn takes_generator(_g: impl Coroutine) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `takes_generator` -error[E0277]: `impl Generator` is not a future +error[E0277]: `impl Coroutine` is not a future --> $DIR/generator-not-future.rs:39:18 | LL | takes_future(returns_generator()); - | ------------ ^^^^^^^^^^^^^^^^^^^ `impl Generator` is not a future + | ------------ ^^^^^^^^^^^^^^^^^^^ `impl Coroutine` is not a future | | | required by a bound introduced by this call | - = help: the trait `Future` is not implemented for `impl Generator` - = note: impl Generator must be a future or must implement `IntoFuture` to be awaited + = help: the trait `Future` is not implemented for `impl Coroutine` + = note: impl Coroutine 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); trait Trait {} -impl Trait for Wrapper {} +impl Trait for Wrapper {} impl Trait for Wrapper {} -//[stock]~^ ERROR conflicting implementations of trait `Trait` for type `Wrapper` +//[stock]~^ ERROR conflicting implementations of trait `Trait` for type `Wrapper` 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` +error[E0119]: conflicting implementations of trait `Trait` for type `Wrapper` --> $DIR/coherence-with-generator.rs:21:1 | -LL | impl Trait for Wrapper {} +LL | impl Trait for Wrapper {} | --------------------------------------- first implementation here LL | impl Trait for Wrapper {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Wrapper` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Wrapper` 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 = ::create(); +LL | let cont: u32 = ::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: T) -> Box + Unpin> { +pub fn bar(t: T) -> Box + 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(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, - expected_max_discr: u32 + gen: impl Coroutine<()> + Unpin + DiscriminantKind, + 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) - where T: Generator + where T: Coroutine { } @@ -20,7 +20,7 @@ fn supply_cyclic_generator_return() { } pub fn want_cyclic_generator_yield(_: T) - where T: Generator + where T: Coroutine { } 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) | ---------------------------- required by a bound in this function -LL | where T: Generator +LL | where T: Coroutine | ^^^^^^^^^^ 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) | --------------------------- required by a bound in this function -LL | where T: Generator +LL | where T: Coroutine | ^^^^^^^^^ 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(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 { 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) -> impl Generator +fn with(f: F) -> impl Coroutine 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 @@ fn get_connection(&self) -> impl Iterator { Some(()).into_iter() } - fn check_connection(&self) -> impl Generator + '_ { + fn check_connection(&self) -> impl Coroutine + '_ { 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 @@ cell::RefCell, sync::Arc, pin::Pin, - ops::{Generator, GeneratorState}, + ops::{Coroutine, CoroutineState}, }; pub struct Ready(Option); -impl Generator<()> for Ready { +impl Coroutine<()> for Ready { 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) -> Ready { @@ -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>> { +fn make_non_send_generator() -> impl Coroutine>> { 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) -> impl Generator { +pub fn make_gen2(t: T) -> impl Coroutine { //~^ NOTE appears within the type //~| NOTE expansion of desugaring || { //~ NOTE used within this generator @@ -51,7 +51,7 @@ pub fn make_gen2(t: T) -> impl Generator { t } } -fn make_non_send_generator2() -> impl Generator>> { //~ NOTE appears within the type +fn make_non_send_generator2() -> impl Coroutine>> { //~ 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>>` which is not `Send` + | ------------- has type `impl Coroutine>>` 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>>` +note: required because it appears within the type `impl Coroutine>>` --> $DIR/issue-68112.rs:46:30 | -LL | pub fn make_gen2(t: T) -> impl Generator { +LL | pub fn make_gen2(t: T) -> impl Coroutine { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: required because it appears within the type `impl Generator>>` +note: required because it appears within the type `impl Coroutine>>` --> $DIR/issue-68112.rs:54:34 | -LL | fn make_non_send_generator2() -> impl Generator>> { +LL | fn make_non_send_generator2() -> impl Coroutine>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: required because it captures the following types: `impl Generator>>` + = note: required because it captures the following types: `impl Coroutine>>` 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 { +fn gen() -> impl Coroutine { |_: 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 { +fn my_scenario() -> impl Coroutine { |_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::Gen; } -pub struct Context { +pub struct Context { pub link: Box, } -impl GeneratorProviderAlt for () { - type Gen = impl Generator<(), Return = (), Yield = ()>; +impl CoroutineProviderAlt for () { + type Gen = impl Coroutine<(), Return = (), Yield = ()>; fn start(ctx: Context) -> 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); // This impl isn't safe in general, but the generator used in this test is movable // so it won't cause problems. -impl + Unpin> Iterator for W { +impl + Unpin> Iterator for W { type Item = T::Yield; fn next(&mut self) -> Option { 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 = 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) { +fn assert_generator(_: 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 @@ cell::RefCell, sync::Arc, pin::Pin, - ops::{Generator, GeneratorState}, + ops::{Coroutine, CoroutineState}, }; pub struct Ready(Option); -impl Generator<()> for Ready { +impl Coroutine<()> for Ready { 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) -> Ready { @@ -25,7 +25,7 @@ pub fn make_gen1(t: T) -> Ready { fn require_send(_: impl Send) {} -fn make_non_send_generator() -> impl Generator>> { +fn make_non_send_generator() -> impl Coroutine>> { 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) -> impl Generator { +pub fn make_gen2(t: T) -> impl Coroutine { || { yield; t } } -fn make_non_send_generator2() -> impl Generator>> { +fn make_non_send_generator2() -> impl Coroutine>> { 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>])` --> $DIR/generator-print-verbose-1.rs:41:30 | -LL | pub fn make_gen2(t: T) -> impl Generator { +LL | pub fn make_gen2(t: T) -> impl Coroutine { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 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>> { +LL | fn make_non_send_generator2() -> impl Coroutine>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = 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| { 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 { +fn move_before_yield() -> impl Coroutine { static || { let first = Foo([0; FOO_SIZE]); let _second = first; @@ -36,7 +36,7 @@ fn move_before_yield() -> impl Generator { fn noop() {} -fn move_before_yield_with_noop() -> impl Generator { +fn move_before_yield_with_noop() -> impl Coroutine { static || { let first = Foo([0; FOO_SIZE]); noop(); @@ -48,7 +48,7 @@ fn move_before_yield_with_noop() -> impl Generator { // 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 { +fn overlap_move_points() -> impl Coroutine { static || { let first = Foo([0; FOO_SIZE]); yield; @@ -59,7 +59,7 @@ fn overlap_move_points() -> impl Generator { } } -fn overlap_x_and_y() -> impl Generator { +fn overlap_x_and_y() -> impl Coroutine { 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 + Unpin, R, Y>( +fn drain + Unpin, R, Y>( gen: &mut G, - inout: Vec<(R, GeneratorState)>, + inout: Vec<(R, CoroutineState)>, ) 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, _: G::Return) {} +fn f(_: 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 { +fn foo() -> impl Coroutine { //~^ 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 { +LL | fn foo() -> impl Coroutine { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 + T: FakeCoroutine >(x: T) -> impl FakeFuture { GenFuture(x) } -struct GenFuture>(#[allow(unused_tuple_struct_fields)] T); +struct GenFuture>(#[allow(unused_tuple_struct_fields)] T); -impl> FakeFuture for GenFuture { +impl> FakeFuture for GenFuture { 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 { +fn mk_gen() -> impl Coroutine { || { loop { yield; } } } fn main() { - let gens: [impl Generator;2] = [ mk_gen(), mk_gen() ]; + let gens: [impl Coroutine;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;2] = [ mk_gen(), mk_gen() ]; +LL | let gens: [impl Coroutine;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 { +fn foo() -> impl Coroutine { //~^ ERROR cannot resolve opaque type //~| NOTE recursive opaque type //~| NOTE in this expansion of desugaring of @@ -10,7 +10,7 @@ fn foo() -> impl Generator { 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 { +LL | fn foo() -> impl Coroutine { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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(gen: T) -> impl Future where - T: Generator, + T: Coroutine, { - struct GenFuture>(T); + struct GenFuture>(T); // We rely on the fact that async/await futures are immovable in order to create // self-referential borrows in the underlying generator. - impl> !Unpin for GenFuture {} + impl> !Unpin for GenFuture {} - impl> Future for GenFuture { + impl> Future for GenFuture { type Output = T::Return; fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { // SAFETY: Safe because we're !Unpin + !Drop, and this is just a field projection. @@ -36,8 +36,8 @@ fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { // 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::>())) { - 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); impl Iterator for GenIter 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 { @@ -14,13 +14,13 @@ enum YieldOrReturn { fn finish(mut t: T) -> Vec> 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 @@ fn finish(mut t: T) -> Vec> // This test checks that the polymorphization analysis functions on generators. #[rustc_polymorphize_error] -pub fn unused_type() -> impl Generator<(), Yield = u32, Return = u32> + Unpin { +pub fn unused_type() -> impl Coroutine<(), Yield = u32, Return = u32> + Unpin { || { //~^ ERROR item has unused generic parameters yield 1; @@ -40,7 +40,7 @@ pub fn unused_type() -> impl Generator<(), Yield = u32, Return = u32> + Unpin } #[rustc_polymorphize_error] -pub fn used_type_in_yield() -> impl Generator<(), Yield = Y, Return = u32> + Unpin { +pub fn used_type_in_yield() -> impl Coroutine<(), Yield = Y, Return = u32> + Unpin { || { yield Y::default(); 2 @@ -48,7 +48,7 @@ pub fn used_type_in_yield() -> impl Generator<(), Yield = Y, Return } #[rustc_polymorphize_error] -pub fn used_type_in_return() -> impl Generator<(), Yield = u32, Return = R> + Unpin { +pub fn used_type_in_return() -> impl Coroutine<(), Yield = u32, Return = R> + Unpin { || { yield 3; R::default() @@ -56,7 +56,7 @@ pub fn used_type_in_return() -> impl Generator<(), Yield = u32, Retu } #[rustc_polymorphize_error] -pub fn unused_const() -> impl Generator<(), Yield = u32, Return = u32> + Unpin { +pub fn unused_const() -> impl Coroutine<(), Yield = u32, Return = u32> + Unpin { || { //~^ ERROR item has unused generic parameters yield 1; @@ -65,7 +65,7 @@ pub fn unused_const() -> impl Generator<(), Yield = u32, Return = } #[rustc_polymorphize_error] -pub fn used_const_in_yield() -> impl Generator<(), Yield = u32, Return = u32> + Unpin +pub fn used_const_in_yield() -> impl Coroutine<(), Yield = u32, Return = u32> + Unpin { || { yield Y; @@ -74,7 +74,7 @@ pub fn used_const_in_yield() -> impl Generator<(), Yield = u32, Re } #[rustc_polymorphize_error] -pub fn used_const_in_return() -> impl Generator<(), Yield = u32, Return = u32> + Unpin +pub fn used_const_in_return() -> 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() -> impl Generator<(), Yield = u32, Return = u32> + Unpin { +LL | pub fn unused_type() -> 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() -> impl Generator<(), Yield = u32, Return = u32> + Unpin { +LL | pub fn unused_const() -> 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(array: [u8; C]) -> impl Generator { +fn generator(array: [u8; C]) -> impl Coroutine { 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>( +fn mono_generator>( 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> + val: Pin<&mut dyn Coroutine> ) -> (&'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` is not satisfied +error[E0277]: the trait bound `{generator@$DIR/generator.rs:18:21: 18:23}: Coroutine` is not satisfied --> $DIR/generator.rs:18:21 | LL | needs_generator(|| { @@ -10,15 +10,15 @@ LL | | LL | | LL | | yield (); LL | | }); - | |_____^ the trait `Generator` is not implemented for `{generator@$DIR/generator.rs:18:21: 18:23}` + | |_____^ the trait `Coroutine` 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) {} +LL | fn needs_generator(_: impl Coroutine) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `needs_generator` -error[E0271]: type mismatch resolving `<{generator@$DIR/generator.rs:18:21: 18:23} as Generator>::Yield == B` +error[E0271]: type mismatch resolving `<{generator@$DIR/generator.rs:18:21: 18:23} as Coroutine>::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) {} +LL | fn needs_generator(_: impl Coroutine) {} | ^^^^^^^^^ required by this bound in `needs_generator` -error[E0271]: type mismatch resolving `<{generator@$DIR/generator.rs:18:21: 18:23} as Generator>::Return == C` +error[E0271]: type mismatch resolving `<{generator@$DIR/generator.rs:18:21: 18:23} as Coroutine>::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) {} +LL | fn needs_generator(_: impl Coroutine) {} | ^^^^^^^^^^ 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) {} +fn needs_generator(_: impl Coroutine) {} #[cfg(fail)] fn main() { needs_generator(|| { - //[fail]~^ ERROR Generator` is not satisfied - //[fail]~| ERROR as Generator>::Yield == B` - //[fail]~| ERROR as Generator>::Return == C` + //[fail]~^ ERROR Coroutine` is not satisfied + //[fail]~| ERROR as Coroutine>::Yield == B` + //[fail]~| ERROR as Coroutine>::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 = impl Generator; + pub type GenOnce = impl Coroutine; pub const fn const_generator(yielding: Y, returning: R) -> GenOnce { 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 + 'a; -fn rand_generator<'a>(rng: &'a ()) -> RandGenerator<'a> { +type RandCoroutine<'a> = impl Coroutine + '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 + 'c; -pub fn rand_generator_with_indirection<'a>(rng: &'a ()) -> RandGeneratorWithIndirection<'a> { - fn helper<'b>(rng: &'b ()) -> impl 'b + Generator { +pub type RandCoroutineWithIndirection<'c> = impl Coroutine + 'c; +pub fn rand_generator_with_indirection<'a>(rng: &'a ()) -> RandCoroutineWithIndirection<'a> { + fn helper<'b>(rng: &'b ()) -> impl 'b + Coroutine { move || { let _rng = rng; loop { @@ -33,7 +33,7 @@ fn helper<'b>(rng: &'b ()) -> impl 'b + Generator { 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; + type Gen: Coroutine; fn run(&mut self) -> Self::Gen; } @@ -10,7 +10,7 @@ trait Runnable { struct Implementor {} impl Runnable for Implementor { - type Gen = impl Generator; + type Gen = impl Coroutine; 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 {