diff options
Diffstat (limited to 'tests/ui/hashmap/hashmap-iter-value-lifetime.rs')
-rw-r--r-- | tests/ui/hashmap/hashmap-iter-value-lifetime.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/ui/hashmap/hashmap-iter-value-lifetime.rs b/tests/ui/hashmap/hashmap-iter-value-lifetime.rs new file mode 100644 index 000000000..260ea8c7a --- /dev/null +++ b/tests/ui/hashmap/hashmap-iter-value-lifetime.rs @@ -0,0 +1,10 @@ +fn main() { + let mut my_stuff = std::collections::HashMap::new(); + my_stuff.insert(0, 42); + + let (_, thing) = my_stuff.iter().next().unwrap(); + + my_stuff.clear(); //~ ERROR cannot borrow + + println!("{}", *thing); +} |