Skip to content

Commit 0633d73

Browse files
committed
Auto merge of #215 - alexcrichton:fix-ci, r=alexcrichton
Fix nightly CI Currently we're getting lots of errors about duplicate lang items so deal with this by `#[cfg_attr]`'ing off the lang item attribute in tests.
2 parents 200c94e + a6f7dfd commit 0633d73

File tree

6 files changed

+127
-103
lines changed

6 files changed

+127
-103
lines changed

src/int/addsub.rs

+41-39
Original file line numberDiff line numberDiff line change
@@ -79,44 +79,46 @@ trait Subo: AddSub
7979
impl Subo for i128 {}
8080
impl Subo for u128 {}
8181

82-
#[cfg_attr(not(stage0), lang = "i128_add")]
83-
pub fn rust_i128_add(a: i128, b: i128) -> i128 {
84-
rust_u128_add(a as _, b as _) as _
85-
}
86-
#[cfg_attr(not(stage0), lang = "i128_addo")]
87-
pub fn rust_i128_addo(a: i128, b: i128) -> (i128, bool) {
88-
let mut oflow = 0;
89-
let r = a.addo(b, &mut oflow);
90-
(r, oflow != 0)
91-
}
92-
#[cfg_attr(not(stage0), lang = "u128_add")]
93-
pub fn rust_u128_add(a: u128, b: u128) -> u128 {
94-
a.add(b)
95-
}
96-
#[cfg_attr(not(stage0), lang = "u128_addo")]
97-
pub fn rust_u128_addo(a: u128, b: u128) -> (u128, bool) {
98-
let mut oflow = 0;
99-
let r = a.addo(b, &mut oflow);
100-
(r, oflow != 0)
101-
}
82+
u128_lang_items! {
83+
#[lang = "i128_add"]
84+
pub fn rust_i128_add(a: i128, b: i128) -> i128 {
85+
rust_u128_add(a as _, b as _) as _
86+
}
87+
#[lang = "i128_addo"]
88+
pub fn rust_i128_addo(a: i128, b: i128) -> (i128, bool) {
89+
let mut oflow = 0;
90+
let r = a.addo(b, &mut oflow);
91+
(r, oflow != 0)
92+
}
93+
#[lang = "u128_add"]
94+
pub fn rust_u128_add(a: u128, b: u128) -> u128 {
95+
a.add(b)
96+
}
97+
#[lang = "u128_addo"]
98+
pub fn rust_u128_addo(a: u128, b: u128) -> (u128, bool) {
99+
let mut oflow = 0;
100+
let r = a.addo(b, &mut oflow);
101+
(r, oflow != 0)
102+
}
102103

103-
#[cfg_attr(not(stage0), lang = "i128_sub")]
104-
pub fn rust_i128_sub(a: i128, b: i128) -> i128 {
105-
rust_u128_sub(a as _, b as _) as _
106-
}
107-
#[cfg_attr(not(stage0), lang = "i128_subo")]
108-
pub fn rust_i128_subo(a: i128, b: i128) -> (i128, bool) {
109-
let mut oflow = 0;
110-
let r = a.subo(b, &mut oflow);
111-
(r, oflow != 0)
112-
}
113-
#[cfg_attr(not(stage0), lang = "u128_sub")]
114-
pub fn rust_u128_sub(a: u128, b: u128) -> u128 {
115-
a.sub(b)
116-
}
117-
#[cfg_attr(not(stage0), lang = "u128_subo")]
118-
pub fn rust_u128_subo(a: u128, b: u128) -> (u128, bool) {
119-
let mut oflow = 0;
120-
let r = a.subo(b, &mut oflow);
121-
(r, oflow != 0)
104+
#[lang = "i128_sub"]
105+
pub fn rust_i128_sub(a: i128, b: i128) -> i128 {
106+
rust_u128_sub(a as _, b as _) as _
107+
}
108+
#[lang = "i128_subo"]
109+
pub fn rust_i128_subo(a: i128, b: i128) -> (i128, bool) {
110+
let mut oflow = 0;
111+
let r = a.subo(b, &mut oflow);
112+
(r, oflow != 0)
113+
}
114+
#[lang = "u128_sub"]
115+
pub fn rust_u128_sub(a: u128, b: u128) -> u128 {
116+
a.sub(b)
117+
}
118+
#[lang = "u128_subo"]
119+
pub fn rust_u128_subo(a: u128, b: u128) -> (u128, bool) {
120+
let mut oflow = 0;
121+
let r = a.subo(b, &mut oflow);
122+
(r, oflow != 0)
123+
}
122124
}

src/int/mul.rs

+21-19
Original file line numberDiff line numberDiff line change
@@ -108,23 +108,25 @@ intrinsics! {
108108
}
109109
}
110110

111-
#[cfg_attr(not(stage0), lang = "i128_mul")]
112-
pub fn rust_i128_mul(a: i128, b: i128) -> i128 {
113-
__multi3(a, b)
114-
}
115-
#[cfg_attr(not(stage0), lang = "i128_mulo")]
116-
pub fn rust_i128_mulo(a: i128, b: i128) -> (i128, bool) {
117-
let mut oflow = 0;
118-
let r = __muloti4(a, b, &mut oflow);
119-
(r, oflow != 0)
120-
}
121-
#[cfg_attr(not(stage0), lang = "u128_mul")]
122-
pub fn rust_u128_mul(a: u128, b: u128) -> u128 {
123-
__multi3(a as _, b as _) as _
124-
}
125-
#[cfg_attr(not(stage0), lang = "u128_mulo")]
126-
pub fn rust_u128_mulo(a: u128, b: u128) -> (u128, bool) {
127-
let mut oflow = 0;
128-
let r = a.mulo(b, &mut oflow);
129-
(r, oflow != 0)
111+
u128_lang_items! {
112+
#[lang = "i128_mul"]
113+
pub fn rust_i128_mul(a: i128, b: i128) -> i128 {
114+
__multi3(a, b)
115+
}
116+
#[lang = "i128_mulo"]
117+
pub fn rust_i128_mulo(a: i128, b: i128) -> (i128, bool) {
118+
let mut oflow = 0;
119+
let r = __muloti4(a, b, &mut oflow);
120+
(r, oflow != 0)
121+
}
122+
#[lang = "u128_mul"]
123+
pub fn rust_u128_mul(a: u128, b: u128) -> u128 {
124+
__multi3(a as _, b as _) as _
125+
}
126+
#[lang = "u128_mulo"]
127+
pub fn rust_u128_mulo(a: u128, b: u128) -> (u128, bool) {
128+
let mut oflow = 0;
129+
let r = a.mulo(b, &mut oflow);
130+
(r, oflow != 0)
131+
}
130132
}

src/int/sdiv.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,13 @@ intrinsics! {
9898
}
9999
}
100100

101-
#[cfg_attr(not(stage0), lang = "i128_div")]
102-
pub fn rust_i128_div(a: i128, b: i128) -> i128 {
103-
__divti3(a, b)
104-
}
105-
#[cfg_attr(not(stage0), lang = "i128_rem")]
106-
pub fn rust_i128_rem(a: i128, b: i128) -> i128 {
107-
__modti3(a, b)
101+
u128_lang_items! {
102+
#[lang = "i128_div"]
103+
pub fn rust_i128_div(a: i128, b: i128) -> i128 {
104+
__divti3(a, b)
105+
}
106+
#[lang = "i128_rem"]
107+
pub fn rust_i128_rem(a: i128, b: i128) -> i128 {
108+
__modti3(a, b)
109+
}
108110
}

src/int/shift.rs

+33-31
Original file line numberDiff line numberDiff line change
@@ -96,36 +96,38 @@ intrinsics! {
9696
}
9797
}
9898

99-
#[cfg_attr(not(stage0), lang = "i128_shl")]
100-
pub fn rust_i128_shl(a: i128, b: u32) -> i128 {
101-
__ashlti3(a as _, b) as _
102-
}
103-
#[cfg_attr(not(stage0), lang = "i128_shlo")]
104-
pub fn rust_i128_shlo(a: i128, b: u128) -> (i128, bool) {
105-
(rust_i128_shl(a, b as _), b >= 128)
106-
}
107-
#[cfg_attr(not(stage0), lang = "u128_shl")]
108-
pub fn rust_u128_shl(a: u128, b: u32) -> u128 {
109-
__ashlti3(a, b)
110-
}
111-
#[cfg_attr(not(stage0), lang = "u128_shlo")]
112-
pub fn rust_u128_shlo(a: u128, b: u128) -> (u128, bool) {
113-
(rust_u128_shl(a, b as _), b >= 128)
114-
}
99+
u128_lang_items! {
100+
#[lang = "i128_shl"]
101+
pub fn rust_i128_shl(a: i128, b: u32) -> i128 {
102+
__ashlti3(a as _, b) as _
103+
}
104+
#[lang = "i128_shlo"]
105+
pub fn rust_i128_shlo(a: i128, b: u128) -> (i128, bool) {
106+
(rust_i128_shl(a, b as _), b >= 128)
107+
}
108+
#[lang = "u128_shl"]
109+
pub fn rust_u128_shl(a: u128, b: u32) -> u128 {
110+
__ashlti3(a, b)
111+
}
112+
#[lang = "u128_shlo"]
113+
pub fn rust_u128_shlo(a: u128, b: u128) -> (u128, bool) {
114+
(rust_u128_shl(a, b as _), b >= 128)
115+
}
115116

116-
#[cfg_attr(not(stage0), lang = "i128_shr")]
117-
pub fn rust_i128_shr(a: i128, b: u32) -> i128 {
118-
__ashrti3(a, b)
119-
}
120-
#[cfg_attr(not(stage0), lang = "i128_shro")]
121-
pub fn rust_i128_shro(a: i128, b: u128) -> (i128, bool) {
122-
(rust_i128_shr(a, b as _), b >= 128)
123-
}
124-
#[cfg_attr(not(stage0), lang = "u128_shr")]
125-
pub fn rust_u128_shr(a: u128, b: u32) -> u128 {
126-
__lshrti3(a, b)
127-
}
128-
#[cfg_attr(not(stage0), lang = "u128_shro")]
129-
pub fn rust_u128_shro(a: u128, b: u128) -> (u128, bool) {
130-
(rust_u128_shr(a, b as _), b >= 128)
117+
#[lang = "i128_shr"]
118+
pub fn rust_i128_shr(a: i128, b: u32) -> i128 {
119+
__ashrti3(a, b)
120+
}
121+
#[lang = "i128_shro"]
122+
pub fn rust_i128_shro(a: i128, b: u128) -> (i128, bool) {
123+
(rust_i128_shr(a, b as _), b >= 128)
124+
}
125+
#[lang = "u128_shr"]
126+
pub fn rust_u128_shr(a: u128, b: u32) -> u128 {
127+
__lshrti3(a, b)
128+
}
129+
#[lang = "u128_shro"]
130+
pub fn rust_u128_shro(a: u128, b: u128) -> (u128, bool) {
131+
(rust_u128_shr(a, b as _), b >= 128)
132+
}
131133
}

src/int/udiv.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -270,11 +270,13 @@ intrinsics! {
270270
}
271271
}
272272

273-
#[cfg_attr(not(stage0), lang = "u128_div")]
274-
pub fn rust_u128_div(a: u128, b: u128) -> u128 {
275-
__udivti3(a, b)
276-
}
277-
#[cfg_attr(not(stage0), lang = "u128_rem")]
278-
pub fn rust_u128_rem(a: u128, b: u128) -> u128 {
279-
__umodti3(a, b)
273+
u128_lang_items! {
274+
#[lang = "u128_div"]
275+
pub fn rust_u128_div(a: u128, b: u128) -> u128 {
276+
__udivti3(a, b)
277+
}
278+
#[lang = "u128_rem"]
279+
pub fn rust_u128_rem(a: u128, b: u128) -> u128 {
280+
__umodti3(a, b)
281+
}
280282
}

src/macros.rs

+14
Original file line numberDiff line numberDiff line change
@@ -280,3 +280,17 @@ pub mod win64_128bit_abi_hack {
280280
}
281281
}
282282
}
283+
284+
macro_rules! u128_lang_items {
285+
($(
286+
#[lang = $lang:tt]
287+
pub fn $name:ident( $($argname:ident: $ty:ty),* ) -> $ret:ty {
288+
$($body:tt)*
289+
}
290+
)*) => ($(
291+
#[cfg_attr(not(any(stage0, feature = "gen-tests")), lang = $lang)]
292+
pub fn $name( $($argname: $ty),* ) -> $ret {
293+
$($body)*
294+
}
295+
)*)
296+
}

0 commit comments

Comments
 (0)