Skip to content

Commit

Permalink
Rollup merge of rust-lang#84887 - jyn514:index-span, r=Xanewok
Browse files Browse the repository at this point in the history
Remove SpanInterner::get

- It's used exactly once, so it's trivial to replace
- It doesn't match the normal convention for containers: normally
`get()` returns an option and indexing panics. Instead `SpanInterner::get()` panics
  and there's no indexing operation available.
  • Loading branch information
Dylan-DPC authored May 7, 2021
2 parents eb36bc6 + b73ad09 commit 44bee53
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions compiler/rustc_span/src/span_encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl Span {
// Interned format.
debug_assert!(self.ctxt_or_zero == 0);
let index = self.base_or_index;
with_span_interner(|interner| *interner.get(index))
with_span_interner(|interner| interner.spans[index as usize])
}
}
}
Expand All @@ -117,11 +117,6 @@ impl SpanInterner {
let (index, _) = self.spans.insert_full(*span_data);
index as u32
}

#[inline]
fn get(&self, index: u32) -> &SpanData {
&self.spans[index as usize]
}
}

// If an interner exists, return it. Otherwise, prepare a fresh one.
Expand Down

0 comments on commit 44bee53

Please sign in to comment.