Skip to content

Commit 34c7929

Browse files
authored
Rollup merge of rust-lang#48402 - eddyb:y-u-no-inline, r=nikomatsakis
rustc_data_structures: add missing #[inline]. r? @nikomatsakis
2 parents f80d057 + 713b05f commit 34c7929

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

Diff for: src/librustc_data_structures/bitslice.rs

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ pub trait BitSlice {
2424

2525
impl BitSlice for [Word] {
2626
/// Clears bit at `idx` to 0; returns true iff this changed `self.`
27+
#[inline]
2728
fn clear_bit(&mut self, idx: usize) -> bool {
2829
let words = self;
2930
debug!("clear_bit: words={} idx={}",
@@ -37,6 +38,7 @@ impl BitSlice for [Word] {
3738
}
3839

3940
/// Sets bit at `idx` to 1; returns true iff this changed `self.`
41+
#[inline]
4042
fn set_bit(&mut self, idx: usize) -> bool {
4143
let words = self;
4244
debug!("set_bit: words={} idx={}",
@@ -50,6 +52,7 @@ impl BitSlice for [Word] {
5052
}
5153

5254
/// Extracts value of bit at `idx` in `self`.
55+
#[inline]
5356
fn get_bit(&self, idx: usize) -> bool {
5457
let words = self;
5558
let BitLookup { word, bit_mask, .. } = bit_lookup(idx);

Diff for: src/librustc_data_structures/indexed_vec.rs

+6
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,16 @@ pub trait Idx: Copy + 'static + Eq + Debug {
2929
}
3030

3131
impl Idx for usize {
32+
#[inline]
3233
fn new(idx: usize) -> Self { idx }
34+
#[inline]
3335
fn index(self) -> usize { self }
3436
}
3537

3638
impl Idx for u32 {
39+
#[inline]
3740
fn new(idx: usize) -> Self { assert!(idx <= u32::MAX as usize); idx as u32 }
41+
#[inline]
3842
fn index(self) -> usize { self as usize }
3943
}
4044

@@ -73,11 +77,13 @@ macro_rules! newtype_index {
7377
pub struct $type($($pub)* u32);
7478

7579
impl Idx for $type {
80+
#[inline]
7681
fn new(value: usize) -> Self {
7782
assert!(value < ($max) as usize);
7883
$type(value as u32)
7984
}
8085

86+
#[inline]
8187
fn index(self) -> usize {
8288
self.0 as usize
8389
}

0 commit comments

Comments
 (0)