Skip to content

Conversation

@Dylan-DPC-zz
Copy link

Successful merges:

Failed merges:

r? @ghost

vorner and others added 13 commits April 13, 2020 17:17
* Rename Weak::as_raw to Weak::as_ptr for consistency with some other
  types.
* The as_ptr for a dangling Weak pointer might return whatever garbage
  (and takes that advantage to avoid a conditional).
* Don't guarantee to be able to do `Weak::from_raw(weak.as_ptr())` (even
  though it'll still work fine).
It is safer to use `from_ne_bytes` to convert raw bytes to type like u32.
For consistency with Weak
…anieu

Address concerns of weak-into-raw

This should address the standing concerns in rust-lang#60728 (comment).

I've still left the ability to create a new dangling pointer from `null`, as I feel like this is the natural behaviour to expect, but I'm fine removing that too. I've modified the documentation to allow the `as_ptr` or `into_ptr` to return whatever garbage in case of a dangling pointer. I've also removed the guarantee to be able to do `from_raw(as_ptr)` from the documentation (but it would still work right now).

I've renamed the method and added implementations for `Rc`/`Arc`.

I've also tried if I can just „enable“ unsized types. I believe the current interface is compatible with them. But the inner implementation will be a bit challenging ‒ I can't use the `data_offset` as is used by `Rc` or `Arc` because it AFAIK „touches“ (creates a reference to) the live value of `T` ‒ and in case of `Weak`, it might be completely bogus or already dead ‒ so that would be UB.

`./x.py test tidy` is completely mad on my own system all over the code base :-(. I'll just hope it goes through CI, or will fix as necessary.

Is it OK if I ask @Amanieu for review, as the concerns are from you?

~r @Amanieu
Fixed missing trait method suggests incorrect code (self parameter not named "self").

fixes rust-lang#71150
…r=XAMPPRocky

Clarify when to use the tracking issue template

People tend to open this for feature requests. Let's see if this helps.

r? @XAMPPRocky
…=Dylan-DPC

Add example in the alternative in std::mem::transmute docs

It is safer to use `from_ne_bytes` to convert raw bytes to type like u32.  rust-lang#71187
@Dylan-DPC-zz Dylan-DPC-zz deleted the rollup-b0otkua branch April 19, 2020 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants