Skip to content

Commit

Permalink
Fix CI issues arising from use of Rust 1.64 (#6067)
Browse files Browse the repository at this point in the history
## Objective

Fixes #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)`.
  • Loading branch information
targrub committed Sep 22, 2022
1 parent dc5836f commit a09dd03
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions crates/bevy_ecs/src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ impl ComponentDescriptor {
is_send_and_sync: true,
type_id: Some(TypeId::of::<T>()),
layout: Layout::new::<T>(),
drop: needs_drop::<T>().then(|| Self::drop_ptr::<T> as _),
drop: needs_drop::<T>().then_some(Self::drop_ptr::<T> as _),
}
}

Expand Down Expand Up @@ -331,7 +331,7 @@ impl ComponentDescriptor {
is_send_and_sync: true,
type_id: Some(TypeId::of::<T>()),
layout: Layout::new::<T>(),
drop: needs_drop::<T>().then(|| Self::drop_ptr::<T> as _),
drop: needs_drop::<T>().then_some(Self::drop_ptr::<T> as _),
}
}

Expand All @@ -342,7 +342,7 @@ impl ComponentDescriptor {
is_send_and_sync: false,
type_id: Some(TypeId::of::<T>()),
layout: Layout::new::<T>(),
drop: needs_drop::<T>().then(|| Self::drop_ptr::<T> as _),
drop: needs_drop::<T>().then_some(Self::drop_ptr::<T> as _),
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/entity/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ error[E0277]: the trait bound `bevy_ecs::query::Changed<Foo>: 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<Foo>, bevy_ecs::query::With<Bar>)>`
= note: required because of the requirements on the impl of `ExactSizeIterator` for `QueryCombinationIter<'_, '_, &Foo, bevy_ecs::query::Or<(bevy_ecs::query::Changed<Foo>, bevy_ecs::query::With<Bar>)>, 2_usize>`
= note: required because of the requirements on the impl of `ExactSizeIterator` for `QueryCombinationIter<'_, '_, &Foo, bevy_ecs::query::Or<(bevy_ecs::query::Changed<Foo>, bevy_ecs::query::With<Bar>)>, 2>`
note: required by a bound in `is_exact_size_iterator`
--> tests/ui/query_combin_exact_sized_iterator_safety.rs:18:30
|
Expand All @@ -43,7 +43,7 @@ error[E0277]: the trait bound `bevy_ecs::query::Added<Foo>: 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<Foo>, bevy_ecs::query::Without<Bar>)`
= note: required because of the requirements on the impl of `ExactSizeIterator` for `QueryCombinationIter<'_, '_, &Foo, (bevy_ecs::query::Added<Foo>, bevy_ecs::query::Without<Bar>), 2_usize>`
= note: required because of the requirements on the impl of `ExactSizeIterator` for `QueryCombinationIter<'_, '_, &Foo, (bevy_ecs::query::Added<Foo>, bevy_ecs::query::Without<Bar>), 2>`
note: required by a bound in `is_exact_size_iterator`
--> tests/ui/query_combin_exact_sized_iterator_safety.rs:18:30
|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<bevy_ecs::entity::Entity, 1_usize>>`
= note: required because of the requirements on the impl of `Iterator` for `QueryManyIter<'_, '_, &mut A, (), std::array::IntoIter<bevy_ecs::entity::Entity, 1>>`
note: required by a bound in `is_iterator`
--> tests/ui/query_iter_many_mut_iterator_safety.rs:13:19
|
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_window/src/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion tools/build-example-pages/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ fn parse_examples(panic_on_missing: bool) -> Vec<Example> {
.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;
Expand Down

0 comments on commit a09dd03

Please sign in to comment.