rust/compiler/rustc_borrowck/src
bors 08273780d8 Auto merge of #122213 - estebank:issue-50195, r=oli-obk,estebank
Provide suggestion to dereference closure tail if appropriate

When encoutnering a case like

```rust
use std::collections::HashMap;

fn main() {
    let vs = vec![0, 0, 1, 1, 3, 4, 5, 6, 3, 3, 3];

    let mut counts = HashMap::new();
    for num in vs {
        let count = counts.entry(num).or_insert(0);
        *count += 1;
    }

    let _ = counts.iter().max_by_key(|(_, v)| v);
```
produce the following suggestion
```
error: lifetime may not live long enough
  --> $DIR/return-value-lifetime-error.rs:13:47
   |
LL |     let _ = counts.iter().max_by_key(|(_, v)| v);
   |                                       ------- ^ returning this value requires that `'1` must outlive `'2`
   |                                       |     |
   |                                       |     return type of closure is &'2 &i32
   |                                       has type `&'1 (&i32, &i32)`
   |
help: dereference the return value
   |
LL |     let _ = counts.iter().max_by_key(|(_, v)| **v);
   |                                               ++
```

Fix #50195.
2024-04-11 02:37:35 +00:00
..
constraints Invert diagnostic lints. 2024-02-06 13:12:33 +11:00
diagnostics Use trait solver to answer questions instead of manually writing a trait solver 2024-04-10 05:22:43 +00:00
polonius Implement asm goto in MIR and MIR lowering 2024-02-24 18:50:09 +00:00
region_infer Eliminate DefiningAnchor now that is just a single-variant enum 2024-04-08 15:00:27 +00:00
type_check Eagerly check for accidentally registered region constraints instead of waiting until borrowck is done 2024-04-08 15:00:26 +00:00
util Move some utils out of rustc_const_eval 2023-04-16 12:05:54 +02:00
borrow_set.rs rustc_index: Add a ZERO constant to index types 2024-04-03 19:06:22 +03:00
borrowck_errors.rs Rename DiagnosticBuilder as Diag. 2024-02-28 08:55:35 +11:00
consumers.rs Eliminate DefiningAnchor now that is just a single-variant enum 2024-04-08 15:00:27 +00:00
dataflow.rs Invert diagnostic lints. 2024-02-06 13:12:33 +11:00
def_use.rs Invert diagnostic lints. 2024-02-06 13:12:33 +11:00
facts.rs Move trait into attr so it's greppable 2024-02-16 15:07:37 +00:00
lib.rs Auto merge of #122077 - oli-obk:eager_opaque_checks4, r=lcnr 2024-04-08 23:01:50 +00:00
location.rs Invert diagnostic lints. 2024-02-06 13:12:33 +11:00
member_constraints.rs Invert diagnostic lints. 2024-02-06 13:12:33 +11:00
nll.rs Avoid a span_delayed_bug in compute_regions. 2024-02-27 16:40:13 +11:00
path_utils.rs remove a bunch of dead parameters in fn 2024-02-12 09:51:35 +08:00
place_ext.rs Move trait into attr so it's greppable 2024-02-16 15:07:37 +00:00
places_conflict.rs Invert diagnostic lints. 2024-02-06 13:12:33 +11:00
prefixes.rs cleanup prefixes iterator 2024-03-13 12:34:58 -07:00
renumber.rs Invert diagnostic lints. 2024-02-06 13:12:33 +11:00
session_diagnostics.rs Prevent opaque types being instantiated twice with different regions within the same function 2024-03-18 10:26:10 +00:00
universal_regions.rs Rename DiagnosticBuilder as Diag. 2024-02-28 08:55:35 +11:00
used_muts.rs Bump indexmap 2024-02-13 21:03:34 +00:00