Skip to content

Commit 5dbd691

Browse files
committed
Rename the internal unsigned_abs to avoid upstream
Rust is adding inherent `unsigned_abs` methods, which raises a forward- compatibility warning against the use of our internal trait-method by the same name. The inherent methods will take precedence eventually, but that will be fine since they do the same thing. Still, the warning is annoying, so rename ours to `uabs` just to avoid that.
1 parent 7562ab2 commit 5dbd691

File tree

1 file changed

+42
-41
lines changed

1 file changed

+42
-41
lines changed

src/bigint.rs

Lines changed: 42 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,8 @@ pow_impl!(BigUint);
991991
trait UnsignedAbs {
992992
type Unsigned;
993993
/// A convenience method for getting the absolute value of a signed primitive as unsigned
994-
fn unsigned_abs(self) -> Self::Unsigned;
994+
/// See also `unsigned_abs`: https://github.com/rust-lang/rust/issues/74913
995+
fn uabs(self) -> Self::Unsigned;
995996
}
996997

997998
macro_rules! impl_unsigned_abs {
@@ -1000,7 +1001,7 @@ macro_rules! impl_unsigned_abs {
10001001
type Unsigned = $Unsigned;
10011002

10021003
#[inline]
1003-
fn unsigned_abs(self) -> $Unsigned {
1004+
fn uabs(self) -> $Unsigned {
10041005
self.wrapping_abs() as $Unsigned
10051006
}
10061007
}
@@ -1177,7 +1178,7 @@ impl Add<i32> for BigInt {
11771178
if other >= 0 {
11781179
self + other as u32
11791180
} else {
1180-
self - other.unsigned_abs()
1181+
self - other.uabs()
11811182
}
11821183
}
11831184
}
@@ -1187,7 +1188,7 @@ impl AddAssign<i32> for BigInt {
11871188
if other >= 0 {
11881189
*self += other as u32;
11891190
} else {
1190-
*self -= other.unsigned_abs();
1191+
*self -= other.uabs();
11911192
}
11921193
}
11931194
}
@@ -1200,7 +1201,7 @@ impl Add<i64> for BigInt {
12001201
if other >= 0 {
12011202
self + other as u64
12021203
} else {
1203-
self - other.unsigned_abs()
1204+
self - other.uabs()
12041205
}
12051206
}
12061207
}
@@ -1210,7 +1211,7 @@ impl AddAssign<i64> for BigInt {
12101211
if other >= 0 {
12111212
*self += other as u64;
12121213
} else {
1213-
*self -= other.unsigned_abs();
1214+
*self -= other.uabs();
12141215
}
12151216
}
12161217
}
@@ -1223,7 +1224,7 @@ impl Add<i128> for BigInt {
12231224
if other >= 0 {
12241225
self + other as u128
12251226
} else {
1226-
self - other.unsigned_abs()
1227+
self - other.uabs()
12271228
}
12281229
}
12291230
}
@@ -1233,7 +1234,7 @@ impl AddAssign<i128> for BigInt {
12331234
if other >= 0 {
12341235
*self += other as u128;
12351236
} else {
1236-
*self -= other.unsigned_abs();
1237+
*self -= other.uabs();
12371238
}
12381239
}
12391240
}
@@ -1429,7 +1430,7 @@ impl Sub<i32> for BigInt {
14291430
if other >= 0 {
14301431
self - other as u32
14311432
} else {
1432-
self + other.unsigned_abs()
1433+
self + other.uabs()
14331434
}
14341435
}
14351436
}
@@ -1439,7 +1440,7 @@ impl SubAssign<i32> for BigInt {
14391440
if other >= 0 {
14401441
*self -= other as u32;
14411442
} else {
1442-
*self += other.unsigned_abs();
1443+
*self += other.uabs();
14431444
}
14441445
}
14451446
}
@@ -1452,7 +1453,7 @@ impl Sub<BigInt> for i32 {
14521453
if self >= 0 {
14531454
self as u32 - other
14541455
} else {
1455-
-other - self.unsigned_abs()
1456+
-other - self.uabs()
14561457
}
14571458
}
14581459
}
@@ -1465,7 +1466,7 @@ impl Sub<i64> for BigInt {
14651466
if other >= 0 {
14661467
self - other as u64
14671468
} else {
1468-
self + other.unsigned_abs()
1469+
self + other.uabs()
14691470
}
14701471
}
14711472
}
@@ -1475,7 +1476,7 @@ impl SubAssign<i64> for BigInt {
14751476
if other >= 0 {
14761477
*self -= other as u64;
14771478
} else {
1478-
*self += other.unsigned_abs();
1479+
*self += other.uabs();
14791480
}
14801481
}
14811482
}
@@ -1488,7 +1489,7 @@ impl Sub<BigInt> for i64 {
14881489
if self >= 0 {
14891490
self as u64 - other
14901491
} else {
1491-
-other - self.unsigned_abs()
1492+
-other - self.uabs()
14921493
}
14931494
}
14941495
}
@@ -1501,7 +1502,7 @@ impl Sub<i128> for BigInt {
15011502
if other >= 0 {
15021503
self - other as u128
15031504
} else {
1504-
self + other.unsigned_abs()
1505+
self + other.uabs()
15051506
}
15061507
}
15071508
}
@@ -1512,7 +1513,7 @@ impl SubAssign<i128> for BigInt {
15121513
if other >= 0 {
15131514
*self -= other as u128;
15141515
} else {
1515-
*self += other.unsigned_abs();
1516+
*self += other.uabs();
15161517
}
15171518
}
15181519
}
@@ -1525,7 +1526,7 @@ impl Sub<BigInt> for i128 {
15251526
if self >= 0 {
15261527
self as u128 - other
15271528
} else {
1528-
-other - self.unsigned_abs()
1529+
-other - self.uabs()
15291530
}
15301531
}
15311532
}
@@ -1624,7 +1625,7 @@ impl Mul<i32> for BigInt {
16241625
if other >= 0 {
16251626
self * other as u32
16261627
} else {
1627-
-(self * other.unsigned_abs())
1628+
-(self * other.uabs())
16281629
}
16291630
}
16301631
}
@@ -1636,7 +1637,7 @@ impl MulAssign<i32> for BigInt {
16361637
*self *= other as u32;
16371638
} else {
16381639
self.sign = -self.sign;
1639-
*self *= other.unsigned_abs();
1640+
*self *= other.uabs();
16401641
}
16411642
}
16421643
}
@@ -1649,7 +1650,7 @@ impl Mul<i64> for BigInt {
16491650
if other >= 0 {
16501651
self * other as u64
16511652
} else {
1652-
-(self * other.unsigned_abs())
1653+
-(self * other.uabs())
16531654
}
16541655
}
16551656
}
@@ -1661,7 +1662,7 @@ impl MulAssign<i64> for BigInt {
16611662
*self *= other as u64;
16621663
} else {
16631664
self.sign = -self.sign;
1664-
*self *= other.unsigned_abs();
1665+
*self *= other.uabs();
16651666
}
16661667
}
16671668
}
@@ -1674,7 +1675,7 @@ impl Mul<i128> for BigInt {
16741675
if other >= 0 {
16751676
self * other as u128
16761677
} else {
1677-
-(self * other.unsigned_abs())
1678+
-(self * other.uabs())
16781679
}
16791680
}
16801681
}
@@ -1686,7 +1687,7 @@ impl MulAssign<i128> for BigInt {
16861687
*self *= other as u128;
16871688
} else {
16881689
self.sign = -self.sign;
1689-
*self *= other.unsigned_abs();
1690+
*self *= other.uabs();
16901691
}
16911692
}
16921693
}
@@ -1813,7 +1814,7 @@ impl Div<i32> for BigInt {
18131814
if other >= 0 {
18141815
self / other as u32
18151816
} else {
1816-
-(self / other.unsigned_abs())
1817+
-(self / other.uabs())
18171818
}
18181819
}
18191820
}
@@ -1825,7 +1826,7 @@ impl DivAssign<i32> for BigInt {
18251826
*self /= other as u32;
18261827
} else {
18271828
self.sign = -self.sign;
1828-
*self /= other.unsigned_abs();
1829+
*self /= other.uabs();
18291830
}
18301831
}
18311832
}
@@ -1838,7 +1839,7 @@ impl Div<BigInt> for i32 {
18381839
if self >= 0 {
18391840
self as u32 / other
18401841
} else {
1841-
-(self.unsigned_abs() / other)
1842+
-(self.uabs() / other)
18421843
}
18431844
}
18441845
}
@@ -1851,7 +1852,7 @@ impl Div<i64> for BigInt {
18511852
if other >= 0 {
18521853
self / other as u64
18531854
} else {
1854-
-(self / other.unsigned_abs())
1855+
-(self / other.uabs())
18551856
}
18561857
}
18571858
}
@@ -1863,7 +1864,7 @@ impl DivAssign<i64> for BigInt {
18631864
*self /= other as u64;
18641865
} else {
18651866
self.sign = -self.sign;
1866-
*self /= other.unsigned_abs();
1867+
*self /= other.uabs();
18671868
}
18681869
}
18691870
}
@@ -1876,7 +1877,7 @@ impl Div<BigInt> for i64 {
18761877
if self >= 0 {
18771878
self as u64 / other
18781879
} else {
1879-
-(self.unsigned_abs() / other)
1880+
-(self.uabs() / other)
18801881
}
18811882
}
18821883
}
@@ -1889,7 +1890,7 @@ impl Div<i128> for BigInt {
18891890
if other >= 0 {
18901891
self / other as u128
18911892
} else {
1892-
-(self / other.unsigned_abs())
1893+
-(self / other.uabs())
18931894
}
18941895
}
18951896
}
@@ -1901,7 +1902,7 @@ impl DivAssign<i128> for BigInt {
19011902
*self /= other as u128;
19021903
} else {
19031904
self.sign = -self.sign;
1904-
*self /= other.unsigned_abs();
1905+
*self /= other.uabs();
19051906
}
19061907
}
19071908
}
@@ -1914,7 +1915,7 @@ impl Div<BigInt> for i128 {
19141915
if self >= 0 {
19151916
self as u128 / other
19161917
} else {
1917-
-(self.unsigned_abs() / other)
1918+
-(self.uabs() / other)
19181919
}
19191920
}
19201921
}
@@ -2047,7 +2048,7 @@ impl Rem<i32> for BigInt {
20472048
if other >= 0 {
20482049
self % other as u32
20492050
} else {
2050-
self % other.unsigned_abs()
2051+
self % other.uabs()
20512052
}
20522053
}
20532054
}
@@ -2058,7 +2059,7 @@ impl RemAssign<i32> for BigInt {
20582059
if other >= 0 {
20592060
*self %= other as u32;
20602061
} else {
2061-
*self %= other.unsigned_abs();
2062+
*self %= other.uabs();
20622063
}
20632064
}
20642065
}
@@ -2071,7 +2072,7 @@ impl Rem<BigInt> for i32 {
20712072
if self >= 0 {
20722073
self as u32 % other
20732074
} else {
2074-
-(self.unsigned_abs() % other)
2075+
-(self.uabs() % other)
20752076
}
20762077
}
20772078
}
@@ -2084,7 +2085,7 @@ impl Rem<i64> for BigInt {
20842085
if other >= 0 {
20852086
self % other as u64
20862087
} else {
2087-
self % other.unsigned_abs()
2088+
self % other.uabs()
20882089
}
20892090
}
20902091
}
@@ -2095,7 +2096,7 @@ impl RemAssign<i64> for BigInt {
20952096
if other >= 0 {
20962097
*self %= other as u64;
20972098
} else {
2098-
*self %= other.unsigned_abs();
2099+
*self %= other.uabs();
20992100
}
21002101
}
21012102
}
@@ -2108,7 +2109,7 @@ impl Rem<BigInt> for i64 {
21082109
if self >= 0 {
21092110
self as u64 % other
21102111
} else {
2111-
-(self.unsigned_abs() % other)
2112+
-(self.uabs() % other)
21122113
}
21132114
}
21142115
}
@@ -2121,7 +2122,7 @@ impl Rem<i128> for BigInt {
21212122
if other >= 0 {
21222123
self % other as u128
21232124
} else {
2124-
self % other.unsigned_abs()
2125+
self % other.uabs()
21252126
}
21262127
}
21272128
}
@@ -2132,7 +2133,7 @@ impl RemAssign<i128> for BigInt {
21322133
if other >= 0 {
21332134
*self %= other as u128;
21342135
} else {
2135-
*self %= other.unsigned_abs();
2136+
*self %= other.uabs();
21362137
}
21372138
}
21382139
}
@@ -2145,7 +2146,7 @@ impl Rem<BigInt> for i128 {
21452146
if self >= 0 {
21462147
self as u128 % other
21472148
} else {
2148-
-(self.unsigned_abs() % other)
2149+
-(self.uabs() % other)
21492150
}
21502151
}
21512152
}

0 commit comments

Comments
 (0)