Skip to content

Commit fa38b29

Browse files
committed
fix some cfg logic around optimize_for_size and 16-bit targets
1 parent b9ef35a commit fa38b29

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

core/src/slice/sort/shared/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![cfg_attr(feature = "optimize_for_size", allow(dead_code))]
1+
#![cfg_attr(any(feature = "optimize_for_size", target_pointer_width = "16"), allow(dead_code))]
22

33
use crate::marker::Freeze;
44

core/src/slice/sort/stable/mod.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
//! This module contains the entry points for `slice::sort`.
22
3-
#[cfg(not(feature = "optimize_for_size"))]
3+
#[cfg(not(any(feature = "optimize_for_size", target_pointer_width = "16")))]
44
use crate::cmp;
55
use crate::intrinsics;
66
use crate::mem::{self, MaybeUninit, SizedTypeProperties};
7-
#[cfg(not(feature = "optimize_for_size"))]
7+
#[cfg(not(any(feature = "optimize_for_size", target_pointer_width = "16")))]
88
use crate::slice::sort::shared::smallsort::{
99
SMALL_SORT_GENERAL_SCRATCH_LEN, StableSmallSortTypeImpl, insertion_sort_shift_left,
1010
};
1111

1212
pub(crate) mod merge;
1313

14-
#[cfg(not(feature = "optimize_for_size"))]
14+
#[cfg(not(any(feature = "optimize_for_size", target_pointer_width = "16")))]
1515
pub(crate) mod drift;
16-
#[cfg(not(feature = "optimize_for_size"))]
16+
#[cfg(not(any(feature = "optimize_for_size", target_pointer_width = "16")))]
1717
pub(crate) mod quicksort;
1818

19-
#[cfg(feature = "optimize_for_size")]
19+
#[cfg(any(feature = "optimize_for_size", target_pointer_width = "16"))]
2020
pub(crate) mod tiny;
2121

2222
/// Stable sort called driftsort by Orson Peters and Lukas Bergdoll.
@@ -45,7 +45,7 @@ pub fn sort<T, F: FnMut(&T, &T) -> bool, BufT: BufGuard<T>>(v: &mut [T], is_less
4545

4646
cfg_if! {
4747
if #[cfg(target_pointer_width = "16")] {
48-
let heap_buf = BufT::with_capacity(alloc_len);
48+
let mut heap_buf = BufT::with_capacity(alloc_len);
4949
let scratch = heap_buf.as_uninit_slice_mut();
5050
} else {
5151
// For small inputs 4KiB of stack storage suffices, which allows us to avoid
@@ -85,7 +85,7 @@ pub fn sort<T, F: FnMut(&T, &T) -> bool, BufT: BufGuard<T>>(v: &mut [T], is_less
8585
///
8686
/// Deliberately don't inline the main sorting routine entrypoint to ensure the
8787
/// inlined insertion sort i-cache footprint remains minimal.
88-
#[cfg(not(feature = "optimize_for_size"))]
88+
#[cfg(not(any(feature = "optimize_for_size", target_pointer_width = "16")))]
8989
#[inline(never)]
9090
fn driftsort_main<T, F: FnMut(&T, &T) -> bool, BufT: BufGuard<T>>(v: &mut [T], is_less: &mut F) {
9191
// By allocating n elements of memory we can ensure the entire input can

core/src/slice/sort/unstable/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
33
use crate::intrinsics;
44
use crate::mem::SizedTypeProperties;
5-
#[cfg(not(feature = "optimize_for_size"))]
5+
#[cfg(not(any(feature = "optimize_for_size", target_pointer_width = "16")))]
66
use crate::slice::sort::shared::find_existing_run;
7-
#[cfg(not(feature = "optimize_for_size"))]
7+
#[cfg(not(any(feature = "optimize_for_size", target_pointer_width = "16")))]
88
use crate::slice::sort::shared::smallsort::insertion_sort_shift_left;
99

1010
pub(crate) mod heapsort;
@@ -55,7 +55,7 @@ pub fn sort<T, F: FnMut(&T, &T) -> bool>(v: &mut [T], is_less: &mut F) {
5555
///
5656
/// Deliberately don't inline the main sorting routine entrypoint to ensure the
5757
/// inlined insertion sort i-cache footprint remains minimal.
58-
#[cfg(not(feature = "optimize_for_size"))]
58+
#[cfg(not(any(feature = "optimize_for_size", target_pointer_width = "16")))]
5959
#[inline(never)]
6060
fn ipnsort<T, F>(v: &mut [T], is_less: &mut F)
6161
where

0 commit comments

Comments
 (0)