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

Add opt-in may_dangle support #132

Closed
nnethercote opened this issue Nov 20, 2018 · 0 comments
Closed

Add opt-in may_dangle support #132

nnethercote opened this issue Nov 20, 2018 · 0 comments

Comments

@nnethercote
Copy link
Contributor

nnethercote commented Nov 20, 2018

A couple of times now I've tried to use SmallVec as a drop-in replacement for Vec within rustc, and it hasn't worked because SmallVec doesn't have #[may_dangle] annotations. (rust-lang/rust#55525 is one case; rust-lang/rust#56269 is the other.) That annotation is unstable so I think it would have to be behind a feature flag, but that would suffice for my purposes.

I'm not sure about the right way to do this, though. I tried changing this line:

impl<A: Array> Drop for SmallVec {

to this:

unsafe impl<#[may_dangle] A: Array> Drop for SmallVec {

For the current code I'm working on (rust-lang/rust#56269), where Vec works but SmallVec doesn't, this reduced the number of borrow checker errors from 4 to 2. So it helped, but didn't solve things completely. Maybe there's a better way to do it.

nnethercote added a commit to nnethercote/rust-smallvec that referenced this issue Nov 29, 2018
This commit adds a `may_dangle` annotation to `drop`, matching `Vec`.
This feature increases the ability of `SmallVec` to be used as a drop-in
replacement for `Vec`. A feature is necessary because `may_dangle` is
Nightly-only.

Fixes servo#132.
bors-servo pushed a commit that referenced this issue Nov 29, 2018
Add a new feature, `may_dangle`.

This commit adds a `may_dangle` annotation to `drop`, matching `Vec`.
This feature increases the ability of `SmallVec` to be used as a drop-in
replacement for `Vec`. A feature is necessary because `may_dangle` is
Nightly-only.

Fixes #132.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/rust-smallvec/133)
<!-- Reviewable:end -->
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

1 participant