-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move purity checking into borrowck, addresses #1422
- Loading branch information
1 parent
2585384
commit 63eb8e0
Showing
7 changed files
with
203 additions
and
88 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
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
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
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 |
---|---|---|
@@ -1,11 +1,12 @@ | ||
// -*- rust -*- | ||
// error-pattern: safe function calls function marked unsafe | ||
|
||
#[abi = "cdecl"] | ||
native mod test { | ||
unsafe fn free(); | ||
} | ||
|
||
fn main() { | ||
test::free(); | ||
//!^ ERROR access to unsafe function requires unsafe function or block | ||
} | ||
|
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,18 @@ | ||
// Check that pure functions cannot modify aliased state. | ||
|
||
pure fn modify_in_ref(&&sum: {mut f: int}) { | ||
sum.f = 3; //! ERROR assigning to mutable field prohibited in pure functions | ||
} | ||
|
||
pure fn modify_in_box(sum: @mut {f: int}) { | ||
sum.f = 3; //! ERROR assigning to mutable field prohibited in pure functions | ||
} | ||
|
||
impl foo for int { | ||
pure fn modify_in_box_rec(sum: @{mut f: int}) { | ||
sum.f = self; //! ERROR assigning to mutable field prohibited in pure functions | ||
} | ||
} | ||
|
||
fn main() { | ||
} |
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 |
---|---|---|
@@ -1,8 +1,7 @@ | ||
// -*- rust -*- | ||
// error-pattern: safe function calls function marked unsafe | ||
|
||
unsafe fn f() { ret; } | ||
|
||
fn main() { | ||
f(); | ||
f(); //! ERROR access to unsafe function requires unsafe function or block | ||
} |
Oops, something went wrong.