From a09dd034a2695dec504fbe45c4441cc459c9b08d Mon Sep 17 00:00:00 2001 From: targrub Date: Thu, 22 Sep 2022 16:56:43 +0000 Subject: [PATCH] Fix CI issues arising from use of Rust 1.64 (#6067) ## Objective Fixes https://github.com/bevyengine/bevy/issues/6063 ## Solution - Use `then_some(x)` instead of `then( || x)`. - Updated error logs from `bevy_ecs_compile_fail_tests`. ## Migration Guide From Rust 1.63 to 1.64, a new Clippy error was added; now one should use `then_some(x)` instead of `then( || x)`. --- crates/bevy_ecs/src/component.rs | 6 +++--- crates/bevy_ecs/src/entity/mod.rs | 2 +- .../ui/query_combin_exact_sized_iterator_safety.stderr | 4 ++-- .../ui/query_iter_combinations_mut_iterator_safety.stderr | 2 +- .../tests/ui/query_iter_many_mut_iterator_safety.stderr | 2 +- crates/bevy_window/src/system.rs | 2 +- tools/build-example-pages/src/main.rs | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/bevy_ecs/src/component.rs b/crates/bevy_ecs/src/component.rs index eb379934efed4..c59a1e2028737 100644 --- a/crates/bevy_ecs/src/component.rs +++ b/crates/bevy_ecs/src/component.rs @@ -294,7 +294,7 @@ impl ComponentDescriptor { is_send_and_sync: true, type_id: Some(TypeId::of::()), layout: Layout::new::(), - drop: needs_drop::().then(|| Self::drop_ptr:: as _), + drop: needs_drop::().then_some(Self::drop_ptr:: as _), } } @@ -331,7 +331,7 @@ impl ComponentDescriptor { is_send_and_sync: true, type_id: Some(TypeId::of::()), layout: Layout::new::(), - drop: needs_drop::().then(|| Self::drop_ptr:: as _), + drop: needs_drop::().then_some(Self::drop_ptr:: as _), } } @@ -342,7 +342,7 @@ impl ComponentDescriptor { is_send_and_sync: false, type_id: Some(TypeId::of::()), layout: Layout::new::(), - drop: needs_drop::().then(|| Self::drop_ptr:: as _), + drop: needs_drop::().then_some(Self::drop_ptr:: as _), } } diff --git a/crates/bevy_ecs/src/entity/mod.rs b/crates/bevy_ecs/src/entity/mod.rs index 6ccf5a2150673..2d2f8592189db 100644 --- a/crates/bevy_ecs/src/entity/mod.rs +++ b/crates/bevy_ecs/src/entity/mod.rs @@ -547,7 +547,7 @@ impl Entities { // If this entity was manually created, then free_cursor might be positive // Returning None handles that case correctly let num_pending = usize::try_from(-free_cursor).ok()?; - (idu < self.meta.len() + num_pending).then(|| Entity { generation: 0, id }) + (idu < self.meta.len() + num_pending).then_some(Entity { generation: 0, id }) } } diff --git a/crates/bevy_ecs_compile_fail_tests/tests/ui/query_combin_exact_sized_iterator_safety.stderr b/crates/bevy_ecs_compile_fail_tests/tests/ui/query_combin_exact_sized_iterator_safety.stderr index 3de9d2c0897d7..62056278cd9c7 100644 --- a/crates/bevy_ecs_compile_fail_tests/tests/ui/query_combin_exact_sized_iterator_safety.stderr +++ b/crates/bevy_ecs_compile_fail_tests/tests/ui/query_combin_exact_sized_iterator_safety.stderr @@ -17,7 +17,7 @@ error[E0277]: the trait bound `bevy_ecs::query::Changed: ArchetypeFilter` i (F0, F1, F2, F3, F4, F5, F6, F7) and 26 others = note: required because of the requirements on the impl of `ArchetypeFilter` for `bevy_ecs::query::Or<(bevy_ecs::query::Changed, bevy_ecs::query::With)>` - = note: required because of the requirements on the impl of `ExactSizeIterator` for `QueryCombinationIter<'_, '_, &Foo, bevy_ecs::query::Or<(bevy_ecs::query::Changed, bevy_ecs::query::With)>, 2_usize>` + = note: required because of the requirements on the impl of `ExactSizeIterator` for `QueryCombinationIter<'_, '_, &Foo, bevy_ecs::query::Or<(bevy_ecs::query::Changed, bevy_ecs::query::With)>, 2>` note: required by a bound in `is_exact_size_iterator` --> tests/ui/query_combin_exact_sized_iterator_safety.rs:18:30 | @@ -43,7 +43,7 @@ error[E0277]: the trait bound `bevy_ecs::query::Added: ArchetypeFilter` is (F0, F1, F2, F3, F4, F5, F6, F7) and 26 others = note: required because of the requirements on the impl of `ArchetypeFilter` for `(bevy_ecs::query::Added, bevy_ecs::query::Without)` - = note: required because of the requirements on the impl of `ExactSizeIterator` for `QueryCombinationIter<'_, '_, &Foo, (bevy_ecs::query::Added, bevy_ecs::query::Without), 2_usize>` + = note: required because of the requirements on the impl of `ExactSizeIterator` for `QueryCombinationIter<'_, '_, &Foo, (bevy_ecs::query::Added, bevy_ecs::query::Without), 2>` note: required by a bound in `is_exact_size_iterator` --> tests/ui/query_combin_exact_sized_iterator_safety.rs:18:30 | diff --git a/crates/bevy_ecs_compile_fail_tests/tests/ui/query_iter_combinations_mut_iterator_safety.stderr b/crates/bevy_ecs_compile_fail_tests/tests/ui/query_iter_combinations_mut_iterator_safety.stderr index 7cd36eadcff93..d374bf6f64cba 100644 --- a/crates/bevy_ecs_compile_fail_tests/tests/ui/query_iter_combinations_mut_iterator_safety.stderr +++ b/crates/bevy_ecs_compile_fail_tests/tests/ui/query_iter_combinations_mut_iterator_safety.stderr @@ -17,7 +17,7 @@ error[E0277]: the trait bound `&mut A: ReadOnlyWorldQuery` is not satisfied (F0, F1, F2, F3, F4, F5, F6) and 49 others = note: `ReadOnlyWorldQuery` is implemented for `&A`, but not for `&mut A` - = note: required because of the requirements on the impl of `Iterator` for `QueryCombinationIter<'_, '_, &mut A, (), {_: usize}>` + = note: required because of the requirements on the impl of `Iterator` for `QueryCombinationIter<'_, '_, &mut A, (), _>` note: required by a bound in `is_iterator` --> tests/ui/query_iter_combinations_mut_iterator_safety.rs:13:19 | diff --git a/crates/bevy_ecs_compile_fail_tests/tests/ui/query_iter_many_mut_iterator_safety.stderr b/crates/bevy_ecs_compile_fail_tests/tests/ui/query_iter_many_mut_iterator_safety.stderr index 45840aa3230be..b5662900ee7e6 100644 --- a/crates/bevy_ecs_compile_fail_tests/tests/ui/query_iter_many_mut_iterator_safety.stderr +++ b/crates/bevy_ecs_compile_fail_tests/tests/ui/query_iter_many_mut_iterator_safety.stderr @@ -17,7 +17,7 @@ error[E0277]: the trait bound `&mut A: ReadOnlyWorldQuery` is not satisfied (F0, F1, F2, F3, F4, F5, F6) and 49 others = note: `ReadOnlyWorldQuery` is implemented for `&A`, but not for `&mut A` - = note: required because of the requirements on the impl of `Iterator` for `QueryManyIter<'_, '_, &mut A, (), std::array::IntoIter>` + = note: required because of the requirements on the impl of `Iterator` for `QueryManyIter<'_, '_, &mut A, (), std::array::IntoIter>` note: required by a bound in `is_iterator` --> tests/ui/query_iter_many_mut_iterator_safety.rs:13:19 | diff --git a/crates/bevy_window/src/system.rs b/crates/bevy_window/src/system.rs index 45a374fe2e09d..6cb17b877ab8f 100644 --- a/crates/bevy_window/src/system.rs +++ b/crates/bevy_window/src/system.rs @@ -44,7 +44,7 @@ pub fn close_on_esc( ) { // TODO: Track this in e.g. a resource to ensure consistent behaviour across similar systems for event in focused_events.iter() { - *focused = event.focused.then(|| event.id); + *focused = event.focused.then_some(event.id); } if let Some(focused) = &*focused { diff --git a/tools/build-example-pages/src/main.rs b/tools/build-example-pages/src/main.rs index b64530a97bc9c..f480cc788a29b 100644 --- a/tools/build-example-pages/src/main.rs +++ b/tools/build-example-pages/src/main.rs @@ -112,7 +112,7 @@ fn parse_examples(panic_on_missing: bool) -> Vec { .get(&technical_name) .and_then(|metadata| metadata.get("hidden")) .and_then(|hidden| hidden.as_bool()) - .and_then(|hidden| hidden.then(|| ())) + .and_then(|hidden| hidden.then_some(())) .is_some() { return None;