We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
slice::sort
1 parent 94a0cd1 commit 00e6809Copy full SHA for 00e6809
2 files changed
library/alloctests/tests/sort/tests.rs
@@ -362,6 +362,13 @@ fn sort_vs_sort_by_impl<S: Sort>() {
362
assert_eq!(input_sort_by, expected);
363
}
364
365
+pub fn box_value_impl<S: Sort>() {
366
+ for len in [3, 9, 35, 56, 132] {
367
+ test_is_sorted::<Box<i32>, S>(len, Box::new, patterns::random);
368
+ test_is_sorted::<Box<i32>, S>(len, Box::new, |len| patterns::random_sorted(len, 80.0));
369
+ }
370
+}
371
+
372
gen_sort_test_fns_with_default_patterns!(
373
correct_i32,
374
|len, pattern_fn| test_is_sorted::<i32, S>(len, |val| val, pattern_fn),
@@ -967,6 +974,7 @@ define_instantiate_sort_tests!(
967
974
[miri_yes, fixed_seed_rand_vec_prefix],
968
975
[miri_yes, int_edge],
969
976
[miri_yes, sort_vs_sort_by],
977
+ [miri_yes, box_value],
970
978
[miri_yes, correct_i32_random],
971
979
[miri_yes, correct_i32_random_z1],
972
980
[miri_yes, correct_i32_random_d2],
library/core/src/slice/sort/stable/quicksort.rs
@@ -42,7 +42,10 @@ pub fn quicksort<T, F: FnMut(&T, &T) -> bool>(
42
// self-modifications via `is_less` would not be observed and this would
43
// be unsound. Our temporary copy does not escape this scope.
44
let pivot_copy = unsafe { ManuallyDrop::new(ptr::read(&v[pivot_pos])) };
45
- let pivot_ref = (!has_direct_interior_mutability::<T>()).then_some(&*pivot_copy);
+ // Stacked Borrows does not allow the access pattern for `pivot_copy`, but Tree Borrows
46
+ // does. FIXME: Remove `!cfg!(miri)` once/if Tree Borrows becomes the standard.
47
+ let pivot_ref =
48
+ (!has_direct_interior_mutability::<T>() && !cfg!(miri)).then_some(&*pivot_copy);
49
50
// We choose a pivot, and check if this pivot is equal to our left
51
// ancestor. If true, we do a partition putting equal elements on the
0 commit comments