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

fix: Goto definition for index_mut #16709

Merged
merged 2 commits into from Feb 29, 2024

Conversation

ShoyuVanilla
Copy link
Contributor

Mostly same with #16696.

&Expr::Index { base, index, is_assignee_expr: _ } => {
if mutability == Mutability::Mut {
if let Some((f, _)) = self.result.method_resolutions.get_mut(&tgt_expr) {
if let Some(index_trait) = self
.db
.lang_item(self.table.trait_env.krate, LangItem::IndexMut)
.and_then(|l| l.as_trait())
{
if let Some(index_fn) =
self.db.trait_data(index_trait).method_by_name(&name![index_mut])
{
*f = index_fn;
let base_adjustments = self
.result
.expr_adjustments
.get_mut(&base)
.and_then(|it| it.last_mut());
if let Some(Adjustment {
kind: Adjust::Borrow(AutoBorrow::Ref(mutability)),
..
}) = base_adjustments
{
*mutability = Mutability::Mut;
}
}
}
}
}
self.infer_mut_expr(base, mutability);
self.infer_mut_expr(index, Mutability::Not);
}

Thankfully, we are doing similar method resolutions so we can use them like the mentioned PR.
As there are only three LangItems having Mut in there names; FnMut, DerefMut and IndexMut, I think that this is the last one 😄

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 28, 2024
@Veykril
Copy link
Member

Veykril commented Feb 29, 2024

Let's see if bors works again
@bors r+

@bors
Copy link
Collaborator

bors commented Feb 29, 2024

📌 Commit bf23dee has been approved by Veykril

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented Feb 29, 2024

⌛ Testing commit bf23dee with merge 0ec6015...

@bors
Copy link
Collaborator

bors commented Feb 29, 2024

☀️ Test successful - checks-actions
Approved by: Veykril
Pushing 0ec6015 to master...

@bors bors merged commit 0ec6015 into rust-lang:master Feb 29, 2024
11 checks passed
@ShoyuVanilla ShoyuVanilla deleted the fix-goto-index-mut branch February 29, 2024 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants