Skip to content

Commit

Permalink
Remove num::{Zero,One}
Browse files Browse the repository at this point in the history
[unstable, deprecated since 1.11.0]
  • Loading branch information
cuviper committed Apr 21, 2017
1 parent 313aab8 commit c903ac6
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 99 deletions.
2 changes: 0 additions & 2 deletions src/doc/unstable-book/src/SUMMARY.md
Expand Up @@ -217,5 +217,3 @@
- [windows_handle](library-features/windows-handle.md)
- [windows_net](library-features/windows-net.md)
- [windows_stdio](library-features/windows-stdio.md)
- [zero_one](library-features/zero-one.md)
>>>>>> Add top level sections to the Unstable Book.
7 changes: 0 additions & 7 deletions src/doc/unstable-book/src/library-features/zero-one.md

This file was deleted.

5 changes: 3 additions & 2 deletions src/libcore/fmt/num.rs
Expand Up @@ -15,16 +15,16 @@
// FIXME: #6220 Implement floating point formatting

use fmt;
use num::Zero;
use ops::{Div, Rem, Sub};
use str;
use slice;
use ptr;
use mem;

#[doc(hidden)]
trait Int: Zero + PartialEq + PartialOrd + Div<Output=Self> + Rem<Output=Self> +
trait Int: PartialEq + PartialOrd + Div<Output=Self> + Rem<Output=Self> +
Sub<Output=Self> + Copy {
fn zero() -> Self;
fn from_u8(u: u8) -> Self;
fn to_u8(&self) -> u8;
fn to_u16(&self) -> u16;
Expand All @@ -35,6 +35,7 @@ trait Int: Zero + PartialEq + PartialOrd + Div<Output=Self> + Rem<Output=Self> +

macro_rules! doit {
($($t:ident)*) => ($(impl Int for $t {
fn zero() -> $t { 0 }
fn from_u8(u: u8) -> $t { u as $t }
fn to_u8(&self) -> u8 { *self as u8 }
fn to_u16(&self) -> u16 { *self as u16 }
Expand Down
72 changes: 0 additions & 72 deletions src/libcore/num/mod.rs
Expand Up @@ -96,78 +96,6 @@ pub mod dec2flt;
pub mod bignum;
pub mod diy_float;

/// Types that have a "zero" value.
///
/// This trait is intended for use in conjunction with `Add`, as an identity:
/// `x + T::zero() == x`.
#[unstable(feature = "zero_one",
reason = "unsure of placement, wants to use associated constants",
issue = "27739")]
#[rustc_deprecated(since = "1.11.0", reason = "no longer used for \
Iterator::sum")]
pub trait Zero: Sized {
/// The "zero" (usually, additive identity) for this type.
fn zero() -> Self;
}

/// Types that have a "one" value.
///
/// This trait is intended for use in conjunction with `Mul`, as an identity:
/// `x * T::one() == x`.
#[unstable(feature = "zero_one",
reason = "unsure of placement, wants to use associated constants",
issue = "27739")]
#[rustc_deprecated(since = "1.11.0", reason = "no longer used for \
Iterator::product")]
pub trait One: Sized {
/// The "one" (usually, multiplicative identity) for this type.
fn one() -> Self;
}

macro_rules! zero_one_impl {
($($t:ty)*) => ($(
#[unstable(feature = "zero_one",
reason = "unsure of placement, wants to use associated constants",
issue = "27739")]
#[allow(deprecated)]
impl Zero for $t {
#[inline]
fn zero() -> Self { 0 }
}
#[unstable(feature = "zero_one",
reason = "unsure of placement, wants to use associated constants",
issue = "27739")]
#[allow(deprecated)]
impl One for $t {
#[inline]
fn one() -> Self { 1 }
}
)*)
}
zero_one_impl! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize }

macro_rules! zero_one_impl_float {
($($t:ty)*) => ($(
#[unstable(feature = "zero_one",
reason = "unsure of placement, wants to use associated constants",
issue = "27739")]
#[allow(deprecated)]
impl Zero for $t {
#[inline]
fn zero() -> Self { 0.0 }
}
#[unstable(feature = "zero_one",
reason = "unsure of placement, wants to use associated constants",
issue = "27739")]
#[allow(deprecated)]
impl One for $t {
#[inline]
fn one() -> Self { 1.0 }
}
)*)
}
zero_one_impl_float! { f32 f64 }

macro_rules! checked_op {
($U:ty, $op:path, $x:expr, $y:expr) => {{
let (result, overflowed) = unsafe { $op($x as $U, $y as $U) };
Expand Down
1 change: 0 additions & 1 deletion src/libstd/lib.rs
Expand Up @@ -318,7 +318,6 @@
#![feature(untagged_unions)]
#![feature(unwind_attributes)]
#![feature(vec_push_all)]
#![feature(zero_one)]
#![cfg_attr(test, feature(update_panic_count))]
#![cfg_attr(stage0, feature(pub_restricted))]
#![cfg_attr(test, feature(float_bits_conv))]
Expand Down
3 changes: 0 additions & 3 deletions src/libstd/num.rs
Expand Up @@ -16,9 +16,6 @@
#![stable(feature = "rust1", since = "1.0.0")]
#![allow(missing_docs)]

#[stable(feature = "rust1", since = "1.0.0")]
#[allow(deprecated)]
pub use core::num::{Zero, One};
#[stable(feature = "rust1", since = "1.0.0")]
pub use core::num::{FpCategory, ParseIntError, ParseFloatError, TryFromIntError};
#[stable(feature = "rust1", since = "1.0.0")]
Expand Down
35 changes: 23 additions & 12 deletions src/test/run-pass/issue-8460.rs
Expand Up @@ -9,11 +9,22 @@
// except according to those terms.

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

use std::num::Zero;
use std::thread;

trait Int {
fn zero() -> Self;
fn one() -> Self;
}
macro_rules! doit {
($($t:ident)*) => ($(impl Int for $t {
fn zero() -> $t { 0 }
fn one() -> $t { 1 }
})*)
}
doit! { i8 i16 i32 i64 isize }

macro_rules! check {
($($e:expr),*) => {
$(assert!(thread::spawn({
Expand All @@ -24,21 +35,21 @@ macro_rules! check {

fn main() {
check![
isize::min_value() / -1,
i8::min_value() / -1,
i16::min_value() / -1,
i32::min_value() / -1,
i64::min_value() / -1,
isize::min_value() / -isize::one(),
i8::min_value() / -i8::one(),
i16::min_value() / -i16::one(),
i32::min_value() / -i32::one(),
i64::min_value() / -i64::one(),
1isize / isize::zero(),
1i8 / i8::zero(),
1i16 / i16::zero(),
1i32 / i32::zero(),
1i64 / i64::zero(),
isize::min_value() % -1,
i8::min_value() % -1,
i16::min_value() % -1,
i32::min_value() % -1,
i64::min_value() % -1,
isize::min_value() % -isize::one(),
i8::min_value() % -i8::one(),
i16::min_value() % -i16::one(),
i32::min_value() % -i32::one(),
i64::min_value() % -i64::one(),
1isize % isize::zero(),
1i8 % i8::zero(),
1i16 % i16::zero(),
Expand Down

0 comments on commit c903ac6

Please sign in to comment.