Skip to content

Commit 84bf599

Browse files
committed
Add inlining.
1 parent 17a07d7 commit 84bf599

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

compiler/rustc_data_structures/src/stable_hasher.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ impl StableHasher {
3535
StableHasher { state: SipHasher128::new_with_keys(0, 0) }
3636
}
3737

38+
#[inline]
3839
pub fn finish<W: StableHasherResult>(self) -> W {
3940
W::finish(self)
4041
}

compiler/rustc_macros/src/hash_stable.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ pub fn hash_stable_generic_derive(mut s: synstructure::Structure<'_>) -> proc_ma
7474
s.bound_impl(
7575
quote!(::rustc_data_structures::stable_hasher::HashStable<__CTX>),
7676
quote! {
77+
#[inline]
7778
fn hash_stable(
7879
&self,
7980
__hcx: &mut __CTX,
@@ -119,6 +120,7 @@ pub fn hash_stable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::To
119120
>
120121
),
121122
quote! {
123+
#[inline]
122124
fn hash_stable(
123125
&self,
124126
__hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>,

library/core/src/hash/mod.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,10 +548,12 @@ mod impls {
548548
($(($ty:ident, $meth:ident),)*) => {$(
549549
#[stable(feature = "rust1", since = "1.0.0")]
550550
impl Hash for $ty {
551+
#[inline]
551552
fn hash<H: Hasher>(&self, state: &mut H) {
552553
state.$meth(*self)
553554
}
554555

556+
#[inline]
555557
fn hash_slice<H: Hasher>(data: &[$ty], state: &mut H) {
556558
let newlen = data.len() * mem::size_of::<$ty>();
557559
let ptr = data.as_ptr() as *const u8;
@@ -582,20 +584,23 @@ mod impls {
582584

583585
#[stable(feature = "rust1", since = "1.0.0")]
584586
impl Hash for bool {
587+
#[inline]
585588
fn hash<H: Hasher>(&self, state: &mut H) {
586589
state.write_u8(*self as u8)
587590
}
588591
}
589592

590593
#[stable(feature = "rust1", since = "1.0.0")]
591594
impl Hash for char {
595+
#[inline]
592596
fn hash<H: Hasher>(&self, state: &mut H) {
593597
state.write_u32(*self as u32)
594598
}
595599
}
596600

597601
#[stable(feature = "rust1", since = "1.0.0")]
598602
impl Hash for str {
603+
#[inline]
599604
fn hash<H: Hasher>(&self, state: &mut H) {
600605
state.write(self.as_bytes());
601606
state.write_u8(0xff)
@@ -604,6 +609,7 @@ mod impls {
604609

605610
#[stable(feature = "never_hash", since = "1.29.0")]
606611
impl Hash for ! {
612+
#[inline]
607613
fn hash<H: Hasher>(&self, _: &mut H) {
608614
*self
609615
}
@@ -613,6 +619,7 @@ mod impls {
613619
() => (
614620
#[stable(feature = "rust1", since = "1.0.0")]
615621
impl Hash for () {
622+
#[inline]
616623
fn hash<H: Hasher>(&self, _state: &mut H) {}
617624
}
618625
);
@@ -621,6 +628,7 @@ mod impls {
621628
#[stable(feature = "rust1", since = "1.0.0")]
622629
impl<$($name: Hash),+> Hash for ($($name,)+) where last_type!($($name,)+): ?Sized {
623630
#[allow(non_snake_case)]
631+
#[inline]
624632
fn hash<S: Hasher>(&self, state: &mut S) {
625633
let ($(ref $name,)+) = *self;
626634
$($name.hash(state);)+
@@ -650,6 +658,7 @@ mod impls {
650658

651659
#[stable(feature = "rust1", since = "1.0.0")]
652660
impl<T: Hash> Hash for [T] {
661+
#[inline]
653662
fn hash<H: Hasher>(&self, state: &mut H) {
654663
self.len().hash(state);
655664
Hash::hash_slice(self, state)
@@ -658,20 +667,23 @@ mod impls {
658667

659668
#[stable(feature = "rust1", since = "1.0.0")]
660669
impl<T: ?Sized + Hash> Hash for &T {
670+
#[inline]
661671
fn hash<H: Hasher>(&self, state: &mut H) {
662672
(**self).hash(state);
663673
}
664674
}
665675

666676
#[stable(feature = "rust1", since = "1.0.0")]
667677
impl<T: ?Sized + Hash> Hash for &mut T {
678+
#[inline]
668679
fn hash<H: Hasher>(&self, state: &mut H) {
669680
(**self).hash(state);
670681
}
671682
}
672683

673684
#[stable(feature = "rust1", since = "1.0.0")]
674685
impl<T: ?Sized> Hash for *const T {
686+
#[inline]
675687
fn hash<H: Hasher>(&self, state: &mut H) {
676688
#[cfg(not(bootstrap))]
677689
{
@@ -701,6 +713,7 @@ mod impls {
701713

702714
#[stable(feature = "rust1", since = "1.0.0")]
703715
impl<T: ?Sized> Hash for *mut T {
716+
#[inline]
704717
fn hash<H: Hasher>(&self, state: &mut H) {
705718
#[cfg(not(bootstrap))]
706719
{

0 commit comments

Comments
 (0)