Skip to content

Commit

Permalink
forgotten tests for #3217, #2977, #3067
Browse files Browse the repository at this point in the history
  • Loading branch information
nikomatsakis committed Aug 18, 2012
1 parent 4b1d83c commit fcb055e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/test/compile-fail/borrowck-borrowed-uniq-rvalue-2.rs
Original file line number Diff line number Diff line change
@@ -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
}
13 changes: 13 additions & 0 deletions src/test/compile-fail/borrowck-borrowed-uniq-rvalue.rs
Original file line number Diff line number Diff line change
@@ -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);
}
11 changes: 11 additions & 0 deletions src/test/compile-fail/borrowck-ref-into-rvalue.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
fn main() {
let msg;
match some(~"Hello") { //~ ERROR illegal borrow
some(ref m) => {
msg = m;
},
none => { fail }
}
io::println(*msg);
}

0 comments on commit fcb055e

Please sign in to comment.