parent
4b1d83ca64
commit
fcb055ef7e
3 changed files with 33 additions and 0 deletions
9
src/test/compile-fail/borrowck-borrowed-uniq-rvalue-2.rs
Normal file
9
src/test/compile-fail/borrowck-borrowed-uniq-rvalue-2.rs
Normal 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
|
||||
}
|
13
src/test/compile-fail/borrowck-borrowed-uniq-rvalue.rs
Normal file
13
src/test/compile-fail/borrowck-borrowed-uniq-rvalue.rs
Normal 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);
|
||||
}
|
11
src/test/compile-fail/borrowck-ref-into-rvalue.rs
Normal file
11
src/test/compile-fail/borrowck-ref-into-rvalue.rs
Normal 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);
|
||||
}
|
||||
|
Loading…
Add table
Reference in a new issue