Skip to content

Commit ca1d3a2

Browse files
committed
---
yaml --- r: 36651 b: refs/heads/try2 c: 3fcdb7d h: refs/heads/master i: 36649: db4ab17 36647: deff816 v: v3
1 parent 3d38d19 commit ca1d3a2

File tree

9 files changed

+67
-23
lines changed

9 files changed

+67
-23
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: eb8fd119c65c67f3b1b8268cc7341c22d39b7b61
55
refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: ed686aeac4c717a85175a0f3b63d3ff50c2f50a7
8+
refs/heads/try2: 3fcdb7d6a758ac4ed1f27fcda77c372edaab4c09
99
refs/heads/incoming: d9317a174e434d4c99fc1a37fd7dc0d2f5328d37
1010
refs/heads/dist-snap: 22efa39382d41b084fde1719df7ae8ce5697d8c9
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try2/src/libcore/rt.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ use gc::{cleanup_stack_for_failure, gc, Word};
2626
pub type rust_task = c_void;
2727

2828
extern mod rustrt {
29-
#[rust_stack]
30-
fn rust_upcall_fail(expr: *c_char, file: *c_char, line: size_t);
31-
3229
#[rust_stack]
3330
fn rust_upcall_exchange_malloc(td: *c_char, size: uintptr_t) -> *c_char;
3431

@@ -47,11 +44,7 @@ extern mod rustrt {
4744
// gather_rust_rtcalls.
4845
#[rt(fail_)]
4946
pub fn rt_fail_(expr: *c_char, file: *c_char, line: size_t) -> ! {
50-
unsafe {
51-
cleanup_stack_for_failure();
52-
rustrt::rust_upcall_fail(expr, file, line);
53-
cast::transmute(())
54-
}
47+
sys::begin_unwind_(expr, file, line);
5548
}
5649

5750
#[rt(fail_bounds_check)]

branches/try2/src/libcore/sys.rs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#[forbid(deprecated_pattern)];
1616

1717
use cmp::{Eq, Ord};
18-
use libc::c_void;
18+
use libc::{c_void, c_char, size_t};
1919

2020
pub type FreeGlue = fn(*TypeDesc, *c_void);
2121

@@ -43,6 +43,11 @@ extern mod rusti {
4343
fn min_align_of<T>() -> uint;
4444
}
4545

46+
extern mod rustrt {
47+
#[rust_stack]
48+
fn rust_upcall_fail(expr: *c_char, file: *c_char, line: size_t);
49+
}
50+
4651
/// Compares contents of two pointers using the default method.
4752
/// Equivalent to `*x1 == *x2`. Useful for hashtables.
4853
pub pure fn shape_eq<T:Eq>(x1: &T, x2: &T) -> bool {
@@ -108,6 +113,28 @@ pub pure fn log_str<T>(t: &T) -> ~str {
108113
}
109114
}
110115

116+
/** Initiate task failure */
117+
pub pure fn begin_unwind(msg: ~str, file: ~str, line: uint) -> ! {
118+
do str::as_buf(msg) |msg_buf, _msg_len| {
119+
do str::as_buf(file) |file_buf, _file_len| {
120+
unsafe {
121+
let msg_buf = cast::transmute(msg_buf);
122+
let file_buf = cast::transmute(file_buf);
123+
begin_unwind_(msg_buf, file_buf, line as libc::size_t)
124+
}
125+
}
126+
}
127+
}
128+
129+
// XXX: Temorary until rt::rt_fail_ goes away
130+
pub pure fn begin_unwind_(msg: *c_char, file: *c_char, line: size_t) -> ! {
131+
unsafe {
132+
gc::cleanup_stack_for_failure();
133+
rustrt::rust_upcall_fail(msg, file, line);
134+
cast::transmute(())
135+
}
136+
}
137+
111138
#[cfg(test)]
112139
pub mod tests {
113140

branches/try2/src/libsyntax/ext/expand.rs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -378,21 +378,10 @@ fn core_macros() -> ~str {
378378

379379
macro_rules! die(
380380
($msg: expr) => (
381-
{
382-
do core::str::as_buf($msg) |msg_buf, _msg_len| {
383-
do core::str::as_buf(file!()) |file_buf, _file_len| {
384-
unsafe {
385-
let msg_buf = core::cast::transmute(msg_buf);
386-
let file_buf = core::cast::transmute(file_buf);
387-
let line = line!() as core::libc::size_t;
388-
core::rt::rt_fail_(msg_buf, file_buf, line)
389-
}
390-
}
391-
}
392-
}
381+
core::sys::begin_unwind($msg, file!(), line!())
393382
);
394383
() => (
395-
die!(\"explicit failure\")
384+
die!(~\"explicit failure\")
396385
)
397386
)
398387
}";
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// error-pattern:mismatched types
2+
3+
fn main() {
4+
die!("test");
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// error-pattern:test
2+
3+
fn main() {
4+
let i: int = die!(~"test");
5+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// error-pattern:test
2+
3+
pure fn f() {
4+
die!(~"test");
5+
}
6+
7+
fn main() {
8+
f();
9+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// error-pattern:test
2+
3+
fn main() {
4+
die!(~"test");
5+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Just testing that die!() type checks in statement or expr
2+
3+
fn f() {
4+
die!();
5+
6+
let x: int = die!();
7+
}
8+
9+
fn main() {
10+
11+
}

0 commit comments

Comments
 (0)