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

Don't cast callbacks as &Box<T> but use &T instead to make clippy… #1618

Merged
merged 1 commit into from
Nov 15, 2024

Conversation

sdroege
Copy link
Member

@sdroege sdroege commented Nov 15, 2024

… happy


error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
   --> gstreamer-rtsp-server/src/auto/rtsp_stream_transport.rs:178:27
    |
178 |             let callback: &Box_<(P, Q)> = &*(user_data as *mut _);
    |                           ^^^^^^^^^^^^^ help: try: `&(P, Q)`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#borrowed_box
    = note: `-D clippy::borrowed-box` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(clippy::borrowed_box)]`
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
   --> gstreamer-rtsp-server/src/auto/rtsp_stream_transport.rs:193:27
    |
193 |             let callback: &Box_<(P, Q)> = &*(user_data as *mut _);
    |                           ^^^^^^^^^^^^^ help: try: `&(P, Q)`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#borrowed_box

@sdroege
Copy link
Member Author

sdroege commented Nov 15, 2024

Causes no changes in gtk-rs-core / gtk4-rs.

@sdroege sdroege merged commit 63aaa63 into gtk-rs:main Nov 15, 2024
7 checks passed
@sdroege sdroege deleted the callbacks-no-box-reference branch November 15, 2024 10:50
@sdroege
Copy link
Member Author

sdroege commented Nov 15, 2024

Of course that was not correct 🙄

diff --git a/gstreamer-rtsp-server/src/auto/rtsp_stream_transport.rs b/gstreamer-rtsp-server/src/auto/rtsp_stream_transport.rs
index 7defca6f8..486134753 100644
--- a/gstreamer-rtsp-server/src/auto/rtsp_stream_transport.rs
+++ b/gstreamer-rtsp-server/src/auto/rtsp_stream_transport.rs
@@ -175,7 +175,7 @@ pub trait RTSPStreamTransportExt: IsA<RTSPStreamTransport> + 'static {
             user_data: glib::ffi::gpointer,
         ) -> glib::ffi::gboolean {
             let buffer = from_glib_borrow(buffer);
-            let callback: &Box_<(P, Q)> = &*(user_data as *mut _);
+            let callback: &(P, Q) = &*(user_data as *mut _);
             let callback = &callback.0;
             (*callback)(&buffer, channel).into_glib()
         }
@@ -190,7 +190,7 @@ pub trait RTSPStreamTransportExt: IsA<RTSPStreamTransport> + 'static {
             user_data: glib::ffi::gpointer,
         ) -> glib::ffi::gboolean {
             let buffer = from_glib_borrow(buffer);
-            let callback: &Box_<(P, Q)> = &*(user_data as *mut _);
+            let callback: &(P, Q) = &*(user_data as *mut _);
             let callback = &callback.1;
             (*callback)(&buffer, channel).into_glib()
         }
@@ -201,10 +201,10 @@ pub trait RTSPStreamTransportExt: IsA<RTSPStreamTransport> + 'static {
         >(
             data: glib::ffi::gpointer,
         ) {
-            let _callback: Box_<(P, Q)> = Box_::from_raw(data as *mut _);
+            let _callback: &(P, Q) = Box_::from_raw(data as *mut _);
         }
         let destroy_call4 = Some(notify_func::<P, Q> as _);
-        let super_callback0: Box_<(P, Q)> = Box_::new((send_rtp_data, send_rtcp_data));
+        let super_callback0: &(P, Q) = Box_::new((send_rtp_data, send_rtcp_data));
         unsafe {
             ffi::gst_rtsp_stream_transport_set_callbacks(
                 self.as_ref().to_glib_none().0,

@sdroege
Copy link
Member Author

sdroege commented Nov 15, 2024

#1619

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants