forgotten tests for #3217, #2977, #3067

This commit is contained in:
Niko Matsakis 2012-08-17 17:30:29 -07:00
parent 4b1d83ca64
commit fcb055ef7e
3 changed files with 33 additions and 0 deletions

View file

@ -0,0 +1,9 @@
struct defer {
x: &[&str];
new(x: &[&str]) { self.x = x; }
drop { #error["%?", self.x]; }
}
fn main() {
let _x = defer(~["Goodbye", "world!"]); //~ ERROR illegal borrow
}

View file

@ -0,0 +1,13 @@
//buggy.rs
use std;
import std::map::hashmap;
import std::map;
fn main() {
let buggy_map :hashmap<uint, &uint> = hashmap::<uint, &uint>(uint::hash, uint::eq);
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);
}

View file

@ -0,0 +1,11 @@
fn main() {
let msg;
match some(~"Hello") { //~ ERROR illegal borrow
some(ref m) => {
msg = m;
},
none => { fail }
}
io::println(*msg);
}