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
This commit is contained in:
Alex Crichton 2016-01-15 10:07:52 -08:00
parent c14b615534
commit 9a4f43b9b6
58 changed files with 356 additions and 235 deletions

View File

@ -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)]

View File

@ -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
@ -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");
}

View File

@ -247,12 +247,15 @@ 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
@ -260,6 +263,7 @@ impl<'a, B: ?Sized> IntoCow<'a, B> for Cow<'a, B> where B: ToOwned {
}
#[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

View File

@ -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();

View File

@ -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};

View File

@ -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)]

View File

@ -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
@ -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];
/// let src = [1, 2, 3];
///
/// assert!(dst.clone_from_slice(&src) == 2);
/// assert!(dst == [1, 2, 0]);
///
/// 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)
}

View File

@ -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};
@ -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
@ -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> {
@ -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> {

View File

@ -73,6 +73,7 @@ use core::ops;
use core::ptr;
use core::slice;
#[allow(deprecated)]
use borrow::{Cow, IntoCow};
use super::range::RangeArgument;
@ -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
}
@ -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[..]
}
@ -1516,6 +1513,7 @@ 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)
@ -1523,6 +1521,7 @@ impl<'a, T: 'a> IntoCow<'a, [T]> for Vec<T> where T: Clone {
}
#[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)

View File

@ -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;
@ -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.

View File

@ -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
}

View File

@ -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};
@ -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);
@ -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;

View File

@ -10,6 +10,8 @@
//! Integer and floating-point number formatting
#![allow(deprecated)]
// FIXME: #6220 Implement floating point formatting
use prelude::v1::*;
@ -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,
}
@ -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);
@ -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))
}

View File

@ -195,6 +195,7 @@ pub trait Hasher {
mod impls {
use prelude::v1::*;
use mem;
use slice;
use super::*;
@ -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) })
}

View File

@ -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)
@ -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 {

View File

@ -17,6 +17,8 @@ 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
@ -24,6 +26,8 @@ pub const BITS : usize = $bits;
#[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);
@ -31,7 +35,7 @@ pub const BYTES : usize = ($bits / 8);
// 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.

View File

@ -13,8 +13,6 @@
#![stable(feature = "rust1", since = "1.0.0")]
#![allow(missing_docs)]
use self::wrapping::OverflowingOps;
use char::CharExt;
use cmp::{Eq, PartialOrd};
use convert::From;
@ -464,15 +462,13 @@ macro_rules! int_impl {
/// Basic usage:
///
/// ```
/// #![feature(wrapping)]
///
/// use std::i32;
///
/// assert_eq!(5i32.checked_rem(2), Some(1));
/// assert_eq!(5i32.checked_rem(0), None);
/// assert_eq!(i32::MIN.checked_rem(-1), None);
/// ```
#[unstable(feature = "wrapping", issue = "27755")]
#[stable(feature = "wrapping", since = "1.7.0")]
#[inline]
pub fn checked_rem(self, other: Self) -> Option<Self> {
if other == 0 {
@ -491,14 +487,12 @@ macro_rules! int_impl {
/// Basic usage:
///
/// ```
/// #![feature(wrapping)]
///
/// use std::i32;
///
/// assert_eq!(5i32.checked_neg(), Some(-5));
/// assert_eq!(i32::MIN.checked_neg(), None);
/// ```
#[unstable(feature = "wrapping", issue = "27755")]
#[stable(feature = "wrapping", since = "1.7.0")]
#[inline]
pub fn checked_neg(self) -> Option<Self> {
let (a, b) = self.overflowing_neg();
@ -513,12 +507,10 @@ macro_rules! int_impl {
/// Basic usage:
///
/// ```
/// #![feature(wrapping)]
///
/// assert_eq!(0x10i32.checked_shl(4), Some(0x100));
/// assert_eq!(0x10i32.checked_shl(33), None);
/// ```
#[unstable(feature = "wrapping", issue = "27755")]
#[stable(feature = "wrapping", since = "1.7.0")]
#[inline]
pub fn checked_shl(self, rhs: u32) -> Option<Self> {
let (a, b) = self.overflowing_shl(rhs);
@ -533,12 +525,10 @@ macro_rules! int_impl {
/// Basic usage:
///
/// ```
/// #![feature(wrapping)]
///
/// assert_eq!(0x10i32.checked_shr(4), Some(0x1));
/// assert_eq!(0x10i32.checked_shr(33), None);
/// ```
#[unstable(feature = "wrapping", issue = "27755")]
#[stable(feature = "wrapping", since = "1.7.0")]
#[inline]
pub fn checked_shr(self, rhs: u32) -> Option<Self> {
let (a, b) = self.overflowing_shr(rhs);
@ -595,15 +585,13 @@ macro_rules! int_impl {
/// Basic usage:
///
/// ```
/// #![feature(wrapping)]
///
/// use std::i32;
///
/// assert_eq!(100i32.saturating_mul(127), 12700);
/// assert_eq!((1i32 << 23).saturating_mul(1 << 23), i32::MAX);
/// assert_eq!((-1i32 << 23).saturating_mul(1 << 23), i32::MIN);
/// ```
#[unstable(feature = "wrapping", issue = "27755")]
#[stable(feature = "wrapping", since = "1.7.0")]
#[inline]
pub fn saturating_mul(self, other: Self) -> Self {
self.checked_mul(other).unwrap_or_else(|| {
@ -796,15 +784,13 @@ macro_rules! int_impl {
/// Basic usage
///
/// ```
/// #![feature(wrapping)]
///
/// use std::i32;
///
/// assert_eq!(5i32.overflowing_add(2), (7, false));
/// assert_eq!(i32::MAX.overflowing_add(1), (i32::MIN, true));
/// ```
#[inline]
#[unstable(feature = "wrapping", issue = "27755")]
#[stable(feature = "wrapping", since = "1.7.0")]
pub fn overflowing_add(self, rhs: Self) -> (Self, bool) {
unsafe {
let (a, b) = $add_with_overflow(self as $ActualT,
@ -824,15 +810,13 @@ macro_rules! int_impl {
/// Basic usage
///
/// ```
/// #![feature(wrapping)]
///
/// use std::i32;
///
/// assert_eq!(5i32.overflowing_sub(2), (3, false));
/// assert_eq!(i32::MIN.overflowing_sub(1), (i32::MAX, true));
/// ```
#[inline]
#[unstable(feature = "wrapping", issue = "27755")]
#[stable(feature = "wrapping", since = "1.7.0")]
pub fn overflowing_sub(self, rhs: Self) -> (Self, bool) {
unsafe {
let (a, b) = $sub_with_overflow(self as $ActualT,
@ -852,13 +836,11 @@ macro_rules! int_impl {
/// Basic usage
///
/// ```
/// #![feature(wrapping)]
///
/// assert_eq!(5i32.overflowing_mul(2), (10, false));
/// assert_eq!(1_000_000_000i32.overflowing_mul(10), (1410065408, true));
/// ```
#[inline]
#[unstable(feature = "wrapping", issue = "27755")]
#[stable(feature = "wrapping", since = "1.7.0")]
pub fn overflowing_mul(self, rhs: Self) -> (Self, bool) {
unsafe {
let (a, b) = $mul_with_overflow(self as $ActualT,
@ -882,15 +864,13 @@ macro_rules! int_impl {
/// Basic usage
///
/// ```
/// #![feature(wrapping)]
///
/// use std::i32;
///
/// assert_eq!(5i32.overflowing_div(2), (2, false));
/// assert_eq!(i32::MIN.overflowing_div(-1), (i32::MIN, true));
/// ```
#[inline]
#[unstable(feature = "wrapping", issue = "27755")]
#[stable(feature = "wrapping", since = "1.7.0")]
pub fn overflowing_div(self, rhs: Self) -> (Self, bool) {
if self == Self::min_value() && rhs == -1 {
(self, true)
@ -914,15 +894,13 @@ macro_rules! int_impl {
/// Basic usage
///
/// ```
/// #![feature(wrapping)]
///
/// use std::i32;
///
/// assert_eq!(5i32.overflowing_rem(2), (1, false));
/// assert_eq!(i32::MIN.overflowing_rem(-1), (0, true));
/// ```
#[inline]
#[unstable(feature = "wrapping", issue = "27755")]
#[stable(feature = "wrapping", since = "1.7.0")]
pub fn overflowing_rem(self, rhs: Self) -> (Self, bool) {
if self == Self::min_value() && rhs == -1 {
(0, true)
@ -944,15 +922,13 @@ macro_rules! int_impl {
/// Basic usage
///
/// ```
/// #![feature(wrapping)]
///
/// use std::i32;
///
/// assert_eq!(2i32.overflowing_neg(), (-2, false));
/// assert_eq!(i32::MIN.overflowing_neg(), (i32::MIN, true));
/// ```
#[inline]
#[unstable(feature = "wrapping", issue = "27755")]
#[stable(feature = "wrapping", since = "1.7.0")]
pub fn overflowing_neg(self) -> (Self, bool) {
if self == Self::min_value() {
(Self::min_value(), true)
@ -974,13 +950,11 @@ macro_rules! int_impl {
/// Basic usage
///
/// ```
/// #![feature(wrapping)]
///
/// assert_eq!(0x10i32.overflowing_shl(4), (0x100, false));
/// assert_eq!(0x10i32.overflowing_shl(36), (0x100, true));
/// ```
#[inline]
#[unstable(feature = "wrapping", issue = "27755")]
#[stable(feature = "wrapping", since = "1.7.0")]
pub fn overflowing_shl(self, rhs: u32) -> (Self, bool) {
(self << (rhs & ($BITS - 1)), (rhs > ($BITS - 1)))
}
@ -998,13 +972,11 @@ macro_rules! int_impl {
/// Basic usage
///
/// ```
/// #![feature(wrapping)]
///
/// assert_eq!(0x10i32.overflowing_shr(4), (0x1, false));
/// assert_eq!(0x10i32.overflowing_shr(36), (0x1, true));
/// ```
#[inline]
#[unstable(feature = "wrapping", issue = "27755")]
#[stable(feature = "wrapping", since = "1.7.0")]
pub fn overflowing_shr(self, rhs: u32) -> (Self, bool) {
(self >> (rhs & ($BITS - 1)), (rhs > ($BITS - 1)))
}
@ -1542,12 +1514,10 @@ macro_rules! uint_impl {
/// Basic usage:
///
/// ```
/// #![feature(wrapping)]
///
/// assert_eq!(5u32.checked_rem(2), Some(1));
/// assert_eq!(5u32.checked_rem(0), None);
/// ```
#[unstable(feature = "wrapping", issue = "27755")]
#[stable(feature = "wrapping", since = "1.7.0")]
#[inline]
pub fn checked_rem(self, other: Self) -> Option<Self> {
if other == 0 {
@ -1557,6 +1527,26 @@ macro_rules! uint_impl {
}
}
/// Checked negation. Computes `-self`, returning `None` unless `self ==
/// 0`.
///
/// Note that negating any positive integer will overflow.
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// assert_eq!(0u32.checked_neg(), Some(0));
/// assert_eq!(1u32.checked_neg(), None);
/// ```
#[stable(feature = "wrapping", since = "1.7.0")]
#[inline]
pub fn checked_neg(self) -> Option<Self> {
let (a, b) = self.overflowing_neg();
if b {None} else {Some(a)}
}
/// Checked shift left. Computes `self << rhs`, returning `None`
/// if `rhs` is larger than or equal to the number of bits in `self`.
///
@ -1565,12 +1555,10 @@ macro_rules! uint_impl {
/// Basic usage:
///
/// ```
/// #![feature(wrapping)]
///
/// assert_eq!(0x10u32.checked_shl(4), Some(0x100));
/// assert_eq!(0x10u32.checked_shl(33), None);
/// ```
#[unstable(feature = "wrapping", issue = "27755")]
#[stable(feature = "wrapping", since = "1.7.0")]
#[inline]
pub fn checked_shl(self, rhs: u32) -> Option<Self> {
let (a, b) = self.overflowing_shl(rhs);
@ -1585,12 +1573,10 @@ macro_rules! uint_impl {
/// Basic usage:
///
/// ```
/// #![feature(wrapping)]
///
/// assert_eq!(0x10u32.checked_shr(4), Some(0x1));
/// assert_eq!(0x10u32.checked_shr(33), None);
/// ```
#[unstable(feature = "wrapping", issue = "27755")]
#[stable(feature = "wrapping", since = "1.7.0")]
#[inline]
pub fn checked_shr(self, rhs: u32) -> Option<Self> {
let (a, b) = self.overflowing_shr(rhs);
@ -1647,14 +1633,12 @@ macro_rules! uint_impl {
/// Basic usage:
///
/// ```
/// #![feature(wrapping)]
///
/// use std::u32;
///
/// assert_eq!(100u32.saturating_mul(127), 12700);
/// assert_eq!((1u32 << 23).saturating_mul(1 << 23), u32::MAX);
/// ```
#[unstable(feature = "wrapping", issue = "27755")]
#[stable(feature = "wrapping", since = "1.7.0")]
#[inline]
pub fn saturating_mul(self, other: Self) -> Self {
self.checked_mul(other).unwrap_or(Self::max_value())
@ -1833,15 +1817,13 @@ macro_rules! uint_impl {
/// Basic usage
///
/// ```
/// #![feature(wrapping)]
///
/// use std::u32;
///
/// assert_eq!(5u32.overflowing_add(2), (7, false));
/// assert_eq!(u32::MAX.overflowing_add(1), (0, true));
/// ```
#[inline]
#[unstable(feature = "wrapping", issue = "27755")]
#[stable(feature = "wrapping", since = "1.7.0")]
pub fn overflowing_add(self, rhs: Self) -> (Self, bool) {
unsafe {
let (a, b) = $add_with_overflow(self as $ActualT,
@ -1861,15 +1843,13 @@ macro_rules! uint_impl {
/// Basic usage
///
/// ```
/// #![feature(wrapping)]
///
/// use std::u32;
///
/// assert_eq!(5u32.overflowing_sub(2), (3, false));
/// assert_eq!(0u32.overflowing_sub(1), (u32::MAX, true));
/// ```
#[inline]
#[unstable(feature = "wrapping", issue = "27755")]
#[stable(feature = "wrapping", since = "1.7.0")]
pub fn overflowing_sub(self, rhs: Self) -> (Self, bool) {
unsafe {
let (a, b) = $sub_with_overflow(self as $ActualT,
@ -1889,13 +1869,11 @@ macro_rules! uint_impl {
/// Basic usage
///
/// ```
/// #![feature(wrapping)]
///
/// assert_eq!(5u32.overflowing_mul(2), (10, false));
/// assert_eq!(1_000_000_000u32.overflowing_mul(10), (1410065408, true));
/// ```
#[inline]
#[unstable(feature = "wrapping", issue = "27755")]
#[stable(feature = "wrapping", since = "1.7.0")]
pub fn overflowing_mul(self, rhs: Self) -> (Self, bool) {
unsafe {
let (a, b) = $mul_with_overflow(self as $ActualT,
@ -1920,12 +1898,10 @@ macro_rules! uint_impl {
/// Basic usage
///
/// ```
/// #![feature(wrapping)]
///
/// assert_eq!(5u32.overflowing_div(2), (2, false));
/// ```
#[inline]
#[unstable(feature = "wrapping", issue = "27755")]
#[stable(feature = "wrapping", since = "1.7.0")]
pub fn overflowing_div(self, rhs: Self) -> (Self, bool) {
(self / rhs, false)
}
@ -1946,12 +1922,10 @@ macro_rules! uint_impl {
/// Basic usage
///
/// ```
/// #![feature(wrapping)]
///
/// assert_eq!(5u32.overflowing_rem(2), (1, false));
/// ```
#[inline]
#[unstable(feature = "wrapping", issue = "27755")]
#[stable(feature = "wrapping", since = "1.7.0")]
pub fn overflowing_rem(self, rhs: Self) -> (Self, bool) {
(self % rhs, false)
}
@ -1968,13 +1942,11 @@ macro_rules! uint_impl {
/// Basic usage
///
/// ```
/// #![feature(wrapping)]
///
/// assert_eq!(0u32.overflowing_neg(), (0, false));
/// assert_eq!(2u32.overflowing_neg(), (-2i32 as u32, true));
/// ```
#[inline]
#[unstable(feature = "wrapping", issue = "27755")]
#[stable(feature = "wrapping", since = "1.7.0")]
pub fn overflowing_neg(self) -> (Self, bool) {
((!self).wrapping_add(1), self != 0)
}
@ -1992,13 +1964,11 @@ macro_rules! uint_impl {
/// Basic usage
///
/// ```
/// #![feature(wrapping)]
///
/// assert_eq!(0x10u32.overflowing_shl(4), (0x100, false));
/// assert_eq!(0x10u32.overflowing_shl(36), (0x100, true));
/// ```
#[inline]
#[unstable(feature = "wrapping", issue = "27755")]
#[stable(feature = "wrapping", since = "1.7.0")]
pub fn overflowing_shl(self, rhs: u32) -> (Self, bool) {
(self << (rhs & ($BITS - 1)), (rhs > ($BITS - 1)))
}
@ -2016,13 +1986,11 @@ macro_rules! uint_impl {
/// Basic usage
///
/// ```
/// #![feature(wrapping)]
///
/// assert_eq!(0x10u32.overflowing_shr(4), (0x1, false));
/// assert_eq!(0x10u32.overflowing_shr(36), (0x1, true));
/// ```
#[inline]
#[unstable(feature = "wrapping", issue = "27755")]
#[stable(feature = "wrapping", since = "1.7.0")]
pub fn overflowing_shr(self, rhs: u32) -> (Self, bool) {
(self >> (rhs & ($BITS - 1)), (rhs > ($BITS - 1)))
}

View File

@ -15,11 +15,15 @@ macro_rules! uint_module { ($T:ty, $T_SIGNED: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;
#[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);

View File

@ -14,4 +14,7 @@
#![stable(feature = "rust1", since = "1.0.0")]
uint_module! { usize, isize, ::isize::BITS }
#[cfg(target_pointer_width = "32")]
uint_module! { usize, isize, 32 }
#[cfg(target_pointer_width = "64")]
uint_module! { usize, isize, 64 }

View File

@ -9,7 +9,7 @@
// except according to those terms.
#![allow(missing_docs)]
#![unstable(feature = "wrapping", reason = "may be removed or relocated",
#![unstable(feature = "old_wrapping", reason = "may be removed or relocated",
issue = "27755")]
use intrinsics::{add_with_overflow, sub_with_overflow, mul_with_overflow};
@ -20,6 +20,9 @@ use ops::*;
use ::{i8, i16, i32, i64, isize};
#[unstable(feature = "old_wrapping", reason = "may be removed or relocated",
issue = "27755")]
#[rustc_deprecated(since = "1.7.0", reason = "moved to inherent methods")]
pub trait OverflowingOps {
fn overflowing_add(self, rhs: Self) -> (Self, bool);
fn overflowing_sub(self, rhs: Self) -> (Self, bool);
@ -331,6 +334,7 @@ mod shift_max {
macro_rules! signed_overflowing_impl {
($($t:ident)*) => ($(
#[allow(deprecated)]
impl OverflowingOps for $t {
#[inline(always)]
fn overflowing_add(self, rhs: $t) -> ($t, bool) {
@ -393,6 +397,7 @@ macro_rules! signed_overflowing_impl {
macro_rules! unsigned_overflowing_impl {
($($t:ident)*) => ($(
#[allow(deprecated)]
impl OverflowingOps for $t {
#[inline(always)]
fn overflowing_add(self, rhs: $t) -> ($t, bool) {

View File

@ -49,7 +49,6 @@ use result::Result::{Ok, Err};
use ptr;
use mem;
use marker::{Send, Sync, self};
use num::wrapping::OverflowingOps;
use raw::Repr;
// Avoid conflicts with *both* the Slice trait (buggy) and the `slice::raw` module.
use raw::Slice as RawSlice;
@ -151,8 +150,8 @@ pub trait SliceExt {
#[stable(feature = "core", since = "1.6.0")]
fn ends_with(&self, needle: &[Self::Item]) -> bool where Self::Item: PartialEq;
#[unstable(feature = "clone_from_slice", issue= "27750")]
fn clone_from_slice(&mut self, &[Self::Item]) -> usize where Self::Item: Clone;
#[stable(feature = "clone_from_slice", since = "1.7.0")]
fn clone_from_slice(&mut self, &[Self::Item]) where Self::Item: Clone;
}
// Use macros to be generic over const/mut
@ -476,14 +475,12 @@ impl<T> SliceExt for [T] {
}
#[inline]
fn clone_from_slice(&mut self, src: &[T]) -> usize where T: Clone {
let min = cmp::min(self.len(), src.len());
let dst = &mut self[.. min];
let src = &src[.. min];
for i in 0..min {
dst[i].clone_from(&src[i]);
fn clone_from_slice(&mut self, src: &[T]) where T: Clone {
assert!(self.len() == src.len(),
"destination and source slices have different lengths");
for (dst, src) in self.iter_mut().zip(src) {
dst.clone_from(src);
}
min
}
}

View File

@ -32,7 +32,6 @@ use option::Option::{self, None, Some};
use raw::{Repr, Slice};
use result::Result::{self, Ok, Err};
use slice::{self, SliceExt};
use usize;
pub mod pattern;
@ -1160,15 +1159,16 @@ fn run_utf8_validation(v: &[u8]) -> Result<(), Utf8Error> {
// Ascii case, try to skip forward quickly.
// When the pointer is aligned, read 2 words of data per iteration
// until we find a word containing a non-ascii byte.
const BYTES_PER_ITERATION: usize = 2 * usize::BYTES;
let usize_bytes = mem::size_of::<usize>();
let bytes_per_iteration = 2 * usize_bytes;
let ptr = v.as_ptr();
let align = (ptr as usize + offset) & (usize::BYTES - 1);
let align = (ptr as usize + offset) & (usize_bytes - 1);
if align == 0 {
if len >= BYTES_PER_ITERATION {
while offset <= len - BYTES_PER_ITERATION {
if len >= bytes_per_iteration {
while offset <= len - bytes_per_iteration {
unsafe {
let u = *(ptr.offset(offset as isize) as *const usize);
let v = *(ptr.offset((offset + usize::BYTES) as isize) as *const usize);
let v = *(ptr.offset((offset + usize_bytes) as isize) as *const usize);
// break if there is a nonascii byte
let zu = contains_nonascii(u);
@ -1177,7 +1177,7 @@ fn run_utf8_validation(v: &[u8]) -> Result<(), Utf8Error> {
break;
}
}
offset += BYTES_PER_ITERATION;
offset += bytes_per_iteration;
}
}
// step from the point where the wordwise loop stopped

View File

@ -100,7 +100,7 @@ fn check_exact<F, T>(mut f: F, v: T, vstr: &str, expected: &[u8], expectedk: i16
// check significant digits
for i in 1..cut.unwrap_or(expected.len() - 1) {
expected_.clone_from_slice(&expected[..i]);
expected_[..i].clone_from_slice(&expected[..i]);
let mut expectedk_ = expectedk;
if expected[i] >= b'5' {
// check if this is a rounding-to-even case.
@ -147,7 +147,7 @@ fn check_exact<F, T>(mut f: F, v: T, vstr: &str, expected: &[u8], expectedk: i16
// check infinite zero digits
if let Some(cut) = cut {
for i in cut..expected.len()-1 {
expected_.clone_from_slice(&expected[..cut]);
expected_[..cut].clone_from_slice(&expected[..cut]);
for c in &mut expected_[cut..i] { *c = b'0'; }
try_exact!(f(&decoded) => &mut buf, &expected_[..i], expectedk;

View File

@ -47,9 +47,9 @@
//! which is cyclic.
//!
//! ```rust
//! #![feature(rustc_private, into_cow)]
//! #![feature(rustc_private)]
//!
//! use std::borrow::IntoCow;
//! use graphviz::IntoCow;
//! use std::io::Write;
//! use graphviz as dot;
//!
@ -281,12 +281,11 @@
html_root_url = "https://doc.rust-lang.org/nightly/",
test(attr(allow(unused_variables), deny(warnings))))]
#![feature(into_cow)]
#![feature(str_escape)]
use self::LabelText::*;
use std::borrow::{IntoCow, Cow};
use std::borrow::{Cow, ToOwned};
use std::io::prelude::*;
use std::io;
@ -719,6 +718,34 @@ pub fn render_opts<'a,
writeln(w, &["}"])
}
pub trait IntoCow<'a, B: ?Sized> where B: ToOwned {
fn into_cow(self) -> Cow<'a, B>;
}
impl<'a> IntoCow<'a, str> for String {
fn into_cow(self) -> Cow<'a, str> {
Cow::Owned(self)
}
}
impl<'a> IntoCow<'a, str> for &'a str {
fn into_cow(self) -> Cow<'a, str> {
Cow::Borrowed(self)
}
}
impl<'a, T: Clone> IntoCow<'a, [T]> for Vec<T> {
fn into_cow(self) -> Cow<'a, [T]> {
Cow::Owned(self)
}
}
impl<'a, T: Clone> IntoCow<'a, [T]> for &'a [T] {
fn into_cow(self) -> Cow<'a, [T]> {
Cow::Borrowed(self)
}
}
#[cfg(test)]
mod tests {
use self::NodeLabels::*;
@ -726,7 +753,7 @@ mod tests {
use super::LabelText::{self, LabelStr, EscStr, HtmlStr};
use std::io;
use std::io::prelude::*;
use std::borrow::IntoCow;
use IntoCow;
/// each node is an index in a vector in the graph.
type Node = usize;

View File

@ -123,7 +123,6 @@
#![feature(rustc_private)]
#![feature(staged_api)]
#![feature(clone_from_slice)]
#![cfg_attr(test, feature(test))]
@ -972,7 +971,7 @@ pub mod writer {
{
let last_size_pos = last_size_pos as usize;
let data = &self.writer.get_ref()[last_size_pos+4..cur_pos as usize];
buf.clone_from_slice(data);
buf[..size].clone_from_slice(data);
}
// overwrite the size and data and continue

View File

@ -26,16 +26,13 @@
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(cell_extras)]
#![feature(clone_from_slice)]
#![feature(collections)]
#![feature(const_fn)]
#![feature(enumset)]
#![feature(hashmap_hasher)]
#![feature(into_cow)]
#![feature(iter_arith)]
#![feature(libc)]
#![feature(nonzero)]
#![feature(num_bits_bytes)]
#![feature(quote)]
#![feature(rustc_diagnostic_macros)]
#![feature(rustc_private)]
@ -44,7 +41,6 @@
#![feature(staged_api)]
#![feature(str_char)]
#![feature(time2)]
#![feature(wrapping)]
#![cfg_attr(test, feature(test))]
#![allow(trivial_casts)]

View File

@ -11,10 +11,9 @@
/// This module provides linkage between rustc::middle::graph and
/// libgraphviz traits.
use std::borrow::IntoCow;
// For clarity, rename the graphviz crate locally to dot.
use graphviz as dot;
use graphviz::IntoCow;
use syntax::ast;

View File

@ -26,6 +26,7 @@ use middle::astconv_util::ast_ty_to_prim_ty;
use util::num::ToPrimitive;
use util::nodemap::NodeMap;
use graphviz::IntoCow;
use syntax::{ast, abi};
use rustc_front::hir::Expr;
use rustc_front::hir;
@ -35,8 +36,7 @@ use syntax::parse::token::InternedString;
use syntax::ptr::P;
use syntax::codemap;
use std::borrow::{Cow, IntoCow};
use std::num::wrapping::OverflowingOps;
use std::borrow::Cow;
use std::cmp::Ordering;
use std::collections::hash_map::Entry::Vacant;
use std::hash;

View File

@ -18,6 +18,7 @@ use middle::cfg;
use middle::cfg::CFGIndex;
use middle::ty;
use std::io;
use std::mem;
use std::usize;
use syntax::ast;
use syntax::ast_util::IdRange;
@ -229,7 +230,8 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> {
oper: O,
id_range: IdRange,
bits_per_id: usize) -> DataFlowContext<'a, 'tcx, O> {
let words_per_id = (bits_per_id + usize::BITS - 1) / usize::BITS;
let usize_bits = mem::size_of::<usize>() * 8;
let words_per_id = (bits_per_id + usize_bits - 1) / usize_bits;
let num_nodes = cfg.graph.all_nodes().len();
debug!("DataFlowContext::new(analysis_name: {}, id_range={:?}, \
@ -408,10 +410,11 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> {
//! Returns false on the first call to `f` that returns false;
//! if all calls to `f` return true, then returns true.
let usize_bits = mem::size_of::<usize>() * 8;
for (word_index, &word) in words.iter().enumerate() {
if word != 0 {
let base_index = word_index * usize::BITS;
for offset in 0..usize::BITS {
let base_index = word_index * usize_bits;
for offset in 0..usize_bits {
let bit = 1 << offset;
if (word & bit) != 0 {
// NB: we round up the total number of bits
@ -618,7 +621,7 @@ fn bits_to_string(words: &[usize]) -> String {
for &word in words {
let mut v = word;
for _ in 0..usize::BYTES {
for _ in 0..mem::size_of::<usize>() {
result.push(sep);
result.push_str(&format!("{:02x}", v & 0xFF));
v >>= 8;
@ -647,8 +650,9 @@ fn bitwise<Op:BitwiseOperator>(out_vec: &mut [usize],
fn set_bit(words: &mut [usize], bit: usize) -> bool {
debug!("set_bit: words={} bit={}",
mut_bits_to_string(words), bit_str(bit));
let word = bit / usize::BITS;
let bit_in_word = bit % usize::BITS;
let usize_bits = mem::size_of::<usize>() * 8;
let word = bit / usize_bits;
let bit_in_word = bit % usize_bits;
let bit_mask = 1 << bit_in_word;
debug!("word={} bit_in_word={} bit_mask={}", word, bit_in_word, word);
let oldv = words[word];

View File

@ -17,8 +17,9 @@ use rustc_data_structures::tuple_slice::TupleSlice;
use rustc_front::hir::InlineAsm;
use syntax::ast::{self, Name};
use syntax::codemap::Span;
use graphviz::IntoCow;
use std::ascii;
use std::borrow::{Cow, IntoCow};
use std::borrow::Cow;
use std::fmt::{self, Debug, Formatter, Write};
use std::{iter, u32};
use std::ops::{Index, IndexMut};

View File

@ -33,7 +33,6 @@
#![feature(libc)]
#![feature(rand)]
#![feature(rustc_private)]
#![feature(clone_from_slice)]
#![feature(staged_api)]
#![feature(step_by)]
#![cfg_attr(test, feature(test, rand))]

View File

@ -23,7 +23,7 @@ use dot;
use rustc::middle::cfg::CFGIndex;
use rustc::middle::dataflow::{DataFlowOperator, DataFlowContext, EntryOrExit};
use std::rc::Rc;
use std::borrow::IntoCow;
use dot::IntoCow;
#[derive(Debug, Copy, Clone)]
pub enum Variant {

View File

@ -22,7 +22,6 @@
#![feature(rustc_diagnostic_macros)]
#![feature(rustc_private)]
#![feature(staged_api)]
#![feature(into_cow)]
#[macro_use] extern crate log;
#[macro_use] extern crate syntax;

View File

@ -30,7 +30,6 @@
#![cfg_attr(test, feature(test))]
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(num_bits_bytes)]
#![feature(quote)]
#![feature(rustc_diagnostic_macros)]
#![feature(rustc_private)]

View File

@ -275,20 +275,20 @@ impl LateLintPass for TypeLimits {
fn int_ty_bits(int_ty: ast::IntTy, target_int_ty: ast::IntTy) -> u64 {
match int_ty {
ast::TyIs => int_ty_bits(target_int_ty, target_int_ty),
ast::TyI8 => i8::BITS as u64,
ast::TyI16 => i16::BITS as u64,
ast::TyI32 => i32::BITS as u64,
ast::TyI64 => i64::BITS as u64
ast::TyI8 => 8,
ast::TyI16 => 16 as u64,
ast::TyI32 => 32,
ast::TyI64 => 64,
}
}
fn uint_ty_bits(uint_ty: ast::UintTy, target_uint_ty: ast::UintTy) -> u64 {
match uint_ty {
ast::TyUs => uint_ty_bits(target_uint_ty, target_uint_ty),
ast::TyU8 => u8::BITS as u64,
ast::TyU16 => u16::BITS as u64,
ast::TyU32 => u32::BITS as u64,
ast::TyU64 => u64::BITS as u64
ast::TyU8 => 8,
ast::TyU16 => 16,
ast::TyU32 => 32,
ast::TyU64 => 64,
}
}

View File

@ -27,10 +27,8 @@
#![feature(const_fn)]
#![feature(custom_attribute)]
#![allow(unused_attributes)]
#![feature(into_cow)]
#![feature(iter_arith)]
#![feature(libc)]
#![feature(path_relative_from)]
#![feature(quote)]
#![feature(rustc_diagnostic_macros)]
#![feature(rustc_private)]

View File

@ -45,7 +45,7 @@ use rustc_data_structures::fnv::{FnvHashMap, FnvHashSet};
use rustc_data_structures::graph::{Direction, INCOMING, OUTGOING, NodeIndex};
use rustc_front::hir;
use rustc_front::intravisit::Visitor;
use std::borrow::IntoCow;
use graphviz::IntoCow;
use std::env;
use std::fs::File;
use std::io::Write;

View File

@ -990,8 +990,8 @@ pub fn compile_unit_metadata(cx: &CrateContext) -> DIDescriptor {
cx.sess().warn("debuginfo: Invalid path to crate's local root source file!");
fallback_path(cx)
} else {
match abs_path.relative_from(work_dir) {
Some(ref p) if p.is_relative() => {
match abs_path.strip_prefix(work_dir) {
Ok(ref p) if p.is_relative() => {
if p.starts_with(Path::new("./")) {
path2cstr(p)
} else {

View File

@ -819,7 +819,7 @@ fn clean_srcpath<F>(src_root: &Path, p: &Path, keep_filename: bool, mut f: F) wh
F: FnMut(&str),
{
// make it relative, if possible
let p = p.relative_from(src_root).unwrap_or(p);
let p = p.strip_prefix(src_root).unwrap_or(p);
let mut iter = p.iter().map(|x| x.to_str().unwrap()).peekable();
while let Some(c) = iter.next() {

View File

@ -21,7 +21,6 @@
#![feature(box_syntax)]
#![feature(dynamic_lib)]
#![feature(libc)]
#![feature(path_relative_from)]
#![feature(rustc_private)]
#![feature(set_stdio)]
#![feature(slice_patterns)]

View File

@ -10,10 +10,9 @@
//! Implementations of serialization for structures found in libcollections
use std::usize;
use std::default::Default;
use std::hash::Hash;
use std::collections::hash_state::HashState;
use std::mem;
use {Decodable, Encodable, Decoder, Encoder};
use std::collections::{LinkedList, VecDeque, BTreeMap, BTreeSet, HashMap, HashSet};
@ -148,7 +147,7 @@ impl<
fn decode<D: Decoder>(d: &mut D) -> Result<EnumSet<T>, D::Error> {
let bits = try!(d.read_uint());
let mut set = EnumSet::new();
for bit in 0..usize::BITS {
for bit in 0..(mem::size_of::<usize>()*8) {
if bits & (1 << bit) != 0 {
set.insert(CLike::from_usize(1 << bit));
}

View File

@ -30,7 +30,6 @@ Core encoding and decoding interfaces.
#![feature(collections)]
#![feature(enumset)]
#![feature(hashmap_hasher)]
#![feature(num_bits_bytes)]
#![feature(rustc_private)]
#![feature(staged_api)]
#![feature(str_char)]

View File

@ -15,7 +15,6 @@ use hash::{Hash, Hasher};
use marker;
use mem::{align_of, size_of};
use mem;
use num::wrapping::OverflowingOps;
use ops::{Deref, DerefMut};
use ptr::{self, Unique};
use collections::hash_state::HashState;

View File

@ -150,7 +150,7 @@ pub struct NulError(usize, Vec<u8>);
/// An error returned from `CString::into_string` to indicate that a UTF-8 error
/// was encountered during the conversion.
#[derive(Clone, PartialEq, Debug)]
#[unstable(feature = "cstring_into", reason = "recently added", issue = "29157")]
#[stable(feature = "cstring_into", since = "1.7.0")]
pub struct IntoStringError {
inner: CString,
error: Utf8Error,
@ -235,7 +235,7 @@ impl CString {
/// Converts the `CString` into a `String` if it contains valid Unicode data.
///
/// On failure, ownership of the original `CString` is returned.
#[unstable(feature = "cstring_into", reason = "recently added", issue = "29157")]
#[stable(feature = "cstring_into", since = "1.7.0")]
pub fn into_string(self) -> Result<String, IntoStringError> {
String::from_utf8(self.into_bytes())
.map_err(|e| IntoStringError {
@ -248,9 +248,8 @@ impl CString {
///
/// The returned buffer does **not** contain the trailing nul separator and
/// it is guaranteed to not have any interior nul bytes.
#[unstable(feature = "cstring_into", reason = "recently added", issue = "29157")]
#[stable(feature = "cstring_into", since = "1.7.0")]
pub fn into_bytes(self) -> Vec<u8> {
// FIXME: Once this method becomes stable, add an `impl Into<Vec<u8>> for CString`
let mut vec = self.inner.into_vec();
let _nul = vec.pop();
debug_assert_eq!(_nul, Some(0u8));
@ -259,7 +258,7 @@ impl CString {
/// Equivalent to the `into_bytes` function except that the returned vector
/// includes the trailing nul byte.
#[unstable(feature = "cstring_into", reason = "recently added", issue = "29157")]
#[stable(feature = "cstring_into", since = "1.7.0")]
pub fn into_bytes_with_nul(self) -> Vec<u8> {
self.inner.into_vec()
}
@ -297,6 +296,13 @@ impl fmt::Debug for CString {
}
}
#[stable(feature = "cstring_into", since = "1.7.0")]
impl From<CString> for Vec<u8> {
fn from(s: CString) -> Vec<u8> {
s.into_bytes()
}
}
#[stable(feature = "cstr_debug", since = "1.3.0")]
impl fmt::Debug for CStr {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@ -348,29 +354,33 @@ impl From<NulError> for io::Error {
impl IntoStringError {
/// Consumes this error, returning original `CString` which generated the
/// error.
#[unstable(feature = "cstring_into", reason = "recently added", issue = "29157")]
#[stable(feature = "cstring_into", since = "1.7.0")]
pub fn into_cstring(self) -> CString {
self.inner
}
/// Access the underlying UTF-8 error that was the cause of this error.
#[unstable(feature = "cstring_into", reason = "recently added", issue = "29157")]
#[stable(feature = "cstring_into", since = "1.7.0")]
pub fn utf8_error(&self) -> Utf8Error {
self.error
}
}
#[unstable(feature = "cstring_into", reason = "recently added", issue = "29157")]
#[stable(feature = "cstring_into", since = "1.7.0")]
impl Error for IntoStringError {
fn description(&self) -> &str {
Error::description(&self.error)
"C string contained non-utf8 bytes"
}
fn cause(&self) -> Option<&Error> {
Some(&self.error)
}
}
#[unstable(feature = "cstring_into", reason = "recently added", issue = "29157")]
#[stable(feature = "cstring_into", since = "1.7.0")]
impl fmt::Display for IntoStringError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Display::fmt(&self.error, f)
self.description().fmt(f)
}
}

View File

@ -252,10 +252,13 @@ impl Write for Cursor<Vec<u8>> {
// Figure out what bytes will be used to overwrite what's currently
// there (left), and what will be appended on the end (right)
let space = self.inner.len() - pos as usize;
let (left, right) = buf.split_at(cmp::min(space, buf.len()));
self.inner[(pos as usize)..].clone_from_slice(left);
self.inner.extend_from_slice(right);
{
let pos = pos as usize;
let space = self.inner.len() - pos;
let (left, right) = buf.split_at(cmp::min(space, buf.len()));
self.inner[pos..pos + left.len()].clone_from_slice(left);
self.inner.extend_from_slice(right);
}
// Bump us forward
self.set_position(pos + buf.len() as u64);

View File

@ -156,7 +156,7 @@ impl<'a> Read for &'a [u8] {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
let amt = cmp::min(buf.len(), self.len());
let (a, b) = self.split_at(amt);
buf.clone_from_slice(a);
buf[..amt].clone_from_slice(a);
*self = b;
Ok(amt)
}

View File

@ -219,7 +219,6 @@
#![feature(cfg_target_vendor)]
#![feature(cfg_target_thread_local)]
#![feature(char_internals)]
#![feature(clone_from_slice)]
#![feature(collections)]
#![feature(collections_bound)]
#![feature(const_fn)]
@ -240,6 +239,7 @@
#![feature(linkage)]
#![feature(macro_reexport)]
#![feature(num_bits_bytes)]
#![feature(old_wrapping)]
#![feature(on_unimplemented)]
#![feature(oom)]
#![feature(optin_builtin_traits)]
@ -266,7 +266,6 @@
#![feature(unsafe_no_drop_flag, filling_drop)]
#![feature(unwind_attributes)]
#![feature(vec_push_all)]
#![feature(wrapping)]
#![feature(zero_one)]
// Don't link to std. We are std.

View File

@ -107,7 +107,7 @@ pub fn memrchr(needle: u8, haystack: &[u8]) -> Option<usize> {
#[allow(dead_code)]
mod fallback {
use cmp;
use usize;
use mem;
const LO_U64: u64 = 0x0101010101010101;
const HI_U64: u64 = 0x8080808080808080;
@ -155,12 +155,13 @@ mod fallback {
// - the last remaining part, < 2 word size
let len = text.len();
let ptr = text.as_ptr();
let usize_bytes = mem::size_of::<usize>();
// search up to an aligned boundary
let align = (ptr as usize) & (usize::BYTES- 1);
let align = (ptr as usize) & (usize_bytes- 1);
let mut offset;
if align > 0 {
offset = cmp::min(usize::BYTES - align, len);
offset = cmp::min(usize_bytes - align, len);
if let Some(index) = text[..offset].iter().position(|elt| *elt == x) {
return Some(index);
}
@ -171,11 +172,11 @@ mod fallback {
// search the body of the text
let repeated_x = repeat_byte(x);
if len >= 2 * usize::BYTES {
while offset <= len - 2 * usize::BYTES {
if len >= 2 * usize_bytes {
while offset <= len - 2 * usize_bytes {
unsafe {
let u = *(ptr.offset(offset as isize) as *const usize);
let v = *(ptr.offset((offset + usize::BYTES) as isize) as *const usize);
let v = *(ptr.offset((offset + usize_bytes) as isize) as *const usize);
// break if there is a matching byte
let zu = contains_zero_byte(u ^ repeated_x);
@ -184,7 +185,7 @@ mod fallback {
break;
}
}
offset += usize::BYTES * 2;
offset += usize_bytes * 2;
}
}
@ -202,12 +203,13 @@ mod fallback {
// - the first remaining bytes, < 2 word size
let len = text.len();
let ptr = text.as_ptr();
let usize_bytes = mem::size_of::<usize>();
// search to an aligned boundary
let end_align = (ptr as usize + len) & (usize::BYTES - 1);
let end_align = (ptr as usize + len) & (usize_bytes - 1);
let mut offset;
if end_align > 0 {
offset = len - cmp::min(usize::BYTES - end_align, len);
offset = len - cmp::min(usize_bytes - end_align, len);
if let Some(index) = text[offset..].iter().rposition(|elt| *elt == x) {
return Some(offset + index);
}
@ -218,10 +220,10 @@ mod fallback {
// search the body of the text
let repeated_x = repeat_byte(x);
while offset >= 2 * usize::BYTES {
while offset >= 2 * usize_bytes {
unsafe {
let u = *(ptr.offset(offset as isize - 2 * usize::BYTES as isize) as *const usize);
let v = *(ptr.offset(offset as isize - usize::BYTES as isize) as *const usize);
let u = *(ptr.offset(offset as isize - 2 * usize_bytes as isize) as *const usize);
let v = *(ptr.offset(offset as isize - usize_bytes as isize) as *const usize);
// break if there is a matching byte
let zu = contains_zero_byte(u ^ repeated_x);
@ -230,7 +232,7 @@ mod fallback {
break;
}
}
offset -= 2 * usize::BYTES;
offset -= 2 * usize_bytes;
}
// find the byte before the point the body loop stopped

View File

@ -89,6 +89,9 @@ impl Ipv4Addr {
}
/// Returns true if this is a loopback address (127.0.0.0/8).
///
/// This property is defined by RFC 6890
#[stable(since = "1.7.0", feature = "ip_17")]
pub fn is_loopback(&self) -> bool {
self.octets()[0] == 127
}
@ -100,6 +103,7 @@ impl Ipv4Addr {
/// - 10.0.0.0/8
/// - 172.16.0.0/12
/// - 192.168.0.0/16
#[stable(since = "1.7.0", feature = "ip_17")]
pub fn is_private(&self) -> bool {
match (self.octets()[0], self.octets()[1]) {
(10, _) => true,
@ -110,6 +114,9 @@ impl Ipv4Addr {
}
/// Returns true if the address is link-local (169.254.0.0/16).
///
/// This property is defined by RFC 6890
#[stable(since = "1.7.0", feature = "ip_17")]
pub fn is_link_local(&self) -> bool {
self.octets()[0] == 169 && self.octets()[1] == 254
}
@ -130,7 +137,9 @@ impl Ipv4Addr {
/// Returns true if this is a multicast address.
///
/// Multicast addresses have a most significant octet between 224 and 239.
/// Multicast addresses have a most significant octet between 224 and 239,
/// and is defined by RFC 5771
#[stable(since = "1.7.0", feature = "ip_17")]
pub fn is_multicast(&self) -> bool {
self.octets()[0] >= 224 && self.octets()[0] <= 239
}
@ -138,6 +147,7 @@ impl Ipv4Addr {
/// Returns true if this is a broadcast address.
///
/// A broadcast address has all octets set to 255 as defined in RFC 919.
#[stable(since = "1.7.0", feature = "ip_17")]
pub fn is_broadcast(&self) -> bool {
self.octets()[0] == 255 && self.octets()[1] == 255 &&
self.octets()[2] == 255 && self.octets()[3] == 255
@ -150,6 +160,7 @@ impl Ipv4Addr {
/// - 192.0.2.0/24 (TEST-NET-1)
/// - 198.51.100.0/24 (TEST-NET-2)
/// - 203.0.113.0/24 (TEST-NET-3)
#[stable(since = "1.7.0", feature = "ip_17")]
pub fn is_documentation(&self) -> bool {
match(self.octets()[0], self.octets()[1], self.octets()[2], self.octets()[3]) {
(192, 0, 2, _) => true,
@ -302,11 +313,17 @@ impl Ipv6Addr {
}
/// Returns true for the special 'unspecified' address ::.
///
/// This property is defined in RFC 6890.
#[stable(since = "1.7.0", feature = "ip_17")]
pub fn is_unspecified(&self) -> bool {
self.segments() == [0, 0, 0, 0, 0, 0, 0, 0]
}
/// Returns true if this is a loopback address (::1).
///
/// This property is defined in RFC 6890.
#[stable(since = "1.7.0", feature = "ip_17")]
pub fn is_loopback(&self) -> bool {
self.segments() == [0, 0, 0, 0, 0, 0, 0, 1]
}
@ -378,7 +395,9 @@ impl Ipv6Addr {
/// Returns true if this is a multicast address.
///
/// Multicast addresses have the form ff00::/8.
/// Multicast addresses have the form ff00::/8, and this property is defined
/// by RFC 3956.
#[stable(since = "1.7.0", feature = "ip_17")]
pub fn is_multicast(&self) -> bool {
(self.segments()[0] & 0xff00) == 0xff00
}

View File

@ -193,7 +193,7 @@ impl<'a> Parser<'a> {
fn ipv6_addr_from_head_tail(head: &[u16], tail: &[u16]) -> Ipv6Addr {
assert!(head.len() + tail.len() <= 8);
let mut gs = [0; 8];
gs.clone_from_slice(head);
gs[..head.len()].clone_from_slice(head);
gs[(8 - tail.len()) .. 8].clone_from_slice(tail);
Ipv6Addr::new(gs[0], gs[1], gs[2], gs[3], gs[4], gs[5], gs[6], gs[7])
}

View File

@ -100,8 +100,10 @@
#![stable(feature = "rust1", since = "1.0.0")]
use ascii::*;
#[allow(deprecated)]
use borrow::{Borrow, IntoCow, ToOwned, Cow};
use cmp;
use error::Error;
use fmt;
use fs;
use hash::{Hash, Hasher};
@ -1043,6 +1045,7 @@ impl PathBuf {
self._push(path.as_ref())
}
#[allow(deprecated)]
fn _push(&mut self, path: &Path) {
// in general, a separator is needed if the rightmost byte is not a separator
let mut need_sep = self.as_mut_vec().last().map(|c| !is_sep_byte(*c)).unwrap_or(false);
@ -1219,6 +1222,7 @@ impl Borrow<Path> for PathBuf {
}
#[stable(feature = "rust1", since = "1.0.0")]
#[allow(deprecated)]
impl IntoCow<'static, Path> for PathBuf {
fn into_cow(self) -> Cow<'static, Path> {
Cow::Owned(self)
@ -1226,6 +1230,7 @@ impl IntoCow<'static, Path> for PathBuf {
}
#[stable(feature = "rust1", since = "1.0.0")]
#[allow(deprecated)]
impl<'a> IntoCow<'a, Path> for &'a Path {
fn into_cow(self) -> Cow<'a, Path> {
Cow::Borrowed(self)
@ -1328,6 +1333,12 @@ pub struct Path {
inner: OsStr,
}
/// An error returned from the `Path::strip_prefix` method indicating that the
/// prefix was not found in `self`.
#[derive(Debug, Clone, PartialEq, Eq)]
#[stable(since = "1.7.0", feature = "strip_prefix")]
pub struct StripPrefixError(());
impl Path {
// The following (private!) function allows construction of a path from a u8
// slice, which is only safe when it is known to follow the OsStr encoding.
@ -1447,6 +1458,7 @@ impl Path {
/// assert!(!Path::new("foo.txt").is_absolute());
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[allow(deprecated)]
pub fn is_absolute(&self) -> bool {
self.has_root() && (cfg!(unix) || self.prefix().is_some())
}
@ -1473,6 +1485,8 @@ impl Path {
#[unstable(feature = "path_prefix",
reason = "uncertain whether to expose this convenience",
issue = "27722")]
#[rustc_deprecated(since = "1.7.0",
reason = "inspect components().next() instead")]
pub fn prefix(&self) -> Option<Prefix> {
self.components().prefix
}
@ -1561,12 +1575,28 @@ impl Path {
/// returns false), then `relative_from` returns `None`.
#[unstable(feature = "path_relative_from", reason = "see #23284",
issue = "23284")]
#[rustc_deprecated(since = "1.7.0", reason = "renamed to strip_prefix")]
pub fn relative_from<'a, P: ?Sized + AsRef<Path>>(&'a self, base: &'a P) -> Option<&Path> {
self._relative_from(base.as_ref())
self._strip_prefix(base.as_ref()).ok()
}
fn _relative_from<'a>(&'a self, base: &'a Path) -> Option<&'a Path> {
iter_after(self.components(), base.components()).map(|c| c.as_path())
/// Returns a path that, when joined onto `base`, yields `self`.
///
/// If `base` is not a prefix of `self` (i.e. `starts_with`
/// returns false), then `relative_from` returns `None`.
#[stable(since = "1.7.0", feature = "path_strip_prefix")]
pub fn strip_prefix<'a, P: ?Sized>(&'a self, base: &'a P)
-> Result<&'a Path, StripPrefixError>
where P: AsRef<Path>
{
self._strip_prefix(base.as_ref())
}
fn _strip_prefix<'a>(&'a self, base: &'a Path)
-> Result<&'a Path, StripPrefixError> {
iter_after(self.components(), base.components())
.map(|c| c.as_path())
.ok_or(StripPrefixError(()))
}
/// Determines whether `base` is a prefix of `self`.
@ -2015,6 +2045,18 @@ impl_eq!(Cow<'a, Path>, Path);
impl_eq!(Cow<'a, Path>, &'b Path);
impl_eq!(Cow<'a, Path>, PathBuf);
#[stable(since = "1.7.0", feature = "strip_prefix")]
impl fmt::Display for StripPrefixError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
self.description().fmt(f)
}
}
#[stable(since = "1.7.0", feature = "strip_prefix")]
impl Error for StripPrefixError {
fn description(&self) -> &str { "prefix not found" }
}
#[cfg(test)]
mod tests {
use super::*;
@ -2105,6 +2147,7 @@ mod tests {
);
#[test]
#[allow(deprecated)]
fn into_cow() {
use borrow::{Cow, IntoCow};

View File

@ -39,6 +39,7 @@ pub use self::rwlock::{RwLockReadGuard, RwLockWriteGuard};
#[stable(feature = "rust1", since = "1.0.0")]
pub use self::rwlock::{RwLock, StaticRwLock, RW_LOCK_INIT};
#[stable(feature = "rust1", since = "1.0.0")]
#[allow(deprecated)]
pub use self::semaphore::{Semaphore, SemaphoreGuard};
pub mod mpsc;

View File

@ -12,6 +12,10 @@
reason = "the interaction between semaphores and the acquisition/release \
of resources is currently unclear",
issue = "27798")]
#![rustc_deprecated(since = "1.7.0",
reason = "easily confused with system sempahores and not \
used enough to pull its weight")]
#![allow(deprecated)]
use ops::Drop;
use sync::{Mutex, Condvar};

View File

@ -23,42 +23,61 @@ use sys;
use sys_common::{FromInner, AsInner, AsInnerMut};
#[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
pub const USER_READ: raw::mode_t = 0o400;
#[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
pub const USER_WRITE: raw::mode_t = 0o200;
#[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
pub const USER_EXECUTE: raw::mode_t = 0o100;
#[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
pub const USER_RWX: raw::mode_t = 0o700;
#[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
pub const GROUP_READ: raw::mode_t = 0o040;
#[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
pub const GROUP_WRITE: raw::mode_t = 0o020;
#[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
pub const GROUP_EXECUTE: raw::mode_t = 0o010;
#[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
pub const GROUP_RWX: raw::mode_t = 0o070;
#[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
pub const OTHER_READ: raw::mode_t = 0o004;
#[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
pub const OTHER_WRITE: raw::mode_t = 0o002;
#[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
pub const OTHER_EXECUTE: raw::mode_t = 0o001;
#[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
pub const OTHER_RWX: raw::mode_t = 0o007;
#[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
pub const ALL_READ: raw::mode_t = 0o444;
#[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
pub const ALL_WRITE: raw::mode_t = 0o222;
#[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
pub const ALL_EXECUTE: raw::mode_t = 0o111;
#[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
pub const ALL_RWX: raw::mode_t = 0o777;
#[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
pub const SETUID: raw::mode_t = 0o4000;
#[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
pub const SETGID: raw::mode_t = 0o2000;
#[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")]
#[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")]
pub const STICKY_BIT: raw::mode_t = 0o1000;
/// Unix-specific extensions to `Permissions`

View File

@ -126,9 +126,9 @@ pub fn parse_summary(input: &mut Read, src: &Path) -> Result<Book, Vec<String>>
let title = line[start_bracket + 1..end_bracket].to_string();
let indent = &line[..star_idx];
let path_from_root = match src.join(given_path).relative_from(src) {
Some(p) => p.to_path_buf(),
None => {
let path_from_root = match src.join(given_path).strip_prefix(src) {
Ok(p) => p.to_path_buf(),
Err(..) => {
errors.push(format!("paths in SUMMARY.md must be relative, \
but path '{}' for section '{}' is not.",
given_path, title));

View File

@ -11,7 +11,6 @@
#![deny(warnings)]
#![feature(iter_arith)]
#![feature(path_relative_from)]
#![feature(rustc_private)]
#![feature(rustdoc)]

View File

@ -11,7 +11,7 @@
#![deny(exceeding_bitshifts)]
#![allow(unused_variables)]
#![allow(dead_code)]
#![feature(num_bits_bytes, const_indexing)]
#![feature(const_indexing)]
fn main() {
let n = 1u8 << 7;
@ -57,8 +57,13 @@ fn main() {
let n = 1u8 << (4+3);
let n = 1u8 << (4+4); //~ ERROR: bitshift exceeds the type's number of bits
let n = 1_isize << std::isize::BITS; //~ ERROR: bitshift exceeds the type's number of bits
let n = 1_usize << std::usize::BITS; //~ ERROR: bitshift exceeds the type's number of bits
#[cfg(target_pointer_width = "32")]
const BITS: usize = 32;
#[cfg(target_pointer_width = "64")]
const BITS: usize = 64;
let n = 1_isize << BITS; //~ ERROR: bitshift exceeds the type's number of bits
let n = 1_usize << BITS; //~ ERROR: bitshift exceeds the type's number of bits
let n = 1i8<<(1isize+-1);

View File

@ -12,9 +12,8 @@
// type is `&mut [u8]`, passes in a pointer to the lvalue and not a
// temporary. Issue #19147.
#![feature(clone_from_slice)]
use std::slice;
use std::cmp;
trait MyWriter {
fn my_write(&mut self, buf: &[u8]) -> Result<(), ()>;
@ -22,7 +21,8 @@ trait MyWriter {
impl<'a> MyWriter for &'a mut [u8] {
fn my_write(&mut self, buf: &[u8]) -> Result<(), ()> {
self.clone_from_slice(buf);
let amt = cmp::min(self.len(), buf.len());
self[..amt].clone_from_slice(&buf[..amt]);
let write_len = buf.len();
unsafe {