Skip to content

Commit 9a4f43b

Browse files
committed
std: Stabilize APIs for the 1.7 release
This commit stabilizes and deprecates the FCP (final comment period) APIs for the upcoming 1.7 beta release. The specific APIs which changed were: Stabilized * `Path::strip_prefix` (renamed from `relative_from`) * `path::StripPrefixError` (new error type returned from `strip_prefix`) * `Ipv4Addr::is_loopback` * `Ipv4Addr::is_private` * `Ipv4Addr::is_link_local` * `Ipv4Addr::is_multicast` * `Ipv4Addr::is_broadcast` * `Ipv4Addr::is_documentation` * `Ipv6Addr::is_unspecified` * `Ipv6Addr::is_loopback` * `Ipv6Addr::is_unique_local` * `Ipv6Addr::is_multicast` * `Vec::as_slice` * `Vec::as_mut_slice` * `String::as_str` * `String::as_mut_str` * `<[T]>::clone_from_slice` - the `usize` return value is removed * `<[T]>::sort_by_key` * `i32::checked_rem` (and other signed types) * `i32::checked_neg` (and other signed types) * `i32::checked_shl` (and other signed types) * `i32::checked_shr` (and other signed types) * `i32::saturating_mul` (and other signed types) * `i32::overflowing_add` (and other signed types) * `i32::overflowing_sub` (and other signed types) * `i32::overflowing_mul` (and other signed types) * `i32::overflowing_div` (and other signed types) * `i32::overflowing_rem` (and other signed types) * `i32::overflowing_neg` (and other signed types) * `i32::overflowing_shl` (and other signed types) * `i32::overflowing_shr` (and other signed types) * `u32::checked_rem` (and other unsigned types) * `u32::checked_neg` (and other unsigned types) * `u32::checked_shl` (and other unsigned types) * `u32::saturating_mul` (and other unsigned types) * `u32::overflowing_add` (and other unsigned types) * `u32::overflowing_sub` (and other unsigned types) * `u32::overflowing_mul` (and other unsigned types) * `u32::overflowing_div` (and other unsigned types) * `u32::overflowing_rem` (and other unsigned types) * `u32::overflowing_neg` (and other unsigned types) * `u32::overflowing_shl` (and other unsigned types) * `u32::overflowing_shr` (and other unsigned types) * `ffi::IntoStringError` * `CString::into_string` * `CString::into_bytes` * `CString::into_bytes_with_nul` * `From<CString> for Vec<u8>` * `From<CString> for Vec<u8>` * `IntoStringError::into_cstring` * `IntoStringError::utf8_error` * `Error for IntoStringError` Deprecated * `Path::relative_from` - renamed to `strip_prefix` * `Path::prefix` - use `components().next()` instead * `os::unix::fs` constants - moved to the `libc` crate * `fmt::{radix, Radix, RadixFmt}` - not used enough to stabilize * `IntoCow` - conflicts with `Into` and may come back later * `i32::{BITS, BYTES}` (and other integers) - not pulling their weight * `DebugTuple::formatter` - will be removed * `sync::Semaphore` - not used enough and confused with system semaphores Closes #23284 cc #27709 (still lots more methods though) Closes #27712 Closes #27722 Closes #27728 Closes #27735 Closes #27729 Closes #27755 Closes #27782 Closes #27798
1 parent c14b615 commit 9a4f43b

Some content is hidden

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

58 files changed

+356
-235
lines changed

src/liballoc/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@
7878
#![feature(custom_attribute)]
7979
#![feature(fundamental)]
8080
#![feature(lang_items)]
81-
#![feature(num_bits_bytes)]
8281
#![feature(optin_builtin_traits)]
8382
#![feature(placement_in_syntax)]
8483
#![feature(placement_new_protocol)]

src/liballoc/raw_vec.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use super::oom;
1616
use super::boxed::Box;
1717
use core::ops::Drop;
1818
use core::cmp;
19-
use core;
2019

2120
/// A low-level utility for more ergonomically allocating, reallocating, and deallocating a
2221
/// a buffer of memory on the heap without having to worry about all the corner cases
@@ -584,7 +583,7 @@ impl<T> Drop for RawVec<T> {
584583

585584
#[inline]
586585
fn alloc_guard(alloc_size: usize) {
587-
if core::usize::BITS < 64 {
586+
if mem::size_of::<usize>() < 8 {
588587
assert!(alloc_size <= ::core::isize::MAX as usize,
589588
"capacity overflow");
590589
}

src/libcollections/borrow.rs

+4
Original file line numberDiff line numberDiff line change
@@ -247,19 +247,23 @@ impl<'a, B: ?Sized> Hash for Cow<'a, B> where B: Hash + ToOwned {
247247
/// Trait for moving into a `Cow`.
248248
#[unstable(feature = "into_cow", reason = "may be replaced by `convert::Into`",
249249
issue = "27735")]
250+
#[rustc_deprecated(since = "1.7.0",
251+
reason = "conflicts with Into, may return with specialization")]
250252
pub trait IntoCow<'a, B: ?Sized> where B: ToOwned {
251253
/// Moves `self` into `Cow`
252254
fn into_cow(self) -> Cow<'a, B>;
253255
}
254256

255257
#[stable(feature = "rust1", since = "1.0.0")]
258+
#[allow(deprecated)]
256259
impl<'a, B: ?Sized> IntoCow<'a, B> for Cow<'a, B> where B: ToOwned {
257260
fn into_cow(self) -> Cow<'a, B> {
258261
self
259262
}
260263
}
261264

262265
#[stable(feature = "rust1", since = "1.0.0")]
266+
#[allow(deprecated)]
263267
impl<'a, T: ?Sized + ToOwned> AsRef<T> for Cow<'a, T> {
264268
fn as_ref(&self) -> &T {
265269
self

src/libcollections/enum_set.rs

+1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ pub trait CLike {
8181
fn from_usize(usize) -> Self;
8282
}
8383

84+
#[allow(deprecated)]
8485
fn bit<E: CLike>(e: &E) -> usize {
8586
use core::usize;
8687
let value = e.to_usize();

src/libcollections/fmt.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,11 @@ pub use core::fmt::{LowerExp, UpperExp};
490490
#[stable(feature = "rust1", since = "1.0.0")]
491491
pub use core::fmt::Error;
492492
#[stable(feature = "rust1", since = "1.0.0")]
493-
pub use core::fmt::{ArgumentV1, Arguments, write, radix, Radix, RadixFmt};
493+
pub use core::fmt::{ArgumentV1, Arguments, write};
494+
#[unstable(feature = "fmt_radix", issue = "27728")]
495+
#[rustc_deprecated(since = "1.7.0", reason = "not used enough to stabilize")]
496+
#[allow(deprecated)]
497+
pub use core::fmt::{radix, Radix, RadixFmt};
494498
#[stable(feature = "rust1", since = "1.0.0")]
495499
pub use core::fmt::{DebugList, DebugMap, DebugSet, DebugStruct, DebugTuple};
496500

src/libcollections/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
#![feature(alloc)]
3333
#![feature(box_patterns)]
3434
#![feature(box_syntax)]
35-
#![feature(clone_from_slice)]
3635
#![feature(core_intrinsics)]
3736
#![feature(decode_utf16)]
3837
#![feature(drop_in_place)]

src/libcollections/slice.rs

+13-20
Original file line numberDiff line numberDiff line change
@@ -788,15 +788,12 @@ impl<T> [T] {
788788
/// # Examples
789789
///
790790
/// ```rust
791-
/// #![feature(slice_sort_by_key)]
792-
///
793791
/// let mut v = [-5i32, 4, 1, -3, 2];
794792
///
795793
/// v.sort_by_key(|k| k.abs());
796794
/// assert!(v == [1, 2, -3, 4, -5]);
797795
/// ```
798-
#[unstable(feature = "slice_sort_by_key", reason = "recently added",
799-
issue = "27724")]
796+
#[stable(feature = "slice_sort_by_key", since = "1.7.0")]
800797
#[inline]
801798
pub fn sort_by_key<B, F>(&mut self, mut f: F)
802799
where F: FnMut(&T) -> B, B: Ord
@@ -829,29 +826,25 @@ impl<T> [T] {
829826
merge_sort(self, compare)
830827
}
831828

832-
/// Copies as many elements from `src` as it can into `self` (the
833-
/// shorter of `self.len()` and `src.len()`). Returns the number
834-
/// of elements copied.
829+
/// Copies the elements from `src` into `self`.
830+
///
831+
/// The length of this slice must be the same as the slice passed in.
832+
///
833+
/// # Panics
834+
///
835+
/// This function will panic if the two slices have different lengths.
835836
///
836837
/// # Example
837838
///
838839
/// ```rust
839-
/// #![feature(clone_from_slice)]
840-
///
841840
/// let mut dst = [0, 0, 0];
842-
/// let src = [1, 2];
843-
///
844-
/// assert!(dst.clone_from_slice(&src) == 2);
845-
/// assert!(dst == [1, 2, 0]);
841+
/// let src = [1, 2, 3];
846842
///
847-
/// let src2 = [3, 4, 5, 6];
848-
/// assert!(dst.clone_from_slice(&src2) == 3);
849-
/// assert!(dst == [3, 4, 5]);
843+
/// dst.clone_from_slice(&src);
844+
/// assert!(dst == [1, 2, 3]);
850845
/// ```
851-
#[unstable(feature = "clone_from_slice", issue = "27750")]
852-
pub fn clone_from_slice(&mut self, src: &[T]) -> usize
853-
where T: Clone
854-
{
846+
#[stable(feature = "clone_from_slice", since = "1.7.0")]
847+
pub fn clone_from_slice(&mut self, src: &[T]) where T: Clone {
855848
core_slice::SliceExt::clone_from_slice(self, src)
856849
}
857850

src/libcollections/string.rs

+11-3
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ use core::str::pattern::Pattern;
6666
use rustc_unicode::char::{decode_utf16, REPLACEMENT_CHARACTER};
6767
use rustc_unicode::str as unicode_str;
6868

69+
#[allow(deprecated)]
6970
use borrow::{Cow, IntoCow};
7071
use range::RangeArgument;
7172
use str::{self, FromStr, Utf8Error, Chars};
@@ -783,13 +784,18 @@ impl String {
783784

784785
/// Extracts a string slice containing the entire string.
785786
#[inline]
786-
#[unstable(feature = "convert",
787-
reason = "waiting on RFC revision",
788-
issue = "27729")]
787+
#[stable(feature = "string_as_str", since = "1.7.0")]
789788
pub fn as_str(&self) -> &str {
790789
self
791790
}
792791

792+
/// Extracts a string slice containing the entire string.
793+
#[inline]
794+
#[stable(feature = "string_as_str", since = "1.7.0")]
795+
pub fn as_mut_str(&mut self) -> &mut str {
796+
self
797+
}
798+
793799
/// Appends a given string slice onto the end of this `String`.
794800
///
795801
/// # Examples
@@ -1794,6 +1800,7 @@ impl Into<Vec<u8>> for String {
17941800

17951801
#[unstable(feature = "into_cow", reason = "may be replaced by `convert::Into`",
17961802
issue= "27735")]
1803+
#[allow(deprecated)]
17971804
impl IntoCow<'static, str> for String {
17981805
#[inline]
17991806
fn into_cow(self) -> Cow<'static, str> {
@@ -1803,6 +1810,7 @@ impl IntoCow<'static, str> for String {
18031810

18041811
#[unstable(feature = "into_cow", reason = "may be replaced by `convert::Into`",
18051812
issue = "27735")]
1813+
#[allow(deprecated)]
18061814
impl<'a> IntoCow<'a, str> for &'a str {
18071815
#[inline]
18081816
fn into_cow(self) -> Cow<'a, str> {

src/libcollections/vec.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ use core::ops;
7373
use core::ptr;
7474
use core::slice;
7575

76+
#[allow(deprecated)]
7677
use borrow::{Cow, IntoCow};
7778

7879
use super::range::RangeArgument;
@@ -464,9 +465,7 @@ impl<T> Vec<T> {
464465
///
465466
/// Equivalent to `&s[..]`.
466467
#[inline]
467-
#[unstable(feature = "convert",
468-
reason = "waiting on RFC revision",
469-
issue = "27729")]
468+
#[stable(feature = "vec_as_slice", since = "1.7.0")]
470469
pub fn as_slice(&self) -> &[T] {
471470
self
472471
}
@@ -475,9 +474,7 @@ impl<T> Vec<T> {
475474
///
476475
/// Equivalent to `&mut s[..]`.
477476
#[inline]
478-
#[unstable(feature = "convert",
479-
reason = "waiting on RFC revision",
480-
issue = "27729")]
477+
#[stable(feature = "vec_as_slice", since = "1.7.0")]
481478
pub fn as_mut_slice(&mut self) -> &mut [T] {
482479
&mut self[..]
483480
}
@@ -1516,13 +1513,15 @@ impl<'a, T> FromIterator<T> for Cow<'a, [T]> where T: Clone {
15161513
}
15171514

15181515
#[stable(feature = "rust1", since = "1.0.0")]
1516+
#[allow(deprecated)]
15191517
impl<'a, T: 'a> IntoCow<'a, [T]> for Vec<T> where T: Clone {
15201518
fn into_cow(self) -> Cow<'a, [T]> {
15211519
Cow::Owned(self)
15221520
}
15231521
}
15241522

15251523
#[stable(feature = "rust1", since = "1.0.0")]
1524+
#[allow(deprecated)]
15261525
impl<'a, T> IntoCow<'a, [T]> for &'a [T] where T: Clone {
15271526
fn into_cow(self) -> Cow<'a, [T]> {
15281527
Cow::Borrowed(self)

src/libcollections/vec_deque.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ use core::mem;
2525
use core::ops::{Index, IndexMut};
2626
use core::ptr;
2727
use core::slice;
28-
use core::usize;
2928

3029
use core::hash::{Hash, Hasher};
3130
use core::cmp;
@@ -36,7 +35,10 @@ use super::range::RangeArgument;
3635

3736
const INITIAL_CAPACITY: usize = 7; // 2^3 - 1
3837
const MINIMUM_CAPACITY: usize = 1; // 2 - 1
39-
const MAXIMUM_ZST_CAPACITY: usize = 1 << (usize::BITS - 1); // Largest possible power of two
38+
#[cfg(target_pointer_width = "32")]
39+
const MAXIMUM_ZST_CAPACITY: usize = 1 << (32 - 1); // Largest possible power of two
40+
#[cfg(target_pointer_width = "64")]
41+
const MAXIMUM_ZST_CAPACITY: usize = 1 << (64 - 1); // Largest possible power of two
4042

4143
/// `VecDeque` is a growable ring buffer, which can be used as a double-ended
4244
/// queue efficiently.

src/libcore/fmt/builders.rs

+1
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ impl<'a, 'b: 'a> DebugTuple<'a, 'b> {
181181
/// Returns the wrapped `Formatter`.
182182
#[unstable(feature = "debug_builder_formatter", reason = "recently added",
183183
issue = "27782")]
184+
#[rustc_deprecated(since = "1.7.0", reason = "will be removed")]
184185
pub fn formatter(&mut self) -> &mut fmt::Formatter<'b> {
185186
&mut self.fmt
186187
}

src/libcore/fmt/mod.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,16 @@ use str;
2525
use self::rt::v1::Alignment;
2626

2727
#[unstable(feature = "fmt_radix", issue = "27728")]
28+
#[rustc_deprecated(since = "1.7.0", reason = "not used enough to stabilize")]
29+
#[allow(deprecated)]
2830
pub use self::num::radix;
2931
#[unstable(feature = "fmt_radix", issue = "27728")]
32+
#[rustc_deprecated(since = "1.7.0", reason = "not used enough to stabilize")]
33+
#[allow(deprecated)]
3034
pub use self::num::Radix;
3135
#[unstable(feature = "fmt_radix", issue = "27728")]
36+
#[rustc_deprecated(since = "1.7.0", reason = "not used enough to stabilize")]
37+
#[allow(deprecated)]
3238
pub use self::num::RadixFmt;
3339
#[stable(feature = "debug_builders", since = "1.2.0")]
3440
pub use self::builders::{DebugStruct, DebugTuple, DebugSet, DebugList, DebugMap};
@@ -1391,7 +1397,7 @@ impl<T> Pointer for *const T {
13911397
f.flags |= 1 << (FlagV1::SignAwareZeroPad as u32);
13921398

13931399
if let None = f.width {
1394-
f.width = Some((::usize::BITS/4) + 2);
1400+
f.width = Some(((mem::size_of::<usize>() * 8) / 4) + 2);
13951401
}
13961402
}
13971403
f.flags |= 1 << (FlagV1::Alternate as u32);
@@ -1532,7 +1538,7 @@ macro_rules! tuple {
15321538
( $($name:ident,)+ ) => (
15331539
#[stable(feature = "rust1", since = "1.0.0")]
15341540
impl<$($name:Debug),*> Debug for ($($name,)*) {
1535-
#[allow(non_snake_case, unused_assignments)]
1541+
#[allow(non_snake_case, unused_assignments, deprecated)]
15361542
fn fmt(&self, f: &mut Formatter) -> Result {
15371543
let mut builder = f.debug_tuple("");
15381544
let ($(ref $name,)*) = *self;

src/libcore/fmt/num.rs

+5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
//! Integer and floating-point number formatting
1212
13+
#![allow(deprecated)]
14+
1315
// FIXME: #6220 Implement floating point formatting
1416

1517
use prelude::v1::*;
@@ -143,6 +145,7 @@ radix! { UpperHex, 16, "0x", x @ 0 ... 9 => b'0' + x,
143145
#[unstable(feature = "fmt_radix",
144146
reason = "may be renamed or move to a different module",
145147
issue = "27728")]
148+
#[rustc_deprecated(since = "1.7.0", reason = "not used enough to stabilize")]
146149
pub struct Radix {
147150
base: u8,
148151
}
@@ -173,6 +176,7 @@ impl GenericRadix for Radix {
173176
#[unstable(feature = "fmt_radix",
174177
reason = "may be renamed or move to a different module",
175178
issue = "27728")]
179+
#[rustc_deprecated(since = "1.7.0", reason = "not used enough to stabilize")]
176180
#[derive(Copy, Clone)]
177181
pub struct RadixFmt<T, R>(T, R);
178182

@@ -189,6 +193,7 @@ pub struct RadixFmt<T, R>(T, R);
189193
#[unstable(feature = "fmt_radix",
190194
reason = "may be renamed or move to a different module",
191195
issue = "27728")]
196+
#[rustc_deprecated(since = "1.7.0", reason = "not used enough to stabilize")]
192197
pub fn radix<T>(x: T, base: u8) -> RadixFmt<T, Radix> {
193198
RadixFmt(x, Radix::new(base))
194199
}

src/libcore/hash/mod.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ pub trait Hasher {
195195
mod impls {
196196
use prelude::v1::*;
197197

198+
use mem;
198199
use slice;
199200
use super::*;
200201

@@ -207,9 +208,7 @@ mod impls {
207208
}
208209

209210
fn hash_slice<H: Hasher>(data: &[$ty], state: &mut H) {
210-
// FIXME(#23542) Replace with type ascription.
211-
#![allow(trivial_casts)]
212-
let newlen = data.len() * ::$ty::BYTES;
211+
let newlen = data.len() * mem::size_of::<$ty>();
213212
let ptr = data.as_ptr() as *const u8;
214213
state.write(unsafe { slice::from_raw_parts(ptr, newlen) })
215214
}

src/libcore/num/flt2dec/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ impl<'a> Part<'a> {
210210
}
211211
}
212212
Part::Copy(buf) => {
213-
out.clone_from_slice(buf);
213+
out[..buf.len()].clone_from_slice(buf);
214214
}
215215
}
216216
Some(len)
@@ -245,7 +245,7 @@ impl<'a> Formatted<'a> {
245245
/// (It may still leave partially written bytes in the buffer; do not rely on that.)
246246
pub fn write(&self, out: &mut [u8]) -> Option<usize> {
247247
if out.len() < self.sign.len() { return None; }
248-
out.clone_from_slice(self.sign);
248+
out[..self.sign.len()].clone_from_slice(self.sign);
249249

250250
let mut written = self.sign.len();
251251
for part in self.parts {

src/libcore/num/int_macros.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,25 @@ macro_rules! int_module { ($T:ty, $bits:expr) => (
1717
#[unstable(feature = "num_bits_bytes",
1818
reason = "may want to be an associated function",
1919
issue = "27753")]
20+
#[rustc_deprecated(since = "1.7.0",
21+
reason = "will be replaced via const fn or associated constants")]
2022
#[allow(missing_docs)]
2123
pub const BITS : usize = $bits;
2224
// FIXME(#11621): Should be deprecated once CTFE is implemented in favour of
2325
// calling the `mem::size_of` function.
2426
#[unstable(feature = "num_bits_bytes",
2527
reason = "may want to be an associated function",
2628
issue = "27753")]
29+
#[rustc_deprecated(since = "1.7.0",
30+
reason = "will be replaced via const fn or associated constants")]
2731
#[allow(missing_docs)]
2832
pub const BYTES : usize = ($bits / 8);
2933

3034
// FIXME(#11621): Should be deprecated once CTFE is implemented in favour of
3135
// calling the `Bounded::min_value` function.
3236
#[stable(feature = "rust1", since = "1.0.0")]
3337
#[allow(missing_docs)]
34-
pub const MIN: $T = (-1 as $T) << (BITS - 1);
38+
pub const MIN: $T = (-1 as $T) << ($bits - 1);
3539
// FIXME(#9837): Compute MIN like this so the high bits that shouldn't exist are 0.
3640
// FIXME(#11621): Should be deprecated once CTFE is implemented in favour of
3741
// calling the `Bounded::max_value` function.

0 commit comments

Comments
 (0)