-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thing
Description
false positive for let and return (possible linked to #848)
commented version works but generate clippy's warning.
given version does not compile:
error: `h` does not live long enough
--> src/main.rs:9:1
|
6 | h.drain().map(|(_, v)| v).collect()
| - borrow occurs here
...
9 | }
| ^ `h` dropped here while still borrowed
|
= note: values in a scope are dropped in the opposite order they are created
source code:
use std::collections::HashMap;
fn vecto() -> Vec<u32> {
let mut h = HashMap::new();
h.insert(1000, 3);
h.insert(10000, 4);
h.drain().map(|(_, v)| v).collect()
//let r = h.drain().map(|(_, v)| v).collect();
//r
}
fn main() {
let v = vecto();
println!("{:?}", v);
}
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thing