rust/tests/ui/nll/polonius
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
..
assignment-kills-loans.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
assignment-to-differing-field.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
assignment-to-differing-field.stderr Do not set up wrong span for adjustments 2023-07-10 20:09:26 +00:00
call-kills-loans.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-46589.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
location-insensitive-scopes-issue-116657.nll.stderr add non-regression test for issue 116657 2023-10-19 21:11:21 +00:00
location-insensitive-scopes-issue-116657.polonius.stderr add non-regression test for issue 116657 2023-10-19 21:11:21 +00:00
location-insensitive-scopes-issue-116657.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
location-insensitive-scopes-issue-117146.nll.stderr Modify find_expr from Span to better account for closures 2024-04-24 22:21:13 +00:00
location-insensitive-scopes-issue-117146.polonius.stderr Modify find_expr from Span to better account for closures 2024-04-24 22:21:13 +00:00
location-insensitive-scopes-issue-117146.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
location-insensitive-scopes-liveness.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
polonius-smoke-test.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
polonius-smoke-test.stderr Account for * when looking for inner-most path in expression 2023-01-17 02:45:11 +00:00
storagedead-kills-loans.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
subset-relations.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
subset-relations.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00