mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 23:12:02 +00:00
accommodate new scoping rules in test/compile-fail.
This commit is contained in:
parent
9fe8d8602d
commit
70192ab779
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user