rust/tests/ui/nll/closure-requirements
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
..
escape-argument-callee.rs
escape-argument-callee.stderr update region debug formatting 2024-03-18 16:44:12 +00:00
escape-argument.rs
escape-argument.stderr update region debug formatting 2024-03-18 16:44:12 +00:00
escape-upvar-nested.rs
escape-upvar-nested.stderr Modify find_expr from Span to better account for closures 2024-04-24 22:21:13 +00:00
escape-upvar-ref.rs
escape-upvar-ref.stderr Modify find_expr from Span to better account for closures 2024-04-24 22:21:13 +00:00
issue-58127-mutliple-requirements.rs
propagate-approximated-fail-no-postdom.rs
propagate-approximated-fail-no-postdom.stderr update region debug formatting 2024-03-18 16:44:12 +00:00
propagate-approximated-ref.rs
propagate-approximated-ref.stderr update region debug formatting 2024-03-18 16:44:12 +00:00
propagate-approximated-shorter-to-static-comparing-against-free.rs
propagate-approximated-shorter-to-static-comparing-against-free.stderr Stop ConstraintCategory Ord impl from relying on Ty's Ord impl. 2024-03-21 10:45:30 +00:00
propagate-approximated-shorter-to-static-no-bound.rs
propagate-approximated-shorter-to-static-no-bound.stderr update region debug formatting 2024-03-18 16:44:12 +00:00
propagate-approximated-shorter-to-static-wrong-bound.rs
propagate-approximated-shorter-to-static-wrong-bound.stderr update region debug formatting 2024-03-18 16:44:12 +00:00
propagate-approximated-val.rs
propagate-approximated-val.stderr update region debug formatting 2024-03-18 16:44:12 +00:00
propagate-despite-same-free-region.rs
propagate-despite-same-free-region.stderr update region debug formatting 2024-03-18 16:44:12 +00:00
propagate-fail-to-approximate-longer-no-bounds.rs
propagate-fail-to-approximate-longer-no-bounds.stderr update region debug formatting 2024-03-18 16:44:12 +00:00
propagate-fail-to-approximate-longer-wrong-bounds.rs
propagate-fail-to-approximate-longer-wrong-bounds.stderr update region debug formatting 2024-03-18 16:44:12 +00:00
propagate-from-trait-match.rs
propagate-from-trait-match.stderr
propagate-multiple-requirements.rs
propagate-multiple-requirements.stderr Modify find_expr from Span to better account for closures 2024-04-24 22:21:13 +00:00
region-lbr1-does-not-outlive-ebr2.rs
region-lbr1-does-not-outlive-ebr2.stderr
region-lbr1-does-outlive-lbr2-because-implied-bound.rs
region-lbr-anon-does-not-outlive-static.rs
region-lbr-anon-does-not-outlive-static.stderr
region-lbr-named-does-not-outlive-static.rs
region-lbr-named-does-not-outlive-static.stderr
return-wrong-bound-region.rs
return-wrong-bound-region.stderr update region debug formatting 2024-03-18 16:44:12 +00:00
type-test-subject-non-trivial-region.rs
type-test-subject-opaque-1.rs
type-test-subject-opaque-2.rs
type-test-subject-unnamed-region.rs