diff options
| author | Corey Farwell <coreyf@rwell.org> | 2017-03-29 16:53:32 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-03-29 16:53:32 -0400 |
| commit | 233e0f3e52910aa7c1436b497d8b9215c172bcfb (patch) | |
| tree | 170e78acdedb38958cf730f1796218db9840cfec | |
| parent | 7f1083e741de0b210bb3eda4f17cffb0b470c3d2 (diff) | |
| parent | b90936449b161f4aee5ff81bbb4906bf5a27f181 (diff) | |
| download | rust-233e0f3e52910aa7c1436b497d8b9215c172bcfb.tar.gz rust-233e0f3e52910aa7c1436b497d8b9215c172bcfb.zip | |
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
| -rw-r--r-- | src/libcore/slice/sort.rs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/libcore/slice/sort.rs b/src/libcore/slice/sort.rs index 3612ee65bca..7065fdb79fc 100644 --- a/src/libcore/slice/sort.rs +++ b/src/libcore/slice/sort.rs @@ -527,7 +527,9 @@ fn break_patterns<T>(v: &mut [T]) { // we first take it modulo a power of two, and then decrease by `len` until it fits // into the range `[0, len - 1]`. let mut other = gen_usize() & (modulus - 1); - while other >= len { + + // `other` is guaranteed to be less than `2 * len`. + if other >= len { other -= len; } |
