rust/tests/ui/coroutine
Esteban Küber 4aba2c55e6 Modify find_expr from Span to better account for closures
Start pointing to where bindings were declared when they are captured in closures:

```
error[E0597]: `x` does not live long enough
  --> $DIR/suggest-return-closure.rs:23:9
   |
LL |     let x = String::new();
   |         - binding `x` declared here
...
LL |     |c| {
   |     --- value captured here
LL |         x.push(c);
   |         ^ borrowed value does not live long enough
...
LL | }
   | -- borrow later used here
   | |
   | `x` dropped here while still borrowed
```

Suggest cloning in more cases involving closures:

```
error[E0507]: cannot move out of `foo` in pattern guard
  --> $DIR/issue-27282-move-ref-mut-into-guard.rs:11:19
   |
LL |             if { (|| { let mut bar = foo; bar.take() })(); false } => {},
   |                   ^^                 --- move occurs because `foo` has type `&mut Option<&i32>`, which does not implement the `Copy` trait
   |                   |
   |                   `foo` is moved here
   |
   = note: variables bound in patterns cannot be moved from until after the end of the pattern guard
help: consider cloning the value if the performance cost is acceptable
   |
LL |             if { (|| { let mut bar = foo.clone(); bar.take() })(); false } => {},
   |                                         ++++++++
```
2024-04-24 22:21:13 +00:00
..
auxiliary Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
print Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
addassign-yield.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
async_gen_fn_iter.rs
async_gen_fn.e2024.stderr
async_gen_fn.none.stderr
async_gen_fn.rs
async-coroutine-issue-67158.rs
async-coroutine-issue-67158.stderr
async-gen-deduce-yield.rs
async-gen-yield-ty-is-unit.rs
auto-trait-regions.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
auto-trait-regions.stderr
borrow-in-tail-expr.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
borrowing.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
borrowing.stderr Modify find_expr from Span to better account for closures 2024-04-24 22:21:13 +00:00
check-resume-ty-lifetimes-2.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
check-resume-ty-lifetimes-2.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
check-resume-ty-lifetimes.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
check-resume-ty-lifetimes.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
clone-impl-async.rs
clone-impl-async.stderr
clone-impl-static.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
clone-impl-static.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
clone-impl.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
clone-impl.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
clone-rpit.next.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
clone-rpit.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
conditional-drop.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
control-flow.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
coroutine-in-orphaned-anon-const.rs crash -> test 2024-04-15 22:21:50 -04:00
coroutine-in-orphaned-anon-const.stderr crash -> test 2024-04-15 22:21:50 -04:00
coroutine-region-requirements.migrate.stderr
coroutine-region-requirements.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
coroutine-region-requirements.stderr
coroutine-resume-after-panic.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
coroutine-with-nll.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
coroutine-with-nll.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
coroutine-yielding-or-returning-itself.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
coroutine-yielding-or-returning-itself.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
derived-drop-parent-expr.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
discriminant.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
drop-and-replace.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
drop-control-flow.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
drop-env.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
drop-track-addassign-yield.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
drop-tracking-parent-expression.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
drop-tracking-parent-expression.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
drop-tracking-yielding-in-match-guards.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
drop-yield-twice.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
drop-yield-twice.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
dropck-resume.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
dropck-resume.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
dropck.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
dropck.stderr Modify find_expr from Span to better account for closures 2024-04-24 22:21:13 +00:00
gen_block_is_coro.rs
gen_block_is_coro.stderr
gen_block_is_fused_iter.rs Implement FusedIterator for gen block 2024-03-22 02:02:34 +09:00
gen_block_is_iter.rs
gen_block_is_no_future.rs
gen_block_is_no_future.stderr Use root obligation on E0277 for some cases 2024-03-03 18:53:35 +00:00
gen_block_iterate.rs
gen_block_move.fixed
gen_block_move.rs
gen_block_move.stderr
gen_block_panic.rs
gen_block_panic.stderr
gen_block.e2024.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
gen_block.none.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
gen_block.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
gen_fn_iter.rs
gen_fn_lifetime_capture.rs
gen_fn.e2024.stderr
gen_fn.none.stderr
gen_fn.rs
issue-44197.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
issue-45729-unsafe-in-coroutine.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
issue-45729-unsafe-in-coroutine.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
issue-48048.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
issue-48048.stderr
issue-52304.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
issue-52398.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
issue-52398.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
issue-53548-1.rs
issue-53548.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
issue-57017.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
issue-57084.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
issue-57084.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
issue-57478.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
issue-58888.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
issue-61442-stmt-expr-with-drop.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
issue-62506-two_awaits.rs
issue-64620-yield-array-element.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
issue-64620-yield-array-element.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
issue-68112.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
issue-68112.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
issue-69017.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
issue-69039.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
issue-87142.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
issue-88653.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
issue-88653.stderr
issue-91477.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
issue-91477.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
issue-93161.rs
issue-102645.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
issue-102645.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
issue-105084.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
issue-105084.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
issue-110929-coroutine-conflict-error-ice.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
issue-113279.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
issue-113279.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
iterator-count.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
layout-error.rs
layout-error.stderr
live-upvar-across-yield.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
match-bindings.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
match-bindings.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
metadata-sufficient-for-layout.rs
metadata-sufficient-for-layout.stderr
missing_coroutine_attr_suggestion.fixed Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
missing_coroutine_attr_suggestion.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
missing_coroutine_attr_suggestion.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
nested_coroutine.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
niche-in-coroutine.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
non-static-is-unpin.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
not-send-sync.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
not-send-sync.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
overlap-locals.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
panic-drops-resume.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
panic-drops.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
panic-safe.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
parent-expression.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
parent-expression.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
partial-drop.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
partial-initialization-across-yield.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
partial-initialization-across-yield.stderr
pattern-borrow.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
pattern-borrow.stderr
pin-box-coroutine.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
polymorphize-args.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
reborrow-mut-upvar.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
reborrow-mut-upvar.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
ref-escapes-but-not-over-yield.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
ref-escapes-but-not-over-yield.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
ref-upvar-not-send.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
ref-upvar-not-send.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
reinit-in-match-guard.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
resume-after-return.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
resume-arg-late-bound.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
resume-arg-late-bound.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
resume-arg-size.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
resume-live-across-yield.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
retain-resume-ref.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
retain-resume-ref.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
return-types-diverge.rs
return-types.rs
return-types.stderr
self_referential_gen_block.rs
self_referential_gen_block.stderr
size-moved-locals.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
sized-yield.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
sized-yield.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
smoke-resume-args.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
smoke.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
static-coroutine.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
static-mut-reference-across-yield.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
static-not-unpin.current.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
static-not-unpin.next.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
static-not-unpin.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
static-reference-across-yield.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
too-live-local-in-immovable-gen.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
too-live-local-in-immovable-gen.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
too-many-parameters.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
too-many-parameters.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
type-mismatch-error.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
type-mismatch-error.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
type-mismatch-signature-deduction.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
type-mismatch-signature-deduction.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
uninhabited-field.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
unresolved-ct-var.rs
unresolved-ct-var.stderr
unsized-capture-across-yield.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
unsized-capture-across-yield.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
unsized-local-across-yield.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
unsized-local-across-yield.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
unwind-abort-mix.rs
witness-ignore-fake-reads.rs
xcrate-reachable.rs
xcrate.rs
yield-in-args-rev.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
yield-in-args-rev.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
yield-in-args.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
yield-in-args.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
yield-in-const.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
yield-in-const.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
yield-in-function.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
yield-in-function.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
yield-in-initializer.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
yield-in-initializer.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
yield-in-static.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
yield-in-static.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
yield-outside-coroutine-issue-78653.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
yield-outside-coroutine-issue-78653.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
yield-subtype.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
yield-subtype.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
yield-while-iterating.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
yield-while-iterating.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
yield-while-local-borrowed.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
yield-while-local-borrowed.stderr
yield-while-ref-reborrowed.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
yield-while-ref-reborrowed.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
yielding-in-match-guards.rs