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

Fix an issue where PinnedDrop implementations can call unsafe code without an unsafe block #149

Merged
merged 1 commit into from
Oct 17, 2019

Conversation

taiki-e
Copy link
Owner

@taiki-e taiki-e commented Oct 17, 2019

This change will generate code similar to the following:

from:

impl PinnedDrop for Foo {
    fn drop(self: Pin<&mut Self>) {
        // ...
    }
}

into:

impl PinnedDrop for Foo {
    unsafe fn drop(self: Pin<&mut Self>) {
        fn __drop_inner<T>(__self: Pin<&mut Foo<'_, T>>) {
            // ...
        }
        __drop_inner(self);
    }
}

Fixes #148

@taiki-e
Copy link
Owner Author

taiki-e commented Oct 17, 2019

bors r+

bors bot added a commit that referenced this pull request Oct 17, 2019
149: Fix an issue where PinnedDrop implementations can call unsafe code without an unsafe block r=taiki-e a=taiki-e

This change will generate code similar to the following:

from:

```rust
impl PinnedDrop for Foo {
    fn drop(self: Pin<&mut Self>) {
        // ...
    }
}
```
into:
```rust
impl PinnedDrop for Foo {
    unsafe fn drop(self: Pin<&mut Self>) {
        fn __drop_inner<T>(__self: Pin<&mut Foo<'_, T>>) {
            // ...
        }
        __drop_inner(self);
    }
}
```

Fixes #148 


Co-authored-by: Taiki Endo <[email protected]>
@bors
Copy link
Contributor

bors bot commented Oct 17, 2019

Build succeeded

  • test (macos)
  • style (rustdoc)
  • style (rustfmt)
  • test (1.33.0)
  • style (clippy)
  • test (1.36.0)
  • test (beta)
  • test (nightly)
  • test (stable)

@bors bors bot merged commit e2a44d0 into master Oct 17, 2019
@bors bors bot deleted the pinned-drop-unsafe-code branch October 17, 2019 14:43
@taiki-e taiki-e added the A-drop Area: #[pinned_drop] and Drop label May 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-drop Area: #[pinned_drop] and Drop
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PinnedDrop implementations can contain unsafe code without an unsafe block
1 participant