Skip to content

Commit 7fef1c2

Browse files
committed
Give intrinsic ops an inline(always).
1 parent 52e8117 commit 7fef1c2

File tree

3 files changed

+48
-48
lines changed

3 files changed

+48
-48
lines changed

library/core/src/cmp.rs

+31-31
Original file line numberDiff line numberDiff line change
@@ -1275,21 +1275,21 @@ mod impls {
12751275
($($t:ty)*) => ($(
12761276
#[stable(feature = "rust1", since = "1.0.0")]
12771277
impl PartialEq for $t {
1278-
#[inline]
1278+
#[inline(always)]
12791279
fn eq(&self, other: &$t) -> bool { (*self) == (*other) }
1280-
#[inline]
1280+
#[inline(always)]
12811281
fn ne(&self, other: &$t) -> bool { (*self) != (*other) }
12821282
}
12831283
)*)
12841284
}
12851285

12861286
#[stable(feature = "rust1", since = "1.0.0")]
12871287
impl PartialEq for () {
1288-
#[inline]
1288+
#[inline(always)]
12891289
fn eq(&self, _other: &()) -> bool {
12901290
true
12911291
}
1292-
#[inline]
1292+
#[inline(always)]
12931293
fn ne(&self, _other: &()) -> bool {
12941294
false
12951295
}
@@ -1335,15 +1335,15 @@ mod impls {
13351335

13361336
#[stable(feature = "rust1", since = "1.0.0")]
13371337
impl PartialOrd for () {
1338-
#[inline]
1338+
#[inline(always)]
13391339
fn partial_cmp(&self, _: &()) -> Option<Ordering> {
13401340
Some(Equal)
13411341
}
13421342
}
13431343

13441344
#[stable(feature = "rust1", since = "1.0.0")]
13451345
impl PartialOrd for bool {
1346-
#[inline]
1346+
#[inline(always)]
13471347
fn partial_cmp(&self, other: &bool) -> Option<Ordering> {
13481348
Some(self.cmp(other))
13491349
}
@@ -1355,7 +1355,7 @@ mod impls {
13551355
($($t:ty)*) => ($(
13561356
#[stable(feature = "rust1", since = "1.0.0")]
13571357
impl PartialOrd for $t {
1358-
#[inline]
1358+
#[inline(always)]
13591359
fn partial_cmp(&self, other: &$t) -> Option<Ordering> {
13601360
Some(self.cmp(other))
13611361
}
@@ -1385,7 +1385,7 @@ mod impls {
13851385

13861386
#[stable(feature = "rust1", since = "1.0.0")]
13871387
impl Ord for () {
1388-
#[inline]
1388+
#[inline(always)]
13891389
fn cmp(&self, _other: &()) -> Ordering {
13901390
Equal
13911391
}
@@ -1412,7 +1412,7 @@ mod impls {
14121412

14131413
#[unstable(feature = "never_type", issue = "35121")]
14141414
impl PartialEq for ! {
1415-
#[inline]
1415+
#[inline(always)]
14161416
fn eq(&self, _: &!) -> bool {
14171417
*self
14181418
}
@@ -1423,15 +1423,15 @@ mod impls {
14231423

14241424
#[unstable(feature = "never_type", issue = "35121")]
14251425
impl PartialOrd for ! {
1426-
#[inline]
1426+
#[inline(always)]
14271427
fn partial_cmp(&self, _: &!) -> Option<Ordering> {
14281428
*self
14291429
}
14301430
}
14311431

14321432
#[unstable(feature = "never_type", issue = "35121")]
14331433
impl Ord for ! {
1434-
#[inline]
1434+
#[inline(always)]
14351435
fn cmp(&self, _: &!) -> Ordering {
14361436
*self
14371437
}
@@ -1444,11 +1444,11 @@ mod impls {
14441444
where
14451445
A: PartialEq<B>,
14461446
{
1447-
#[inline]
1447+
#[inline(always)]
14481448
fn eq(&self, other: &&B) -> bool {
14491449
PartialEq::eq(*self, *other)
14501450
}
1451-
#[inline]
1451+
#[inline(always)]
14521452
fn ne(&self, other: &&B) -> bool {
14531453
PartialEq::ne(*self, *other)
14541454
}
@@ -1458,23 +1458,23 @@ mod impls {
14581458
where
14591459
A: PartialOrd<B>,
14601460
{
1461-
#[inline]
1461+
#[inline(always)]
14621462
fn partial_cmp(&self, other: &&B) -> Option<Ordering> {
14631463
PartialOrd::partial_cmp(*self, *other)
14641464
}
1465-
#[inline]
1465+
#[inline(always)]
14661466
fn lt(&self, other: &&B) -> bool {
14671467
PartialOrd::lt(*self, *other)
14681468
}
1469-
#[inline]
1469+
#[inline(always)]
14701470
fn le(&self, other: &&B) -> bool {
14711471
PartialOrd::le(*self, *other)
14721472
}
1473-
#[inline]
1473+
#[inline(always)]
14741474
fn gt(&self, other: &&B) -> bool {
14751475
PartialOrd::gt(*self, *other)
14761476
}
1477-
#[inline]
1477+
#[inline(always)]
14781478
fn ge(&self, other: &&B) -> bool {
14791479
PartialOrd::ge(*self, *other)
14801480
}
@@ -1484,7 +1484,7 @@ mod impls {
14841484
where
14851485
A: Ord,
14861486
{
1487-
#[inline]
1487+
#[inline(always)]
14881488
fn cmp(&self, other: &Self) -> Ordering {
14891489
Ord::cmp(*self, *other)
14901490
}
@@ -1499,11 +1499,11 @@ mod impls {
14991499
where
15001500
A: PartialEq<B>,
15011501
{
1502-
#[inline]
1502+
#[inline(always)]
15031503
fn eq(&self, other: &&mut B) -> bool {
15041504
PartialEq::eq(*self, *other)
15051505
}
1506-
#[inline]
1506+
#[inline(always)]
15071507
fn ne(&self, other: &&mut B) -> bool {
15081508
PartialEq::ne(*self, *other)
15091509
}
@@ -1513,23 +1513,23 @@ mod impls {
15131513
where
15141514
A: PartialOrd<B>,
15151515
{
1516-
#[inline]
1516+
#[inline(always)]
15171517
fn partial_cmp(&self, other: &&mut B) -> Option<Ordering> {
15181518
PartialOrd::partial_cmp(*self, *other)
15191519
}
1520-
#[inline]
1520+
#[inline(always)]
15211521
fn lt(&self, other: &&mut B) -> bool {
15221522
PartialOrd::lt(*self, *other)
15231523
}
1524-
#[inline]
1524+
#[inline(always)]
15251525
fn le(&self, other: &&mut B) -> bool {
15261526
PartialOrd::le(*self, *other)
15271527
}
1528-
#[inline]
1528+
#[inline(always)]
15291529
fn gt(&self, other: &&mut B) -> bool {
15301530
PartialOrd::gt(*self, *other)
15311531
}
1532-
#[inline]
1532+
#[inline(always)]
15331533
fn ge(&self, other: &&mut B) -> bool {
15341534
PartialOrd::ge(*self, *other)
15351535
}
@@ -1539,7 +1539,7 @@ mod impls {
15391539
where
15401540
A: Ord,
15411541
{
1542-
#[inline]
1542+
#[inline(always)]
15431543
fn cmp(&self, other: &Self) -> Ordering {
15441544
Ord::cmp(*self, *other)
15451545
}
@@ -1552,11 +1552,11 @@ mod impls {
15521552
where
15531553
A: PartialEq<B>,
15541554
{
1555-
#[inline]
1555+
#[inline(always)]
15561556
fn eq(&self, other: &&mut B) -> bool {
15571557
PartialEq::eq(*self, *other)
15581558
}
1559-
#[inline]
1559+
#[inline(always)]
15601560
fn ne(&self, other: &&mut B) -> bool {
15611561
PartialEq::ne(*self, *other)
15621562
}
@@ -1567,11 +1567,11 @@ mod impls {
15671567
where
15681568
A: PartialEq<B>,
15691569
{
1570-
#[inline]
1570+
#[inline(always)]
15711571
fn eq(&self, other: &&B) -> bool {
15721572
PartialEq::eq(*self, *other)
15731573
}
1574-
#[inline]
1574+
#[inline(always)]
15751575
fn ne(&self, other: &&B) -> bool {
15761576
PartialEq::ne(*self, *other)
15771577
}

library/core/src/internal_macros.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ macro_rules! forward_ref_binop {
3030
impl<'a> $imp<$u> for &'a $t {
3131
type Output = <$t as $imp<$u>>::Output;
3232

33-
#[inline]
33+
#[inline(always)]
3434
fn $method(self, other: $u) -> <$t as $imp<$u>>::Output {
3535
$imp::$method(*self, other)
3636
}
@@ -40,7 +40,7 @@ macro_rules! forward_ref_binop {
4040
impl $imp<&$u> for $t {
4141
type Output = <$t as $imp<$u>>::Output;
4242

43-
#[inline]
43+
#[inline(always)]
4444
fn $method(self, other: &$u) -> <$t as $imp<$u>>::Output {
4545
$imp::$method(self, *other)
4646
}
@@ -50,7 +50,7 @@ macro_rules! forward_ref_binop {
5050
impl $imp<&$u> for &$t {
5151
type Output = <$t as $imp<$u>>::Output;
5252

53-
#[inline]
53+
#[inline(always)]
5454
fn $method(self, other: &$u) -> <$t as $imp<$u>>::Output {
5555
$imp::$method(*self, *other)
5656
}
@@ -68,7 +68,7 @@ macro_rules! forward_ref_op_assign {
6868
(impl $imp:ident, $method:ident for $t:ty, $u:ty, #[$attr:meta]) => {
6969
#[$attr]
7070
impl $imp<&$u> for $t {
71-
#[inline]
71+
#[inline(always)]
7272
fn $method(&mut self, other: &$u) {
7373
$imp::$method(self, *other);
7474
}

library/core/src/ops/arith.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ macro_rules! add_impl {
9797
impl Add for $t {
9898
type Output = $t;
9999

100-
#[inline]
100+
#[inline(always)]
101101
#[rustc_inherit_overflow_checks]
102102
fn add(self, other: $t) -> $t { self + other }
103103
}
@@ -205,7 +205,7 @@ macro_rules! sub_impl {
205205
impl Sub for $t {
206206
type Output = $t;
207207

208-
#[inline]
208+
#[inline(always)]
209209
#[rustc_inherit_overflow_checks]
210210
fn sub(self, other: $t) -> $t { self - other }
211211
}
@@ -334,7 +334,7 @@ macro_rules! mul_impl {
334334
impl Mul for $t {
335335
type Output = $t;
336336

337-
#[inline]
337+
#[inline(always)]
338338
#[rustc_inherit_overflow_checks]
339339
fn mul(self, other: $t) -> $t { self * other }
340340
}
@@ -473,7 +473,7 @@ macro_rules! div_impl_integer {
473473
impl Div for $t {
474474
type Output = $t;
475475

476-
#[inline]
476+
#[inline(always)]
477477
fn div(self, other: $t) -> $t { self / other }
478478
}
479479

@@ -492,7 +492,7 @@ macro_rules! div_impl_float {
492492
impl Div for $t {
493493
type Output = $t;
494494

495-
#[inline]
495+
#[inline(always)]
496496
fn div(self, other: $t) -> $t { self / other }
497497
}
498498

@@ -574,7 +574,7 @@ macro_rules! rem_impl_integer {
574574
impl Rem for $t {
575575
type Output = $t;
576576

577-
#[inline]
577+
#[inline(always)]
578578
fn rem(self, other: $t) -> $t { self % other }
579579
}
580580

@@ -608,7 +608,7 @@ macro_rules! rem_impl_float {
608608
impl Rem for $t {
609609
type Output = $t;
610610

611-
#[inline]
611+
#[inline(always)]
612612
fn rem(self, other: $t) -> $t { self % other }
613613
}
614614

@@ -682,7 +682,7 @@ macro_rules! neg_impl {
682682
impl Neg for $t {
683683
type Output = $t;
684684

685-
#[inline]
685+
#[inline(always)]
686686
#[rustc_inherit_overflow_checks]
687687
fn neg(self) -> $t { -self }
688688
}
@@ -748,7 +748,7 @@ macro_rules! add_assign_impl {
748748
($($t:ty)+) => ($(
749749
#[stable(feature = "op_assign_traits", since = "1.8.0")]
750750
impl AddAssign for $t {
751-
#[inline]
751+
#[inline(always)]
752752
#[rustc_inherit_overflow_checks]
753753
fn add_assign(&mut self, other: $t) { *self += other }
754754
}
@@ -814,7 +814,7 @@ macro_rules! sub_assign_impl {
814814
($($t:ty)+) => ($(
815815
#[stable(feature = "op_assign_traits", since = "1.8.0")]
816816
impl SubAssign for $t {
817-
#[inline]
817+
#[inline(always)]
818818
#[rustc_inherit_overflow_checks]
819819
fn sub_assign(&mut self, other: $t) { *self -= other }
820820
}
@@ -871,7 +871,7 @@ macro_rules! mul_assign_impl {
871871
($($t:ty)+) => ($(
872872
#[stable(feature = "op_assign_traits", since = "1.8.0")]
873873
impl MulAssign for $t {
874-
#[inline]
874+
#[inline(always)]
875875
#[rustc_inherit_overflow_checks]
876876
fn mul_assign(&mut self, other: $t) { *self *= other }
877877
}
@@ -928,7 +928,7 @@ macro_rules! div_assign_impl {
928928
($($t:ty)+) => ($(
929929
#[stable(feature = "op_assign_traits", since = "1.8.0")]
930930
impl DivAssign for $t {
931-
#[inline]
931+
#[inline(always)]
932932
fn div_assign(&mut self, other: $t) { *self /= other }
933933
}
934934

@@ -988,7 +988,7 @@ macro_rules! rem_assign_impl {
988988
($($t:ty)+) => ($(
989989
#[stable(feature = "op_assign_traits", since = "1.8.0")]
990990
impl RemAssign for $t {
991-
#[inline]
991+
#[inline(always)]
992992
fn rem_assign(&mut self, other: $t) { *self %= other }
993993
}
994994

0 commit comments

Comments
 (0)