Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename IndexVec::lastlast_index #109718

Merged
merged 1 commit into from
Mar 29, 2023
Merged

Conversation

scottmcm
Copy link
Member

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.)

@rustbot
Copy link
Collaborator

rustbot commented Mar 29, 2023

r? @petrochenkov

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Mar 29, 2023
@rustbot
Copy link
Collaborator

rustbot commented Mar 29, 2023

Some changes occurred to the core trait solver

cc @rust-lang/initiative-trait-system-refactor

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.)
@rustbot
Copy link
Collaborator

rustbot commented Mar 29, 2023

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

Copy link
Member

@Noratrieb Noratrieb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r? Nilstrieb
r=me, the renaming makes a lot of sense

@rustbot rustbot assigned Noratrieb and unassigned petrochenkov Mar 29, 2023
@scottmcm
Copy link
Member Author

CI came in clean, so
@bors r=Nilstrieb

@bors
Copy link
Contributor

bors commented Mar 29, 2023

📌 Commit 843c5e3 has been approved by Nilstrieb

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 29, 2023
@Noratrieb
Copy link
Member

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Mar 29, 2023

💡 This pull request was already approved, no need to approve it again.

@bors
Copy link
Contributor

bors commented Mar 29, 2023

📌 Commit 843c5e3 has been approved by Nilstrieb

It is now in the queue for this repository.

@Noratrieb
Copy link
Member

oh, GitHub didn't refresh for me :D

bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 29, 2023
Rollup of 7 pull requests

Successful merges:

 - rust-lang#108335 (rustdoc + rustdoc-json support for `feature(non_lifetime_binders)`)
 - rust-lang#109534 (rustdoc: Unsupport importing `doc(primitive)` and `doc(keyword)` modules)
 - rust-lang#109659 (llvm-wrapper: adapt for LLVM API change)
 - rust-lang#109664 (Use span of placeholders in format_args!() expansion.)
 - rust-lang#109683 (Check for overflow in `assemble_candidates_after_normalizing_self_ty`)
 - rust-lang#109713 (Fix mismatched punctuation in Debug impl of AttrId)
 - rust-lang#109718 (Rename `IndexVec::last` → `last_index`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 1415756 into rust-lang:master Mar 29, 2023
@rustbot rustbot added this to the 1.70.0 milestone Mar 29, 2023
@scottmcm scottmcm deleted the indexvec-last branch March 29, 2023 16:08
@lcnr lcnr removed the WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) label Apr 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants