Skip to content

Commit 44593ae

Browse files
committed
Auto merge of rust-lang#89512 - Manishearth:rollup-meh9x7r, r=Manishearth
Rollup of 14 pull requests Successful merges: - rust-lang#86434 (Add `Ipv6Addr::is_benchmarking`) - rust-lang#86828 (const fn for option copied, take & replace) - rust-lang#87679 (BTree: refine some comments) - rust-lang#87910 (Mark unsafe methods NonZero*::unchecked_(add|mul) as const.) - rust-lang#88286 (Remove unnecessary unsafe block in `process_unix`) - rust-lang#88305 (Manual Debug for Unix ExitCode ExitStatus ExitStatusError) - rust-lang#88353 (Partially stabilize `array_methods`) - rust-lang#88370 (Add missing `# Panics` section to `Vec` method) - rust-lang#88481 (Remove some feature gates) - rust-lang#89138 (Fix link in Ipv6Addr::to_ipv4 docs) - rust-lang#89401 (Add truncate note to Vec::resize) - rust-lang#89467 (Fix typos in rustdoc/lints) - rust-lang#89472 (Only register `WSACleanup` if `WSAStartup` is actually ever called) - rust-lang#89505 (Add regression test for spurious const error with NLL) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents d25de31 + 5c5dde8 commit 44593ae

File tree

30 files changed

+251
-135
lines changed

30 files changed

+251
-135
lines changed

compiler/rustc_borrowck/src/member_constraints.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ impl<R> MemberConstraintSet<'tcx, R>
144144
where
145145
R: Copy + Hash + Eq,
146146
{
147-
crate fn all_indices(&self) -> impl Iterator<Item = NllMemberConstraintIndex> {
147+
crate fn all_indices(&self) -> impl Iterator<Item = NllMemberConstraintIndex> + '_ {
148148
self.constraints.indices()
149149
}
150150

compiler/rustc_borrowck/src/region_infer/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
497497
}
498498

499499
/// Returns an iterator over all the region indices.
500-
pub fn regions(&self) -> impl Iterator<Item = RegionVid> {
500+
pub fn regions(&self) -> impl Iterator<Item = RegionVid> + '_ {
501501
self.definitions.indices()
502502
}
503503

compiler/rustc_data_structures/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
//! This API is completely unstable and subject to change.
88
99
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
10-
#![feature(allow_internal_unstable)]
1110
#![feature(array_windows)]
1211
#![feature(associated_type_bounds)]
1312
#![feature(auto_traits)]

compiler/rustc_index/src/lib.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
#![feature(bench_black_box)]
33
#![feature(extend_one)]
44
#![feature(iter_zip)]
5-
#![feature(unboxed_closures)]
5+
#![feature(min_specialization)]
66
#![feature(test)]
7-
#![feature(fn_traits)]
87

98
pub mod bit_set;
109
pub mod vec;

compiler/rustc_index/src/vec.rs

+17-44
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
33
use std::fmt;
44
use std::fmt::Debug;
55
use std::hash::Hash;
6-
use std::iter::{self, FromIterator};
6+
use std::iter::FromIterator;
77
use std::marker::PhantomData;
8-
use std::ops::{Index, IndexMut, Range, RangeBounds};
8+
use std::ops::{Index, IndexMut, RangeBounds};
99
use std::slice;
1010
use std::vec;
1111

@@ -518,8 +518,6 @@ impl<I: Idx, T: fmt::Debug> fmt::Debug for IndexVec<I, T> {
518518
}
519519
}
520520

521-
pub type Enumerated<I, J> = iter::Map<iter::Enumerate<J>, IntoIdx<I>>;
522-
523521
impl<I: Idx, T> IndexVec<I, T> {
524522
#[inline]
525523
pub fn new() -> Self {
@@ -596,8 +594,10 @@ impl<I: Idx, T> IndexVec<I, T> {
596594
}
597595

598596
#[inline]
599-
pub fn into_iter_enumerated(self) -> Enumerated<I, vec::IntoIter<T>> {
600-
self.raw.into_iter().enumerate().map(IntoIdx { _marker: PhantomData })
597+
pub fn into_iter_enumerated(
598+
self,
599+
) -> impl DoubleEndedIterator<Item = (I, T)> + ExactSizeIterator {
600+
self.raw.into_iter().enumerate().map(|(n, t)| (I::new(n), t))
601601
}
602602

603603
#[inline]
@@ -606,13 +606,15 @@ impl<I: Idx, T> IndexVec<I, T> {
606606
}
607607

608608
#[inline]
609-
pub fn iter_enumerated(&self) -> Enumerated<I, slice::Iter<'_, T>> {
610-
self.raw.iter().enumerate().map(IntoIdx { _marker: PhantomData })
609+
pub fn iter_enumerated(
610+
&self,
611+
) -> impl DoubleEndedIterator<Item = (I, &T)> + ExactSizeIterator + '_ {
612+
self.raw.iter().enumerate().map(|(n, t)| (I::new(n), t))
611613
}
612614

613615
#[inline]
614-
pub fn indices(&self) -> iter::Map<Range<usize>, IntoIdx<I>> {
615-
(0..self.len()).map(IntoIdx { _marker: PhantomData })
616+
pub fn indices(&self) -> impl DoubleEndedIterator<Item = I> + ExactSizeIterator + 'static {
617+
(0..self.len()).map(|n| I::new(n))
616618
}
617619

618620
#[inline]
@@ -621,8 +623,10 @@ impl<I: Idx, T> IndexVec<I, T> {
621623
}
622624

623625
#[inline]
624-
pub fn iter_enumerated_mut(&mut self) -> Enumerated<I, slice::IterMut<'_, T>> {
625-
self.raw.iter_mut().enumerate().map(IntoIdx { _marker: PhantomData })
626+
pub fn iter_enumerated_mut(
627+
&mut self,
628+
) -> impl DoubleEndedIterator<Item = (I, &mut T)> + ExactSizeIterator + '_ {
629+
self.raw.iter_mut().enumerate().map(|(n, t)| (I::new(n), t))
626630
}
627631

628632
#[inline]
@@ -638,7 +642,7 @@ impl<I: Idx, T> IndexVec<I, T> {
638642
&'a mut self,
639643
range: R,
640644
) -> impl Iterator<Item = (I, T)> + 'a {
641-
self.raw.drain(range).enumerate().map(IntoIdx { _marker: PhantomData })
645+
self.raw.drain(range).enumerate().map(|(n, t)| (I::new(n), t))
642646
}
643647

644648
#[inline]
@@ -832,36 +836,5 @@ impl<'a, I: Idx, T> IntoIterator for &'a mut IndexVec<I, T> {
832836
}
833837
}
834838

835-
pub struct IntoIdx<I: Idx> {
836-
_marker: PhantomData<fn(&I)>,
837-
}
838-
impl<I: Idx, T> FnOnce<((usize, T),)> for IntoIdx<I> {
839-
type Output = (I, T);
840-
841-
extern "rust-call" fn call_once(self, ((n, t),): ((usize, T),)) -> Self::Output {
842-
(I::new(n), t)
843-
}
844-
}
845-
846-
impl<I: Idx, T> FnMut<((usize, T),)> for IntoIdx<I> {
847-
extern "rust-call" fn call_mut(&mut self, ((n, t),): ((usize, T),)) -> Self::Output {
848-
(I::new(n), t)
849-
}
850-
}
851-
852-
impl<I: Idx> FnOnce<(usize,)> for IntoIdx<I> {
853-
type Output = I;
854-
855-
extern "rust-call" fn call_once(self, (n,): (usize,)) -> Self::Output {
856-
I::new(n)
857-
}
858-
}
859-
860-
impl<I: Idx> FnMut<(usize,)> for IntoIdx<I> {
861-
extern "rust-call" fn call_mut(&mut self, (n,): (usize,)) -> Self::Output {
862-
I::new(n)
863-
}
864-
}
865-
866839
#[cfg(test)]
867840
mod tests;

compiler/rustc_lint/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
//! This API is completely unstable and subject to change.
2727
2828
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
29-
#![cfg_attr(test, feature(test))]
3029
#![feature(array_windows)]
3130
#![feature(bool_to_option)]
3231
#![feature(box_patterns)]

compiler/rustc_middle/src/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,11 @@
4141
#![feature(once_cell)]
4242
#![feature(min_specialization)]
4343
#![feature(trusted_len)]
44-
#![feature(test)]
4544
#![feature(in_band_lifetimes)]
4645
#![feature(crate_visibility_modifier)]
4746
#![feature(associated_type_bounds)]
4847
#![feature(rustc_attrs)]
4948
#![feature(half_open_range_patterns)]
50-
#![feature(exclusive_range_pattern)]
5149
#![feature(control_flow_enum)]
5250
#![feature(associated_type_defaults)]
5351
#![feature(iter_zip)]

compiler/rustc_middle/src/ty/codec.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
// This module contains some shared code for encoding and decoding various
2-
// things from the `ty` module, and in particular implements support for
3-
// "shorthands" which allow to have pointers back into the already encoded
4-
// stream instead of re-encoding the same thing twice.
5-
//
6-
// The functionality in here is shared between persisting to crate metadata and
7-
// persisting to incr. comp. caches.
1+
//! This module contains some shared code for encoding and decoding various
2+
//! things from the `ty` module, and in particular implements support for
3+
//! "shorthands" which allow to have pointers back into the already encoded
4+
//! stream instead of re-encoding the same thing twice.
5+
//!
6+
//! The functionality in here is shared between persisting to crate metadata and
7+
//! persisting to incr. comp. caches.
88
99
use crate::arena::ArenaAllocatable;
1010
use crate::infer::canonical::{CanonicalVarInfo, CanonicalVarInfos};

compiler/rustc_mir_dataflow/src/move_paths/mod.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
use core::slice::Iter;
21
use rustc_data_structures::fx::FxHashMap;
3-
use rustc_index::vec::{Enumerated, IndexVec};
2+
use rustc_index::vec::IndexVec;
43
use rustc_middle::mir::*;
54
use rustc_middle::ty::{ParamEnv, Ty, TyCtxt};
65
use rustc_span::Span;
@@ -337,7 +336,9 @@ impl MovePathLookup {
337336

338337
/// An enumerated iterator of `local`s and their associated
339338
/// `MovePathIndex`es.
340-
pub fn iter_locals_enumerated(&self) -> Enumerated<Local, Iter<'_, MovePathIndex>> {
339+
pub fn iter_locals_enumerated(
340+
&self,
341+
) -> impl DoubleEndedIterator<Item = (Local, &MovePathIndex)> + ExactSizeIterator {
341342
self.locals.iter_enumerated()
342343
}
343344
}

compiler/rustc_target/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#![feature(exhaustive_patterns)]
1616
#![feature(min_specialization)]
1717
#![feature(step_trait)]
18-
#![feature(unchecked_math)]
1918

2019
use std::path::{Path, PathBuf};
2120

compiler/rustc_ty_utils/src/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
77
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
88
#![feature(control_flow_enum)]
9-
#![feature(half_open_range_patterns)]
10-
#![feature(exclusive_range_pattern)]
119
#![feature(nll)]
1210
#![recursion_limit = "256"]
1311

library/alloc/src/collections/btree/map.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@ mod entry;
1919
pub use entry::{Entry, OccupiedEntry, OccupiedError, VacantEntry};
2020
use Entry::*;
2121

22-
/// Minimum number of elements in nodes that are not a root.
22+
/// Minimum number of elements in a node that is not a root.
2323
/// We might temporarily have fewer elements during methods.
2424
pub(super) const MIN_LEN: usize = node::MIN_LEN_AFTER_SPLIT;
2525

2626
// A tree in a `BTreeMap` is a tree in the `node` module with additional invariants:
2727
// - Keys must appear in ascending order (according to the key's type).
28-
// - If the root node is internal, it must contain at least 1 element.
28+
// - Every non-leaf node contains at least 1 element (has at least 2 children).
2929
// - Every non-root node contains at least MIN_LEN elements.
3030
//
31-
// An empty map may be represented both by the absence of a root node or by a
31+
// An empty map is represented either by the absence of a root node or by a
3232
// root node that is an empty leaf.
3333

3434
/// A map based on a [B-Tree].
@@ -1735,8 +1735,8 @@ impl<'a, K: 'a, V: 'a> DrainFilterInner<'a, K, V> {
17351735
pub(super) fn size_hint(&self) -> (usize, Option<usize>) {
17361736
// In most of the btree iterators, `self.length` is the number of elements
17371737
// yet to be visited. Here, it includes elements that were visited and that
1738-
// the predicate decided not to drain. Making this upper bound more accurate
1739-
// requires maintaining an extra field and is not worth while.
1738+
// the predicate decided not to drain. Making this upper bound more tight
1739+
// during iteration would require an extra field.
17401740
(0, Some(*self.length))
17411741
}
17421742
}

library/alloc/src/collections/btree/navigate.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -440,8 +440,7 @@ impl<K, V> Handle<NodeRef<marker::Dying, K, V, marker::Leaf>, marker::Edge> {
440440
/// - The given edge must not have been previously returned by counterpart
441441
/// `deallocating_next_back`.
442442
/// - The returned KV handle is only valid to access the key and value,
443-
/// and only valid until the next call to this method or counterpart
444-
/// `deallocating_next_back`.
443+
/// and only valid until the next call to a `deallocating_` method.
445444
unsafe fn deallocating_next(
446445
self,
447446
) -> Option<(Self, Handle<NodeRef<marker::Dying, K, V, marker::LeafOrInternal>, marker::KV>)>
@@ -470,8 +469,7 @@ impl<K, V> Handle<NodeRef<marker::Dying, K, V, marker::Leaf>, marker::Edge> {
470469
/// - The given edge must not have been previously returned by counterpart
471470
/// `deallocating_next`.
472471
/// - The returned KV handle is only valid to access the key and value,
473-
/// and only valid until the next call to this method or counterpart
474-
/// `deallocating_next`.
472+
/// and only valid until the next call to a `deallocating_` method.
475473
unsafe fn deallocating_next_back(
476474
self,
477475
) -> Option<(Self, Handle<NodeRef<marker::Dying, K, V, marker::LeafOrInternal>, marker::KV>)>

library/alloc/src/collections/btree/node.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ impl<K, V> NodeRef<marker::Owned, K, V, marker::LeafOrInternal> {
574574
/// no cleanup is done on any of the keys, values and other children.
575575
/// This decreases the height by 1 and is the opposite of `push_internal_level`.
576576
///
577-
/// Requires exclusive access to the `Root` object but not to the root node;
577+
/// Requires exclusive access to the `NodeRef` object but not to the root node;
578578
/// it will not invalidate other handles or references to the root node.
579579
///
580580
/// Panics if there is no internal level, i.e., if the root node is a leaf.

library/alloc/src/vec/mod.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -2137,6 +2137,7 @@ impl<T: Clone, A: Allocator> Vec<T, A> {
21372137
/// in order to be able to clone the passed value.
21382138
/// If you need more flexibility (or want to rely on [`Default`] instead of
21392139
/// [`Clone`]), use [`Vec::resize_with`].
2140+
/// If you only need to resize to a smaller size, use [`Vec::truncate`].
21402141
///
21412142
/// # Examples
21422143
///
@@ -2188,7 +2189,12 @@ impl<T: Clone, A: Allocator> Vec<T, A> {
21882189

21892190
/// Copies elements from `src` range to the end of the vector.
21902191
///
2191-
/// ## Examples
2192+
/// # Panics
2193+
///
2194+
/// Panics if the starting point is greater than the end point or if
2195+
/// the end point is greater than the length of the vector.
2196+
///
2197+
/// # Examples
21922198
///
21932199
/// ```
21942200
/// let mut vec = vec![0, 1, 2, 3, 4];

library/core/src/array/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -368,14 +368,14 @@ impl<T, const N: usize> [T; N] {
368368
}
369369

370370
/// Returns a slice containing the entire array. Equivalent to `&s[..]`.
371-
#[unstable(feature = "array_methods", issue = "76118")]
372-
pub fn as_slice(&self) -> &[T] {
371+
#[stable(feature = "array_as_slice", since = "1.57.0")]
372+
pub const fn as_slice(&self) -> &[T] {
373373
self
374374
}
375375

376376
/// Returns a mutable slice containing the entire array. Equivalent to
377377
/// `&mut s[..]`.
378-
#[unstable(feature = "array_methods", issue = "76118")]
378+
#[stable(feature = "array_as_slice", since = "1.57.0")]
379379
pub fn as_mut_slice(&mut self) -> &mut [T] {
380380
self
381381
}

library/core/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
#![feature(const_maybe_uninit_assume_init)]
9292
#![feature(const_option)]
9393
#![feature(const_pin)]
94+
#![feature(const_replace)]
9495
#![feature(const_ptr_offset)]
9596
#![feature(const_ptr_offset_from)]
9697
#![feature(const_ptr_read)]

library/core/src/num/nonzero.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ macro_rules! nonzero_unsigned_operations {
379379
/// ```
380380
#[unstable(feature = "nonzero_ops", issue = "84186")]
381381
#[inline]
382-
pub unsafe fn unchecked_add(self, other: $Int) -> $Ty {
382+
pub const unsafe fn unchecked_add(self, other: $Int) -> $Ty {
383383
// SAFETY: The caller ensures there is no overflow.
384384
unsafe { $Ty::new_unchecked(self.get().unchecked_add(other)) }
385385
}
@@ -750,7 +750,7 @@ macro_rules! nonzero_unsigned_signed_operations {
750750
/// ```
751751
#[unstable(feature = "nonzero_ops", issue = "84186")]
752752
#[inline]
753-
pub unsafe fn unchecked_mul(self, other: $Ty) -> $Ty {
753+
pub const unsafe fn unchecked_mul(self, other: $Ty) -> $Ty {
754754
// SAFETY: The caller ensures there is no overflow.
755755
unsafe { $Ty::new_unchecked(self.get().unchecked_mul(other.get())) }
756756
}

0 commit comments

Comments
 (0)