about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src
diff options
context:
space:
mode:
authorDylan DPC <99973273+Dylan-DPC@users.noreply.github.com>2023-03-29 14:07:31 +0530
committerGitHub <noreply@github.com>2023-03-29 14:07:31 +0530
commit14157561fb6ac5937deb1de37eb9cb6fb8cd802f (patch)
tree88c1f389db1c022878ed3ca50cfa6e396a0dd464 /compiler/rustc_trait_selection/src
parent2a4455d141e651c0ff627998ea484a095ee8b493 (diff)
parent843c5e361e1b392f89f71ac26a951f8dfd84e43a (diff)
downloadrust-14157561fb6ac5937deb1de37eb9cb6fb8cd802f.tar.gz
rust-14157561fb6ac5937deb1de37eb9cb6fb8cd802f.zip
Rollup merge of #109718 - scottmcm:indexvec-last, r=Nilstrieb
Rename `IndexVec::last` → `last_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.)
Diffstat (limited to 'compiler/rustc_trait_selection/src')
-rw-r--r--compiler/rustc_trait_selection/src/solve/search_graph/mod.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/compiler/rustc_trait_selection/src/solve/search_graph/mod.rs b/compiler/rustc_trait_selection/src/solve/search_graph/mod.rs
index d7ad730b4a3..aeb67666035 100644
--- a/compiler/rustc_trait_selection/src/solve/search_graph/mod.rs
+++ b/compiler/rustc_trait_selection/src/solve/search_graph/mod.rs
@@ -70,7 +70,7 @@ impl<'tcx> SearchGraph<'tcx> {
     /// Whether we're currently in a cycle. This should only be used
     /// for debug assertions.
     pub(super) fn in_cycle(&self) -> bool {
-        if let Some(stack_depth) = self.stack.last() {
+        if let Some(stack_depth) = self.stack.last_index() {
             // Either the current goal on the stack is the root of a cycle...
             if self.stack[stack_depth].has_been_used {
                 return true;