auto merge of #18070 : alexcrichton/rust/spring-cleaning, r=aturon

This is a large spring-cleaning commit now that the 0.12.0 release has passed removing an amount of deprecated functionality. This removes a number of deprecated crates (all still available as cargo packages in the rust-lang organization) as well as a slew of deprecated functions. All `#[crate_id]` support has also been removed.

I tried to avoid anything that was recently deprecated, but I may have missed something! The major pain points of this commit is the fact that rustc/syntax have `#[allow(deprecated)]`, but I've removed that annotation so moving forward they should be cleaned up as we go.
This commit is contained in:
bors 2014-10-20 16:07:43 +00:00
commit 7d0cc44f87
355 changed files with 1364 additions and 12821 deletions

View file

@ -333,29 +333,6 @@ pub fn to_str_exp_digits(num: f32, dig: uint, upper: bool) -> String {
r
}
impl num::ToStrRadix for f32 {
/// Converts a float to a string in a given radix
///
/// # Arguments
///
/// * num - The float value
/// * radix - The base to use
///
/// # Failure
///
/// Fails if called on a special value like `inf`, `-inf` or `NaN` due to
/// possible misinterpretation of the result at higher bases. If those values
/// are expected, use `to_str_radix_special()` instead.
#[inline]
fn to_str_radix(&self, rdx: uint) -> String {
let (r, special) = strconv::float_to_str_common(
*self, rdx, true, strconv::SignNeg, strconv::DigAll, strconv::ExpNone, false);
if special { fail!("number has a special value, \
try to_str_radix_special() if those are expected") }
r
}
}
/// Convert a string in base 16 to a float.
/// Accepts an optional binary exponent.
///

View file

@ -341,29 +341,6 @@ pub fn to_str_exp_digits(num: f64, dig: uint, upper: bool) -> String {
r
}
impl num::ToStrRadix for f64 {
/// Converts a float to a string in a given radix
///
/// # Arguments
///
/// * num - The float value
/// * radix - The base to use
///
/// # Failure
///
/// Fails if called on a special value like `inf`, `-inf` or `NAN` due to
/// possible misinterpretation of the result at higher bases. If those values
/// are expected, use `to_str_radix_special()` instead.
#[inline]
fn to_str_radix(&self, rdx: uint) -> String {
let (r, special) = strconv::float_to_str_common(
*self, rdx, true, strconv::SignNeg, strconv::DigAll, strconv::ExpNone, false);
if special { fail!("number has a special value, \
try to_str_radix_special() if those are expected") }
r
}
}
/// Convert a string in base 16 to a float.
/// Accepts an optional binary exponent.
///

View file

@ -14,10 +14,9 @@
#![doc(primitive = "i16")]
use from_str::FromStr;
use num::{ToStrRadix, FromStrRadix};
use num::FromStrRadix;
use num::strconv;
use option::Option;
use string::String;
pub use core::i16::{BITS, BYTES, MIN, MAX};

View file

@ -14,10 +14,9 @@
#![doc(primitive = "i32")]
use from_str::FromStr;
use num::{ToStrRadix, FromStrRadix};
use num::FromStrRadix;
use num::strconv;
use option::Option;
use string::String;
pub use core::i32::{BITS, BYTES, MIN, MAX};

View file

@ -14,10 +14,9 @@
#![doc(primitive = "i64")]
use from_str::FromStr;
use num::{ToStrRadix, FromStrRadix};
use num::FromStrRadix;
use num::strconv;
use option::Option;
use string::String;
pub use core::i64::{BITS, BYTES, MIN, MAX};

View file

@ -14,10 +14,9 @@
#![doc(primitive = "i8")]
use from_str::FromStr;
use num::{ToStrRadix, FromStrRadix};
use num::FromStrRadix;
use num::strconv;
use option::Option;
use string::String;
pub use core::i8::{BITS, BYTES, MIN, MAX};

View file

@ -14,10 +14,9 @@
#![doc(primitive = "int")]
use from_str::FromStr;
use num::{ToStrRadix, FromStrRadix};
use num::FromStrRadix;
use num::strconv;
use option::Option;
use string::String;
pub use core::int::{BITS, BYTES, MIN, MAX};

View file

@ -51,52 +51,12 @@ impl FromStrRadix for $T {
}
}
// String conversion functions and impl num -> str
/// Convert to a string as a byte slice in a given base.
///
/// Use in place of x.to_string() when you do not need to store the string permanently
///
/// # Examples
///
/// ```
/// #![allow(deprecated)]
///
/// std::int::to_str_bytes(123, 10, |v| {
/// assert!(v == "123".as_bytes());
/// });
/// ```
#[inline]
#[deprecated = "just use .to_string(), or a BufWriter with write! if you mustn't allocate"]
pub fn to_str_bytes<U>(n: $T, radix: uint, f: |v: &[u8]| -> U) -> U {
use io::{Writer, Seek};
// The radix can be as low as 2, so we need at least 64 characters for a
// base 2 number, and then we need another for a possible '-' character.
let mut buf = [0u8, ..65];
let amt = {
let mut wr = ::io::BufWriter::new(buf);
(write!(&mut wr, "{}", ::fmt::radix(n, radix as u8))).unwrap();
wr.tell().unwrap() as uint
};
f(buf[..amt])
}
#[deprecated = "use fmt::radix"]
impl ToStrRadix for $T {
/// Convert to a string in a given base.
#[inline]
fn to_str_radix(&self, radix: uint) -> String {
format!("{}", ::fmt::radix(*self, radix as u8))
}
}
#[cfg(test)]
mod tests {
use prelude::*;
use super::*;
use i32;
use num::ToStrRadix;
use str::StrSlice;
#[test]
@ -142,16 +102,6 @@ mod tests {
assert!(parse_bytes("-9".as_bytes(), 2u).is_none());
}
#[test]
fn test_to_string() {
assert_eq!((0 as $T).to_str_radix(10u), "0".to_string());
assert_eq!((1 as $T).to_str_radix(10u), "1".to_string());
assert_eq!((-1 as $T).to_str_radix(10u), "-1".to_string());
assert_eq!((127 as $T).to_str_radix(16u), "7f".to_string());
assert_eq!((100 as $T).to_str_radix(10u), "100".to_string());
}
#[test]
fn test_int_to_str_overflow() {
let mut i8_val: i8 = 127_i8;

View file

@ -17,7 +17,6 @@
#![allow(missing_doc)]
use option::Option;
use string::String;
#[cfg(test)] use fmt::Show;
@ -111,12 +110,6 @@ pub trait FloatMath: Float {
fn atanh(self) -> Self;
}
/// A generic trait for converting a value to a string with a radix (base)
#[deprecated = "use fmt::radix"]
pub trait ToStrRadix {
fn to_str_radix(&self, radix: uint) -> String;
}
/// A generic trait for converting a string with a radix (base) to a value
#[experimental = "might need to return Result"]
pub trait FromStrRadix {

View file

@ -20,7 +20,7 @@ use num::{Float, FPNaN, FPInfinite, ToPrimitive};
use num;
use ops::{Add, Sub, Mul, Div, Rem, Neg};
use option::{None, Option, Some};
use slice::{ImmutableSlice, MutableSlice};
use slice::{ImmutableSlice, MutableSlice, CloneableVector};
use std::cmp::{PartialOrd, PartialEq};
use str::StrSlice;
use string::String;
@ -168,8 +168,7 @@ static NAN_BUF: [u8, ..3] = [b'N', b'a', b'N'];
* # Failure
* - Fails if `radix` < 2 or `radix` > 36.
*/
#[deprecated = "format!() and friends should be favored instead"]
pub fn int_to_str_bytes_common<T: Int>(num: T, radix: uint, sign: SignFormat, f: |u8|) {
fn int_to_str_bytes_common<T: Int>(num: T, radix: uint, sign: SignFormat, f: |u8|) {
assert!(2 <= radix && radix <= 36);
let _0: T = Zero::zero();
@ -257,7 +256,6 @@ pub fn int_to_str_bytes_common<T: Int>(num: T, radix: uint, sign: SignFormat, f:
* - Fails if `radix` > 25 and `exp_format` is `ExpBin` due to conflict
* between digit and exponent sign `'p'`.
*/
#[allow(deprecated)]
pub fn float_to_str_bytes_common<T:NumCast+Zero+One+PartialEq+PartialOrd+Float+
Div<T,T>+Neg<T>+Rem<T,T>+Mul<T,T>>(
num: T, radix: uint, negative_zero: bool,
@ -278,17 +276,17 @@ pub fn float_to_str_bytes_common<T:NumCast+Zero+One+PartialEq+PartialOrd+Float+
let _1: T = One::one();
match num.classify() {
FPNaN => { return (Vec::from_slice("NaN".as_bytes()), true); }
FPNaN => { return (b"NaN".to_vec(), true); }
FPInfinite if num > _0 => {
return match sign {
SignAll => (Vec::from_slice("+inf".as_bytes()), true),
_ => (Vec::from_slice("inf".as_bytes()), true)
SignAll => (b"+inf".to_vec(), true),
_ => (b"inf".to_vec(), true)
};
}
FPInfinite if num < _0 => {
return match sign {
SignNone => (Vec::from_slice("inf".as_bytes()), true),
_ => (Vec::from_slice("-inf".as_bytes()), true),
SignNone => (b"inf".to_vec(), true),
_ => (b"-inf".to_vec(), true),
};
}
_ => {}
@ -413,18 +411,18 @@ pub fn float_to_str_bytes_common<T:NumCast+Zero+One+PartialEq+PartialOrd+Float+
// If reached left end of number, have to
// insert additional digit:
if i < 0
|| *buf.get(i as uint) == b'-'
|| *buf.get(i as uint) == b'+' {
|| buf[i as uint] == b'-'
|| buf[i as uint] == b'+' {
buf.insert((i + 1) as uint, value2ascii(1));
break;
}
// Skip the '.'
if *buf.get(i as uint) == b'.' { i -= 1; continue; }
if buf[i as uint] == b'.' { i -= 1; continue; }
// Either increment the digit,
// or set to 0 if max and carry the 1.
let current_digit = ascii2value(*buf.get(i as uint));
let current_digit = ascii2value(buf[i as uint]);
if current_digit < (radix - 1) {
*buf.get_mut(i as uint) = value2ascii(current_digit+1);
break;
@ -446,25 +444,25 @@ pub fn float_to_str_bytes_common<T:NumCast+Zero+One+PartialEq+PartialOrd+Float+
let mut i = buf_max_i;
// discover trailing zeros of fractional part
while i > start_fractional_digits && *buf.get(i) == b'0' {
while i > start_fractional_digits && buf[i] == b'0' {
i -= 1;
}
// Only attempt to truncate digits if buf has fractional digits
if i >= start_fractional_digits {
// If buf ends with '.', cut that too.
if *buf.get(i) == b'.' { i -= 1 }
if buf[i] == b'.' { i -= 1 }
// only resize buf if we actually remove digits
if i < buf_max_i {
buf = Vec::from_slice(buf.slice(0, i + 1));
buf = buf.slice(0, i + 1).to_vec();
}
}
} // If exact and trailing '.', just cut that
else {
let max_i = buf.len() - 1;
if *buf.get(max_i) == b'.' {
buf = Vec::from_slice(buf.slice(0, max_i));
if buf[max_i] == b'.' {
buf = buf.slice(0, max_i).to_vec();
}
}

View file

@ -14,10 +14,9 @@
#![doc(primitive = "u16")]
use from_str::FromStr;
use num::{ToStrRadix, FromStrRadix};
use num::FromStrRadix;
use num::strconv;
use option::Option;
use string::String;
pub use core::u16::{BITS, BYTES, MIN, MAX};

View file

@ -14,10 +14,9 @@
#![doc(primitive = "u32")]
use from_str::FromStr;
use num::{ToStrRadix, FromStrRadix};
use num::FromStrRadix;
use num::strconv;
use option::Option;
use string::String;
pub use core::u32::{BITS, BYTES, MIN, MAX};

View file

@ -14,10 +14,9 @@
#![doc(primitive = "u64")]
use from_str::FromStr;
use num::{ToStrRadix, FromStrRadix};
use num::FromStrRadix;
use num::strconv;
use option::Option;
use string::String;
pub use core::u64::{BITS, BYTES, MIN, MAX};

View file

@ -14,10 +14,9 @@
#![doc(primitive = "u8")]
use from_str::FromStr;
use num::{ToStrRadix, FromStrRadix};
use num::FromStrRadix;
use num::strconv;
use option::Option;
use string::String;
pub use core::u8::{BITS, BYTES, MIN, MAX};

View file

@ -14,10 +14,9 @@
#![doc(primitive = "uint")]
use from_str::FromStr;
use num::{ToStrRadix, FromStrRadix};
use num::FromStrRadix;
use num::strconv;
use option::Option;
use string::String;
pub use core::uint::{BITS, BYTES, MIN, MAX};

View file

@ -82,35 +82,14 @@ pub fn to_str_bytes<U>(n: $T, radix: uint, f: |v: &[u8]| -> U) -> U {
f(buf[..amt])
}
#[deprecated = "use fmt::radix"]
impl ToStrRadix for $T {
/// Convert to a string in a given base.
#[inline]
fn to_str_radix(&self, radix: uint) -> String {
format!("{}", ::fmt::radix(*self, radix as u8))
}
}
#[cfg(test)]
mod tests {
use prelude::*;
use super::*;
use num::ToStrRadix;
use str::StrSlice;
use u16;
#[test]
pub fn test_to_string() {
assert_eq!((0 as $T).to_str_radix(10u), "0".to_string());
assert_eq!((1 as $T).to_str_radix(10u), "1".to_string());
assert_eq!((2 as $T).to_str_radix(10u), "2".to_string());
assert_eq!((11 as $T).to_str_radix(10u), "11".to_string());
assert_eq!((11 as $T).to_str_radix(16u), "b".to_string());
assert_eq!((255 as $T).to_str_radix(16u), "ff".to_string());
assert_eq!((0xff as $T).to_str_radix(10u), "255".to_string());
}
#[test]
pub fn test_from_str() {
assert_eq!(from_str::<$T>("0"), Some(0u as $T));
@ -199,18 +178,6 @@ mod tests {
assert_eq!(from_str::<u64>("0"), Some(u64_val));
assert!(from_str::<u64>("-1").is_none());
}
#[test]
#[should_fail]
pub fn to_str_radix1() {
100u.to_str_radix(1u);
}
#[test]
#[should_fail]
pub fn to_str_radix37() {
100u.to_str_radix(37u);
}
}
))