Skip to content

New lint swap_ptr_to_ref #8916

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

Merged
merged 1 commit into from
May 31, 2022
Merged

New lint swap_ptr_to_ref #8916

merged 1 commit into from
May 31, 2022

Conversation

Jarcho
Copy link
Contributor

@Jarcho Jarcho commented May 30, 2022

fixes: #7381

changelog: New lint swap_ptr_to_ref

@rust-highfive
Copy link

r? @Manishearth

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label May 30, 2022
@Jarcho Jarcho force-pushed the swap_ptr_to_ref branch 2 times, most recently from fb96e75 to 5032d42 Compare May 30, 2022 17:18
@bors
Copy link
Contributor

bors commented May 31, 2022

☔ The latest upstream changes (presumably #8918) made this pull request unmergeable. Please resolve the merge conflicts.

Copy link
Member

@Manishearth Manishearth left a comment

Choose a reason for hiding this comment

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

really neat lint!

one small issue, then feel free to r=me

}
}

fn is_ptr_to_ref(cx: &LateContext<'_>, e: &Expr<'_>, ctxt: SyntaxContext) -> (bool, Option<Span>) {
Copy link
Member

Choose a reason for hiding this comment

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

nit: documentation

@Manishearth
Copy link
Member

@bors delegate+

@bors
Copy link
Contributor

bors commented May 31, 2022

✌️ @Jarcho can now approve this pull request

@Jarcho Jarcho force-pushed the swap_ptr_to_ref branch from 5032d42 to a86ca82 Compare May 31, 2022 16:54
@Jarcho Jarcho force-pushed the swap_ptr_to_ref branch from a86ca82 to ca78e24 Compare May 31, 2022 17:08
@Jarcho
Copy link
Contributor Author

Jarcho commented May 31, 2022

I switched the category to suspicious. The lint makes no attempt to determine if it's possible the pointers overlap and there may be a performance penalty for using ptr::swap.

@Jarcho
Copy link
Contributor Author

Jarcho commented May 31, 2022

@bors r=Manishearth

@bors
Copy link
Contributor

bors commented May 31, 2022

📌 Commit ca78e24 has been approved by Manishearth

@bors
Copy link
Contributor

bors commented May 31, 2022

⌛ Testing commit ca78e24 with merge f0bf200...

@Manishearth
Copy link
Member

good call!

@bors
Copy link
Contributor

bors commented May 31, 2022

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: Manishearth
Pushing f0bf200 to master...

@bors bors merged commit f0bf200 into rust-lang:master May 31, 2022
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.

Suggest std::ptr::swap(a, b) instead of std::mem::swap(&mut *a, &mut *b)
4 participants