Skip to content

Rollup of 25 pull requests #138383

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 106 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
01795b1
change definitely non-productive cycles to error
lcnr Feb 27, 2025
18809a2
keep inductive cycles as ambig in coherence
lcnr Feb 28, 2025
607987e
Support rmeta inputs for --crate-type=bin --emit=obj
sam-mccall Mar 7, 2025
1833737
uefi: fs: Implement FilePermission
Ayush1325 Mar 9, 2025
c717cc7
uefi: fs: Implement FileType
Ayush1325 Mar 9, 2025
e0a9dd3
uefi: fs: Partially implement FileAttr
Ayush1325 Mar 9, 2025
112f7b0
make precise capturing args in rustdoc Json typed
Kohei316 Mar 2, 2025
c9ccec9
Initial STD support for Cygwin
Berrysoft Dec 26, 2024
e3e98c8
Fix `std::sys::unix::set_linger` for Cygwin
Mar 4, 2024
1aad114
Fix building for cygwin
Berrysoft Dec 29, 2024
886fb15
Update metadata for cygwin target
Berrysoft Feb 25, 2025
abcbd88
Revert changes for rtstartup
Berrysoft Feb 25, 2025
d24c6a2
Fix code style
Berrysoft Feb 25, 2025
7d80aaa
Remove std::os::cygwin::raw
Berrysoft Mar 7, 2025
268e734
Impl cygwin rand with getrandom
Berrysoft Mar 7, 2025
c3051b1
Unify cygwin & horizon random impl
Berrysoft Mar 7, 2025
b9fe8de
Readd os::cygwin::raw as pub(crate)
Berrysoft Mar 7, 2025
c3c02a5
Use __xpg_strerror_r on cygwin
Berrysoft Mar 7, 2025
9cab8c2
Remove stack overflow handler for cygwin
Berrysoft Mar 7, 2025
87ca2db
Apply rustc-0023-Add-Trusty-OS-support-to-Rust-std.patch
randomPoison Feb 4, 2025
7f6ee12
Apply rustc-0054-Add-std-os-fd-support-for-Trusty.patch
randomPoison Feb 4, 2025
d633d8e
Format after patches have been applied
randomPoison Feb 4, 2025
22fea97
Disable unsupported tests
randomPoison Feb 4, 2025
5b94113
Update Trusty platform docs
randomPoison Feb 11, 2025
0b1a7ab
Remove custom TLS implementation for Trusty targets
randomPoison Feb 19, 2025
5d4ff50
Update books
rustbot Mar 10, 2025
f5dd3d1
Update Trusty support to account for recent libstd reorganization
randomPoison Mar 10, 2025
d75c973
main.js: insertAfter needs non-root referenceNode
lolbinarycat Mar 10, 2025
93161f5
main.js: don't set mouseMovedAfterSearch, as it is never read
lolbinarycat Mar 10, 2025
cf7f3cf
main.js: give type signatures to a few helper functions
lolbinarycat Mar 10, 2025
da5da99
main.js: handleEscape and handleShortcut accept KeyboardEvent
lolbinarycat Mar 10, 2025
6622111
main.js: always refer to searchState through window.searchState
lolbinarycat Mar 10, 2025
f5efd2a
main.js(isDisplayed): coerce truthy values to boolean
lolbinarycat Mar 10, 2025
ab180c2
main.js: handle document.activeElement being null
lolbinarycat Mar 10, 2025
2e1c8f0
rustdoc.d.ts: window.SIDEBAR_ITEMS may exist.
lolbinarycat Mar 10, 2025
749b6bf
rustdoc.d.ts: add window.{register_implementors,pending_implementors}
lolbinarycat Mar 10, 2025
7421546
main.js: typecheck things related to window.register_type_impls
lolbinarycat Mar 10, 2025
2b3b0bd
Remove unused file
randomPoison Mar 10, 2025
20bac26
main.js: remove searchState from globals.
lolbinarycat Mar 10, 2025
c0957ef
naked functions: on windows emit `.endef` without the symbol name
folkertdev Mar 10, 2025
3b0c258
Convert `ShardedHashMap` to use `hashbrown::HashTable`
cuviper Feb 27, 2025
c9c8387
Use `RUSTC_LINT_FLAGS` more.
nnethercote Mar 11, 2025
55505ab
Add `unreachable_pub` to `RUSTC_LINT_FLAGS` for `compiler/` crates.
nnethercote Mar 11, 2025
ff0a5fe
Remove `#![warn(unreachable_pub)]` from all `compiler/` crates.
nnethercote Mar 11, 2025
2a8c87b
Rebuild llvm spuriously less frequently
jyn514 Mar 11, 2025
ff5a8ad
Explain the actual reason why stripping binders is fine
oli-obk Feb 24, 2025
9882eca
Remove some dead code
oli-obk Mar 11, 2025
7475a34
Stabilize `std::io::ErrorKind::InvalidFilename`
GrigorenkoPV Dec 9, 2024
47ba5bd
Enable `f16` tests for `powf`
tgross35 Mar 11, 2025
436959e
Add PeekMut::refresh
HeroicKatora Mar 7, 2025
c170d0f
Elaborate param-env built for checking DispatchFromDyn for dyn compat
compiler-errors Mar 11, 2025
6133999
Fix `cargo vendor` not working without `rustc` installed
ehuss Mar 11, 2025
590b277
Add a test for new 2024 standard library behavior
ehuss Feb 11, 2025
0e071c2
Migrate core to Rust 2024
ehuss Feb 11, 2025
f505d4e
Migrate alloc to Rust 2024
ehuss Feb 11, 2025
b9454af
Migrate panic_abort to Rust 2024
ehuss Feb 11, 2025
985f66b
Migrate panic_unwind to Rust 2024
ehuss Feb 12, 2025
540ef90
Migrate unwind to Rust 2024
ehuss Feb 12, 2025
993359e
Migrate std to Rust 2024
ehuss Feb 12, 2025
f1a9513
Migrate test to Rust 2024
ehuss Feb 12, 2025
0b2489c
Migrate proc_macro to Rust 2024
ehuss Feb 12, 2025
80311c4
Migrate profiler_builtins to Rust 2024
ehuss Feb 12, 2025
32c61f7
Migrated the rustc-std-workspace crates to Rust 2024
ehuss Feb 12, 2025
ba06ce6
Migrate the sysroot crate to Rust 2024
ehuss Feb 12, 2025
b130747
Migrate windows-targets to Rust 2024
ehuss Feb 12, 2025
d3c55cd
Remove unnecessary parens
randomPoison Mar 11, 2025
faa5b3f
Fix false-positive in `expr_or_init` and in the `invalid_from_utf8` lint
Urgau Mar 9, 2025
64d1433
Refactor pick2_mut & pick3_mut to use get_disjoint_mut
Eclips4 Mar 11, 2025
d2642ab
Adjust `Map`'s `to_string` functionality.
nnethercote Feb 21, 2025
281af35
Rename `hir_attrs` query as `hir_attr_map`.
nnethercote Feb 24, 2025
256c27e
Move methods from `Map` to `TyCtxt`, part 4.
nnethercote Feb 21, 2025
763db5d
Convert a delayed bug to a bug.
nnethercote Mar 5, 2025
fe04460
Remove an unnecessary `kw::Empty` check.
nnethercote Mar 6, 2025
0b2d706
Introduce `sym::dummy` and `Ident::dummy`.
nnethercote Mar 4, 2025
4eadaff
Convert a `kw::Empty` occurrence to `sym::dummy`.
nnethercote Mar 11, 2025
7398b39
Make panic's more specific
Eclips4 Mar 11, 2025
576bcfc
Update compiletest's `has_asm_support` to match rustc
cuviper Mar 11, 2025
d7029d7
Remove unused `OwnerNode::ident` method.
nnethercote Mar 7, 2025
ed10418
Inline and remove `State::print_item_type`.
nnethercote Mar 7, 2025
ee9ef82
Factor out some repeated code in `parse_item_impl`.
nnethercote Mar 7, 2025
c0cee43
Remove unnecessary lifetime from `PatInfo`.
nnethercote Jan 30, 2025
fc97d9c
Rollup merge of #134076 - GrigorenkoPV:InvalidFilename, r=joboet
jieyouxu Mar 12, 2025
8e910ef
Rollup merge of #136842 - randomPoison:trusty-libstd-v3, r=ChrisDenton
jieyouxu Mar 12, 2025
9b185bc
Rollup merge of #137314 - lcnr:cycles-with-unknown-kind, r=compiler-e…
jieyouxu Mar 12, 2025
33ddf0c
Rollup merge of #137504 - nnethercote:remove-Map-4, r=Zalathar
jieyouxu Mar 12, 2025
8d52064
Rollup merge of #137621 - Berrysoft:cygwin-std, r=joboet
jieyouxu Mar 12, 2025
fcc698f
Rollup merge of #137701 - cuviper:sharded-hashtable, r=fmease
jieyouxu Mar 12, 2025
ca5c840
Rollup merge of #138109 - Kohei316:feat/rust-doc-precise-capturing-ar…
jieyouxu Mar 12, 2025
7df2fdb
Rollup merge of #138161 - HeroicKatora:heap-peek-mut-refresh, r=dtolnay
jieyouxu Mar 12, 2025
c6845de
Rollup merge of #138162 - ehuss:library-2024, r=cuviper
jieyouxu Mar 12, 2025
d7a1a28
Rollup merge of #138174 - compiler-errors:elaborate-unsize-self-pred,…
jieyouxu Mar 12, 2025
350db18
Rollup merge of #138175 - sam-mccall:binobj, r=nnethercote
jieyouxu Mar 12, 2025
44a2af2
Rollup merge of #138269 - Ayush1325:uefi-fs-permission, r=joboet
jieyouxu Mar 12, 2025
7942812
Rollup merge of #138313 - rustbot:docs-update, r=jieyouxu
jieyouxu Mar 12, 2025
4ecc04b
Rollup merge of #138318 - lolbinarycat:rustdoc-js-less-expect-error-p…
jieyouxu Mar 12, 2025
9995e80
Rollup merge of #138331 - nnethercote:use-RUSTC_LINT_FLAGS-more, r=on…
jieyouxu Mar 12, 2025
6ad1e10
Rollup merge of #138333 - jyn514:spurious-llvm-rebuilds, r=onur-ozkan
jieyouxu Mar 12, 2025
511574d
Rollup merge of #138343 - tgross35:f16-powf, r=joboet
jieyouxu Mar 12, 2025
9e4680c
Rollup merge of #138345 - oli-obk:autodiff-cleanup, r=compiler-errors
jieyouxu Mar 12, 2025
daa721e
Rollup merge of #138346 - folkertdev:naked-asm-windows-endef, r=Chris…
jieyouxu Mar 12, 2025
8901c0b
Rollup merge of #138347 - nnethercote:less-kw-Empty-2, r=compiler-errors
jieyouxu Mar 12, 2025
06a93ec
Rollup merge of #138360 - Urgau:fix-fp-expr_or_init, r=wesleywiser
jieyouxu Mar 12, 2025
6bcaf65
Rollup merge of #138371 - cuviper:stable-asm-test, r=jieyouxu
jieyouxu Mar 12, 2025
ae5ccbb
Rollup merge of #138372 - Eclips4:issue-138196, r=scottmcm
jieyouxu Mar 12, 2025
acfc84d
Rollup merge of #138376 - nnethercote:hir-ItemKind-ident-precursors, …
jieyouxu Mar 12, 2025
df1dbe7
Rollup merge of #138377 - nnethercote:rustc_hir_typeck, r=compiler-er…
jieyouxu Mar 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add PeekMut::refresh
This improves the useability of heaps for priority-based work queues. In
certain scenarios, modifications on the most relevant or critical items are
performed until a condition that determines the work items have been
sufficiently addressed. The loop will repeatedly access the most critical
item and put it back in a sorted position when it is complete. Crucially,
due to the ordering invariant we know that all work was performed when the
completed item remains the most critical. Getting this information from the
heap position avoids a (potentially more costly) check on the item state
itself.

A customized `drop` with boolean result would avoid up to two more
comparisons performed in both the last no-op refresh and Drop code but this
occurs once in each execution of the above scenario whereas refresh occurs
any number of times. Also note that the comparison overhead of Drop is only
taken if the element is mutably inspected to determine the end condition,
i.e. not when refresh itself is the break condition.
HeroicKatora committed Mar 11, 2025
commit 436959e3f710d3161093bfa183e3c5deceff7ccf
82 changes: 78 additions & 4 deletions library/alloc/src/collections/binary_heap/mod.rs
Original file line number Diff line number Diff line change
@@ -359,6 +359,74 @@ impl<T: Ord, A: Allocator> DerefMut for PeekMut<'_, T, A> {
}

impl<'a, T: Ord, A: Allocator> PeekMut<'a, T, A> {
/// Sifts the current element to its new position.
///
/// Afterwards refers to the new element. Returns if the element changed.
///
/// ## Examples
///
/// The condition can be used to upper bound all elements in the heap. When only few elements
/// are affected, the heap's sort ensures this is faster than a reconstruction from the raw
/// element list and requires no additional allocation.
///
/// ```
/// #![feature(binary_heap_peek_mut_refresh)]
/// use std::collections::BinaryHeap;
///
/// let mut heap: BinaryHeap<u32> = (0..128).collect();
/// let mut peek = heap.peek_mut().unwrap();
///
/// loop {
/// *peek = 99;
///
/// if !peek.refresh() {
/// break;
/// }
/// }
///
/// // Post condition, this is now an upper bound.
/// assert!(*peek < 100);
/// ```
///
/// When the element remains the maximum after modification, the peek remains unchanged:
///
/// ```
/// #![feature(binary_heap_peek_mut_refresh)]
/// use std::collections::BinaryHeap;
///
/// let mut heap: BinaryHeap<u32> = [1, 2, 3].into();
/// let mut peek = heap.peek_mut().unwrap();
///
/// assert_eq!(*peek, 3);
/// *peek = 42;
///
/// // When we refresh, the peek is updated to the new maximum.
/// assert!(!peek.refresh(), "42 is even larger than 3");
/// assert_eq!(*peek, 42);
/// ```
#[unstable(feature = "binary_heap_peek_mut_refresh", issue = "138355")]
#[must_use = "is equivalent to dropping and getting a new PeekMut except for return information"]
pub fn refresh(&mut self) -> bool {
// The length of the underlying heap is unchanged by sifting down. The value stored for leak
// amplification thus remains accurate. We erase the leak amplification firstly because the
// operation is then equivalent to constructing a new PeekMut and secondly this avoids any
// future complication where original_len being non-empty would be interpreted as the heap
// having been leak amplified instead of checking the heap itself.
if let Some(original_len) = self.original_len.take() {
// SAFETY: This is how many elements were in the Vec at the time of
// the BinaryHeap::peek_mut call.
unsafe { self.heap.data.set_len(original_len.get()) };

// The length of the heap did not change by sifting, upholding our own invariants.

// SAFETY: PeekMut is only instantiated for non-empty heaps.
(unsafe { self.heap.sift_down(0) }) != 0
} else {
// The element was not modified.
false
}
}

/// Removes the peeked value from the heap and returns it.
#[stable(feature = "binary_heap_peek_mut_pop", since = "1.18.0")]
pub fn pop(mut this: PeekMut<'a, T, A>) -> T {
@@ -670,6 +738,8 @@ impl<T: Ord, A: Allocator> BinaryHeap<T, A> {
/// # Safety
///
/// The caller must guarantee that `pos < self.len()`.
///
/// Returns the new position of the element.
unsafe fn sift_up(&mut self, start: usize, pos: usize) -> usize {
// Take out the value at `pos` and create a hole.
// SAFETY: The caller guarantees that pos < self.len()
@@ -696,10 +766,12 @@ impl<T: Ord, A: Allocator> BinaryHeap<T, A> {
/// Take an element at `pos` and move it down the heap,
/// while its children are larger.
///
/// Returns the new position of the element.
///
/// # Safety
///
/// The caller must guarantee that `pos < end <= self.len()`.
unsafe fn sift_down_range(&mut self, pos: usize, end: usize) {
unsafe fn sift_down_range(&mut self, pos: usize, end: usize) -> usize {
// SAFETY: The caller guarantees that pos < end <= self.len().
let mut hole = unsafe { Hole::new(&mut self.data, pos) };
let mut child = 2 * hole.pos() + 1;
@@ -719,7 +791,7 @@ impl<T: Ord, A: Allocator> BinaryHeap<T, A> {
// SAFETY: child is now either the old child or the old child+1
// We already proven that both are < self.len() and != hole.pos()
if hole.element() >= unsafe { hole.get(child) } {
return;
return hole.pos();
}

// SAFETY: same as above.
@@ -734,16 +806,18 @@ impl<T: Ord, A: Allocator> BinaryHeap<T, A> {
// child == 2 * hole.pos() + 1 != hole.pos().
unsafe { hole.move_to(child) };
}

hole.pos()
}

/// # Safety
///
/// The caller must guarantee that `pos < self.len()`.
unsafe fn sift_down(&mut self, pos: usize) {
unsafe fn sift_down(&mut self, pos: usize) -> usize {
let len = self.len();
// SAFETY: pos < len is guaranteed by the caller and
// obviously len = self.len() <= self.len().
unsafe { self.sift_down_range(pos, len) };
unsafe { self.sift_down_range(pos, len) }
}

/// Take an element at `pos` and move it all the way down the heap,