Skip to content

Commit e123036

Browse files
Merge branch 'main' into asciiinvariant
2 parents 0730d3c + 517e11e commit e123036

File tree

348 files changed

+9423
-8929
lines changed

Some content is hidden

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

348 files changed

+9423
-8929
lines changed

.github/workflows/flux.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99

1010
env:
1111
FIXPOINT_VERSION: "556104ba5508891c357b0bdf819ce706e93d9349"
12-
FLUX_VERSION: "f6bdf90c54ad6eed51b25c125f251cac01cfe170"
12+
FLUX_VERSION: "ebafb8d0ca32d8c0fcd2a0cfef6b1b4bd4dc4a6f"
1313

1414
jobs:
1515
check-flux-on-core:

library/Cargo.lock

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

library/alloc/Cargo.toml

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

library/alloc/src/boxed/thin.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use core::error::Error;
66
use core::fmt::{self, Debug, Display, Formatter};
77
#[cfg(not(no_global_oom_handling))]
8-
use core::intrinsics::const_allocate;
8+
use core::intrinsics::{const_allocate, const_make_global};
99
use core::marker::PhantomData;
1010
#[cfg(not(no_global_oom_handling))]
1111
use core::marker::Unsize;
@@ -340,9 +340,10 @@ impl<H> WithHeader<H> {
340340
alloc.add(metadata_offset).cast();
341341
// SAFETY: `*metadata_ptr` is within the allocation.
342342
metadata_ptr.write(ptr::metadata::<Dyn>(ptr::dangling::<T>() as *const Dyn));
343-
343+
// SAFETY: valid heap allocation
344+
const_make_global(alloc);
344345
// SAFETY: we have just written the metadata.
345-
&*(metadata_ptr)
346+
&*metadata_ptr
346347
}
347348
};
348349

library/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

library/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>,

library/alloc/src/collections/vec_deque/iter.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
use core::iter::{FusedIterator, TrustedLen, TrustedRandomAccess, TrustedRandomAccessNoCoerce};
2+
#[cfg(kani)]
3+
use core::kani;
24
use core::num::NonZero;
35
use core::ops::Try;
46
use core::{fmt, mem, slice};
57

8+
use safety::requires;
9+
610
/// An iterator over the elements of a `VecDeque`.
711
///
812
/// This `struct` is created by the [`iter`] method on [`super::VecDeque`]. See its
@@ -144,6 +148,8 @@ impl<'a, T> Iterator for Iter<'a, T> {
144148
}
145149

146150
#[inline]
151+
#[requires(idx < self.len())]
152+
#[cfg_attr(kani, kani::modifies(self))]
147153
unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> Self::Item {
148154
// Safety: The TrustedRandomAccess contract requires that callers only pass an index
149155
// that is in bounds.

library/alloc/src/collections/vec_deque/iter_mut.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
use core::iter::{FusedIterator, TrustedLen, TrustedRandomAccess, TrustedRandomAccessNoCoerce};
2+
#[cfg(kani)]
3+
use core::kani;
24
use core::num::NonZero;
35
use core::ops::Try;
46
use core::{fmt, mem, slice};
57

8+
use safety::requires;
9+
610
/// A mutable iterator over the elements of a `VecDeque`.
711
///
812
/// This `struct` is created by the [`iter_mut`] method on [`super::VecDeque`]. See its
@@ -208,6 +212,8 @@ impl<'a, T> Iterator for IterMut<'a, T> {
208212
}
209213

210214
#[inline]
215+
#[requires(idx < self.len())]
216+
#[cfg_attr(kani, kani::modifies(self))]
211217
unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> Self::Item {
212218
// Safety: The TrustedRandomAccess contract requires that callers only pass an index
213219
// that is in bounds.

0 commit comments

Comments
 (0)