Skip to content

Commit

Permalink
fix: mark all std::boxed::Box returns with #[allow(clippy::unnecessar…
Browse files Browse the repository at this point in the history
…y_box_returns)], and updated tests
  • Loading branch information
kristof-mattei authored and ahayzen-kdab committed Nov 25, 2024
1 parent f55c006 commit f5afefe
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions crates/cxx-qt-gen/src/generator/rust/constructor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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<MyObjectRust>
{
std::boxed::Box::new(core::default::Default::default())
Expand Down Expand Up @@ -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<MyObjectRust> {
std::boxed::Box::new(
<qobject::MyObject as cxx_qt::Constructor<()> >::new(())
Expand Down Expand Up @@ -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<MyObjectRust> {
std::boxed::Box::new(
<qobject::MyObject as cxx_qt::Constructor<(*const QObject,)> >::new(
Expand Down
1 change: 1 addition & 0 deletions crates/cxx-qt-gen/test_outputs/inheritance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ impl cxx_qt::Upcast<inheritance::QAbstractItemModel> 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<MyObjectRust> {
std::boxed::Box::new(core::default::Default::default())
}
Expand Down
2 changes: 2 additions & 0 deletions crates/cxx-qt-gen/test_outputs/invokables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<MyObjectRust> {
Expand Down Expand Up @@ -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<MyObjectRust> {
Expand Down
3 changes: 3 additions & 0 deletions crates/cxx-qt-gen/test_outputs/passthrough_and_naming.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<MyObjectRust> {
std::boxed::Box::new(core::default::Default::default())
}
Expand Down Expand Up @@ -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<SecondObjectRust> {
std::boxed::Box::new(core::default::Default::default())
}
Expand All @@ -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<ThirdObjectRust> {
std::boxed::Box::new(core::default::Default::default())
}
Expand Down
1 change: 1 addition & 0 deletions crates/cxx-qt-gen/test_outputs/properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<MyObjectRust> {
std::boxed::Box::new(core::default::Default::default())
}
Expand Down
2 changes: 2 additions & 0 deletions crates/cxx-qt-gen/test_outputs/qenum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ mod ffi {
}
}
#[doc(hidden)]
#[allow(clippy::unnecessary_box_returns)]
pub fn create_rs_MyObjectRust() -> std::boxed::Box<MyObjectRust> {
std::boxed::Box::new(core::default::Default::default())
}
Expand All @@ -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<InternalObject> {
std::boxed::Box::new(core::default::Default::default())
}
Expand Down
1 change: 1 addition & 0 deletions crates/cxx-qt-gen/test_outputs/signals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<MyObjectRust> {
std::boxed::Box::new(core::default::Default::default())
}
Expand Down

0 comments on commit f5afefe

Please sign in to comment.