fix(assists/add_reference_here): _modify_ the reference type when dealing with &T->&mut T#22342
Open
ada4a wants to merge 3 commits into
Open
fix(assists/add_reference_here): _modify_ the reference type when dealing with &T->&mut T#22342ada4a wants to merge 3 commits into
ada4a wants to merge 3 commits into
Conversation
This comment has been minimized.
This comment has been minimized.
- use `ctx.db()` - move `add_mutable_reference_to_let_stmt` closer to `add_reference_to_let_stmt`
910f6cb to
fdfffdb
Compare
Collaborator
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
ada4a
commented
May 11, 2026
Comment on lines
+100
to
+108
| let expr = expr_ptr.to_node(ctx.db()); | ||
| // If the node comes from a macro expansion, then we shouldn't assist, | ||
| // as the suggestion would overwrite the macro _definition_ position | ||
| let expr = ctx.sema.original_ast_node(expr)?; | ||
| let expr_without_ref = RefExpr::cast(expr.syntax().clone())?.expr()?; | ||
|
|
||
| let pos = expr_without_ref.syntax().text_range().start(); | ||
| let edit = TextEdit::insert(pos, "mut ".to_string()); | ||
| let source_change = SourceChange::from_text_edit(range.file_id, edit); |
Contributor
Author
There was a problem hiding this comment.
I initially wanted to do this with SyntaxEditor, but it looks like a text edit works just fine... Let me know which one I should go with.
fdfffdb to
a66b485
Compare
…ling with &T->&mut T ..instead of adding another layer of reference, i.e. &T -> &mut &T Co-authored-by: Ana Hobden <operator@hoverbear.org>
a66b485 to
4e6676e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
..instead of adding another layer of reference, i.e. &T -> &mut &T
Fixes #13047