Skip to content

Commit

Permalink
std: Stabilize APIs for the 1.7 release
Browse files Browse the repository at this point in the history
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 rust-lang#23284
cc rust-lang#27709 (still lots more methods though)
Closes rust-lang#27712
Closes rust-lang#27722
Closes rust-lang#27728
Closes rust-lang#27735
Closes rust-lang#27729
Closes rust-lang#27755
Closes rust-lang#27782
Closes rust-lang#27798
  • Loading branch information
alexcrichton committed Jan 16, 2016
1 parent c14b615 commit 9a4f43b
Show file tree
Hide file tree
Showing 58 changed files with 356 additions and 235 deletions.
1 change: 0 additions & 1 deletion src/liballoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
#![feature(custom_attribute)]
#![feature(fundamental)]
#![feature(lang_items)]
#![feature(num_bits_bytes)]
#![feature(optin_builtin_traits)]
#![feature(placement_in_syntax)]
#![feature(placement_new_protocol)]
Expand Down
3 changes: 1 addition & 2 deletions src/liballoc/raw_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use super::oom;
use super::boxed::Box;
use core::ops::Drop;
use core::cmp;
use core;

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

#[inline]
fn alloc_guard(alloc_size: usize) {
if core::usize::BITS < 64 {
if mem::size_of::<usize>() < 8 {
assert!(alloc_size <= ::core::isize::MAX as usize,
"capacity overflow");
}
Expand Down
4 changes: 4 additions & 0 deletions src/libcollections/borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,19 +247,23 @@ impl<'a, B: ?Sized> Hash for Cow<'a, B> where B: Hash + ToOwned {
/// Trait for moving into a `Cow`.
#[unstable(feature = "into_cow", reason = "may be replaced by `convert::Into`",
issue = "27735")]
#[rustc_deprecated(since = "1.7.0",
reason = "conflicts with Into, may return with specialization")]
pub trait IntoCow<'a, B: ?Sized> where B: ToOwned {
/// Moves `self` into `Cow`
fn into_cow(self) -> Cow<'a, B>;
}

#[stable(feature = "rust1", since = "1.0.0")]
#[allow(deprecated)]
impl<'a, B: ?Sized> IntoCow<'a, B> for Cow<'a, B> where B: ToOwned {
fn into_cow(self) -> Cow<'a, B> {
self
}
}

#[stable(feature = "rust1", since = "1.0.0")]
#[allow(deprecated)]
impl<'a, T: ?Sized + ToOwned> AsRef<T> for Cow<'a, T> {
fn as_ref(&self) -> &T {
self
Expand Down
1 change: 1 addition & 0 deletions src/libcollections/enum_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ pub trait CLike {
fn from_usize(usize) -> Self;
}

#[allow(deprecated)]
fn bit<E: CLike>(e: &E) -> usize {
use core::usize;
let value = e.to_usize();
Expand Down
6 changes: 5 additions & 1 deletion src/libcollections/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,11 @@ pub use core::fmt::{LowerExp, UpperExp};
#[stable(feature = "rust1", since = "1.0.0")]
pub use core::fmt::Error;
#[stable(feature = "rust1", since = "1.0.0")]
pub use core::fmt::{ArgumentV1, Arguments, write, radix, Radix, RadixFmt};
pub use core::fmt::{ArgumentV1, Arguments, write};
#[unstable(feature = "fmt_radix", issue = "27728")]
#[rustc_deprecated(since = "1.7.0", reason = "not used enough to stabilize")]
#[allow(deprecated)]
pub use core::fmt::{radix, Radix, RadixFmt};
#[stable(feature = "rust1", since = "1.0.0")]
pub use core::fmt::{DebugList, DebugMap, DebugSet, DebugStruct, DebugTuple};

Expand Down
1 change: 0 additions & 1 deletion src/libcollections/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#![feature(alloc)]
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(clone_from_slice)]
#![feature(core_intrinsics)]
#![feature(decode_utf16)]
#![feature(drop_in_place)]
Expand Down
33 changes: 13 additions & 20 deletions src/libcollections/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -788,15 +788,12 @@ impl<T> [T] {
/// # Examples
///
/// ```rust
/// #![feature(slice_sort_by_key)]
///
/// let mut v = [-5i32, 4, 1, -3, 2];
///
/// v.sort_by_key(|k| k.abs());
/// assert!(v == [1, 2, -3, 4, -5]);
/// ```
#[unstable(feature = "slice_sort_by_key", reason = "recently added",
issue = "27724")]
#[stable(feature = "slice_sort_by_key", since = "1.7.0")]
#[inline]
pub fn sort_by_key<B, F>(&mut self, mut f: F)
where F: FnMut(&T) -> B, B: Ord
Expand Down Expand Up @@ -829,29 +826,25 @@ impl<T> [T] {
merge_sort(self, compare)
}

/// Copies as many elements from `src` as it can into `self` (the
/// shorter of `self.len()` and `src.len()`). Returns the number
/// of elements copied.
/// Copies the elements from `src` into `self`.
///
/// The length of this slice must be the same as the slice passed in.
///
/// # Panics
///
/// This function will panic if the two slices have different lengths.
///
/// # Example
///
/// ```rust
/// #![feature(clone_from_slice)]
///
/// let mut dst = [0, 0, 0];
/// let src = [1, 2];
///
/// assert!(dst.clone_from_slice(&src) == 2);
/// assert!(dst == [1, 2, 0]);
/// let src = [1, 2, 3];
///
/// let src2 = [3, 4, 5, 6];
/// assert!(dst.clone_from_slice(&src2) == 3);
/// assert!(dst == [3, 4, 5]);
/// dst.clone_from_slice(&src);
/// assert!(dst == [1, 2, 3]);
/// ```
#[unstable(feature = "clone_from_slice", issue = "27750")]
pub fn clone_from_slice(&mut self, src: &[T]) -> usize
where T: Clone
{
#[stable(feature = "clone_from_slice", since = "1.7.0")]
pub fn clone_from_slice(&mut self, src: &[T]) where T: Clone {
core_slice::SliceExt::clone_from_slice(self, src)
}

Expand Down
14 changes: 11 additions & 3 deletions src/libcollections/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ use core::str::pattern::Pattern;
use rustc_unicode::char::{decode_utf16, REPLACEMENT_CHARACTER};
use rustc_unicode::str as unicode_str;

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

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

/// Extracts a string slice containing the entire string.
#[inline]
#[stable(feature = "string_as_str", since = "1.7.0")]
pub fn as_mut_str(&mut self) -> &mut str {
self
}

/// Appends a given string slice onto the end of this `String`.
///
/// # Examples
Expand Down Expand Up @@ -1794,6 +1800,7 @@ impl Into<Vec<u8>> for String {

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

#[unstable(feature = "into_cow", reason = "may be replaced by `convert::Into`",
issue = "27735")]
#[allow(deprecated)]
impl<'a> IntoCow<'a, str> for &'a str {
#[inline]
fn into_cow(self) -> Cow<'a, str> {
Expand Down
11 changes: 5 additions & 6 deletions src/libcollections/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ use core::ops;
use core::ptr;
use core::slice;

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

use super::range::RangeArgument;
Expand Down Expand Up @@ -464,9 +465,7 @@ impl<T> Vec<T> {
///
/// Equivalent to `&s[..]`.
#[inline]
#[unstable(feature = "convert",
reason = "waiting on RFC revision",
issue = "27729")]
#[stable(feature = "vec_as_slice", since = "1.7.0")]
pub fn as_slice(&self) -> &[T] {
self
}
Expand All @@ -475,9 +474,7 @@ impl<T> Vec<T> {
///
/// Equivalent to `&mut s[..]`.
#[inline]
#[unstable(feature = "convert",
reason = "waiting on RFC revision",
issue = "27729")]
#[stable(feature = "vec_as_slice", since = "1.7.0")]
pub fn as_mut_slice(&mut self) -> &mut [T] {
&mut self[..]
}
Expand Down Expand Up @@ -1516,13 +1513,15 @@ impl<'a, T> FromIterator<T> for Cow<'a, [T]> where T: Clone {
}

#[stable(feature = "rust1", since = "1.0.0")]
#[allow(deprecated)]
impl<'a, T: 'a> IntoCow<'a, [T]> for Vec<T> where T: Clone {
fn into_cow(self) -> Cow<'a, [T]> {
Cow::Owned(self)
}
}

#[stable(feature = "rust1", since = "1.0.0")]
#[allow(deprecated)]
impl<'a, T> IntoCow<'a, [T]> for &'a [T] where T: Clone {
fn into_cow(self) -> Cow<'a, [T]> {
Cow::Borrowed(self)
Expand Down
6 changes: 4 additions & 2 deletions src/libcollections/vec_deque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ use core::mem;
use core::ops::{Index, IndexMut};
use core::ptr;
use core::slice;
use core::usize;

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

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

/// `VecDeque` is a growable ring buffer, which can be used as a double-ended
/// queue efficiently.
Expand Down
1 change: 1 addition & 0 deletions src/libcore/fmt/builders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ impl<'a, 'b: 'a> DebugTuple<'a, 'b> {
/// Returns the wrapped `Formatter`.
#[unstable(feature = "debug_builder_formatter", reason = "recently added",
issue = "27782")]
#[rustc_deprecated(since = "1.7.0", reason = "will be removed")]
pub fn formatter(&mut self) -> &mut fmt::Formatter<'b> {
&mut self.fmt
}
Expand Down
10 changes: 8 additions & 2 deletions src/libcore/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,16 @@ use str;
use self::rt::v1::Alignment;

#[unstable(feature = "fmt_radix", issue = "27728")]
#[rustc_deprecated(since = "1.7.0", reason = "not used enough to stabilize")]
#[allow(deprecated)]
pub use self::num::radix;
#[unstable(feature = "fmt_radix", issue = "27728")]
#[rustc_deprecated(since = "1.7.0", reason = "not used enough to stabilize")]
#[allow(deprecated)]
pub use self::num::Radix;
#[unstable(feature = "fmt_radix", issue = "27728")]
#[rustc_deprecated(since = "1.7.0", reason = "not used enough to stabilize")]
#[allow(deprecated)]
pub use self::num::RadixFmt;
#[stable(feature = "debug_builders", since = "1.2.0")]
pub use self::builders::{DebugStruct, DebugTuple, DebugSet, DebugList, DebugMap};
Expand Down Expand Up @@ -1391,7 +1397,7 @@ impl<T> Pointer for *const T {
f.flags |= 1 << (FlagV1::SignAwareZeroPad as u32);

if let None = f.width {
f.width = Some((::usize::BITS/4) + 2);
f.width = Some(((mem::size_of::<usize>() * 8) / 4) + 2);
}
}
f.flags |= 1 << (FlagV1::Alternate as u32);
Expand Down Expand Up @@ -1532,7 +1538,7 @@ macro_rules! tuple {
( $($name:ident,)+ ) => (
#[stable(feature = "rust1", since = "1.0.0")]
impl<$($name:Debug),*> Debug for ($($name,)*) {
#[allow(non_snake_case, unused_assignments)]
#[allow(non_snake_case, unused_assignments, deprecated)]
fn fmt(&self, f: &mut Formatter) -> Result {
let mut builder = f.debug_tuple("");
let ($(ref $name,)*) = *self;
Expand Down
5 changes: 5 additions & 0 deletions src/libcore/fmt/num.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

//! Integer and floating-point number formatting

#![allow(deprecated)]

// FIXME: #6220 Implement floating point formatting

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

Expand All @@ -189,6 +193,7 @@ pub struct RadixFmt<T, R>(T, R);
#[unstable(feature = "fmt_radix",
reason = "may be renamed or move to a different module",
issue = "27728")]
#[rustc_deprecated(since = "1.7.0", reason = "not used enough to stabilize")]
pub fn radix<T>(x: T, base: u8) -> RadixFmt<T, Radix> {
RadixFmt(x, Radix::new(base))
}
Expand Down
5 changes: 2 additions & 3 deletions src/libcore/hash/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ pub trait Hasher {
mod impls {
use prelude::v1::*;

use mem;
use slice;
use super::*;

Expand All @@ -207,9 +208,7 @@ mod impls {
}

fn hash_slice<H: Hasher>(data: &[$ty], state: &mut H) {
// FIXME(#23542) Replace with type ascription.
#![allow(trivial_casts)]
let newlen = data.len() * ::$ty::BYTES;
let newlen = data.len() * mem::size_of::<$ty>();
let ptr = data.as_ptr() as *const u8;
state.write(unsafe { slice::from_raw_parts(ptr, newlen) })
}
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/num/flt2dec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ impl<'a> Part<'a> {
}
}
Part::Copy(buf) => {
out.clone_from_slice(buf);
out[..buf.len()].clone_from_slice(buf);
}
}
Some(len)
Expand Down Expand Up @@ -245,7 +245,7 @@ impl<'a> Formatted<'a> {
/// (It may still leave partially written bytes in the buffer; do not rely on that.)
pub fn write(&self, out: &mut [u8]) -> Option<usize> {
if out.len() < self.sign.len() { return None; }
out.clone_from_slice(self.sign);
out[..self.sign.len()].clone_from_slice(self.sign);

let mut written = self.sign.len();
for part in self.parts {
Expand Down
6 changes: 5 additions & 1 deletion src/libcore/num/int_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,25 @@ macro_rules! int_module { ($T:ty, $bits:expr) => (
#[unstable(feature = "num_bits_bytes",
reason = "may want to be an associated function",
issue = "27753")]
#[rustc_deprecated(since = "1.7.0",
reason = "will be replaced via const fn or associated constants")]
#[allow(missing_docs)]
pub const BITS : usize = $bits;
// FIXME(#11621): Should be deprecated once CTFE is implemented in favour of
// calling the `mem::size_of` function.
#[unstable(feature = "num_bits_bytes",
reason = "may want to be an associated function",
issue = "27753")]
#[rustc_deprecated(since = "1.7.0",
reason = "will be replaced via const fn or associated constants")]
#[allow(missing_docs)]
pub const BYTES : usize = ($bits / 8);

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

0 comments on commit 9a4f43b

Please sign in to comment.