diff options
| author | bors <bors@rust-lang.org> | 2014-09-29 17:18:07 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-09-29 17:18:07 +0000 |
| commit | 1f3cda8bd8496c3b3771b0201d1073ed575321d0 (patch) | |
| tree | 0acaf08d99d544c93df6f688fa96ce40e747588f /src/libcore | |
| parent | 5079a10b1e9d87fa0b0d50f1456f920b1ba8323c (diff) | |
| parent | d3e171861f0fd8f3a61ad28d70f675ea9dc712b8 (diff) | |
| download | rust-1f3cda8bd8496c3b3771b0201d1073ed575321d0.tar.gz rust-1f3cda8bd8496c3b3771b0201d1073ed575321d0.zip | |
auto merge of #17629 : alexcrichton/rust/rollup, r=alexcrichton
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/failure.rs | 30 | ||||
| -rw-r--r-- | src/libcore/iter.rs | 4 | ||||
| -rw-r--r-- | src/libcore/macros.rs | 4 | ||||
| -rw-r--r-- | src/libcore/ops.rs | 8 | ||||
| -rw-r--r-- | src/libcore/option.rs | 2 | ||||
| -rw-r--r-- | src/libcore/raw.rs | 8 | ||||
| -rw-r--r-- | src/libcore/str.rs | 23 |
7 files changed, 38 insertions, 41 deletions
diff --git a/src/libcore/failure.rs b/src/libcore/failure.rs index f5f45b2f72e..9b63d325bc8 100644 --- a/src/libcore/failure.rs +++ b/src/libcore/failure.rs @@ -33,24 +33,9 @@ use fmt; use intrinsics; -// NOTE: remove after next snapshot -#[cfg(stage0)] -#[cold] #[inline(never)] // this is the slow path, always -#[lang="fail_"] -fn fail_(expr_file_line: &(&'static str, &'static str, uint)) -> ! { - let (expr, file, line) = *expr_file_line; - let ref file_line = (file, line); - format_args!(|args| -> () { - fail_fmt(args, file_line); - }, "{}", expr); - - unsafe { intrinsics::abort() } -} - -#[cfg(not(stage0))] #[cold] #[inline(never)] // this is the slow path, always #[lang="fail"] -fn fail(expr_file_line: &(&'static str, &'static str, uint)) -> ! { +pub fn fail(expr_file_line: &(&'static str, &'static str, uint)) -> ! { let (expr, file, line) = *expr_file_line; let ref file_line = (file, line); format_args!(|args| -> () { @@ -71,22 +56,9 @@ fn fail_bounds_check(file_line: &(&'static str, uint), } #[cold] #[inline(never)] -pub fn fail_str(msg: &str, file: &(&'static str, uint)) -> ! { - format_args!(|fmt| fail_fmt(fmt, file), "{}", msg) -} - -#[cold] #[inline(never)] pub fn fail_fmt(fmt: &fmt::Arguments, file_line: &(&'static str, uint)) -> ! { #[allow(ctypes)] extern { - - // NOTE: remove after next snapshot - #[cfg(stage0)] - #[lang = "begin_unwind"] - fn fail_impl(fmt: &fmt::Arguments, file: &'static str, - line: uint) -> !; - - #[cfg(not(stage0))] #[lang = "fail_fmt"] fn fail_impl(fmt: &fmt::Arguments, file: &'static str, line: uint) -> !; diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index f78c8c2aa0e..9799e9d3980 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -366,7 +366,7 @@ pub trait Iterator<A> { /// let mut sum = 0; /// for x in it { /// if x > 5 { - /// continue; + /// break; /// } /// sum += x; /// } @@ -377,6 +377,8 @@ pub trait Iterator<A> { /// sum /// } /// let x = vec![1i,2,3,7,8,9]; + /// assert_eq!(process(x.into_iter()), 6); + /// let x = vec![1i,2,3]; /// assert_eq!(process(x.into_iter()), 1006); /// ``` #[inline] diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs index 0f972a67029..17fcf025457 100644 --- a/src/libcore/macros.rs +++ b/src/libcore/macros.rs @@ -17,8 +17,8 @@ macro_rules! fail( fail!("{}", "explicit failure") ); ($msg:expr) => ({ - static _FILE_LINE: (&'static str, uint) = (file!(), line!()); - ::core::failure::fail_str($msg, &_FILE_LINE) + static _MSG_FILE_LINE: (&'static str, &'static str, uint) = ($msg, file!(), line!()); + ::core::failure::fail(&_MSG_FILE_LINE) }); ($fmt:expr, $($arg:tt)*) => ({ // a closure can't have return type !, so we need a full diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs index 718d3119995..ad0f128a02e 100644 --- a/src/libcore/ops.rs +++ b/src/libcore/ops.rs @@ -764,13 +764,13 @@ pub trait Slice<Idx, Sized? Result> for Sized? { // FIXME(#17273) remove the postscript _s #[lang="slice_mut"] pub trait SliceMut<Idx, Sized? Result> for Sized? { - /// The method for the slicing operation foo[] + /// The method for the slicing operation foo[mut] fn as_mut_slice_<'a>(&'a mut self) -> &'a mut Result; - /// The method for the slicing operation foo[from..] + /// The method for the slicing operation foo[mut from..] fn slice_from_mut_<'a>(&'a mut self, from: &Idx) -> &'a mut Result; - /// The method for the slicing operation foo[..to] + /// The method for the slicing operation foo[mut ..to] fn slice_to_mut_<'a>(&'a mut self, to: &Idx) -> &'a mut Result; - /// The method for the slicing operation foo[from..to] + /// The method for the slicing operation foo[mut from..to] fn slice_mut_<'a>(&'a mut self, from: &Idx, to: &Idx) -> &'a mut Result; } /** diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 77fe55aadee..1e353708730 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -312,7 +312,7 @@ impl<T> Option<T> { pub fn expect(self, msg: &str) -> T { match self { Some(val) => val, - None => fail!(msg), + None => fail!("{}", msg), } } diff --git a/src/libcore/raw.rs b/src/libcore/raw.rs index 188ef2a3b88..86b96ff15f1 100644 --- a/src/libcore/raw.rs +++ b/src/libcore/raw.rs @@ -20,12 +20,12 @@ use mem; -/// The representation of a Rust managed box -pub struct Box<T> { +/// The representation of `std::gc::Gc`. +pub struct GcBox<T> { pub ref_count: uint, pub drop_glue: fn(ptr: *mut u8), - pub prev: *mut Box<T>, - pub next: *mut Box<T>, + pub prev: *mut GcBox<T>, + pub next: *mut GcBox<T>, pub data: T, } diff --git a/src/libcore/str.rs b/src/libcore/str.rs index 7e399902a4b..343b8e0b64b 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -1123,6 +1123,7 @@ pub mod traits { use collections::Collection; use iter::Iterator; use option::{Option, Some}; + use ops; use str::{Str, StrSlice, eq_slice}; impl<'a> Ord for &'a str { @@ -1162,6 +1163,28 @@ pub mod traits { #[inline] fn equiv(&self, other: &S) -> bool { eq_slice(*self, other.as_slice()) } } + + impl ops::Slice<uint, str> for str { + #[inline] + fn as_slice_<'a>(&'a self) -> &'a str { + self + } + + #[inline] + fn slice_from_<'a>(&'a self, from: &uint) -> &'a str { + self.slice_from(*from) + } + + #[inline] + fn slice_to_<'a>(&'a self, to: &uint) -> &'a str { + self.slice_to(*to) + } + + #[inline] + fn slice_<'a>(&'a self, from: &uint, to: &uint) -> &'a str { + self.slice(*from, *to) + } + } } /// Any string that can be represented as a slice |
