accommodate new scoping rules in test/compile-fail.

This commit is contained in:
Felix S. Klock II 2015-01-26 15:21:24 +01:00
parent 9fe8d8602d
commit 70192ab779
2 changed files with 4 additions and 3 deletions

View File

@ -16,10 +16,11 @@ extern crate collections;
use std::collections::HashMap;
fn main() {
let tmp;
let mut buggy_map: HashMap<usize, &usize> = HashMap::new();
buggy_map.insert(42, &*box 1); //~ ERROR borrowed value does not live long enough
// but it is ok if we use a temporary
let tmp = box 2;
tmp = box 2;
buggy_map.insert(43, &*tmp);
}

View File

@ -13,16 +13,16 @@
use std::cell::RefCell;
fn main() {
let c = RefCell::new(vec![]);
let mut y = 1us;
let c = RefCell::new(vec![]);
c.push(box || y = 0);
c.push(box || y = 0);
//~^ ERROR cannot borrow `y` as mutable more than once at a time
}
fn ufcs() {
let c = RefCell::new(vec![]);
let mut y = 1us;
let c = RefCell::new(vec![]);
Push::push(&c, box || y = 0);
Push::push(&c, box || y = 0);