]> git.lizzy.rs Git - rust.git/blob - tests/ui/borrowck/borrowck-borrowed-uniq-rvalue.fixed
Auto merge of #106646 - Amanieu:ilp32-object, r=Mark-Simulacrum
[rust.git] / tests / ui / borrowck / borrowck-borrowed-uniq-rvalue.fixed
1 // run-rustfix
2
3 use std::collections::HashMap;
4
5 fn main() {
6     let tmp: Box<_>;
7     let mut buggy_map: HashMap<usize, &usize> = HashMap::new();
8     let binding = Box::new(1);
9     buggy_map.insert(42, &*binding); //~ ERROR temporary value dropped while borrowed
10
11     // but it is ok if we use a temporary
12     tmp = Box::new(2);
13     buggy_map.insert(43, &*tmp);
14 }