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

stable_deref_trait could be used to remove boxing #1

Open
Ten0 opened this issue Aug 4, 2020 · 2 comments
Open

stable_deref_trait could be used to remove boxing #1

Ten0 opened this issue Aug 4, 2020 · 2 comments

Comments

@Ten0
Copy link

Ten0 commented Aug 4, 2020

Regarding this comment: https://docs.rs/gsrs/0.1.4/src/gsrs/lib.rs.html#135-138
It seems this "collection trait" already exists as a library: https://lib.rs/crates/stable_deref_trait

The traits in this library seem to be implemented for Box, String, etc, which all use Unique instead of NonNull, and other crates using stable_deref_trait don't seem to have issues the AliasedBox of this crate refers to.
Can you explain more in detail the issue(s) using Unique would cause ? From https://doc.rust-lang.org/stable/src/core/ptr/unique.rs.html#14-17 I feel like the usage this crate has would respect these constraints.

@rrevenantt
Copy link
Owner

rrevenantt commented Aug 10, 2020

owning_ref is currently unsound because of using Unique - Kimundi/owning-ref-rs#49. In my case i had added a similar test_cell test that was triggering unsoundness with Unique by violating its the referent of the pointer should not be modified without a unique path to its owning Unique. requirement. If it is still confusing, could you be more precise in what to explain more?

stable_deref_trait also has soundness issue(Storyyeller/stable_deref_trait#10) which is why i didn't use it. Although now I have looked into this issue again, and IIRC recently third option for solving it was finally implemented in rust core. So apparently it is fixed and I will see again if i can use it. At first glance just implementing StableDeref for AliasedBox should be enough, but then i would have to forbid Box somehow. Also same should be done for Vec. For now it looks like it would be better to wait until similar issue rust-lang/rust#63818 in rust compiler is fixed, to implement mine in the same way.

@Ten0
Copy link
Author

Ten0 commented Aug 10, 2020

Alright that's pretty clear! 🙂
Wouldn't this question deserve these references in the code comments?

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

No branches or pull requests

2 participants