Skip to content

Commit e39a823

Browse files
gergoerdishepmaster
authored andcommitted
Disable operations on 128-bit numbers
Works around avr-rust/rust-legacy-fork#37 and avr-rust/rust-legacy-fork#57
1 parent f9a3909 commit e39a823

File tree

6 files changed

+15
-55
lines changed

6 files changed

+15
-55
lines changed

src/fmt/num.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ trait Int: PartialEq + PartialOrd + Div<Output=Self> + Rem<Output=Self> +
2929
fn to_u16(&self) -> u16;
3030
fn to_u32(&self) -> u32;
3131
fn to_u64(&self) -> u64;
32-
fn to_u128(&self) -> u128;
3332
}
3433

3534
macro_rules! doit {
@@ -40,10 +39,9 @@ macro_rules! doit {
4039
fn to_u16(&self) -> u16 { *self as u16 }
4140
fn to_u32(&self) -> u32 { *self as u32 }
4241
fn to_u64(&self) -> u64 { *self as u64 }
43-
fn to_u128(&self) -> u128 { *self as u128 }
4442
})*)
4543
}
46-
doit! { i8 i16 i32 i64 i128 isize u8 u16 u32 u64 u128 usize }
44+
doit! { i8 i16 i32 i64 isize u8 u16 u32 u64 usize }
4745

4846
/// A type that represents a specific radix
4947
#[doc(hidden)]
@@ -184,7 +182,6 @@ integer! { i8, u8 }
184182
integer! { i16, u16 }
185183
integer! { i32, u32 }
186184
integer! { i64, u64 }
187-
integer! { i128, u128 }
188185

189186
const DEC_DIGITS_LUT: &'static[u8] =
190187
b"0001020304050607080910111213141516171819\
@@ -260,7 +257,6 @@ macro_rules! impl_Display {
260257

261258
impl_Display!(i8, u8, i16, u16, i32, u32: to_u32);
262259
impl_Display!(i64, u64: to_u64);
263-
impl_Display!(i128, u128: to_u128);
264260
#[cfg(target_pointer_width = "16")]
265261
impl_Display!(isize, usize: to_u16);
266262
#[cfg(target_pointer_width = "32")]

src/iter/range.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ step_impl_signed!([i64: u64]);
175175
// assume here that it is less than 64-bits.
176176
#[cfg(not(target_pointer_width = "64"))]
177177
step_impl_no_between!(u64 i64);
178-
step_impl_no_between!(u128 i128);
179178

180179
macro_rules! range_exact_iter_impl {
181180
($($t:ty)*) => ($(

src/iter/traits.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ macro_rules! float_sum_product {
833833
)*)
834834
}
835835

836-
integer_sum_product! { i8 i16 i32 i64 i128 isize u8 u16 u32 u64 u128 usize }
836+
integer_sum_product! { i8 i16 i32 i64 isize u8 u16 u32 u64 usize }
837837
float_sum_product! { f32 f64 }
838838

839839
/// An iterator adapter that produces output as long as the underlying

src/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,12 @@ mod uint_macros;
138138
#[path = "num/i16.rs"] pub mod i16;
139139
#[path = "num/i32.rs"] pub mod i32;
140140
#[path = "num/i64.rs"] pub mod i64;
141-
#[path = "num/i128.rs"] pub mod i128;
142141

143142
#[path = "num/usize.rs"] pub mod usize;
144143
#[path = "num/u8.rs"] pub mod u8;
145144
#[path = "num/u16.rs"] pub mod u16;
146145
#[path = "num/u32.rs"] pub mod u32;
147146
#[path = "num/u64.rs"] pub mod u64;
148-
#[path = "num/u128.rs"] pub mod u128;
149-
150147

151148
#[macro_use]
152149
pub mod num;

src/num/mod.rs

Lines changed: 11 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ nonzero_integers! {
101101
NonZeroU16(u16);
102102
NonZeroU32(u32);
103103
NonZeroU64(u64);
104-
NonZeroU128(u128);
105104
NonZeroUsize(usize);
106105
}
107106

@@ -114,7 +113,6 @@ nonzero_integers! {
114113
NonZeroI16(i16);
115114
NonZeroI32(i32);
116115
NonZeroI64(i64);
117-
NonZeroI128(i128);
118116
NonZeroIsize(isize);
119117
}
120118

@@ -1940,12 +1938,6 @@ impl i64 {
19401938
int_impl! { i64, i64, u64, 64, -9223372036854775808, 9223372036854775807, "", "" }
19411939
}
19421940

1943-
#[lang = "i128"]
1944-
impl i128 {
1945-
int_impl! { i128, i128, u128, 128, -170141183460469231731687303715884105728,
1946-
170141183460469231731687303715884105727, "", "" }
1947-
}
1948-
19491941
#[cfg(target_pointer_width = "16")]
19501942
#[lang = "isize"]
19511943
impl isize {
@@ -4030,11 +4022,6 @@ impl u64 {
40304022
uint_impl! { u64, u64, 64, 18446744073709551615, "", "" }
40314023
}
40324024

4033-
#[lang = "u128"]
4034-
impl u128 {
4035-
uint_impl! { u128, u128, 128, 340282366920938463463374607431768211455, "", "" }
4036-
}
4037-
40384025
#[cfg(target_pointer_width = "16")]
40394026
#[lang = "usize"]
40404027
impl usize {
@@ -4168,7 +4155,7 @@ macro_rules! from_str_radix_int_impl {
41684155
}
41694156
)*}
41704157
}
4171-
from_str_radix_int_impl! { isize i8 i16 i32 i64 i128 usize u8 u16 u32 u64 u128 }
4158+
from_str_radix_int_impl! { isize i8 i16 i32 i64 usize u8 u16 u32 u64 }
41724159

41734160
/// The error type returned when a checked integral type conversion fails.
41744161
#[unstable(feature = "try_from", issue = "33417")]
@@ -4269,30 +4256,25 @@ macro_rules! rev {
42694256
try_from_upper_bounded!(u16, u8);
42704257
try_from_upper_bounded!(u32, u16, u8);
42714258
try_from_upper_bounded!(u64, u32, u16, u8);
4272-
try_from_upper_bounded!(u128, u64, u32, u16, u8);
42734259

42744260
try_from_both_bounded!(i16, i8);
42754261
try_from_both_bounded!(i32, i16, i8);
42764262
try_from_both_bounded!(i64, i32, i16, i8);
4277-
try_from_both_bounded!(i128, i64, i32, i16, i8);
42784263

42794264
// unsigned-to-signed
42804265
try_from_upper_bounded!(u8, i8);
42814266
try_from_upper_bounded!(u16, i8, i16);
42824267
try_from_upper_bounded!(u32, i8, i16, i32);
42834268
try_from_upper_bounded!(u64, i8, i16, i32, i64);
4284-
try_from_upper_bounded!(u128, i8, i16, i32, i64, i128);
42854269

42864270
// signed-to-unsigned
4287-
try_from_lower_bounded!(i8, u8, u16, u32, u64, u128);
4288-
try_from_lower_bounded!(i16, u16, u32, u64, u128);
4289-
try_from_lower_bounded!(i32, u32, u64, u128);
4290-
try_from_lower_bounded!(i64, u64, u128);
4291-
try_from_lower_bounded!(i128, u128);
4271+
try_from_lower_bounded!(i8, u8, u16, u32, u64);
4272+
try_from_lower_bounded!(i16, u16, u32, u64);
4273+
try_from_lower_bounded!(i32, u32, u64);
4274+
try_from_lower_bounded!(i64, u64);
42924275
try_from_both_bounded!(i16, u8);
42934276
try_from_both_bounded!(i32, u16, u8);
42944277
try_from_both_bounded!(i64, u32, u16, u8);
4295-
try_from_both_bounded!(i128, u64, u32, u16, u8);
42964278

42974279
// usize/isize
42984280
try_from_upper_bounded!(usize, isize);
@@ -4309,9 +4291,9 @@ mod ptr_try_from_impls {
43094291
use convert::TryFrom;
43104292

43114293
// Fallible across platfoms, only implementation differs
4312-
try_from_lower_bounded!(isize, u16, u32, u64, u128);
4294+
try_from_lower_bounded!(isize, u16, u32, u64);
43134295
rev!(try_from_lower_bounded, usize, i8, i16);
4314-
rev!(try_from_both_bounded, usize, i32, i64, i128);
4296+
rev!(try_from_both_bounded, usize, i32, i64);
43154297
}
43164298

43174299
#[cfg(target_pointer_width = "32")]
@@ -4321,9 +4303,9 @@ mod ptr_try_from_impls {
43214303

43224304
// Fallible across platfoms, only implementation differs
43234305
try_from_both_bounded!(isize, u16);
4324-
try_from_lower_bounded!(isize, u32, u64, u128);
4306+
try_from_lower_bounded!(isize, u32, u64);
43254307
rev!(try_from_lower_bounded, usize, i8, i16, i32);
4326-
rev!(try_from_both_bounded, usize, i64, i128);
4308+
rev!(try_from_both_bounded, usize, i64);
43274309
}
43284310

43294311
#[cfg(target_pointer_width = "64")]
@@ -4333,9 +4315,8 @@ mod ptr_try_from_impls {
43334315

43344316
// Fallible across platfoms, only implementation differs
43354317
try_from_both_bounded!(isize, u16, u32);
4336-
try_from_lower_bounded!(isize, u64, u128);
4318+
try_from_lower_bounded!(isize, u64);
43374319
rev!(try_from_lower_bounded, usize, i8, i16, i32, i64);
4338-
rev!(try_from_both_bounded, usize, i128);
43394320
}
43404321

43414322
#[doc(hidden)]
@@ -4370,7 +4351,7 @@ macro_rules! doit {
43704351
}
43714352
})*)
43724353
}
4373-
doit! { i8 i16 i32 i64 i128 isize u8 u16 u32 u64 u128 usize }
4354+
doit! { i8 i16 i32 isize u8 u16 u32 usize }
43744355

43754356
fn from_str_radix<T: FromStrRadixHelper>(src: &str, radix: u32) -> Result<T, ParseIntError> {
43764357
use self::IntErrorKind::*;
@@ -4511,39 +4492,27 @@ macro_rules! impl_from {
45114492
impl_from! { u8, u16, #[stable(feature = "lossless_int_conv", since = "1.5.0")] }
45124493
impl_from! { u8, u32, #[stable(feature = "lossless_int_conv", since = "1.5.0")] }
45134494
impl_from! { u8, u64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] }
4514-
impl_from! { u8, u128, #[stable(feature = "i128", since = "1.26.0")] }
45154495
impl_from! { u8, usize, #[stable(feature = "lossless_int_conv", since = "1.5.0")] }
45164496
impl_from! { u16, u32, #[stable(feature = "lossless_int_conv", since = "1.5.0")] }
45174497
impl_from! { u16, u64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] }
4518-
impl_from! { u16, u128, #[stable(feature = "i128", since = "1.26.0")] }
45194498
impl_from! { u32, u64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] }
4520-
impl_from! { u32, u128, #[stable(feature = "i128", since = "1.26.0")] }
4521-
impl_from! { u64, u128, #[stable(feature = "i128", since = "1.26.0")] }
45224499

45234500
// Signed -> Signed
45244501
impl_from! { i8, i16, #[stable(feature = "lossless_int_conv", since = "1.5.0")] }
45254502
impl_from! { i8, i32, #[stable(feature = "lossless_int_conv", since = "1.5.0")] }
45264503
impl_from! { i8, i64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] }
4527-
impl_from! { i8, i128, #[stable(feature = "i128", since = "1.26.0")] }
45284504
impl_from! { i8, isize, #[stable(feature = "lossless_int_conv", since = "1.5.0")] }
45294505
impl_from! { i16, i32, #[stable(feature = "lossless_int_conv", since = "1.5.0")] }
45304506
impl_from! { i16, i64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] }
4531-
impl_from! { i16, i128, #[stable(feature = "i128", since = "1.26.0")] }
45324507
impl_from! { i32, i64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] }
4533-
impl_from! { i32, i128, #[stable(feature = "i128", since = "1.26.0")] }
4534-
impl_from! { i64, i128, #[stable(feature = "i128", since = "1.26.0")] }
45354508

45364509
// Unsigned -> Signed
45374510
impl_from! { u8, i16, #[stable(feature = "lossless_int_conv", since = "1.5.0")] }
45384511
impl_from! { u8, i32, #[stable(feature = "lossless_int_conv", since = "1.5.0")] }
45394512
impl_from! { u8, i64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] }
4540-
impl_from! { u8, i128, #[stable(feature = "i128", since = "1.26.0")] }
45414513
impl_from! { u16, i32, #[stable(feature = "lossless_int_conv", since = "1.5.0")] }
45424514
impl_from! { u16, i64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] }
4543-
impl_from! { u16, i128, #[stable(feature = "i128", since = "1.26.0")] }
45444515
impl_from! { u32, i64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] }
4545-
impl_from! { u32, i128, #[stable(feature = "i128", since = "1.26.0")] }
4546-
impl_from! { u64, i128, #[stable(feature = "i128", since = "1.26.0")] }
45474516

45484517
// The C99 standard defines bounds on INTPTR_MIN, INTPTR_MAX, and UINTPTR_MAX
45494518
// which imply that pointer-sized integers must be at least 16 bits:
@@ -4558,7 +4527,6 @@ impl_from! { i16, isize, #[stable(feature = "lossless_iusize_conv", since = "1.2
45584527
// https://www.cl.cam.ac.uk/research/security/ctsrd/pdfs/20171017a-cheri-poster.pdf
45594528
// http://www.csl.sri.com/users/neumann/2012resolve-cheri.pdf
45604529

4561-
45624530
// Note: integers can only be represented with full precision in a float if
45634531
// they fit in the significand, which is 24 bits in f32 and 53 bits in f64.
45644532
// Lossy float conversions are not implemented at this time.

src/num/wrapping.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ macro_rules! wrapping_impl {
321321
)*)
322322
}
323323

324-
wrapping_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
324+
wrapping_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 }
325325

326326
macro_rules! wrapping_int_impl {
327327
($($t:ty)*) => ($(
@@ -628,7 +628,7 @@ macro_rules! wrapping_int_impl {
628628
)*)
629629
}
630630

631-
wrapping_int_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
631+
wrapping_int_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 }
632632

633633

634634
mod shift_max {

0 commit comments

Comments
 (0)