]> git.proxmox.com Git - rustc.git/blob - src/test/compile-fail/borrowck-borrowed-uniq-rvalue.rs
9c10f01e027557c7e9885d43574a62044cc5f27a
[rustc.git] / src / test / compile-fail / borrowck-borrowed-uniq-rvalue.rs
1 // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 //buggy.rs
12
13 #![feature(box_syntax)]
14
15 extern crate collections;
16 use std::collections::HashMap;
17
18 fn main() {
19 let tmp;
20 let mut buggy_map: HashMap<usize, &usize> = HashMap::new();
21 buggy_map.insert(42, &*box 1); //~ ERROR borrowed value does not live long enough
22
23 // but it is ok if we use a temporary
24 tmp = box 2;
25 buggy_map.insert(43, &*tmp);
26 }