diff --git a/src/libcore/iter/range.rs b/src/libcore/iter/range.rs index 651c7a35d413c..55addd86bc1ce 100644 --- a/src/libcore/iter/range.rs +++ b/src/libcore/iter/range.rs @@ -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")] diff --git a/src/test/run-pass/issue-48006.rs b/src/test/run-pass/issue-48006.rs new file mode 100644 index 0000000000000..d5887bb64cd25 --- /dev/null +++ b/src/test/run-pass/issue-48006.rs @@ -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 or the MIT license +// , 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()); +}