Commit Graph

16 Commits

Author SHA1 Message Date
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
Oli Scherer cda209bf43 Stop `ConstraintCategory` `Ord` impl from relying on `Ty`'s `Ord` impl. 2024-03-21 10:45:30 +00:00
Ali MJ Al-Nasrawy 19e0ea4a6d make `type_flags(ReError) & HAS_ERROR` 2024-03-20 17:29:58 +00:00
Boxy 8124b26122 update region debug formatting 2024-03-18 16:44:12 +00:00
许杰友 Jieyou Xu (Joe) ec2cc761bc
[AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
jyn b5d8361909 rename to verbose-internals 2023-12-19 13:35:37 -05:00
Nilstrieb 41e8d152dc Show number in error message even for one error
Co-authored-by: Adrian <adrian.iosdev@gmail.com>
2023-11-24 19:15:52 +01:00
Ali MJ Al-Nasrawy a8830631b9 remove trailing dots 2023-10-08 10:06:17 +00:00
Ali MJ Al-Nasrawy 996ffcb718 always show and explain sub region 2023-10-08 09:59:51 +00:00
Alex Macleod 5453a9f34d Add a note to duplicate diagnostics 2023-10-05 01:04:41 +00:00
Mahdi Dibaiee e55583c4b8 refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
Eric Mark Martin 76a7772759 resolve typerelative ctors to adt 2023-06-30 08:26:56 -04:00
Maybe Waffle cac143f0e3 Extend and use `hir::Node::body_id` 2023-04-19 19:13:45 +00:00
Ali MJ Al-Nasrawy a42cbdb165 allow ReError in CanonicalUserTypeAnnotation 2023-03-31 14:53:42 +00:00
Esteban Küber 656db98bd9 Tweak E0597
CC #99430
2023-01-15 19:46:20 +00:00
Albert Larsan cf2dff2b1e
Move /src/test to /tests 2023-01-11 09:32:08 +00:00