Skip to content

Rollup of 6 pull requests #51310

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Jun 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -952,8 +952,7 @@ impl Step for Compiletest {
if suite.ends_with("fulldeps") ||
// FIXME: Does pretty need librustc compiled? Note that there are
// fulldeps test suites with mode = pretty as well.
mode == "pretty" ||
mode == "rustdoc"
mode == "pretty"
{
builder.ensure(compile::Rustc { compiler, target });
}
Expand Down
1 change: 0 additions & 1 deletion src/liballoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@
#![feature(ptr_internals)]
#![feature(ptr_offset_from)]
#![feature(rustc_attrs)]
#![feature(slice_get_slice)]
#![feature(specialization)]
#![feature(staged_api)]
#![feature(str_internals)]
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ pub use core::slice::{RSplit, RSplitMut};
pub use core::slice::{from_raw_parts, from_raw_parts_mut};
#[stable(feature = "from_ref", since = "1.28.0")]
pub use core::slice::{from_ref, from_mut};
#[unstable(feature = "slice_get_slice", issue = "35729")]
#[stable(feature = "slice_get_slice", since = "1.28.0")]
pub use core::slice::SliceIndex;
#[unstable(feature = "exact_chunks", issue = "47115")]
pub use core::slice::{ExactChunks, ExactChunksMut};
Expand Down
5 changes: 3 additions & 2 deletions src/libcore/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -635,8 +635,9 @@ pub fn swap<T>(x: &mut T, y: &mut T) {
}
}

/// Replaces the value at a mutable location with a new one, returning the old value, without
/// deinitializing either one.
/// Moves `src` into the referenced `dest`, returning the previous `dest` value.
///
/// Neither value is dropped.
///
/// # Examples
///
Expand Down
6 changes: 5 additions & 1 deletion src/libcore/num/f32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ pub const MANTISSA_DIGITS: u32 = 24;
#[stable(feature = "rust1", since = "1.0.0")]
pub const DIGITS: u32 = 6;

/// Difference between `1.0` and the next largest representable number.
/// [Machine epsilon] value for `f32`.
///
/// This is the difference between `1.0` and the next largest representable number.
///
/// [Machine epsilon]: https://en.wikipedia.org/wiki/Machine_epsilon
#[stable(feature = "rust1", since = "1.0.0")]
pub const EPSILON: f32 = 1.19209290e-07_f32;

Expand Down
6 changes: 5 additions & 1 deletion src/libcore/num/f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ pub const MANTISSA_DIGITS: u32 = 53;
#[stable(feature = "rust1", since = "1.0.0")]
pub const DIGITS: u32 = 15;

/// Difference between `1.0` and the next largest representable number.
/// [Machine epsilon] value for `f64`.
///
/// This is the difference between `1.0` and the next largest representable number.
///
/// [Machine epsilon]: https://en.wikipedia.org/wiki/Machine_epsilon
#[stable(feature = "rust1", since = "1.0.0")]
pub const EPSILON: f64 = 2.2204460492503131e-16_f64;

Expand Down
5 changes: 3 additions & 2 deletions src/libcore/ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,9 @@ unsafe fn swap_nonoverlapping_bytes(x: *mut u8, y: *mut u8, len: usize) {
}
}

/// Replaces the value at `dest` with `src`, returning the old
/// value, without dropping either.
/// Moves `src` into the pointed `dest`, returning the previous `dest` value.
///
/// Neither value is dropped.
///
/// # Safety
///
Expand Down
32 changes: 30 additions & 2 deletions src/libcore/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1977,35 +1977,63 @@ fn slice_index_overflow_fail() -> ! {
panic!("attempted to index slice up to maximum usize");
}

mod private_slice_index {
use super::ops;
#[stable(feature = "slice_get_slice", since = "1.28.0")]
pub trait Sealed {}

#[stable(feature = "slice_get_slice", since = "1.28.0")]
impl Sealed for usize {}
#[stable(feature = "slice_get_slice", since = "1.28.0")]
impl Sealed for ops::Range<usize> {}
#[stable(feature = "slice_get_slice", since = "1.28.0")]
impl Sealed for ops::RangeTo<usize> {}
#[stable(feature = "slice_get_slice", since = "1.28.0")]
impl Sealed for ops::RangeFrom<usize> {}
#[stable(feature = "slice_get_slice", since = "1.28.0")]
impl Sealed for ops::RangeFull {}
#[stable(feature = "slice_get_slice", since = "1.28.0")]
impl Sealed for ops::RangeInclusive<usize> {}
#[stable(feature = "slice_get_slice", since = "1.28.0")]
impl Sealed for ops::RangeToInclusive<usize> {}
}

/// A helper trait used for indexing operations.
#[unstable(feature = "slice_get_slice", issue = "35729")]
#[stable(feature = "slice_get_slice", since = "1.28.0")]
#[rustc_on_unimplemented = "slice indices are of type `usize` or ranges of `usize`"]
pub trait SliceIndex<T: ?Sized> {
pub trait SliceIndex<T: ?Sized>: private_slice_index::Sealed {
/// The output type returned by methods.
#[stable(feature = "slice_get_slice", since = "1.28.0")]
type Output: ?Sized;

/// Returns a shared reference to the output at this location, if in
/// bounds.
#[unstable(feature = "slice_index_methods", issue = "0")]
fn get(self, slice: &T) -> Option<&Self::Output>;

/// Returns a mutable reference to the output at this location, if in
/// bounds.
#[unstable(feature = "slice_index_methods", issue = "0")]
fn get_mut(self, slice: &mut T) -> Option<&mut Self::Output>;

/// Returns a shared reference to the output at this location, without
/// performing any bounds checking.
#[unstable(feature = "slice_index_methods", issue = "0")]
unsafe fn get_unchecked(self, slice: &T) -> &Self::Output;

/// Returns a mutable reference to the output at this location, without
/// performing any bounds checking.
#[unstable(feature = "slice_index_methods", issue = "0")]
unsafe fn get_unchecked_mut(self, slice: &mut T) -> &mut Self::Output;

/// Returns a shared reference to the output at this location, panicking
/// if out of bounds.
#[unstable(feature = "slice_index_methods", issue = "0")]
fn index(self, slice: &T) -> &Self::Output;

/// Returns a mutable reference to the output at this location, panicking
/// if out of bounds.
#[unstable(feature = "slice_index_methods", issue = "0")]
fn index_mut(self, slice: &mut T) -> &mut Self::Output;
}

Expand Down
51 changes: 51 additions & 0 deletions src/libcore/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,57 @@ impl Duration {
#[inline]
pub const fn subsec_nanos(&self) -> u32 { self.nanos }

/// Returns the total number of milliseconds contained by this `Duration`.
///
/// # Examples
///
/// ```
/// # #![feature(duration_as_u128)]
/// use std::time::Duration;
///
/// let duration = Duration::new(5, 730023852);
/// assert_eq!(duration.as_millis(), 5730);
/// ```
#[unstable(feature = "duration_as_u128", issue = "50202")]
#[inline]
pub fn as_millis(&self) -> u128 {
self.secs as u128 * MILLIS_PER_SEC as u128 + (self.nanos / NANOS_PER_MILLI) as u128
}

/// Returns the total number of microseconds contained by this `Duration`.
///
/// # Examples
///
/// ```
/// # #![feature(duration_as_u128)]
/// use std::time::Duration;
///
/// let duration = Duration::new(5, 730023852);
/// assert_eq!(duration.as_micros(), 5730023);
/// ```
#[unstable(feature = "duration_as_u128", issue = "50202")]
#[inline]
pub fn as_micros(&self) -> u128 {
self.secs as u128 * MICROS_PER_SEC as u128 + (self.nanos / NANOS_PER_MICRO) as u128
}

/// Returns the total number of nanoseconds contained by this `Duration`.
///
/// # Examples
///
/// ```
/// # #![feature(duration_as_u128)]
/// use std::time::Duration;
///
/// let duration = Duration::new(5, 730023852);
/// assert_eq!(duration.as_nanos(), 5730023852);
/// ```
#[unstable(feature = "duration_as_u128", issue = "50202")]
#[inline]
pub fn as_nanos(&self) -> u128 {
self.secs as u128 * NANOS_PER_SEC as u128 + self.nanos as u128
}

/// Checked `Duration` addition. Computes `self + other`, returning [`None`]
/// if overflow occurred.
///
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/traits/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ impl<'tcx> ProjectionTyCandidateSet<'tcx> {
// was not used). On other paths, it is not assigned,
// and hence if those paths *could* reach the code that
// comes after the match, this fn would not compile.
let convert_to_ambigious;
let convert_to_ambiguous;

match self {
None => {
Expand All @@ -169,10 +169,10 @@ impl<'tcx> ProjectionTyCandidateSet<'tcx> {
// clauses are the safer choice. See the comment on
// `select::SelectionCandidate` and #21974 for more details.
match (current, candidate) {
(ParamEnv(..), ParamEnv(..)) => convert_to_ambigious = (),
(ParamEnv(..), ParamEnv(..)) => convert_to_ambiguous = (),
(ParamEnv(..), _) => return false,
(_, ParamEnv(..)) => { unreachable!(); }
(_, _) => convert_to_ambigious = (),
(_, _) => convert_to_ambiguous = (),
}
}

Expand All @@ -183,7 +183,7 @@ impl<'tcx> ProjectionTyCandidateSet<'tcx> {

// We only ever get here when we moved from a single candidate
// to ambiguous.
let () = convert_to_ambigious;
let () = convert_to_ambiguous;
*self = Ambiguous;
false
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/traits/query/normalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl<'cx, 'gcx, 'tcx> At<'cx, 'gcx, 'tcx> {
/// normalized. If you don't care about regions, you should prefer
/// `normalize_erasing_regions`, which is more efficient.
///
/// If the normalization succeeds and is unambigious, returns back
/// If the normalization succeeds and is unambiguous, returns back
/// the normalized value along with various outlives relations (in
/// the form of obligations that must be discharged).
///
Expand Down
1 change: 1 addition & 0 deletions src/test/rustdoc/rustc-macro-crate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// except according to those terms.

// no-prefer-dynamic
// ignore-stage1

#![crate_type = "proc-macro"]

Expand Down