Skip to content

Commit 80991bb

Browse files
committed
auto merge of #10719 : Kimundi/rust/switch_to_multi_item_macros, r=alexcrichton
- Removed module reexport workaround for the integer module macros - Removed legacy reexports of `cmp::{min, max}` in the integer module macros - Combined a few macros in `vec` into one - Documented a few issues
2 parents dd1184e + 4840064 commit 80991bb

File tree

19 files changed

+244
-256
lines changed

19 files changed

+244
-256
lines changed

src/librustc/middle/trans/foreign.rs

+12-13
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,31 @@
1010

1111

1212
use back::{link};
13-
use std::libc::c_uint;
14-
use lib::llvm::{ValueRef, CallConv, StructRetAttribute};
1513
use lib::llvm::llvm;
14+
use lib::llvm::{ValueRef, CallConv, StructRetAttribute};
1615
use lib;
17-
use middle::trans::machine;
18-
use middle::trans::base;
1916
use middle::trans::base::push_ctxt;
20-
use middle::trans::cabi;
17+
use middle::trans::base;
2118
use middle::trans::build::*;
2219
use middle::trans::builder::noname;
20+
use middle::trans::cabi;
2321
use middle::trans::common::*;
22+
use middle::trans::machine;
23+
use middle::trans::type_::Type;
2424
use middle::trans::type_of::*;
2525
use middle::trans::type_of;
26-
use middle::ty;
2726
use middle::ty::FnSig;
28-
29-
use std::uint;
27+
use middle::ty;
28+
use std::cmp;
29+
use std::libc::c_uint;
3030
use std::vec;
31+
use syntax::abi::{Cdecl, Aapcs, C, AbiSet, Win64};
32+
use syntax::abi::{RustIntrinsic, Rust, Stdcall, Fastcall, System};
3133
use syntax::codemap::Span;
34+
use syntax::parse::token::special_idents;
3235
use syntax::{ast};
3336
use syntax::{attr, ast_map};
34-
use syntax::parse::token::special_idents;
35-
use syntax::abi::{RustIntrinsic, Rust, Stdcall, Fastcall, System,
36-
Cdecl, Aapcs, C, AbiSet, Win64};
3737
use util::ppaux::{Repr, UserString};
38-
use middle::trans::type_::Type;
3938

4039
///////////////////////////////////////////////////////////////////////////
4140
// Type definitions
@@ -332,7 +331,7 @@ pub fn trans_native_call(bcx: @mut Block,
332331
let llrust_size = machine::llsize_of_store(ccx, llrust_ret_ty);
333332
let llforeign_align = machine::llalign_of_min(ccx, llforeign_ret_ty);
334333
let llrust_align = machine::llalign_of_min(ccx, llrust_ret_ty);
335-
let llalign = uint::min(llforeign_align, llrust_align);
334+
let llalign = cmp::min(llforeign_align, llrust_align);
336335
debug!("llrust_size={:?}", llrust_size);
337336
base::call_memcpy(bcx, llretptr_i8, llscratch_i8,
338337
C_uint(ccx, llrust_size), llalign as u32);

src/libstd/fmt/mod.rs

+18-23
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ impl<'self> Formatter<'self> {
901901
// case where the maximum length will matter.
902902
let char_len = s.char_len();
903903
if char_len >= max {
904-
let nchars = ::uint::min(max, char_len);
904+
let nchars = ::cmp::min(max, char_len);
905905
self.buf.write(s.slice_chars(0, nchars).as_bytes());
906906
return
907907
}
@@ -1036,31 +1036,26 @@ pub fn upperhex(buf: &[u8], f: &mut Formatter) {
10361036
f.pad_integral(local.slice_to(buf.len()), "0x", true);
10371037
}
10381038

1039-
// FIXME(#4375) shouldn't need an inner module
10401039
macro_rules! integer(($signed:ident, $unsigned:ident) => {
1041-
mod $signed {
1042-
use super::*;
1043-
1044-
// Signed is special because it actuall emits the negative sign,
1045-
// nothing else should do that, however.
1046-
impl Signed for $signed {
1047-
fn fmt(c: &$signed, f: &mut Formatter) {
1048-
::$unsigned::to_str_bytes(c.abs() as $unsigned, 10, |buf| {
1049-
f.pad_integral(buf, "", *c >= 0);
1050-
})
1051-
}
1040+
// Signed is special because it actuall emits the negative sign,
1041+
// nothing else should do that, however.
1042+
impl Signed for $signed {
1043+
fn fmt(c: &$signed, f: &mut Formatter) {
1044+
::$unsigned::to_str_bytes(c.abs() as $unsigned, 10, |buf| {
1045+
f.pad_integral(buf, "", *c >= 0);
1046+
})
10521047
}
1053-
int_base!($signed, $unsigned, 2, Binary, "0b")
1054-
int_base!($signed, $unsigned, 8, Octal, "0o")
1055-
int_base!($signed, $unsigned, 16, LowerHex, "0x")
1056-
upper_hex!($signed, $unsigned)
1057-
1058-
int_base!($unsigned, $unsigned, 2, Binary, "0b")
1059-
int_base!($unsigned, $unsigned, 8, Octal, "0o")
1060-
int_base!($unsigned, $unsigned, 10, Unsigned, "")
1061-
int_base!($unsigned, $unsigned, 16, LowerHex, "0x")
1062-
upper_hex!($unsigned, $unsigned)
10631048
}
1049+
int_base!($signed, $unsigned, 2, Binary, "0b")
1050+
int_base!($signed, $unsigned, 8, Octal, "0o")
1051+
int_base!($signed, $unsigned, 16, LowerHex, "0x")
1052+
upper_hex!($signed, $unsigned)
1053+
1054+
int_base!($unsigned, $unsigned, 2, Binary, "0b")
1055+
int_base!($unsigned, $unsigned, 8, Octal, "0o")
1056+
int_base!($unsigned, $unsigned, 10, Unsigned, "")
1057+
int_base!($unsigned, $unsigned, 16, LowerHex, "0x")
1058+
upper_hex!($unsigned, $unsigned)
10641059
})
10651060

10661061
integer!(int, uint)

src/libstd/num/f32.rs

+13-20
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,19 @@
1111
//! Operations and constants for `f32`
1212
#[allow(missing_doc)];
1313

14+
use prelude::*;
15+
16+
use cmath::c_float_utils;
1417
use default::Default;
15-
use libc::c_int;
16-
use num::{Zero, One, strconv};
18+
use libc::{c_float, c_int};
1719
use num::{FPCategory, FPNaN, FPInfinite , FPZero, FPSubnormal, FPNormal};
20+
use num::{Zero, One, strconv};
1821
use num;
19-
use prelude::*;
2022
use to_str;
23+
use unstable::intrinsics;
2124

2225
pub use cmath::c_float_targ_consts::*;
2326

24-
use self::delegated::*;
25-
2627
macro_rules! delegate(
2728
(
2829
$(
@@ -33,22 +34,14 @@ macro_rules! delegate(
3334
) -> $rv:ty = $bound_name:path
3435
),*
3536
) => (
36-
// An inner module is required to get the #[inline] attribute on the
37-
// functions.
38-
mod delegated {
39-
use cmath::c_float_utils;
40-
use libc::{c_float, c_int};
41-
use unstable::intrinsics;
42-
43-
$(
44-
#[inline]
45-
pub fn $name($( $arg : $arg_ty ),*) -> $rv {
46-
unsafe {
47-
$bound_name($( $arg ),*)
48-
}
37+
$(
38+
#[inline]
39+
pub fn $name($( $arg : $arg_ty ),*) -> $rv {
40+
unsafe {
41+
$bound_name($( $arg ),*)
4942
}
50-
)*
51-
}
43+
}
44+
)*
5245
)
5346
)
5447

src/libstd/num/f64.rs

+13-20
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,20 @@
1212
1313
#[allow(missing_doc)];
1414

15+
use prelude::*;
16+
17+
use cmath::c_double_utils;
1518
use default::Default;
16-
use libc::c_int;
17-
use num::{Zero, One, strconv};
19+
use libc::{c_double, c_int};
1820
use num::{FPCategory, FPNaN, FPInfinite , FPZero, FPSubnormal, FPNormal};
21+
use num::{Zero, One, strconv};
1922
use num;
20-
use prelude::*;
2123
use to_str;
24+
use unstable::intrinsics;
2225

2326
pub use cmath::c_double_targ_consts::*;
2427
pub use cmp::{min, max};
2528

26-
use self::delegated::*;
27-
2829
macro_rules! delegate(
2930
(
3031
$(
@@ -35,22 +36,14 @@ macro_rules! delegate(
3536
) -> $rv:ty = $bound_name:path
3637
),*
3738
) => (
38-
// An inner module is required to get the #[inline] attribute on the
39-
// functions.
40-
mod delegated {
41-
use cmath::c_double_utils;
42-
use libc::{c_double, c_int};
43-
use unstable::intrinsics;
44-
45-
$(
46-
#[inline]
47-
pub fn $name($( $arg : $arg_ty ),*) -> $rv {
48-
unsafe {
49-
$bound_name($( $arg ),*)
50-
}
39+
$(
40+
#[inline]
41+
pub fn $name($( $arg : $arg_ty ),*) -> $rv {
42+
unsafe {
43+
$bound_name($( $arg ),*)
5144
}
52-
)*
53-
}
45+
}
46+
)*
5447
)
5548
)
5649

src/libstd/num/i16.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,18 @@
1010

1111
//! Operations and constants for `i16`
1212
13+
#[allow(non_uppercase_statics)];
14+
15+
use prelude::*;
16+
17+
use default::Default;
1318
use num::{BitCount, CheckedAdd, CheckedSub, CheckedMul};
19+
use num::{CheckedDiv, Zero, One, strconv};
20+
use num::{ToStrRadix, FromStrRadix};
1421
use option::{Option, Some, None};
22+
use str;
1523
use unstable::intrinsics;
1624

17-
pub use self::generated::*;
18-
1925
int_module!(i16, 16)
2026

2127
impl BitCount for i16 {

src/libstd/num/i32.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,18 @@
1010

1111
//! Operations and constants for `i32`
1212
13+
#[allow(non_uppercase_statics)];
14+
15+
use prelude::*;
16+
17+
use default::Default;
1318
use num::{BitCount, CheckedAdd, CheckedSub, CheckedMul};
19+
use num::{CheckedDiv, Zero, One, strconv};
20+
use num::{ToStrRadix, FromStrRadix};
1421
use option::{Option, Some, None};
22+
use str;
1523
use unstable::intrinsics;
1624

17-
pub use self::generated::*;
18-
1925
int_module!(i32, 32)
2026

2127
impl BitCount for i32 {

src/libstd/num/i64.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,20 @@
1010

1111
//! Operations and constants for `i64`
1212
13-
use num::{BitCount, CheckedAdd, CheckedSub};
13+
#[allow(non_uppercase_statics)];
14+
15+
use prelude::*;
16+
17+
use default::Default;
1418
#[cfg(target_word_size = "64")]
1519
use num::CheckedMul;
20+
use num::{BitCount, CheckedAdd, CheckedSub};
21+
use num::{CheckedDiv, Zero, One, strconv};
22+
use num::{ToStrRadix, FromStrRadix};
1623
use option::{Option, Some, None};
24+
use str;
1725
use unstable::intrinsics;
1826

19-
pub use self::generated::*;
20-
2127
int_module!(i64, 64)
2228

2329
impl BitCount for i64 {

src/libstd/num/i8.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,18 @@
1010

1111
//! Operations and constants for `i8`
1212
13+
#[allow(non_uppercase_statics)];
14+
15+
use prelude::*;
16+
17+
use default::Default;
1318
use num::{BitCount, CheckedAdd, CheckedSub, CheckedMul};
19+
use num::{CheckedDiv, Zero, One, strconv};
20+
use num::{ToStrRadix, FromStrRadix};
1421
use option::{Option, Some, None};
22+
use str;
1523
use unstable::intrinsics;
1624

17-
pub use self::generated::*;
18-
1925
int_module!(i8, 8)
2026

2127
impl BitCount for i8 {

src/libstd/num/int.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,18 @@
1212
1313
#[allow(non_uppercase_statics)];
1414

15+
use prelude::*;
16+
17+
use default::Default;
1518
use num::{BitCount, CheckedAdd, CheckedSub, CheckedMul};
19+
use num::{CheckedDiv, Zero, One, strconv};
20+
use num::{ToStrRadix, FromStrRadix};
1621
use option::{Option, Some, None};
22+
use str;
1723
use unstable::intrinsics;
1824

19-
pub use self::generated::*;
20-
21-
#[cfg(target_word_size = "32")] pub static bits: uint = 32;
22-
#[cfg(target_word_size = "64")] pub static bits: uint = 64;
23-
24-
int_module!(int, super::bits)
25+
#[cfg(target_word_size = "32")] int_module!(int, 32)
26+
#[cfg(target_word_size = "64")] int_module!(int, 64)
2527

2628
#[cfg(target_word_size = "32")]
2729
impl BitCount for int {

src/libstd/num/int_macros.rs

+2-14
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,10 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// FIXME(#4375): this shouldn't have to be a nested module named 'generated'
12-
1311
#[macro_escape];
1412
#[doc(hidden)];
1513

16-
macro_rules! int_module (($T:ty, $bits:expr) => (mod generated {
17-
18-
#[allow(non_uppercase_statics)];
19-
20-
use default::Default;
21-
use num::{ToStrRadix, FromStrRadix};
22-
use num::{CheckedDiv, Zero, One, strconv};
23-
use prelude::*;
24-
use str;
25-
26-
pub use cmp::{min, max};
14+
macro_rules! int_module (($T:ty, $bits:expr) => (
2715

2816
pub static bits : uint = $bits;
2917
pub static bytes : uint = ($bits / 8);
@@ -781,4 +769,4 @@ mod tests {
781769
}
782770
}
783771

784-
}))
772+
))

src/libstd/num/u16.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,19 @@
1010

1111
//! Operations and constants for `u16`
1212
13+
#[allow(non_uppercase_statics)];
14+
15+
use prelude::*;
16+
17+
use default::Default;
18+
use num::BitCount;
1319
use num::{CheckedAdd, CheckedSub, CheckedMul};
20+
use num::{CheckedDiv, Zero, One, strconv};
21+
use num::{ToStrRadix, FromStrRadix};
1422
use option::{Option, Some, None};
23+
use str;
1524
use unstable::intrinsics;
1625

17-
pub use self::generated::*;
18-
1926
uint_module!(u16, i16, 16)
2027

2128
impl CheckedAdd for u16 {

0 commit comments

Comments
 (0)