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

Suggest pointer::cast when possible in transmute_ptr_to_ref #8939

Merged
merged 1 commit into from
Jun 27, 2022

Conversation

Jarcho
Copy link
Contributor

@Jarcho Jarcho commented Jun 4, 2022

fixes #8924

changelog: Suggest casting the pointer for any type containing lifetimes in transmute_ptr_to_ref.
changelog: Suggest pointer::cast when possible in transmute_ptr_to_ref.

@rust-highfive
Copy link

r? @giraffate

(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 Jun 4, 2022
@Jarcho
Copy link
Contributor Author

Jarcho commented Jun 4, 2022

Apparently casting *const &'a T to *const &'b T directly doesn't work with as. Not sure if double cast as a workaround is really better than transmute.

Copy link
Contributor

@giraffate giraffate left a comment

Choose a reason for hiding this comment

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

Sorry for the late reviewing. I made comments.

@@ -25,7 +25,7 @@ msrv_aliases! {
1,40,0 { MEM_TAKE, NON_EXHAUSTIVE, OPTION_AS_DEREF }
1,38,0 { POINTER_CAST }
1,37,0 { TYPE_ALIAS_ENUM_VARIANTS }
1,36,0 { ITERATOR_COPIED }
1,36,0 { ITERATOR_COPIED, PTR_CAST }
Copy link
Contributor

Choose a reason for hiding this comment

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

What method is this? I thought it was this, but it looks like this was added at 1.38.0.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is the right method. I don't know where I got 1.36 from.

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay. Can 1,38,0 { POINTER_CAST } be used for msrv?

Defensively add a cast to any type with lifetimes.
@giraffate
Copy link
Contributor

@bors r+

It looks good, thanks!

@bors
Copy link
Collaborator

bors commented Jun 27, 2022

📌 Commit 7cdaabc has been approved by giraffate

@bors
Copy link
Collaborator

bors commented Jun 27, 2022

⌛ Testing commit 7cdaabc with merge 88da5f2...

@bors
Copy link
Collaborator

bors commented Jun 27, 2022

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: giraffate
Pushing 88da5f2 to master...

@bors bors merged commit 88da5f2 into rust-lang:master Jun 27, 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.

transmute_ptr_to_ref false positive for types containing differing lifetimes
4 participants