rust/tests/ui/fn
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
..
bad-main.rs
bad-main.stderr
dyn-fn-alignment.rs
expr-fn-panic.rs
expr-fn.rs
fn_def_coercion.rs Add some FnDef LUB coercion tests 2024-04-24 10:05:32 +00:00
fn_def_coercion.stderr Add some FnDef LUB coercion tests 2024-04-24 10:05:32 +00:00
fn_def_opaque_coercion.rs Register hidden types when equating function definitions in coercion 2024-04-24 10:05:33 +00:00
fn-bad-block-type.rs
fn-bad-block-type.stderr
fn-closure-mutable-capture.rs
fn-closure-mutable-capture.stderr
fn-compare-mismatch.rs
fn-compare-mismatch.stderr
fn-item-type.rs
fn-item-type.stderr
fn-pointer-mismatch.rs
fn-pointer-mismatch.stderr
fn-ptr-trait-int-float-infer-var.rs
fn-ptr-trait.rs
fn-recover-return-sign2.rs
fn-recover-return-sign2.stderr
fn-recover-return-sign.fixed
fn-recover-return-sign.rs
fn-recover-return-sign.stderr
fn-trait-formatting.rs
fn-trait-formatting.stderr
fun-call-variants.rs
implied-bounds-impl-header-projections.rs
implied-bounds-unnorm-associated-type-2.rs
implied-bounds-unnorm-associated-type-2.stderr
implied-bounds-unnorm-associated-type-3.rs
implied-bounds-unnorm-associated-type-4.rs
implied-bounds-unnorm-associated-type-4.stderr Account for unops when suggesting cloning 2024-04-11 16:41:41 +00:00
implied-bounds-unnorm-associated-type-5.rs
implied-bounds-unnorm-associated-type-5.stderr Account for unops when suggesting cloning 2024-04-11 16:41:41 +00:00
implied-bounds-unnorm-associated-type.rs
implied-bounds-unnorm-associated-type.stderr Account for unops when suggesting cloning 2024-04-11 16:41:41 +00:00
issue-1451.rs
issue-1900.rs
issue-1900.stderr
issue-3044.rs
issue-3044.stderr
issue-3099.rs
issue-3099.stderr
issue-3904.rs
issue-39259.rs
issue-39259.stderr
issue-80179.rs
issue-80179.stderr
keyword-order.rs
keyword-order.stderr
nested-function-names-issue-8587.rs
signature-error-reporting-under-verbose.rs
signature-error-reporting-under-verbose.stderr
suggest-return-closure.rs Modify find_expr from Span to better account for closures 2024-04-24 22:21:13 +00:00
suggest-return-closure.stderr Modify find_expr from Span to better account for closures 2024-04-24 22:21:13 +00:00
suggest-return-future.rs
suggest-return-future.stderr