From edcae08455a8b43aa5d6e6d8f609b5ac3672a369 Mon Sep 17 00:00:00 2001 From: Eric Holk Date: Wed, 29 Oct 2025 14:03:48 -0700 Subject: [PATCH] Remove support for prefix yield --- compiler/rustc_ast/src/ast.rs | 7 -- compiler/rustc_ast_lowering/src/expr.rs | 8 +- .../rustc_ast_pretty/src/pprust/state/expr.rs | 8 -- .../src/pprust/state/fixup.rs | 9 +-- .../example/gen_block_iterate.rs | 8 +- .../example/std_example.rs | 2 +- .../rustc_codegen_gcc/example/std_example.rs | 2 +- .../src/error_codes/E0626.md | 12 +-- .../src/error_codes/E0627.md | 4 +- .../src/error_codes/E0628.md | 4 +- .../src/error_codes/E0727.md | 4 +- compiler/rustc_hir/src/hir.rs | 2 +- .../src/collect/resolve_bound_vars.rs | 4 +- compiler/rustc_metadata/src/rmeta/decoder.rs | 8 +- compiler/rustc_middle/src/ty/closure.rs | 6 +- compiler/rustc_middle/src/ty/context.rs | 2 +- compiler/rustc_mir_transform/src/coroutine.rs | 4 +- .../src/coverage/expansion.rs | 4 +- compiler/rustc_parse/src/parser/expr.rs | 12 --- compiler/rustc_type_ir/src/ty_kind.rs | 6 +- .../core/src/iter/sources/from_coroutine.rs | 6 +- library/core/src/iter/sources/generator.rs | 6 +- library/core/src/ops/coroutine.rs | 2 +- library/core/src/pin.rs | 4 +- library/core/src/unicode/printable.py | 12 +-- .../src/language-features/coroutines.md | 6 +- .../unstable-book/src/the-unstable-book.md | 2 +- src/tools/miri/tests/pass/coroutine.rs | 52 ++++++------- src/tools/miri/tests/pass/iter_macro.rs | 4 +- .../coroutine-self-referential.rs | 6 +- .../miri/tests/pass/track-caller-attribute.rs | 4 +- src/tools/rustfmt/src/expr.rs | 7 -- src/tools/rustfmt/src/utils.rs | 4 +- tests/codegen-llvm/coroutine-debug.rs | 4 +- .../issues/issue-98678-closure-coroutine.rs | 2 +- tests/coverage/coroutine.rs | 2 +- tests/coverage/yield.rs | 8 +- tests/crashes/139570.rs | 2 +- tests/mir-opt/building/coroutine.rs | 8 +- tests/mir-opt/coroutine_drop_cleanup.rs | 2 +- .../mir-opt/coroutine_storage_dead_unwind.rs | 2 +- tests/mir-opt/coroutine_tiny.rs | 2 +- tests/mir-opt/inline/inline_coroutine.rs | 2 +- tests/pretty/postfix-yield.rs | 2 +- .../async-gen-move-suggestion.fixed | 4 +- .../async-await/async-gen-move-suggestion.rs | 4 +- .../async-gen-move-suggestion.stderr | 4 +- tests/ui/async-await/coroutine-not-future.rs | 6 +- .../async-await/coroutine-not-future.stderr | 2 +- tests/ui/async-await/for-await-passthrough.rs | 2 +- ...65419-coroutine-resume-after-completion.rs | 2 +- tests/ui/async-await/non-trivial-drop.rs | 4 +- .../ui/coherence/coherence-with-coroutine.rs | 2 +- tests/ui/coroutine/addassign-yield.rs | 8 +- .../coroutine/async-coroutine-issue-67158.rs | 2 +- .../async-coroutine-issue-67158.stderr | 2 +- tests/ui/coroutine/async-gen-deduce-yield.rs | 2 +- .../coroutine/async-gen-yield-ty-is-unit.rs | 2 +- tests/ui/coroutine/async_gen_fn_iter.rs | 6 +- tests/ui/coroutine/auto-trait-regions.rs | 6 +- tests/ui/coroutine/auto-trait-regions.stderr | 8 +- .../metadata-sufficient-for-layout.rs | 2 +- tests/ui/coroutine/auxiliary/unwind-aux.rs | 2 +- .../coroutine/auxiliary/xcrate-reachable.rs | 2 +- tests/ui/coroutine/auxiliary/xcrate.rs | 4 +- tests/ui/coroutine/borrow-in-tail-expr.rs | 2 +- tests/ui/coroutine/borrowing.rs | 4 +- tests/ui/coroutine/borrowing.stderr | 12 +-- .../coroutine/check-resume-ty-lifetimes-2.rs | 8 +- .../check-resume-ty-lifetimes-2.stderr | 4 +- .../ui/coroutine/check-resume-ty-lifetimes.rs | 2 +- .../check-resume-ty-lifetimes.stderr | 2 +- tests/ui/coroutine/clone-impl-static.rs | 2 +- tests/ui/coroutine/clone-impl.rs | 12 +-- tests/ui/coroutine/clone-impl.stderr | 4 +- tests/ui/coroutine/clone-rpit.rs | 2 +- tests/ui/coroutine/conditional-drop.rs | 4 +- tests/ui/coroutine/control-flow.rs | 14 ++-- .../coroutine-region-requirements.rs | 2 +- .../coroutine/coroutine-resume-after-panic.rs | 2 +- tests/ui/coroutine/coroutine-with-nll.rs | 2 +- tests/ui/coroutine/coroutine-with-nll.stderr | 2 +- .../coroutine-yielding-or-returning-itself.rs | 4 +- ...outine-yielding-or-returning-itself.stderr | 4 +- .../ui/coroutine/derived-drop-parent-expr.rs | 2 +- tests/ui/coroutine/discriminant.rs | 76 +++++++++---------- tests/ui/coroutine/drop-and-replace.rs | 4 +- tests/ui/coroutine/drop-control-flow.rs | 18 ++--- tests/ui/coroutine/drop-env.rs | 6 +- .../coroutine/drop-track-addassign-yield.rs | 6 +- .../drop-tracking-parent-expression.rs | 4 +- .../drop-tracking-parent-expression.stderr | 12 +-- .../drop-tracking-yielding-in-match-guards.rs | 2 +- tests/ui/coroutine/drop-yield-twice.rs | 4 +- tests/ui/coroutine/drop-yield-twice.stderr | 8 +- tests/ui/coroutine/dropck-resume.rs | 2 +- tests/ui/coroutine/dropck.rs | 2 +- tests/ui/coroutine/gen_block.e2024.stderr | 6 +- tests/ui/coroutine/gen_block.none.stderr | 30 ++++---- tests/ui/coroutine/gen_block.rs | 8 +- tests/ui/coroutine/gen_block_is_coro.rs | 6 +- tests/ui/coroutine/gen_block_is_coro.stderr | 6 +- tests/ui/coroutine/gen_block_is_fused_iter.rs | 6 +- tests/ui/coroutine/gen_block_is_iter.rs | 6 +- tests/ui/coroutine/gen_block_is_no_future.rs | 2 +- .../coroutine/gen_block_is_no_future.stderr | 2 +- tests/ui/coroutine/gen_block_iterate.rs | 6 +- tests/ui/coroutine/gen_block_move.fixed | 4 +- tests/ui/coroutine/gen_block_move.rs | 4 +- tests/ui/coroutine/gen_block_move.stderr | 4 +- tests/ui/coroutine/gen_block_panic.rs | 4 +- tests/ui/coroutine/gen_block_panic.stderr | 2 +- tests/ui/coroutine/gen_fn_iter.rs | 6 +- tests/ui/coroutine/gen_fn_lifetime_capture.rs | 4 +- tests/ui/coroutine/issue-102645.rs | 2 +- tests/ui/coroutine/issue-105084.rs | 2 +- tests/ui/coroutine/issue-105084.stderr | 6 +- ...sue-110929-coroutine-conflict-error-ice.rs | 2 +- tests/ui/coroutine/issue-113279.rs | 2 +- tests/ui/coroutine/issue-44197.rs | 4 +- .../issue-45729-unsafe-in-coroutine.rs | 2 +- tests/ui/coroutine/issue-48048.rs | 2 +- tests/ui/coroutine/issue-48048.stderr | 4 +- tests/ui/coroutine/issue-52304.rs | 2 +- tests/ui/coroutine/issue-52398.rs | 4 +- tests/ui/coroutine/issue-52398.stderr | 4 +- tests/ui/coroutine/issue-53548.rs | 2 +- tests/ui/coroutine/issue-57017.rs | 4 +- tests/ui/coroutine/issue-57084.rs | 4 +- tests/ui/coroutine/issue-57084.stderr | 2 +- tests/ui/coroutine/issue-57478.rs | 2 +- tests/ui/coroutine/issue-58888.rs | 2 +- .../issue-61442-stmt-expr-with-drop.rs | 4 +- .../issue-64620-yield-array-element.rs | 2 +- .../issue-64620-yield-array-element.stderr | 4 +- tests/ui/coroutine/issue-68112.rs | 6 +- tests/ui/coroutine/issue-68112.stderr | 4 +- tests/ui/coroutine/issue-69017.rs | 2 +- tests/ui/coroutine/issue-69039.rs | 4 +- tests/ui/coroutine/issue-87142.rs | 2 +- tests/ui/coroutine/issue-88653.rs | 2 +- tests/ui/coroutine/issue-91477.rs | 2 +- tests/ui/coroutine/issue-91477.stderr | 4 +- tests/ui/coroutine/iterator-count.rs | 4 +- tests/ui/coroutine/live-upvar-across-yield.rs | 2 +- tests/ui/coroutine/match-bindings.rs | 2 +- .../missing_coroutine_attr_suggestion.fixed | 2 +- .../missing_coroutine_attr_suggestion.rs | 2 +- .../missing_coroutine_attr_suggestion.stderr | 6 +- tests/ui/coroutine/moved-twice.rs | 6 +- tests/ui/coroutine/moved-twice.stderr | 4 +- tests/ui/coroutine/nested_coroutine.rs | 4 +- tests/ui/coroutine/niche-in-coroutine.rs | 2 +- tests/ui/coroutine/non-static-is-unpin.rs | 2 +- tests/ui/coroutine/not-send-sync.rs | 4 +- tests/ui/coroutine/not-send-sync.stderr | 12 +-- tests/ui/coroutine/other-attribute-on-gen.rs | 16 ++-- tests/ui/coroutine/overlap-locals.rs | 8 +- tests/ui/coroutine/panic-drops-resume.rs | 2 +- tests/ui/coroutine/panic-drops.rs | 4 +- tests/ui/coroutine/panic-safe.rs | 2 +- tests/ui/coroutine/parent-expression.rs | 4 +- tests/ui/coroutine/parent-expression.stderr | 12 +-- tests/ui/coroutine/partial-drop.rs | 6 +- .../partial-initialization-across-yield.rs | 6 +- tests/ui/coroutine/pattern-borrow.rs | 2 +- tests/ui/coroutine/pattern-borrow.stderr | 2 +- tests/ui/coroutine/pin-box-coroutine.rs | 4 +- tests/ui/coroutine/postfix-yield.rs | 2 +- .../print/coroutine-print-verbose-1.rs | 6 +- .../print/coroutine-print-verbose-1.stderr | 4 +- .../print/coroutine-print-verbose-2.rs | 4 +- .../print/coroutine-print-verbose-2.stderr | 12 +-- .../print/coroutine-print-verbose-3.rs | 2 +- .../print/coroutine-print-verbose-3.stderr | 2 +- tests/ui/coroutine/reborrow-mut-upvar.rs | 2 +- tests/ui/coroutine/reborrow-mut-upvar.stderr | 2 +- .../ref-escapes-but-not-over-yield.rs | 2 +- tests/ui/coroutine/ref-upvar-not-send.rs | 4 +- tests/ui/coroutine/ref-upvar-not-send.stderr | 4 +- tests/ui/coroutine/reinit-in-match-guard.rs | 2 +- tests/ui/coroutine/resume-after-return.rs | 2 +- tests/ui/coroutine/resume-arg-late-bound.rs | 2 +- tests/ui/coroutine/resume-arg-outlives-2.rs | 4 +- tests/ui/coroutine/resume-arg-outlives.rs | 2 +- tests/ui/coroutine/resume-arg-size.rs | 4 +- .../ui/coroutine/resume-live-across-yield.rs | 2 +- tests/ui/coroutine/retain-resume-ref.rs | 2 +- tests/ui/coroutine/return-types-diverge.rs | 4 +- tests/ui/coroutine/return-types.rs | 4 +- tests/ui/coroutine/return-types.stderr | 4 +- .../coroutine/self_referential_gen_block.rs | 2 +- .../self_referential_gen_block.stderr | 2 +- tests/ui/coroutine/size-moved-locals.rs | 14 ++-- tests/ui/coroutine/sized-yield.rs | 2 +- tests/ui/coroutine/sized-yield.stderr | 2 +- tests/ui/coroutine/smoke-resume-args.rs | 16 ++-- tests/ui/coroutine/smoke.rs | 30 ++++---- tests/ui/coroutine/static-coroutine.rs | 2 +- .../ui/coroutine/static-move-suggestion.fixed | 2 +- tests/ui/coroutine/static-move-suggestion.rs | 2 +- .../coroutine/static-move-suggestion.stderr | 2 +- .../static-mut-reference-across-yield.rs | 4 +- tests/ui/coroutine/static-not-unpin.rs | 2 +- .../static-reference-across-yield.rs | 4 +- .../too-live-local-in-immovable-gen.rs | 2 +- tests/ui/coroutine/too-many-parameters.rs | 2 +- tests/ui/coroutine/type-mismatch-error.rs | 2 +- tests/ui/coroutine/type-mismatch-error.stderr | 2 +- .../type-mismatch-signature-deduction.rs | 2 +- tests/ui/coroutine/uninhabited-field.rs | 4 +- .../coroutine/unsized-capture-across-yield.rs | 2 +- .../coroutine/unsized-local-across-yield.rs | 2 +- tests/ui/coroutine/yield-in-args-rev.rs | 2 +- tests/ui/coroutine/yield-in-args-rev.stderr | 2 +- tests/ui/coroutine/yield-in-args.rs | 2 +- tests/ui/coroutine/yield-in-args.stderr | 4 +- tests/ui/coroutine/yield-in-const.rs | 2 +- tests/ui/coroutine/yield-in-const.stderr | 4 +- tests/ui/coroutine/yield-in-function.rs | 2 +- tests/ui/coroutine/yield-in-function.stderr | 10 +-- tests/ui/coroutine/yield-in-initializer.rs | 2 +- tests/ui/coroutine/yield-in-static.rs | 2 +- tests/ui/coroutine/yield-in-static.stderr | 4 +- .../yield-outside-coroutine-issue-78653.rs | 2 +- ...yield-outside-coroutine-issue-78653.stderr | 14 ++-- tests/ui/coroutine/yield-subtype.rs | 4 +- tests/ui/coroutine/yield-subtype.stderr | 4 +- tests/ui/coroutine/yield-while-iterating.rs | 12 +-- .../ui/coroutine/yield-while-iterating.stderr | 4 +- .../coroutine/yield-while-local-borrowed.rs | 6 +- .../yield-while-local-borrowed.stderr | 4 +- .../coroutine/yield-while-ref-reborrowed.rs | 6 +- tests/ui/drop/dynamic-drop.rs | 4 +- tests/ui/expr/weird-exprs.rs | 2 +- .../feature-gate-closure_track_caller.rs | 2 +- .../feature-gate-closure_track_caller.stderr | 2 +- .../feature-gate-coroutines.e2024.stderr | 36 ++++----- .../feature-gate-coroutines.none.stderr | 36 ++++----- .../feature-gates/feature-gate-coroutines.rs | 8 +- .../feature-gates/feature-gate-yield-expr.rs | 2 +- .../feature-gate-yield-expr.stderr | 12 +-- tests/ui/impl-trait/issues/issue-58504.rs | 2 +- tests/ui/impl-trait/lifetimes.rs | 2 +- .../impl-trait/recursive-coroutine-boxed.rs | 2 +- .../recursive-coroutine-indirect.rs | 2 +- .../recursive-impl-trait-type-indirect.rs | 2 +- tests/ui/iterators/generator.rs | 4 +- tests/ui/iterators/generator_args.rs | 4 +- tests/ui/iterators/generator_capture.rs | 4 +- tests/ui/iterators/generator_capture_.rs | 2 +- tests/ui/iterators/generator_capture_fail.rs | 4 +- .../iterators/generator_capture_fail.stderr | 4 +- .../ui/iterators/generator_capture_fnonce.rs | 4 +- .../ui/iterators/generator_capture_no_lend.rs | 2 +- .../iterators/generator_returned_from_fn.rs | 24 +++--- .../generator_returned_from_fn.stderr | 12 +-- ...iter-macro-not-async-closure-simplified.rs | 2 +- .../iterators/iter-macro-not-async-closure.rs | 2 +- .../lint/must_not_suspend/tuple-mismatch.rs | 4 +- .../must_not_suspend/tuple-mismatch.stderr | 6 +- .../issue-74883-unused-paren-baren-yield.rs | 20 ++--- ...ssue-74883-unused-paren-baren-yield.stderr | 48 ++++++------ tests/ui/lint/unused/unused-closure.rs | 2 +- tests/ui/liveness/liveness-upvars.rs | 6 +- tests/ui/liveness/liveness-upvars.stderr | 2 +- tests/ui/macros/stringify.rs | 4 +- tests/ui/nll/coroutine-distinct-lifetime.rs | 4 +- tests/ui/nll/coroutine-upvar-mutability.rs | 2 +- tests/ui/nll/extra-unused-mut.rs | 2 +- tests/ui/nll/issue-48623-coroutine.rs | 2 +- tests/ui/nll/issue-48623-coroutine.stderr | 4 +- tests/ui/nll/issue-55850.rs | 2 +- tests/ui/nll/issue-55850.stderr | 14 ++-- tests/ui/packed/packed-struct-drop-aligned.rs | 2 +- tests/ui/print_type_sizes/coroutine.rs | 2 +- .../coroutine_discr_placement.rs | 4 +- .../rfc-2091-track-caller/tracked-closure.rs | 8 +- tests/ui/sanitizer/cfi/coroutine.rs | 6 +- tests/ui/sized-hierarchy/impls.rs | 6 +- tests/ui/suggestions/issue-84973-blacklist.rs | 2 +- .../suggestions/issue-84973-blacklist.stderr | 4 +- tests/ui/suggestions/unnamable-types.rs | 2 +- tests/ui/suggestions/unnamable-types.stderr | 4 +- .../traits/next-solver/coroutine.fail.stderr | 2 +- tests/ui/traits/next-solver/coroutine.rs | 4 +- .../issue-53678-coroutine-and-const-fn.rs | 2 +- .../issue-58662-coroutine-with-lifetime.rs | 4 +- tests/ui/type-alias-impl-trait/issue-94429.rs | 2 +- tests/ui/unpretty/exhaustive.expanded.stdout | 2 +- tests/ui/unpretty/exhaustive.hir.stderr | 4 +- tests/ui/unpretty/exhaustive.rs | 4 +- 292 files changed, 745 insertions(+), 788 deletions(-) diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index e93351bcf7125..da2550a58737e 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -1532,7 +1532,6 @@ impl Expr { ExprKind::Break(_ /*label*/, value) | ExprKind::Ret(value) - | ExprKind::Yield(YieldKind::Prefix(value)) | ExprKind::Yeet(value) => match value { Some(_) => ExprPrecedence::Jump, None => prefix_attrs_precedence(&self.attrs), @@ -2090,8 +2089,6 @@ pub enum MatchKind { /// The kind of yield expression #[derive(Clone, Encodable, Decodable, Debug, Walkable)] pub enum YieldKind { - /// yield expr { ... } - Prefix(Option>), /// expr.yield { ... } Postfix(Box), } @@ -2102,7 +2099,6 @@ impl YieldKind { /// For postfix yields, this is guaranteed to be `Some`. pub const fn expr(&self) -> Option<&Box> { match self { - YieldKind::Prefix(expr) => expr.as_ref(), YieldKind::Postfix(expr) => Some(expr), } } @@ -2110,7 +2106,6 @@ impl YieldKind { /// Returns a mutable reference to the expression being yielded, if any. pub const fn expr_mut(&mut self) -> Option<&mut Box> { match self { - YieldKind::Prefix(expr) => expr.as_mut(), YieldKind::Postfix(expr) => Some(expr), } } @@ -2118,9 +2113,7 @@ impl YieldKind { /// Returns true if both yields are prefix or both are postfix. pub const fn same_kind(&self, other: &Self) -> bool { match (self, other) { - (YieldKind::Prefix(_), YieldKind::Prefix(_)) => true, (YieldKind::Postfix(_), YieldKind::Postfix(_)) => true, - _ => false, } } } diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs index 2be2fca87c3c5..9977fd26df91f 100644 --- a/compiler/rustc_ast_lowering/src/expr.rs +++ b/compiler/rustc_ast_lowering/src/expr.rs @@ -815,7 +815,7 @@ impl<'hir> LoweringContext<'_, 'hir> { /// ::std::task::Poll::Ready(result) => break result, /// ::std::task::Poll::Pending => {} /// } - /// task_context = yield (); + /// task_context = ().yield; /// } /// } /// ``` @@ -962,8 +962,8 @@ impl<'hir> LoweringContext<'_, 'hir> { }; // Depending on `async` of `async gen`: - // async - task_context = yield (); - // async gen - task_context = yield ASYNC_GEN_PENDING; + // async - task_context = ().yield; + // async gen - task_context = ASYNC_GEN_PENDING.yield; let yield_stmt = { let yielded = if is_async_gen { self.arena.alloc(self.expr_lang_item_path(span, hir::LangItem::AsyncGenPending)) @@ -1713,7 +1713,7 @@ impl<'hir> LoweringContext<'_, 'hir> { }; if is_async_gen { - // `yield $expr` is transformed into `task_context = yield async_gen_ready($expr)`. + // `$expr.yield` is transformed into `task_context = async_gen_ready($expr).yield`. // This ensures that we store our resumed `ResumeContext` correctly, and also that // the apparent value of the `yield` expression is `()`. let desugar_span = self.mark_span_with_reason( diff --git a/compiler/rustc_ast_pretty/src/pprust/state/expr.rs b/compiler/rustc_ast_pretty/src/pprust/state/expr.rs index bdf73ac32f0d8..34cc0d4674380 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state/expr.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state/expr.rs @@ -794,14 +794,6 @@ impl<'a> State<'a> { self.print_expr(e, FixupContext::default()); self.pclose(); } - ast::ExprKind::Yield(YieldKind::Prefix(e)) => { - self.word("yield"); - - if let Some(expr) = e { - self.space(); - self.print_expr(expr, fixup.rightmost_subexpression()); - } - } ast::ExprKind::Yield(YieldKind::Postfix(e)) => { self.print_expr_cond_paren( e, diff --git a/compiler/rustc_ast_pretty/src/pprust/state/fixup.rs b/compiler/rustc_ast_pretty/src/pprust/state/fixup.rs index eb5ac8b78a83d..e55539c1d819c 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state/fixup.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state/fixup.rs @@ -1,6 +1,6 @@ use rustc_ast::util::classify; use rustc_ast::util::parser::{self, ExprPrecedence}; -use rustc_ast::{Expr, ExprKind, YieldKind}; +use rustc_ast::{Expr, ExprKind}; // The default amount of fixing is minimal fixing, so all fixups are set to `false` by `Default`. // Fixups should be turned on in a targeted fashion where needed. @@ -239,11 +239,7 @@ impl FixupContext { // Decrease precedence of value-less jumps when followed by an // operator that would otherwise get interpreted as beginning a // value for the jump. - if let ExprKind::Break(..) - | ExprKind::Ret(..) - | ExprKind::Yeet(..) - | ExprKind::Yield(YieldKind::Prefix(..)) = expr.kind - { + if let ExprKind::Break(..) | ExprKind::Ret(..) | ExprKind::Yeet(..) = expr.kind { return ExprPrecedence::Jump; } } @@ -255,7 +251,6 @@ impl FixupContext { | ExprKind::Closure(..) | ExprKind::Ret(..) | ExprKind::Yeet(..) - | ExprKind::Yield(YieldKind::Prefix(..)) | ExprKind::Range(None, ..) = expr.kind { return ExprPrecedence::Prefix; diff --git a/compiler/rustc_codegen_cranelift/example/gen_block_iterate.rs b/compiler/rustc_codegen_cranelift/example/gen_block_iterate.rs index de9a3d550eccd..be302a7741d73 100644 --- a/compiler/rustc_codegen_cranelift/example/gen_block_iterate.rs +++ b/compiler/rustc_codegen_cranelift/example/gen_block_iterate.rs @@ -7,9 +7,9 @@ fn foo() -> impl Iterator { gen { - yield 42; + 42.yield; for x in 3..6 { - yield x + x.yield; } } } @@ -17,13 +17,13 @@ fn foo() -> impl Iterator { fn moved() -> impl Iterator { let mut x = "foo".to_string(); gen move { - yield 42; + 42.yield; if x == "foo" { return; } x.clear(); for x in 3..6 { - yield x + x.yield; } } } diff --git a/compiler/rustc_codegen_cranelift/example/std_example.rs b/compiler/rustc_codegen_cranelift/example/std_example.rs index 5d83066cffb88..0316ff4301245 100644 --- a/compiler/rustc_codegen_cranelift/example/std_example.rs +++ b/compiler/rustc_codegen_cranelift/example/std_example.rs @@ -126,7 +126,7 @@ fn main() { Box::pin( #[coroutine] move |mut _task_context| { - yield (); + ().yield; }, ) .as_mut() diff --git a/compiler/rustc_codegen_gcc/example/std_example.rs b/compiler/rustc_codegen_gcc/example/std_example.rs index 7587b4827ca76..49a76d8bbb96d 100644 --- a/compiler/rustc_codegen_gcc/example/std_example.rs +++ b/compiler/rustc_codegen_gcc/example/std_example.rs @@ -104,7 +104,7 @@ fn main() { } Box::pin(#[coroutine] move |mut _task_context| { - yield (); + ().yield; }).as_mut().resume(0); println!("End"); diff --git a/compiler/rustc_error_codes/src/error_codes/E0626.md b/compiler/rustc_error_codes/src/error_codes/E0626.md index 71c1f811aa774..a259f8ff7b1a1 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0626.md +++ b/compiler/rustc_error_codes/src/error_codes/E0626.md @@ -9,7 +9,7 @@ Erroneous code example: # use std::pin::Pin; let mut b = #[coroutine] || { let a = &String::new(); // <-- This borrow... - yield (); // ...is still in scope here, when the yield occurs. + ().yield; // ...is still in scope here, when the yield occurs. println!("{}", a); }; Pin::new(&mut b).resume(()); @@ -26,7 +26,7 @@ scope. To resolve this error, the coroutine may be marked `static`: # use std::pin::Pin; let mut b = #[coroutine] static || { // <-- note the static keyword let a = &String::from("hello, world"); - yield (); + ().yield; println!("{}", a); }; let mut b = std::pin::pin!(b); @@ -44,7 +44,7 @@ type by value: # use std::pin::Pin; let mut b = #[coroutine] || { let a = String::from("hello, world"); - yield (); + ().yield; println!("{}", a); }; Pin::new(&mut b).resume(()); @@ -63,7 +63,7 @@ This error also frequently arises with iteration: let mut b = #[coroutine] || { let v = vec![1,2,3]; for &x in &v { // <-- borrow of `v` is still in scope... - yield x; // ...when this yield occurs. + x.yield; // ...when this yield occurs. } }; Pin::new(&mut b).resume(()); @@ -79,7 +79,7 @@ Such cases can sometimes be resolved by iterating "by value" (or using let mut b = #[coroutine] || { let v = vec![1,2,3]; for x in v { // <-- Take ownership of the values instead! - yield x; // <-- Now yield is OK. + x.yield; // <-- Now yield is OK. } }; Pin::new(&mut b).resume(()); @@ -96,7 +96,7 @@ let mut b = #[coroutine] || { let len = v.len(); // (*) for i in 0..len { let x = v[i]; // (*) - yield x; // <-- Now yield is OK. + x.yield; // <-- Now yield is OK. } }; Pin::new(&mut b).resume(()); diff --git a/compiler/rustc_error_codes/src/error_codes/E0627.md b/compiler/rustc_error_codes/src/error_codes/E0627.md index da2e2d355a160..5fd85388a2548 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0627.md +++ b/compiler/rustc_error_codes/src/error_codes/E0627.md @@ -6,7 +6,7 @@ Erroneous code example: #![feature(coroutines, coroutine_trait, stmt_expr_attributes)] fn fake_coroutine() -> &'static str { - yield 1; + 1.yield; return "foo" } @@ -23,7 +23,7 @@ literal. This can be fixed by constructing the coroutine correctly. fn main() { let mut coroutine = #[coroutine] || { - yield 1; + 1.yield; return "foo" }; } diff --git a/compiler/rustc_error_codes/src/error_codes/E0628.md b/compiler/rustc_error_codes/src/error_codes/E0628.md index d0d387cf6c7ef..ea8ec37a0e620 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0628.md +++ b/compiler/rustc_error_codes/src/error_codes/E0628.md @@ -9,7 +9,7 @@ fn main() { let coroutine = #[coroutine] |a: i32, b: i32| { // error: too many parameters for a coroutine // Allowed only 0 or 1 parameter - yield a; + a.yield; }; } ``` @@ -24,7 +24,7 @@ the previous example by passing only one parameter. fn main() { let coroutine = #[coroutine] |a: i32| { - yield a; + a.yield; }; } ``` diff --git a/compiler/rustc_error_codes/src/error_codes/E0727.md b/compiler/rustc_error_codes/src/error_codes/E0727.md index 7754186508f11..059c14090acd5 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0727.md +++ b/compiler/rustc_error_codes/src/error_codes/E0727.md @@ -8,7 +8,7 @@ Erroneous code example: fn main() { let coroutine = #[coroutine] || { async { - yield; + ().yield; } }; } @@ -24,7 +24,7 @@ To fix this error, you have to move `yield` out of the `async` block: fn main() { let coroutine = #[coroutine] || { - yield; + ().yield; }; } ``` diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index d26e289bc0d28..f4711b184452e 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -1626,7 +1626,7 @@ pub enum ClosureKind { Closure, /// This is a coroutine expression -- i.e. a closure expression in which /// we've found a `yield`. These can arise either from "plain" coroutine - /// usage (e.g. `let x = || { yield (); }`) or from a desugared expression + /// usage (e.g. `let x = || { ().yield; }`) or from a desugared expression /// (e.g. `async` and `gen` blocks). Coroutine(CoroutineKind), /// This is a coroutine-closure, which is a special sugared closure that diff --git a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs b/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs index 8133f9f68234b..d56f9ffc34250 100644 --- a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs +++ b/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs @@ -2195,7 +2195,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> { { // Yield the trait's def id. Supertraits will be // elaborated from that. - yield item.owner_id.def_id.to_def_id(); + item.owner_id.def_id.to_def_id().yield; } else if let Some(generics) = node.generics() { for pred in generics.predicates { let hir::WherePredicateKind::BoundPredicate(pred) = pred.kind else { @@ -2216,7 +2216,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> { if let Some(def_id) = poly_trait_ref.trait_ref.trait_def_id() { - yield def_id; + def_id.yield; } } hir::GenericBound::Outlives(_) diff --git a/compiler/rustc_metadata/src/rmeta/decoder.rs b/compiler/rustc_metadata/src/rmeta/decoder.rs index b895feb906247..243ed714ae523 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder.rs @@ -1288,20 +1288,20 @@ impl<'a> CrateMetadataRef<'a> { // the view of this crate as a proc macro crate. if id == CRATE_DEF_INDEX { for child_index in data.macros.decode(self) { - yield self.get_mod_child(child_index, sess); + self.get_mod_child(child_index, sess).yield; } } } else { // Iterate over all children. let non_reexports = self.root.tables.module_children_non_reexports.get(self, id); for child_index in non_reexports.unwrap().decode(self) { - yield self.get_mod_child(child_index, sess); + self.get_mod_child(child_index, sess).yield; } let reexports = self.root.tables.module_children_reexports.get(self, id); if !reexports.is_default() { for reexport in reexports.decode((self, sess)) { - yield reexport; + reexport.yield; } } } @@ -2016,7 +2016,7 @@ impl CrateMetadata { .decode(CrateMetadataRef { cdata: self, cstore }) .map(move |index| DefId { index, krate }) }) { - yield def_id; + def_id.yield; } } } diff --git a/compiler/rustc_middle/src/ty/closure.rs b/compiler/rustc_middle/src/ty/closure.rs index ce6f87668beff..513883166e0c7 100644 --- a/compiler/rustc_middle/src/ty/closure.rs +++ b/compiler/rustc_middle/src/ty/closure.rs @@ -454,10 +454,8 @@ pub fn analyze_coroutine_closure_captures<'a, 'tcx: 'a, T>( child capture ({child_capture:#?})" ); - yield for_each( - (parent_field_idx, parent_capture), - (child_field_idx, child_capture), - ); + for_each((parent_field_idx, parent_capture), (child_field_idx, child_capture)) + .yield; field_used_at_least_once = true; } diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 60effa13406be..49c837f2df3ac 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -2214,7 +2214,7 @@ impl<'tcx> TyCtxt<'tcx> { // new ones. while i < { definitions.read().num_definitions() } { let local_def_index = rustc_span::def_id::DefIndex::from_usize(i); - yield LocalDefId { local_def_index }; + LocalDefId { local_def_index }.yield; i += 1; } diff --git a/compiler/rustc_mir_transform/src/coroutine.rs b/compiler/rustc_mir_transform/src/coroutine.rs index 54ed2a95174ee..3d7543fc92efa 100644 --- a/compiler/rustc_mir_transform/src/coroutine.rs +++ b/compiler/rustc_mir_transform/src/coroutine.rs @@ -31,7 +31,7 @@ //! 1 - Coroutine has returned / is completed //! 2 - Coroutine has been poisoned //! -//! It also rewrites `return x` and `yield y` as setting a new coroutine state and returning +//! It also rewrites `return x` and `y.yield` as setting a new coroutine state and returning //! `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 coroutine struct @@ -1589,7 +1589,7 @@ impl<'tcx> crate::MirPass<'tcx> for StateTransform { // Run the transformation which converts Places from Local to coroutine struct // accesses for locals in `remap`. - // It also rewrites `return x` and `yield y` as writing a new coroutine state and returning + // It also rewrites `return x` and `y.yield` as writing a new coroutine state and returning // either `CoroutineState::Complete(x)` and `CoroutineState::Yielded(y)`, // or `Poll::Ready(x)` and `Poll::Pending` respectively depending on the coroutine kind. let mut transform = TransformVisitor { diff --git a/compiler/rustc_mir_transform/src/coverage/expansion.rs b/compiler/rustc_mir_transform/src/coverage/expansion.rs index 851bbaeed48eb..b2e14fad1af3e 100644 --- a/compiler/rustc_mir_transform/src/coverage/expansion.rs +++ b/compiler/rustc_mir_transform/src/coverage/expansion.rs @@ -26,7 +26,7 @@ impl ExpnTree { ) -> impl Iterator { gen move { let Some(root_node) = self.get(root_expn_id) else { return }; - yield root_node; + root_node.yield; // Stack of child-node-ID iterators that drives the depth-first traversal. let mut iter_stack = vec![root_node.child_expn_ids.iter()]; @@ -40,7 +40,7 @@ impl ExpnTree { // Yield this node. let Some(node) = self.get(curr_id) else { continue }; - yield node; + node.yield; // Push the node's children, to be traversed next. if !node.child_expn_ids.is_empty() { diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index e7c89f0796224..3e72eb8aae9d0 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -1525,8 +1525,6 @@ impl<'a> Parser<'a> { this.parse_expr_continue(lo) } else if this.eat_keyword(exp!(Break)) { this.parse_expr_break() - } else if this.eat_keyword(exp!(Yield)) { - this.parse_expr_yield() } else if this.is_do_yeet() { this.parse_expr_yeet() } else if this.eat_keyword(exp!(Become)) { @@ -1952,16 +1950,6 @@ impl<'a> Parser<'a> { Ok(self.mk_expr(lo.to(self.prev_token.span), kind)) } - /// Parse `"yield" expr?`. - fn parse_expr_yield(&mut self) -> PResult<'a, Box> { - let lo = self.prev_token.span; - let kind = ExprKind::Yield(YieldKind::Prefix(self.parse_expr_opt()?)); - let span = lo.to(self.prev_token.span); - self.psess.gated_spans.gate(sym::yield_expr, span); - let expr = self.mk_expr(span, kind); - self.maybe_recover_from_bad_qpath(expr) - } - /// Parse `builtin # ident(args,*)`. fn parse_expr_builtin(&mut self) -> PResult<'a, Box> { self.parse_builtin(|this, lo, ident| { diff --git a/compiler/rustc_type_ir/src/ty_kind.rs b/compiler/rustc_type_ir/src/ty_kind.rs index bb80e2cf46d45..6d020dca91363 100644 --- a/compiler/rustc_type_ir/src/ty_kind.rs +++ b/compiler/rustc_type_ir/src/ty_kind.rs @@ -168,7 +168,7 @@ pub enum TyKind { CoroutineClosure(I::CoroutineClosureId, I::GenericArgs), /// The anonymous type of a coroutine. Used to represent the type of - /// `|a| yield a`. + /// `|a| a.yield`. /// /// For more info about coroutine args, visit the documentation for /// `CoroutineArgs`. @@ -192,8 +192,8 @@ pub enum TyKind { /// #![feature(coroutines)] /// #[coroutine] static |a| { /// let x = &vec![3]; - /// yield a; - /// yield x[0]; + /// a.yield; + /// x[0].yield; /// } /// # ; /// ``` diff --git a/library/core/src/iter/sources/from_coroutine.rs b/library/core/src/iter/sources/from_coroutine.rs index 710ba504ded64..bcebcec675b40 100644 --- a/library/core/src/iter/sources/from_coroutine.rs +++ b/library/core/src/iter/sources/from_coroutine.rs @@ -15,9 +15,9 @@ use crate::pin::Pin; /// #![feature(iter_from_coroutine)] /// /// let it = std::iter::from_coroutine(#[coroutine] || { -/// yield 1; -/// yield 2; -/// yield 3; +/// 1.yield; +/// 2.yield; +/// 3.yield; /// }); /// let v: Vec<_> = it.collect(); /// assert_eq!(v, [1, 2, 3]); diff --git a/library/core/src/iter/sources/generator.rs b/library/core/src/iter/sources/generator.rs index 94d501de033be..b1724c56894c7 100644 --- a/library/core/src/iter/sources/generator.rs +++ b/library/core/src/iter/sources/generator.rs @@ -11,9 +11,9 @@ /// #![feature(iter_macro, coroutines)] /// /// let it = std::iter::iter!{|| { -/// yield 1; -/// yield 2; -/// yield 3; +/// 1.yield; +/// 2.yield; +/// 3.yield; /// } }(); /// let v: Vec<_> = it.collect(); /// assert_eq!(v, [1, 2, 3]); diff --git a/library/core/src/ops/coroutine.rs b/library/core/src/ops/coroutine.rs index c7d596d74c383..f59240dbcd920 100644 --- a/library/core/src/ops/coroutine.rs +++ b/library/core/src/ops/coroutine.rs @@ -47,7 +47,7 @@ pub enum CoroutineState { /// /// fn main() { /// let mut coroutine = #[coroutine] || { -/// yield 1; +/// 1.yield; /// "foo" /// }; /// diff --git a/library/core/src/pin.rs b/library/core/src/pin.rs index 81c2dabf0d1d8..6a6b45f99fb15 100644 --- a/library/core/src/pin.rs +++ b/library/core/src/pin.rs @@ -1954,9 +1954,9 @@ unsafe impl PinCoerceUnsized for *mut T {} /// #[coroutine] static || { /// let foo = String::from("foo"); /// let foo_ref = &foo; // ------+ -/// yield 0; // | <- crosses yield point! +/// 0.yield; // | <- crosses yield point! /// println!("{foo_ref}"); // <--+ -/// yield foo.len(); +/// foo.len().yield; /// } /// } /// diff --git a/library/core/src/unicode/printable.py b/library/core/src/unicode/printable.py index 260fa9f9e6ad2..744a0a8b6d087 100755 --- a/library/core/src/unicode/printable.py +++ b/library/core/src/unicode/printable.py @@ -17,12 +17,12 @@ def to_ranges(iter): for i in iter: if current is None or i != current[1] or i in (0x10000, 0x20000): if current is not None: - yield tuple(current) + tuple(current).yield current = [i, i + 1] else: current[1] += 1 if current is not None: - yield tuple(current) + tuple(current).yield def get_escaped(codepoints): @@ -30,7 +30,7 @@ def get_escaped(codepoints): if (c.class_ or "Cn") in "Cc Cf Cs Co Cn Zl Zp Zs".split() and c.value != ord( " " ): - yield c.value + c.value.yield def get_file(f): @@ -58,20 +58,20 @@ def get_codepoints(f): raise ValueError("Missing Last after First") for c in range(prev_codepoint + 1, codepoint): - yield Codepoint(c, class_first) + Codepoint(c, class_first).yield class_first = None if name.endswith("First>"): class_first = class_ - yield Codepoint(codepoint, class_) + Codepoint(codepoint, class_).yield prev_codepoint = codepoint if class_first is not None: raise ValueError("Missing Last after First") for c in range(prev_codepoint + 1, NUM_CODEPOINTS): - yield Codepoint(c, None) + Codepoint(c, None).yield def compress_singletons(singletons): diff --git a/src/doc/unstable-book/src/language-features/coroutines.md b/src/doc/unstable-book/src/language-features/coroutines.md index 9fb07594650f4..754b5baf9b585 100644 --- a/src/doc/unstable-book/src/language-features/coroutines.md +++ b/src/doc/unstable-book/src/language-features/coroutines.md @@ -33,7 +33,7 @@ use std::pin::Pin; fn main() { let mut coroutine = #[coroutine] || { - yield 1; + 1.yield; return "foo" }; @@ -67,7 +67,7 @@ use std::pin::Pin; fn main() { let mut coroutine = #[coroutine] || { println!("2"); - yield; + ().yield; println!("4"); }; @@ -172,7 +172,7 @@ use std::pin::Pin; fn main() { let ret = "foo"; let mut coroutine = #[coroutine] move || { - yield 1; + 1.yield; return ret }; diff --git a/src/doc/unstable-book/src/the-unstable-book.md b/src/doc/unstable-book/src/the-unstable-book.md index 63134f7ae28c4..40f2e288ae50f 100644 --- a/src/doc/unstable-book/src/the-unstable-book.md +++ b/src/doc/unstable-book/src/the-unstable-book.md @@ -12,7 +12,7 @@ use std::pin::Pin; fn main() { let mut coroutine = #[coroutine] || { - yield 1; + 1.yield; return "foo" }; diff --git a/src/tools/miri/tests/pass/coroutine.rs b/src/tools/miri/tests/pass/coroutine.rs index 96b60b515cb6d..49872858ef2d0 100644 --- a/src/tools/miri/tests/pass/coroutine.rs +++ b/src/tools/miri/tests/pass/coroutine.rs @@ -45,7 +45,7 @@ fn basic() { 1, false, #[coroutine] - || yield 1, + || 1.yield, ); finish( @@ -54,11 +54,11 @@ fn basic() { #[coroutine] || { let mut x = 0; - yield 1; + 1.yield; x += 1; - yield 1; + 1.yield; x += 1; - yield 1; + 1.yield; assert_eq!(x, 2); }, ); @@ -69,7 +69,7 @@ fn basic() { #[coroutine] || { for i in 0..8 { - yield i; + i.yield; } }, ); @@ -80,7 +80,7 @@ fn basic() { #[coroutine] || { if true { - yield 1; + 1.yield; } else { } }, @@ -93,7 +93,7 @@ fn basic() { || { if false { } else { - yield 1; + 1.yield; } }, ); @@ -104,13 +104,13 @@ fn basic() { #[coroutine] || { if { - yield 1; + 1.yield; false } { - yield 1; + 1.yield; panic!() } - yield 1; + 1.yield; }, ); @@ -124,7 +124,7 @@ fn basic() { let mut x = 5; let y = &mut x; *y = 5; - yield *y; + y.yield; *y = 10; x } @@ -140,7 +140,7 @@ fn basic() { let mut x = Box::new(5); let y = &mut *x; *y = 5; - yield *y; + y.yield; *y = 10; *x } @@ -154,14 +154,14 @@ fn basic() { false, #[coroutine] || { - yield 1; + 1.yield; if b { return; } #[allow(unused)] let x = never(); #[allow(unreachable_code)] - yield 2; + 2.yield; drop(x); }, ); @@ -171,10 +171,10 @@ fn basic() { false, #[coroutine] || { - yield 1; + 1.yield; #[allow(unreachable_code)] let _x: (String, !) = (String::new(), { - yield 2; + 2.yield; return; }); }, @@ -223,7 +223,7 @@ fn smoke_resume_arg() { &mut #[coroutine] |mut b| { while b != 0 { - b = yield (b + 1); + b = (b + 1).yield; } -1 }, @@ -233,7 +233,7 @@ fn smoke_resume_arg() { expect_drops(2, || { drain( &mut #[coroutine] - |a| yield a, + |a| a.yield, vec![(DropMe, Yielded(DropMe))], ) }); @@ -241,7 +241,7 @@ fn smoke_resume_arg() { expect_drops(6, || { drain( &mut #[coroutine] - |a| yield yield a, + |a| a.yield.yield, vec![(DropMe, Yielded(DropMe)), (DropMe, Yielded(DropMe)), (DropMe, Complete(DropMe))], ) }); @@ -250,7 +250,7 @@ fn smoke_resume_arg() { expect_drops(2, || { drain( &mut #[coroutine] - |a| yield return a, + |a| (return a).yield, vec![(DropMe, Complete(DropMe))], ) }); @@ -259,7 +259,7 @@ fn smoke_resume_arg() { drain( &mut #[coroutine] |a: DropMe| { - if false { yield () } else { a } + if false { ().yield } else { a } }, vec![(DropMe, Complete(DropMe))], ) @@ -270,9 +270,9 @@ fn smoke_resume_arg() { #[allow(unused_assignments, unused_variables)] &mut #[coroutine] |mut a: DropMe| { - a = yield; - a = yield; - a = yield; + a = ().yield; + a = ().yield; + a = ().yield; }, vec![ (DropMe, Yielded(())), @@ -299,13 +299,13 @@ fn uninit_fields() { if y { _a = conjure::(); } - yield (); + ().yield; } else { let _a: T; if y { _a = conjure::(); } - yield (); + ().yield; } }; assert!(matches!(Pin::new(&mut c).resume(()), CoroutineState::Yielded(()))); diff --git a/src/tools/miri/tests/pass/iter_macro.rs b/src/tools/miri/tests/pass/iter_macro.rs index 367c13f996905..d5aaa7b5f4676 100644 --- a/src/tools/miri/tests/pass/iter_macro.rs +++ b/src/tools/miri/tests/pass/iter_macro.rs @@ -4,9 +4,9 @@ use std::iter::iter; fn main() { let i = iter! { || { - yield 0; + 0.yield; for x in 5..10 { - yield x * 2; + (x * 2).yield; } } }; let mut i = i(); diff --git a/src/tools/miri/tests/pass/stacked_borrows/coroutine-self-referential.rs b/src/tools/miri/tests/pass/stacked_borrows/coroutine-self-referential.rs index 72e360fe19a1f..bb794dbbecf7c 100644 --- a/src/tools/miri/tests/pass/stacked_borrows/coroutine-self-referential.rs +++ b/src/tools/miri/tests/pass/stacked_borrows/coroutine-self-referential.rs @@ -11,13 +11,13 @@ fn firstn() -> impl Coroutine { let mut num = 0; let num = &mut num; - yield *num; + (*num).yield; *num += 1; // would fail here - yield *num; + (*num).yield; *num += 1; - yield *num; + (*num).yield; *num += 1; } } diff --git a/src/tools/miri/tests/pass/track-caller-attribute.rs b/src/tools/miri/tests/pass/track-caller-attribute.rs index c3803af3cc8ec..bc9a58c25ce43 100644 --- a/src/tools/miri/tests/pass/track-caller-attribute.rs +++ b/src/tools/miri/tests/pass/track-caller-attribute.rs @@ -233,8 +233,8 @@ fn test_coroutine() { #[rustfmt::skip] let coroutine = #[track_caller] #[coroutine] |arg: String| { - yield ("first", arg.clone(), Location::caller()); - yield ("second", arg.clone(), Location::caller()); + ("first", arg.clone(), Location::caller()).yield; + ("second", arg.clone(), Location::caller()).yield; }; let mut pinned = Box::pin(coroutine); diff --git a/src/tools/rustfmt/src/expr.rs b/src/tools/rustfmt/src/expr.rs index 975f9be44e4d3..18e4bb0e2b2bd 100644 --- a/src/tools/rustfmt/src/expr.rs +++ b/src/tools/rustfmt/src/expr.rs @@ -221,13 +221,6 @@ pub(crate) fn format_expr( Ok(format!("break{id_str}")) } } - ast::ExprKind::Yield(ast::YieldKind::Prefix(ref opt_expr)) => { - if let Some(ref expr) = *opt_expr { - rewrite_unary_prefix(context, "yield ", &**expr, shape) - } else { - Ok("yield".to_string()) - } - } ast::ExprKind::Closure(ref cl) => closures::rewrite_closure( &cl.binder, cl.constness, diff --git a/src/tools/rustfmt/src/utils.rs b/src/tools/rustfmt/src/utils.rs index b9950e94d0c31..fe3bf7089ec09 100644 --- a/src/tools/rustfmt/src/utils.rs +++ b/src/tools/rustfmt/src/utils.rs @@ -1,6 +1,5 @@ use std::borrow::Cow; -use rustc_ast::YieldKind; use rustc_ast::ast::{ self, Attribute, MetaItem, MetaItemInner, MetaItemKind, NodeId, Path, Visibility, VisibilityKind, @@ -484,8 +483,7 @@ pub(crate) fn is_block_expr(context: &RewriteContext<'_>, expr: &ast::Expr, repr | ast::ExprKind::Binary(_, _, ref expr) | ast::ExprKind::Index(_, ref expr, _) | ast::ExprKind::Unary(_, ref expr) - | ast::ExprKind::Try(ref expr) - | ast::ExprKind::Yield(YieldKind::Prefix(Some(ref expr))) => { + | ast::ExprKind::Try(ref expr) => { is_block_expr(context, expr, repr) } ast::ExprKind::Closure(ref closure) => is_block_expr(context, &closure.body, repr), diff --git a/tests/codegen-llvm/coroutine-debug.rs b/tests/codegen-llvm/coroutine-debug.rs index ff62e9709b4be..0d21b5b1a7dba 100644 --- a/tests/codegen-llvm/coroutine-debug.rs +++ b/tests/codegen-llvm/coroutine-debug.rs @@ -14,9 +14,9 @@ use std::ops::Coroutine; fn coroutine_test() -> impl Coroutine { #[coroutine] || { - yield 0; + 0.yield; let s = String::from("foo"); - yield 1; + 1.yield; } } diff --git a/tests/codegen-llvm/issues/issue-98678-closure-coroutine.rs b/tests/codegen-llvm/issues/issue-98678-closure-coroutine.rs index 8763bcb799ded..eb4f1ed334d0b 100644 --- a/tests/codegen-llvm/issues/issue-98678-closure-coroutine.rs +++ b/tests/codegen-llvm/issues/issue-98678-closure-coroutine.rs @@ -21,5 +21,5 @@ pub fn foo() { // NONMSVC-DAG: !DICompositeType({{.*"[{]}}coroutine_env#1{{[}]".*}}file: ![[#FILE]]{{.*}}line: [[# @LINE + 3]], // MSVC-DAG: !DICompositeType({{.*".*foo::}}coroutine_env$1>{{".*}}file: ![[#FILE]]{{.*}}line: [[# @LINE + 2]], let _coroutine = #[coroutine] - || yield 1; + || 1.yield; } diff --git a/tests/coverage/coroutine.rs b/tests/coverage/coroutine.rs index bd149764b3737..61a16d8d32ed2 100644 --- a/tests/coverage/coroutine.rs +++ b/tests/coverage/coroutine.rs @@ -20,7 +20,7 @@ fn main() { let is_true = std::env::args().len() == 1; let mut coroutine = #[coroutine] || { - yield get_u32(is_true); + get_u32(is_true).yield; return "foo"; }; diff --git a/tests/coverage/yield.rs b/tests/coverage/yield.rs index e02e3d3561243..08bc22dfbc9da 100644 --- a/tests/coverage/yield.rs +++ b/tests/coverage/yield.rs @@ -7,7 +7,7 @@ use std::pin::Pin; fn main() { let mut coroutine = #[coroutine] || { - yield 1; + 1.yield; return "foo"; }; @@ -22,9 +22,9 @@ fn main() { let mut coroutine = #[coroutine] || { - yield 1; - yield 2; - yield 3; + 1.yield; + 2.yield; + 3.yield; return "foo"; }; diff --git a/tests/crashes/139570.rs b/tests/crashes/139570.rs index 9c001aaf848aa..eddf52f92b617 100644 --- a/tests/crashes/139570.rs +++ b/tests/crashes/139570.rs @@ -1,4 +1,4 @@ //@ known-bug: #139570 fn main() { - |(1, 42), ()| yield; + |(1, 42), ()| ().yield; } diff --git a/tests/mir-opt/building/coroutine.rs b/tests/mir-opt/building/coroutine.rs index 6d50c4d90b1a4..7ddf7f344ed0d 100644 --- a/tests/mir-opt/building/coroutine.rs +++ b/tests/mir-opt/building/coroutine.rs @@ -16,14 +16,14 @@ use std::pin::Pin; fn main() { let simple = #[coroutine] |arg: String| { - yield ("first", arg.clone(), Location::caller()); - yield ("second", arg.clone(), Location::caller()); + ("first", arg.clone(), Location::caller()).yield; + ("second", arg.clone(), Location::caller()).yield; }; let track_caller = #[track_caller] #[coroutine] |arg: String| { - yield ("first", arg.clone(), Location::caller()); - yield ("second", arg.clone(), Location::caller()); + ("first", arg.clone(), Location::caller()).yield; + ("second", arg.clone(), Location::caller()).yield; }; } diff --git a/tests/mir-opt/coroutine_drop_cleanup.rs b/tests/mir-opt/coroutine_drop_cleanup.rs index 4ae97273cd90a..b63dfd8fc47b9 100644 --- a/tests/mir-opt/coroutine_drop_cleanup.rs +++ b/tests/mir-opt/coroutine_drop_cleanup.rs @@ -11,6 +11,6 @@ fn main() { let gen_ = #[coroutine] || { let _s = String::new(); - yield; + ().yield; }; } diff --git a/tests/mir-opt/coroutine_storage_dead_unwind.rs b/tests/mir-opt/coroutine_storage_dead_unwind.rs index ce9bad483af83..4cae0a34c6aa2 100644 --- a/tests/mir-opt/coroutine_storage_dead_unwind.rs +++ b/tests/mir-opt/coroutine_storage_dead_unwind.rs @@ -24,7 +24,7 @@ fn main() { || { let a = Foo(5); let b = Bar(6); - yield; + ().yield; take(a); take(b); }; diff --git a/tests/mir-opt/coroutine_tiny.rs b/tests/mir-opt/coroutine_tiny.rs index 81e9940541ba0..4b840f9d68601 100644 --- a/tests/mir-opt/coroutine_tiny.rs +++ b/tests/mir-opt/coroutine_tiny.rs @@ -21,7 +21,7 @@ fn main() { |_x: u8| { let _d = HasDrop; loop { - yield; + ().yield; callee(); } }; diff --git a/tests/mir-opt/inline/inline_coroutine.rs b/tests/mir-opt/inline/inline_coroutine.rs index 07f8fb20f7ea2..bd2895cfbd112 100644 --- a/tests/mir-opt/inline/inline_coroutine.rs +++ b/tests/mir-opt/inline/inline_coroutine.rs @@ -17,5 +17,5 @@ fn main() { pub fn g() -> impl Coroutine { #[inline] #[coroutine] - |a| yield if a { 7 } else { 13 } + |a| if a { 7 } else { 13 }.yield } diff --git a/tests/pretty/postfix-yield.rs b/tests/pretty/postfix-yield.rs index 60380a4071c54..29f1b5b8a115d 100644 --- a/tests/pretty/postfix-yield.rs +++ b/tests/pretty/postfix-yield.rs @@ -9,7 +9,7 @@ use std::ops::{Coroutine, CoroutineState}; use std::pin::pin; fn main() { - let mut gn = gen { yield 1; 2.yield; (1 + 2).yield; }; + let mut gn = gen { 1.yield; 2.yield; (1 + 2).yield; }; let mut coro = pin!(#[coroutine] |_: i32| { let x = 1.yield; (x + 2).yield; }); diff --git a/tests/ui/async-await/async-gen-move-suggestion.fixed b/tests/ui/async-await/async-gen-move-suggestion.fixed index d802076552895..b5f6c411aec98 100644 --- a/tests/ui/async-await/async-gen-move-suggestion.fixed +++ b/tests/ui/async-await/async-gen-move-suggestion.fixed @@ -16,7 +16,7 @@ fn moved() -> impl AsyncIterator { async gen move { //~ ERROR x.clear(); - for x in 3..6 { yield x } + for x in 3..6 { x.yield } } } @@ -27,7 +27,7 @@ fn check_with_whitespace_chars() -> impl AsyncIterator { async // Just to check that whitespace characters are correctly handled gen move { //~^ ERROR x.clear(); - for x in 3..6 { yield x } + for x in 3..6 { x.yield } } } diff --git a/tests/ui/async-await/async-gen-move-suggestion.rs b/tests/ui/async-await/async-gen-move-suggestion.rs index 825fb0fd1898c..8326900283dc5 100644 --- a/tests/ui/async-await/async-gen-move-suggestion.rs +++ b/tests/ui/async-await/async-gen-move-suggestion.rs @@ -16,7 +16,7 @@ fn moved() -> impl AsyncIterator { async gen { //~ ERROR x.clear(); - for x in 3..6 { yield x } + for x in 3..6 { x.yield } } } @@ -27,7 +27,7 @@ fn check_with_whitespace_chars() -> impl AsyncIterator { async // Just to check that whitespace characters are correctly handled gen { //~^ ERROR x.clear(); - for x in 3..6 { yield x } + for x in 3..6 { x.yield } } } diff --git a/tests/ui/async-await/async-gen-move-suggestion.stderr b/tests/ui/async-await/async-gen-move-suggestion.stderr index b8cdb8be7a4ae..7c81a46e9ef3b 100644 --- a/tests/ui/async-await/async-gen-move-suggestion.stderr +++ b/tests/ui/async-await/async-gen-move-suggestion.stderr @@ -11,7 +11,7 @@ note: async gen block is returned here | LL | / async gen { LL | | x.clear(); -LL | | for x in 3..6 { yield x } +LL | | for x in 3..6 { x.yield } LL | | } | |_____^ help: to force the async gen block to take ownership of `x` (and any other referenced variables), use the `move` keyword @@ -34,7 +34,7 @@ note: async gen block is returned here LL | / async // Just to check that whitespace characters are correctly handled LL | | gen { LL | | x.clear(); -LL | | for x in 3..6 { yield x } +LL | | for x in 3..6 { x.yield } LL | | } | |_____^ help: to force the async gen block to take ownership of `x` (and any other referenced variables), use the `move` keyword diff --git a/tests/ui/async-await/coroutine-not-future.rs b/tests/ui/async-await/coroutine-not-future.rs index de627333fe44c..6c9c8f64e3757 100644 --- a/tests/ui/async-await/coroutine-not-future.rs +++ b/tests/ui/async-await/coroutine-not-future.rs @@ -12,7 +12,7 @@ fn returns_async_block() -> impl Future { fn returns_coroutine() -> impl Coroutine<(), Yield = (), Return = ()> { #[coroutine] || { - let _: () = yield (); + let _: () = ().yield; } } @@ -28,7 +28,7 @@ fn main() { takes_coroutine( #[coroutine] || { - let _: () = yield (); + let _: () = ().yield; }, ); @@ -47,7 +47,7 @@ fn main() { #[coroutine] |ctx| { //~^ ERROR is not a future - ctx = yield (); + ctx = ().yield; }, ); } diff --git a/tests/ui/async-await/coroutine-not-future.stderr b/tests/ui/async-await/coroutine-not-future.stderr index b0f371f6706d1..0ef1b11f04202 100644 --- a/tests/ui/async-await/coroutine-not-future.stderr +++ b/tests/ui/async-await/coroutine-not-future.stderr @@ -63,7 +63,7 @@ LL | takes_future( LL | #[coroutine] LL | / |ctx| { LL | | -LL | | ctx = yield (); +LL | | ctx = ().yield; LL | | }, | |_________^ `{coroutine@$DIR/coroutine-not-future.rs:48:9: 48:14}` is not a future | diff --git a/tests/ui/async-await/for-await-passthrough.rs b/tests/ui/async-await/for-await-passthrough.rs index 0b9078ae046cd..1b75fee50fdd4 100644 --- a/tests/ui/async-await/for-await-passthrough.rs +++ b/tests/ui/async-await/for-await-passthrough.rs @@ -5,7 +5,7 @@ async gen fn async_iter() -> i32 { let iter = core::async_iter::from_iter(0..3); for await i in iter { - yield i + 1; + (i + 1).yield; } } diff --git a/tests/ui/async-await/issues/issue-65419/issue-65419-coroutine-resume-after-completion.rs b/tests/ui/async-await/issues/issue-65419/issue-65419-coroutine-resume-after-completion.rs index 6b7dfc1235e8e..076f15982623d 100644 --- a/tests/ui/async-await/issues/issue-65419/issue-65419-coroutine-resume-after-completion.rs +++ b/tests/ui/async-await/issues/issue-65419/issue-65419-coroutine-resume-after-completion.rs @@ -13,7 +13,7 @@ use std::{ops::Coroutine, pin::Pin}; fn main() { let mut g = #[coroutine] || { - yield; + ().yield; }; Pin::new(&mut g).resume(()); // Yields once. Pin::new(&mut g).resume(()); // Completes here. diff --git a/tests/ui/async-await/non-trivial-drop.rs b/tests/ui/async-await/non-trivial-drop.rs index 95de3c5b0054d..054ad24d0ddf8 100644 --- a/tests/ui/async-await/non-trivial-drop.rs +++ b/tests/ui/async-await/non-trivial-drop.rs @@ -9,10 +9,10 @@ fn main() { fn foo() { #[coroutine] || { - yield drop(Config { + drop(Config { nickname: NonCopy, b: NonCopy2, - }.nickname); + }.nickname).yield; }; } diff --git a/tests/ui/coherence/coherence-with-coroutine.rs b/tests/ui/coherence/coherence-with-coroutine.rs index 0e65a6c1da031..e32fee9a7c5b8 100644 --- a/tests/ui/coherence/coherence-with-coroutine.rs +++ b/tests/ui/coherence/coherence-with-coroutine.rs @@ -12,7 +12,7 @@ fn defining_use() -> OpaqueCoroutine { #[coroutine] || { for i in 0..10 { - yield i; + i.yield; } } } diff --git a/tests/ui/coroutine/addassign-yield.rs b/tests/ui/coroutine/addassign-yield.rs index 8329b53d715e6..2c0b727f40417 100644 --- a/tests/ui/coroutine/addassign-yield.rs +++ b/tests/ui/coroutine/addassign-yield.rs @@ -10,12 +10,12 @@ fn foo() { let _x = #[coroutine] static || { let mut s = String::new(); - s += { yield; "" }; + s += { ().yield; "" }; }; let _y = #[coroutine] static || { let x = &mut 0; - *{ yield; x } += match String::new() { _ => 0 }; + *{ ().yield; x } += match String::new() { _ => 0 }; }; // Please don't ever actually write something like this @@ -23,8 +23,8 @@ fn foo() { let x = &mut 0; *{ let inner = &mut 1; - *{ yield (); inner } += match String::new() { _ => 1}; - yield; + *{ ().yield; inner } += match String::new() { _ => 1}; + ().yield; x } += match String::new() { _ => 2 }; }; diff --git a/tests/ui/coroutine/async-coroutine-issue-67158.rs b/tests/ui/coroutine/async-coroutine-issue-67158.rs index 14905e6b8bf72..ec00746fb6fe4 100644 --- a/tests/ui/coroutine/async-coroutine-issue-67158.rs +++ b/tests/ui/coroutine/async-coroutine-issue-67158.rs @@ -2,5 +2,5 @@ //@ edition:2018 // Regression test for #67158. fn main() { - async { yield print!(":C") }; //~ ERROR `async` coroutines are not yet supported + async { print!(":C").yield }; //~ ERROR `async` coroutines are not yet supported } diff --git a/tests/ui/coroutine/async-coroutine-issue-67158.stderr b/tests/ui/coroutine/async-coroutine-issue-67158.stderr index 1c4a6b0c35530..7b18291e7d09f 100644 --- a/tests/ui/coroutine/async-coroutine-issue-67158.stderr +++ b/tests/ui/coroutine/async-coroutine-issue-67158.stderr @@ -1,7 +1,7 @@ error[E0727]: `async` coroutines are not yet supported --> $DIR/async-coroutine-issue-67158.rs:5:13 | -LL | async { yield print!(":C") }; +LL | async { print!(":C").yield }; | ^^^^^^^^^^^^^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/coroutine/async-gen-deduce-yield.rs b/tests/ui/coroutine/async-gen-deduce-yield.rs index a9572ee9b0dd9..6849e23fa4240 100644 --- a/tests/ui/coroutine/async-gen-deduce-yield.rs +++ b/tests/ui/coroutine/async-gen-deduce-yield.rs @@ -7,7 +7,7 @@ use std::async_iter::AsyncIterator; fn deduce() -> impl AsyncIterator { async gen { - yield Default::default(); + Default::default().yield; } } diff --git a/tests/ui/coroutine/async-gen-yield-ty-is-unit.rs b/tests/ui/coroutine/async-gen-yield-ty-is-unit.rs index 53e3ce77f8a82..72ad63795a8fd 100644 --- a/tests/ui/coroutine/async-gen-yield-ty-is-unit.rs +++ b/tests/ui/coroutine/async-gen-yield-ty-is-unit.rs @@ -6,7 +6,7 @@ use std::{async_iter::AsyncIterator, pin::pin, task::{Context, Waker}}; async gen fn gen_fn() -> &'static str { - yield "hello" + "hello".yield } pub fn main() { diff --git a/tests/ui/coroutine/async_gen_fn_iter.rs b/tests/ui/coroutine/async_gen_fn_iter.rs index 81adb618aa575..88b0f5c203675 100644 --- a/tests/ui/coroutine/async_gen_fn_iter.rs +++ b/tests/ui/coroutine/async_gen_fn_iter.rs @@ -18,11 +18,11 @@ async fn two() -> i32 { } async gen fn foo() -> i32 { - yield one().await; + one().await.yield; pause().await; - yield two().await; + two().await.yield; pause().await; - yield 3; + 3.yield; pause().await; } diff --git a/tests/ui/coroutine/auto-trait-regions.rs b/tests/ui/coroutine/auto-trait-regions.rs index 736555b31bbd1..7e83dcd0f49e8 100644 --- a/tests/ui/coroutine/auto-trait-regions.rs +++ b/tests/ui/coroutine/auto-trait-regions.rs @@ -25,7 +25,7 @@ fn main() { let x: &'static _ = &OnlyFooIfStaticRef(No); let generator = #[coroutine] move || { let x = x; - yield; + ().yield; assert_foo(x); }; assert_foo(generator); @@ -35,7 +35,7 @@ fn main() { let x = &OnlyFooIfRef(No); let generator = #[coroutine] move || { let x = x; - yield; + ().yield; assert_foo(x); }; assert_foo(generator); // ok @@ -45,7 +45,7 @@ fn main() { let a = A(&mut true, &mut true, No); //~^ ERROR borrow may still be in use when coroutine yields //~| ERROR borrow may still be in use when coroutine yields - yield; + ().yield; assert_foo(a); }; assert_foo(generator); diff --git a/tests/ui/coroutine/auto-trait-regions.stderr b/tests/ui/coroutine/auto-trait-regions.stderr index beb689d868d46..3bf573ef37cd5 100644 --- a/tests/ui/coroutine/auto-trait-regions.stderr +++ b/tests/ui/coroutine/auto-trait-regions.stderr @@ -6,8 +6,8 @@ LL | let generator = #[coroutine] move || { LL | let a = A(&mut true, &mut true, No); | ^^^^^^^^^ ... -LL | yield; - | ----- possible yield occurs here +LL | ().yield; + | -------- possible yield occurs here | help: add `static` to mark this coroutine as unmovable | @@ -22,8 +22,8 @@ LL | let generator = #[coroutine] move || { LL | let a = A(&mut true, &mut true, No); | ^^^^^^^^^ ... -LL | yield; - | ----- possible yield occurs here +LL | ().yield; + | -------- possible yield occurs here | help: add `static` to mark this coroutine as unmovable | diff --git a/tests/ui/coroutine/auxiliary/metadata-sufficient-for-layout.rs b/tests/ui/coroutine/auxiliary/metadata-sufficient-for-layout.rs index 8ecb8c0c09793..020922f885183 100644 --- a/tests/ui/coroutine/auxiliary/metadata-sufficient-for-layout.rs +++ b/tests/ui/coroutine/auxiliary/metadata-sufficient-for-layout.rs @@ -7,6 +7,6 @@ use std::ops::Coroutine; pub fn g() -> impl Coroutine<(), Yield = (), Return = ()> { #[coroutine] || { - yield; + ().yield; } } diff --git a/tests/ui/coroutine/auxiliary/unwind-aux.rs b/tests/ui/coroutine/auxiliary/unwind-aux.rs index 5d5e5c2218d39..a689eb9329e81 100644 --- a/tests/ui/coroutine/auxiliary/unwind-aux.rs +++ b/tests/ui/coroutine/auxiliary/unwind-aux.rs @@ -7,6 +7,6 @@ pub fn run(a: T) { let _ = #[coroutine] move || { drop(a); - yield; + ().yield; }; } diff --git a/tests/ui/coroutine/auxiliary/xcrate-reachable.rs b/tests/ui/coroutine/auxiliary/xcrate-reachable.rs index 0b5d18823004a..f3897b258c39d 100644 --- a/tests/ui/coroutine/auxiliary/xcrate-reachable.rs +++ b/tests/ui/coroutine/auxiliary/xcrate-reachable.rs @@ -9,7 +9,7 @@ fn msg() -> u32 { pub fn foo() -> impl Coroutine<(), Yield = (), Return = u32> { #[coroutine] || { - yield; + ().yield; return msg(); } } diff --git a/tests/ui/coroutine/auxiliary/xcrate.rs b/tests/ui/coroutine/auxiliary/xcrate.rs index 524eaafc75299..fcb74224f20e9 100644 --- a/tests/ui/coroutine/auxiliary/xcrate.rs +++ b/tests/ui/coroutine/auxiliary/xcrate.rs @@ -7,7 +7,7 @@ pub fn foo() -> impl Coroutine<(), Yield = (), Return = ()> { #[coroutine] || { if false { - yield; + ().yield; } } } @@ -16,7 +16,7 @@ pub fn bar(t: T) -> Box + Box::new( #[coroutine] || { - yield t; + t.yield; }, ) } diff --git a/tests/ui/coroutine/borrow-in-tail-expr.rs b/tests/ui/coroutine/borrow-in-tail-expr.rs index 380e95cfc7765..3394e9ff22a69 100644 --- a/tests/ui/coroutine/borrow-in-tail-expr.rs +++ b/tests/ui/coroutine/borrow-in-tail-expr.rs @@ -4,7 +4,7 @@ fn main() { let _a = #[coroutine] || { - yield; + ().yield; let a = String::new(); a.len() }; diff --git a/tests/ui/coroutine/borrowing.rs b/tests/ui/coroutine/borrowing.rs index a6628766c1bad..e9a43934c835e 100644 --- a/tests/ui/coroutine/borrowing.rs +++ b/tests/ui/coroutine/borrowing.rs @@ -6,14 +6,14 @@ use std::pin::Pin; fn main() { let _b = { let a = 3; - Pin::new(&mut #[coroutine] || yield &a).resume(()) + Pin::new(&mut #[coroutine] || (&a).yield).resume(()) //~^ ERROR: `a` does not live long enough }; let _b = { let a = 3; #[coroutine] || { - yield &a + (&a).yield //~^ ERROR: `a` does not live long enough } }; diff --git a/tests/ui/coroutine/borrowing.stderr b/tests/ui/coroutine/borrowing.stderr index 4f8b97377777a..78f21ffaf5e88 100644 --- a/tests/ui/coroutine/borrowing.stderr +++ b/tests/ui/coroutine/borrowing.stderr @@ -1,12 +1,12 @@ error[E0597]: `a` does not live long enough - --> $DIR/borrowing.rs:9:46 + --> $DIR/borrowing.rs:9:41 | LL | let _b = { | -- borrow later stored here LL | let a = 3; | - binding `a` declared here -LL | Pin::new(&mut #[coroutine] || yield &a).resume(()) - | -- ^ borrowed value does not live long enough +LL | Pin::new(&mut #[coroutine] || (&a).yield).resume(()) + | -- ^ borrowed value does not live long enough | | | value captured here by coroutine LL | @@ -14,7 +14,7 @@ LL | }; | - `a` dropped here while still borrowed error[E0597]: `a` does not live long enough - --> $DIR/borrowing.rs:16:20 + --> $DIR/borrowing.rs:16:15 | LL | let _b = { | -- borrow later stored here @@ -22,8 +22,8 @@ LL | let a = 3; | - binding `a` declared here LL | #[coroutine] || { | -- value captured here by coroutine -LL | yield &a - | ^ borrowed value does not live long enough +LL | (&a).yield + | ^ borrowed value does not live long enough ... LL | }; | - `a` dropped here while still borrowed diff --git a/tests/ui/coroutine/check-resume-ty-lifetimes-2.rs b/tests/ui/coroutine/check-resume-ty-lifetimes-2.rs index 327756ebe6604..1543a590f3015 100644 --- a/tests/ui/coroutine/check-resume-ty-lifetimes-2.rs +++ b/tests/ui/coroutine/check-resume-ty-lifetimes-2.rs @@ -8,27 +8,27 @@ struct Covariant<'a>(fn() -> &'a ()); fn bad1<'short, 'long: 'short>() -> impl Coroutine> { #[coroutine] |_: Covariant<'short>| { - let a: Covariant<'long> = yield (); + let a: Covariant<'long> = ().yield; //~^ ERROR lifetime may not live long enough } } fn bad2<'short, 'long: 'short>() -> impl Coroutine> { #[coroutine] |_: Contravariant<'long>| { - let a: Contravariant<'short> = yield (); + let a: Contravariant<'short> = ().yield; //~^ ERROR lifetime may not live long enough } } fn good1<'short, 'long: 'short>() -> impl Coroutine> { #[coroutine] |_: Covariant<'long>| { - let a: Covariant<'short> = yield (); + let a: Covariant<'short> = ().yield; } } fn good2<'short, 'long: 'short>() -> impl Coroutine> { #[coroutine] |_: Contravariant<'short>| { - let a: Contravariant<'long> = yield (); + let a: Contravariant<'long> = ().yield; } } diff --git a/tests/ui/coroutine/check-resume-ty-lifetimes-2.stderr b/tests/ui/coroutine/check-resume-ty-lifetimes-2.stderr index 8eb7ab3501b35..d4b4b175e2d67 100644 --- a/tests/ui/coroutine/check-resume-ty-lifetimes-2.stderr +++ b/tests/ui/coroutine/check-resume-ty-lifetimes-2.stderr @@ -6,7 +6,7 @@ LL | fn bad1<'short, 'long: 'short>() -> impl Coroutine> { | | | lifetime `'short` defined here LL | #[coroutine] |_: Covariant<'short>| { -LL | let a: Covariant<'long> = yield (); +LL | let a: Covariant<'long> = ().yield; | ^^^^^^^^^^^^^^^^ type annotation requires that `'short` must outlive `'long` | = help: consider adding the following bound: `'short: 'long` @@ -23,7 +23,7 @@ LL | fn bad2<'short, 'long: 'short>() -> impl Coroutine> { | | | lifetime `'short` defined here LL | #[coroutine] |_: Contravariant<'long>| { -LL | let a: Contravariant<'short> = yield (); +LL | let a: Contravariant<'short> = ().yield; | ^^^^^^^^ yielding this value requires that `'short` must outlive `'long` | = help: consider adding the following bound: `'short: 'long` diff --git a/tests/ui/coroutine/check-resume-ty-lifetimes.rs b/tests/ui/coroutine/check-resume-ty-lifetimes.rs index b75e46c541cc5..7aa3cb6408b14 100644 --- a/tests/ui/coroutine/check-resume-ty-lifetimes.rs +++ b/tests/ui/coroutine/check-resume-ty-lifetimes.rs @@ -12,7 +12,7 @@ fn mk_static(s: &str) -> &'static str { let mut coroutine = pin!( #[coroutine] |_: &str| { - let x: &'static str = yield (); + let x: &'static str = ().yield; //~^ ERROR lifetime may not live long enough storage = Some(x); } diff --git a/tests/ui/coroutine/check-resume-ty-lifetimes.stderr b/tests/ui/coroutine/check-resume-ty-lifetimes.stderr index 1fbaeb9f7fa41..5edc0faf9a2e0 100644 --- a/tests/ui/coroutine/check-resume-ty-lifetimes.stderr +++ b/tests/ui/coroutine/check-resume-ty-lifetimes.stderr @@ -4,7 +4,7 @@ error: lifetime may not live long enough LL | fn mk_static(s: &str) -> &'static str { | - let's call the lifetime of this reference `'1` ... -LL | let x: &'static str = yield (); +LL | let x: &'static str = ().yield; | ^^^^^^^^^^^^ type annotation requires that `'1` must outlive `'static` error: aborting due to 1 previous error diff --git a/tests/ui/coroutine/clone-impl-static.rs b/tests/ui/coroutine/clone-impl-static.rs index 2f941d6559125..f4adedff6985b 100644 --- a/tests/ui/coroutine/clone-impl-static.rs +++ b/tests/ui/coroutine/clone-impl-static.rs @@ -9,7 +9,7 @@ fn main() { let generator = #[coroutine] static move || { - yield; + ().yield; }; check_copy(&generator); //~^ ERROR Copy` is not satisfied diff --git a/tests/ui/coroutine/clone-impl.rs b/tests/ui/coroutine/clone-impl.rs index 9e04e256fc11e..db207252318d3 100644 --- a/tests/ui/coroutine/clone-impl.rs +++ b/tests/ui/coroutine/clone-impl.rs @@ -11,7 +11,7 @@ fn test1() { let copyable: u32 = 123; let gen_copy_0 = #[coroutine] move || { - yield; + ().yield; drop(copyable); }; check_copy(&gen_copy_0); @@ -28,7 +28,7 @@ fn test2() { drop(v); drop(n); */ - yield; + ().yield; let v = vec!['a']; let n = NonClone; drop(n); @@ -42,7 +42,7 @@ fn test3_upvars() { let clonable_0: Vec = Vec::new(); let gen_clone_0 = #[coroutine] move || { - yield; + ().yield; drop(clonable_0); }; check_copy(&gen_clone_0); @@ -54,7 +54,7 @@ fn test3_witness() { let gen_clone_1 = #[coroutine] move || { let v = vec!['a']; - yield; + ().yield; drop(v); }; check_copy(&gen_clone_1); @@ -66,7 +66,7 @@ fn test4() { let clonable_1: Vec = Vec::new(); let gen_clone_1 = #[coroutine] move || { - yield; + ().yield; let n = NonClone; drop(n); drop(clonable_1); @@ -80,7 +80,7 @@ fn test5() { let non_clonable: NonClone = NonClone; let gen_non_clone = #[coroutine] move || { - yield; + ().yield; drop(non_clonable); }; check_copy(&gen_non_clone); diff --git a/tests/ui/coroutine/clone-impl.stderr b/tests/ui/coroutine/clone-impl.stderr index f316902a42d08..8c69d3d083184 100644 --- a/tests/ui/coroutine/clone-impl.stderr +++ b/tests/ui/coroutine/clone-impl.stderr @@ -32,8 +32,8 @@ note: coroutine does not implement `Copy` as this value is used across a yield | LL | let v = vec!['a']; | - has type `Vec` which does not implement `Copy` -LL | yield; - | ^^^^^ yield occurs here, with `v` maybe used later +LL | ().yield; + | ^^^^^^^^ yield occurs here, with `v` maybe used later note: required by a bound in `check_copy` --> $DIR/clone-impl.rs:92:18 | diff --git a/tests/ui/coroutine/clone-rpit.rs b/tests/ui/coroutine/clone-rpit.rs index 3882564639b4e..e18f36770d280 100644 --- a/tests/ui/coroutine/clone-rpit.rs +++ b/tests/ui/coroutine/clone-rpit.rs @@ -12,7 +12,7 @@ pub fn foo<'a, 'b>() -> impl Clone { #[coroutine] move |_: ()| { - let () = yield (); + let () = ().yield; } } diff --git a/tests/ui/coroutine/conditional-drop.rs b/tests/ui/coroutine/conditional-drop.rs index 52e1b561946c7..5cc5441c880fb 100644 --- a/tests/ui/coroutine/conditional-drop.rs +++ b/tests/ui/coroutine/conditional-drop.rs @@ -34,7 +34,7 @@ fn t1() { if test() { drop(b); } - yield; + ().yield; }; let n = A.load(Ordering::SeqCst); @@ -50,7 +50,7 @@ fn t2() { if test2() { drop(b); } - yield; + ().yield; }; let n = A.load(Ordering::SeqCst); diff --git a/tests/ui/coroutine/control-flow.rs b/tests/ui/coroutine/control-flow.rs index f64b6f7388366..fcf0d12d4fd04 100644 --- a/tests/ui/coroutine/control-flow.rs +++ b/tests/ui/coroutine/control-flow.rs @@ -24,29 +24,29 @@ fn finish(mut amt: usize, mut t: T) -> T::Return } fn main() { - finish(1, #[coroutine] || yield); + finish(1, #[coroutine] || ().yield); finish(8, #[coroutine] || { for _ in 0..8 { - yield; + ().yield; } }); finish(1, #[coroutine] || { if true { - yield; + ().yield; } else { } }); finish(1, #[coroutine] || { if false { } else { - yield; + ().yield; } }); finish(2, #[coroutine] || { - if { yield; false } { - yield; + if { ().yield; false } { + ().yield; panic!() } - yield + ().yield }); } diff --git a/tests/ui/coroutine/coroutine-region-requirements.rs b/tests/ui/coroutine/coroutine-region-requirements.rs index ab6f16995e276..a8bb0a2ce1558 100644 --- a/tests/ui/coroutine/coroutine-region-requirements.rs +++ b/tests/ui/coroutine/coroutine-region-requirements.rs @@ -4,7 +4,7 @@ use std::pin::Pin; fn dangle(x: &mut i32) -> &'static mut i32 { let mut g = #[coroutine] || { - yield; + ().yield; x }; loop { diff --git a/tests/ui/coroutine/coroutine-resume-after-panic.rs b/tests/ui/coroutine/coroutine-resume-after-panic.rs index 1aa547c2a7bd2..541797a273278 100644 --- a/tests/ui/coroutine/coroutine-resume-after-panic.rs +++ b/tests/ui/coroutine/coroutine-resume-after-panic.rs @@ -16,7 +16,7 @@ use std::{ fn main() { let mut g = #[coroutine] || { panic!(); - yield; + ().yield; }; panic::catch_unwind(panic::AssertUnwindSafe(|| { let x = Pin::new(&mut g).resume(()); diff --git a/tests/ui/coroutine/coroutine-with-nll.rs b/tests/ui/coroutine/coroutine-with-nll.rs index 44ead560cf889..0aebe11a16656 100644 --- a/tests/ui/coroutine/coroutine-with-nll.rs +++ b/tests/ui/coroutine/coroutine-with-nll.rs @@ -7,7 +7,7 @@ fn main() { let _a = &mut true; let b = &mut true; //~^ ERROR borrow may still be in use when coroutine yields - yield (); + ().yield; println!("{}", b); }; } diff --git a/tests/ui/coroutine/coroutine-with-nll.stderr b/tests/ui/coroutine/coroutine-with-nll.stderr index ee3a8f45f44a7..ff2e751c62851 100644 --- a/tests/ui/coroutine/coroutine-with-nll.stderr +++ b/tests/ui/coroutine/coroutine-with-nll.stderr @@ -7,7 +7,7 @@ LL | || { LL | let b = &mut true; | ^^^^^^^^^ LL | -LL | yield (); +LL | ().yield; | -------- possible yield occurs here | help: add `static` to mark this coroutine as unmovable diff --git a/tests/ui/coroutine/coroutine-yielding-or-returning-itself.rs b/tests/ui/coroutine/coroutine-yielding-or-returning-itself.rs index f3110d71d0d72..2cec00c752a2a 100644 --- a/tests/ui/coroutine/coroutine-yielding-or-returning-itself.rs +++ b/tests/ui/coroutine/coroutine-yielding-or-returning-itself.rs @@ -14,7 +14,7 @@ pub fn want_cyclic_coroutine_return(_: T) fn supply_cyclic_coroutine_return() { want_cyclic_coroutine_return(#[coroutine] || { //~^ ERROR type mismatch - if false { yield None.unwrap(); } + if false { None.unwrap().yield; } None.unwrap() }) } @@ -27,7 +27,7 @@ pub fn want_cyclic_coroutine_yield(_: T) fn supply_cyclic_coroutine_yield() { want_cyclic_coroutine_yield(#[coroutine] || { //~^ ERROR type mismatch - if false { yield None.unwrap(); } + if false { None.unwrap().yield; } None.unwrap() }) } diff --git a/tests/ui/coroutine/coroutine-yielding-or-returning-itself.stderr b/tests/ui/coroutine/coroutine-yielding-or-returning-itself.stderr index 32799148ae1da..b030a656d1c4d 100644 --- a/tests/ui/coroutine/coroutine-yielding-or-returning-itself.stderr +++ b/tests/ui/coroutine/coroutine-yielding-or-returning-itself.stderr @@ -6,7 +6,7 @@ LL | want_cyclic_coroutine_return(#[coroutine] || { | | | | | required by a bound introduced by this call LL | | -LL | | if false { yield None.unwrap(); } +LL | | if false { None.unwrap().yield; } LL | | None.unwrap() LL | | }) | |_____^ cyclic type of infinite size @@ -31,7 +31,7 @@ LL | want_cyclic_coroutine_yield(#[coroutine] || { | | | | | required by a bound introduced by this call LL | | -LL | | if false { yield None.unwrap(); } +LL | | if false { None.unwrap().yield; } LL | | None.unwrap() LL | | }) | |_____^ cyclic type of infinite size diff --git a/tests/ui/coroutine/derived-drop-parent-expr.rs b/tests/ui/coroutine/derived-drop-parent-expr.rs index cc217e4960e90..5b9b3c6ce1f50 100644 --- a/tests/ui/coroutine/derived-drop-parent-expr.rs +++ b/tests/ui/coroutine/derived-drop-parent-expr.rs @@ -10,7 +10,7 @@ pub struct Client { pub nickname: String } fn main() { let g = #[coroutine] move || match drop(Client { ..Client::default() }) { - _status => yield, + _status => ().yield, }; assert_send(g); } diff --git a/tests/ui/coroutine/discriminant.rs b/tests/ui/coroutine/discriminant.rs index ca4fcedd7e536..32eca0e987c28 100644 --- a/tests/ui/coroutine/discriminant.rs +++ b/tests/ui/coroutine/discriminant.rs @@ -12,35 +12,35 @@ use std::{cmp, ops::*}; macro_rules! yield25 { ($e:expr) => { - yield $e; - yield $e; - yield $e; - yield $e; - yield $e; - - yield $e; - yield $e; - yield $e; - yield $e; - yield $e; - - yield $e; - yield $e; - yield $e; - yield $e; - yield $e; - - yield $e; - yield $e; - yield $e; - yield $e; - yield $e; - - yield $e; - yield $e; - yield $e; - yield $e; - yield $e; + $e.yield; + $e.yield; + $e.yield; + $e.yield; + $e.yield; + + $e.yield; + $e.yield; + $e.yield; + $e.yield; + $e.yield; + + $e.yield; + $e.yield; + $e.yield; + $e.yield; + $e.yield; + + $e.yield; + $e.yield; + $e.yield; + $e.yield; + $e.yield; + + $e.yield; + $e.yield; + $e.yield; + $e.yield; + $e.yield; }; } @@ -91,8 +91,8 @@ fn main() { yield250!(); // 253 variants - yield; // 254 - yield; // 255 + ().yield; // 254 + ().yield; // 255 } }; @@ -103,9 +103,9 @@ fn main() { yield250!(); // 253 variants - yield; // 254 - yield; // 255 - yield; // 256 + ().yield; // 254 + ().yield; // 255 + ().yield; // 256 } }; @@ -116,10 +116,10 @@ fn main() { yield250!(); // 253 variants - yield; // 254 - yield; // 255 - yield; // 256 - yield; // 257 + ().yield; // 254 + ().yield; // 255 + ().yield; // 256 + ().yield; // 257 } }; diff --git a/tests/ui/coroutine/drop-and-replace.rs b/tests/ui/coroutine/drop-and-replace.rs index d3d7e000020a1..6aa9256c066fe 100644 --- a/tests/ui/coroutine/drop-and-replace.rs +++ b/tests/ui/coroutine/drop-and-replace.rs @@ -20,7 +20,7 @@ fn main() { let mut a = #[coroutine] || { let mut x = Foo(4); - yield; + ().yield; assert_eq!(x.0, 4); // At one point this tricked our dataflow analysis into thinking `x` was @@ -30,7 +30,7 @@ fn main() { { let y = Foo(6); - yield; + ().yield; assert_eq!(y.0, 6); } diff --git a/tests/ui/coroutine/drop-control-flow.rs b/tests/ui/coroutine/drop-control-flow.rs index f576b1b759443..04c179d634ddd 100644 --- a/tests/ui/coroutine/drop-control-flow.rs +++ b/tests/ui/coroutine/drop-control-flow.rs @@ -24,7 +24,7 @@ fn one_armed_if(arg: bool) { if arg { drop(arr); } - yield; + ().yield; }; } @@ -36,7 +36,7 @@ fn two_armed_if(arg: bool) { } else { drop(arr); } - yield; + ().yield; }) } @@ -46,7 +46,7 @@ fn if_let(arg: Option) { if let Some(_) = arg { drop(arr); } - yield; + ().yield; }; } @@ -57,7 +57,7 @@ fn init_in_if(arg: bool) { if arg { x = NonSend; } else { - yield; + ().yield; } }) } @@ -68,7 +68,7 @@ fn init_in_match_arm(arg: Option) { drop(x); match arg { Some(_) => x = NonSend, - None => yield, + None => ().yield, } }) } @@ -78,7 +78,7 @@ fn reinit() { let mut arr = [Ptr]; drop(arr); arr = [Ptr]; - yield; + ().yield; }; } @@ -88,7 +88,7 @@ fn loop_uninit() { let mut count = 0; drop(arr); while count < 3 { - yield; + ().yield; arr = [Ptr]; count += 1; } @@ -102,7 +102,7 @@ fn nested_loop() { drop(arr); while count < 3 { for _ in 0..3 { - yield; + ().yield; } arr = [Ptr]; count += 1; @@ -117,7 +117,7 @@ fn loop_continue(b: bool) { drop(arr); while count < 3 { count += 1; - yield; + ().yield; if b { arr = [Ptr]; continue; diff --git a/tests/ui/coroutine/drop-env.rs b/tests/ui/coroutine/drop-env.rs index d36228dc84904..702dc23e8509e 100644 --- a/tests/ui/coroutine/drop-env.rs +++ b/tests/ui/coroutine/drop-env.rs @@ -29,7 +29,7 @@ fn main() { fn t1() { let b = B; let mut foo = #[coroutine] || { - yield; + ().yield; drop(b); }; @@ -43,7 +43,7 @@ fn t1() { fn t2() { let b = B; let mut foo = #[coroutine] || { - yield b; + b.yield; }; let n = A.load(Ordering::SeqCst); @@ -56,7 +56,7 @@ fn t2() { fn t3() { let b = B; let foo = #[coroutine] || { - yield; + ().yield; drop(b); }; diff --git a/tests/ui/coroutine/drop-track-addassign-yield.rs b/tests/ui/coroutine/drop-track-addassign-yield.rs index 537e66c41b20b..c62580d288b45 100644 --- a/tests/ui/coroutine/drop-track-addassign-yield.rs +++ b/tests/ui/coroutine/drop-track-addassign-yield.rs @@ -9,7 +9,7 @@ fn foo() { let _y = #[coroutine] static || { let x = &mut 0; *{ - yield; + ().yield; x } += match String::new() { _ => 0, @@ -22,12 +22,12 @@ fn foo() { *{ let inner = &mut 1; *{ - yield (); + ().yield; inner } += match String::new() { _ => 1, }; - yield; + ().yield; x } += match String::new() { _ => 2, diff --git a/tests/ui/coroutine/drop-tracking-parent-expression.rs b/tests/ui/coroutine/drop-tracking-parent-expression.rs index 702cbc88ae4b0..ee99009cdba95 100644 --- a/tests/ui/coroutine/drop-tracking-parent-expression.rs +++ b/tests/ui/coroutine/drop-tracking-parent-expression.rs @@ -20,7 +20,7 @@ macro_rules! type_combinations { //~^ NOTE `significant_drop::Client` which is not `Send` //~| NOTE `insignificant_dtor::Client` which is not `Send` //~| NOTE `derived_drop::Client` which is not `Send` - _ => yield, + _ => ().yield, }; assert_send(g); //~^ ERROR cannot be sent between threads @@ -32,7 +32,7 @@ macro_rules! type_combinations { // even though the temporary expression doesn't end until after the yield. { let g = #[coroutine] move || match drop($name::Client::default()) { - _ => yield, + _ => ().yield, }; assert_send(g); } diff --git a/tests/ui/coroutine/drop-tracking-parent-expression.stderr b/tests/ui/coroutine/drop-tracking-parent-expression.stderr index fe8c17c12946d..23fbdbd4b8f7e 100644 --- a/tests/ui/coroutine/drop-tracking-parent-expression.stderr +++ b/tests/ui/coroutine/drop-tracking-parent-expression.stderr @@ -23,8 +23,8 @@ note: coroutine is not `Send` as this value is used across a yield LL | let g = #[coroutine] move || match drop($name::Client { ..$name::Client::default() }) { | ------------------------ has type `derived_drop::Client` which is not `Send` ... -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later +LL | _ => ().yield, + | ^^^^^^^^ yield occurs here, with `$name::Client::default()` maybe used later ... LL | / type_combinations!( LL | | // OK @@ -65,8 +65,8 @@ note: coroutine is not `Send` as this value is used across a yield LL | let g = #[coroutine] move || match drop($name::Client { ..$name::Client::default() }) { | ------------------------ has type `significant_drop::Client` which is not `Send` ... -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later +LL | _ => ().yield, + | ^^^^^^^^ yield occurs here, with `$name::Client::default()` maybe used later ... LL | / type_combinations!( LL | | // OK @@ -107,8 +107,8 @@ note: coroutine is not `Send` as this value is used across a yield LL | let g = #[coroutine] move || match drop($name::Client { ..$name::Client::default() }) { | ------------------------ has type `insignificant_dtor::Client` which is not `Send` ... -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later +LL | _ => ().yield, + | ^^^^^^^^ yield occurs here, with `$name::Client::default()` maybe used later ... LL | / type_combinations!( LL | | // OK diff --git a/tests/ui/coroutine/drop-tracking-yielding-in-match-guards.rs b/tests/ui/coroutine/drop-tracking-yielding-in-match-guards.rs index 43e42fa85f7f4..aab9ccdbaa681 100644 --- a/tests/ui/coroutine/drop-tracking-yielding-in-match-guards.rs +++ b/tests/ui/coroutine/drop-tracking-yielding-in-match-guards.rs @@ -5,7 +5,7 @@ fn main() { let _ = #[coroutine] static |x: u8| match x { - y if { yield } == y + 1 => (), + y if { ().yield } == y + 1 => (), _ => (), }; } diff --git a/tests/ui/coroutine/drop-yield-twice.rs b/tests/ui/coroutine/drop-yield-twice.rs index 7ac1345b2ff2e..926395ab0455f 100644 --- a/tests/ui/coroutine/drop-yield-twice.rs +++ b/tests/ui/coroutine/drop-yield-twice.rs @@ -6,9 +6,9 @@ impl !Send for Foo {} fn main() { assert_send(#[coroutine] || { //~ ERROR coroutine cannot be sent between threads safely let guard = Foo(42); - yield; + ().yield; drop(guard); - yield; + ().yield; }) } diff --git a/tests/ui/coroutine/drop-yield-twice.stderr b/tests/ui/coroutine/drop-yield-twice.stderr index 5ac2b471cb615..925d155f621e8 100644 --- a/tests/ui/coroutine/drop-yield-twice.stderr +++ b/tests/ui/coroutine/drop-yield-twice.stderr @@ -3,9 +3,9 @@ error: coroutine cannot be sent between threads safely | LL | / assert_send(#[coroutine] || { LL | | let guard = Foo(42); -LL | | yield; +LL | | ().yield; LL | | drop(guard); -LL | | yield; +LL | | ().yield; LL | | }) | |______^ coroutine is not `Send` | @@ -19,8 +19,8 @@ note: coroutine is not `Send` as this value is used across a yield | LL | let guard = Foo(42); | ----- has type `Foo` which is not `Send` -LL | yield; - | ^^^^^ yield occurs here, with `guard` maybe used later +LL | ().yield; + | ^^^^^^^^ yield occurs here, with `guard` maybe used later note: required by a bound in `assert_send` --> $DIR/drop-yield-twice.rs:15:19 | diff --git a/tests/ui/coroutine/dropck-resume.rs b/tests/ui/coroutine/dropck-resume.rs index df014400f00fe..adc3119d1cbc8 100644 --- a/tests/ui/coroutine/dropck-resume.rs +++ b/tests/ui/coroutine/dropck-resume.rs @@ -19,7 +19,7 @@ fn drop_using_coroutine() -> i32 { let mut g = #[coroutine] move |r| { let _s = SetToNone(r); - yield; + ().yield; }; let mut g = Pin::new(&mut g); g.as_mut().resume(z); diff --git a/tests/ui/coroutine/dropck.rs b/tests/ui/coroutine/dropck.rs index 9331c1fa1d580..3b1e871b286ff 100644 --- a/tests/ui/coroutine/dropck.rs +++ b/tests/ui/coroutine/dropck.rs @@ -14,7 +14,7 @@ fn main() { || { // but the coroutine can use it to drop a `Ref<'a, i32>`. let _d = ref_.take(); //~ ERROR `ref_` does not live long enough - yield; + ().yield; }; Pin::new(&mut gen).resume(()); // drops the RefCell and then the Ref, leading to use-after-free diff --git a/tests/ui/coroutine/gen_block.e2024.stderr b/tests/ui/coroutine/gen_block.e2024.stderr index 347f111e79fdc..c3457c097cfe2 100644 --- a/tests/ui/coroutine/gen_block.e2024.stderr +++ b/tests/ui/coroutine/gen_block.e2024.stderr @@ -1,7 +1,7 @@ error[E0658]: the `#[coroutine]` attribute is an experimental feature --> $DIR/gen_block.rs:20:13 | -LL | let _ = #[coroutine] || yield true; +LL | let _ = #[coroutine] || true.yield; | ^^^^^^^^^^^^ | = note: see issue #43122 for more information @@ -21,12 +21,12 @@ LL | let _ = #[coroutine] || {}; error: `yield` can only be used in `#[coroutine]` closures, or `gen` blocks --> $DIR/gen_block.rs:16:16 | -LL | let _ = || yield true; +LL | let _ = || true.yield; | ^^^^^^^^^^ | help: use `#[coroutine]` to make this closure a coroutine | -LL | let _ = #[coroutine] || yield true; +LL | let _ = #[coroutine] || true.yield; | ++++++++++++ error[E0282]: type annotations needed diff --git a/tests/ui/coroutine/gen_block.none.stderr b/tests/ui/coroutine/gen_block.none.stderr index b793033b5216a..036f4274ad144 100644 --- a/tests/ui/coroutine/gen_block.none.stderr +++ b/tests/ui/coroutine/gen_block.none.stderr @@ -1,8 +1,8 @@ -error: expected identifier, found reserved keyword `yield` +error: expected identifier, found `42` --> $DIR/gen_block.rs:10:19 | -LL | let y = gen { yield 42 }; - | --- ^^^^^ expected identifier, found reserved keyword +LL | let y = gen { 42.yield }; + | --- ^^ expected identifier | | | while parsing this struct @@ -15,7 +15,7 @@ LL | let x = gen {}; error[E0422]: cannot find struct, variant or union type `gen` in this scope --> $DIR/gen_block.rs:10:13 | -LL | let y = gen { yield 42 }; +LL | let y = gen { 42.yield }; | ^^^ not found in this scope error[E0422]: cannot find struct, variant or union type `gen` in this scope @@ -25,20 +25,20 @@ LL | gen {}; | ^^^ not found in this scope error[E0658]: yield syntax is experimental - --> $DIR/gen_block.rs:16:16 + --> $DIR/gen_block.rs:16:21 | -LL | let _ = || yield true; - | ^^^^^^^^^^ +LL | let _ = || true.yield; + | ^^^^^ | = note: see issue #43122 for more information = help: add `#![feature(yield_expr)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: yield syntax is experimental - --> $DIR/gen_block.rs:20:29 + --> $DIR/gen_block.rs:20:34 | -LL | let _ = #[coroutine] || yield true; - | ^^^^^^^^^^ +LL | let _ = #[coroutine] || true.yield; + | ^^^^^ | = note: see issue #43122 for more information = help: add `#![feature(yield_expr)]` to the crate attributes to enable @@ -47,7 +47,7 @@ LL | let _ = #[coroutine] || yield true; error[E0658]: the `#[coroutine]` attribute is an experimental feature --> $DIR/gen_block.rs:20:13 | -LL | let _ = #[coroutine] || yield true; +LL | let _ = #[coroutine] || true.yield; | ^^^^^^^^^^^^ | = note: see issue #43122 for more information @@ -67,7 +67,7 @@ LL | let _ = #[coroutine] || {}; error[E0658]: yield syntax is experimental --> $DIR/gen_block.rs:16:16 | -LL | let _ = || yield true; +LL | let _ = || true.yield; | ^^^^^^^^^^ | = note: see issue #43122 for more information @@ -77,18 +77,18 @@ LL | let _ = || yield true; error: `yield` can only be used in `#[coroutine]` closures, or `gen` blocks --> $DIR/gen_block.rs:16:16 | -LL | let _ = || yield true; +LL | let _ = || true.yield; | ^^^^^^^^^^ | help: use `#[coroutine]` to make this closure a coroutine | -LL | let _ = #[coroutine] || yield true; +LL | let _ = #[coroutine] || true.yield; | ++++++++++++ error[E0658]: yield syntax is experimental --> $DIR/gen_block.rs:20:29 | -LL | let _ = #[coroutine] || yield true; +LL | let _ = #[coroutine] || true.yield; | ^^^^^^^^^^ | = note: see issue #43122 for more information diff --git a/tests/ui/coroutine/gen_block.rs b/tests/ui/coroutine/gen_block.rs index e3734dd4cdf05..6274d80b92d0c 100644 --- a/tests/ui/coroutine/gen_block.rs +++ b/tests/ui/coroutine/gen_block.rs @@ -7,17 +7,17 @@ fn main() { let x = gen {}; //[none]~^ ERROR: cannot find //[e2024]~^^ ERROR: type annotations needed - let y = gen { yield 42 }; - //[none]~^ ERROR: found reserved keyword `yield` + let y = gen { 42.yield }; + //[none]~^ ERROR: expected identifier //[none]~| ERROR: cannot find gen {}; //[none]~^ ERROR: cannot find - let _ = || yield true; //[none]~ ERROR yield syntax is experimental + let _ = || true.yield; //[none]~ ERROR yield syntax is experimental //[none]~^ ERROR yield syntax is experimental //~^^ ERROR `yield` can only be used in - let _ = #[coroutine] || yield true; //[none]~ ERROR yield syntax is experimental + let _ = #[coroutine] || true.yield; //[none]~ ERROR yield syntax is experimental //~^ ERROR `#[coroutine]` attribute is an experimental feature //[none]~^^ ERROR yield syntax is experimental diff --git a/tests/ui/coroutine/gen_block_is_coro.rs b/tests/ui/coroutine/gen_block_is_coro.rs index bccc3e86ee463..c64f0c37bd807 100644 --- a/tests/ui/coroutine/gen_block_is_coro.rs +++ b/tests/ui/coroutine/gen_block_is_coro.rs @@ -5,15 +5,15 @@ use std::ops::Coroutine; fn foo() -> impl Coroutine { //~ ERROR: Coroutine` is not satisfied - gen { yield 42 } + gen { 42.yield } } fn bar() -> impl Coroutine { //~ ERROR: Coroutine` is not satisfied - gen { yield 42 } + gen { 42.yield } } fn baz() -> impl Coroutine { //~ ERROR: Coroutine` is not satisfied - gen { yield 42 } + gen { 42.yield } } fn main() {} diff --git a/tests/ui/coroutine/gen_block_is_coro.stderr b/tests/ui/coroutine/gen_block_is_coro.stderr index 444f0eca1d54c..5ebbb19ef1e02 100644 --- a/tests/ui/coroutine/gen_block_is_coro.stderr +++ b/tests/ui/coroutine/gen_block_is_coro.stderr @@ -3,7 +3,7 @@ error[E0277]: the trait bound `{gen block@$DIR/gen_block_is_coro.rs:8:5: 8:8}: C | LL | fn foo() -> impl Coroutine { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Coroutine` is not implemented for `{gen block@$DIR/gen_block_is_coro.rs:8:5: 8:8}` -LL | gen { yield 42 } +LL | gen { 42.yield } | ---------------- return type was inferred to be `{gen block@$DIR/gen_block_is_coro.rs:8:5: 8:8}` here error[E0277]: the trait bound `{gen block@$DIR/gen_block_is_coro.rs:12:5: 12:8}: Coroutine` is not satisfied @@ -11,7 +11,7 @@ error[E0277]: the trait bound `{gen block@$DIR/gen_block_is_coro.rs:12:5: 12:8}: | LL | fn bar() -> impl Coroutine { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Coroutine` is not implemented for `{gen block@$DIR/gen_block_is_coro.rs:12:5: 12:8}` -LL | gen { yield 42 } +LL | gen { 42.yield } | ---------------- return type was inferred to be `{gen block@$DIR/gen_block_is_coro.rs:12:5: 12:8}` here error[E0277]: the trait bound `{gen block@$DIR/gen_block_is_coro.rs:16:5: 16:8}: Coroutine` is not satisfied @@ -19,7 +19,7 @@ error[E0277]: the trait bound `{gen block@$DIR/gen_block_is_coro.rs:16:5: 16:8}: | LL | fn baz() -> impl Coroutine { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Coroutine` is not implemented for `{gen block@$DIR/gen_block_is_coro.rs:16:5: 16:8}` -LL | gen { yield 42 } +LL | gen { 42.yield } | ---------------- return type was inferred to be `{gen block@$DIR/gen_block_is_coro.rs:16:5: 16:8}` here error: aborting due to 3 previous errors diff --git a/tests/ui/coroutine/gen_block_is_fused_iter.rs b/tests/ui/coroutine/gen_block_is_fused_iter.rs index e4eab6195eecf..83ff8683a0b01 100644 --- a/tests/ui/coroutine/gen_block_is_fused_iter.rs +++ b/tests/ui/coroutine/gen_block_is_fused_iter.rs @@ -7,15 +7,15 @@ use std::iter::FusedIterator; fn foo() -> impl FusedIterator { - gen { yield 42 } + gen { 42.yield } } fn bar() -> impl FusedIterator { - gen { yield 42 } + gen { 42.yield } } fn baz() -> impl FusedIterator + Iterator { - gen { yield 42 } + gen { 42.yield } } fn main() {} diff --git a/tests/ui/coroutine/gen_block_is_iter.rs b/tests/ui/coroutine/gen_block_is_iter.rs index 032360fbee032..69cfddb387273 100644 --- a/tests/ui/coroutine/gen_block_is_iter.rs +++ b/tests/ui/coroutine/gen_block_is_iter.rs @@ -5,15 +5,15 @@ #![feature(gen_blocks)] fn foo() -> impl Iterator { - gen { yield 42 } + gen { 42.yield } } fn bar() -> impl Iterator { - gen { yield 42 } + gen { 42.yield } } fn baz() -> impl Iterator { - gen { yield 42 } + gen { 42.yield } } fn main() {} diff --git a/tests/ui/coroutine/gen_block_is_no_future.rs b/tests/ui/coroutine/gen_block_is_no_future.rs index eca8a9b6320fd..0c0fb489ed831 100644 --- a/tests/ui/coroutine/gen_block_is_no_future.rs +++ b/tests/ui/coroutine/gen_block_is_no_future.rs @@ -2,7 +2,7 @@ #![feature(gen_blocks)] fn foo() -> impl std::future::Future { //~ ERROR is not a future - gen { yield 42 } + gen { 42.yield } } fn main() {} diff --git a/tests/ui/coroutine/gen_block_is_no_future.stderr b/tests/ui/coroutine/gen_block_is_no_future.stderr index 43e18dbc2a9c1..41b2f35dafa2e 100644 --- a/tests/ui/coroutine/gen_block_is_no_future.stderr +++ b/tests/ui/coroutine/gen_block_is_no_future.stderr @@ -3,7 +3,7 @@ error[E0277]: `{gen block@$DIR/gen_block_is_no_future.rs:5:5: 5:8}` is not a fut | LL | fn foo() -> impl std::future::Future { | ^^^^^^^^^^^^^^^^^^^^^^^^ `{gen block@$DIR/gen_block_is_no_future.rs:5:5: 5:8}` is not a future -LL | gen { yield 42 } +LL | gen { 42.yield } | ---------------- return type was inferred to be `{gen block@$DIR/gen_block_is_no_future.rs:5:5: 5:8}` here | = help: the trait `Future` is not implemented for `{gen block@$DIR/gen_block_is_no_future.rs:5:5: 5:8}` diff --git a/tests/ui/coroutine/gen_block_iterate.rs b/tests/ui/coroutine/gen_block_iterate.rs index afeb56cc2f3f9..fd7f3c027d6fb 100644 --- a/tests/ui/coroutine/gen_block_iterate.rs +++ b/tests/ui/coroutine/gen_block_iterate.rs @@ -5,16 +5,16 @@ #![feature(gen_blocks)] fn foo() -> impl Iterator { - gen { yield 42; for x in 3..6 { yield x } } + gen { 42.yield; for x in 3..6 { x.yield } } } fn moved() -> impl Iterator { let mut x = "foo".to_string(); gen move { - yield 42; + 42.yield; if x == "foo" { return } x.clear(); - for x in 3..6 { yield x } + for x in 3..6 { x.yield } } } diff --git a/tests/ui/coroutine/gen_block_move.fixed b/tests/ui/coroutine/gen_block_move.fixed index e58c9b3f9fe32..36412882e9289 100644 --- a/tests/ui/coroutine/gen_block_move.fixed +++ b/tests/ui/coroutine/gen_block_move.fixed @@ -5,10 +5,10 @@ fn moved() -> impl Iterator { let mut x = "foo".to_string(); gen move { //~ ERROR: gen block may outlive the current function - yield 42; + 42.yield; if x == "foo" { return } x.clear(); - for x in 3..6 { yield x } + for x in 3..6 { x.yield } } } diff --git a/tests/ui/coroutine/gen_block_move.rs b/tests/ui/coroutine/gen_block_move.rs index e249404a0a168..756f60fbb8183 100644 --- a/tests/ui/coroutine/gen_block_move.rs +++ b/tests/ui/coroutine/gen_block_move.rs @@ -5,10 +5,10 @@ fn moved() -> impl Iterator { let mut x = "foo".to_string(); gen { //~ ERROR: gen block may outlive the current function - yield 42; + 42.yield; if x == "foo" { return } x.clear(); - for x in 3..6 { yield x } + for x in 3..6 { x.yield } } } diff --git a/tests/ui/coroutine/gen_block_move.stderr b/tests/ui/coroutine/gen_block_move.stderr index 720b8d73322e7..88adcc45508e6 100644 --- a/tests/ui/coroutine/gen_block_move.stderr +++ b/tests/ui/coroutine/gen_block_move.stderr @@ -11,10 +11,10 @@ note: gen block is returned here --> $DIR/gen_block_move.rs:7:5 | LL | / gen { -LL | | yield 42; +LL | | 42.yield; LL | | if x == "foo" { return } LL | | x.clear(); -LL | | for x in 3..6 { yield x } +LL | | for x in 3..6 { x.yield } LL | | } | |_____^ help: to force the gen block to take ownership of `x` (and any other referenced variables), use the `move` keyword diff --git a/tests/ui/coroutine/gen_block_panic.rs b/tests/ui/coroutine/gen_block_panic.rs index 5417ed583e8ca..e4029b1dce82c 100644 --- a/tests/ui/coroutine/gen_block_panic.rs +++ b/tests/ui/coroutine/gen_block_panic.rs @@ -6,9 +6,9 @@ fn main() { let mut iter = gen { - yield 42; + 42.yield; panic!("foo"); - yield 69; //~ WARN: unreachable statement + 69.yield; //~ WARN: unreachable statement }; assert_eq!(iter.next(), Some(42)); let mut tmp = std::panic::AssertUnwindSafe(&mut iter); diff --git a/tests/ui/coroutine/gen_block_panic.stderr b/tests/ui/coroutine/gen_block_panic.stderr index d0a146e7baf9a..27ba31bd573c9 100644 --- a/tests/ui/coroutine/gen_block_panic.stderr +++ b/tests/ui/coroutine/gen_block_panic.stderr @@ -3,7 +3,7 @@ warning: unreachable statement | LL | panic!("foo"); | ------------- any code following this expression is unreachable -LL | yield 69; +LL | 69.yield; | ^^^^^^^^^ unreachable statement | = note: `#[warn(unreachable_code)]` (part of `#[warn(unused)]`) on by default diff --git a/tests/ui/coroutine/gen_fn_iter.rs b/tests/ui/coroutine/gen_fn_iter.rs index 9cd75551ad45c..d820fa955a1e2 100644 --- a/tests/ui/coroutine/gen_fn_iter.rs +++ b/tests/ui/coroutine/gen_fn_iter.rs @@ -5,9 +5,9 @@ // make sure that a ridiculously simple gen fn works as an iterator. gen fn foo() -> i32 { - yield 1; - yield 2; - yield 3; + 1.yield; + 2.yield; + 3.yield; } fn main() { diff --git a/tests/ui/coroutine/gen_fn_lifetime_capture.rs b/tests/ui/coroutine/gen_fn_lifetime_capture.rs index bee6c2e8803ad..22f3da82601f4 100644 --- a/tests/ui/coroutine/gen_fn_lifetime_capture.rs +++ b/tests/ui/coroutine/gen_fn_lifetime_capture.rs @@ -5,8 +5,8 @@ // make sure gen fn captures lifetimes in its signature gen fn foo<'a, 'b>(x: &'a i32, y: &'b i32, z: &'b i32) -> &'b i32 { - yield y; - yield z; + y.yield; + z.yield; } fn main() { diff --git a/tests/ui/coroutine/issue-102645.rs b/tests/ui/coroutine/issue-102645.rs index ccf82c3606ac2..c4ed99265ee8d 100644 --- a/tests/ui/coroutine/issue-102645.rs +++ b/tests/ui/coroutine/issue-102645.rs @@ -8,7 +8,7 @@ fn main() { let mut b = #[coroutine] || { let d = 6; - yield; + ().yield; _zzz(); // #break a = d; }; diff --git a/tests/ui/coroutine/issue-105084.rs b/tests/ui/coroutine/issue-105084.rs index cddee49901757..24a7c00cc9f64 100644 --- a/tests/ui/coroutine/issue-105084.rs +++ b/tests/ui/coroutine/issue-105084.rs @@ -19,7 +19,7 @@ fn main() { // - create a Box that is ignored for trait computations; // - compute fields (and yields); // - assign to `t`. - let t = std::boxed::box_new((5, yield)); + let t = std::boxed::box_new((5, ().yield)); drop(t); }; diff --git a/tests/ui/coroutine/issue-105084.stderr b/tests/ui/coroutine/issue-105084.stderr index 23c1fdc545922..5a5fcde0e5208 100644 --- a/tests/ui/coroutine/issue-105084.stderr +++ b/tests/ui/coroutine/issue-105084.stderr @@ -34,10 +34,10 @@ LL | let mut h = copy(g); note: coroutine does not implement `Copy` as this value is used across a yield --> $DIR/issue-105084.rs:22:41 | -LL | let t = std::boxed::box_new((5, yield)); - | ------------------------^^^^^-- +LL | let t = std::boxed::box_new((5, ().yield)); + | ------------------------^^^^^^^^-- | | | - | | yield occurs here, with `std::boxed::box_new((5, yield))` maybe used later + | | yield occurs here, with `std::boxed::box_new((5, ().yield))` maybe used later | has type `Box<(i32, ())>` which does not implement `Copy` note: required by a bound in `copy` --> $DIR/issue-105084.rs:10:12 diff --git a/tests/ui/coroutine/issue-110929-coroutine-conflict-error-ice.rs b/tests/ui/coroutine/issue-110929-coroutine-conflict-error-ice.rs index 300c8fe6d4618..0e45c02eaca2d 100644 --- a/tests/ui/coroutine/issue-110929-coroutine-conflict-error-ice.rs +++ b/tests/ui/coroutine/issue-110929-coroutine-conflict-error-ice.rs @@ -6,7 +6,7 @@ fn main() { let x = &mut (); || { let _c = #[coroutine] - || yield *&mut *x; + || (*&mut *x).yield; || _ = &mut *x; }; } diff --git a/tests/ui/coroutine/issue-113279.rs b/tests/ui/coroutine/issue-113279.rs index 98617af105c35..d5173f5913031 100644 --- a/tests/ui/coroutine/issue-113279.rs +++ b/tests/ui/coroutine/issue-113279.rs @@ -13,7 +13,7 @@ fn foo() { static || { let x = &mut 0; *{ - yield; + ().yield; x } += match { *"" }.len() { //~^ ERROR cannot move a value of type `str` [E0161] diff --git a/tests/ui/coroutine/issue-44197.rs b/tests/ui/coroutine/issue-44197.rs index 0240f7a7eaac2..29478d598d175 100644 --- a/tests/ui/coroutine/issue-44197.rs +++ b/tests/ui/coroutine/issue-44197.rs @@ -11,7 +11,7 @@ fn foo(_: &str) -> String { fn bar(baz: String) -> impl Coroutine<(), Yield = String, Return = ()> { #[coroutine] move || { - yield foo(&baz); + foo(&baz).yield; } } @@ -22,7 +22,7 @@ fn foo2(_: &str) -> Result { fn bar2(baz: String) -> impl Coroutine<(), Yield = String, Return = ()> { #[coroutine] move || { if let Ok(quux) = foo2(&baz) { - yield quux; + quux.yield; } } } diff --git a/tests/ui/coroutine/issue-45729-unsafe-in-coroutine.rs b/tests/ui/coroutine/issue-45729-unsafe-in-coroutine.rs index d90886b6b1d6e..c7aef012c2859 100644 --- a/tests/ui/coroutine/issue-45729-unsafe-in-coroutine.rs +++ b/tests/ui/coroutine/issue-45729-unsafe-in-coroutine.rs @@ -5,6 +5,6 @@ fn main() { || { *(1 as *mut u32) = 42; //~^ ERROR dereference of raw pointer is unsafe - yield; + ().yield; }; } diff --git a/tests/ui/coroutine/issue-48048.rs b/tests/ui/coroutine/issue-48048.rs index 75664f20198b5..0ce9d05054e2a 100644 --- a/tests/ui/coroutine/issue-48048.rs +++ b/tests/ui/coroutine/issue-48048.rs @@ -7,7 +7,7 @@ fn main() { let x = x; x.0({ //~ ERROR borrow may still be in use when coroutine yields - yield; + ().yield; }); }; } diff --git a/tests/ui/coroutine/issue-48048.stderr b/tests/ui/coroutine/issue-48048.stderr index 8231dbef7f626..ce6ee3812d93f 100644 --- a/tests/ui/coroutine/issue-48048.stderr +++ b/tests/ui/coroutine/issue-48048.stderr @@ -6,8 +6,8 @@ LL | #[coroutine] || { ... LL | x.0({ | ^^^ -LL | yield; - | ----- possible yield occurs here +LL | ().yield; + | -------- possible yield occurs here | help: add `static` to mark this coroutine as unmovable | diff --git a/tests/ui/coroutine/issue-52304.rs b/tests/ui/coroutine/issue-52304.rs index 77dfe8391956f..85512af246d0a 100644 --- a/tests/ui/coroutine/issue-52304.rs +++ b/tests/ui/coroutine/issue-52304.rs @@ -8,7 +8,7 @@ use std::ops::Coroutine; pub fn example() -> impl Coroutine { #[coroutine] - || yield &1 + || (&1).yield } fn main() {} diff --git a/tests/ui/coroutine/issue-52398.rs b/tests/ui/coroutine/issue-52398.rs index f8b2faf4eabf0..9c13cff793544 100644 --- a/tests/ui/coroutine/issue-52398.rs +++ b/tests/ui/coroutine/issue-52398.rs @@ -15,14 +15,14 @@ fn main() { // Test that the MIR local with type &A created for the auto-borrow adjustment // is caught by typeck #[coroutine] move || { //~ WARN unused coroutine that must be used - A.test(yield); + A.test(().yield); }; // Test that the std::cell::Ref temporary returned from the `borrow` call // is caught by typeck let y = RefCell::new(true); #[coroutine] static move || { //~ WARN unused coroutine that must be used - yield *y.borrow(); + (*y.borrow()).yield; return "Done"; }; } diff --git a/tests/ui/coroutine/issue-52398.stderr b/tests/ui/coroutine/issue-52398.stderr index b3bf2e4a4e6d6..b07a51e8b44f0 100644 --- a/tests/ui/coroutine/issue-52398.stderr +++ b/tests/ui/coroutine/issue-52398.stderr @@ -3,7 +3,7 @@ warning: unused coroutine that must be used | LL | #[coroutine] move || { | __________________^ -LL | | A.test(yield); +LL | | A.test(().yield); LL | | }; | |_____^ | @@ -15,7 +15,7 @@ warning: unused coroutine that must be used | LL | #[coroutine] static move || { | __________________^ -LL | | yield *y.borrow(); +LL | | (*y.borrow()).yield; LL | | return "Done"; LL | | }; | |_____^ diff --git a/tests/ui/coroutine/issue-53548.rs b/tests/ui/coroutine/issue-53548.rs index c70f3e5a0d0a1..7817d254eb51c 100644 --- a/tests/ui/coroutine/issue-53548.rs +++ b/tests/ui/coroutine/issue-53548.rs @@ -33,6 +33,6 @@ fn main() { let store = Store::> { inner: Default::default(), }; - yield (); + ().yield; }); } diff --git a/tests/ui/coroutine/issue-57017.rs b/tests/ui/coroutine/issue-57017.rs index 19cd80ab4a653..0ca3ee6e85535 100644 --- a/tests/ui/coroutine/issue-57017.rs +++ b/tests/ui/coroutine/issue-57017.rs @@ -22,7 +22,7 @@ macro_rules! type_combinations { // This is the same bug as issue 57017, but using yield instead of await { let g = #[coroutine] move || match drop(&$name::unsync::Client::default()) { - _status => yield, + _status => ().yield, }; assert_send(g); } @@ -31,7 +31,7 @@ macro_rules! type_combinations { // function. { let g = #[coroutine] move || match drop($name::unsend::Client::default()) { - _status => yield, + _status => ().yield, }; assert_send(g); } diff --git a/tests/ui/coroutine/issue-57084.rs b/tests/ui/coroutine/issue-57084.rs index 2df60550e0378..eb388f332053e 100644 --- a/tests/ui/coroutine/issue-57084.rs +++ b/tests/ui/coroutine/issue-57084.rs @@ -11,7 +11,7 @@ where F: Fn() -> () #[coroutine] move || { loop { match f() { - _ => yield, + _ => ().yield, } } } @@ -22,7 +22,7 @@ fn main() { #[coroutine] || { //~ WARN unused coroutine that must be used let _to_pin = with(move || println!("{:p}", data)); loop { - yield + ().yield } }; } diff --git a/tests/ui/coroutine/issue-57084.stderr b/tests/ui/coroutine/issue-57084.stderr index 0e2359f2f817d..be492218cd380 100644 --- a/tests/ui/coroutine/issue-57084.stderr +++ b/tests/ui/coroutine/issue-57084.stderr @@ -5,7 +5,7 @@ LL | #[coroutine] || { | __________________^ LL | | let _to_pin = with(move || println!("{:p}", data)); LL | | loop { -LL | | yield +LL | | ().yield LL | | } LL | | }; | |_____^ diff --git a/tests/ui/coroutine/issue-57478.rs b/tests/ui/coroutine/issue-57478.rs index 494c2ee9843eb..4fdea225a6f39 100644 --- a/tests/ui/coroutine/issue-57478.rs +++ b/tests/ui/coroutine/issue-57478.rs @@ -11,7 +11,7 @@ fn main() { || { let guard = Foo; drop(guard); - yield; + ().yield; }, ) } diff --git a/tests/ui/coroutine/issue-58888.rs b/tests/ui/coroutine/issue-58888.rs index e4fada0cd432e..9b608c0b041e0 100644 --- a/tests/ui/coroutine/issue-58888.rs +++ b/tests/ui/coroutine/issue-58888.rs @@ -17,7 +17,7 @@ impl Database { move || { let iter = self.get_connection(); for i in iter { - yield i + i.yield } } } diff --git a/tests/ui/coroutine/issue-61442-stmt-expr-with-drop.rs b/tests/ui/coroutine/issue-61442-stmt-expr-with-drop.rs index 6f513c250a554..ef6f1db022b3f 100644 --- a/tests/ui/coroutine/issue-61442-stmt-expr-with-drop.rs +++ b/tests/ui/coroutine/issue-61442-stmt-expr-with-drop.rs @@ -17,13 +17,13 @@ fn drop_and_yield() { let x = #[coroutine] || { String::new(); - yield; + ().yield; }; Box::pin(x).as_mut().resume(()); let y = #[coroutine] static || { String::new(); - yield; + ().yield; }; Box::pin(y).as_mut().resume(()); } diff --git a/tests/ui/coroutine/issue-64620-yield-array-element.rs b/tests/ui/coroutine/issue-64620-yield-array-element.rs index 0d898d014e80b..3c071a336b78d 100644 --- a/tests/ui/coroutine/issue-64620-yield-array-element.rs +++ b/tests/ui/coroutine/issue-64620-yield-array-element.rs @@ -3,7 +3,7 @@ #![feature(coroutines)] pub fn crash(arr: [usize; 1]) { - yield arr[0]; //~ ERROR: yield expression outside of coroutine literal + arr[0].yield; //~ ERROR: yield expression outside of coroutine literal //~^ ERROR: `yield` can only be used in } diff --git a/tests/ui/coroutine/issue-64620-yield-array-element.stderr b/tests/ui/coroutine/issue-64620-yield-array-element.stderr index 1c030c5248e1e..6002e0935ceb3 100644 --- a/tests/ui/coroutine/issue-64620-yield-array-element.stderr +++ b/tests/ui/coroutine/issue-64620-yield-array-element.stderr @@ -1,7 +1,7 @@ error: `yield` can only be used in `#[coroutine]` closures, or `gen` blocks --> $DIR/issue-64620-yield-array-element.rs:6:5 | -LL | yield arr[0]; +LL | arr[0].yield; | ^^^^^^^^^^^^ | help: use `#[coroutine]` to make this closure a coroutine @@ -12,7 +12,7 @@ LL | #[coroutine] pub fn crash(arr: [usize; 1]) { error[E0627]: yield expression outside of coroutine literal --> $DIR/issue-64620-yield-array-element.rs:6:5 | -LL | yield arr[0]; +LL | arr[0].yield; | ^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/coroutine/issue-68112.rs b/tests/ui/coroutine/issue-68112.rs index b296772c90577..052251f2539c3 100644 --- a/tests/ui/coroutine/issue-68112.rs +++ b/tests/ui/coroutine/issue-68112.rs @@ -33,7 +33,7 @@ fn test1() { let send_gen = #[coroutine] || { let _non_send_gen = make_non_send_coroutine(); //~^ NOTE not `Send` - yield; + ().yield; //~^ NOTE yield occurs here //~| NOTE value is used across a yield }; @@ -47,7 +47,7 @@ pub fn make_gen2(t: T) -> impl Coroutine { //~^ NOTE appears within the type //~| NOTE expansion of desugaring #[coroutine] || { //~ NOTE used within this coroutine - yield; + ().yield; t } } @@ -59,7 +59,7 @@ fn make_non_send_coroutine2() -> impl Coroutine>> { // fn test2() { let send_gen = #[coroutine] || { //~ NOTE used within this coroutine let _non_send_gen = make_non_send_coroutine2(); - yield; + ().yield; }; require_send(send_gen); //~^ ERROR `RefCell` cannot be shared between threads safely diff --git a/tests/ui/coroutine/issue-68112.stderr b/tests/ui/coroutine/issue-68112.stderr index 124537b971e34..409ff1ad5ea9b 100644 --- a/tests/ui/coroutine/issue-68112.stderr +++ b/tests/ui/coroutine/issue-68112.stderr @@ -12,8 +12,8 @@ note: coroutine is not `Send` as this value is used across a yield LL | let _non_send_gen = make_non_send_coroutine(); | ------------- has type `impl Coroutine>>` which is not `Send` LL | -LL | yield; - | ^^^^^ yield occurs here, with `_non_send_gen` maybe used later +LL | ().yield; + | ^^^^^^^^ yield occurs here, with `_non_send_gen` maybe used later note: required by a bound in `require_send` --> $DIR/issue-68112.rs:22:25 | diff --git a/tests/ui/coroutine/issue-69017.rs b/tests/ui/coroutine/issue-69017.rs index bf69e1dfdb13f..cde566b40172d 100644 --- a/tests/ui/coroutine/issue-69017.rs +++ b/tests/ui/coroutine/issue-69017.rs @@ -12,7 +12,7 @@ use std::ops::Coroutine; fn gen() -> impl Coroutine { #[coroutine] |_: usize| { - println!("-> {}", yield); + println!("-> {}", ().yield); } } diff --git a/tests/ui/coroutine/issue-69039.rs b/tests/ui/coroutine/issue-69039.rs index 13cb50e582817..0ef73d16c84dd 100644 --- a/tests/ui/coroutine/issue-69039.rs +++ b/tests/ui/coroutine/issue-69039.rs @@ -11,8 +11,8 @@ fn mkstr(my_name: String, my_mood: String) -> String { fn my_scenario() -> impl Coroutine { #[coroutine] |_arg: String| { - let my_name = yield "What is your name?"; - let my_mood = yield "How are you feeling?"; + let my_name = "What is your name?".yield; + let my_mood = "How are you feeling?".yield; mkstr(my_name, my_mood) } } diff --git a/tests/ui/coroutine/issue-87142.rs b/tests/ui/coroutine/issue-87142.rs index 6c22ba3dd7560..43bd09ecf51fb 100644 --- a/tests/ui/coroutine/issue-87142.rs +++ b/tests/ui/coroutine/issue-87142.rs @@ -27,7 +27,7 @@ impl CoroutineProviderAlt for () { match ctx { _ => (), } - yield (); + ().yield; } } } diff --git a/tests/ui/coroutine/issue-88653.rs b/tests/ui/coroutine/issue-88653.rs index b5936c7960de4..37f40a2d15c28 100644 --- a/tests/ui/coroutine/issue-88653.rs +++ b/tests/ui/coroutine/issue-88653.rs @@ -16,7 +16,7 @@ fn foo(bar: bool) -> impl Coroutine<(bool,)> { //~^ NOTE: found signature defined here //~| NOTE: return type was inferred to be if bar { - yield bar; + bar.yield; } } } diff --git a/tests/ui/coroutine/issue-91477.rs b/tests/ui/coroutine/issue-91477.rs index c215fd7948f33..5fc18699d41e5 100644 --- a/tests/ui/coroutine/issue-91477.rs +++ b/tests/ui/coroutine/issue-91477.rs @@ -1,7 +1,7 @@ #![feature(coroutines)] fn foo() -> impl Sized { - yield 1; //~ ERROR E0627 + 1.yield; //~ ERROR E0627 //~^ ERROR: `yield` can only be used in } diff --git a/tests/ui/coroutine/issue-91477.stderr b/tests/ui/coroutine/issue-91477.stderr index 5e2151c4c35fe..fd0abbea827b8 100644 --- a/tests/ui/coroutine/issue-91477.stderr +++ b/tests/ui/coroutine/issue-91477.stderr @@ -1,7 +1,7 @@ error: `yield` can only be used in `#[coroutine]` closures, or `gen` blocks --> $DIR/issue-91477.rs:4:5 | -LL | yield 1; +LL | 1.yield; | ^^^^^^^ | help: use `#[coroutine]` to make this closure a coroutine @@ -12,7 +12,7 @@ LL | #[coroutine] fn foo() -> impl Sized { error[E0627]: yield expression outside of coroutine literal --> $DIR/issue-91477.rs:4:5 | -LL | yield 1; +LL | 1.yield; | ^^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/coroutine/iterator-count.rs b/tests/ui/coroutine/iterator-count.rs index 1ca8ceaed2a9e..9d19e18519609 100644 --- a/tests/ui/coroutine/iterator-count.rs +++ b/tests/ui/coroutine/iterator-count.rs @@ -24,7 +24,7 @@ fn test() -> impl Coroutine<(), Return = (), Yield = u8> + Unpin { #[coroutine] || { for i in 1..6 { - yield i + i.yield } } } @@ -36,7 +36,7 @@ fn main() { #[coroutine] move || { for i in start..end { - yield i + i.yield } } }; diff --git a/tests/ui/coroutine/live-upvar-across-yield.rs b/tests/ui/coroutine/live-upvar-across-yield.rs index d13d480dcdcce..509d98e8edc24 100644 --- a/tests/ui/coroutine/live-upvar-across-yield.rs +++ b/tests/ui/coroutine/live-upvar-across-yield.rs @@ -8,7 +8,7 @@ use std::pin::Pin; fn main() { let b = |_| 3; let mut a = #[coroutine] || { - b(yield); + b(().yield); }; Pin::new(&mut a).resume(()); } diff --git a/tests/ui/coroutine/match-bindings.rs b/tests/ui/coroutine/match-bindings.rs index 2a0cd9af9f382..39225f7821c0c 100644 --- a/tests/ui/coroutine/match-bindings.rs +++ b/tests/ui/coroutine/match-bindings.rs @@ -17,7 +17,7 @@ fn main() { Enum::B => {} } } - yield; + ().yield; } }; } diff --git a/tests/ui/coroutine/missing_coroutine_attr_suggestion.fixed b/tests/ui/coroutine/missing_coroutine_attr_suggestion.fixed index 128f09a118439..e840fcc7fbdaf 100644 --- a/tests/ui/coroutine/missing_coroutine_attr_suggestion.fixed +++ b/tests/ui/coroutine/missing_coroutine_attr_suggestion.fixed @@ -3,6 +3,6 @@ #![feature(coroutines, gen_blocks, stmt_expr_attributes)] fn main() { - let _ = #[coroutine] || yield; + let _ = #[coroutine] || ().yield; //~^ ERROR `yield` can only be used } diff --git a/tests/ui/coroutine/missing_coroutine_attr_suggestion.rs b/tests/ui/coroutine/missing_coroutine_attr_suggestion.rs index dc95259149609..d2d2d2f13797e 100644 --- a/tests/ui/coroutine/missing_coroutine_attr_suggestion.rs +++ b/tests/ui/coroutine/missing_coroutine_attr_suggestion.rs @@ -3,6 +3,6 @@ #![feature(coroutines, gen_blocks, stmt_expr_attributes)] fn main() { - let _ = || yield; + let _ = || ().yield; //~^ ERROR `yield` can only be used } diff --git a/tests/ui/coroutine/missing_coroutine_attr_suggestion.stderr b/tests/ui/coroutine/missing_coroutine_attr_suggestion.stderr index 8d92471a361cd..b8c5bb3daa34f 100644 --- a/tests/ui/coroutine/missing_coroutine_attr_suggestion.stderr +++ b/tests/ui/coroutine/missing_coroutine_attr_suggestion.stderr @@ -1,12 +1,12 @@ error: `yield` can only be used in `#[coroutine]` closures, or `gen` blocks --> $DIR/missing_coroutine_attr_suggestion.rs:6:16 | -LL | let _ = || yield; - | ^^^^^ +LL | let _ = || ().yield; + | ^^^^^^^^ | help: use `#[coroutine]` to make this closure a coroutine | -LL | let _ = #[coroutine] || yield; +LL | let _ = #[coroutine] || ().yield; | ++++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/coroutine/moved-twice.rs b/tests/ui/coroutine/moved-twice.rs index 72b83e274c929..d7d07f85c02a7 100644 --- a/tests/ui/coroutine/moved-twice.rs +++ b/tests/ui/coroutine/moved-twice.rs @@ -15,12 +15,12 @@ impl Drop for Foo { fn overlap_move_points() -> impl Coroutine { #[coroutine] static || { let first = Foo([0; FOO_SIZE]); - yield; + ().yield; let second = first; - yield; + ().yield; let second = first; //~^ ERROR: use of moved value: `first` [E0382] - yield; + ().yield; } } diff --git a/tests/ui/coroutine/moved-twice.stderr b/tests/ui/coroutine/moved-twice.stderr index 2b21f6c59f0bc..e3b620979f9d3 100644 --- a/tests/ui/coroutine/moved-twice.stderr +++ b/tests/ui/coroutine/moved-twice.stderr @@ -3,10 +3,10 @@ error[E0382]: use of moved value: `first` | LL | let first = Foo([0; FOO_SIZE]); | ----- move occurs because `first` has type `Foo`, which does not implement the `Copy` trait -LL | yield; +LL | ().yield; LL | let second = first; | ----- value moved here -LL | yield; +LL | ().yield; LL | let second = first; | ^^^^^ value used here after move | diff --git a/tests/ui/coroutine/nested_coroutine.rs b/tests/ui/coroutine/nested_coroutine.rs index 2c12ab2adad41..694d302bd80cd 100644 --- a/tests/ui/coroutine/nested_coroutine.rs +++ b/tests/ui/coroutine/nested_coroutine.rs @@ -10,12 +10,12 @@ fn main() { || { let mut sub_coroutine = #[coroutine] || { - yield 2; + 2.yield; }; match Pin::new(&mut sub_coroutine).resume(()) { CoroutineState::Yielded(x) => { - yield x; + x.yield; } _ => panic!(), }; diff --git a/tests/ui/coroutine/niche-in-coroutine.rs b/tests/ui/coroutine/niche-in-coroutine.rs index f268ef09f8923..4c0681058d6b9 100644 --- a/tests/ui/coroutine/niche-in-coroutine.rs +++ b/tests/ui/coroutine/niche-in-coroutine.rs @@ -11,7 +11,7 @@ fn take(_: T) {} fn main() { let x = false; let gen1 = #[coroutine] || { - yield; + ().yield; take(x); }; diff --git a/tests/ui/coroutine/non-static-is-unpin.rs b/tests/ui/coroutine/non-static-is-unpin.rs index b28bf1977145b..fe9f06c4d8c96 100644 --- a/tests/ui/coroutine/non-static-is-unpin.rs +++ b/tests/ui/coroutine/non-static-is-unpin.rs @@ -16,7 +16,7 @@ fn main() { // remains `Unpin`. assert_unpin(#[coroutine] || { let pinned = PhantomPinned; - yield; + ().yield; drop(pinned); }); } diff --git a/tests/ui/coroutine/not-send-sync.rs b/tests/ui/coroutine/not-send-sync.rs index a46dcd14e8825..af347baf883e3 100644 --- a/tests/ui/coroutine/not-send-sync.rs +++ b/tests/ui/coroutine/not-send-sync.rs @@ -14,14 +14,14 @@ fn main() { assert_sync(#[coroutine] || { //~^ ERROR: coroutine cannot be shared between threads safely let a = NotSync; - yield; + ().yield; drop(a); }); assert_send(#[coroutine] || { //~^ ERROR: coroutine cannot be sent between threads safely let a = NotSend; - yield; + ().yield; drop(a); }); } diff --git a/tests/ui/coroutine/not-send-sync.stderr b/tests/ui/coroutine/not-send-sync.stderr index 16277edd66a8e..125e4963f0d34 100644 --- a/tests/ui/coroutine/not-send-sync.stderr +++ b/tests/ui/coroutine/not-send-sync.stderr @@ -4,7 +4,7 @@ error: coroutine cannot be shared between threads safely LL | / assert_sync(#[coroutine] || { LL | | LL | | let a = NotSync; -LL | | yield; +LL | | ().yield; LL | | drop(a); LL | | }); | |______^ coroutine is not `Sync` @@ -19,8 +19,8 @@ note: coroutine is not `Sync` as this value is used across a yield | LL | let a = NotSync; | - has type `NotSync` which is not `Sync` -LL | yield; - | ^^^^^ yield occurs here, with `a` maybe used later +LL | ().yield; + | ^^^^^^^^ yield occurs here, with `a` maybe used later note: required by a bound in `assert_sync` --> $DIR/not-send-sync.rs:11:23 | @@ -33,7 +33,7 @@ error: coroutine cannot be sent between threads safely LL | / assert_send(#[coroutine] || { LL | | LL | | let a = NotSend; -LL | | yield; +LL | | ().yield; LL | | drop(a); LL | | }); | |______^ coroutine is not `Send` @@ -48,8 +48,8 @@ note: coroutine is not `Send` as this value is used across a yield | LL | let a = NotSend; | - has type `NotSend` which is not `Send` -LL | yield; - | ^^^^^ yield occurs here, with `a` maybe used later +LL | ().yield; + | ^^^^^^^^ yield occurs here, with `a` maybe used later note: required by a bound in `assert_send` --> $DIR/not-send-sync.rs:12:23 | diff --git a/tests/ui/coroutine/other-attribute-on-gen.rs b/tests/ui/coroutine/other-attribute-on-gen.rs index 5f4584ee0226e..377d2330e5fed 100644 --- a/tests/ui/coroutine/other-attribute-on-gen.rs +++ b/tests/ui/coroutine/other-attribute-on-gen.rs @@ -12,21 +12,21 @@ fn main() { } fn optimize_gen_block() -> impl Iterator { #[optimize(speed)] - gen { yield (); } + gen { ().yield; } } #[optimize(speed)] gen fn optimize_gen_fn() -> i32 { - yield 1; - yield 2; - yield 3; + 1.yield; + 2.yield; + 3.yield; } #[optimize(speed)] async gen fn optimize_async_gen_fn() -> i32 { - yield 1; - yield 2; - yield 3; + 1.yield; + 2.yield; + 3.yield; } use std::async_iter::AsyncIterator; @@ -34,6 +34,6 @@ use std::async_iter::AsyncIterator; pub fn deduce() -> impl AsyncIterator { #[optimize(size)] async gen { - yield (); + ().yield; } } diff --git a/tests/ui/coroutine/overlap-locals.rs b/tests/ui/coroutine/overlap-locals.rs index 9cfa6e2a76dd2..5f3fcffb34420 100644 --- a/tests/ui/coroutine/overlap-locals.rs +++ b/tests/ui/coroutine/overlap-locals.rs @@ -7,22 +7,22 @@ fn main() { || { { let w: i32 = 4; - yield; + ().yield; println!("{:?}", w); } { let x: i32 = 5; - yield; + ().yield; println!("{:?}", x); } { let y: i32 = 6; - yield; + ().yield; println!("{:?}", y); } { let z: i32 = 7; - yield; + ().yield; println!("{:?}", z); } }; diff --git a/tests/ui/coroutine/panic-drops-resume.rs b/tests/ui/coroutine/panic-drops-resume.rs index ee58dab3e3703..c01acb62c75dc 100644 --- a/tests/ui/coroutine/panic-drops-resume.rs +++ b/tests/ui/coroutine/panic-drops-resume.rs @@ -26,7 +26,7 @@ fn main() { if true { panic!(); } - yield (); + ().yield; }; let mut gen = Pin::new(&mut gen); diff --git a/tests/ui/coroutine/panic-drops.rs b/tests/ui/coroutine/panic-drops.rs index c8ac401372f78..d5ed64823a5ed 100644 --- a/tests/ui/coroutine/panic-drops.rs +++ b/tests/ui/coroutine/panic-drops.rs @@ -31,7 +31,7 @@ fn main() { panic!(); } drop(b); - yield; + ().yield; }; assert_eq!(A.load(Ordering::SeqCst), 0); @@ -45,7 +45,7 @@ fn main() { panic!(); } drop(B); - yield; + ().yield; }; assert_eq!(A.load(Ordering::SeqCst), 1); diff --git a/tests/ui/coroutine/panic-safe.rs b/tests/ui/coroutine/panic-safe.rs index cee2afacb6145..2166122ce05be 100644 --- a/tests/ui/coroutine/panic-safe.rs +++ b/tests/ui/coroutine/panic-safe.rs @@ -13,7 +13,7 @@ fn main() { if true { panic!(); } - yield; + ().yield; }; let res = panic::catch_unwind(panic::AssertUnwindSafe(|| { diff --git a/tests/ui/coroutine/parent-expression.rs b/tests/ui/coroutine/parent-expression.rs index 702cbc88ae4b0..ee99009cdba95 100644 --- a/tests/ui/coroutine/parent-expression.rs +++ b/tests/ui/coroutine/parent-expression.rs @@ -20,7 +20,7 @@ macro_rules! type_combinations { //~^ NOTE `significant_drop::Client` which is not `Send` //~| NOTE `insignificant_dtor::Client` which is not `Send` //~| NOTE `derived_drop::Client` which is not `Send` - _ => yield, + _ => ().yield, }; assert_send(g); //~^ ERROR cannot be sent between threads @@ -32,7 +32,7 @@ macro_rules! type_combinations { // even though the temporary expression doesn't end until after the yield. { let g = #[coroutine] move || match drop($name::Client::default()) { - _ => yield, + _ => ().yield, }; assert_send(g); } diff --git a/tests/ui/coroutine/parent-expression.stderr b/tests/ui/coroutine/parent-expression.stderr index 0dd97c538a87c..5a24532c5ed7f 100644 --- a/tests/ui/coroutine/parent-expression.stderr +++ b/tests/ui/coroutine/parent-expression.stderr @@ -23,8 +23,8 @@ note: coroutine is not `Send` as this value is used across a yield LL | let g = #[coroutine] move || match drop($name::Client { ..$name::Client::default() }) { | ------------------------ has type `derived_drop::Client` which is not `Send` ... -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later +LL | _ => ().yield, + | ^^^^^^^^ yield occurs here, with `$name::Client::default()` maybe used later ... LL | / type_combinations!( LL | | // OK @@ -65,8 +65,8 @@ note: coroutine is not `Send` as this value is used across a yield LL | let g = #[coroutine] move || match drop($name::Client { ..$name::Client::default() }) { | ------------------------ has type `significant_drop::Client` which is not `Send` ... -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later +LL | _ => ().yield, + | ^^^^^^^^ yield occurs here, with `$name::Client::default()` maybe used later ... LL | / type_combinations!( LL | | // OK @@ -107,8 +107,8 @@ note: coroutine is not `Send` as this value is used across a yield LL | let g = #[coroutine] move || match drop($name::Client { ..$name::Client::default() }) { | ------------------------ has type `insignificant_dtor::Client` which is not `Send` ... -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later +LL | _ => ().yield, + | ^^^^^^^^ yield occurs here, with `$name::Client::default()` maybe used later ... LL | / type_combinations!( LL | | // OK diff --git a/tests/ui/coroutine/partial-drop.rs b/tests/ui/coroutine/partial-drop.rs index 9efb551c9c181..f9fcbe3dc8d0f 100644 --- a/tests/ui/coroutine/partial-drop.rs +++ b/tests/ui/coroutine/partial-drop.rs @@ -15,7 +15,7 @@ fn main() { || { let guard = Bar { foo: Foo, x: 42 }; drop(guard.foo); - yield; + ().yield; }, ); @@ -25,7 +25,7 @@ fn main() { let mut guard = Bar { foo: Foo, x: 42 }; drop(guard); guard = Bar { foo: Foo, x: 23 }; - yield; + ().yield; }, ); @@ -35,7 +35,7 @@ fn main() { let guard = Bar { foo: Foo, x: 42 }; let Bar { foo, x } = guard; drop(foo); - yield; + ().yield; }, ); } diff --git a/tests/ui/coroutine/partial-initialization-across-yield.rs b/tests/ui/coroutine/partial-initialization-across-yield.rs index ab6f9c5b1e981..b849e51590047 100644 --- a/tests/ui/coroutine/partial-initialization-across-yield.rs +++ b/tests/ui/coroutine/partial-initialization-across-yield.rs @@ -10,7 +10,7 @@ fn test_tuple() { let _ = #[coroutine] || { let mut t: (i32, i32); t.0 = 42; //~ ERROR E0381 - yield; + ().yield; t.1 = 88; let _ = t; }; @@ -20,7 +20,7 @@ fn test_tuple_struct() { let _ = #[coroutine] || { let mut t: T; t.0 = 42; //~ ERROR E0381 - yield; + ().yield; t.1 = 88; let _ = t; }; @@ -30,7 +30,7 @@ fn test_struct() { let _ = #[coroutine] || { let mut t: S; t.x = 42; //~ ERROR E0381 - yield; + ().yield; t.y = 88; let _ = t; }; diff --git a/tests/ui/coroutine/pattern-borrow.rs b/tests/ui/coroutine/pattern-borrow.rs index 46547504abc9d..351f9c1737315 100644 --- a/tests/ui/coroutine/pattern-borrow.rs +++ b/tests/ui/coroutine/pattern-borrow.rs @@ -7,7 +7,7 @@ fn main() { } fn fun(test: Test) { #[coroutine] move || { if let Test::A(ref _a) = test { //~ ERROR borrow may still be in use when coroutine yields - yield (); + ().yield; _a.use_ref(); } }; diff --git a/tests/ui/coroutine/pattern-borrow.stderr b/tests/ui/coroutine/pattern-borrow.stderr index a3954b0b8ad68..eed91387d4346 100644 --- a/tests/ui/coroutine/pattern-borrow.stderr +++ b/tests/ui/coroutine/pattern-borrow.stderr @@ -5,7 +5,7 @@ LL | #[coroutine] move || { | ------- within this coroutine LL | if let Test::A(ref _a) = test { | ^^^^^^ -LL | yield (); +LL | ().yield; | -------- possible yield occurs here | help: add `static` to mark this coroutine as unmovable diff --git a/tests/ui/coroutine/pin-box-coroutine.rs b/tests/ui/coroutine/pin-box-coroutine.rs index d030f3ef214d1..af9b8753d5e77 100644 --- a/tests/ui/coroutine/pin-box-coroutine.rs +++ b/tests/ui/coroutine/pin-box-coroutine.rs @@ -8,6 +8,6 @@ fn assert_coroutine(_: G) { } fn main() { - assert_coroutine(#[coroutine] static || yield); - assert_coroutine(Box::pin(#[coroutine] static || yield)); + assert_coroutine(#[coroutine] static || ().yield); + assert_coroutine(Box::pin(#[coroutine] static || ().yield)); } diff --git a/tests/ui/coroutine/postfix-yield.rs b/tests/ui/coroutine/postfix-yield.rs index f2fdcebdaa9a9..214703e894d96 100644 --- a/tests/ui/coroutine/postfix-yield.rs +++ b/tests/ui/coroutine/postfix-yield.rs @@ -11,7 +11,7 @@ use std::pin::pin; fn main() { // generators (i.e. yield doesn't return anything useful) let mut gn = gen { - yield 1; + 1.yield; 2.yield; }; diff --git a/tests/ui/coroutine/print/coroutine-print-verbose-1.rs b/tests/ui/coroutine/print/coroutine-print-verbose-1.rs index dc0165c9194da..5bcd1b6c1653e 100644 --- a/tests/ui/coroutine/print/coroutine-print-verbose-1.rs +++ b/tests/ui/coroutine/print/coroutine-print-verbose-1.rs @@ -32,7 +32,7 @@ fn make_non_send_coroutine() -> impl Coroutine>> { fn test1() { let send_gen = #[coroutine] || { let _non_send_gen = make_non_send_coroutine(); - yield; + ().yield; }; require_send(send_gen); //~^ ERROR coroutine cannot be sent between threads @@ -40,7 +40,7 @@ fn test1() { pub fn make_gen2(t: T) -> impl Coroutine { #[coroutine] || { - yield; + ().yield; t } } @@ -51,7 +51,7 @@ fn make_non_send_coroutine2() -> impl Coroutine>> { fn test2() { let send_gen = #[coroutine] || { let _non_send_gen = make_non_send_coroutine2(); - yield; + ().yield; }; require_send(send_gen); //~^ ERROR `RefCell` cannot be shared between threads safely diff --git a/tests/ui/coroutine/print/coroutine-print-verbose-1.stderr b/tests/ui/coroutine/print/coroutine-print-verbose-1.stderr index 410189b9ab6d5..7f6b84abd5d4d 100644 --- a/tests/ui/coroutine/print/coroutine-print-verbose-1.stderr +++ b/tests/ui/coroutine/print/coroutine-print-verbose-1.stderr @@ -11,8 +11,8 @@ note: coroutine is not `Send` as this value is used across a yield | LL | let _non_send_gen = make_non_send_coroutine(); | ------------- has type `Opaque(DefId(0:24 ~ coroutine_print_verbose_1[75fb]::make_non_send_coroutine::{opaque#0}), [])` which is not `Send` -LL | yield; - | ^^^^^ yield occurs here, with `_non_send_gen` maybe used later +LL | ().yield; + | ^^^^^^^^ yield occurs here, with `_non_send_gen` maybe used later note: required by a bound in `require_send` --> $DIR/coroutine-print-verbose-1.rs:26:25 | diff --git a/tests/ui/coroutine/print/coroutine-print-verbose-2.rs b/tests/ui/coroutine/print/coroutine-print-verbose-2.rs index ef7199cafdde0..1da87bbbc370f 100644 --- a/tests/ui/coroutine/print/coroutine-print-verbose-2.rs +++ b/tests/ui/coroutine/print/coroutine-print-verbose-2.rs @@ -17,14 +17,14 @@ fn main() { assert_sync(#[coroutine] || { //~^ ERROR: coroutine cannot be shared between threads safely let a = NotSync; - yield; + ().yield; drop(a); }); assert_send(#[coroutine] || { //~^ ERROR: coroutine cannot be sent between threads safely let a = NotSend; - yield; + ().yield; drop(a); }); } diff --git a/tests/ui/coroutine/print/coroutine-print-verbose-2.stderr b/tests/ui/coroutine/print/coroutine-print-verbose-2.stderr index d27660c67d9b1..78394ea6c37b8 100644 --- a/tests/ui/coroutine/print/coroutine-print-verbose-2.stderr +++ b/tests/ui/coroutine/print/coroutine-print-verbose-2.stderr @@ -4,7 +4,7 @@ error: coroutine cannot be shared between threads safely LL | / assert_sync(#[coroutine] || { LL | | LL | | let a = NotSync; -LL | | yield; +LL | | ().yield; LL | | drop(a); LL | | }); | |______^ coroutine is not `Sync` @@ -19,8 +19,8 @@ note: coroutine is not `Sync` as this value is used across a yield | LL | let a = NotSync; | - has type `NotSync` which is not `Sync` -LL | yield; - | ^^^^^ yield occurs here, with `a` maybe used later +LL | ().yield; + | ^^^^^^^^ yield occurs here, with `a` maybe used later note: required by a bound in `assert_sync` --> $DIR/coroutine-print-verbose-2.rs:14:23 | @@ -33,7 +33,7 @@ error: coroutine cannot be sent between threads safely LL | / assert_send(#[coroutine] || { LL | | LL | | let a = NotSend; -LL | | yield; +LL | | ().yield; LL | | drop(a); LL | | }); | |______^ coroutine is not `Send` @@ -48,8 +48,8 @@ note: coroutine is not `Send` as this value is used across a yield | LL | let a = NotSend; | - has type `NotSend` which is not `Send` -LL | yield; - | ^^^^^ yield occurs here, with `a` maybe used later +LL | ().yield; + | ^^^^^^^^ yield occurs here, with `a` maybe used later note: required by a bound in `assert_send` --> $DIR/coroutine-print-verbose-2.rs:15:23 | diff --git a/tests/ui/coroutine/print/coroutine-print-verbose-3.rs b/tests/ui/coroutine/print/coroutine-print-verbose-3.rs index 5dd15fc1b9516..2580a6f8fbceb 100644 --- a/tests/ui/coroutine/print/coroutine-print-verbose-3.rs +++ b/tests/ui/coroutine/print/coroutine-print-verbose-3.rs @@ -7,7 +7,7 @@ fn main() { let coroutine: () = #[coroutine] || { //~^ ERROR mismatched types - yield 1i32; + 1i32.yield; return x; }; } diff --git a/tests/ui/coroutine/print/coroutine-print-verbose-3.stderr b/tests/ui/coroutine/print/coroutine-print-verbose-3.stderr index 135e81757938c..75b9569065c79 100644 --- a/tests/ui/coroutine/print/coroutine-print-verbose-3.stderr +++ b/tests/ui/coroutine/print/coroutine-print-verbose-3.stderr @@ -5,7 +5,7 @@ LL | let coroutine: () = #[coroutine] | -- expected due to this LL | / || { LL | | -LL | | yield 1i32; +LL | | 1i32.yield; LL | | return x; LL | | }; | |_____^ expected `()`, found coroutine diff --git a/tests/ui/coroutine/reborrow-mut-upvar.rs b/tests/ui/coroutine/reborrow-mut-upvar.rs index 716781e365c5a..1b9cdf3122d98 100644 --- a/tests/ui/coroutine/reborrow-mut-upvar.rs +++ b/tests/ui/coroutine/reborrow-mut-upvar.rs @@ -6,7 +6,7 @@ fn _run(bar: &mut i32) { #[coroutine] || { //~ WARN unused coroutine that must be used { let _baz = &*bar; - yield; + ().yield; } *bar = 2; diff --git a/tests/ui/coroutine/reborrow-mut-upvar.stderr b/tests/ui/coroutine/reborrow-mut-upvar.stderr index a77121a25dc5d..953906372467c 100644 --- a/tests/ui/coroutine/reborrow-mut-upvar.stderr +++ b/tests/ui/coroutine/reborrow-mut-upvar.stderr @@ -5,7 +5,7 @@ LL | #[coroutine] || { | __________________^ LL | | { LL | | let _baz = &*bar; -LL | | yield; +LL | | ().yield; ... | LL | | *bar = 2; LL | | }; diff --git a/tests/ui/coroutine/ref-escapes-but-not-over-yield.rs b/tests/ui/coroutine/ref-escapes-but-not-over-yield.rs index 0f9c56786da06..eb8ff0de25021 100644 --- a/tests/ui/coroutine/ref-escapes-but-not-over-yield.rs +++ b/tests/ui/coroutine/ref-escapes-but-not-over-yield.rs @@ -7,7 +7,7 @@ fn foo(x: &i32) { let mut a = &3; let mut b = #[coroutine] move || { - yield (); + ().yield; let b = 5; a = &b; //~^ ERROR borrowed data escapes outside of coroutine diff --git a/tests/ui/coroutine/ref-upvar-not-send.rs b/tests/ui/coroutine/ref-upvar-not-send.rs index 89bb5e5495f45..1d658d56476e9 100644 --- a/tests/ui/coroutine/ref-upvar-not-send.rs +++ b/tests/ui/coroutine/ref-upvar-not-send.rs @@ -15,7 +15,7 @@ fn main() { assert_send(#[coroutine] move || { //~^ ERROR coroutine cannot be sent between threads safely //~| NOTE coroutine is not `Send` - yield; + ().yield; let _x = x; }); //~^^ NOTE captured value is not `Send` because `&` references cannot be sent unless their referent is `Sync` @@ -23,7 +23,7 @@ fn main() { assert_send(#[coroutine] move || { //~^ ERROR coroutine cannot be sent between threads safely //~| NOTE coroutine is not `Send` - yield; + ().yield; let _y = y; }); //~^^ NOTE captured value is not `Send` because `&mut` references cannot be sent unless their referent is `Send` diff --git a/tests/ui/coroutine/ref-upvar-not-send.stderr b/tests/ui/coroutine/ref-upvar-not-send.stderr index 3a5e8ec4dab0c..597f2a691495e 100644 --- a/tests/ui/coroutine/ref-upvar-not-send.stderr +++ b/tests/ui/coroutine/ref-upvar-not-send.stderr @@ -4,7 +4,7 @@ error: coroutine cannot be sent between threads safely LL | / assert_send(#[coroutine] move || { LL | | LL | | -LL | | yield; +LL | | ().yield; LL | | let _x = x; LL | | }); | |______^ coroutine is not `Send` @@ -27,7 +27,7 @@ error: coroutine cannot be sent between threads safely LL | / assert_send(#[coroutine] move || { LL | | LL | | -LL | | yield; +LL | | ().yield; LL | | let _y = y; LL | | }); | |______^ coroutine is not `Send` diff --git a/tests/ui/coroutine/reinit-in-match-guard.rs b/tests/ui/coroutine/reinit-in-match-guard.rs index 0a97d9fbcb2f7..1c1ce89a6f6a0 100644 --- a/tests/ui/coroutine/reinit-in-match-guard.rs +++ b/tests/ui/coroutine/reinit-in-match-guard.rs @@ -14,7 +14,7 @@ fn main() { false } => {} _ => { - yield; + ().yield; } } }; diff --git a/tests/ui/coroutine/resume-after-return.rs b/tests/ui/coroutine/resume-after-return.rs index f566bd37d3d10..95a8a6f727972 100644 --- a/tests/ui/coroutine/resume-after-return.rs +++ b/tests/ui/coroutine/resume-after-return.rs @@ -14,7 +14,7 @@ fn main() { if true { return; } - yield; + ().yield; }; match Pin::new(&mut foo).resume(()) { diff --git a/tests/ui/coroutine/resume-arg-late-bound.rs b/tests/ui/coroutine/resume-arg-late-bound.rs index e84184da631b5..29ecc4c7e64c5 100644 --- a/tests/ui/coroutine/resume-arg-late-bound.rs +++ b/tests/ui/coroutine/resume-arg-late-bound.rs @@ -9,7 +9,7 @@ fn test(a: impl for<'a> Coroutine<&'a mut bool>) {} fn main() { let gen = #[coroutine] |arg: &mut bool| { - yield (); + ().yield; *arg = true; }; test(gen); diff --git a/tests/ui/coroutine/resume-arg-outlives-2.rs b/tests/ui/coroutine/resume-arg-outlives-2.rs index a805cea9b7ea4..a5d3f741af6b2 100644 --- a/tests/ui/coroutine/resume-arg-outlives-2.rs +++ b/tests/ui/coroutine/resume-arg-outlives-2.rs @@ -9,8 +9,8 @@ fn demo<'not_static>(s: &'not_static str) -> thread::JoinHandle<()> { let mut generator = Box::pin({ #[coroutine] move |_ctx| { - let ctx: &'not_static str = yield; - yield; + let ctx: &'not_static str = ().yield; + ().yield; dbg!(ctx); } }); diff --git a/tests/ui/coroutine/resume-arg-outlives.rs b/tests/ui/coroutine/resume-arg-outlives.rs index 258be28e0631c..fbdf695465749 100644 --- a/tests/ui/coroutine/resume-arg-outlives.rs +++ b/tests/ui/coroutine/resume-arg-outlives.rs @@ -9,7 +9,7 @@ fn demo<'not_static>(s: &'not_static str) -> Pin| { loop { drop(x); - x = yield; + x = ().yield; } }; diff --git a/tests/ui/coroutine/resume-live-across-yield.rs b/tests/ui/coroutine/resume-live-across-yield.rs index b67619ee70fb2..bd8a024d633fe 100644 --- a/tests/ui/coroutine/resume-live-across-yield.rs +++ b/tests/ui/coroutine/resume-live-across-yield.rs @@ -20,7 +20,7 @@ impl Drop for Dropper { fn main() { let mut g = #[coroutine] |mut _d| { - _d = yield; + _d = ().yield; _d }; diff --git a/tests/ui/coroutine/retain-resume-ref.rs b/tests/ui/coroutine/retain-resume-ref.rs index 000e40d47fbe8..535fc50873dae 100644 --- a/tests/ui/coroutine/retain-resume-ref.rs +++ b/tests/ui/coroutine/retain-resume-ref.rs @@ -15,7 +15,7 @@ fn main() { let mut gen = #[coroutine] |r| { if false { - yield r; + r.yield; } }; diff --git a/tests/ui/coroutine/return-types-diverge.rs b/tests/ui/coroutine/return-types-diverge.rs index 7aa8fc028ce44..0aef6bd6ac8f8 100644 --- a/tests/ui/coroutine/return-types-diverge.rs +++ b/tests/ui/coroutine/return-types-diverge.rs @@ -10,11 +10,11 @@ async gen fn async_gen_fn() -> i32 { diverge() } gen fn gen_fn() -> i32 { diverge() } fn async_gen_block() { - async gen { yield (); diverge() }; + async gen { ().yield; diverge() }; } fn gen_block() { - gen { yield (); diverge() }; + gen { ().yield; diverge() }; } fn main() {} diff --git a/tests/ui/coroutine/return-types.rs b/tests/ui/coroutine/return-types.rs index 4fecc55053104..4aabc7780c992 100644 --- a/tests/ui/coroutine/return-types.rs +++ b/tests/ui/coroutine/return-types.rs @@ -9,12 +9,12 @@ gen fn gen_fn() -> i32 { 0 } //~^ ERROR mismatched types fn async_gen_block() { - async gen { yield (); 1 }; + async gen { ().yield; 1 }; //~^ ERROR mismatched types } fn gen_block() { - gen { yield (); 1 }; + gen { ().yield; 1 }; //~^ ERROR mismatched types } diff --git a/tests/ui/coroutine/return-types.stderr b/tests/ui/coroutine/return-types.stderr index 7be96e538d935..55a01cebe538f 100644 --- a/tests/ui/coroutine/return-types.stderr +++ b/tests/ui/coroutine/return-types.stderr @@ -17,13 +17,13 @@ LL | gen fn gen_fn() -> i32 { 0 } error[E0308]: mismatched types --> $DIR/return-types.rs:12:27 | -LL | async gen { yield (); 1 }; +LL | async gen { ().yield; 1 }; | ^ expected `()`, found integer error[E0308]: mismatched types --> $DIR/return-types.rs:17:21 | -LL | gen { yield (); 1 }; +LL | gen { ().yield; 1 }; | ^ expected `()`, found integer error: aborting due to 4 previous errors diff --git a/tests/ui/coroutine/self_referential_gen_block.rs b/tests/ui/coroutine/self_referential_gen_block.rs index 322cbf4f18a9d..b2ab7ce4ee1b4 100644 --- a/tests/ui/coroutine/self_referential_gen_block.rs +++ b/tests/ui/coroutine/self_referential_gen_block.rs @@ -7,7 +7,7 @@ fn main() { let mut x = gen { let y = 42; let z = &y; //~ ERROR: borrow may still be in use when `gen` block yields - yield 43; + 43.yield; panic!("{z}"); }; x.next(); diff --git a/tests/ui/coroutine/self_referential_gen_block.stderr b/tests/ui/coroutine/self_referential_gen_block.stderr index 2f53e7c84a10b..cdc8fde27f172 100644 --- a/tests/ui/coroutine/self_referential_gen_block.stderr +++ b/tests/ui/coroutine/self_referential_gen_block.stderr @@ -6,7 +6,7 @@ LL | let mut x = gen { LL | let y = 42; LL | let z = &y; | ^^ -LL | yield 43; +LL | 43.yield; | -------- possible yield occurs here error: aborting due to 1 previous error diff --git a/tests/ui/coroutine/size-moved-locals.rs b/tests/ui/coroutine/size-moved-locals.rs index 0f800de84544d..edca3cfd98f7e 100644 --- a/tests/ui/coroutine/size-moved-locals.rs +++ b/tests/ui/coroutine/size-moved-locals.rs @@ -28,7 +28,7 @@ fn move_before_yield() -> impl Coroutine { static || { let first = Foo([0; FOO_SIZE]); let _second = first; - yield; + ().yield; // _second dropped here } } @@ -41,7 +41,7 @@ fn move_before_yield_with_noop() -> impl Coroutine { let first = Foo([0; FOO_SIZE]); noop(); let _second = first; - yield; + ().yield; // _second dropped here } } @@ -52,11 +52,11 @@ fn overlap_move_points() -> impl Coroutine { #[coroutine] static || { let first = Foo([0; FOO_SIZE]); - yield; + ().yield; let second = first; - yield; + ().yield; let _third = second; - yield; + ().yield; } } @@ -64,10 +64,10 @@ fn overlap_x_and_y() -> impl Coroutine { #[coroutine] static || { let x = Foo([0; FOO_SIZE]); - yield; + ().yield; drop(x); let y = Foo([0; FOO_SIZE]); - yield; + ().yield; drop(y); } } diff --git a/tests/ui/coroutine/sized-yield.rs b/tests/ui/coroutine/sized-yield.rs index a4c91fafe6ca5..bf12b9bba5e8c 100644 --- a/tests/ui/coroutine/sized-yield.rs +++ b/tests/ui/coroutine/sized-yield.rs @@ -8,7 +8,7 @@ fn main() { let mut gen = #[coroutine] move || { //~^ ERROR the size for values of type - yield s[..]; + s[..].yield; }; Pin::new(&mut gen).resume(()); //~^ ERROR the size for values of type diff --git a/tests/ui/coroutine/sized-yield.stderr b/tests/ui/coroutine/sized-yield.stderr index 5d5dd6803c899..db86f06448dc3 100644 --- a/tests/ui/coroutine/sized-yield.stderr +++ b/tests/ui/coroutine/sized-yield.stderr @@ -3,7 +3,7 @@ error[E0277]: the size for values of type `str` cannot be known at compilation t | LL | / move || { LL | | -LL | | yield s[..]; +LL | | s[..].yield; LL | | }; | |_____^ doesn't have a size known at compile-time | diff --git a/tests/ui/coroutine/smoke-resume-args.rs b/tests/ui/coroutine/smoke-resume-args.rs index 209c481400189..738ff46ff8dee 100644 --- a/tests/ui/coroutine/smoke-resume-args.rs +++ b/tests/ui/coroutine/smoke-resume-args.rs @@ -52,32 +52,32 @@ fn main() { drain( &mut #[coroutine] |mut b| { while b != 0 { - b = yield (b + 1); + b = (b + 1).yield; } -1 }, vec![(1, Yielded(2)), (-45, Yielded(-44)), (500, Yielded(501)), (0, Complete(-1))], ); - expect_drops(2, || drain(&mut #[coroutine] |a| yield a, vec![(DropMe, Yielded(DropMe))])); + expect_drops(2, || drain(&mut #[coroutine] |a| a.yield, vec![(DropMe, Yielded(DropMe))])); expect_drops(6, || { drain( - &mut #[coroutine] |a| yield yield a, + &mut #[coroutine] |a| a.yield.yield, vec![(DropMe, Yielded(DropMe)), (DropMe, Yielded(DropMe)), (DropMe, Complete(DropMe))], ) }); #[allow(unreachable_code)] expect_drops(2, || drain( - &mut #[coroutine] |a| yield return a, + &mut #[coroutine] |a| (return a).yield, vec![(DropMe, Complete(DropMe))] )); expect_drops(2, || { drain( &mut #[coroutine] |a: DropMe| { - if false { yield () } else { a } + if false { ().yield } else { a } }, vec![(DropMe, Complete(DropMe))], ) @@ -87,9 +87,9 @@ fn main() { drain( #[allow(unused_assignments, unused_variables)] &mut #[coroutine] |mut a: DropMe| { - a = yield; - a = yield; - a = yield; + a = ().yield; + a = ().yield; + a = ().yield; }, vec![ (DropMe, Yielded(())), diff --git a/tests/ui/coroutine/smoke.rs b/tests/ui/coroutine/smoke.rs index bfb183fde9368..0e9884dd0bf30 100644 --- a/tests/ui/coroutine/smoke.rs +++ b/tests/ui/coroutine/smoke.rs @@ -16,7 +16,7 @@ use std::thread; fn simple() { let mut foo = #[coroutine] || { if false { - yield; + ().yield; } }; @@ -31,7 +31,7 @@ fn return_capture() { let a = String::from("foo"); let mut foo = #[coroutine] || { if false { - yield; + ().yield; } a }; @@ -45,7 +45,7 @@ fn return_capture() { #[test] fn simple_yield() { let mut foo = #[coroutine] || { - yield; + ().yield; }; match Pin::new(&mut foo).resume(()) { @@ -62,7 +62,7 @@ fn simple_yield() { fn yield_capture() { let b = String::from("foo"); let mut foo = #[coroutine] || { - yield b; + b.yield; }; match Pin::new(&mut foo).resume(()) { @@ -78,7 +78,7 @@ fn yield_capture() { #[test] fn simple_yield_value() { let mut foo = #[coroutine] || { - yield String::from("bar"); + String::from("bar").yield; return String::from("foo") }; @@ -96,7 +96,7 @@ fn simple_yield_value() { fn return_after_yield() { let a = String::from("foo"); let mut foo = #[coroutine] || { - yield; + ().yield; return a }; @@ -113,34 +113,34 @@ fn return_after_yield() { #[test] fn send_and_sync() { assert_send_sync(#[coroutine] || { - yield + ().yield }); assert_send_sync(#[coroutine] || { - yield String::from("foo"); + String::from("foo").yield; }); assert_send_sync(#[coroutine] || { - yield; + ().yield; return String::from("foo"); }); let a = 3; assert_send_sync(#[coroutine] || { - yield a; + a.yield; return }); let a = 3; assert_send_sync(#[coroutine] move || { - yield a; + a.yield; return }); let a = String::from("a"); assert_send_sync(#[coroutine] || { - yield ; + ().yield ; drop(a); return }); let a = String::from("a"); assert_send_sync(#[coroutine] move || { - yield ; + ().yield ; drop(a); return }); @@ -150,7 +150,7 @@ fn send_and_sync() { #[test] fn send_over_threads() { - let mut foo = #[coroutine] || { yield }; + let mut foo = #[coroutine] || { ().yield }; thread::spawn(move || { match Pin::new(&mut foo).resume(()) { CoroutineState::Yielded(()) => {} @@ -163,7 +163,7 @@ fn send_over_threads() { }).join().unwrap(); let a = String::from("a"); - let mut foo = #[coroutine] || { yield a }; + let mut foo = #[coroutine] || { a.yield }; thread::spawn(move || { match Pin::new(&mut foo).resume(()) { CoroutineState::Yielded(ref s) if *s == "a" => {} diff --git a/tests/ui/coroutine/static-coroutine.rs b/tests/ui/coroutine/static-coroutine.rs index eba6336d342fe..5225e7e1dfe9b 100644 --- a/tests/ui/coroutine/static-coroutine.rs +++ b/tests/ui/coroutine/static-coroutine.rs @@ -10,7 +10,7 @@ fn main() { static || { let a = true; let b = &a; - yield; + ().yield; assert_eq!(b as *const _, &a as *const _); }; // SAFETY: We shadow the original coroutine variable so have no safe API to diff --git a/tests/ui/coroutine/static-move-suggestion.fixed b/tests/ui/coroutine/static-move-suggestion.fixed index 56445be4715ff..225a165d8642a 100644 --- a/tests/ui/coroutine/static-move-suggestion.fixed +++ b/tests/ui/coroutine/static-move-suggestion.fixed @@ -9,7 +9,7 @@ fn check() -> impl Sized { #[coroutine] static move || { //~^ ERROR E0373 - yield; + ().yield; x } } diff --git a/tests/ui/coroutine/static-move-suggestion.rs b/tests/ui/coroutine/static-move-suggestion.rs index 1d6e4a6288311..9d0115babdd7d 100644 --- a/tests/ui/coroutine/static-move-suggestion.rs +++ b/tests/ui/coroutine/static-move-suggestion.rs @@ -9,7 +9,7 @@ fn check() -> impl Sized { #[coroutine] static || { //~^ ERROR E0373 - yield; + ().yield; x } } diff --git a/tests/ui/coroutine/static-move-suggestion.stderr b/tests/ui/coroutine/static-move-suggestion.stderr index 6d890468b322c..be3ecd61f4fd3 100644 --- a/tests/ui/coroutine/static-move-suggestion.stderr +++ b/tests/ui/coroutine/static-move-suggestion.stderr @@ -12,7 +12,7 @@ note: coroutine is returned here | LL | / static || { LL | | -LL | | yield; +LL | | ().yield; LL | | x LL | | } | |_____^ diff --git a/tests/ui/coroutine/static-mut-reference-across-yield.rs b/tests/ui/coroutine/static-mut-reference-across-yield.rs index d45d6e6428b9c..4b7c1beea09d6 100644 --- a/tests/ui/coroutine/static-mut-reference-across-yield.rs +++ b/tests/ui/coroutine/static-mut-reference-across-yield.rs @@ -13,14 +13,14 @@ fn main() { let gen_index = #[coroutine] static || { let u = A[{ - yield; + ().yield; 1 }]; }; let gen_match = #[coroutine] static || match A { i if { - yield; + ().yield; true } => { diff --git a/tests/ui/coroutine/static-not-unpin.rs b/tests/ui/coroutine/static-not-unpin.rs index 9be7eca63cbb1..733fd5a3ff42a 100644 --- a/tests/ui/coroutine/static-not-unpin.rs +++ b/tests/ui/coroutine/static-not-unpin.rs @@ -14,7 +14,7 @@ fn assert_unpin(_: T) {} fn main() { let mut coroutine = #[coroutine] static || { - yield; + ().yield; }; assert_unpin(coroutine); //~ ERROR E0277 } diff --git a/tests/ui/coroutine/static-reference-across-yield.rs b/tests/ui/coroutine/static-reference-across-yield.rs index e7ff658ebf643..beb5eec56ba82 100644 --- a/tests/ui/coroutine/static-reference-across-yield.rs +++ b/tests/ui/coroutine/static-reference-across-yield.rs @@ -5,11 +5,11 @@ static A: [i32; 5] = [1, 2, 3, 4, 5]; fn main() { #[coroutine] static || { - let u = A[{yield; 1}]; + let u = A[{().yield; 1}]; }; #[coroutine] static || { match A { - i if { yield; true } => (), + i if { ().yield; true } => (), _ => (), } }; diff --git a/tests/ui/coroutine/too-live-local-in-immovable-gen.rs b/tests/ui/coroutine/too-live-local-in-immovable-gen.rs index 1c689ef7cefc4..d74fc8ca19c67 100644 --- a/tests/ui/coroutine/too-live-local-in-immovable-gen.rs +++ b/tests/ui/coroutine/too-live-local-in-immovable-gen.rs @@ -12,7 +12,7 @@ fn main() { // The compiler will panic if the coroutine transformation finds that // `a` is live and type checking finds it dead. let a = { - yield (); + ().yield; 4i32 }; let _ = &a; diff --git a/tests/ui/coroutine/too-many-parameters.rs b/tests/ui/coroutine/too-many-parameters.rs index 3baaf0623479d..2df01fa9050e9 100644 --- a/tests/ui/coroutine/too-many-parameters.rs +++ b/tests/ui/coroutine/too-many-parameters.rs @@ -4,6 +4,6 @@ fn main() { #[coroutine] |(), ()| { //~^ error: too many parameters for a coroutine - yield; + ().yield; }; } diff --git a/tests/ui/coroutine/type-mismatch-error.rs b/tests/ui/coroutine/type-mismatch-error.rs index ee4e27c20da18..45169ee05b836 100644 --- a/tests/ui/coroutine/type-mismatch-error.rs +++ b/tests/ui/coroutine/type-mismatch-error.rs @@ -12,7 +12,7 @@ fn main() { #[coroutine] |a: u8| { if false { - yield (); + ().yield; } else { a //~^ error: `if` and `else` have incompatible types diff --git a/tests/ui/coroutine/type-mismatch-error.stderr b/tests/ui/coroutine/type-mismatch-error.stderr index f10c30e259072..b1ba66158a76d 100644 --- a/tests/ui/coroutine/type-mismatch-error.stderr +++ b/tests/ui/coroutine/type-mismatch-error.stderr @@ -2,7 +2,7 @@ error[E0308]: `if` and `else` have incompatible types --> $DIR/type-mismatch-error.rs:17:17 | LL | / if false { -LL | | yield (); +LL | | ().yield; | | --------- | | | | | | | help: consider removing this semicolon diff --git a/tests/ui/coroutine/type-mismatch-signature-deduction.rs b/tests/ui/coroutine/type-mismatch-signature-deduction.rs index 5b04b3efaaa46..2ca9c6e2f6a36 100644 --- a/tests/ui/coroutine/type-mismatch-signature-deduction.rs +++ b/tests/ui/coroutine/type-mismatch-signature-deduction.rs @@ -10,7 +10,7 @@ fn foo() -> impl Coroutine { return Ok(6); } - yield (); + ().yield; 5 //~ ERROR mismatched types [E0308] } diff --git a/tests/ui/coroutine/uninhabited-field.rs b/tests/ui/coroutine/uninhabited-field.rs index d6ada07ce0cbc..70eca62d4099e 100644 --- a/tests/ui/coroutine/uninhabited-field.rs +++ b/tests/ui/coroutine/uninhabited-field.rs @@ -19,13 +19,13 @@ fn run(x: bool, y: bool) { if y { a = conjure::(); } - yield (); + ().yield; } else { let a : T; if y { a = conjure::(); } - yield (); + ().yield; } }; assert_matches!(Pin::new(&mut c).resume(()), CoroutineState::Yielded(())); diff --git a/tests/ui/coroutine/unsized-capture-across-yield.rs b/tests/ui/coroutine/unsized-capture-across-yield.rs index ee27ea064ec23..4fac7b218e43c 100644 --- a/tests/ui/coroutine/unsized-capture-across-yield.rs +++ b/tests/ui/coroutine/unsized-capture-across-yield.rs @@ -9,7 +9,7 @@ fn capture() -> impl Coroutine { move || { println!("{:?}", &b); - yield; + ().yield; for elem in b.iter() {} } diff --git a/tests/ui/coroutine/unsized-local-across-yield.rs b/tests/ui/coroutine/unsized-local-across-yield.rs index 4c688e5b99790..4f942f5cd907b 100644 --- a/tests/ui/coroutine/unsized-local-across-yield.rs +++ b/tests/ui/coroutine/unsized-local-across-yield.rs @@ -9,7 +9,7 @@ fn across() -> impl Coroutine { let b: [u8] = *(Box::new([]) as Box<[u8]>); //~^ ERROR the size for values of type `[u8]` cannot be known at compilation time - yield; + ().yield; for elem in b.iter() {} } diff --git a/tests/ui/coroutine/yield-in-args-rev.rs b/tests/ui/coroutine/yield-in-args-rev.rs index 29d79df25fbab..f6edc97e3ab2c 100644 --- a/tests/ui/coroutine/yield-in-args-rev.rs +++ b/tests/ui/coroutine/yield-in-args-rev.rs @@ -12,7 +12,7 @@ fn foo(_a: (), _b: &bool) {} fn bar() { #[coroutine] || { //~ WARN unused coroutine that must be used let b = true; - foo(yield, &b); + foo(().yield, &b); }; } diff --git a/tests/ui/coroutine/yield-in-args-rev.stderr b/tests/ui/coroutine/yield-in-args-rev.stderr index d1650cee6cb01..36d52bcc2162a 100644 --- a/tests/ui/coroutine/yield-in-args-rev.stderr +++ b/tests/ui/coroutine/yield-in-args-rev.stderr @@ -4,7 +4,7 @@ warning: unused coroutine that must be used LL | #[coroutine] || { | __________________^ LL | | let b = true; -LL | | foo(yield, &b); +LL | | foo(().yield, &b); LL | | }; | |_____^ | diff --git a/tests/ui/coroutine/yield-in-args.rs b/tests/ui/coroutine/yield-in-args.rs index bc9909b310c3f..2ecf269e6bd04 100644 --- a/tests/ui/coroutine/yield-in-args.rs +++ b/tests/ui/coroutine/yield-in-args.rs @@ -6,6 +6,6 @@ fn main() { #[coroutine] || { let b = true; - foo(&b, yield); //~ ERROR + foo(&b, ().yield); //~ ERROR }; } diff --git a/tests/ui/coroutine/yield-in-args.stderr b/tests/ui/coroutine/yield-in-args.stderr index 1cc3c83deb3b8..c14b4c35daa9e 100644 --- a/tests/ui/coroutine/yield-in-args.stderr +++ b/tests/ui/coroutine/yield-in-args.stderr @@ -4,8 +4,8 @@ error[E0626]: borrow may still be in use when coroutine yields LL | || { | -- within this coroutine LL | let b = true; -LL | foo(&b, yield); - | ^^ ----- possible yield occurs here +LL | foo(&b, ().yield); + | ^^ -------- possible yield occurs here | help: add `static` to mark this coroutine as unmovable | diff --git a/tests/ui/coroutine/yield-in-const.rs b/tests/ui/coroutine/yield-in-const.rs index dc1b30155b9ff..68249700615e9 100644 --- a/tests/ui/coroutine/yield-in-const.rs +++ b/tests/ui/coroutine/yield-in-const.rs @@ -1,6 +1,6 @@ #![feature(coroutines)] -const A: u8 = { yield 3u8; 3u8}; +const A: u8 = { 3u8.yield; 3u8}; //~^ ERROR yield expression outside //~| ERROR `yield` can only be used in diff --git a/tests/ui/coroutine/yield-in-const.stderr b/tests/ui/coroutine/yield-in-const.stderr index f02729412ccd5..bdf64bff1e0c9 100644 --- a/tests/ui/coroutine/yield-in-const.stderr +++ b/tests/ui/coroutine/yield-in-const.stderr @@ -1,13 +1,13 @@ error: `yield` can only be used in `#[coroutine]` closures, or `gen` blocks --> $DIR/yield-in-const.rs:3:17 | -LL | const A: u8 = { yield 3u8; 3u8}; +LL | const A: u8 = { 3u8.yield; 3u8}; | ^^^^^^^^^ error[E0627]: yield expression outside of coroutine literal --> $DIR/yield-in-const.rs:3:17 | -LL | const A: u8 = { yield 3u8; 3u8}; +LL | const A: u8 = { 3u8.yield; 3u8}; | ^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/coroutine/yield-in-function.rs b/tests/ui/coroutine/yield-in-function.rs index 427c5d0e7f5e5..80b89ff6c7633 100644 --- a/tests/ui/coroutine/yield-in-function.rs +++ b/tests/ui/coroutine/yield-in-function.rs @@ -1,5 +1,5 @@ #![feature(coroutines)] -fn main() { yield; } +fn main() { ().yield; } //~^ ERROR yield expression outside //~| ERROR `yield` can only be used in diff --git a/tests/ui/coroutine/yield-in-function.stderr b/tests/ui/coroutine/yield-in-function.stderr index dbebf310b04ff..5889f8e1c2cf3 100644 --- a/tests/ui/coroutine/yield-in-function.stderr +++ b/tests/ui/coroutine/yield-in-function.stderr @@ -1,19 +1,19 @@ error: `yield` can only be used in `#[coroutine]` closures, or `gen` blocks --> $DIR/yield-in-function.rs:3:13 | -LL | fn main() { yield; } - | ^^^^^ +LL | fn main() { ().yield; } + | ^^^^^^^^ | help: use `#[coroutine]` to make this closure a coroutine | -LL | #[coroutine] fn main() { yield; } +LL | #[coroutine] fn main() { ().yield; } | ++++++++++++ error[E0627]: yield expression outside of coroutine literal --> $DIR/yield-in-function.rs:3:13 | -LL | fn main() { yield; } - | ^^^^^ +LL | fn main() { ().yield; } + | ^^^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/coroutine/yield-in-initializer.rs b/tests/ui/coroutine/yield-in-initializer.rs index 3caefac013ef2..3fec15135411c 100644 --- a/tests/ui/coroutine/yield-in-initializer.rs +++ b/tests/ui/coroutine/yield-in-initializer.rs @@ -8,7 +8,7 @@ fn main() { // Test that `opt` is not live across the yield, even when borrowed in a loop // See https://github.com/rust-lang/rust/issues/52792 let opt = { - yield; + ().yield; true }; let _ = &opt; diff --git a/tests/ui/coroutine/yield-in-static.rs b/tests/ui/coroutine/yield-in-static.rs index 99d08913e64ce..79db0737cd673 100644 --- a/tests/ui/coroutine/yield-in-static.rs +++ b/tests/ui/coroutine/yield-in-static.rs @@ -1,6 +1,6 @@ #![feature(coroutines)] -static B: u8 = { yield 3u8; 3u8}; +static B: u8 = { 3u8.yield; 3u8}; //~^ ERROR yield expression outside //~| ERROR `yield` can only be used in diff --git a/tests/ui/coroutine/yield-in-static.stderr b/tests/ui/coroutine/yield-in-static.stderr index d1fd4eab0fc3c..92d29f11c19fe 100644 --- a/tests/ui/coroutine/yield-in-static.stderr +++ b/tests/ui/coroutine/yield-in-static.stderr @@ -1,13 +1,13 @@ error: `yield` can only be used in `#[coroutine]` closures, or `gen` blocks --> $DIR/yield-in-static.rs:3:18 | -LL | static B: u8 = { yield 3u8; 3u8}; +LL | static B: u8 = { 3u8.yield; 3u8}; | ^^^^^^^^^ error[E0627]: yield expression outside of coroutine literal --> $DIR/yield-in-static.rs:3:18 | -LL | static B: u8 = { yield 3u8; 3u8}; +LL | static B: u8 = { 3u8.yield; 3u8}; | ^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/coroutine/yield-outside-coroutine-issue-78653.rs b/tests/ui/coroutine/yield-outside-coroutine-issue-78653.rs index 6833bc9901212..707e2ae0f3f42 100644 --- a/tests/ui/coroutine/yield-outside-coroutine-issue-78653.rs +++ b/tests/ui/coroutine/yield-outside-coroutine-issue-78653.rs @@ -1,7 +1,7 @@ #![feature(coroutines)] fn main() { - yield || for i in 0 { } + (|| for i in 0 { }).yield //~^ ERROR yield expression outside of coroutine literal //~| ERROR `{integer}` is not an iterator //~| ERROR `yield` can only be used in diff --git a/tests/ui/coroutine/yield-outside-coroutine-issue-78653.stderr b/tests/ui/coroutine/yield-outside-coroutine-issue-78653.stderr index b288e581d88b6..e699c54119df1 100644 --- a/tests/ui/coroutine/yield-outside-coroutine-issue-78653.stderr +++ b/tests/ui/coroutine/yield-outside-coroutine-issue-78653.stderr @@ -1,8 +1,8 @@ error: `yield` can only be used in `#[coroutine]` closures, or `gen` blocks --> $DIR/yield-outside-coroutine-issue-78653.rs:4:5 | -LL | yield || for i in 0 { } - | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | (|| for i in 0 { }).yield + | ^^^^^^^^^^^^^^^^^^^^^^^^^ | help: use `#[coroutine]` to make this closure a coroutine | @@ -12,14 +12,14 @@ LL | #[coroutine] fn main() { error[E0627]: yield expression outside of coroutine literal --> $DIR/yield-outside-coroutine-issue-78653.rs:4:5 | -LL | yield || for i in 0 { } - | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | (|| for i in 0 { }).yield + | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: `{integer}` is not an iterator - --> $DIR/yield-outside-coroutine-issue-78653.rs:4:23 + --> $DIR/yield-outside-coroutine-issue-78653.rs:4:18 | -LL | yield || for i in 0 { } - | ^ `{integer}` is not an iterator +LL | (|| for i in 0 { }).yield + | ^ `{integer}` is not an iterator | = help: the trait `Iterator` is not implemented for `{integer}` = note: if you want to iterate between `start` until a value `end`, use the exclusive range syntax `start..end` or the inclusive range syntax `start..=end` diff --git a/tests/ui/coroutine/yield-subtype.rs b/tests/ui/coroutine/yield-subtype.rs index adee5075e8324..7bc726ad47b63 100644 --- a/tests/ui/coroutine/yield-subtype.rs +++ b/tests/ui/coroutine/yield-subtype.rs @@ -9,8 +9,8 @@ fn bar<'a>() { let b: &'a str = a; #[coroutine] || { //~ WARN unused coroutine that must be used - yield a; - yield b; + a.yield; + b.yield; }; } diff --git a/tests/ui/coroutine/yield-subtype.stderr b/tests/ui/coroutine/yield-subtype.stderr index b2bf219822bc7..522eb1eb8e60b 100644 --- a/tests/ui/coroutine/yield-subtype.stderr +++ b/tests/ui/coroutine/yield-subtype.stderr @@ -3,8 +3,8 @@ warning: unused coroutine that must be used | LL | #[coroutine] || { | __________________^ -LL | | yield a; -LL | | yield b; +LL | | a.yield; +LL | | b.yield; LL | | }; | |_____^ | diff --git a/tests/ui/coroutine/yield-while-iterating.rs b/tests/ui/coroutine/yield-while-iterating.rs index 77f601e4f2c5b..dbd6821765b8c 100644 --- a/tests/ui/coroutine/yield-while-iterating.rs +++ b/tests/ui/coroutine/yield-while-iterating.rs @@ -11,7 +11,7 @@ fn yield_during_iter_owned_data(x: Vec) { // reference in scope, and it doesn't live long enough. let _b =#[coroutine] move || { for p in &x { //~ ERROR - yield(); + ().yield; } }; } @@ -19,7 +19,7 @@ fn yield_during_iter_owned_data(x: Vec) { fn yield_during_iter_borrowed_slice(x: &[i32]) { let _b = #[coroutine] move || { for p in x { - yield(); + ().yield; } }; } @@ -28,7 +28,7 @@ fn yield_during_iter_borrowed_slice_2() { let mut x = vec![22_i32]; let _b = #[coroutine] || { for p in &x { - yield(); + ().yield; } }; println!("{:?}", x); @@ -40,7 +40,7 @@ fn yield_during_iter_borrowed_slice_3() { let mut x = vec![22_i32]; let mut b = #[coroutine] || { for p in &mut x { - yield p; + p.yield; } }; Pin::new(&mut b).resume(()); @@ -52,7 +52,7 @@ fn yield_during_iter_borrowed_slice_4() { let mut x = vec![22_i32]; let mut b = #[coroutine] || { for p in &mut x { - yield p; + p.yield; } }; println!("{}", x[0]); //~ ERROR @@ -66,7 +66,7 @@ fn yield_during_range_iter() { let len = v.len(); for i in 0..len { let x = v[i]; - yield x; + x.yield; } }; Pin::new(&mut b).resume(()); diff --git a/tests/ui/coroutine/yield-while-iterating.stderr b/tests/ui/coroutine/yield-while-iterating.stderr index a92237e44c16b..3ff8229461f1c 100644 --- a/tests/ui/coroutine/yield-while-iterating.stderr +++ b/tests/ui/coroutine/yield-while-iterating.stderr @@ -5,8 +5,8 @@ LL | let _b =#[coroutine] move || { | ------- within this coroutine LL | for p in &x { | ^^ -LL | yield(); - | ------- possible yield occurs here +LL | ().yield; + | -------- possible yield occurs here | help: add `static` to mark this coroutine as unmovable | diff --git a/tests/ui/coroutine/yield-while-local-borrowed.rs b/tests/ui/coroutine/yield-while-local-borrowed.rs index 3db30c36712f0..c02449957842f 100644 --- a/tests/ui/coroutine/yield-while-local-borrowed.rs +++ b/tests/ui/coroutine/yield-while-local-borrowed.rs @@ -12,7 +12,7 @@ fn borrow_local_inline() { let mut b = #[coroutine] move || { let a = &mut 3; //~^ ERROR borrow may still be in use when coroutine 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,7 +39,7 @@ fn borrow_local() { { let b = &a; //~^ ERROR borrow may still be in use when coroutine yields - yield (); + ().yield; println!("{}", b); } }; diff --git a/tests/ui/coroutine/yield-while-local-borrowed.stderr b/tests/ui/coroutine/yield-while-local-borrowed.stderr index b42ca3ba46106..9589de96a8462 100644 --- a/tests/ui/coroutine/yield-while-local-borrowed.stderr +++ b/tests/ui/coroutine/yield-while-local-borrowed.stderr @@ -6,7 +6,7 @@ LL | let mut b = #[coroutine] move || { LL | let a = &mut 3; | ^^^^^^ LL | -LL | yield (); +LL | ().yield; | -------- possible yield occurs here | help: add `static` to mark this coroutine as unmovable @@ -23,7 +23,7 @@ LL | let mut b = #[coroutine] move || { LL | let b = &a; | ^^ LL | -LL | yield (); +LL | ().yield; | -------- possible yield occurs here | help: add `static` to mark this coroutine as unmovable diff --git a/tests/ui/coroutine/yield-while-ref-reborrowed.rs b/tests/ui/coroutine/yield-while-ref-reborrowed.rs index 2600d0b4124b1..410fecc297c54 100644 --- a/tests/ui/coroutine/yield-while-ref-reborrowed.rs +++ b/tests/ui/coroutine/yield-while-ref-reborrowed.rs @@ -10,7 +10,7 @@ fn reborrow_shared_ref(x: &i32) { let mut b = #[coroutine] move || { let a = &*x; - yield (); + ().yield; println!("{}", a); }; Pin::new(&mut b).resume(()); @@ -22,7 +22,7 @@ fn reborrow_mutable_ref(x: &mut i32) { let mut b = #[coroutine] move || { let a = &mut *x; - yield (); + ().yield; println!("{}", a); }; Pin::new(&mut b).resume(()); @@ -33,7 +33,7 @@ fn reborrow_mutable_ref_2(x: &mut i32) { let mut b = #[coroutine] || { let a = &mut *x; - yield (); + ().yield; println!("{}", a); }; println!("{}", x); //~ ERROR diff --git a/tests/ui/drop/dynamic-drop.rs b/tests/ui/drop/dynamic-drop.rs index 1bd75e1852c4a..97194695be425 100644 --- a/tests/ui/drop/dynamic-drop.rs +++ b/tests/ui/drop/dynamic-drop.rs @@ -179,9 +179,9 @@ fn coroutine(a: &Allocator, run_count: usize) { let mut gen = #[coroutine] || { (a.alloc(), - yield a.alloc(), + a.alloc().yield, a.alloc(), - yield a.alloc() + a.alloc().yield ); }; for _ in 0..run_count { diff --git a/tests/ui/expr/weird-exprs.rs b/tests/ui/expr/weird-exprs.rs index 7db92d4606713..c88f516577fb4 100644 --- a/tests/ui/expr/weird-exprs.rs +++ b/tests/ui/expr/weird-exprs.rs @@ -154,7 +154,7 @@ fn r#match() { fn i_yield() { #[coroutine] static || { - yield yield yield yield yield yield yield yield yield; + ().yield.yield.yield.yield.yield.yield.yield.yield.yield; }; } diff --git a/tests/ui/feature-gates/feature-gate-closure_track_caller.rs b/tests/ui/feature-gates/feature-gate-closure_track_caller.rs index d7cfc13cae559..86a1be0a63bd9 100644 --- a/tests/ui/feature-gates/feature-gate-closure_track_caller.rs +++ b/tests/ui/feature-gates/feature-gate-closure_track_caller.rs @@ -4,6 +4,6 @@ fn main() { let _closure = #[track_caller] || {}; //~ ERROR `#[track_caller]` on closures - let _coroutine = #[coroutine] #[track_caller] || { yield; }; //~ ERROR `#[track_caller]` on closures + let _coroutine = #[coroutine] #[track_caller] || { ().yield; }; //~ ERROR `#[track_caller]` on closures let _future = #[track_caller] async {}; //~ ERROR `#[track_caller]` on closures } diff --git a/tests/ui/feature-gates/feature-gate-closure_track_caller.stderr b/tests/ui/feature-gates/feature-gate-closure_track_caller.stderr index 0b12b73fd1fff..656900aff90f1 100644 --- a/tests/ui/feature-gates/feature-gate-closure_track_caller.stderr +++ b/tests/ui/feature-gates/feature-gate-closure_track_caller.stderr @@ -11,7 +11,7 @@ LL | let _closure = #[track_caller] || {}; error[E0658]: `#[track_caller]` on closures is currently unstable --> $DIR/feature-gate-closure_track_caller.rs:7:35 | -LL | let _coroutine = #[coroutine] #[track_caller] || { yield; }; +LL | let _coroutine = #[coroutine] #[track_caller] || { ().yield; }; | ^^^^^^^^^^^^^^^ | = note: see issue #87417 for more information diff --git a/tests/ui/feature-gates/feature-gate-coroutines.e2024.stderr b/tests/ui/feature-gates/feature-gate-coroutines.e2024.stderr index c29c328ac143e..9e379b57c42c9 100644 --- a/tests/ui/feature-gates/feature-gate-coroutines.e2024.stderr +++ b/tests/ui/feature-gates/feature-gate-coroutines.e2024.stderr @@ -1,38 +1,38 @@ error[E0658]: yield syntax is experimental - --> $DIR/feature-gate-coroutines.rs:5:5 + --> $DIR/feature-gate-coroutines.rs:5:10 | -LL | yield true; - | ^^^^^^^^^^ +LL | true.yield; + | ^^^^^ | = note: see issue #43122 for more information = help: add `#![feature(yield_expr)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: yield syntax is experimental - --> $DIR/feature-gate-coroutines.rs:10:16 + --> $DIR/feature-gate-coroutines.rs:10:21 | -LL | let _ = || yield true; - | ^^^^^^^^^^ +LL | let _ = || true.yield; + | ^^^^^ | = note: see issue #43122 for more information = help: add `#![feature(yield_expr)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: yield syntax is experimental - --> $DIR/feature-gate-coroutines.rs:18:5 + --> $DIR/feature-gate-coroutines.rs:18:8 | -LL | yield; - | ^^^^^ +LL | ().yield; + | ^^^^^ | = note: see issue #43122 for more information = help: add `#![feature(yield_expr)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: yield syntax is experimental - --> $DIR/feature-gate-coroutines.rs:19:5 + --> $DIR/feature-gate-coroutines.rs:19:7 | -LL | yield 0; - | ^^^^^^^ +LL | 0.yield; + | ^^^^^ | = note: see issue #43122 for more information = help: add `#![feature(yield_expr)]` to the crate attributes to enable @@ -41,7 +41,7 @@ LL | yield 0; error[E0658]: yield syntax is experimental --> $DIR/feature-gate-coroutines.rs:5:5 | -LL | yield true; +LL | true.yield; | ^^^^^^^^^^ | = note: see issue #43122 for more information @@ -51,7 +51,7 @@ LL | yield true; error: `yield` can only be used in `#[coroutine]` closures, or `gen` blocks --> $DIR/feature-gate-coroutines.rs:5:5 | -LL | yield true; +LL | true.yield; | ^^^^^^^^^^ | help: use `#[coroutine]` to make this closure a coroutine @@ -62,7 +62,7 @@ LL | #[coroutine] fn main() { error[E0658]: yield syntax is experimental --> $DIR/feature-gate-coroutines.rs:10:16 | -LL | let _ = || yield true; +LL | let _ = || true.yield; | ^^^^^^^^^^ | = note: see issue #43122 for more information @@ -72,18 +72,18 @@ LL | let _ = || yield true; error: `yield` can only be used in `#[coroutine]` closures, or `gen` blocks --> $DIR/feature-gate-coroutines.rs:10:16 | -LL | let _ = || yield true; +LL | let _ = || true.yield; | ^^^^^^^^^^ | help: use `#[coroutine]` to make this closure a coroutine | -LL | let _ = #[coroutine] || yield true; +LL | let _ = #[coroutine] || true.yield; | ++++++++++++ error[E0627]: yield expression outside of coroutine literal --> $DIR/feature-gate-coroutines.rs:5:5 | -LL | yield true; +LL | true.yield; | ^^^^^^^^^^ error: aborting due to 9 previous errors diff --git a/tests/ui/feature-gates/feature-gate-coroutines.none.stderr b/tests/ui/feature-gates/feature-gate-coroutines.none.stderr index c29c328ac143e..9e379b57c42c9 100644 --- a/tests/ui/feature-gates/feature-gate-coroutines.none.stderr +++ b/tests/ui/feature-gates/feature-gate-coroutines.none.stderr @@ -1,38 +1,38 @@ error[E0658]: yield syntax is experimental - --> $DIR/feature-gate-coroutines.rs:5:5 + --> $DIR/feature-gate-coroutines.rs:5:10 | -LL | yield true; - | ^^^^^^^^^^ +LL | true.yield; + | ^^^^^ | = note: see issue #43122 for more information = help: add `#![feature(yield_expr)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: yield syntax is experimental - --> $DIR/feature-gate-coroutines.rs:10:16 + --> $DIR/feature-gate-coroutines.rs:10:21 | -LL | let _ = || yield true; - | ^^^^^^^^^^ +LL | let _ = || true.yield; + | ^^^^^ | = note: see issue #43122 for more information = help: add `#![feature(yield_expr)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: yield syntax is experimental - --> $DIR/feature-gate-coroutines.rs:18:5 + --> $DIR/feature-gate-coroutines.rs:18:8 | -LL | yield; - | ^^^^^ +LL | ().yield; + | ^^^^^ | = note: see issue #43122 for more information = help: add `#![feature(yield_expr)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: yield syntax is experimental - --> $DIR/feature-gate-coroutines.rs:19:5 + --> $DIR/feature-gate-coroutines.rs:19:7 | -LL | yield 0; - | ^^^^^^^ +LL | 0.yield; + | ^^^^^ | = note: see issue #43122 for more information = help: add `#![feature(yield_expr)]` to the crate attributes to enable @@ -41,7 +41,7 @@ LL | yield 0; error[E0658]: yield syntax is experimental --> $DIR/feature-gate-coroutines.rs:5:5 | -LL | yield true; +LL | true.yield; | ^^^^^^^^^^ | = note: see issue #43122 for more information @@ -51,7 +51,7 @@ LL | yield true; error: `yield` can only be used in `#[coroutine]` closures, or `gen` blocks --> $DIR/feature-gate-coroutines.rs:5:5 | -LL | yield true; +LL | true.yield; | ^^^^^^^^^^ | help: use `#[coroutine]` to make this closure a coroutine @@ -62,7 +62,7 @@ LL | #[coroutine] fn main() { error[E0658]: yield syntax is experimental --> $DIR/feature-gate-coroutines.rs:10:16 | -LL | let _ = || yield true; +LL | let _ = || true.yield; | ^^^^^^^^^^ | = note: see issue #43122 for more information @@ -72,18 +72,18 @@ LL | let _ = || yield true; error: `yield` can only be used in `#[coroutine]` closures, or `gen` blocks --> $DIR/feature-gate-coroutines.rs:10:16 | -LL | let _ = || yield true; +LL | let _ = || true.yield; | ^^^^^^^^^^ | help: use `#[coroutine]` to make this closure a coroutine | -LL | let _ = #[coroutine] || yield true; +LL | let _ = #[coroutine] || true.yield; | ++++++++++++ error[E0627]: yield expression outside of coroutine literal --> $DIR/feature-gate-coroutines.rs:5:5 | -LL | yield true; +LL | true.yield; | ^^^^^^^^^^ error: aborting due to 9 previous errors diff --git a/tests/ui/feature-gates/feature-gate-coroutines.rs b/tests/ui/feature-gates/feature-gate-coroutines.rs index b37a61d9105f1..bff3c7cac2622 100644 --- a/tests/ui/feature-gates/feature-gate-coroutines.rs +++ b/tests/ui/feature-gates/feature-gate-coroutines.rs @@ -2,12 +2,12 @@ //@[e2024] edition: 2024 fn main() { - yield true; //~ ERROR yield syntax is experimental + true.yield; //~ ERROR yield syntax is experimental //~^ ERROR yield expression outside of coroutine literal //~^^ ERROR yield syntax is experimental //~^^^ ERROR `yield` can only be used - let _ = || yield true; //~ ERROR yield syntax is experimental + let _ = || true.yield; //~ ERROR yield syntax is experimental //~^ ERROR yield syntax is experimental //~^^ ERROR `yield` can only be used } @@ -15,6 +15,6 @@ fn main() { #[cfg(false)] fn foo() { // Ok in 2024 edition - yield; //~ ERROR yield syntax is experimental - yield 0; //~ ERROR yield syntax is experimental + ().yield; //~ ERROR yield syntax is experimental + 0.yield; //~ ERROR yield syntax is experimental } diff --git a/tests/ui/feature-gates/feature-gate-yield-expr.rs b/tests/ui/feature-gates/feature-gate-yield-expr.rs index 382bf89069e7e..77cd524fd97d0 100644 --- a/tests/ui/feature-gates/feature-gate-yield-expr.rs +++ b/tests/ui/feature-gates/feature-gate-yield-expr.rs @@ -2,7 +2,7 @@ #![feature(stmt_expr_attributes)] fn main() { - yield (); //~ ERROR yield syntax is experimental + ().yield; //~ ERROR yield syntax is experimental //~^ ERROR yield syntax is experimental //~^^ ERROR `yield` can only be used in `#[coroutine]` closures, or `gen` blocks //~^^^ ERROR yield expression outside of coroutine literal diff --git a/tests/ui/feature-gates/feature-gate-yield-expr.stderr b/tests/ui/feature-gates/feature-gate-yield-expr.stderr index bfac9e498037d..1cadd6bd00560 100644 --- a/tests/ui/feature-gates/feature-gate-yield-expr.stderr +++ b/tests/ui/feature-gates/feature-gate-yield-expr.stderr @@ -1,8 +1,8 @@ error[E0658]: yield syntax is experimental - --> $DIR/feature-gate-yield-expr.rs:5:5 + --> $DIR/feature-gate-yield-expr.rs:5:8 | -LL | yield (); - | ^^^^^^^^ +LL | ().yield; + | ^^^^^ | = note: see issue #43122 for more information = help: add `#![feature(yield_expr)]` to the crate attributes to enable @@ -11,7 +11,7 @@ LL | yield (); error[E0658]: yield syntax is experimental --> $DIR/feature-gate-yield-expr.rs:5:5 | -LL | yield (); +LL | ().yield; | ^^^^^^^^ | = note: see issue #43122 for more information @@ -21,7 +21,7 @@ LL | yield (); error: `yield` can only be used in `#[coroutine]` closures, or `gen` blocks --> $DIR/feature-gate-yield-expr.rs:5:5 | -LL | yield (); +LL | ().yield; | ^^^^^^^^ | help: use `#[coroutine]` to make this closure a coroutine @@ -32,7 +32,7 @@ LL | #[coroutine] fn main() { error[E0627]: yield expression outside of coroutine literal --> $DIR/feature-gate-yield-expr.rs:5:5 | -LL | yield (); +LL | ().yield; | ^^^^^^^^ error: aborting due to 4 previous errors diff --git a/tests/ui/impl-trait/issues/issue-58504.rs b/tests/ui/impl-trait/issues/issue-58504.rs index 57119671680ed..b2ce588986edc 100644 --- a/tests/ui/impl-trait/issues/issue-58504.rs +++ b/tests/ui/impl-trait/issues/issue-58504.rs @@ -3,7 +3,7 @@ use std::ops::Coroutine; fn mk_gen() -> impl Coroutine { - #[coroutine] || { loop { yield; } } + #[coroutine] || { loop { ().yield; } } } fn main() { diff --git a/tests/ui/impl-trait/lifetimes.rs b/tests/ui/impl-trait/lifetimes.rs index df64b685eab85..54f05c6ba48e6 100644 --- a/tests/ui/impl-trait/lifetimes.rs +++ b/tests/ui/impl-trait/lifetimes.rs @@ -115,7 +115,7 @@ impl<'unnecessary_lifetime> MyVec { } fn coroutine_doesnt_capture_unnecessary_lifetime<'s: 's>() -> impl Sized { - #[coroutine] || yield + #[coroutine] || ().yield } } diff --git a/tests/ui/impl-trait/recursive-coroutine-boxed.rs b/tests/ui/impl-trait/recursive-coroutine-boxed.rs index 932023d103dc4..e8f65ea90ba66 100644 --- a/tests/ui/impl-trait/recursive-coroutine-boxed.rs +++ b/tests/ui/impl-trait/recursive-coroutine-boxed.rs @@ -11,7 +11,7 @@ fn foo() -> impl Coroutine { let mut gen = Box::pin(foo()); let mut r = gen.as_mut().resume(()); while let CoroutineState::Yielded(v) = r { - yield v; + v.yield; r = gen.as_mut().resume(()); } } diff --git a/tests/ui/impl-trait/recursive-coroutine-indirect.rs b/tests/ui/impl-trait/recursive-coroutine-indirect.rs index f0727ad374270..29dd9c905837d 100644 --- a/tests/ui/impl-trait/recursive-coroutine-indirect.rs +++ b/tests/ui/impl-trait/recursive-coroutine-indirect.rs @@ -7,7 +7,7 @@ fn coroutine_hold() -> impl Sized { #[coroutine] move || { //~ ERROR recursion in a coroutine requires boxing let x = coroutine_hold(); - yield; + ().yield; x; } } diff --git a/tests/ui/impl-trait/recursive-impl-trait-type-indirect.rs b/tests/ui/impl-trait/recursive-impl-trait-type-indirect.rs index 8b9dac0e29b0b..830594c4798a6 100644 --- a/tests/ui/impl-trait/recursive-impl-trait-type-indirect.rs +++ b/tests/ui/impl-trait/recursive-impl-trait-type-indirect.rs @@ -60,7 +60,7 @@ fn coroutine_capture() -> impl Sized { #[coroutine] move || { - yield; + ().yield; x; } } diff --git a/tests/ui/iterators/generator.rs b/tests/ui/iterators/generator.rs index e633efb11c1da..bc3c9e6ebd1d3 100644 --- a/tests/ui/iterators/generator.rs +++ b/tests/ui/iterators/generator.rs @@ -6,9 +6,9 @@ use std::iter::iter; fn main() { let i = iter! { || { - yield 0; + 0.yield; for x in 5..10 { - yield x * 2; + (x * 2).yield; } } }; let mut i = i(); diff --git a/tests/ui/iterators/generator_args.rs b/tests/ui/iterators/generator_args.rs index c9da9e5fba609..828b5f21dad3f 100644 --- a/tests/ui/iterators/generator_args.rs +++ b/tests/ui/iterators/generator_args.rs @@ -6,9 +6,9 @@ use std::iter::iter; fn main() { let i = iter! {|foo| { - yield foo; + foo.yield; for x in 5..10 { - yield x * 2; + (x * 2).yield; } }}; let mut i = i(3); diff --git a/tests/ui/iterators/generator_capture.rs b/tests/ui/iterators/generator_capture.rs index c790b7a4b968e..1a83dccbc1915 100644 --- a/tests/ui/iterators/generator_capture.rs +++ b/tests/ui/iterators/generator_capture.rs @@ -8,9 +8,9 @@ fn main() { let i = { let s = String::new(); iter! { move || { - yield s.len(); + s.len().yield; for x in 5..10 { - yield x * 2; + (x * 2).yield; } }} }; diff --git a/tests/ui/iterators/generator_capture_.rs b/tests/ui/iterators/generator_capture_.rs index f630bc64b974c..2d223e5abdcad 100644 --- a/tests/ui/iterators/generator_capture_.rs +++ b/tests/ui/iterators/generator_capture_.rs @@ -9,7 +9,7 @@ fn main() { let s = "foo".to_string(); iter! { move || { for c in s.chars() { - yield c; + c.yield; } }} }; diff --git a/tests/ui/iterators/generator_capture_fail.rs b/tests/ui/iterators/generator_capture_fail.rs index d987b2df01164..d61371ed97037 100644 --- a/tests/ui/iterators/generator_capture_fail.rs +++ b/tests/ui/iterators/generator_capture_fail.rs @@ -6,9 +6,9 @@ fn main() { let i = { let s = String::new(); iter! { || { //~ ERROR `s` does not live long enough - yield s.len(); + s.len().yield; for x in 5..10 { - yield x * 2; + (x * 2).yield; } } } }; diff --git a/tests/ui/iterators/generator_capture_fail.stderr b/tests/ui/iterators/generator_capture_fail.stderr index 225a385d6a0fa..ecd3e8b7490d1 100644 --- a/tests/ui/iterators/generator_capture_fail.stderr +++ b/tests/ui/iterators/generator_capture_fail.stderr @@ -6,9 +6,9 @@ LL | let i = { LL | let s = String::new(); LL | iter! { || { | _________________^ -LL | | yield s.len(); +LL | | s.len().yield; LL | | for x in 5..10 { -LL | | yield x * 2; +LL | | (x * 2).yield; LL | | } LL | | } } | |_________^ borrowed value does not live long enough diff --git a/tests/ui/iterators/generator_capture_fnonce.rs b/tests/ui/iterators/generator_capture_fnonce.rs index 090727eb9b7e4..60e4f558ee128 100644 --- a/tests/ui/iterators/generator_capture_fnonce.rs +++ b/tests/ui/iterators/generator_capture_fnonce.rs @@ -8,9 +8,9 @@ fn main() { let i = { let s = String::new(); iter! { move || { - yield s.len(); + s.len().yield; for x in 5..10 { - yield x * 2; + (x * 2).yield; } }} }; diff --git a/tests/ui/iterators/generator_capture_no_lend.rs b/tests/ui/iterators/generator_capture_no_lend.rs index 822db58d48df2..ce437cccf8c74 100644 --- a/tests/ui/iterators/generator_capture_no_lend.rs +++ b/tests/ui/iterators/generator_capture_no_lend.rs @@ -11,7 +11,7 @@ fn main() { let s = "foo".to_string(); let f = iter! { || { for c in s.chars() { - yield c; + c.yield; } }}; diff --git a/tests/ui/iterators/generator_returned_from_fn.rs b/tests/ui/iterators/generator_returned_from_fn.rs index bd0317b1ffb7f..f59702a23135d 100644 --- a/tests/ui/iterators/generator_returned_from_fn.rs +++ b/tests/ui/iterators/generator_returned_from_fn.rs @@ -4,36 +4,36 @@ use std::iter::iter; fn plain() -> impl Fn() -> impl Iterator { iter! { || { - yield 0; + 0.yield; for x in 5..10 { - yield x * 2; + (x * 2).yield; } } } } fn arg() -> impl Fn(u32) -> impl Iterator { iter! { |arg| { - yield arg; + arg.yield; for x in 5..10 { - yield x * 2; + (x * 2).yield; } } } } fn capture<'a>(a: &'a u32) -> impl Fn() -> (impl Iterator + 'a) { iter! { || { //~ ERROR cannot return reference to function parameter `a` - yield *a; + (*a).yield; for x in 5..10 { - yield x * 2; + (x * 2).yield; } } } } fn capture_move(a: &u32) -> impl Fn() -> impl Iterator { iter! { move || { //~ ERROR does not implement `Fn` because it captures - yield *a; + (*a).yield; for x in 5..10 { - yield x * 2; + (x * 2).yield; } } } } @@ -42,9 +42,9 @@ fn capture_move_once(a: &u32) -> impl FnOnce() -> impl Iterator { iter! { move || { //~^ ERROR captures lifetime //~| ERROR: captures lifetime - yield *a; + (*a).yield; for x in 5..10 { - yield x * 2; + (x * 2).yield; } } } } @@ -53,9 +53,9 @@ fn capture_move_once_lifetimes<'a>( a: &'a u32, ) -> impl FnOnce() -> (impl Iterator + 'a) { iter! { move || { - yield *a; + (*a).yield; for x in 5..10 { - yield x * 2; + (x * 2).yield; } } } } diff --git a/tests/ui/iterators/generator_returned_from_fn.stderr b/tests/ui/iterators/generator_returned_from_fn.stderr index b2324af6d5e40..d5b38445c6b1e 100644 --- a/tests/ui/iterators/generator_returned_from_fn.stderr +++ b/tests/ui/iterators/generator_returned_from_fn.stderr @@ -3,9 +3,9 @@ error[E0515]: cannot return reference to function parameter `a` | LL | iter! { || { | _____________^ -LL | | yield *a; +LL | | (*a).yield; LL | | for x in 5..10 { -LL | | yield x * 2; +LL | | (x * 2).yield; LL | | } LL | | } } | |_____^ returns a reference to data owned by the current function @@ -15,9 +15,9 @@ error: gen closure does not implement `Fn` because it captures state from its en | LL | iter! { move || { | _____________-^^^^^^ -LL | | yield *a; +LL | | (*a).yield; LL | | for x in 5..10 { -LL | | yield x * 2; +LL | | (x * 2).yield; LL | | } LL | | } } | |_____- return type was inferred to be `{gen closure@$DIR/generator_returned_from_fn.rs:33:13: 33:20}` here @@ -33,7 +33,7 @@ LL | iter! { move || { | _____________^ LL | | LL | | -LL | | yield *a; +LL | | (*a).yield; ... | LL | | } } | |_____^ @@ -54,7 +54,7 @@ LL | iter! { move || { | _____________^ LL | | LL | | -LL | | yield *a; +LL | | (*a).yield; ... | LL | | } } | |_____^ diff --git a/tests/ui/iterators/iter-macro-not-async-closure-simplified.rs b/tests/ui/iterators/iter-macro-not-async-closure-simplified.rs index 4fa14fda661cf..0b63bcbcaf1b2 100644 --- a/tests/ui/iterators/iter-macro-not-async-closure-simplified.rs +++ b/tests/ui/iterators/iter-macro-not-async-closure-simplified.rs @@ -20,7 +20,7 @@ fn call_async_once(_: impl AsyncFnOnce()) {} fn main() { let f = iter! { move || { for i in 0..10 { - yield i; + i.yield; } }}; diff --git a/tests/ui/iterators/iter-macro-not-async-closure.rs b/tests/ui/iterators/iter-macro-not-async-closure.rs index 634391883ea73..25fd2daf33750 100644 --- a/tests/ui/iterators/iter-macro-not-async-closure.rs +++ b/tests/ui/iterators/iter-macro-not-async-closure.rs @@ -18,7 +18,7 @@ async fn call_async_once(f: impl AsyncFnOnce()) { fn main() { let f = iter! { move || { for i in 0..10 { - yield i; + i.yield; } }}; diff --git a/tests/ui/lint/must_not_suspend/tuple-mismatch.rs b/tests/ui/lint/must_not_suspend/tuple-mismatch.rs index ec409925d7248..f349fc8fe35f0 100644 --- a/tests/ui/lint/must_not_suspend/tuple-mismatch.rs +++ b/tests/ui/lint/must_not_suspend/tuple-mismatch.rs @@ -3,8 +3,8 @@ fn main() { let _coroutine = #[coroutine] || { - yield ((), ((), ())); - yield ((), ()); + ((), ((), ())).yield; + ((), ()).yield; //~^ ERROR mismatched types }; } diff --git a/tests/ui/lint/must_not_suspend/tuple-mismatch.stderr b/tests/ui/lint/must_not_suspend/tuple-mismatch.stderr index 102eadd7affd4..5cc8a5fb9ca11 100644 --- a/tests/ui/lint/must_not_suspend/tuple-mismatch.stderr +++ b/tests/ui/lint/must_not_suspend/tuple-mismatch.stderr @@ -1,8 +1,8 @@ error[E0308]: mismatched types - --> $DIR/tuple-mismatch.rs:7:20 + --> $DIR/tuple-mismatch.rs:7:14 | -LL | yield ((), ()); - | ^^ expected `((), ())`, found `()` +LL | ((), ()).yield; + | ^^ expected `((), ())`, found `()` | = note: expected tuple `((), ())` found unit type `()` 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 12e2bcb898cad..7fad59f153d8e 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 @@ -7,20 +7,20 @@ use std::pin::Pin; fn main() { let mut x = #[coroutine] |_| { - while let Some(_) = (yield) {} - while let Some(_) = {yield} {} + while let Some(_) = (().yield) {} + while let Some(_) = {().yield} {} // Only warn these cases - while let Some(_) = ({yield}) {} //~ ERROR: unnecessary parentheses - while let Some(_) = ((yield)) {} //~ ERROR: unnecessary parentheses - {{yield}}; //~ ERROR: unnecessary braces - {( yield )}; //~ ERROR: unnecessary parentheses - while let Some(_) = {(yield)} {} //~ ERROR: unnecessary parentheses - while let Some(_) = {{yield}} {} //~ ERROR: unnecessary braces + while let Some(_) = ({().yield}) {} //~ ERROR: unnecessary parentheses + while let Some(_) = ((().yield)) {} //~ ERROR: unnecessary parentheses + {{().yield}}; //~ ERROR: unnecessary braces + {( ().yield )}; //~ ERROR: unnecessary parentheses + while let Some(_) = {(().yield)} {} //~ ERROR: unnecessary parentheses + while let Some(_) = {{().yield}} {} //~ ERROR: unnecessary braces // FIXME: It'd be great if we could also warn them. - ((yield)); - ({ yield }); + ((().yield)); + ({ ().yield }); }; let _ = Pin::new(&mut x).resume(Some(5)); } diff --git a/tests/ui/lint/unused/issue-74883-unused-paren-baren-yield.stderr b/tests/ui/lint/unused/issue-74883-unused-paren-baren-yield.stderr index 3f1fee332bec5..28bb0ae6d3846 100644 --- a/tests/ui/lint/unused/issue-74883-unused-paren-baren-yield.stderr +++ b/tests/ui/lint/unused/issue-74883-unused-paren-baren-yield.stderr @@ -1,8 +1,8 @@ error: unnecessary parentheses around `let` scrutinee expression --> $DIR/issue-74883-unused-paren-baren-yield.rs:14:29 | -LL | while let Some(_) = ({yield}) {} - | ^ ^ +LL | while let Some(_) = ({().yield}) {} + | ^ ^ | note: the lint level is defined here --> $DIR/issue-74883-unused-paren-baren-yield.rs:3:24 @@ -11,27 +11,27 @@ LL | #![deny(unused_braces, unused_parens)] | ^^^^^^^^^^^^^ help: remove these parentheses | -LL - while let Some(_) = ({yield}) {} -LL + while let Some(_) = {yield} {} +LL - while let Some(_) = ({().yield}) {} +LL + while let Some(_) = {().yield} {} | error: unnecessary parentheses around `let` scrutinee expression --> $DIR/issue-74883-unused-paren-baren-yield.rs:15:29 | -LL | while let Some(_) = ((yield)) {} - | ^ ^ +LL | while let Some(_) = ((().yield)) {} + | ^ ^ | help: remove these parentheses | -LL - while let Some(_) = ((yield)) {} -LL + while let Some(_) = (yield) {} +LL - while let Some(_) = ((().yield)) {} +LL + while let Some(_) = (().yield) {} | error: unnecessary braces around block return value --> $DIR/issue-74883-unused-paren-baren-yield.rs:16:10 | -LL | {{yield}}; - | ^ ^ +LL | {{().yield}}; + | ^ ^ | note: the lint level is defined here --> $DIR/issue-74883-unused-paren-baren-yield.rs:3:9 @@ -40,44 +40,44 @@ LL | #![deny(unused_braces, unused_parens)] | ^^^^^^^^^^^^^ help: remove these braces | -LL - {{yield}}; -LL + {yield}; +LL - {{().yield}}; +LL + {().yield}; | error: unnecessary parentheses around block return value --> $DIR/issue-74883-unused-paren-baren-yield.rs:17:10 | -LL | {( yield )}; - | ^^ ^^ +LL | {( ().yield )}; + | ^^ ^^ | help: remove these parentheses | -LL - {( yield )}; -LL + {yield}; +LL - {( ().yield )}; +LL + {().yield}; | error: unnecessary parentheses around block return value --> $DIR/issue-74883-unused-paren-baren-yield.rs:18:30 | -LL | while let Some(_) = {(yield)} {} - | ^ ^ +LL | while let Some(_) = {(().yield)} {} + | ^ ^ | help: remove these parentheses | -LL - while let Some(_) = {(yield)} {} -LL + while let Some(_) = {yield} {} +LL - while let Some(_) = {(().yield)} {} +LL + while let Some(_) = {().yield} {} | error: unnecessary braces around block return value --> $DIR/issue-74883-unused-paren-baren-yield.rs:19:30 | -LL | while let Some(_) = {{yield}} {} - | ^ ^ +LL | while let Some(_) = {{().yield}} {} + | ^ ^ | help: remove these braces | -LL - while let Some(_) = {{yield}} {} -LL + while let Some(_) = {yield} {} +LL - while let Some(_) = {{().yield}} {} +LL + while let Some(_) = {().yield} {} | error: aborting due to 6 previous errors diff --git a/tests/ui/lint/unused/unused-closure.rs b/tests/ui/lint/unused/unused-closure.rs index 1f98cdfb21f0f..263a1a1e8db61 100644 --- a/tests/ui/lint/unused/unused-closure.rs +++ b/tests/ui/lint/unused/unused-closure.rs @@ -25,7 +25,7 @@ fn unused() { fn ignored() { let _ = || {}; - let _ = #[coroutine] || yield 42; + let _ = #[coroutine] || 42.yield; } fn main() { diff --git a/tests/ui/liveness/liveness-upvars.rs b/tests/ui/liveness/liveness-upvars.rs index be58b48a40576..b37d5ca8e7e73 100644 --- a/tests/ui/liveness/liveness-upvars.rs +++ b/tests/ui/liveness/liveness-upvars.rs @@ -139,10 +139,10 @@ pub fn coroutine() { let mut s: u32 = 0; let _ = #[coroutine] |_| { s = 0; - yield (); + ().yield; s = 1; //~ WARN value assigned to `s` is never read - yield (s = 2); - s = yield (); //~ WARN value assigned to `s` is never read + (s = 2).yield; + s = ().yield; //~ WARN value assigned to `s` is never read s = 3; }; } diff --git a/tests/ui/liveness/liveness-upvars.stderr b/tests/ui/liveness/liveness-upvars.stderr index cfed2830164ad..b682903b5f0cd 100644 --- a/tests/ui/liveness/liveness-upvars.stderr +++ b/tests/ui/liveness/liveness-upvars.stderr @@ -191,7 +191,7 @@ LL | s = 1; warning: value assigned to `s` is never read --> $DIR/liveness-upvars.rs:145:9 | -LL | s = yield (); +LL | s = ().yield; | ^^^^^^^^^^^^ | = help: maybe it is overwritten before being read? diff --git a/tests/ui/macros/stringify.rs b/tests/ui/macros/stringify.rs index fa06da5cbfbc6..912b56cd50ccd 100644 --- a/tests/ui/macros/stringify.rs +++ b/tests/ui/macros/stringify.rs @@ -316,8 +316,8 @@ fn test_expr() { c1!(expr, [ expr? ], "expr?"); // ExprKind::Yield - c1!(expr, [ yield ], "yield"); - c1!(expr, [ yield true ], "yield true"); + c1!(expr, [ ().yield ], "().yield"); + c1!(expr, [ true.yield ], "true.yield"); // ExprKind::Yeet c1!(expr, [ do yeet ], "do yeet"); diff --git a/tests/ui/nll/coroutine-distinct-lifetime.rs b/tests/ui/nll/coroutine-distinct-lifetime.rs index 471fad686c4c3..379792cecae2f 100644 --- a/tests/ui/nll/coroutine-distinct-lifetime.rs +++ b/tests/ui/nll/coroutine-distinct-lifetime.rs @@ -12,11 +12,11 @@ fn foo(x: &mut u32) { #[coroutine] move || { let s = &mut *x; - yield; + ().yield; *s += 1; let t = &mut *x; - yield; + ().yield; *t += 1; }; } diff --git a/tests/ui/nll/coroutine-upvar-mutability.rs b/tests/ui/nll/coroutine-upvar-mutability.rs index a7d14173fb9fc..7632dbb123d7c 100644 --- a/tests/ui/nll/coroutine-upvar-mutability.rs +++ b/tests/ui/nll/coroutine-upvar-mutability.rs @@ -9,7 +9,7 @@ fn mutate_upvar() { move || { x = 1; //~^ ERROR - yield; + ().yield; }; } diff --git a/tests/ui/nll/extra-unused-mut.rs b/tests/ui/nll/extra-unused-mut.rs index b040dcc6e5db9..4bede8517cd68 100644 --- a/tests/ui/nll/extra-unused-mut.rs +++ b/tests/ui/nll/extra-unused-mut.rs @@ -22,7 +22,7 @@ fn coroutine_mutable_upvar() { #[coroutine] move || { x = 1; - yield; + ().yield; }; } diff --git a/tests/ui/nll/issue-48623-coroutine.rs b/tests/ui/nll/issue-48623-coroutine.rs index 63348a2047c07..72334a886ca64 100644 --- a/tests/ui/nll/issue-48623-coroutine.rs +++ b/tests/ui/nll/issue-48623-coroutine.rs @@ -12,7 +12,7 @@ impl Drop for WithDrop { fn reborrow_from_coroutine(r: &mut ()) { let d = WithDrop; - #[coroutine] move || { d; yield; &mut *r }; //~ WARN unused coroutine that must be used + #[coroutine] move || { d; ().yield; &mut *r }; //~ WARN unused coroutine that must be used } fn main() {} diff --git a/tests/ui/nll/issue-48623-coroutine.stderr b/tests/ui/nll/issue-48623-coroutine.stderr index 2862d7b2a2f05..d24af93188e46 100644 --- a/tests/ui/nll/issue-48623-coroutine.stderr +++ b/tests/ui/nll/issue-48623-coroutine.stderr @@ -1,8 +1,8 @@ warning: unused coroutine that must be used --> $DIR/issue-48623-coroutine.rs:15:18 | -LL | #[coroutine] move || { d; yield; &mut *r }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[coroutine] move || { d; ().yield; &mut *r }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: coroutines are lazy and do nothing unless resumed = note: `#[warn(unused_must_use)]` (part of `#[warn(unused)]`) on by default diff --git a/tests/ui/nll/issue-55850.rs b/tests/ui/nll/issue-55850.rs index bf1e2e7caef6d..d197f8776e13b 100644 --- a/tests/ui/nll/issue-55850.rs +++ b/tests/ui/nll/issue-55850.rs @@ -25,7 +25,7 @@ where fn bug<'a>() -> impl Iterator { GenIter(#[coroutine] move || { let mut s = String::new(); - yield &s[..] //~ ERROR cannot yield value referencing local variable `s` [E0515] + (&s[..]).yield //~ ERROR cannot yield value referencing local variable `s` [E0515] //~| ERROR borrow may still be in use when coroutine yields }) } diff --git a/tests/ui/nll/issue-55850.stderr b/tests/ui/nll/issue-55850.stderr index 5a9c779919790..06f32f4b511af 100644 --- a/tests/ui/nll/issue-55850.stderr +++ b/tests/ui/nll/issue-55850.stderr @@ -1,20 +1,20 @@ error[E0515]: cannot yield value referencing local variable `s` --> $DIR/issue-55850.rs:28:9 | -LL | yield &s[..] - | ^^^^^^^-^^^^ - | | | - | | `s` is borrowed here +LL | (&s[..]).yield + | ^^-^^^^^^^^^^^ + | | | + | | `s` is borrowed here | yields a value referencing data owned by the current function error[E0626]: borrow may still be in use when coroutine yields - --> $DIR/issue-55850.rs:28:16 + --> $DIR/issue-55850.rs:28:11 | LL | GenIter(#[coroutine] move || { | ------- within this coroutine LL | let mut s = String::new(); -LL | yield &s[..] - | -------^---- possible yield occurs here +LL | (&s[..]).yield + | --^----------- possible yield occurs here | help: add `static` to mark this coroutine as unmovable | diff --git a/tests/ui/packed/packed-struct-drop-aligned.rs b/tests/ui/packed/packed-struct-drop-aligned.rs index e8125115d45e6..708da28825910 100644 --- a/tests/ui/packed/packed-struct-drop-aligned.rs +++ b/tests/ui/packed/packed-struct-drop-aligned.rs @@ -50,7 +50,7 @@ fn main() { // struct to a separate local before dropping it. We move out the // first field to generate and open drop for the second field. drop(p.0); - yield; + ().yield; }; Pin::new(&mut g).resume(()); assert_eq!(drop_count.get(), 1); diff --git a/tests/ui/print_type_sizes/coroutine.rs b/tests/ui/print_type_sizes/coroutine.rs index 1533578878944..3827e8e3c9e63 100644 --- a/tests/ui/print_type_sizes/coroutine.rs +++ b/tests/ui/print_type_sizes/coroutine.rs @@ -9,7 +9,7 @@ use std::ops::Coroutine; fn coroutine(array: [u8; C]) -> impl Coroutine { #[coroutine] move |()| { - yield (); + ().yield; let _ = array; } } diff --git a/tests/ui/print_type_sizes/coroutine_discr_placement.rs b/tests/ui/print_type_sizes/coroutine_discr_placement.rs index d97b0b28ed0fe..fe9ffe1ee7fdc 100644 --- a/tests/ui/print_type_sizes/coroutine_discr_placement.rs +++ b/tests/ui/print_type_sizes/coroutine_discr_placement.rs @@ -13,12 +13,12 @@ pub fn foo() { || { { let w: i32 = 4; - yield; + ().yield; drop(w); } { let z: i32 = 7; - yield; + ().yield; drop(z); } }; 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 9fdceefbf9b92..84f09ed53d343 100644 --- a/tests/ui/rfcs/rfc-2091-track-caller/tracked-closure.rs +++ b/tests/ui/rfcs/rfc-2091-track-caller/tracked-closure.rs @@ -114,8 +114,8 @@ fn dyn_coroutine( fn test_coroutine() { let coroutine = #[track_caller] #[coroutine] |arg: String| { - yield ("first", arg.clone(), Location::caller()); - yield ("second", arg.clone(), Location::caller()); + ("first", arg.clone(), Location::caller()).yield; + ("second", arg.clone(), Location::caller()).yield; }; let mut pinned = Box::pin(coroutine); @@ -136,7 +136,7 @@ fn test_coroutine() { assert_eq!(mono_loc.line(), mono_line); assert_eq!(mono_loc.column(), 42); - let non_tracked_coroutine = #[coroutine] || { yield Location::caller(); }; + let non_tracked_coroutine = #[coroutine] || { Location::caller().yield; }; let non_tracked_line = line!() - 1; // This is the line of the coroutine, not its caller let non_tracked_loc = match Box::pin(non_tracked_coroutine).as_mut().resume(()) { CoroutineState::Yielded(val) => val, @@ -144,7 +144,7 @@ fn test_coroutine() { }; assert_eq!(non_tracked_loc.file(), file!()); assert_eq!(non_tracked_loc.line(), non_tracked_line); - assert_eq!(non_tracked_loc.column(), 57); + assert_eq!(non_tracked_loc.column(), 51); } diff --git a/tests/ui/sanitizer/cfi/coroutine.rs b/tests/ui/sanitizer/cfi/coroutine.rs index d85615b597de2..972f820cce80a 100644 --- a/tests/ui/sanitizer/cfi/coroutine.rs +++ b/tests/ui/sanitizer/cfi/coroutine.rs @@ -29,7 +29,7 @@ use std::async_iter::AsyncIterator; #[test] fn general_coroutine() { let coro = #[coroutine] |x: i32| { - yield x; + x.yield; "done" }; let mut abstract_coro: Pin<&mut dyn Coroutine> = pin!(coro); @@ -47,7 +47,7 @@ fn async_coroutine() { } async gen fn async_gen_fn() -> u8 { - yield 5; + 5.yield; } #[test] @@ -58,7 +58,7 @@ fn async_gen_coroutine() { } gen fn gen_fn() -> u8 { - yield 6; + 6.yield; } #[test] diff --git a/tests/ui/sized-hierarchy/impls.rs b/tests/ui/sized-hierarchy/impls.rs index 643f7bc7c46cb..0638c2bee09e9 100644 --- a/tests/ui/sized-hierarchy/impls.rs +++ b/tests/ui/sized-hierarchy/impls.rs @@ -142,9 +142,9 @@ fn main() { takes_pointeesized(async |a| { a }); // `|a| { yield a }` - takes_sized(#[coroutine] |a| { yield a }); - takes_metasized(#[coroutine] |a| { yield a }); - takes_pointeesized(#[coroutine] |a| { yield a }); + takes_sized(#[coroutine] |a| { a.yield }); + takes_metasized(#[coroutine] |a| { a.yield }); + takes_pointeesized(#[coroutine] |a| { a.yield }); // `!` needs_sized::(); diff --git a/tests/ui/suggestions/issue-84973-blacklist.rs b/tests/ui/suggestions/issue-84973-blacklist.rs index 7edf4d347af25..ce45758f6229c 100644 --- a/tests/ui/suggestions/issue-84973-blacklist.rs +++ b/tests/ui/suggestions/issue-84973-blacklist.rs @@ -15,7 +15,7 @@ struct S; fn main() { f_copy("".to_string()); //~ ERROR: the trait bound `String: Copy` is not satisfied [E0277] f_clone(S); //~ ERROR: the trait bound `S: Clone` is not satisfied [E0277] - f_unpin(#[coroutine] static || { yield; }); + f_unpin(#[coroutine] static || { ().yield; }); //~^ ERROR: cannot be unpinned [E0277] let cl = || (); diff --git a/tests/ui/suggestions/issue-84973-blacklist.stderr b/tests/ui/suggestions/issue-84973-blacklist.stderr index 3db400418c711..61b391a709530 100644 --- a/tests/ui/suggestions/issue-84973-blacklist.stderr +++ b/tests/ui/suggestions/issue-84973-blacklist.stderr @@ -39,8 +39,8 @@ LL | struct S; error[E0277]: `{static coroutine@$DIR/issue-84973-blacklist.rs:18:26: 18:35}` cannot be unpinned --> $DIR/issue-84973-blacklist.rs:18:26 | -LL | f_unpin(#[coroutine] static || { yield; }); - | ------- ^^^^^^^^^^^^^^^^^^^^ the trait `Unpin` is not implemented for `{static coroutine@$DIR/issue-84973-blacklist.rs:18:26: 18:35}` +LL | f_unpin(#[coroutine] static || { ().yield; }); + | ------- ^^^^^^^^^^^^^^^^^^^^^^^ the trait `Unpin` is not implemented for `{static coroutine@$DIR/issue-84973-blacklist.rs:18:26: 18:35}` | | | required by a bound introduced by this call | diff --git a/tests/ui/suggestions/unnamable-types.rs b/tests/ui/suggestions/unnamable-types.rs index 6772217a2f6ff..e100bd7dd4e51 100644 --- a/tests/ui/suggestions/unnamable-types.rs +++ b/tests/ui/suggestions/unnamable-types.rs @@ -34,6 +34,6 @@ const F = S { t: foo }; //~| HELP: provide a type for the constant -const G = #[coroutine] || -> i32 { yield 0; return 1; }; +const G = #[coroutine] || -> i32 { 0.yield; return 1; }; //~^ ERROR: missing type for `const` item //~| NOTE: however, the inferred type diff --git a/tests/ui/suggestions/unnamable-types.stderr b/tests/ui/suggestions/unnamable-types.stderr index bcd1a905194ef..b13fb6f002f24 100644 --- a/tests/ui/suggestions/unnamable-types.stderr +++ b/tests/ui/suggestions/unnamable-types.stderr @@ -55,13 +55,13 @@ LL | const F = S { t: foo }; error: missing type for `const` item --> $DIR/unnamable-types.rs:37:8 | -LL | const G = #[coroutine] || -> i32 { yield 0; return 1; }; +LL | const G = #[coroutine] || -> i32 { 0.yield; return 1; }; | ^ | note: however, the inferred type `{coroutine@$DIR/unnamable-types.rs:37:24: 37:33}` cannot be named --> $DIR/unnamable-types.rs:37:24 | -LL | const G = #[coroutine] || -> i32 { yield 0; return 1; }; +LL | const G = #[coroutine] || -> i32 { 0.yield; return 1; }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 7 previous errors diff --git a/tests/ui/traits/next-solver/coroutine.fail.stderr b/tests/ui/traits/next-solver/coroutine.fail.stderr index 8c263e8644bd0..8d57d2d7a2d9a 100644 --- a/tests/ui/traits/next-solver/coroutine.fail.stderr +++ b/tests/ui/traits/next-solver/coroutine.fail.stderr @@ -6,7 +6,7 @@ LL | needs_coroutine( LL | #[coroutine] LL | / || { LL | | -LL | | yield (); +LL | | ().yield; LL | | }, | |_________^ the trait `Coroutine` is not implemented for `{coroutine@$DIR/coroutine.rs:20:9: 20:11}` | diff --git a/tests/ui/traits/next-solver/coroutine.rs b/tests/ui/traits/next-solver/coroutine.rs index 7f75f29e4b116..817ad5165bd43 100644 --- a/tests/ui/traits/next-solver/coroutine.rs +++ b/tests/ui/traits/next-solver/coroutine.rs @@ -19,7 +19,7 @@ fn main() { #[coroutine] || { //[fail]~^ ERROR Coroutine` is not satisfied - yield (); + ().yield; }, ); } @@ -29,7 +29,7 @@ fn main() { needs_coroutine( #[coroutine] |_: A| { - let _: A = yield B; + let _: A = B.yield; C }, ) diff --git a/tests/ui/type-alias-impl-trait/issue-53678-coroutine-and-const-fn.rs b/tests/ui/type-alias-impl-trait/issue-53678-coroutine-and-const-fn.rs index b258d2e156d03..10184971ee13f 100644 --- a/tests/ui/type-alias-impl-trait/issue-53678-coroutine-and-const-fn.rs +++ b/tests/ui/type-alias-impl-trait/issue-53678-coroutine-and-const-fn.rs @@ -11,7 +11,7 @@ pub type CoroOnce = impl Coroutine; pub const fn const_coroutine(yielding: Y, returning: R) -> CoroOnce { #[coroutine] move || { - yield yielding; + yielding.yield; return returning; } diff --git a/tests/ui/type-alias-impl-trait/issue-58662-coroutine-with-lifetime.rs b/tests/ui/type-alias-impl-trait/issue-58662-coroutine-with-lifetime.rs index c2a9f153815e2..405d6b6be8cae 100644 --- a/tests/ui/type-alias-impl-trait/issue-58662-coroutine-with-lifetime.rs +++ b/tests/ui/type-alias-impl-trait/issue-58662-coroutine-with-lifetime.rs @@ -13,7 +13,7 @@ fn rand_coroutine<'a>(rng: &'a ()) -> RandCoroutine<'a> { move || { let _rng = rng; loop { - yield 0; + 0.yield; } } } @@ -26,7 +26,7 @@ pub fn rand_coroutine_with_indirection<'a>(rng: &'a ()) -> RandCoroutineWithIndi move || { let _rng = rng; loop { - yield 0; + 0.yield; } } } diff --git a/tests/ui/type-alias-impl-trait/issue-94429.rs b/tests/ui/type-alias-impl-trait/issue-94429.rs index 11beed06a20cd..5041f15a1c0df 100644 --- a/tests/ui/type-alias-impl-trait/issue-94429.rs +++ b/tests/ui/type-alias-impl-trait/issue-94429.rs @@ -16,7 +16,7 @@ impl Runnable for Implementor { //~^ ERROR: type mismatch resolving #[coroutine] move || { - yield 1; + 1.yield; } } } diff --git a/tests/ui/unpretty/exhaustive.expanded.stdout b/tests/ui/unpretty/exhaustive.expanded.stdout index a12ea0786f910..32e8cd7cb4218 100644 --- a/tests/ui/unpretty/exhaustive.expanded.stdout +++ b/tests/ui/unpretty/exhaustive.expanded.stdout @@ -338,7 +338,7 @@ mod expressions { /// ExprKind::Try fn expr_try() { let expr; expr?; } /// ExprKind::Yield - fn expr_yield() { yield; yield true; } + fn expr_yield() { ().yield; true.yield; } /// ExprKind::Yeet fn expr_yeet() { do yeet; do yeet 0; } /// ExprKind::Become diff --git a/tests/ui/unpretty/exhaustive.hir.stderr b/tests/ui/unpretty/exhaustive.hir.stderr index eb5c186bd2c05..e53e55c959dfd 100644 --- a/tests/ui/unpretty/exhaustive.hir.stderr +++ b/tests/ui/unpretty/exhaustive.hir.stderr @@ -70,8 +70,8 @@ LL | core::()::marker::()::PhantomData; error: `yield` can only be used in `#[coroutine]` closures, or `gen` blocks --> $DIR/exhaustive.rs:391:9 | -LL | yield; - | ^^^^^ +LL | ().yield; + | ^^^^^^^^ | help: use `#[coroutine]` to make this closure a coroutine | diff --git a/tests/ui/unpretty/exhaustive.rs b/tests/ui/unpretty/exhaustive.rs index 0983a0a7e4372..3895a3dfd20b8 100644 --- a/tests/ui/unpretty/exhaustive.rs +++ b/tests/ui/unpretty/exhaustive.rs @@ -388,8 +388,8 @@ mod expressions { /// ExprKind::Yield fn expr_yield() { - yield; //[hir]~ ERROR `yield` can only be used - yield true; + ().yield; //[hir]~ ERROR `yield` can only be used + true.yield; } /// ExprKind::Yeet