Skip to content

Commit

Permalink
vlcrs-macros: simplify transmuting function pointers
Browse files Browse the repository at this point in the history
Clippy reports[^1] those transmute as being non-necessary, and it seems
that it now works correctly with `as *mut c_void` without the additional
template typing parameters.

[^1]: https://rust-lang.github.io/rust-clippy/master/index.html#/transmutes_expressible_as_ptr_casts
  • Loading branch information
alexandre-janniaux authored and fkuehne committed Aug 25, 2024
1 parent 62782e9 commit 0f4f680
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/rust/vlcrs-macros/src/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -939,10 +939,8 @@ fn generate_module_code(module_info: &ModuleInfo) -> TokenStream2 {
::vlcrs_plugin::ModuleProperties::MODULE_CB_OPEN as _,
#module_open_with_nul,
unsafe {
std::mem::transmute::<
<#loader as ModuleProtocol<#type_>>::Activate,
*mut std::ffi::c_void
>(<#loader as ModuleProtocol<#type_>>::activate_function())
<#loader as ModuleProtocol<#type_>>::activate_function()
as *mut std::ffi::c_void
}
)
} != 0
Expand All @@ -958,10 +956,8 @@ fn generate_module_code(module_info: &ModuleInfo) -> TokenStream2 {
::vlcrs_plugin::ModuleProperties::MODULE_CB_CLOSE as _,
#module_close_with_nul,
unsafe {
std::mem::transmute::<
<#loader as ModuleProtocol<#type_>>::Deactivate,
*mut std::ffi::c_void
>(<#loader as ModuleProtocol<#type_>>::deactivate_function().unwrap())
<#loader as ModuleProtocol<#type_>>::deactivate_function().unwrap()
as *mut std::ffi::c_void
}
)
} != 0
Expand Down

0 comments on commit 0f4f680

Please sign in to comment.