Skip to content

Commit e2f8b51

Browse files
committed
auto merge of #6722 : alexcrichton/rust/issue-4219-no-merge-hack, r=brson
Changes the int/uint modules to all use macros instead of using the `merge` attribute. It would be nice to have #4375 resolved as well for this, but that can probably come at a later date. Closes #4219.
2 parents 2706271 + 03ae629 commit e2f8b51

24 files changed

+909
-1201
lines changed

src/libstd/core.rc

+18-28
Original file line numberDiff line numberDiff line change
@@ -88,34 +88,24 @@ pub mod prelude;
8888

8989
/* Primitive types */
9090

91-
#[path = "num/int-template.rs"] #[merge = "num/int-template/int.rs"]
92-
pub mod int;
93-
#[path = "num/int-template.rs"] #[merge = "num/int-template/i8.rs"]
94-
pub mod i8;
95-
#[path = "num/int-template.rs"] #[merge = "num/int-template/i16.rs"]
96-
pub mod i16;
97-
#[path = "num/int-template.rs"] #[merge = "num/int-template/i32.rs"]
98-
pub mod i32;
99-
#[path = "num/int-template.rs"] #[merge = "num/int-template/i64.rs"]
100-
pub mod i64;
101-
#[path = "num/uint-template.rs"] #[merge = "num/uint-template/uint.rs"]
102-
pub mod uint;
103-
104-
#[path = "num/uint-template.rs"] #[merge = "num/uint-template/u8.rs"]
105-
pub mod u8;
106-
#[path = "num/uint-template.rs"] #[merge = "num/uint-template/u16.rs"]
107-
pub mod u16;
108-
#[path = "num/uint-template.rs"] #[merge = "num/uint-template/u32.rs"]
109-
pub mod u32;
110-
#[path = "num/uint-template.rs"] #[merge = "num/uint-template/u64.rs"]
111-
pub mod u64;
112-
113-
#[path = "num/float.rs"]
114-
pub mod float;
115-
#[path = "num/f32.rs"]
116-
pub mod f32;
117-
#[path = "num/f64.rs"]
118-
pub mod f64;
91+
#[path = "num/int_macros.rs"] mod int_macros;
92+
#[path = "num/uint_macros.rs"] mod uint_macros;
93+
94+
#[path = "num/int.rs"] pub mod int;
95+
#[path = "num/i8.rs"] pub mod i8;
96+
#[path = "num/i16.rs"] pub mod i16;
97+
#[path = "num/i32.rs"] pub mod i32;
98+
#[path = "num/i64.rs"] pub mod i64;
99+
100+
#[path = "num/uint.rs"] pub mod uint;
101+
#[path = "num/u8.rs"] pub mod u8;
102+
#[path = "num/u16.rs"] pub mod u16;
103+
#[path = "num/u32.rs"] pub mod u32;
104+
#[path = "num/u64.rs"] pub mod u64;
105+
106+
#[path = "num/float.rs"] pub mod float;
107+
#[path = "num/f32.rs"] pub mod f32;
108+
#[path = "num/f64.rs"] pub mod f64;
119109

120110
pub mod nil;
121111
pub mod bool;

src/libstd/num/i16.rs

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
//! Operations and constants for `i16`
12+
13+
use num::BitCount;
14+
use unstable::intrinsics;
15+
16+
pub use self::generated::*;
17+
18+
int_module!(i16, 16)
19+
20+
impl BitCount for i16 {
21+
/// Counts the number of bits set. Wraps LLVM's `ctpop` intrinsic.
22+
#[inline(always)]
23+
fn population_count(&self) -> i16 { unsafe { intrinsics::ctpop16(*self) } }
24+
25+
/// Counts the number of leading zeros. Wraps LLVM's `ctlz` intrinsic.
26+
#[inline(always)]
27+
fn leading_zeros(&self) -> i16 { unsafe { intrinsics::ctlz16(*self) } }
28+
29+
/// Counts the number of trailing zeros. Wraps LLVM's `cttz` intrinsic.
30+
#[inline(always)]
31+
fn trailing_zeros(&self) -> i16 { unsafe { intrinsics::cttz16(*self) } }
32+
}

src/libstd/num/i32.rs

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
//! Operations and constants for `i32`
12+
13+
use num::BitCount;
14+
use unstable::intrinsics;
15+
16+
pub use self::generated::*;
17+
18+
int_module!(i32, 32)
19+
20+
impl BitCount for i32 {
21+
/// Counts the number of bits set. Wraps LLVM's `ctpop` intrinsic.
22+
#[inline(always)]
23+
fn population_count(&self) -> i32 { unsafe { intrinsics::ctpop32(*self) } }
24+
25+
/// Counts the number of leading zeros. Wraps LLVM's `ctlz` intrinsic.
26+
#[inline(always)]
27+
fn leading_zeros(&self) -> i32 { unsafe { intrinsics::ctlz32(*self) } }
28+
29+
/// Counts the number of trailing zeros. Wraps LLVM's `cttz` intrinsic.
30+
#[inline(always)]
31+
fn trailing_zeros(&self) -> i32 { unsafe { intrinsics::cttz32(*self) } }
32+
}

src/libstd/num/i64.rs

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
//! Operations and constants for `i64`
12+
13+
use num::BitCount;
14+
use unstable::intrinsics;
15+
16+
pub use self::generated::*;
17+
18+
int_module!(i64, 64)
19+
20+
impl BitCount for i64 {
21+
/// Counts the number of bits set. Wraps LLVM's `ctpop` intrinsic.
22+
#[inline(always)]
23+
fn population_count(&self) -> i64 { unsafe { intrinsics::ctpop64(*self) } }
24+
25+
/// Counts the number of leading zeros. Wraps LLVM's `ctlz` intrinsic.
26+
#[inline(always)]
27+
fn leading_zeros(&self) -> i64 { unsafe { intrinsics::ctlz64(*self) } }
28+
29+
/// Counts the number of trailing zeros. Wraps LLVM's `cttz` intrinsic.
30+
#[inline(always)]
31+
fn trailing_zeros(&self) -> i64 { unsafe { intrinsics::cttz64(*self) } }
32+
}

src/libstd/num/i8.rs

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
//! Operations and constants for `i8`
12+
13+
use num::BitCount;
14+
use unstable::intrinsics;
15+
16+
pub use self::generated::*;
17+
18+
int_module!(i8, 8)
19+
20+
impl BitCount for i8 {
21+
/// Counts the number of bits set. Wraps LLVM's `ctpop` intrinsic.
22+
#[inline(always)]
23+
fn population_count(&self) -> i8 { unsafe { intrinsics::ctpop8(*self) } }
24+
25+
/// Counts the number of leading zeros. Wraps LLVM's `ctlz` intrinsic.
26+
#[inline(always)]
27+
fn leading_zeros(&self) -> i8 { unsafe { intrinsics::ctlz8(*self) } }
28+
29+
/// Counts the number of trailing zeros. Wraps LLVM's `cttz` intrinsic.
30+
#[inline(always)]
31+
fn trailing_zeros(&self) -> i8 { unsafe { intrinsics::cttz8(*self) } }
32+
}

src/libstd/num/int-template/i16.rs

-41
This file was deleted.

src/libstd/num/int-template/i32.rs

-41
This file was deleted.

src/libstd/num/int-template/i64.rs

-41
This file was deleted.

src/libstd/num/int-template/i8.rs

-41
This file was deleted.

0 commit comments

Comments
 (0)