Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
02dac5c
add test suggest-clone-in-macro-issue-139253.rs
xizheyin Jun 17, 2025
fd9c1b9
Find correct span when suggesting using clone
xizheyin Jun 17, 2025
b315e9a
clippy fix: rely on autoderef
hkBst Jul 4, 2025
54cc45d
tests: Don't check for self-printed output in std-backtrace.rs test
Enselic Jul 3, 2025
d77c387
Fixes for Arm64EC
dpaoliello Jul 13, 2025
05154af
docs: update documentation of core::mem::copy to include const on the…
SunkenPotato Jul 15, 2025
690ae52
Tweak borrowck label pointing at `!Copy` value moved into closure
estebank Jul 20, 2025
5082e6a
Generalize logic pointing at binding moved into closure
estebank Jul 20, 2025
8df93e6
Tweak spans when encountering multiline initializer in move error
estebank Jul 20, 2025
dafc9f9
Reduce comment verbosity
estebank Jul 21, 2025
01fdafc
Hint that choose_pivot returns index in bounds
kornelski Jul 22, 2025
6237e73
Point at the type that doesn't impl `Clone` in more cases beyond clos…
estebank Jul 21, 2025
a93a9aa
Don't emit two `assume`s in transmutes when one is a subset of the other
scottmcm Jul 20, 2025
e44a738
Remove dead code and extend test coverage and diagnostics around it
oli-obk Jul 24, 2025
642deb3
remove movability from `RigidTy::Coroutine` and `AggregateKind::Corou…
makai410 Jul 24, 2025
9ffa775
resolve: Remove `Scope::CrateRoot`
petrochenkov Jul 22, 2025
94c0cf8
Rename tests/ui/SUMMARY.md and update rustc dev guide on error-pattern
Oneirical Jul 23, 2025
2e54f7f
Rollup merge of #142569 - xizheyin:139253, r=davidtwco
matthiaskrgr Jul 25, 2025
e9744c9
Rollup merge of #143401 - Enselic:no-stack-backtrace-print-in-display…
matthiaskrgr Jul 25, 2025
dd159ee
Rollup merge of #143424 - hkBst:auto-deref, r=jhpratt
matthiaskrgr Jul 25, 2025
e3b0735
Rollup merge of #143970 - SunkenPotato:update_mem_copy_docs, r=scottmcm
matthiaskrgr Jul 25, 2025
dfbd0c4
Rollup merge of #143979 - dpaoliello:arm64ectest, r=petrochenkov
matthiaskrgr Jul 25, 2025
33a9e4f
Rollup merge of #144200 - estebank:dont-point-at-closure, r=lcnr
matthiaskrgr Jul 25, 2025
f414e7a
Rollup merge of #144209 - scottmcm:assume_less, r=lcnr,dianqk
matthiaskrgr Jul 25, 2025
a2681f9
Rollup merge of #144314 - kornelski:pivot-safely, r=jhpratt
matthiaskrgr Jul 25, 2025
405b2e6
Rollup merge of #144340 - Oneirical:uncertain-illusion, r=jieyouxu
matthiaskrgr Jul 25, 2025
9c257e5
Rollup merge of #144368 - petrochenkov:rmrootscope, r=b-naber
matthiaskrgr Jul 25, 2025
acd4a1c
Rollup merge of #144390 - oli-obk:arbitrary-enum-discrs, r=SparrowLii
matthiaskrgr Jul 25, 2025
1caf701
Rollup merge of #144392 - makai410:rm-mov, r=scottmcm
matthiaskrgr Jul 25, 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
3 changes: 1 addition & 2 deletions library/core/src/slice/sort/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ fn partition_at_index_loop<'a, T, F>(
// slice. Partition the slice into elements equal to and elements greater than the pivot.
// This case is usually hit when the slice contains many duplicate elements.
if let Some(p) = ancestor_pivot {
// SAFETY: choose_pivot promises to return a valid pivot position.
let pivot = unsafe { v.get_unchecked(pivot_pos) };
let pivot = &v[pivot_pos];

if !is_less(p, pivot) {
let num_lt = partition(v, pivot_pos, &mut |a, b| !is_less(b, a));
Expand Down
10 changes: 8 additions & 2 deletions library/core/src/slice/sort/shared/pivot.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! This module contains the logic for pivot selection.

use crate::intrinsics;
use crate::{hint, intrinsics};

// Recursively select a pseudomedian if above this threshold.
const PSEUDO_MEDIAN_REC_THRESHOLD: usize = 64;
Expand All @@ -9,6 +9,7 @@ const PSEUDO_MEDIAN_REC_THRESHOLD: usize = 64;
///
/// This chooses a pivot by sampling an adaptive amount of points, approximating
/// the quality of a median of sqrt(n) elements.
#[inline]
pub fn choose_pivot<T, F: FnMut(&T, &T) -> bool>(v: &[T], is_less: &mut F) -> usize {
// We use unsafe code and raw pointers here because we're dealing with
// heavy recursion. Passing safe slices around would involve a lot of
Expand All @@ -22,7 +23,7 @@ pub fn choose_pivot<T, F: FnMut(&T, &T) -> bool>(v: &[T], is_less: &mut F) -> us
// SAFETY: a, b, c point to initialized regions of len_div_8 elements,
// satisfying median3 and median3_rec's preconditions as v_base points
// to an initialized region of n = len elements.
unsafe {
let index = unsafe {
let v_base = v.as_ptr();
let len_div_8 = len / 8;

Expand All @@ -35,6 +36,11 @@ pub fn choose_pivot<T, F: FnMut(&T, &T) -> bool>(v: &[T], is_less: &mut F) -> us
} else {
median3_rec(a, b, c, len_div_8, is_less).offset_from_unsigned(v_base)
}
};
// SAFETY: preconditions must have been met for offset_from_unsigned()
unsafe {
hint::assert_unchecked(index < v.len());
index
}
}

Expand Down
4 changes: 0 additions & 4 deletions library/core/src/slice/sort/stable/quicksort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ pub fn quicksort<T, F: FnMut(&T, &T) -> bool>(
limit -= 1;

let pivot_pos = choose_pivot(v, is_less);
// SAFETY: choose_pivot promises to return a valid pivot index.
unsafe {
intrinsics::assume(pivot_pos < v.len());
}

// SAFETY: We only access the temporary copy for Freeze types, otherwise
// self-modifications via `is_less` would not be observed and this would
Expand Down
3 changes: 1 addition & 2 deletions library/core/src/slice/sort/unstable/quicksort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ pub(crate) fn quicksort<'a, T, F>(
// slice. Partition the slice into elements equal to and elements greater than the pivot.
// This case is usually hit when the slice contains many duplicate elements.
if let Some(p) = ancestor_pivot {
// SAFETY: We assume choose_pivot yields an in-bounds position.
if !is_less(p, unsafe { v.get_unchecked(pivot_pos) }) {
if !is_less(p, &v[pivot_pos]) {
let num_lt = partition(v, pivot_pos, &mut |a, b| !is_less(b, a));

// Continue sorting elements greater than the pivot. We know that `num_lt` contains
Expand Down