Skip to content

Commit

Permalink
Fix warning in nightly rust
Browse files Browse the repository at this point in the history
```
warning: unused return value of `alloc::boxed::Box::<T>::from_raw` that must be used
Warning:    --> internal/core/properties.rs:382:9
    |
382 |         Box::from_raw(_self as *mut BindingHolder<B>);
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: call `drop(from_raw(ptr))` if you intend to drop the `Box`
```

Just do what the note says
  • Loading branch information
ogoffart committed Jul 18, 2022
1 parent dd5adeb commit ced9504
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion helper_crates/vtable/macro/macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ pub fn vtable(_attr: TokenStream, item: TokenStream) -> TokenStream {
vtable_ctor.push(quote!(#ident: {
#sig_extern {
unsafe {
Box::from_raw((#self_call).0 as *mut _);
::core::mem::drop(Box::from_raw((#self_call).0 as *mut _));
}
}
#ident::<T>
Expand Down
4 changes: 1 addition & 3 deletions internal/core/items/flickable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,7 @@ impl Default for FlickableDataBox {
impl Drop for FlickableDataBox {
fn drop(&mut self) {
// Safety: the self.0 was constructed from a Box::leak in FlickableDataBox::default
unsafe {
Box::from_raw(self.0.as_ptr());
}
drop(unsafe { Box::from_raw(self.0.as_ptr()) });
}
}

Expand Down
2 changes: 1 addition & 1 deletion internal/core/properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ impl BindingHolder {
fn alloc_binding_holder<B: BindingCallable + 'static>(binding: B) -> *mut BindingHolder {
/// Safety: _self must be a pointer that comes from a `Box<BindingHolder<B>>::into_raw()`
unsafe fn binding_drop<B>(_self: *mut BindingHolder) {
Box::from_raw(_self as *mut BindingHolder<B>);
drop(Box::from_raw(_self as *mut BindingHolder<B>));
}

/// Safety: _self must be a pointer to a `BindingHolder<B>`
Expand Down

0 comments on commit ced9504

Please sign in to comment.