diff options
| author | bors <bors@rust-lang.org> | 2015-02-24 09:33:17 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-02-24 09:33:17 +0000 |
| commit | dccdde4007c191aa8b8d9cfffb0c7d3509fa675e (patch) | |
| tree | f4493e88a229c9622daf5389616001fd48d337c2 /src/libcore | |
| parent | 0ef56da541a90c62801440702a3e3c009e5332be (diff) | |
| parent | b182cd7245a999ac702f88c89dcc28811d6fdf8a (diff) | |
| download | rust-dccdde4007c191aa8b8d9cfffb0c7d3509fa675e.tar.gz rust-dccdde4007c191aa8b8d9cfffb0c7d3509fa675e.zip | |
Auto merge of #22755 - Manishearth:rollup, r=Manishearth
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/fmt/float.rs | 22 | ||||
| -rw-r--r-- | src/libcore/fmt/mod.rs | 93 | ||||
| -rw-r--r-- | src/libcore/fmt/num.rs | 2 | ||||
| -rw-r--r-- | src/libcore/fmt/rt/v1.rs | 6 | ||||
| -rw-r--r-- | src/libcore/hash/mod.rs | 4 | ||||
| -rw-r--r-- | src/libcore/hash/sip.rs | 4 | ||||
| -rw-r--r-- | src/libcore/iter.rs | 3 | ||||
| -rw-r--r-- | src/libcore/ops.rs | 17 | ||||
| -rw-r--r-- | src/libcore/ptr.rs | 2 |
9 files changed, 81 insertions, 72 deletions
diff --git a/src/libcore/fmt/float.rs b/src/libcore/fmt/float.rs index 7f7264a0468..f92e631c1f2 100644 --- a/src/libcore/fmt/float.rs +++ b/src/libcore/fmt/float.rs @@ -40,10 +40,10 @@ pub enum ExponentFormat { pub enum SignificantDigits { /// At most the given number of digits will be printed, truncating any /// trailing zeroes. - DigMax(uint), + DigMax(usize), /// Precisely the given number of digits will be printed. - DigExact(uint) + DigExact(usize) } /// How to emit the sign of a number. @@ -240,27 +240,27 @@ pub fn float_to_str_bytes_common<T: Float, U, F>( // If reached left end of number, have to // insert additional digit: if i < 0 - || buf[i as uint] == b'-' - || buf[i as uint] == b'+' { - for j in (i as uint + 1..end).rev() { + || buf[i as usize] == b'-' + || buf[i as usize] == b'+' { + for j in (i as usize + 1..end).rev() { buf[j + 1] = buf[j]; } - buf[(i + 1) as uint] = value2ascii(1); + buf[(i + 1) as usize] = value2ascii(1); end += 1; break; } // Skip the '.' - if buf[i as uint] == b'.' { i -= 1; continue; } + if buf[i as usize] == b'.' { i -= 1; continue; } // Either increment the digit, // or set to 0 if max and carry the 1. - let current_digit = ascii2value(buf[i as uint]); + let current_digit = ascii2value(buf[i as usize]); if current_digit < (radix - 1) { - buf[i as uint] = value2ascii(current_digit+1); + buf[i as usize] = value2ascii(current_digit+1); break; } else { - buf[i as uint] = value2ascii(0); + buf[i as usize] = value2ascii(0); i -= 1; } } @@ -311,7 +311,7 @@ pub fn float_to_str_bytes_common<T: Float, U, F>( struct Filler<'a> { buf: &'a mut [u8], - end: &'a mut uint, + end: &'a mut usize, } impl<'a> fmt::Write for Filler<'a> { diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index a2c1bbc0331..0bf44dd77aa 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -110,11 +110,14 @@ pub trait Write { /// traits. #[stable(feature = "rust1", since = "1.0.0")] pub struct Formatter<'a> { - flags: uint, + #[cfg(not(stage0))] + flags: u32, + #[cfg(stage0)] + flags: usize, fill: char, align: rt::v1::Alignment, - width: Option<uint>, - precision: Option<uint>, + width: Option<usize>, + precision: Option<usize>, buf: &'a mut (Write+'a), curarg: slice::Iter<'a, ArgumentV1<'a>>, @@ -140,7 +143,7 @@ pub struct ArgumentV1<'a> { impl<'a> ArgumentV1<'a> { #[inline(never)] - fn show_uint(x: &uint, f: &mut Formatter) -> Result { + fn show_usize(x: &usize, f: &mut Formatter) -> Result { Display::fmt(x, f) } @@ -156,15 +159,22 @@ impl<'a> ArgumentV1<'a> { } } + #[cfg(stage0)] #[doc(hidden)] #[stable(feature = "rust1", since = "1.0.0")] pub fn from_uint(x: &uint) -> ArgumentV1 { - ArgumentV1::new(x, ArgumentV1::show_uint) + ArgumentV1::new(x, ArgumentV1::show_usize) + } + #[cfg(not(stage0))] + #[doc(hidden)] + #[stable(feature = "rust1", since = "1.0.0")] + pub fn from_usize(x: &usize) -> ArgumentV1 { + ArgumentV1::new(x, ArgumentV1::show_usize) } - fn as_uint(&self) -> Option<uint> { - if self.formatter as uint == ArgumentV1::show_uint as uint { - Some(unsafe { *(self.value as *const _ as *const uint) }) + fn as_usize(&self) -> Option<usize> { + if self.formatter as usize == ArgumentV1::show_usize as usize { + Some(unsafe { *(self.value as *const _ as *const usize) }) } else { None } @@ -194,7 +204,7 @@ impl<'a> Arguments<'a> { /// The `pieces` array must be at least as long as `fmt` to construct /// a valid Arguments structure. Also, any `Count` within `fmt` that is /// `CountIsParam` or `CountIsNextParam` has to point to an argument - /// created with `argumentuint`. However, failing to do so doesn't cause + /// created with `argumentusize`. However, failing to do so doesn't cause /// unsafety, but will ignore invalid . #[doc(hidden)] #[inline] #[stable(feature = "rust1", since = "1.0.0")] @@ -248,16 +258,6 @@ impl<'a> Display for Arguments<'a> { /// Format trait for the `:?` format. Useful for debugging, all types /// should implement this. -#[deprecated(since = "1.0.0", reason = "renamed to Debug")] -#[unstable(feature = "old_fmt")] -pub trait Show { - /// Formats the value using the given formatter. - #[stable(feature = "rust1", since = "1.0.0")] - fn fmt(&self, &mut Formatter) -> Result; -} - -/// Format trait for the `:?` format. Useful for debugging, all types -/// should implement this. #[stable(feature = "rust1", since = "1.0.0")] #[rustc_on_unimplemented = "`{Self}` cannot be formatted using `:?`; if it is \ defined in your crate, add `#[derive(Debug)]` or \ @@ -269,22 +269,6 @@ pub trait Debug { fn fmt(&self, &mut Formatter) -> Result; } -#[allow(deprecated)] -impl<T: Show + ?Sized> Debug for T { - #[allow(deprecated)] - fn fmt(&self, f: &mut Formatter) -> Result { Show::fmt(self, f) } -} - -/// When a value can be semantically expressed as a String, this trait may be -/// used. It corresponds to the default format, `{}`. -#[deprecated(since = "1.0.0", reason = "renamed to Display")] -#[unstable(feature = "old_fmt")] -pub trait String { - /// Formats the value using the given formatter. - #[stable(feature = "rust1", since = "1.0.0")] - fn fmt(&self, &mut Formatter) -> Result; -} - /// When a value can be semantically expressed as a String, this trait may be /// used. It corresponds to the default format, `{}`. #[rustc_on_unimplemented = "`{Self}` cannot be formatted with the default \ @@ -297,12 +281,6 @@ pub trait Display { fn fmt(&self, &mut Formatter) -> Result; } -#[allow(deprecated)] -impl<T: String + ?Sized> Display for T { - #[allow(deprecated)] - fn fmt(&self, f: &mut Formatter) -> Result { String::fmt(self, f) } -} - /// Format trait for the `o` character #[stable(feature = "rust1", since = "1.0.0")] pub trait Octal { @@ -434,15 +412,15 @@ impl<'a> Formatter<'a> { (value.formatter)(value.value, self) } - fn getcount(&mut self, cnt: &rt::v1::Count) -> Option<uint> { + fn getcount(&mut self, cnt: &rt::v1::Count) -> Option<usize> { match *cnt { rt::v1::Count::Is(n) => Some(n), rt::v1::Count::Implied => None, rt::v1::Count::Param(i) => { - self.args[i].as_uint() + self.args[i].as_usize() } rt::v1::Count::NextParam => { - self.curarg.next().and_then(|arg| arg.as_uint()) + self.curarg.next().and_then(|arg| arg.as_usize()) } } } @@ -476,12 +454,12 @@ impl<'a> Formatter<'a> { let mut sign = None; if !is_positive { sign = Some('-'); width += 1; - } else if self.flags & (1 << (FlagV1::SignPlus as uint)) != 0 { + } else if self.flags & (1 << (FlagV1::SignPlus as u32)) != 0 { sign = Some('+'); width += 1; } let mut prefixed = false; - if self.flags & (1 << (FlagV1::Alternate as uint)) != 0 { + if self.flags & (1 << (FlagV1::Alternate as u32)) != 0 { prefixed = true; width += prefix.char_len(); } @@ -511,7 +489,7 @@ impl<'a> Formatter<'a> { } // The sign and prefix goes before the padding if the fill character // is zero - Some(min) if self.flags & (1 << (FlagV1::SignAwareZeroPad as uint)) != 0 => { + Some(min) if self.flags & (1 << (FlagV1::SignAwareZeroPad as u32)) != 0 => { self.fill = '0'; try!(write_prefix(self)); self.with_padding(min - width, Alignment::Right, |f| { @@ -581,7 +559,7 @@ impl<'a> Formatter<'a> { /// Runs a callback, emitting the correct padding either before or /// afterwards depending on whether right or left alignment is requested. - fn with_padding<F>(&mut self, padding: uint, default: Alignment, + fn with_padding<F>(&mut self, padding: usize, default: Alignment, f: F) -> Result where F: FnOnce(&mut Formatter) -> Result, { @@ -627,6 +605,11 @@ impl<'a> Formatter<'a> { write(self.buf, fmt) } + #[cfg(not(stage0))] + /// Flags for formatting (packed version of rt::Flag) + #[stable(feature = "rust1", since = "1.0.0")] + pub fn flags(&self) -> u32 { self.flags } + #[cfg(stage0)] /// Flags for formatting (packed version of rt::Flag) #[stable(feature = "rust1", since = "1.0.0")] pub fn flags(&self) -> usize { self.flags } @@ -641,11 +624,11 @@ impl<'a> Formatter<'a> { /// Optionally specified integer width that the output should be #[unstable(feature = "core", reason = "method was just created")] - pub fn width(&self) -> Option<uint> { self.width } + pub fn width(&self) -> Option<usize> { self.width } /// Optionally specified precision for numeric types #[unstable(feature = "core", reason = "method was just created")] - pub fn precision(&self) -> Option<uint> { self.precision } + pub fn precision(&self) -> Option<usize> { self.precision } } #[stable(feature = "rust1", since = "1.0.0")] @@ -731,9 +714,9 @@ impl Display for char { #[stable(feature = "rust1", since = "1.0.0")] impl<T> Pointer for *const T { fn fmt(&self, f: &mut Formatter) -> Result { - f.flags |= 1 << (FlagV1::Alternate as uint); - let ret = LowerHex::fmt(&(*self as uint), f); - f.flags &= !(1 << (FlagV1::Alternate as uint)); + f.flags |= 1 << (FlagV1::Alternate as u32); + let ret = LowerHex::fmt(&(*self as u32), f); + f.flags &= !(1 << (FlagV1::Alternate as u32)); ret } } @@ -889,7 +872,7 @@ impl<'a> Debug for &'a (any::Any+'a) { #[stable(feature = "rust1", since = "1.0.0")] impl<T: Debug> Debug for [T] { fn fmt(&self, f: &mut Formatter) -> Result { - if f.flags & (1 << (FlagV1::Alternate as uint)) == 0 { + if f.flags & (1 << (FlagV1::Alternate as u32)) == 0 { try!(write!(f, "[")); } let mut is_first = true; @@ -901,7 +884,7 @@ impl<T: Debug> Debug for [T] { } try!(write!(f, "{:?}", *x)) } - if f.flags & (1 << (FlagV1::Alternate as uint)) == 0 { + if f.flags & (1 << (FlagV1::Alternate as u32)) == 0 { try!(write!(f, "]")); } Ok(()) diff --git a/src/libcore/fmt/num.rs b/src/libcore/fmt/num.rs index 1222126b5e0..0175e21c8da 100644 --- a/src/libcore/fmt/num.rs +++ b/src/libcore/fmt/num.rs @@ -214,7 +214,7 @@ macro_rules! integer { show! { $Uint with $SU } } } -integer! { int, uint, "i", "u" } +integer! { isize, usize, "i", "u" } integer! { i8, u8 } integer! { i16, u16 } integer! { i32, u32 } diff --git a/src/libcore/fmt/rt/v1.rs b/src/libcore/fmt/rt/v1.rs index 0c9bb6316e0..c35611acb81 100644 --- a/src/libcore/fmt/rt/v1.rs +++ b/src/libcore/fmt/rt/v1.rs @@ -32,8 +32,12 @@ pub struct FormatSpec { pub fill: char, #[stable(feature = "rust1", since = "1.0.0")] pub align: Alignment, + #[cfg(stage0)] #[stable(feature = "rust1", since = "1.0.0")] - pub flags: uint, + pub flags: usize, + #[cfg(not(stage0))] + #[stable(feature = "rust1", since = "1.0.0")] + pub flags: u32, #[stable(feature = "rust1", since = "1.0.0")] pub precision: Count, #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libcore/hash/mod.rs b/src/libcore/hash/mod.rs index ed48903a7c2..edc4b7e10ee 100644 --- a/src/libcore/hash/mod.rs +++ b/src/libcore/hash/mod.rs @@ -20,7 +20,7 @@ //! //! #[derive(Hash)] //! struct Person { -//! id: uint, +//! id: u32, //! name: String, //! phone: u64, //! } @@ -38,7 +38,7 @@ //! use std::hash::{hash, Hash, Hasher, SipHasher}; //! //! struct Person { -//! id: uint, +//! id: u32, //! name: String, //! phone: u64, //! } diff --git a/src/libcore/hash/sip.rs b/src/libcore/hash/sip.rs index 6f24fc70673..39bcbacdff1 100644 --- a/src/libcore/hash/sip.rs +++ b/src/libcore/hash/sip.rs @@ -34,13 +34,13 @@ use super::Hasher; pub struct SipHasher { k0: u64, k1: u64, - length: uint, // how many bytes we've processed + length: usize, // how many bytes we've processed v0: u64, // hash state v1: u64, v2: u64, v3: u64, tail: u64, // unprocessed bytes le - ntail: uint, // how many bytes in tail are valid + ntail: usize, // how many bytes in tail are valid } // sadly, these macro definitions can't appear later, diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index 2d50bbb6413..09089f2d04c 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -86,6 +86,7 @@ use usize; #[rustc_on_unimplemented = "`{Self}` is not an iterator; maybe try calling `.iter()` or a similar \ method"] pub trait Iterator { + /// The type of the elements being iterated #[stable(feature = "rust1", since = "1.0.0")] type Item; @@ -122,9 +123,11 @@ pub trait FromIterator<A> { /// Conversion into an `Iterator` #[stable(feature = "rust1", since = "1.0.0")] pub trait IntoIterator { + /// The type of the elements being iterated #[stable(feature = "rust1", since = "1.0.0")] type Item; + /// A container for iterating over elements of type Item #[stable(feature = "rust1", since = "1.0.0")] type IntoIter: Iterator<Item=Self::Item>; diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs index fbd7f840da6..c382ac46d5d 100644 --- a/src/libcore/ops.rs +++ b/src/libcore/ops.rs @@ -184,6 +184,7 @@ macro_rules! forward_ref_binop { #[lang="add"] #[stable(feature = "rust1", since = "1.0.0")] pub trait Add<RHS=Self> { + /// The resulting type after applying the `+` operator #[stable(feature = "rust1", since = "1.0.0")] type Output; @@ -237,6 +238,7 @@ add_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } #[lang="sub"] #[stable(feature = "rust1", since = "1.0.0")] pub trait Sub<RHS=Self> { + /// The resulting type after applying the `-` operator #[stable(feature = "rust1", since = "1.0.0")] type Output; @@ -290,6 +292,7 @@ sub_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } #[lang="mul"] #[stable(feature = "rust1", since = "1.0.0")] pub trait Mul<RHS=Self> { + /// The resulting type after applying the `*` operator #[stable(feature = "rust1", since = "1.0.0")] type Output; @@ -343,6 +346,7 @@ mul_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } #[lang="div"] #[stable(feature = "rust1", since = "1.0.0")] pub trait Div<RHS=Self> { + /// The resulting type after applying the `/` operator #[stable(feature = "rust1", since = "1.0.0")] type Output; @@ -396,6 +400,7 @@ div_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } #[lang="rem"] #[stable(feature = "rust1", since = "1.0.0")] pub trait Rem<RHS=Self> { + /// The resulting type after applying the `%` operator #[stable(feature = "rust1", since = "1.0.0")] type Output = Self; @@ -468,6 +473,7 @@ rem_float_impl! { f64, fmod } #[lang="neg"] #[stable(feature = "rust1", since = "1.0.0")] pub trait Neg { + /// The resulting type after applying the `-` operator #[stable(feature = "rust1", since = "1.0.0")] type Output; @@ -544,6 +550,7 @@ neg_uint_impl! { u64, i64 } #[lang="not"] #[stable(feature = "rust1", since = "1.0.0")] pub trait Not { + /// The resulting type after applying the `!` operator #[stable(feature = "rust1", since = "1.0.0")] type Output; @@ -597,6 +604,7 @@ not_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } #[lang="bitand"] #[stable(feature = "rust1", since = "1.0.0")] pub trait BitAnd<RHS=Self> { + /// The resulting type after applying the `&` operator #[stable(feature = "rust1", since = "1.0.0")] type Output; @@ -650,6 +658,7 @@ bitand_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } #[lang="bitor"] #[stable(feature = "rust1", since = "1.0.0")] pub trait BitOr<RHS=Self> { + /// The resulting type after applying the `|` operator #[stable(feature = "rust1", since = "1.0.0")] type Output; @@ -703,6 +712,7 @@ bitor_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } #[lang="bitxor"] #[stable(feature = "rust1", since = "1.0.0")] pub trait BitXor<RHS=Self> { + /// The resulting type after applying the `^` operator #[stable(feature = "rust1", since = "1.0.0")] type Output; @@ -756,6 +766,7 @@ bitxor_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } #[lang="shl"] #[stable(feature = "rust1", since = "1.0.0")] pub trait Shl<RHS> { + /// The resulting type after applying the `<<` operator #[stable(feature = "rust1", since = "1.0.0")] type Output; @@ -827,6 +838,7 @@ shl_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } #[lang="shr"] #[stable(feature = "rust1", since = "1.0.0")] pub trait Shr<RHS> { + /// The resulting type after applying the `>>` operator #[stable(feature = "rust1", since = "1.0.0")] type Output; @@ -900,6 +912,7 @@ shr_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } #[rustc_on_unimplemented = "the type `{Self}` cannot be indexed by `{Idx}`"] #[stable(feature = "rust1", since = "1.0.0")] pub trait Index<Idx: ?Sized> { + /// The returned type after indexing type Output: ?Sized; /// The method for the indexing (`Foo[Bar]`) operation @@ -1047,6 +1060,7 @@ impl<Idx: fmt::Debug> fmt::Debug for RangeTo<Idx> { #[lang="deref"] #[stable(feature = "rust1", since = "1.0.0")] pub trait Deref { + /// The resulting type after dereferencing #[stable(feature = "rust1", since = "1.0.0")] type Target: ?Sized; @@ -1122,6 +1136,7 @@ impl<'a, T: ?Sized> DerefMut for &'a mut T { #[stable(feature = "rust1", since = "1.0.0")] #[rustc_paren_sugar] pub trait Fn<Args> { + /// The returned type after the call operator is used. type Output; /// This is called when the call operator is used. @@ -1133,6 +1148,7 @@ pub trait Fn<Args> { #[stable(feature = "rust1", since = "1.0.0")] #[rustc_paren_sugar] pub trait FnMut<Args> { + /// The returned type after the call operator is used. type Output; /// This is called when the call operator is used. @@ -1144,6 +1160,7 @@ pub trait FnMut<Args> { #[stable(feature = "rust1", since = "1.0.0")] #[rustc_paren_sugar] pub trait FnOnce<Args> { + /// The returned type after the call operator is used. type Output; /// This is called when the call operator is used. diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 16b84dcf18e..b44cc899787 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -249,6 +249,7 @@ pub unsafe fn write<T>(dst: *mut T, src: T) { /// Methods on raw pointers #[stable(feature = "rust1", since = "1.0.0")] pub trait PtrExt: Sized { + /// The type which is being pointed at type Target; /// Returns true if the pointer is null. @@ -284,6 +285,7 @@ pub trait PtrExt: Sized { /// Methods on mutable raw pointers #[stable(feature = "rust1", since = "1.0.0")] pub trait MutPtrExt { + /// The type which is being pointed at type Target; /// Returns `None` if the pointer is null, or else returns a mutable |
