rust/src/test/compile-fail/borrowck-borrowed-uniq-rvalue.rs

15 lines
304 B
Rust
Raw Normal View History

//buggy.rs
extern mod std;
2012-09-10 17:38:28 -05:00
use std::map::HashMap;
2012-09-05 14:32:05 -05:00
use std::map;
fn main() {
2012-09-10 17:38:28 -05:00
let buggy_map :HashMap<uint, &uint> =
HashMap::<uint, &uint>();
buggy_map.insert(42, ~1); //~ ERROR illegal borrow
// but it is ok if we use a temporary
let tmp = ~2;
buggy_map.insert(43, tmp);
}