Skip to content

Commit 3515dab

Browse files
committed
Auto merge of #51310 - Mark-Simulacrum:rollup, r=Mark-Simulacrum
Rollup of 6 pull requests Successful merges: - #50167 ( Add as_nanos function to Duration) - #50919 (Provide more context for what the {f32,f64}::EPSILON values represent.) - #51124 (Reword {ptr,mem}::replace docs.) - #51147 (Stabilize SliceIndex trait.) - #51291 (Fix typos of ‘ambiguous’) - #51302 (Permit building rustdoc without compiler artifacts) Failed merges:
2 parents 4ecf12b + dcfe311 commit 3515dab

File tree

12 files changed

+105
-17
lines changed

12 files changed

+105
-17
lines changed

src/bootstrap/test.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -952,8 +952,7 @@ impl Step for Compiletest {
952952
if suite.ends_with("fulldeps") ||
953953
// FIXME: Does pretty need librustc compiled? Note that there are
954954
// fulldeps test suites with mode = pretty as well.
955-
mode == "pretty" ||
956-
mode == "rustdoc"
955+
mode == "pretty"
957956
{
958957
builder.ensure(compile::Rustc { compiler, target });
959958
}

src/liballoc/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@
104104
#![feature(ptr_internals)]
105105
#![feature(ptr_offset_from)]
106106
#![feature(rustc_attrs)]
107-
#![feature(slice_get_slice)]
108107
#![feature(specialization)]
109108
#![feature(staged_api)]
110109
#![feature(str_internals)]

src/liballoc/slice.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ pub use core::slice::{RSplit, RSplitMut};
121121
pub use core::slice::{from_raw_parts, from_raw_parts_mut};
122122
#[stable(feature = "from_ref", since = "1.28.0")]
123123
pub use core::slice::{from_ref, from_mut};
124-
#[unstable(feature = "slice_get_slice", issue = "35729")]
124+
#[stable(feature = "slice_get_slice", since = "1.28.0")]
125125
pub use core::slice::SliceIndex;
126126
#[unstable(feature = "exact_chunks", issue = "47115")]
127127
pub use core::slice::{ExactChunks, ExactChunksMut};

src/libcore/mem.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -635,8 +635,9 @@ pub fn swap<T>(x: &mut T, y: &mut T) {
635635
}
636636
}
637637

638-
/// Replaces the value at a mutable location with a new one, returning the old value, without
639-
/// deinitializing either one.
638+
/// Moves `src` into the referenced `dest`, returning the previous `dest` value.
639+
///
640+
/// Neither value is dropped.
640641
///
641642
/// # Examples
642643
///

src/libcore/num/f32.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ pub const MANTISSA_DIGITS: u32 = 24;
3131
#[stable(feature = "rust1", since = "1.0.0")]
3232
pub const DIGITS: u32 = 6;
3333

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

src/libcore/num/f64.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ pub const MANTISSA_DIGITS: u32 = 53;
3131
#[stable(feature = "rust1", since = "1.0.0")]
3232
pub const DIGITS: u32 = 15;
3333

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

src/libcore/ptr.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,9 @@ unsafe fn swap_nonoverlapping_bytes(x: *mut u8, y: *mut u8, len: usize) {
239239
}
240240
}
241241

242-
/// Replaces the value at `dest` with `src`, returning the old
243-
/// value, without dropping either.
242+
/// Moves `src` into the pointed `dest`, returning the previous `dest` value.
243+
///
244+
/// Neither value is dropped.
244245
///
245246
/// # Safety
246247
///

src/libcore/slice/mod.rs

+30-2
Original file line numberDiff line numberDiff line change
@@ -1977,35 +1977,63 @@ fn slice_index_overflow_fail() -> ! {
19771977
panic!("attempted to index slice up to maximum usize");
19781978
}
19791979

1980+
mod private_slice_index {
1981+
use super::ops;
1982+
#[stable(feature = "slice_get_slice", since = "1.28.0")]
1983+
pub trait Sealed {}
1984+
1985+
#[stable(feature = "slice_get_slice", since = "1.28.0")]
1986+
impl Sealed for usize {}
1987+
#[stable(feature = "slice_get_slice", since = "1.28.0")]
1988+
impl Sealed for ops::Range<usize> {}
1989+
#[stable(feature = "slice_get_slice", since = "1.28.0")]
1990+
impl Sealed for ops::RangeTo<usize> {}
1991+
#[stable(feature = "slice_get_slice", since = "1.28.0")]
1992+
impl Sealed for ops::RangeFrom<usize> {}
1993+
#[stable(feature = "slice_get_slice", since = "1.28.0")]
1994+
impl Sealed for ops::RangeFull {}
1995+
#[stable(feature = "slice_get_slice", since = "1.28.0")]
1996+
impl Sealed for ops::RangeInclusive<usize> {}
1997+
#[stable(feature = "slice_get_slice", since = "1.28.0")]
1998+
impl Sealed for ops::RangeToInclusive<usize> {}
1999+
}
2000+
19802001
/// A helper trait used for indexing operations.
1981-
#[unstable(feature = "slice_get_slice", issue = "35729")]
2002+
#[stable(feature = "slice_get_slice", since = "1.28.0")]
19822003
#[rustc_on_unimplemented = "slice indices are of type `usize` or ranges of `usize`"]
1983-
pub trait SliceIndex<T: ?Sized> {
2004+
pub trait SliceIndex<T: ?Sized>: private_slice_index::Sealed {
19842005
/// The output type returned by methods.
2006+
#[stable(feature = "slice_get_slice", since = "1.28.0")]
19852007
type Output: ?Sized;
19862008

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

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

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

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

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

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

src/libcore/time.rs

+51
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,57 @@ impl Duration {
268268
#[inline]
269269
pub const fn subsec_nanos(&self) -> u32 { self.nanos }
270270

271+
/// Returns the total number of milliseconds contained by this `Duration`.
272+
///
273+
/// # Examples
274+
///
275+
/// ```
276+
/// # #![feature(duration_as_u128)]
277+
/// use std::time::Duration;
278+
///
279+
/// let duration = Duration::new(5, 730023852);
280+
/// assert_eq!(duration.as_millis(), 5730);
281+
/// ```
282+
#[unstable(feature = "duration_as_u128", issue = "50202")]
283+
#[inline]
284+
pub fn as_millis(&self) -> u128 {
285+
self.secs as u128 * MILLIS_PER_SEC as u128 + (self.nanos / NANOS_PER_MILLI) as u128
286+
}
287+
288+
/// Returns the total number of microseconds contained by this `Duration`.
289+
///
290+
/// # Examples
291+
///
292+
/// ```
293+
/// # #![feature(duration_as_u128)]
294+
/// use std::time::Duration;
295+
///
296+
/// let duration = Duration::new(5, 730023852);
297+
/// assert_eq!(duration.as_micros(), 5730023);
298+
/// ```
299+
#[unstable(feature = "duration_as_u128", issue = "50202")]
300+
#[inline]
301+
pub fn as_micros(&self) -> u128 {
302+
self.secs as u128 * MICROS_PER_SEC as u128 + (self.nanos / NANOS_PER_MICRO) as u128
303+
}
304+
305+
/// Returns the total number of nanoseconds contained by this `Duration`.
306+
///
307+
/// # Examples
308+
///
309+
/// ```
310+
/// # #![feature(duration_as_u128)]
311+
/// use std::time::Duration;
312+
///
313+
/// let duration = Duration::new(5, 730023852);
314+
/// assert_eq!(duration.as_nanos(), 5730023852);
315+
/// ```
316+
#[unstable(feature = "duration_as_u128", issue = "50202")]
317+
#[inline]
318+
pub fn as_nanos(&self) -> u128 {
319+
self.secs as u128 * NANOS_PER_SEC as u128 + self.nanos as u128
320+
}
321+
271322
/// Checked `Duration` addition. Computes `self + other`, returning [`None`]
272323
/// if overflow occurred.
273324
///

src/librustc/traits/project.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ impl<'tcx> ProjectionTyCandidateSet<'tcx> {
146146
// was not used). On other paths, it is not assigned,
147147
// and hence if those paths *could* reach the code that
148148
// comes after the match, this fn would not compile.
149-
let convert_to_ambigious;
149+
let convert_to_ambiguous;
150150

151151
match self {
152152
None => {
@@ -169,10 +169,10 @@ impl<'tcx> ProjectionTyCandidateSet<'tcx> {
169169
// clauses are the safer choice. See the comment on
170170
// `select::SelectionCandidate` and #21974 for more details.
171171
match (current, candidate) {
172-
(ParamEnv(..), ParamEnv(..)) => convert_to_ambigious = (),
172+
(ParamEnv(..), ParamEnv(..)) => convert_to_ambiguous = (),
173173
(ParamEnv(..), _) => return false,
174174
(_, ParamEnv(..)) => { unreachable!(); }
175-
(_, _) => convert_to_ambigious = (),
175+
(_, _) => convert_to_ambiguous = (),
176176
}
177177
}
178178

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

184184
// We only ever get here when we moved from a single candidate
185185
// to ambiguous.
186-
let () = convert_to_ambigious;
186+
let () = convert_to_ambiguous;
187187
*self = Ambiguous;
188188
false
189189
}

src/librustc/traits/query/normalize.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl<'cx, 'gcx, 'tcx> At<'cx, 'gcx, 'tcx> {
3333
/// normalized. If you don't care about regions, you should prefer
3434
/// `normalize_erasing_regions`, which is more efficient.
3535
///
36-
/// If the normalization succeeds and is unambigious, returns back
36+
/// If the normalization succeeds and is unambiguous, returns back
3737
/// the normalized value along with various outlives relations (in
3838
/// the form of obligations that must be discharged).
3939
///

src/test/rustdoc/rustc-macro-crate.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
// no-prefer-dynamic
12+
// ignore-stage1
1213

1314
#![crate_type = "proc-macro"]
1415

0 commit comments

Comments
 (0)