diff options
Diffstat (limited to 'src/libstd/rt')
| -rw-r--r-- | src/libstd/rt/args.rs | 1 | ||||
| -rw-r--r-- | src/libstd/rt/env.rs | 2 | ||||
| -rw-r--r-- | src/libstd/rt/mod.rs | 2 | ||||
| -rw-r--r-- | src/libstd/rt/task.rs | 2 | ||||
| -rw-r--r-- | src/libstd/rt/unwind.rs | 42 |
5 files changed, 14 insertions, 35 deletions
diff --git a/src/libstd/rt/args.rs b/src/libstd/rt/args.rs index 17e6f6b7698..ac1692e6bb3 100644 --- a/src/libstd/rt/args.rs +++ b/src/libstd/rt/args.rs @@ -70,7 +70,6 @@ mod imp { use owned::Box; use unstable::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT}; use mem; - #[cfg(not(test))] use str::StrSlice; #[cfg(not(test))] use ptr::RawPtr; static mut global_args_ptr: uint = 0; diff --git a/src/libstd/rt/env.rs b/src/libstd/rt/env.rs index 94f56d42613..708c42030ab 100644 --- a/src/libstd/rt/env.rs +++ b/src/libstd/rt/env.rs @@ -11,7 +11,7 @@ //! Runtime environment settings use from_str::from_str; -use option::{Some, None}; +use option::{Some, None, Expect}; use os; // Note that these are all accessed without any synchronization. diff --git a/src/libstd/rt/mod.rs b/src/libstd/rt/mod.rs index e79e3056838..5b9c314d42b 100644 --- a/src/libstd/rt/mod.rs +++ b/src/libstd/rt/mod.rs @@ -70,7 +70,7 @@ use self::task::{Task, BlockedTask}; pub use self::util::default_sched_threads; // Export unwinding facilities used by the failure macros -pub use self::unwind::{begin_unwind, begin_unwind_raw, begin_unwind_fmt}; +pub use self::unwind::{begin_unwind, begin_unwind_fmt}; pub use self::util::{Stdio, Stdout, Stderr}; diff --git a/src/libstd/rt/task.rs b/src/libstd/rt/task.rs index 5b29de5a8c1..909df5618aa 100644 --- a/src/libstd/rt/task.rs +++ b/src/libstd/rt/task.rs @@ -436,7 +436,7 @@ mod test { #[test] fn rng() { use rand::{StdRng, Rng}; - let mut r = StdRng::new().unwrap(); + let mut r = StdRng::new().ok().unwrap(); let _ = r.next_u32(); } diff --git a/src/libstd/rt/unwind.rs b/src/libstd/rt/unwind.rs index 3ba97f381ab..5f3731eb819 100644 --- a/src/libstd/rt/unwind.rs +++ b/src/libstd/rt/unwind.rs @@ -58,7 +58,6 @@ // Currently Rust uses unwind runtime provided by libgcc. use any::{Any, AnyRefExt}; -use c_str::CString; use cast; use fmt; use kinds::Send; @@ -298,42 +297,23 @@ pub mod eabi { } #[cold] -#[lang="fail_"] +#[no_mangle] #[cfg(not(test))] -pub fn fail_(expr: *u8, file: *u8, line: uint) -> ! { - begin_unwind_raw(expr, file, line); -} - -#[cold] -#[lang="fail_bounds_check"] -#[cfg(not(test))] -pub fn fail_bounds_check(file: *u8, line: uint, index: uint, len: uint) -> ! { - use c_str::ToCStr; +pub extern fn rust_fail_bounds_check(file: *u8, line: uint, + index: uint, len: uint) -> ! { + use str::raw::c_str_to_static_slice; let msg = format!("index out of bounds: the len is {} but the index is {}", len as uint, index as uint); - msg.with_c_str(|buf| fail_(buf as *u8, file, line)) + begin_unwind(msg, unsafe { c_str_to_static_slice(file as *i8) }, line) } -/// This is the entry point of unwinding for things like lang items and such. -/// The arguments are normally generated by the compiler, and need to -/// have static lifetimes. -#[inline(never)] #[cold] // this is the slow path, please never inline this -pub fn begin_unwind_raw(msg: *u8, file: *u8, line: uint) -> ! { - use libc::c_char; - #[inline] - fn static_char_ptr(p: *u8) -> &'static str { - let s = unsafe { CString::new(p as *c_char, false) }; - match s.as_str() { - Some(s) => unsafe { cast::transmute::<&str, &'static str>(s) }, - None => rtabort!("message wasn't utf8?") - } - } - - let msg = static_char_ptr(msg); - let file = static_char_ptr(file); - - begin_unwind(msg, file, line as uint) +// Entry point of failure from the libcore crate +#[no_mangle] +#[cfg(not(test))] +pub extern fn rust_begin_unwind(msg: &str, file: &'static str, line: uint) -> ! { + use str::StrAllocating; + begin_unwind(msg.to_owned(), file, line) } /// The entry point for unwinding with a formatted message. |
