From f5afefecf837e199848b99d3317a623a64767c5a Mon Sep 17 00:00:00 2001 From: Kristof Mattei <864376+Kristof-Mattei@users.noreply.github.com> Date: Fri, 15 Nov 2024 09:23:06 -0700 Subject: [PATCH] fix: mark all std::boxed::Box returns with #[allow(clippy::unnecessary_box_returns)], and updated tests --- crates/cxx-qt-gen/src/generator/rust/constructor.rs | 4 ++++ crates/cxx-qt-gen/test_outputs/inheritance.rs | 1 + crates/cxx-qt-gen/test_outputs/invokables.rs | 2 ++ crates/cxx-qt-gen/test_outputs/passthrough_and_naming.rs | 3 +++ crates/cxx-qt-gen/test_outputs/properties.rs | 1 + crates/cxx-qt-gen/test_outputs/qenum.rs | 2 ++ crates/cxx-qt-gen/test_outputs/signals.rs | 1 + 7 files changed, 14 insertions(+) diff --git a/crates/cxx-qt-gen/src/generator/rust/constructor.rs b/crates/cxx-qt-gen/src/generator/rust/constructor.rs index 76d6b911c..02e8875a4 100644 --- a/crates/cxx-qt-gen/src/generator/rust/constructor.rs +++ b/crates/cxx-qt-gen/src/generator/rust/constructor.rs @@ -406,6 +406,7 @@ pub fn generate( #[doc(hidden)] #[allow(unused_variables)] #[allow(clippy::extra_unused_lifetimes)] + #[allow(clippy::unnecessary_box_returns)] // If we use the lifetime here for casting to the specific Constructor type, then // clippy for some reason thinks that the lifetime is unused even though it is used // by the `as` expression. @@ -492,6 +493,7 @@ mod tests { &blocks.cxx_qt_mod_contents[0], quote! { #[doc(hidden)] + #[allow(clippy::unnecessary_box_returns)] pub fn create_rs_MyObjectRust() -> std::boxed::Box { std::boxed::Box::new(core::default::Default::default()) @@ -600,6 +602,7 @@ mod tests { #[doc(hidden)] #[allow(unused_variables)] #[allow(clippy::extra_unused_lifetimes)] + #[allow(clippy::unnecessary_box_returns)] pub fn new_rs_MyObject_0(new_arguments: qobject::CxxQtConstructorNewArgumentsMyObject0) -> std::boxed::Box { std::boxed::Box::new( >::new(()) @@ -733,6 +736,7 @@ mod tests { #[doc(hidden)] #[allow(unused_variables)] #[allow(clippy::extra_unused_lifetimes)] + #[allow(clippy::unnecessary_box_returns)] pub fn new_rs_MyObject_1(new_arguments: qobject::CxxQtConstructorNewArgumentsMyObject1) -> std::boxed::Box { std::boxed::Box::new( >::new( diff --git a/crates/cxx-qt-gen/test_outputs/inheritance.rs b/crates/cxx-qt-gen/test_outputs/inheritance.rs index c6d03b9a5..0218031e2 100644 --- a/crates/cxx-qt-gen/test_outputs/inheritance.rs +++ b/crates/cxx-qt-gen/test_outputs/inheritance.rs @@ -84,6 +84,7 @@ impl cxx_qt::Upcast for inheritance::MyObject { #[allow(dead_code)] use inheritance::QAbstractItemModel as _; #[doc(hidden)] +#[allow(clippy::unnecessary_box_returns)] pub fn create_rs_MyObjectRust() -> std::boxed::Box { std::boxed::Box::new(core::default::Default::default()) } diff --git a/crates/cxx-qt-gen/test_outputs/invokables.rs b/crates/cxx-qt-gen/test_outputs/invokables.rs index 19fcecefb..1a26d2705 100644 --- a/crates/cxx-qt-gen/test_outputs/invokables.rs +++ b/crates/cxx-qt-gen/test_outputs/invokables.rs @@ -324,6 +324,7 @@ pub fn route_arguments_MyObject_0<'a>( #[doc(hidden)] #[allow(unused_variables)] #[allow(clippy::extra_unused_lifetimes)] +#[allow(clippy::unnecessary_box_returns)] pub fn new_rs_MyObject_0<'a>( new_arguments: ffi::CxxQtConstructorNewArgumentsMyObject0<'a>, ) -> std::boxed::Box { @@ -356,6 +357,7 @@ pub fn route_arguments_MyObject_1() -> ffi::CxxQtConstructorArgumentsMyObject1 { #[doc(hidden)] #[allow(unused_variables)] #[allow(clippy::extra_unused_lifetimes)] +#[allow(clippy::unnecessary_box_returns)] pub fn new_rs_MyObject_1( new_arguments: ffi::CxxQtConstructorNewArgumentsMyObject1, ) -> std::boxed::Box { diff --git a/crates/cxx-qt-gen/test_outputs/passthrough_and_naming.rs b/crates/cxx-qt-gen/test_outputs/passthrough_and_naming.rs index 31b9eab10..ac3b9af56 100644 --- a/crates/cxx-qt-gen/test_outputs/passthrough_and_naming.rs +++ b/crates/cxx-qt-gen/test_outputs/passthrough_and_naming.rs @@ -591,6 +591,7 @@ cxx_qt::static_assertions::assert_eq_size!( [usize; 2] ); #[doc(hidden)] +#[allow(clippy::unnecessary_box_returns)] pub fn create_rs_MyObjectRust() -> std::boxed::Box { std::boxed::Box::new(core::default::Default::default()) } @@ -756,6 +757,7 @@ cxx_qt::static_assertions::assert_eq_size!( [usize; 2] ); #[doc(hidden)] +#[allow(clippy::unnecessary_box_returns)] pub fn create_rs_SecondObjectRust() -> std::boxed::Box { std::boxed::Box::new(core::default::Default::default()) } @@ -775,6 +777,7 @@ impl ::cxx_qt::CxxQtType for ffi::SecondObject { } } #[doc(hidden)] +#[allow(clippy::unnecessary_box_returns)] pub fn create_rs_ThirdObjectRust() -> std::boxed::Box { std::boxed::Box::new(core::default::Default::default()) } diff --git a/crates/cxx-qt-gen/test_outputs/properties.rs b/crates/cxx-qt-gen/test_outputs/properties.rs index 67e1428d7..6104617d2 100644 --- a/crates/cxx-qt-gen/test_outputs/properties.rs +++ b/crates/cxx-qt-gen/test_outputs/properties.rs @@ -1038,6 +1038,7 @@ cxx_qt::static_assertions::assert_eq_size!( [usize; 2] ); #[doc(hidden)] +#[allow(clippy::unnecessary_box_returns)] pub fn create_rs_MyObjectRust() -> std::boxed::Box { std::boxed::Box::new(core::default::Default::default()) } diff --git a/crates/cxx-qt-gen/test_outputs/qenum.rs b/crates/cxx-qt-gen/test_outputs/qenum.rs index c976803f6..a5b809157 100644 --- a/crates/cxx-qt-gen/test_outputs/qenum.rs +++ b/crates/cxx-qt-gen/test_outputs/qenum.rs @@ -145,6 +145,7 @@ mod ffi { } } #[doc(hidden)] +#[allow(clippy::unnecessary_box_returns)] pub fn create_rs_MyObjectRust() -> std::boxed::Box { std::boxed::Box::new(core::default::Default::default()) } @@ -164,6 +165,7 @@ impl ::cxx_qt::CxxQtType for ffi::MyObject { } } #[doc(hidden)] +#[allow(clippy::unnecessary_box_returns)] pub fn create_rs_InternalObject() -> std::boxed::Box { std::boxed::Box::new(core::default::Default::default()) } diff --git a/crates/cxx-qt-gen/test_outputs/signals.rs b/crates/cxx-qt-gen/test_outputs/signals.rs index da9053f16..c0091df81 100644 --- a/crates/cxx-qt-gen/test_outputs/signals.rs +++ b/crates/cxx-qt-gen/test_outputs/signals.rs @@ -429,6 +429,7 @@ cxx_qt::static_assertions::assert_eq_size!( [usize; 2] ); #[doc(hidden)] +#[allow(clippy::unnecessary_box_returns)] pub fn create_rs_MyObjectRust() -> std::boxed::Box { std::boxed::Box::new(core::default::Default::default()) }