Rename IndexVec::lastlast_index

As I've been trying to replace a `Vec` with an `IndexVec`, having `last` exist on both but returning very different types makes the transition a bit awkward -- the errors are later, where you get things like "there's no `ty` method on `mir::Field`" rather than a more localized error like "hey, there's no `last` on `IndexVec`".

So I propose renaming `last` to `last_index` to help distinguish `Vec::last`, which returns an element, and `IndexVec::last_index`, which returns an index.

(Similarly, `Iterator::last` also returns an element, not an index.)
This commit is contained in:
Scott McMurray 2023-03-29 00:04:14 -07:00
parent acd27bb557
commit 843c5e361e
4 changed files with 5 additions and 5 deletions

View file

@ -65,7 +65,7 @@ impl<'tcx> MockBlocks<'tcx> {
}
fn push(&mut self, kind: TerminatorKind<'tcx>) -> BasicBlock {
let next_lo = if let Some(last) = self.blocks.last() {
let next_lo = if let Some(last) = self.blocks.last_index() {
self.blocks[last].terminator().source_info.span.hi()
} else {
BytePos(1)