-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
4b1d83c
commit fcb055e
Showing
3 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|