Skip to content

Commit ad27045

Browse files
committed
Auto merge of rust-lang#137571 - tgross35:rollup-i1tcnv1, r=tgross35
Rollup of 8 pull requests Successful merges: - rust-lang#134655 (Stabilize `hash_extract_if`) - rust-lang#135933 (Explain how Vec::with_capacity is faithful) - rust-lang#136668 (Stabilize `core::str::from_utf8_mut` as `const`) - rust-lang#136775 (Update `String::from_raw_parts` safety requirements) - rust-lang#137109 (stabilize extract_if) - rust-lang#137349 (Implement `read_buf` for zkVM stdin) - rust-lang#137493 (configure.py: don't instruct user to run nonexistent program) - rust-lang#137516 (remove some unnecessary rustc_const_unstable) r? `@ghost` `@rustbot` modify labels: rollup
2 parents f5729cf + 91dc3ee commit ad27045

File tree

20 files changed

+51
-57
lines changed

20 files changed

+51
-57
lines changed

compiler/rustc_errors/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#![feature(box_into_inner)]
1616
#![feature(box_patterns)]
1717
#![feature(error_reporter)]
18-
#![feature(extract_if)]
1918
#![feature(if_let_guard)]
2019
#![feature(let_chains)]
2120
#![feature(negative_impls)]

compiler/rustc_lint/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#![feature(array_windows)]
2727
#![feature(assert_matches)]
2828
#![feature(box_patterns)]
29-
#![feature(extract_if)]
3029
#![feature(if_let_guard)]
3130
#![feature(iter_order_by)]
3231
#![feature(let_chains)]

compiler/rustc_metadata/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#![feature(coroutines)]
66
#![feature(decl_macro)]
77
#![feature(error_iter)]
8-
#![feature(extract_if)]
98
#![feature(file_buffered)]
109
#![feature(if_let_guard)]
1110
#![feature(iter_from_coroutine)]

compiler/rustc_middle/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
#![feature(decl_macro)]
4545
#![feature(discriminant_kind)]
4646
#![feature(extern_types)]
47-
#![feature(extract_if)]
4847
#![feature(file_buffered)]
4948
#![feature(if_let_guard)]
5049
#![feature(intra_doc_pointers)]

compiler/rustc_resolve/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#![doc(rust_logo)]
1616
#![feature(assert_matches)]
1717
#![feature(box_patterns)]
18-
#![feature(extract_if)]
1918
#![feature(if_let_guard)]
2019
#![feature(iter_intersperse)]
2120
#![feature(let_chains)]

compiler/rustc_trait_selection/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#![feature(associated_type_defaults)]
2121
#![feature(box_patterns)]
2222
#![feature(cfg_version)]
23-
#![feature(extract_if)]
2423
#![feature(if_let_guard)]
2524
#![feature(iter_intersperse)]
2625
#![feature(iterator_try_reduce)]

library/alloc/src/collections/linked_list.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,7 +1140,6 @@ impl<T, A: Allocator> LinkedList<T, A> {
11401140
/// Splitting a list into evens and odds, reusing the original list:
11411141
///
11421142
/// ```
1143-
/// #![feature(extract_if)]
11441143
/// use std::collections::LinkedList;
11451144
///
11461145
/// let mut numbers: LinkedList<u32> = LinkedList::new();
@@ -1152,7 +1151,7 @@ impl<T, A: Allocator> LinkedList<T, A> {
11521151
/// assert_eq!(evens.into_iter().collect::<Vec<_>>(), vec![2, 4, 6, 8, 14]);
11531152
/// assert_eq!(odds.into_iter().collect::<Vec<_>>(), vec![1, 3, 5, 9, 11, 13, 15]);
11541153
/// ```
1155-
#[unstable(feature = "extract_if", reason = "recently added", issue = "43244")]
1154+
#[stable(feature = "extract_if", since = "CURRENT_RUSTC_VERSION")]
11561155
pub fn extract_if<F>(&mut self, filter: F) -> ExtractIf<'_, T, F, A>
11571156
where
11581157
F: FnMut(&mut T) -> bool,
@@ -1932,7 +1931,7 @@ impl<'a, T, A: Allocator> CursorMut<'a, T, A> {
19321931
}
19331932

19341933
/// An iterator produced by calling `extract_if` on LinkedList.
1935-
#[unstable(feature = "extract_if", reason = "recently added", issue = "43244")]
1934+
#[stable(feature = "extract_if", since = "CURRENT_RUSTC_VERSION")]
19361935
#[must_use = "iterators are lazy and do nothing unless consumed"]
19371936
pub struct ExtractIf<
19381937
'a,
@@ -1947,7 +1946,7 @@ pub struct ExtractIf<
19471946
old_len: usize,
19481947
}
19491948

1950-
#[unstable(feature = "extract_if", reason = "recently added", issue = "43244")]
1949+
#[stable(feature = "extract_if", since = "CURRENT_RUSTC_VERSION")]
19511950
impl<T, F, A: Allocator> Iterator for ExtractIf<'_, T, F, A>
19521951
where
19531952
F: FnMut(&mut T) -> bool,
@@ -1976,7 +1975,7 @@ where
19761975
}
19771976
}
19781977

1979-
#[unstable(feature = "extract_if", reason = "recently added", issue = "43244")]
1978+
#[stable(feature = "extract_if", since = "CURRENT_RUSTC_VERSION")]
19801979
impl<T: fmt::Debug, F> fmt::Debug for ExtractIf<'_, T, F> {
19811980
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
19821981
f.debug_tuple("ExtractIf").field(&self.list).finish()

library/alloc/src/string.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -966,11 +966,8 @@ impl String {
966966
/// This is highly unsafe, due to the number of invariants that aren't
967967
/// checked:
968968
///
969-
/// * The memory at `buf` needs to have been previously allocated by the
970-
/// same allocator the standard library uses, with a required alignment of exactly 1.
971-
/// * `length` needs to be less than or equal to `capacity`.
972-
/// * `capacity` needs to be the correct value.
973-
/// * The first `length` bytes at `buf` need to be valid UTF-8.
969+
/// * all safety requirements for [`Vec::<u8>::from_raw_parts`].
970+
/// * all safety requirements for [`String::from_utf8_unchecked`].
974971
///
975972
/// Violating these may cause problems like corrupting the allocator's
976973
/// internal data structures. For example, it is normally **not** safe to

library/alloc/src/vec/extract_if.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,10 @@ use crate::alloc::{Allocator, Global};
1212
/// # Example
1313
///
1414
/// ```
15-
/// #![feature(extract_if)]
16-
///
1715
/// let mut v = vec![0, 1, 2];
1816
/// let iter: std::vec::ExtractIf<'_, _, _> = v.extract_if(.., |x| *x % 2 == 0);
1917
/// ```
20-
#[unstable(feature = "extract_if", reason = "recently added", issue = "43244")]
18+
#[stable(feature = "extract_if", since = "CURRENT_RUSTC_VERSION")]
2119
#[derive(Debug)]
2220
#[must_use = "iterators are lazy and do nothing unless consumed"]
2321
pub struct ExtractIf<
@@ -59,7 +57,7 @@ impl<'a, T, F, A: Allocator> ExtractIf<'a, T, F, A> {
5957
}
6058
}
6159

62-
#[unstable(feature = "extract_if", reason = "recently added", issue = "43244")]
60+
#[stable(feature = "extract_if", since = "CURRENT_RUSTC_VERSION")]
6361
impl<T, F, A: Allocator> Iterator for ExtractIf<'_, T, F, A>
6462
where
6563
F: FnMut(&mut T) -> bool,
@@ -95,7 +93,7 @@ where
9593
}
9694
}
9795

98-
#[unstable(feature = "extract_if", reason = "recently added", issue = "43244")]
96+
#[stable(feature = "extract_if", since = "CURRENT_RUSTC_VERSION")]
9997
impl<T, F, A: Allocator> Drop for ExtractIf<'_, T, F, A> {
10098
fn drop(&mut self) {
10199
unsafe {

library/alloc/src/vec/mod.rs

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ use core::ptr::{self, NonNull};
6666
use core::slice::{self, SliceIndex};
6767
use core::{fmt, intrinsics};
6868

69-
#[unstable(feature = "extract_if", reason = "recently added", issue = "43244")]
69+
#[stable(feature = "extract_if", since = "CURRENT_RUSTC_VERSION")]
7070
pub use self::extract_if::ExtractIf;
7171
use crate::alloc::{Allocator, Global};
7272
use crate::borrow::{Cow, ToOwned};
@@ -355,11 +355,20 @@ mod spec_extend;
355355
/// and it may prove desirable to use a non-constant growth factor. Whatever
356356
/// strategy is used will of course guarantee *O*(1) amortized [`push`].
357357
///
358-
/// `vec![x; n]`, `vec![a, b, c, d]`, and
359-
/// [`Vec::with_capacity(n)`][`Vec::with_capacity`], will all produce a `Vec`
360-
/// with at least the requested capacity. If <code>[len] == [capacity]</code>,
361-
/// (as is the case for the [`vec!`] macro), then a `Vec<T>` can be converted to
362-
/// and from a [`Box<[T]>`][owned slice] without reallocating or moving the elements.
358+
/// It is guaranteed, in order to respect the intentions of the programmer, that
359+
/// all of `vec![e_1, e_2, ..., e_n]`, `vec![x; n]`, and [`Vec::with_capacity(n)`] produce a `Vec`
360+
/// that requests an allocation of the exact size needed for precisely `n` elements from the allocator,
361+
/// and no other size (such as, for example: a size rounded up to the nearest power of 2).
362+
/// The allocator will return an allocation that is at least as large as requested, but it may be larger.
363+
///
364+
/// It is guaranteed that the [`Vec::capacity`] method returns a value that is at least the requested capacity
365+
/// and not more than the allocated capacity.
366+
///
367+
/// The method [`Vec::shrink_to_fit`] will attempt to discard excess capacity an allocator has given to a `Vec`.
368+
/// If <code>[len] == [capacity]</code>, then a `Vec<T>` can be converted
369+
/// to and from a [`Box<[T]>`][owned slice] without reallocating or moving the elements.
370+
/// `Vec` exploits this fact as much as reasonable when implementing common conversions
371+
/// such as [`into_boxed_slice`].
363372
///
364373
/// `Vec` will not specifically overwrite any data that is removed from it,
365374
/// but also won't specifically preserve it. Its uninitialized memory is
@@ -383,14 +392,17 @@ mod spec_extend;
383392
/// [`shrink_to`]: Vec::shrink_to
384393
/// [capacity]: Vec::capacity
385394
/// [`capacity`]: Vec::capacity
395+
/// [`Vec::capacity`]: Vec::capacity
386396
/// [mem::size_of::\<T>]: core::mem::size_of
387397
/// [len]: Vec::len
388398
/// [`len`]: Vec::len
389399
/// [`push`]: Vec::push
390400
/// [`insert`]: Vec::insert
391401
/// [`reserve`]: Vec::reserve
402+
/// [`Vec::with_capacity(n)`]: Vec::with_capacity
392403
/// [`MaybeUninit`]: core::mem::MaybeUninit
393404
/// [owned slice]: Box
405+
/// [`into_boxed_slice`]: Vec::into_boxed_slice
394406
#[stable(feature = "rust1", since = "1.0.0")]
395407
#[cfg_attr(not(test), rustc_diagnostic_item = "Vec")]
396408
#[rustc_insignificant_dtor]
@@ -3684,7 +3696,6 @@ impl<T, A: Allocator> Vec<T, A> {
36843696
/// Splitting an array into evens and odds, reusing the original allocation:
36853697
///
36863698
/// ```
3687-
/// #![feature(extract_if)]
36883699
/// let mut numbers = vec![1, 2, 3, 4, 5, 6, 8, 9, 11, 13, 14, 15];
36893700
///
36903701
/// let evens = numbers.extract_if(.., |x| *x % 2 == 0).collect::<Vec<_>>();
@@ -3697,13 +3708,12 @@ impl<T, A: Allocator> Vec<T, A> {
36973708
/// Using the range argument to only process a part of the vector:
36983709
///
36993710
/// ```
3700-
/// #![feature(extract_if)]
37013711
/// let mut items = vec![0, 0, 0, 0, 0, 0, 0, 1, 2, 1, 2, 1, 2];
37023712
/// let ones = items.extract_if(7.., |x| *x == 1).collect::<Vec<_>>();
37033713
/// assert_eq!(items, vec![0, 0, 0, 0, 0, 0, 0, 2, 2, 2]);
37043714
/// assert_eq!(ones.len(), 3);
37053715
/// ```
3706-
#[unstable(feature = "extract_if", reason = "recently added", issue = "43244")]
3716+
#[stable(feature = "extract_if", since = "CURRENT_RUSTC_VERSION")]
37073717
pub fn extract_if<F, R>(&mut self, range: R, filter: F) -> ExtractIf<'_, T, F, A>
37083718
where
37093719
F: FnMut(&mut T) -> bool,

0 commit comments

Comments
 (0)