Skip to content

Commit

Permalink
fix u32 steps_between for 16-bit systems
Browse files Browse the repository at this point in the history
  • Loading branch information
llogiq committed Aug 30, 2018
1 parent 59e52b1 commit 9dab56c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/libcore/iter/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,16 @@ macro_rules! step_impl_no_between {
)*)
}

step_impl_unsigned!(usize u8 u16 u32);
step_impl_signed!([isize: usize] [i8: u8] [i16: u16] [i32: u32]);
step_impl_unsigned!(usize u8 u16);
#[cfg(not(target_pointer_witdth = "16"))]
step_impl_unsigned!(u32);
#[cfg(target_pointer_witdth = "16")]
step_impl_no_between!(u32);
step_impl_signed!([isize: usize] [i8: u8] [i16: u16]);
#[cfg(not(target_pointer_witdth = "16"))]
step_impl_signed!([i32: u32]);
#[cfg(target_pointer_witdth = "16")]
step_impl_no_between!(i32);
#[cfg(target_pointer_width = "64")]
step_impl_unsigned!(u64);
#[cfg(target_pointer_width = "64")]
Expand Down
23 changes: 23 additions & 0 deletions src/test/run-pass/issue-48006.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(step_trait)]

use std::iter::Step;

#[cfg(target_pointer_width = "16")]
fn main() {
assert!(Step::steps_between(&0u32, &::std::u32::MAX).is_none());
}

#[cfg(any(target_pointer_width = "32", target_pointer_width = "64"))]
fn main() {
assert!(Step::steps_between(&0u32, &::std::u32::MAX).is_some());
}

0 comments on commit 9dab56c

Please sign in to comment.