Skip to content

Commit a1dd5ac

Browse files
committed
rollup merge of rust-lang#24636: alexcrichton/remove-deprecated
Conflicts: src/libcore/result.rs
2 parents 98e9765 + a568a7f commit a1dd5ac

File tree

197 files changed

+1380
-6420
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

197 files changed

+1380
-6420
lines changed

src/doc/trpl/traits.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ This shows off the additional feature of `where` clauses: they allow bounds
336336
where the left-hand side is an arbitrary type (`i32` in this case), not just a
337337
plain type parameter (like `T`).
338338

339-
# Default methods
339+
## Default methods
340340

341341
There’s one last feature of traits we should cover: default methods. It’s
342342
easiest just to show an example:

src/libcollections/bit.rs

-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
//! ```
4141
//! # #![feature(collections, core, step_by)]
4242
//! use std::collections::{BitSet, BitVec};
43-
//! use std::num::Float;
4443
//! use std::iter;
4544
//!
4645
//! let max_prime = 10000;

src/libcollections/fmt.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@
175175
//! # #![feature(core, std_misc)]
176176
//! use std::fmt;
177177
//! use std::f64;
178-
//! use std::num::Float;
179178
//!
180179
//! #[derive(Debug)]
181180
//! struct Vector2D {
@@ -200,10 +199,11 @@
200199
//! let magnitude = magnitude.sqrt();
201200
//!
202201
//! // Respect the formatting flags by using the helper method
203-
//! // `pad_integral` on the Formatter object. See the method documentation
204-
//! // for details, and the function `pad` can be used to pad strings.
202+
//! // `pad_integral` on the Formatter object. See the method
203+
//! // documentation for details, and the function `pad` can be used
204+
//! // to pad strings.
205205
//! let decimals = f.precision().unwrap_or(3);
206-
//! let string = f64::to_str_exact(magnitude, decimals);
206+
//! let string = format!("{:.*}", decimals, magnitude);
207207
//! f.pad_integral(true, "", &string)
208208
//! }
209209
//! }

src/libcollections/slice.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ use self::Direction::*;
9898
use borrow::{Borrow, BorrowMut, ToOwned};
9999
use vec::Vec;
100100

101-
pub use core::slice::{Chunks, AsSlice, Windows};
101+
pub use core::slice::{Chunks, Windows};
102102
pub use core::slice::{Iter, IterMut};
103103
pub use core::slice::{IntSliceExt, SplitMut, ChunksMut, Split};
104104
pub use core::slice::{SplitN, RSplitN, SplitNMut, RSplitNMut};

src/libcollections/str.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ use rustc_unicode;
6767
use vec::Vec;
6868
use slice::SliceConcatExt;
6969

70-
pub use core::str::{FromStr, Utf8Error, Str};
70+
pub use core::str::{FromStr, Utf8Error};
7171
pub use core::str::{Lines, LinesAny, CharRange};
7272
pub use core::str::{Split, RSplit};
7373
pub use core::str::{SplitN, RSplitN};

src/libcollections/string.rs

-17
Original file line numberDiff line numberDiff line change
@@ -837,15 +837,6 @@ impl<'a, 'b> PartialEq<Cow<'a, str>> for &'b str {
837837
fn ne(&self, other: &Cow<'a, str>) -> bool { PartialEq::ne(&self[..], &other[..]) }
838838
}
839839

840-
#[unstable(feature = "collections", reason = "waiting on Str stabilization")]
841-
#[allow(deprecated)]
842-
impl Str for String {
843-
#[inline]
844-
fn as_slice(&self) -> &str {
845-
unsafe { mem::transmute(&*self.vec) }
846-
}
847-
}
848-
849840
#[stable(feature = "rust1", since = "1.0.0")]
850841
impl Default for String {
851842
#[inline]
@@ -1067,14 +1058,6 @@ impl<'a> IntoCow<'a, str> for &'a str {
10671058
}
10681059
}
10691060

1070-
#[allow(deprecated)]
1071-
impl<'a> Str for Cow<'a, str> {
1072-
#[inline]
1073-
fn as_slice<'b>(&'b self) -> &'b str {
1074-
&**self
1075-
}
1076-
}
1077-
10781061
#[stable(feature = "rust1", since = "1.0.0")]
10791062
impl fmt::Write for String {
10801063
#[inline]

src/libcollections/vec.rs

-12
Original file line numberDiff line numberDiff line change
@@ -1591,18 +1591,6 @@ impl<T: Ord> Ord for Vec<T> {
15911591
}
15921592
}
15931593

1594-
#[unstable(feature = "collections",
1595-
reason = "will be replaced by slice syntax")]
1596-
#[deprecated(since = "1.0.0", reason = "use &mut s[..] instead")]
1597-
#[allow(deprecated)]
1598-
impl<T> AsSlice<T> for Vec<T> {
1599-
/// Deprecated: use `&mut s[..]` instead.
1600-
#[inline]
1601-
fn as_slice(&self) -> &[T] {
1602-
self
1603-
}
1604-
}
1605-
16061594
#[unstable(feature = "collections",
16071595
reason = "recent addition, needs more experience")]
16081596
impl<'a, T: Clone> Add<&'a [T]> for Vec<T> {

src/libcore/fmt/float.rs

+29-14
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
pub use self::ExponentFormat::*;
1212
pub use self::SignificantDigits::*;
1313

14-
use char::{self, CharExt};
14+
use prelude::*;
15+
16+
use char;
1517
use fmt;
16-
use iter::Iterator;
17-
use num::{cast, Float, ToPrimitive};
18+
use num::Float;
1819
use num::FpCategory as Fp;
19-
use ops::FnOnce;
20-
use result::Result::Ok;
21-
use slice::{self, SliceExt};
22-
use str::{self, StrExt};
20+
use ops::{Div, Rem, Mul};
21+
use slice;
22+
use str;
2323

2424
/// A flag that specifies whether to use exponential (scientific) notation.
2525
pub enum ExponentFormat {
@@ -42,6 +42,21 @@ pub enum SignificantDigits {
4242
DigExact(usize)
4343
}
4444

45+
#[doc(hidden)]
46+
pub trait MyFloat: Float + PartialEq + PartialOrd + Div<Output=Self> +
47+
Mul<Output=Self> + Rem<Output=Self> + Copy {
48+
fn from_u32(u: u32) -> Self;
49+
fn to_i32(&self) -> i32;
50+
}
51+
52+
macro_rules! doit {
53+
($($t:ident)*) => ($(impl MyFloat for $t {
54+
fn from_u32(u: u32) -> $t { u as $t }
55+
fn to_i32(&self) -> i32 { *self as i32 }
56+
})*)
57+
}
58+
doit! { f32 f64 }
59+
4560
/// Converts a float number to its string representation.
4661
/// This is meant to be a common base implementation for various formatting styles.
4762
/// The number is assumed to be non-negative, callers use `Formatter::pad_integral`
@@ -63,7 +78,7 @@ pub enum SignificantDigits {
6378
/// # Panics
6479
///
6580
/// - Panics if `num` is negative.
66-
pub fn float_to_str_bytes_common<T: Float, U, F>(
81+
pub fn float_to_str_bytes_common<T: MyFloat, U, F>(
6782
num: T,
6883
digits: SignificantDigits,
6984
exp_format: ExponentFormat,
@@ -72,10 +87,10 @@ pub fn float_to_str_bytes_common<T: Float, U, F>(
7287
) -> U where
7388
F: FnOnce(&str) -> U,
7489
{
75-
let _0: T = Float::zero();
76-
let _1: T = Float::one();
90+
let _0: T = T::zero();
91+
let _1: T = T::one();
7792
let radix: u32 = 10;
78-
let radix_f: T = cast(radix).unwrap();
93+
let radix_f = T::from_u32(radix);
7994

8095
assert!(num.is_nan() || num >= _0, "float_to_str_bytes_common: number is negative");
8196

@@ -99,7 +114,7 @@ pub fn float_to_str_bytes_common<T: Float, U, F>(
99114
let (num, exp) = match exp_format {
100115
ExpDec if num != _0 => {
101116
let exp = num.log10().floor();
102-
(num / radix_f.powf(exp), cast::<T, i32>(exp).unwrap())
117+
(num / radix_f.powf(exp), exp.to_i32())
103118
}
104119
_ => (num, 0)
105120
};
@@ -114,7 +129,7 @@ pub fn float_to_str_bytes_common<T: Float, U, F>(
114129
deccum = deccum / radix_f;
115130
deccum = deccum.trunc();
116131

117-
let c = char::from_digit(current_digit.to_isize().unwrap() as u32, radix);
132+
let c = char::from_digit(current_digit.to_i32() as u32, radix);
118133
buf[end] = c.unwrap() as u8;
119134
end += 1;
120135

@@ -158,7 +173,7 @@ pub fn float_to_str_bytes_common<T: Float, U, F>(
158173

159174
let current_digit = deccum.trunc();
160175

161-
let c = char::from_digit(current_digit.to_isize().unwrap() as u32, radix);
176+
let c = char::from_digit(current_digit.to_i32() as u32, radix);
162177
buf[end] = c.unwrap() as u8;
163178
end += 1;
164179

src/libcore/fmt/mod.rs

+8-16
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,16 @@
1212
1313
#![stable(feature = "rust1", since = "1.0.0")]
1414

15+
use prelude::*;
16+
1517
use cell::{Cell, RefCell, Ref, RefMut, BorrowState};
16-
use char::CharExt;
17-
use clone::Clone;
18-
use iter::Iterator;
19-
use marker::{Copy, PhantomData, Sized};
18+
use marker::PhantomData;
2019
use mem;
21-
use num::Float;
22-
use option::Option;
23-
use option::Option::{Some, None};
24-
use result::Result::Ok;
25-
use ops::{Deref, FnOnce};
20+
use ops::Deref;
2621
use result;
27-
use slice::SliceExt;
22+
use num::Float;
2823
use slice;
29-
use str::{self, StrExt};
24+
use str;
3025
use self::rt::v1::Alignment;
3126

3227
pub use self::num::radix;
@@ -929,7 +924,8 @@ impl<'a, T> Pointer for &'a mut T {
929924
}
930925

931926
// Common code of floating point Debug and Display.
932-
fn float_to_str_common<T: Float, F>(num: &T, precision: Option<usize>, post: F) -> Result
927+
fn float_to_str_common<T: float::MyFloat, F>(num: &T, precision: Option<usize>,
928+
post: F) -> Result
933929
where F : FnOnce(&str) -> Result {
934930
let digits = match precision {
935931
Some(i) => float::DigExact(i),
@@ -967,8 +963,6 @@ macro_rules! floating { ($ty:ident) => {
967963
#[stable(feature = "rust1", since = "1.0.0")]
968964
impl LowerExp for $ty {
969965
fn fmt(&self, fmt: &mut Formatter) -> Result {
970-
use num::Float;
971-
972966
let digits = match fmt.precision {
973967
Some(i) => float::DigExact(i),
974968
None => float::DigMax(6),
@@ -986,8 +980,6 @@ macro_rules! floating { ($ty:ident) => {
986980
#[stable(feature = "rust1", since = "1.0.0")]
987981
impl UpperExp for $ty {
988982
fn fmt(&self, fmt: &mut Formatter) -> Result {
989-
use num::Float;
990-
991983
let digits = match fmt.precision {
992984
Some(i) => float::DigExact(i),
993985
None => float::DigMax(6),

src/libcore/fmt/num.rs

+29-14
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,28 @@
1414

1515
#![allow(unsigned_negation)]
1616

17+
use prelude::*;
18+
1719
use fmt;
18-
use iter::Iterator;
19-
use num::{Int, cast};
20-
use slice::SliceExt;
20+
use num::Zero;
21+
use ops::{Div, Rem, Sub};
2122
use str;
2223

24+
#[doc(hidden)]
25+
trait Int: Zero + PartialEq + PartialOrd + Div<Output=Self> + Rem<Output=Self> +
26+
Sub<Output=Self> + Copy {
27+
fn from_u8(u: u8) -> Self;
28+
fn to_u8(&self) -> u8;
29+
}
30+
31+
macro_rules! doit {
32+
($($t:ident)*) => ($(impl Int for $t {
33+
fn from_u8(u: u8) -> $t { u as $t }
34+
fn to_u8(&self) -> u8 { *self as u8 }
35+
})*)
36+
}
37+
doit! { i8 i16 i32 i64 isize u8 u16 u32 u64 usize }
38+
2339
/// A type that represents a specific radix
2440
#[doc(hidden)]
2541
trait GenericRadix {
@@ -33,33 +49,32 @@ trait GenericRadix {
3349
fn digit(&self, x: u8) -> u8;
3450

3551
/// Format an integer using the radix using a formatter.
36-
#[allow(deprecated)] // Int
3752
fn fmt_int<T: Int>(&self, mut x: T, f: &mut fmt::Formatter) -> fmt::Result {
3853
// The radix can be as low as 2, so we need a buffer of at least 64
3954
// characters for a base 2 number.
40-
let zero = Int::zero();
55+
let zero = T::zero();
4156
let is_positive = x >= zero;
4257
let mut buf = [0; 64];
4358
let mut curr = buf.len();
44-
let base = cast(self.base()).unwrap();
59+
let base = T::from_u8(self.base());
4560
if is_positive {
4661
// Accumulate each digit of the number from the least significant
4762
// to the most significant figure.
4863
for byte in buf.iter_mut().rev() {
49-
let n = x % base; // Get the current place value.
50-
x = x / base; // Deaccumulate the number.
51-
*byte = self.digit(cast(n).unwrap()); // Store the digit in the buffer.
64+
let n = x % base; // Get the current place value.
65+
x = x / base; // Deaccumulate the number.
66+
*byte = self.digit(n.to_u8()); // Store the digit in the buffer.
5267
curr -= 1;
53-
if x == zero { break }; // No more digits left to accumulate.
68+
if x == zero { break }; // No more digits left to accumulate.
5469
}
5570
} else {
5671
// Do the same as above, but accounting for two's complement.
5772
for byte in buf.iter_mut().rev() {
58-
let n = zero - (x % base); // Get the current place value.
59-
x = x / base; // Deaccumulate the number.
60-
*byte = self.digit(cast(n).unwrap()); // Store the digit in the buffer.
73+
let n = zero - (x % base); // Get the current place value.
74+
x = x / base; // Deaccumulate the number.
75+
*byte = self.digit(n.to_u8()); // Store the digit in the buffer.
6176
curr -= 1;
62-
if x == zero { break }; // No more digits left to accumulate.
77+
if x == zero { break }; // No more digits left to accumulate.
6378
}
6479
}
6580
let buf = unsafe { str::from_utf8_unchecked(&buf[curr..]) };

0 commit comments

Comments
 (0)