Don't leak missing Safety doc clippy warnings

With rustc 1.40.0, clippy checks that the `unsafe` functions come with
a `Safety` section. When running clippy on a downstream crate, the
macros such as `gst_plugin_define!` leak the clippy warnings for the
unsafe functions.

Silence the warnings for now.
This commit is contained in:
François Laignel 2019-11-18 09:15:56 +01:00
parent 9f121b1f12
commit dc7937a8d4
3 changed files with 6 additions and 2 deletions

View file

@ -352,7 +352,7 @@ where
} }
unsafe extern "C" fn filter_boxed_ref<T: 'static>(boxed: gpointer) -> gpointer { unsafe extern "C" fn filter_boxed_ref<T: 'static>(boxed: gpointer) -> gpointer {
let boxed = Arc::from_raw(boxed as *const (Box<dyn Fn(T) -> bool + Send + Sync + 'static>)); let boxed = Arc::from_raw(boxed as *const Box<dyn Fn(T) -> bool + Send + Sync + 'static>);
let copy = Arc::clone(&boxed); let copy = Arc::clone(&boxed);
// Forget it and keep it alive, we will still need it later // Forget it and keep it alive, we will still need it later
@ -362,7 +362,7 @@ unsafe extern "C" fn filter_boxed_ref<T: 'static>(boxed: gpointer) -> gpointer {
} }
unsafe extern "C" fn filter_boxed_unref<T: 'static>(boxed: gpointer) { unsafe extern "C" fn filter_boxed_unref<T: 'static>(boxed: gpointer) {
let _ = Arc::from_raw(boxed as *const (Box<dyn Fn(T) -> bool + Send + Sync + 'static>)); let _ = Arc::from_raw(boxed as *const Box<dyn Fn(T) -> bool + Send + Sync + 'static>);
} }
unsafe extern "C" fn filter_boxed_get_type<T: StaticType + 'static>() -> glib_sys::GType { unsafe extern "C" fn filter_boxed_get_type<T: StaticType + 'static>() -> glib_sys::GType {

View file

@ -64,6 +64,7 @@ macro_rules! gst_plugin_define(
} }
} }
#[allow(clippy::missing_safety_doc)]
unsafe extern "C" fn plugin_init_trampoline(plugin: *mut $crate::gst_sys::GstPlugin) -> $crate::glib_sys::gboolean { unsafe extern "C" fn plugin_init_trampoline(plugin: *mut $crate::gst_sys::GstPlugin) -> $crate::glib_sys::gboolean {
use std::panic::{self, AssertUnwindSafe}; use std::panic::{self, AssertUnwindSafe};

View file

@ -62,16 +62,19 @@ macro_rules! gst_plugin_define(
$crate::paste::item! { $crate::paste::item! {
#[no_mangle] #[no_mangle]
#[allow(clippy::missing_safety_doc)]
pub unsafe extern "C" fn [<gst_plugin_ $name _register>] () { pub unsafe extern "C" fn [<gst_plugin_ $name _register>] () {
let _ = plugin_register_static(); let _ = plugin_register_static();
} }
#[no_mangle] #[no_mangle]
#[allow(clippy::missing_safety_doc)]
pub unsafe extern "C" fn [<gst_plugin_ $name _get_desc>] () -> *const $crate::gst_sys::GstPluginDesc { pub unsafe extern "C" fn [<gst_plugin_ $name _get_desc>] () -> *const $crate::gst_sys::GstPluginDesc {
&GST_PLUGIN_DESC.0 &GST_PLUGIN_DESC.0
} }
} }
#[allow(clippy::missing_safety_doc)]
unsafe extern "C" fn plugin_init_trampoline(plugin: *mut $crate::gst_sys::GstPlugin) -> $crate::glib_sys::gboolean { unsafe extern "C" fn plugin_init_trampoline(plugin: *mut $crate::gst_sys::GstPlugin) -> $crate::glib_sys::gboolean {
use std::panic::{self, AssertUnwindSafe}; use std::panic::{self, AssertUnwindSafe};