From 90f9eb3b1ef30ea07ae16f9445a8ab0d97269917 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marvin=20L=C3=B6bel?= Date: Fri, 29 Nov 2013 15:52:38 +0100 Subject: [PATCH 1/3] Removed a few macro-expanding-to-module workarounds Also documented a few issues --- src/libstd/fmt/mod.rs | 39 ++++--- src/libstd/num/f32.rs | 33 +++--- src/libstd/num/f64.rs | 33 +++--- src/libstd/num/int_macros.rs | 4 +- src/libstd/num/uint_macros.rs | 4 +- src/libstd/tuple.rs | 184 ++++++++++++++++------------------ src/libstd/vec.rs | 31 +----- 7 files changed, 143 insertions(+), 185 deletions(-) diff --git a/src/libstd/fmt/mod.rs b/src/libstd/fmt/mod.rs index 9fa2c7ab1f3b4..2d37d82e172c6 100644 --- a/src/libstd/fmt/mod.rs +++ b/src/libstd/fmt/mod.rs @@ -1036,31 +1036,26 @@ pub fn upperhex(buf: &[u8], f: &mut Formatter) { f.pad_integral(local.slice_to(buf.len()), "0x", true); } -// FIXME(#4375) shouldn't need an inner module macro_rules! integer(($signed:ident, $unsigned:ident) => { - mod $signed { - use super::*; - - // Signed is special because it actuall emits the negative sign, - // nothing else should do that, however. - impl Signed for $signed { - fn fmt(c: &$signed, f: &mut Formatter) { - ::$unsigned::to_str_bytes(c.abs() as $unsigned, 10, |buf| { - f.pad_integral(buf, "", *c >= 0); - }) - } + // Signed is special because it actuall emits the negative sign, + // nothing else should do that, however. + impl Signed for $signed { + fn fmt(c: &$signed, f: &mut Formatter) { + ::$unsigned::to_str_bytes(c.abs() as $unsigned, 10, |buf| { + f.pad_integral(buf, "", *c >= 0); + }) } - int_base!($signed, $unsigned, 2, Binary, "0b") - int_base!($signed, $unsigned, 8, Octal, "0o") - int_base!($signed, $unsigned, 16, LowerHex, "0x") - upper_hex!($signed, $unsigned) - - int_base!($unsigned, $unsigned, 2, Binary, "0b") - int_base!($unsigned, $unsigned, 8, Octal, "0o") - int_base!($unsigned, $unsigned, 10, Unsigned, "") - int_base!($unsigned, $unsigned, 16, LowerHex, "0x") - upper_hex!($unsigned, $unsigned) } + int_base!($signed, $unsigned, 2, Binary, "0b") + int_base!($signed, $unsigned, 8, Octal, "0o") + int_base!($signed, $unsigned, 16, LowerHex, "0x") + upper_hex!($signed, $unsigned) + + int_base!($unsigned, $unsigned, 2, Binary, "0b") + int_base!($unsigned, $unsigned, 8, Octal, "0o") + int_base!($unsigned, $unsigned, 10, Unsigned, "") + int_base!($unsigned, $unsigned, 16, LowerHex, "0x") + upper_hex!($unsigned, $unsigned) }) integer!(int, uint) diff --git a/src/libstd/num/f32.rs b/src/libstd/num/f32.rs index a0dddffd85184..53bd2d3dc0865 100644 --- a/src/libstd/num/f32.rs +++ b/src/libstd/num/f32.rs @@ -11,18 +11,19 @@ //! Operations and constants for `f32` #[allow(missing_doc)]; +use prelude::*; + +use cmath::c_float_utils; use default::Default; -use libc::c_int; -use num::{Zero, One, strconv}; +use libc::{c_float, c_int}; use num::{FPCategory, FPNaN, FPInfinite , FPZero, FPSubnormal, FPNormal}; +use num::{Zero, One, strconv}; use num; -use prelude::*; use to_str; +use unstable::intrinsics; pub use cmath::c_float_targ_consts::*; -use self::delegated::*; - macro_rules! delegate( ( $( @@ -33,22 +34,14 @@ macro_rules! delegate( ) -> $rv:ty = $bound_name:path ),* ) => ( - // An inner module is required to get the #[inline] attribute on the - // functions. - mod delegated { - use cmath::c_float_utils; - use libc::{c_float, c_int}; - use unstable::intrinsics; - - $( - #[inline] - pub fn $name($( $arg : $arg_ty ),*) -> $rv { - unsafe { - $bound_name($( $arg ),*) - } + $( + #[inline] + pub fn $name($( $arg : $arg_ty ),*) -> $rv { + unsafe { + $bound_name($( $arg ),*) } - )* - } + } + )* ) ) diff --git a/src/libstd/num/f64.rs b/src/libstd/num/f64.rs index 8cb7fa1800186..49b20b2c4f473 100644 --- a/src/libstd/num/f64.rs +++ b/src/libstd/num/f64.rs @@ -12,19 +12,20 @@ #[allow(missing_doc)]; +use prelude::*; + +use cmath::c_double_utils; use default::Default; -use libc::c_int; -use num::{Zero, One, strconv}; +use libc::{c_double, c_int}; use num::{FPCategory, FPNaN, FPInfinite , FPZero, FPSubnormal, FPNormal}; +use num::{Zero, One, strconv}; use num; -use prelude::*; use to_str; +use unstable::intrinsics; pub use cmath::c_double_targ_consts::*; pub use cmp::{min, max}; -use self::delegated::*; - macro_rules! delegate( ( $( @@ -35,22 +36,14 @@ macro_rules! delegate( ) -> $rv:ty = $bound_name:path ),* ) => ( - // An inner module is required to get the #[inline] attribute on the - // functions. - mod delegated { - use cmath::c_double_utils; - use libc::{c_double, c_int}; - use unstable::intrinsics; - - $( - #[inline] - pub fn $name($( $arg : $arg_ty ),*) -> $rv { - unsafe { - $bound_name($( $arg ),*) - } + $( + #[inline] + pub fn $name($( $arg : $arg_ty ),*) -> $rv { + unsafe { + $bound_name($( $arg ),*) } - )* - } + } + )* ) ) diff --git a/src/libstd/num/int_macros.rs b/src/libstd/num/int_macros.rs index fc56bf91c2a77..42f0ed95d1e0f 100644 --- a/src/libstd/num/int_macros.rs +++ b/src/libstd/num/int_macros.rs @@ -8,7 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// FIXME(#4375): this shouldn't have to be a nested module named 'generated' +// FIXME(#4375): This shouldn't have to be a nested module named 'generated'... +// FIXME(#10716): ... but now that we could solve that, the import lines and +// attributes still prevent a removal of that module. #[macro_escape]; #[doc(hidden)]; diff --git a/src/libstd/num/uint_macros.rs b/src/libstd/num/uint_macros.rs index 3c276378df863..0a21aa9fcc8a8 100644 --- a/src/libstd/num/uint_macros.rs +++ b/src/libstd/num/uint_macros.rs @@ -8,7 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// FIXME(#4375): this shouldn't have to be a nested module named 'generated' +// FIXME(#4375): This shouldn't have to be a nested module named 'generated'... +// FIXME(#10716): ... but now that we could solve that, the import lines and +// attributes still prevent a removal of that module. #[macro_escape]; #[doc(hidden)]; diff --git a/src/libstd/tuple.rs b/src/libstd/tuple.rs index 623909b79759e..313fd9c79b46a 100644 --- a/src/libstd/tuple.rs +++ b/src/libstd/tuple.rs @@ -13,8 +13,9 @@ #[allow(missing_doc)]; use clone::Clone; - -pub use self::inner::*; +#[cfg(not(test))] use cmp::*; +#[cfg(not(test))] use default::Default; +#[cfg(not(test))] use num::Zero; /// Method extensions to pairs where both types satisfy the `Clone` bound pub trait CopyableTuple { @@ -86,116 +87,109 @@ macro_rules! tuple_impls { })+ } )+) => { - pub mod inner { - use clone::Clone; - #[cfg(not(test))] use cmp::*; - #[cfg(not(test))] use default::Default; - #[cfg(not(test))] use num::Zero; - - $( - pub trait $move_trait<$($T),+> { - $(fn $get_fn(self) -> $T;)+ - } + $( + pub trait $move_trait<$($T),+> { + $(fn $get_fn(self) -> $T;)+ + } - impl<$($T),+> $move_trait<$($T),+> for ($($T,)+) { - $( - #[inline] - fn $get_fn(self) -> $T { - let $move_pattern = self; - $ret - } - )+ - } - - pub trait $immutable_trait<$($T),+> { - $(fn $get_ref_fn<'a>(&'a self) -> &'a $T;)+ - } + impl<$($T),+> $move_trait<$($T),+> for ($($T,)+) { + $( + #[inline] + fn $get_fn(self) -> $T { + let $move_pattern = self; + $ret + } + )+ + } - impl<$($T),+> $immutable_trait<$($T),+> for ($($T,)+) { - $( - #[inline] - fn $get_ref_fn<'a>(&'a self) -> &'a $T { - let $ref_pattern = *self; - $ret - } - )+ - } + pub trait $immutable_trait<$($T),+> { + $(fn $get_ref_fn<'a>(&'a self) -> &'a $T;)+ + } - impl<$($T:Clone),+> Clone for ($($T,)+) { - fn clone(&self) -> ($($T,)+) { - ($(self.$get_ref_fn().clone(),)+) + impl<$($T),+> $immutable_trait<$($T),+> for ($($T,)+) { + $( + #[inline] + fn $get_ref_fn<'a>(&'a self) -> &'a $T { + let $ref_pattern = *self; + $ret } + )+ + } + + impl<$($T:Clone),+> Clone for ($($T,)+) { + fn clone(&self) -> ($($T,)+) { + ($(self.$get_ref_fn().clone(),)+) } + } - #[cfg(not(test))] - impl<$($T:Eq),+> Eq for ($($T,)+) { - #[inline] - fn eq(&self, other: &($($T,)+)) -> bool { - $(*self.$get_ref_fn() == *other.$get_ref_fn())&&+ - } - #[inline] - fn ne(&self, other: &($($T,)+)) -> bool { - $(*self.$get_ref_fn() != *other.$get_ref_fn())||+ - } + #[cfg(not(test))] + impl<$($T:Eq),+> Eq for ($($T,)+) { + #[inline] + fn eq(&self, other: &($($T,)+)) -> bool { + $(*self.$get_ref_fn() == *other.$get_ref_fn())&&+ + } + #[inline] + fn ne(&self, other: &($($T,)+)) -> bool { + $(*self.$get_ref_fn() != *other.$get_ref_fn())||+ } + } - #[cfg(not(test))] - impl<$($T:TotalEq),+> TotalEq for ($($T,)+) { - #[inline] - fn equals(&self, other: &($($T,)+)) -> bool { - $(self.$get_ref_fn().equals(other.$get_ref_fn()))&&+ - } + #[cfg(not(test))] + impl<$($T:TotalEq),+> TotalEq for ($($T,)+) { + #[inline] + fn equals(&self, other: &($($T,)+)) -> bool { + $(self.$get_ref_fn().equals(other.$get_ref_fn()))&&+ } + } - #[cfg(not(test))] - impl<$($T:Ord + Eq),+> Ord for ($($T,)+) { - #[inline] - fn lt(&self, other: &($($T,)+)) -> bool { - lexical_ord!(lt, $(self.$get_ref_fn(), other.$get_ref_fn()),+) - } - #[inline] - fn le(&self, other: &($($T,)+)) -> bool { - lexical_ord!(le, $(self.$get_ref_fn(), other.$get_ref_fn()),+) - } - #[inline] - fn ge(&self, other: &($($T,)+)) -> bool { - lexical_ord!(ge, $(self.$get_ref_fn(), other.$get_ref_fn()),+) - } - #[inline] - fn gt(&self, other: &($($T,)+)) -> bool { - lexical_ord!(gt, $(self.$get_ref_fn(), other.$get_ref_fn()),+) - } + #[cfg(not(test))] + impl<$($T:Ord + Eq),+> Ord for ($($T,)+) { + #[inline] + fn lt(&self, other: &($($T,)+)) -> bool { + lexical_ord!(lt, $(self.$get_ref_fn(), other.$get_ref_fn()),+) + } + #[inline] + fn le(&self, other: &($($T,)+)) -> bool { + lexical_ord!(le, $(self.$get_ref_fn(), other.$get_ref_fn()),+) + } + #[inline] + fn ge(&self, other: &($($T,)+)) -> bool { + lexical_ord!(ge, $(self.$get_ref_fn(), other.$get_ref_fn()),+) } + #[inline] + fn gt(&self, other: &($($T,)+)) -> bool { + lexical_ord!(gt, $(self.$get_ref_fn(), other.$get_ref_fn()),+) + } + } - #[cfg(not(test))] - impl<$($T:TotalOrd),+> TotalOrd for ($($T,)+) { - #[inline] - fn cmp(&self, other: &($($T,)+)) -> Ordering { - lexical_cmp!($(self.$get_ref_fn(), other.$get_ref_fn()),+) - } + #[cfg(not(test))] + impl<$($T:TotalOrd),+> TotalOrd for ($($T,)+) { + #[inline] + fn cmp(&self, other: &($($T,)+)) -> Ordering { + lexical_cmp!($(self.$get_ref_fn(), other.$get_ref_fn()),+) } + } - #[cfg(not(test))] - impl<$($T:Default),+> Default for ($($T,)+) { - #[inline] - fn default() -> ($($T,)+) { - ($({ let x: $T = Default::default(); x},)+) - } + #[cfg(not(test))] + impl<$($T:Default),+> Default for ($($T,)+) { + #[inline] + fn default() -> ($($T,)+) { + ($({ let x: $T = Default::default(); x},)+) } + } - #[cfg(not(test))] - impl<$($T:Zero),+> Zero for ($($T,)+) { - #[inline] - fn zero() -> ($($T,)+) { - ($({ let x: $T = Zero::zero(); x},)+) - } - #[inline] - fn is_zero(&self) -> bool { - $(self.$get_ref_fn().is_zero())&&+ - } + #[cfg(not(test))] + impl<$($T:Zero),+> Zero for ($($T,)+) { + #[inline] + fn zero() -> ($($T,)+) { + ($({ let x: $T = Zero::zero(); x},)+) } - )+ - } + #[inline] + fn is_zero(&self) -> bool { + $(self.$get_ref_fn().is_zero())&&+ + } + } + )+ } } diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs index e76251e8a1e72..293c9ed981728 100644 --- a/src/libstd/vec.rs +++ b/src/libstd/vec.rs @@ -2463,15 +2463,14 @@ impl Default for @[A] { } macro_rules! iterator { - /* FIXME: #4375 Cannot attach documentation/attributes to a macro generated struct. (struct $name:ident -> $ptr:ty, $elem:ty) => { + /// An iterator for iterating over a vector. pub struct $name<'self, T> { priv ptr: $ptr, priv end: $ptr, - priv lifetime: $elem // FIXME: #5922 + priv lifetime: Option<$elem> // FIXME: #5922 } - };*/ - (impl $name:ident -> $elem:ty) => { + impl<'self, T> Iterator<$elem> for $name<'self, T> { #[inline] fn next(&mut self) -> Option<$elem> { @@ -2502,11 +2501,7 @@ macro_rules! iterator { (exact, Some(exact)) } } - } -} -macro_rules! double_ended_iterator { - (impl $name:ident -> $elem:ty) => { impl<'self, T> DoubleEndedIterator<$elem> for $name<'self, T> { #[inline] fn next_back(&mut self) -> Option<$elem> { @@ -2548,15 +2543,7 @@ impl<'self, T> RandomAccessIterator<&'self T> for VecIterator<'self, T> { } } -//iterator!{struct VecIterator -> *T, &'self T} -/// An iterator for iterating over a vector. -pub struct VecIterator<'self, T> { - priv ptr: *T, - priv end: *T, - priv lifetime: Option<&'self ()> // FIXME: #5922 -} -iterator!{impl VecIterator -> &'self T} -double_ended_iterator!{impl VecIterator -> &'self T} +iterator!{struct VecIterator -> *T, &'self T} pub type RevIterator<'self, T> = Invert>; impl<'self, T> ExactSize<&'self T> for VecIterator<'self, T> {} @@ -2566,15 +2553,7 @@ impl<'self, T> Clone for VecIterator<'self, T> { fn clone(&self) -> VecIterator<'self, T> { *self } } -//iterator!{struct VecMutIterator -> *mut T, &'self mut T} -/// An iterator for mutating the elements of a vector. -pub struct VecMutIterator<'self, T> { - priv ptr: *mut T, - priv end: *mut T, - priv lifetime: Option<&'self mut ()> // FIXME: #5922 -} -iterator!{impl VecMutIterator -> &'self mut T} -double_ended_iterator!{impl VecMutIterator -> &'self mut T} +iterator!{struct VecMutIterator -> *mut T, &'self mut T} pub type MutRevIterator<'self, T> = Invert>; /// An iterator that moves out of a vector. From 0d8ace823b33489284cc60aaab3945d764ab3394 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marvin=20L=C3=B6bel?= Date: Fri, 29 Nov 2013 20:19:22 +0100 Subject: [PATCH 2/3] Removed useless cmp::{min, max} reexports from the integer modules --- src/librustc/middle/trans/foreign.rs | 25 ++++++++++++------------- src/libstd/fmt/mod.rs | 2 +- src/libstd/num/int_macros.rs | 2 -- src/libstd/num/uint_macros.rs | 2 -- src/libstd/rt/logging.rs | 3 +-- 5 files changed, 14 insertions(+), 20 deletions(-) diff --git a/src/librustc/middle/trans/foreign.rs b/src/librustc/middle/trans/foreign.rs index ac65719f02e86..2a0840a0ef8ad 100644 --- a/src/librustc/middle/trans/foreign.rs +++ b/src/librustc/middle/trans/foreign.rs @@ -10,32 +10,31 @@ use back::{link}; -use std::libc::c_uint; -use lib::llvm::{ValueRef, CallConv, StructRetAttribute}; use lib::llvm::llvm; +use lib::llvm::{ValueRef, CallConv, StructRetAttribute}; use lib; -use middle::trans::machine; -use middle::trans::base; use middle::trans::base::push_ctxt; -use middle::trans::cabi; +use middle::trans::base; use middle::trans::build::*; use middle::trans::builder::noname; +use middle::trans::cabi; use middle::trans::common::*; +use middle::trans::machine; +use middle::trans::type_::Type; use middle::trans::type_of::*; use middle::trans::type_of; -use middle::ty; use middle::ty::FnSig; - -use std::uint; +use middle::ty; +use std::cmp; +use std::libc::c_uint; use std::vec; +use syntax::abi::{Cdecl, Aapcs, C, AbiSet, Win64}; +use syntax::abi::{RustIntrinsic, Rust, Stdcall, Fastcall, System}; use syntax::codemap::Span; +use syntax::parse::token::special_idents; use syntax::{ast}; use syntax::{attr, ast_map}; -use syntax::parse::token::special_idents; -use syntax::abi::{RustIntrinsic, Rust, Stdcall, Fastcall, System, - Cdecl, Aapcs, C, AbiSet, Win64}; use util::ppaux::{Repr, UserString}; -use middle::trans::type_::Type; /////////////////////////////////////////////////////////////////////////// // Type definitions @@ -332,7 +331,7 @@ pub fn trans_native_call(bcx: @mut Block, let llrust_size = machine::llsize_of_store(ccx, llrust_ret_ty); let llforeign_align = machine::llalign_of_min(ccx, llforeign_ret_ty); let llrust_align = machine::llalign_of_min(ccx, llrust_ret_ty); - let llalign = uint::min(llforeign_align, llrust_align); + let llalign = cmp::min(llforeign_align, llrust_align); debug!("llrust_size={:?}", llrust_size); base::call_memcpy(bcx, llretptr_i8, llscratch_i8, C_uint(ccx, llrust_size), llalign as u32); diff --git a/src/libstd/fmt/mod.rs b/src/libstd/fmt/mod.rs index 2d37d82e172c6..c74a9bc905176 100644 --- a/src/libstd/fmt/mod.rs +++ b/src/libstd/fmt/mod.rs @@ -901,7 +901,7 @@ impl<'self> Formatter<'self> { // case where the maximum length will matter. let char_len = s.char_len(); if char_len >= max { - let nchars = ::uint::min(max, char_len); + let nchars = ::cmp::min(max, char_len); self.buf.write(s.slice_chars(0, nchars).as_bytes()); return } diff --git a/src/libstd/num/int_macros.rs b/src/libstd/num/int_macros.rs index 42f0ed95d1e0f..07893087628c1 100644 --- a/src/libstd/num/int_macros.rs +++ b/src/libstd/num/int_macros.rs @@ -25,8 +25,6 @@ use num::{CheckedDiv, Zero, One, strconv}; use prelude::*; use str; -pub use cmp::{min, max}; - pub static bits : uint = $bits; pub static bytes : uint = ($bits / 8); diff --git a/src/libstd/num/uint_macros.rs b/src/libstd/num/uint_macros.rs index 0a21aa9fcc8a8..31f1b75e02e82 100644 --- a/src/libstd/num/uint_macros.rs +++ b/src/libstd/num/uint_macros.rs @@ -26,8 +26,6 @@ use num::{CheckedDiv, Zero, One, strconv}; use prelude::*; use str; -pub use cmp::{min, max}; - pub static bits : uint = $bits; pub static bytes : uint = ($bits / 8); diff --git a/src/libstd/rt/logging.rs b/src/libstd/rt/logging.rs index 13e18f7d9b75e..3f169b511df9a 100644 --- a/src/libstd/rt/logging.rs +++ b/src/libstd/rt/logging.rs @@ -17,7 +17,6 @@ use io::stdio::StdWriter; use io::buffered::LineBufferedWriter; use rt::crate_map::{ModEntry, CrateMap, iter_crate_map, get_crate_map}; use str::StrSlice; -use u32; use vec::ImmutableVector; #[cfg(test)] use cast::transmute; @@ -46,7 +45,7 @@ fn parse_log_level(level: &str) -> Option { let position = log_level_names.iter().position(|&name| name == level); match position { Some(position) => { - log_level = Some(u32::min(MAX_LOG_LEVEL, (position + 1) as u32)) + log_level = Some(::cmp::min(MAX_LOG_LEVEL, (position + 1) as u32)) }, _ => { log_level = None; From 4840064f85a28c9332d928ad0631e9dc2d21e150 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marvin=20L=C3=B6bel?= Date: Fri, 29 Nov 2013 20:30:31 +0100 Subject: [PATCH 3/3] Removed module macro workaround for signed and unsigned integers --- src/libstd/num/i16.rs | 10 ++++++++-- src/libstd/num/i32.rs | 10 ++++++++-- src/libstd/num/i64.rs | 12 +++++++++--- src/libstd/num/i8.rs | 10 ++++++++-- src/libstd/num/int.rs | 14 ++++++++------ src/libstd/num/int_macros.rs | 16 ++-------------- src/libstd/num/u16.rs | 11 +++++++++-- src/libstd/num/u32.rs | 11 +++++++++-- src/libstd/num/u64.rs | 13 ++++++++++--- src/libstd/num/u8.rs | 11 +++++++++-- src/libstd/num/uint.rs | 15 +++++++++++---- src/libstd/num/uint_macros.rs | 17 ++--------------- 12 files changed, 93 insertions(+), 57 deletions(-) diff --git a/src/libstd/num/i16.rs b/src/libstd/num/i16.rs index 5c077c7e633d0..fcf1f24d0e455 100644 --- a/src/libstd/num/i16.rs +++ b/src/libstd/num/i16.rs @@ -10,12 +10,18 @@ //! Operations and constants for `i16` +#[allow(non_uppercase_statics)]; + +use prelude::*; + +use default::Default; use num::{BitCount, CheckedAdd, CheckedSub, CheckedMul}; +use num::{CheckedDiv, Zero, One, strconv}; +use num::{ToStrRadix, FromStrRadix}; use option::{Option, Some, None}; +use str; use unstable::intrinsics; -pub use self::generated::*; - int_module!(i16, 16) impl BitCount for i16 { diff --git a/src/libstd/num/i32.rs b/src/libstd/num/i32.rs index f076e33b3a218..385e1c91ca503 100644 --- a/src/libstd/num/i32.rs +++ b/src/libstd/num/i32.rs @@ -10,12 +10,18 @@ //! Operations and constants for `i32` +#[allow(non_uppercase_statics)]; + +use prelude::*; + +use default::Default; use num::{BitCount, CheckedAdd, CheckedSub, CheckedMul}; +use num::{CheckedDiv, Zero, One, strconv}; +use num::{ToStrRadix, FromStrRadix}; use option::{Option, Some, None}; +use str; use unstable::intrinsics; -pub use self::generated::*; - int_module!(i32, 32) impl BitCount for i32 { diff --git a/src/libstd/num/i64.rs b/src/libstd/num/i64.rs index d991bf0330034..f6b369b1312a5 100644 --- a/src/libstd/num/i64.rs +++ b/src/libstd/num/i64.rs @@ -10,14 +10,20 @@ //! Operations and constants for `i64` -use num::{BitCount, CheckedAdd, CheckedSub}; +#[allow(non_uppercase_statics)]; + +use prelude::*; + +use default::Default; #[cfg(target_word_size = "64")] use num::CheckedMul; +use num::{BitCount, CheckedAdd, CheckedSub}; +use num::{CheckedDiv, Zero, One, strconv}; +use num::{ToStrRadix, FromStrRadix}; use option::{Option, Some, None}; +use str; use unstable::intrinsics; -pub use self::generated::*; - int_module!(i64, 64) impl BitCount for i64 { diff --git a/src/libstd/num/i8.rs b/src/libstd/num/i8.rs index a807f6b9e53f3..9de90ca4657d1 100644 --- a/src/libstd/num/i8.rs +++ b/src/libstd/num/i8.rs @@ -10,12 +10,18 @@ //! Operations and constants for `i8` +#[allow(non_uppercase_statics)]; + +use prelude::*; + +use default::Default; use num::{BitCount, CheckedAdd, CheckedSub, CheckedMul}; +use num::{CheckedDiv, Zero, One, strconv}; +use num::{ToStrRadix, FromStrRadix}; use option::{Option, Some, None}; +use str; use unstable::intrinsics; -pub use self::generated::*; - int_module!(i8, 8) impl BitCount for i8 { diff --git a/src/libstd/num/int.rs b/src/libstd/num/int.rs index c5364fa3dab96..517bd45e45bd1 100644 --- a/src/libstd/num/int.rs +++ b/src/libstd/num/int.rs @@ -12,16 +12,18 @@ #[allow(non_uppercase_statics)]; +use prelude::*; + +use default::Default; use num::{BitCount, CheckedAdd, CheckedSub, CheckedMul}; +use num::{CheckedDiv, Zero, One, strconv}; +use num::{ToStrRadix, FromStrRadix}; use option::{Option, Some, None}; +use str; use unstable::intrinsics; -pub use self::generated::*; - -#[cfg(target_word_size = "32")] pub static bits: uint = 32; -#[cfg(target_word_size = "64")] pub static bits: uint = 64; - -int_module!(int, super::bits) +#[cfg(target_word_size = "32")] int_module!(int, 32) +#[cfg(target_word_size = "64")] int_module!(int, 64) #[cfg(target_word_size = "32")] impl BitCount for int { diff --git a/src/libstd/num/int_macros.rs b/src/libstd/num/int_macros.rs index 07893087628c1..8c60b0ec75a69 100644 --- a/src/libstd/num/int_macros.rs +++ b/src/libstd/num/int_macros.rs @@ -8,22 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// FIXME(#4375): This shouldn't have to be a nested module named 'generated'... -// FIXME(#10716): ... but now that we could solve that, the import lines and -// attributes still prevent a removal of that module. - #[macro_escape]; #[doc(hidden)]; -macro_rules! int_module (($T:ty, $bits:expr) => (mod generated { - -#[allow(non_uppercase_statics)]; - -use default::Default; -use num::{ToStrRadix, FromStrRadix}; -use num::{CheckedDiv, Zero, One, strconv}; -use prelude::*; -use str; +macro_rules! int_module (($T:ty, $bits:expr) => ( pub static bits : uint = $bits; pub static bytes : uint = ($bits / 8); @@ -781,4 +769,4 @@ mod tests { } } -})) +)) diff --git a/src/libstd/num/u16.rs b/src/libstd/num/u16.rs index e227947ca6e5f..ed8ec3b6c54b9 100644 --- a/src/libstd/num/u16.rs +++ b/src/libstd/num/u16.rs @@ -10,12 +10,19 @@ //! Operations and constants for `u16` +#[allow(non_uppercase_statics)]; + +use prelude::*; + +use default::Default; +use num::BitCount; use num::{CheckedAdd, CheckedSub, CheckedMul}; +use num::{CheckedDiv, Zero, One, strconv}; +use num::{ToStrRadix, FromStrRadix}; use option::{Option, Some, None}; +use str; use unstable::intrinsics; -pub use self::generated::*; - uint_module!(u16, i16, 16) impl CheckedAdd for u16 { diff --git a/src/libstd/num/u32.rs b/src/libstd/num/u32.rs index 4dbd543da7b0b..2977549803384 100644 --- a/src/libstd/num/u32.rs +++ b/src/libstd/num/u32.rs @@ -10,12 +10,19 @@ //! Operations and constants for `u32` +#[allow(non_uppercase_statics)]; + +use prelude::*; + +use default::Default; +use num::BitCount; use num::{CheckedAdd, CheckedSub, CheckedMul}; +use num::{CheckedDiv, Zero, One, strconv}; +use num::{ToStrRadix, FromStrRadix}; use option::{Option, Some, None}; +use str; use unstable::intrinsics; -pub use self::generated::*; - uint_module!(u32, i32, 32) impl CheckedAdd for u32 { diff --git a/src/libstd/num/u64.rs b/src/libstd/num/u64.rs index d3077333077d3..dc43801eb3958 100644 --- a/src/libstd/num/u64.rs +++ b/src/libstd/num/u64.rs @@ -10,14 +10,21 @@ //! Operations and constants for `u64` -use num::{CheckedAdd, CheckedSub}; +#[allow(non_uppercase_statics)]; + +use prelude::*; + +use default::Default; +use num::BitCount; #[cfg(target_word_size = "64")] use num::CheckedMul; +use num::{CheckedAdd, CheckedSub}; +use num::{CheckedDiv, Zero, One, strconv}; +use num::{ToStrRadix, FromStrRadix}; use option::{Option, Some, None}; +use str; use unstable::intrinsics; -pub use self::generated::*; - uint_module!(u64, i64, 64) impl CheckedAdd for u64 { diff --git a/src/libstd/num/u8.rs b/src/libstd/num/u8.rs index ca54af5cecc43..12ad4efdbd5d1 100644 --- a/src/libstd/num/u8.rs +++ b/src/libstd/num/u8.rs @@ -10,12 +10,19 @@ //! Operations and constants for `u8` +#[allow(non_uppercase_statics)]; + +use prelude::*; + +use default::Default; +use num::BitCount; use num::{CheckedAdd, CheckedSub, CheckedMul}; +use num::{CheckedDiv, Zero, One, strconv}; +use num::{ToStrRadix, FromStrRadix}; use option::{Option, Some, None}; +use str; use unstable::intrinsics; -pub use self::generated::*; - uint_module!(u8, i8, 8) impl CheckedAdd for u8 { diff --git a/src/libstd/num/uint.rs b/src/libstd/num/uint.rs index cf28083bb09b9..549490050c590 100644 --- a/src/libstd/num/uint.rs +++ b/src/libstd/num/uint.rs @@ -10,13 +10,20 @@ //! Operations and constants for `uint` -use num; +#[allow(non_uppercase_statics)]; + +use prelude::*; + +use default::Default; +use mem; +use num::BitCount; use num::{CheckedAdd, CheckedSub, CheckedMul}; +use num::{CheckedDiv, Zero, One, strconv}; +use num::{ToStrRadix, FromStrRadix}; +use num; use option::{Option, Some, None}; +use str; use unstable::intrinsics; -use mem; - -pub use self::generated::*; uint_module!(uint, int, ::int::bits) diff --git a/src/libstd/num/uint_macros.rs b/src/libstd/num/uint_macros.rs index 31f1b75e02e82..ee3cd6446089a 100644 --- a/src/libstd/num/uint_macros.rs +++ b/src/libstd/num/uint_macros.rs @@ -8,23 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// FIXME(#4375): This shouldn't have to be a nested module named 'generated'... -// FIXME(#10716): ... but now that we could solve that, the import lines and -// attributes still prevent a removal of that module. - #[macro_escape]; #[doc(hidden)]; -macro_rules! uint_module (($T:ty, $T_SIGNED:ty, $bits:expr) => (mod generated { - -#[allow(non_uppercase_statics)]; - -use default::Default; -use num::BitCount; -use num::{ToStrRadix, FromStrRadix}; -use num::{CheckedDiv, Zero, One, strconv}; -use prelude::*; -use str; +macro_rules! uint_module (($T:ty, $T_SIGNED:ty, $bits:expr) => ( pub static bits : uint = $bits; pub static bytes : uint = ($bits / 8); @@ -554,4 +541,4 @@ mod tests { } } -})) +))