Skip to content

Commit 233e0f3

Browse files
authored
Rollup merge of #40832 - pftbest:fix_msp430, r=stjepang
libcore: fix compilation on 16bit target (MSP430). Since PR #40601 has been merged, libcore no longer compiles on MSP430. The reason is this code in `break_patterns`: ```rust let mut random = len; random ^= random << 13; random ^= random >> 17; random ^= random << 5; random &= modulus - 1; ``` It assumes that `len` is at least a 32 bit integer. As a workaround replace `break_patterns` with an empty function for 16bit targets. cc @stjepang cc @alexcrichton
2 parents 7f1083e + b909364 commit 233e0f3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/libcore/slice/sort.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,9 @@ fn break_patterns<T>(v: &mut [T]) {
527527
// we first take it modulo a power of two, and then decrease by `len` until it fits
528528
// into the range `[0, len - 1]`.
529529
let mut other = gen_usize() & (modulus - 1);
530-
while other >= len {
530+
531+
// `other` is guaranteed to be less than `2 * len`.
532+
if other >= len {
531533
other -= len;
532534
}
533535

0 commit comments

Comments
 (0)