Skip to content

Commit 9e20531

Browse files
nikomatsakisbrson
authored andcommitted
---
yaml --- r: 5777 b: refs/heads/master c: 046ca82 h: refs/heads/master i: 5775: c9e51cb v: v3
1 parent d8f6cdb commit 9e20531

File tree

6 files changed

+31
-7
lines changed

6 files changed

+31
-7
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 29584cc5ac9369a18d1082d3d2c95eb0471a64db
2+
refs/heads/master: 046ca827dd02ca6e9b18264bfe5ffb8d30f77b47

trunk/src/comp/middle/typeck.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,10 +1552,12 @@ fn require_pure_call(ccx: @crate_ctxt, caller_purity: ast::purity,
15521552
ccx.tcx.sess.span_fatal
15531553
(sp, "safe function calls function marked unsafe");
15541554
}
1555-
//some(ast::def_native_fn(_)) {
1556-
// ccx.tcx.sess.span_fatal
1557-
// (sp, "native functions can only be invoked from unsafe code");
1558-
//}
1555+
/* Temporarily disable until unsafe blocks parse!
1556+
some(ast::def_native_fn(_)) {
1557+
ccx.tcx.sess.span_fatal
1558+
(sp, "native functions can only be invoked from unsafe code");
1559+
}
1560+
*/
15591561
_ {
15601562
}
15611563
}

trunk/src/comp/syntax/parse/parser.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2165,7 +2165,8 @@ fn parse_item(p: parser, attrs: [ast::attribute]) -> option::t<@ast::item> {
21652165
let proto = parse_fn_proto(p);
21662166
ret some(parse_item_fn_or_iter(p, ast::pure_fn, proto, attrs,
21672167
ast::il_normal));
2168-
} else if eat_word(p, "unsafe") {
2168+
} else if is_word(p, "unsafe") && p.look_ahead(1u) != token::LBRACE {
2169+
p.bump();
21692170
expect_word(p, "fn");
21702171
ret some(parse_item_fn_or_iter(p, ast::unsafe_fn, ast::proto_fn,
21712172
attrs, ast::il_normal));

trunk/src/lib/vec.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ native "rust" mod rustrt {
1515

1616
/// Reserves space for `n` elements in the given vector.
1717
fn reserve<@T>(&v: [mutable? T], n: uint) {
18-
rustrt::vec_reserve_shared(v, n);
18+
//unsafe {
19+
rustrt::vec_reserve_shared(v, n);
20+
//}
1921
}
2022

2123
pure fn len<T>(v: [mutable? T]) -> uint { unchecked { rusti::vec_len(v) } }
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// -*- rust -*-
2+
// error-pattern: safe function calls function marked unsafe
3+
4+
unsafe fn f() { ret; }
5+
6+
fn main() {
7+
f();
8+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// -*- rust -*-
2+
//
3+
// See also: compile-fail/unsafe-fn-called-from-safe.rs
4+
5+
unsafe fn f() { ret; }
6+
7+
fn main() {
8+
unsafe {
9+
f();
10+
}
11+
}

0 commit comments

Comments
 (0)