Skip to content

Commit c903ac6

Browse files
committed
Remove num::{Zero,One}
[unstable, deprecated since 1.11.0]
1 parent 313aab8 commit c903ac6

File tree

7 files changed

+26
-99
lines changed

7 files changed

+26
-99
lines changed

src/doc/unstable-book/src/SUMMARY.md

-2
Original file line numberDiff line numberDiff line change
@@ -217,5 +217,3 @@
217217
- [windows_handle](library-features/windows-handle.md)
218218
- [windows_net](library-features/windows-net.md)
219219
- [windows_stdio](library-features/windows-stdio.md)
220-
- [zero_one](library-features/zero-one.md)
221-
>>>>>> Add top level sections to the Unstable Book.

src/doc/unstable-book/src/library-features/zero-one.md

-7
This file was deleted.

src/libcore/fmt/num.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@
1515
// FIXME: #6220 Implement floating point formatting
1616

1717
use fmt;
18-
use num::Zero;
1918
use ops::{Div, Rem, Sub};
2019
use str;
2120
use slice;
2221
use ptr;
2322
use mem;
2423

2524
#[doc(hidden)]
26-
trait Int: Zero + PartialEq + PartialOrd + Div<Output=Self> + Rem<Output=Self> +
25+
trait Int: PartialEq + PartialOrd + Div<Output=Self> + Rem<Output=Self> +
2726
Sub<Output=Self> + Copy {
27+
fn zero() -> Self;
2828
fn from_u8(u: u8) -> Self;
2929
fn to_u8(&self) -> u8;
3030
fn to_u16(&self) -> u16;
@@ -35,6 +35,7 @@ trait Int: Zero + PartialEq + PartialOrd + Div<Output=Self> + Rem<Output=Self> +
3535

3636
macro_rules! doit {
3737
($($t:ident)*) => ($(impl Int for $t {
38+
fn zero() -> $t { 0 }
3839
fn from_u8(u: u8) -> $t { u as $t }
3940
fn to_u8(&self) -> u8 { *self as u8 }
4041
fn to_u16(&self) -> u16 { *self as u16 }

src/libcore/num/mod.rs

-72
Original file line numberDiff line numberDiff line change
@@ -96,78 +96,6 @@ pub mod dec2flt;
9696
pub mod bignum;
9797
pub mod diy_float;
9898

99-
/// Types that have a "zero" value.
100-
///
101-
/// This trait is intended for use in conjunction with `Add`, as an identity:
102-
/// `x + T::zero() == x`.
103-
#[unstable(feature = "zero_one",
104-
reason = "unsure of placement, wants to use associated constants",
105-
issue = "27739")]
106-
#[rustc_deprecated(since = "1.11.0", reason = "no longer used for \
107-
Iterator::sum")]
108-
pub trait Zero: Sized {
109-
/// The "zero" (usually, additive identity) for this type.
110-
fn zero() -> Self;
111-
}
112-
113-
/// Types that have a "one" value.
114-
///
115-
/// This trait is intended for use in conjunction with `Mul`, as an identity:
116-
/// `x * T::one() == x`.
117-
#[unstable(feature = "zero_one",
118-
reason = "unsure of placement, wants to use associated constants",
119-
issue = "27739")]
120-
#[rustc_deprecated(since = "1.11.0", reason = "no longer used for \
121-
Iterator::product")]
122-
pub trait One: Sized {
123-
/// The "one" (usually, multiplicative identity) for this type.
124-
fn one() -> Self;
125-
}
126-
127-
macro_rules! zero_one_impl {
128-
($($t:ty)*) => ($(
129-
#[unstable(feature = "zero_one",
130-
reason = "unsure of placement, wants to use associated constants",
131-
issue = "27739")]
132-
#[allow(deprecated)]
133-
impl Zero for $t {
134-
#[inline]
135-
fn zero() -> Self { 0 }
136-
}
137-
#[unstable(feature = "zero_one",
138-
reason = "unsure of placement, wants to use associated constants",
139-
issue = "27739")]
140-
#[allow(deprecated)]
141-
impl One for $t {
142-
#[inline]
143-
fn one() -> Self { 1 }
144-
}
145-
)*)
146-
}
147-
zero_one_impl! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize }
148-
149-
macro_rules! zero_one_impl_float {
150-
($($t:ty)*) => ($(
151-
#[unstable(feature = "zero_one",
152-
reason = "unsure of placement, wants to use associated constants",
153-
issue = "27739")]
154-
#[allow(deprecated)]
155-
impl Zero for $t {
156-
#[inline]
157-
fn zero() -> Self { 0.0 }
158-
}
159-
#[unstable(feature = "zero_one",
160-
reason = "unsure of placement, wants to use associated constants",
161-
issue = "27739")]
162-
#[allow(deprecated)]
163-
impl One for $t {
164-
#[inline]
165-
fn one() -> Self { 1.0 }
166-
}
167-
)*)
168-
}
169-
zero_one_impl_float! { f32 f64 }
170-
17199
macro_rules! checked_op {
172100
($U:ty, $op:path, $x:expr, $y:expr) => {{
173101
let (result, overflowed) = unsafe { $op($x as $U, $y as $U) };

src/libstd/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,6 @@
318318
#![feature(untagged_unions)]
319319
#![feature(unwind_attributes)]
320320
#![feature(vec_push_all)]
321-
#![feature(zero_one)]
322321
#![cfg_attr(test, feature(update_panic_count))]
323322
#![cfg_attr(stage0, feature(pub_restricted))]
324323
#![cfg_attr(test, feature(float_bits_conv))]

src/libstd/num.rs

-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
#![stable(feature = "rust1", since = "1.0.0")]
1717
#![allow(missing_docs)]
1818

19-
#[stable(feature = "rust1", since = "1.0.0")]
20-
#[allow(deprecated)]
21-
pub use core::num::{Zero, One};
2219
#[stable(feature = "rust1", since = "1.0.0")]
2320
pub use core::num::{FpCategory, ParseIntError, ParseFloatError, TryFromIntError};
2421
#[stable(feature = "rust1", since = "1.0.0")]

src/test/run-pass/issue-8460.rs

+23-12
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,22 @@
99
// except according to those terms.
1010

1111
// ignore-emscripten no threads support
12-
#![feature(rustc_attrs, zero_one)]
12+
#![feature(rustc_attrs)]
1313

14-
use std::num::Zero;
1514
use std::thread;
1615

16+
trait Int {
17+
fn zero() -> Self;
18+
fn one() -> Self;
19+
}
20+
macro_rules! doit {
21+
($($t:ident)*) => ($(impl Int for $t {
22+
fn zero() -> $t { 0 }
23+
fn one() -> $t { 1 }
24+
})*)
25+
}
26+
doit! { i8 i16 i32 i64 isize }
27+
1728
macro_rules! check {
1829
($($e:expr),*) => {
1930
$(assert!(thread::spawn({
@@ -24,21 +35,21 @@ macro_rules! check {
2435

2536
fn main() {
2637
check![
27-
isize::min_value() / -1,
28-
i8::min_value() / -1,
29-
i16::min_value() / -1,
30-
i32::min_value() / -1,
31-
i64::min_value() / -1,
38+
isize::min_value() / -isize::one(),
39+
i8::min_value() / -i8::one(),
40+
i16::min_value() / -i16::one(),
41+
i32::min_value() / -i32::one(),
42+
i64::min_value() / -i64::one(),
3243
1isize / isize::zero(),
3344
1i8 / i8::zero(),
3445
1i16 / i16::zero(),
3546
1i32 / i32::zero(),
3647
1i64 / i64::zero(),
37-
isize::min_value() % -1,
38-
i8::min_value() % -1,
39-
i16::min_value() % -1,
40-
i32::min_value() % -1,
41-
i64::min_value() % -1,
48+
isize::min_value() % -isize::one(),
49+
i8::min_value() % -i8::one(),
50+
i16::min_value() % -i16::one(),
51+
i32::min_value() % -i32::one(),
52+
i64::min_value() % -i64::one(),
4253
1isize % isize::zero(),
4354
1i8 % i8::zero(),
4455
1i16 % i16::zero(),

0 commit comments

Comments
 (0)