]> git.lizzy.rs Git - rust.git/blob - tests/ui/borrowck/borrowck-borrowed-uniq-rvalue.rs
Rollup merge of #106726 - cmorin6:fix-comment-typos, r=Nilstrieb
[rust.git] / tests / ui / borrowck / borrowck-borrowed-uniq-rvalue.rs
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     buggy_map.insert(42, &*Box::new(1)); //~ ERROR temporary value dropped while borrowed
9
10     // but it is ok if we use a temporary
11     tmp = Box::new(2);
12     buggy_map.insert(43, &*tmp);
13 }