diff --git a/gstreamer-check/src/harness.rs b/gstreamer-check/src/harness.rs index 7f5c8bbf3..ead79e39a 100644 --- a/gstreamer-check/src/harness.rs +++ b/gstreamer-check/src/harness.rs @@ -22,10 +22,7 @@ use std::ptr; use TestClock; #[derive(Debug)] -pub struct Harness( - ptr::NonNull, - PhantomData, -); +pub struct Harness(ptr::NonNull); impl Drop for Harness { fn drop(&mut self) { @@ -567,7 +564,7 @@ impl Harness { unsafe fn from_glib_full(ptr: *mut gst_check_sys::GstHarness) -> Harness { assert!(!ptr.is_null()); - Harness(ptr::NonNull::new_unchecked(ptr), PhantomData) + Harness(ptr::NonNull::new_unchecked(ptr)) } pub fn new(element_name: &str) -> Harness { @@ -728,10 +725,7 @@ impl Harness { None } else { Some(Ref( - mem::ManuallyDrop::new(Harness( - ptr::NonNull::new_unchecked(sink_harness), - PhantomData, - )), + mem::ManuallyDrop::new(Harness(ptr::NonNull::new_unchecked(sink_harness))), PhantomData, )) } @@ -745,10 +739,7 @@ impl Harness { None } else { Some(Ref( - mem::ManuallyDrop::new(Harness( - ptr::NonNull::new_unchecked(src_harness), - PhantomData, - )), + mem::ManuallyDrop::new(Harness(ptr::NonNull::new_unchecked(src_harness))), PhantomData, )) } @@ -762,10 +753,7 @@ impl Harness { None } else { Some(RefMut( - mem::ManuallyDrop::new(Harness( - ptr::NonNull::new_unchecked(sink_harness), - PhantomData, - )), + mem::ManuallyDrop::new(Harness(ptr::NonNull::new_unchecked(sink_harness))), PhantomData, )) } @@ -779,10 +767,7 @@ impl Harness { None } else { Some(RefMut( - mem::ManuallyDrop::new(Harness( - ptr::NonNull::new_unchecked(src_harness), - PhantomData, - )), + mem::ManuallyDrop::new(Harness(ptr::NonNull::new_unchecked(src_harness))), PhantomData, )) } diff --git a/gstreamer-video/src/video_codec_state.rs b/gstreamer-video/src/video_codec_state.rs index ba7087237..4bace6560 100644 --- a/gstreamer-video/src/video_codec_state.rs +++ b/gstreamer-video/src/video_codec_state.rs @@ -54,7 +54,6 @@ impl<'a> VideoCodecStateContext<'a> for Readable { pub struct VideoCodecState<'a, T: VideoCodecStateContext<'a>> { state: *mut gst_video_sys::GstVideoCodecState, pub(crate) context: T, - /* FIXME: should not be needed because lifetime is actually used */ phantom: PhantomData<&'a T>, } diff --git a/gstreamer/src/caps_features.rs b/gstreamer/src/caps_features.rs index 5348b4424..1ee2488f7 100644 --- a/gstreamer/src/caps_features.rs +++ b/gstreamer/src/caps_features.rs @@ -9,7 +9,6 @@ use std::borrow::{Borrow, BorrowMut, ToOwned}; use std::ffi::CStr; use std::fmt; -use std::marker::PhantomData; use std::mem; use std::ops::{Deref, DerefMut}; use std::ptr; @@ -26,7 +25,7 @@ use glib_sys::gpointer; use gobject_sys; use gst_sys; -pub struct CapsFeatures(ptr::NonNull, PhantomData); +pub struct CapsFeatures(ptr::NonNull); unsafe impl Send for CapsFeatures {} unsafe impl Sync for CapsFeatures {} @@ -45,24 +44,18 @@ impl CapsFeatures { pub fn new_empty() -> Self { assert_initialized_main_thread!(); unsafe { - CapsFeatures( - ptr::NonNull::new_unchecked( - gst_sys::gst_caps_features_new_empty() as *mut CapsFeaturesRef - ), - PhantomData, - ) + CapsFeatures(ptr::NonNull::new_unchecked( + gst_sys::gst_caps_features_new_empty() as *mut CapsFeaturesRef, + )) } } pub fn new_any() -> Self { assert_initialized_main_thread!(); unsafe { - CapsFeatures( - ptr::NonNull::new_unchecked( - gst_sys::gst_caps_features_new_any() as *mut CapsFeaturesRef - ), - PhantomData, - ) + CapsFeatures(ptr::NonNull::new_unchecked( + gst_sys::gst_caps_features_new_any() as *mut CapsFeaturesRef, + )) } } @@ -103,7 +96,7 @@ impl Clone for CapsFeatures { unsafe { let ptr = gst_sys::gst_caps_features_copy(&self.0.as_ref().0) as *mut CapsFeaturesRef; assert!(!ptr.is_null()); - CapsFeatures(ptr::NonNull::new_unchecked(ptr), PhantomData) + CapsFeatures(ptr::NonNull::new_unchecked(ptr)) } } } @@ -143,10 +136,9 @@ impl str::FromStr for CapsFeatures { )); } - Ok(CapsFeatures( - ptr::NonNull::new_unchecked(ptr as *mut CapsFeaturesRef), - PhantomData, - )) + Ok(CapsFeatures(ptr::NonNull::new_unchecked( + ptr as *mut CapsFeaturesRef, + ))) } } } @@ -206,10 +198,7 @@ impl FromGlibPtrNone<*const gst_sys::GstCapsFeatures> for CapsFeatures { assert!(!ptr.is_null()); let ptr = gst_sys::gst_caps_features_copy(ptr); assert!(!ptr.is_null()); - CapsFeatures( - ptr::NonNull::new_unchecked(ptr as *mut CapsFeaturesRef), - PhantomData, - ) + CapsFeatures(ptr::NonNull::new_unchecked(ptr as *mut CapsFeaturesRef)) } } @@ -218,30 +207,21 @@ impl FromGlibPtrNone<*mut gst_sys::GstCapsFeatures> for CapsFeatures { assert!(!ptr.is_null()); let ptr = gst_sys::gst_caps_features_copy(ptr); assert!(!ptr.is_null()); - CapsFeatures( - ptr::NonNull::new_unchecked(ptr as *mut CapsFeaturesRef), - PhantomData, - ) + CapsFeatures(ptr::NonNull::new_unchecked(ptr as *mut CapsFeaturesRef)) } } impl FromGlibPtrFull<*const gst_sys::GstCapsFeatures> for CapsFeatures { unsafe fn from_glib_full(ptr: *const gst_sys::GstCapsFeatures) -> Self { assert!(!ptr.is_null()); - CapsFeatures( - ptr::NonNull::new_unchecked(ptr as *mut CapsFeaturesRef), - PhantomData, - ) + CapsFeatures(ptr::NonNull::new_unchecked(ptr as *mut CapsFeaturesRef)) } } impl FromGlibPtrFull<*mut gst_sys::GstCapsFeatures> for CapsFeatures { unsafe fn from_glib_full(ptr: *mut gst_sys::GstCapsFeatures) -> Self { assert!(!ptr.is_null()); - CapsFeatures( - ptr::NonNull::new_unchecked(ptr as *mut CapsFeaturesRef), - PhantomData, - ) + CapsFeatures(ptr::NonNull::new_unchecked(ptr as *mut CapsFeaturesRef)) } } diff --git a/gstreamer/src/miniobject.rs b/gstreamer/src/miniobject.rs index 39a41d0d2..decef0252 100644 --- a/gstreamer/src/miniobject.rs +++ b/gstreamer/src/miniobject.rs @@ -11,7 +11,6 @@ macro_rules! gst_define_mini_object_wrapper( ($name:ident, $ref_name:ident, $gst_sys_name:path, $get_type:expr) => { pub struct $name { obj: ::std::ptr::NonNull<$ref_name>, - phantom: ::std::marker::PhantomData<$ref_name>, } #[repr(C)] @@ -26,7 +25,6 @@ macro_rules! gst_define_mini_object_wrapper( $name { obj: ::std::ptr::NonNull::new_unchecked(ptr as *mut $gst_sys_name as *mut $ref_name), - phantom: ::std::marker::PhantomData, } } @@ -36,7 +34,6 @@ macro_rules! gst_define_mini_object_wrapper( $name { obj: ::std::ptr::NonNull::new_unchecked(ptr as *mut $gst_sys_name as *mut $ref_name), - phantom: ::std::marker::PhantomData, } } @@ -46,7 +43,6 @@ macro_rules! gst_define_mini_object_wrapper( $crate::glib::translate::Borrowed::new($name { obj: ::std::ptr::NonNull::new_unchecked(ptr as *mut $gst_sys_name as *mut $ref_name), - phantom: ::std::marker::PhantomData, }) } diff --git a/gstreamer/src/structure.rs b/gstreamer/src/structure.rs index a2f839f32..c2fd3def0 100644 --- a/gstreamer/src/structure.rs +++ b/gstreamer/src/structure.rs @@ -9,7 +9,6 @@ use std::borrow::{Borrow, BorrowMut, ToOwned}; use std::ffi::CStr; use std::fmt; -use std::marker::PhantomData; use std::mem; use std::ops::{Deref, DerefMut}; use std::ptr; @@ -56,7 +55,7 @@ impl<'name> GetError<'name> { } } -pub struct Structure(ptr::NonNull, PhantomData); +pub struct Structure(ptr::NonNull); unsafe impl Send for Structure {} unsafe impl Sync for Structure {} @@ -71,7 +70,7 @@ impl Structure { unsafe { let ptr = gst_sys::gst_structure_new_empty(name.to_glib_none().0) as *mut StructureRef; assert!(!ptr.is_null()); - Structure(ptr::NonNull::new_unchecked(ptr), PhantomData) + Structure(ptr::NonNull::new_unchecked(ptr)) } } @@ -143,7 +142,7 @@ impl Clone for Structure { unsafe { let ptr = gst_sys::gst_structure_copy(&self.0.as_ref().0) as *mut StructureRef; assert!(!ptr.is_null()); - Structure(ptr::NonNull::new_unchecked(ptr), PhantomData) + Structure(ptr::NonNull::new_unchecked(ptr)) } } } @@ -192,10 +191,9 @@ impl str::FromStr for Structure { if structure.is_null() { Err(glib_bool_error!("Failed to parse structure from string")) } else { - Ok(Structure( - ptr::NonNull::new_unchecked(structure as *mut StructureRef), - PhantomData, - )) + Ok(Structure(ptr::NonNull::new_unchecked( + structure as *mut StructureRef, + ))) } } } @@ -220,7 +218,7 @@ impl ToOwned for StructureRef { unsafe { let ptr = gst_sys::gst_structure_copy(&self.0) as *mut StructureRef; assert!(!ptr.is_null()); - Structure(ptr::NonNull::new_unchecked(ptr), PhantomData) + Structure(ptr::NonNull::new_unchecked(ptr)) } } } @@ -268,10 +266,7 @@ impl FromGlibPtrNone<*const gst_sys::GstStructure> for Structure { assert!(!ptr.is_null()); let ptr = gst_sys::gst_structure_copy(ptr); assert!(!ptr.is_null()); - Structure( - ptr::NonNull::new_unchecked(ptr as *mut StructureRef), - PhantomData, - ) + Structure(ptr::NonNull::new_unchecked(ptr as *mut StructureRef)) } } @@ -280,30 +275,21 @@ impl FromGlibPtrNone<*mut gst_sys::GstStructure> for Structure { assert!(!ptr.is_null()); let ptr = gst_sys::gst_structure_copy(ptr); assert!(!ptr.is_null()); - Structure( - ptr::NonNull::new_unchecked(ptr as *mut StructureRef), - PhantomData, - ) + Structure(ptr::NonNull::new_unchecked(ptr as *mut StructureRef)) } } impl FromGlibPtrFull<*const gst_sys::GstStructure> for Structure { unsafe fn from_glib_full(ptr: *const gst_sys::GstStructure) -> Self { assert!(!ptr.is_null()); - Structure( - ptr::NonNull::new_unchecked(ptr as *mut StructureRef), - PhantomData, - ) + Structure(ptr::NonNull::new_unchecked(ptr as *mut StructureRef)) } } impl FromGlibPtrFull<*mut gst_sys::GstStructure> for Structure { unsafe fn from_glib_full(ptr: *mut gst_sys::GstStructure) -> Self { assert!(!ptr.is_null()); - Structure( - ptr::NonNull::new_unchecked(ptr as *mut StructureRef), - PhantomData, - ) + Structure(ptr::NonNull::new_unchecked(ptr as *mut StructureRef)) } } diff --git a/gstreamer/src/typefind.rs b/gstreamer/src/typefind.rs index 00651aee0..8a4f58de5 100644 --- a/gstreamer/src/typefind.rs +++ b/gstreamer/src/typefind.rs @@ -16,13 +16,12 @@ use TypeFindProbability; use glib; use glib::translate::*; use glib_sys; -use std::marker::PhantomData; use std::ptr; use std::slice; #[repr(C)] #[derive(Debug)] -pub struct TypeFind<'a>(gst_sys::GstTypeFind, PhantomData<&'a ()>); +pub struct TypeFind(gst_sys::GstTypeFind); pub trait TypeFindImpl { fn peek(&mut self, offset: i64, size: u32) -> Option<&[u8]>; @@ -32,7 +31,7 @@ pub trait TypeFindImpl { } } -impl<'a> TypeFind<'a> { +impl TypeFind { pub fn register( plugin: Option<&Plugin>, name: &str,