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

Fixes: #12050 - identity_op correctly suggests a deference for coerced references #12056

Merged
merged 1 commit into from Jan 3, 2024

Conversation

m-rph
Copy link
Contributor

@m-rph m-rph commented Dec 30, 2023

When identity_op identifies a no_op, provides a suggestion, it also checks the type of the type of the variable. If the variable is a reference that's been coerced into a value, e.g.

let x = &0i32;
let _ = x + 0;

the suggestion will now use a derefence. This is done by identifying whether the variable is a reference to an integral value, and then whether it gets dereferenced.

changelog: false positive: [identity_op]: corrected suggestion for reference coerced to value.

fixes: #12050

When `identity_op` identifies a `no_op`, provides a suggestion, it also
checks the type of the type of the variable. If the variable is
a reference that's been coerced into a value, e.g.

```
let x = &0i32;
let _ = x + 0;
```

the suggestion will now use a derefence. This is done by identifying
whether the variable is a reference to an integral value, and then
whether it gets dereferenced.

changelog: false positive: [`identity_op`]: corrected suggestion for
reference coerced to value.

fixes: rust-lang#12050
@rustbot
Copy link
Collaborator

rustbot commented Dec 30, 2023

r? @xFrednet

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

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Dec 30, 2023
@m-rph m-rph changed the title Fixes: #12050 identity_op correctly suggests a deference for coerced references Fixes: #12050 - identity_op correctly suggests a deference for coerced references Dec 30, 2023
@m-rph m-rph marked this pull request as ready for review December 30, 2023 11:37
@xFrednet
Copy link
Member

xFrednet commented Jan 3, 2024

Looks good to me, thank you for the update. :D

@bors r+

@bors
Copy link
Collaborator

bors commented Jan 3, 2024

📌 Commit c2b3f5c has been approved by xFrednet

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented Jan 3, 2024

⌛ Testing commit c2b3f5c with merge 2eb13d3...

@bors
Copy link
Collaborator

bors commented Jan 3, 2024

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: xFrednet
Pushing 2eb13d3 to master...

@bors bors merged commit 2eb13d3 into rust-lang:master Jan 3, 2024
5 checks passed
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.

identity_op: fails to apply fix for reference
4 participants