Skip to content

Commit 8dc1d77

Browse files
author
The rustc-josh-sync Cronjob Bot
committed
Merge ref 'ffb9d94dcf4a' from rust-lang/rust
Pull recent changes from https://github.com/rust-lang/rust via Josh. Upstream ref: ffb9d94 Filtered ref: 2f31646593733abae36e4c05b5a54acfb9f1f6bc This merge was created using https://github.com/rust-lang/josh-sync.
2 parents 76b219d + 88e5129 commit 8dc1d77

File tree

315 files changed

+13125
-10438
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

315 files changed

+13125
-10438
lines changed

Cargo.lock

Lines changed: 17 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

alloc/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ compiler_builtins = { path = "../compiler-builtins/compiler-builtins", features
2121
[features]
2222
compiler-builtins-mem = ['compiler_builtins/mem']
2323
compiler-builtins-c = ["compiler_builtins/c"]
24-
compiler-builtins-no-asm = ["compiler_builtins/no-asm"]
2524
compiler-builtins-no-f16-f128 = ["compiler_builtins/no-f16-f128"]
26-
compiler-builtins-mangled-names = ["compiler_builtins/mangled-names"]
2725
# Make panics and failed asserts immediately abort without formatting any message
2826
panic_immediate_abort = ["core/panic_immediate_abort"]
2927
# Choose algorithms that are optimized for binary size instead of runtime performance

alloc/src/collections/btree/map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ impl<'a, K: 'a, V: 'a> Default for Iter<'a, K, V> {
382382
/// documentation for more.
383383
///
384384
/// [`iter_mut`]: BTreeMap::iter_mut
385+
#[must_use = "iterators are lazy and do nothing unless consumed"]
385386
#[stable(feature = "rust1", since = "1.0.0")]
386387
pub struct IterMut<'a, K: 'a, V: 'a> {
387388
range: LazyLeafRange<marker::ValMut<'a>, K, V>,
@@ -391,7 +392,6 @@ pub struct IterMut<'a, K: 'a, V: 'a> {
391392
_marker: PhantomData<&'a mut (K, V)>,
392393
}
393394

394-
#[must_use = "iterators are lazy and do nothing unless consumed"]
395395
#[stable(feature = "collection_debug", since = "1.17.0")]
396396
impl<K: fmt::Debug, V: fmt::Debug> fmt::Debug for IterMut<'_, K, V> {
397397
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {

alloc/src/collections/linked_list.rs

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,7 @@ impl<T, A: Allocator> LinkedList<T, A> {
825825
unsafe { self.tail.as_mut().map(|node| &mut node.as_mut().element) }
826826
}
827827

828-
/// Adds an element first in the list.
828+
/// Adds an element to the front of the list.
829829
///
830830
/// This operation should compute in *O*(1) time.
831831
///
@@ -844,11 +844,34 @@ impl<T, A: Allocator> LinkedList<T, A> {
844844
/// ```
845845
#[stable(feature = "rust1", since = "1.0.0")]
846846
pub fn push_front(&mut self, elt: T) {
847+
let _ = self.push_front_mut(elt);
848+
}
849+
850+
/// Adds an element to the front of the list, returning a reference to it.
851+
///
852+
/// This operation should compute in *O*(1) time.
853+
///
854+
/// # Examples
855+
///
856+
/// ```
857+
/// #![feature(push_mut)]
858+
/// use std::collections::LinkedList;
859+
///
860+
/// let mut dl = LinkedList::from([1, 2, 3]);
861+
///
862+
/// let ptr = dl.push_front_mut(2);
863+
/// *ptr += 4;
864+
/// assert_eq!(dl.front().unwrap(), &6);
865+
/// ```
866+
#[unstable(feature = "push_mut", issue = "135974")]
867+
#[must_use = "if you don't need a reference to the value, use `LinkedList::push_front` instead"]
868+
pub fn push_front_mut(&mut self, elt: T) -> &mut T {
847869
let node = Box::new_in(Node::new(elt), &self.alloc);
848-
let node_ptr = NonNull::from(Box::leak(node));
870+
let mut node_ptr = NonNull::from(Box::leak(node));
849871
// SAFETY: node_ptr is a unique pointer to a node we boxed with self.alloc and leaked
850872
unsafe {
851873
self.push_front_node(node_ptr);
874+
&mut node_ptr.as_mut().element
852875
}
853876
}
854877

@@ -876,7 +899,7 @@ impl<T, A: Allocator> LinkedList<T, A> {
876899
self.pop_front_node().map(Node::into_element)
877900
}
878901

879-
/// Appends an element to the back of a list.
902+
/// Adds an element to the back of the list.
880903
///
881904
/// This operation should compute in *O*(1) time.
882905
///
@@ -893,11 +916,34 @@ impl<T, A: Allocator> LinkedList<T, A> {
893916
#[stable(feature = "rust1", since = "1.0.0")]
894917
#[rustc_confusables("push", "append")]
895918
pub fn push_back(&mut self, elt: T) {
919+
let _ = self.push_back_mut(elt);
920+
}
921+
922+
/// Adds an element to the back of the list, returning a reference to it.
923+
///
924+
/// This operation should compute in *O*(1) time.
925+
///
926+
/// # Examples
927+
///
928+
/// ```
929+
/// #![feature(push_mut)]
930+
/// use std::collections::LinkedList;
931+
///
932+
/// let mut dl = LinkedList::from([1, 2, 3]);
933+
///
934+
/// let ptr = dl.push_back_mut(2);
935+
/// *ptr += 4;
936+
/// assert_eq!(dl.back().unwrap(), &6);
937+
/// ```
938+
#[unstable(feature = "push_mut", issue = "135974")]
939+
#[must_use = "if you don't need a reference to the value, use `LinkedList::push_back` instead"]
940+
pub fn push_back_mut(&mut self, elt: T) -> &mut T {
896941
let node = Box::new_in(Node::new(elt), &self.alloc);
897-
let node_ptr = NonNull::from(Box::leak(node));
942+
let mut node_ptr = NonNull::from(Box::leak(node));
898943
// SAFETY: node_ptr is a unique pointer to a node we boxed with self.alloc and leaked
899944
unsafe {
900945
self.push_back_node(node_ptr);
946+
&mut node_ptr.as_mut().element
901947
}
902948
}
903949

alloc/src/collections/vec_deque/drain.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ impl<T, A: Allocator> Drop for Drain<'_, T, A> {
192192
// this branch is never taken.
193193
// We use `#[cold]` instead of `#[inline(never)]`, because inlining this
194194
// function into the general case (`.drain(n..m)`) is fine.
195-
// See `tests/codegen/vecdeque-drain.rs` for a test.
195+
// See `tests/codegen-llvm/vecdeque-drain.rs` for a test.
196196
#[cold]
197197
fn join_head_and_tail_wrapping<T, A: Allocator>(
198198
source_deque: &mut VecDeque<T, A>,

0 commit comments

Comments
 (0)