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: handle SelfParam better in "Inline call" #16378

Merged
merged 3 commits into from
Jan 17, 2024

Conversation

roife
Copy link
Member

@roife roife commented Jan 17, 2024

fix #15470.

The current inline_call directly translates &self into let ref this = ...; and &mut self into let ref mut this = ...;. However, it does not handle some complex scenarios.

This PR addresses the following transformations (assuming the receiving object is obj):

  • self: let this = obj
  • mut self: let mut this = obj
  • &self: let this = &obj
  • &mut self
    • If obj is let mut obj = ..., use a mutable reference: let this = &mut obj
    • If obj is let obj = &mut ...;, perform a reborrow: let this = &mut *obj

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

Veykril commented Jan 17, 2024

@bors r+

@bors
Copy link
Collaborator

bors commented Jan 17, 2024

📌 Commit 920e99a has been approved by Veykril

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented Jan 17, 2024

⌛ Testing commit 920e99a with merge f4fec4f...

@bors
Copy link
Collaborator

bors commented Jan 17, 2024

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

@bors bors merged commit f4fec4f into rust-lang:master Jan 17, 2024
10 checks passed
@lnicola lnicola changed the title fix: better handling of SelfParam in assist 'inline_call' fix: handle SelfParam better in "Inline call" Jan 20, 2024
@roife roife deleted the fix/issue-15470 branch February 27, 2024 06:20
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.

weird behavior when inlining a function
4 participants