diff options
| author | bors <bors@rust-lang.org> | 2024-04-11 02:37:35 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-04-11 02:37:35 +0000 |
| commit | 08273780d84816d85f002f4385c342fc7eaba58b (patch) | |
| tree | 72d64c0f45a00edb2424af00a3434c9649ca8a78 /compiler/rustc_codegen_gcc | |
| parent | 4435924bb62cda0131e38dd5d2bba36f9616039f (diff) | |
| parent | f2465f8f2009e58412e8ca62abba6b2e4b8dd554 (diff) | |
| download | rust-08273780d84816d85f002f4385c342fc7eaba58b.tar.gz rust-08273780d84816d85f002f4385c342fc7eaba58b.zip | |
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.
Diffstat (limited to 'compiler/rustc_codegen_gcc')
0 files changed, 0 insertions, 0 deletions
