Skip to content

Commit

Permalink
Fix CI for Rust 1.72 (#9562)
Browse files Browse the repository at this point in the history
# Objective

[Rust 1.72.0](https://blog.rust-lang.org/2023/08/24/Rust-1.72.0.html) is
now stable.

# Notes

- `let-else` formatting has arrived!
- I chose to allow `explicit_iter_loop` due to
rust-lang/rust-clippy#11074.
  
We didn't hit any of the false positives that prevent compilation, but
fixing this did produce a lot of the "symbol soup" mentioned, e.g. `for
image in &mut *image_events {`.
  
  Happy to undo this if there's consensus the other way.

---------

Co-authored-by: François <mockersf@gmail.com>
  • Loading branch information
rparrett and mockersf authored Aug 25, 2023
1 parent b88ff15 commit a788e31
Show file tree
Hide file tree
Showing 46 changed files with 235 additions and 159 deletions.
16 changes: 12 additions & 4 deletions crates/bevy_animation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,13 @@ fn verify_no_ancestor_player(
player_parent: Option<&Parent>,
parents: &Query<(Option<With<AnimationPlayer>>, Option<&Parent>)>,
) -> bool {
let Some(mut current) = player_parent.map(Parent::get) else { return true };
let Some(mut current) = player_parent.map(Parent::get) else {
return true;
};
loop {
let Ok((maybe_player, parent)) = parents.get(current) else { return true };
let Ok((maybe_player, parent)) = parents.get(current) else {
return true;
};
if maybe_player.is_some() {
return false;
}
Expand Down Expand Up @@ -506,7 +510,9 @@ fn apply_animation(
for (path, bone_id) in &animation_clip.paths {
let cached_path = &mut animation.path_cache[*bone_id];
let curves = animation_clip.get_curves(*bone_id).unwrap();
let Some(target) = entity_from_path(root, path, children, names, cached_path) else { continue };
let Some(target) = entity_from_path(root, path, children, names, cached_path) else {
continue;
};
// SAFETY: The verify_no_ancestor_player check above ensures that two animation players cannot alias
// any of their descendant Transforms.
//
Expand All @@ -519,7 +525,9 @@ fn apply_animation(
// This means only the AnimationPlayers closest to the root of the hierarchy will be able
// to run their animation. Any players in the children or descendants will log a warning
// and do nothing.
let Ok(mut transform) = (unsafe { transforms.get_unchecked(target) }) else { continue };
let Ok(mut transform) = (unsafe { transforms.get_unchecked(target) }) else {
continue;
};
let mut morphs = unsafe { morphs.get_unchecked(target) };
for curve in curves {
// Some curves have only one keyframe used to set a transform
Expand Down
14 changes: 10 additions & 4 deletions crates/bevy_asset/src/asset_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,8 @@ mod test {
let asset_server = setup(".");
asset_server.add_loader(FakePngLoader);

let Ok(MaybeAssetLoader::Ready(t)) = asset_server.get_path_asset_loader("test.png", true) else {
let Ok(MaybeAssetLoader::Ready(t)) = asset_server.get_path_asset_loader("test.png", true)
else {
panic!();
};

Expand All @@ -802,7 +803,8 @@ mod test {
let asset_server = setup(".");
asset_server.add_loader(FakePngLoader);

let Ok(MaybeAssetLoader::Ready(t)) = asset_server.get_path_asset_loader("test.PNG", true) else {
let Ok(MaybeAssetLoader::Ready(t)) = asset_server.get_path_asset_loader("test.PNG", true)
else {
panic!();
};
assert_eq!(t.extensions()[0], "png");
Expand Down Expand Up @@ -855,7 +857,9 @@ mod test {
let asset_server = setup(".");
asset_server.add_loader(FakePngLoader);

let Ok(MaybeAssetLoader::Ready(t)) = asset_server.get_path_asset_loader("test-v1.2.3.png", true) else {
let Ok(MaybeAssetLoader::Ready(t)) =
asset_server.get_path_asset_loader("test-v1.2.3.png", true)
else {
panic!();
};
assert_eq!(t.extensions()[0], "png");
Expand All @@ -866,7 +870,9 @@ mod test {
let asset_server = setup(".");
asset_server.add_loader(FakeMultipleDotLoader);

let Ok(MaybeAssetLoader::Ready(t)) = asset_server.get_path_asset_loader("test.test.png", true) else {
let Ok(MaybeAssetLoader::Ready(t)) =
asset_server.get_path_asset_loader("test.test.png", true)
else {
panic!();
};
assert_eq!(t.extensions()[0], "test.png");
Expand Down
4 changes: 3 additions & 1 deletion crates/bevy_asset/src/io/file_asset_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,9 @@ pub fn filesystem_watcher_system(
} = event
{
for path in &paths {
let Some(set) = watcher.path_map.get(path) else {continue};
let Some(set) = watcher.path_map.get(path) else {
continue;
};
for to_reload in set {
// When an asset is modified, note down the timestamp (overriding any previous modification events)
changed.insert(to_reload.to_owned(), Instant::now());
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_core_pipeline/src/blit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ impl Plugin for BlitPlugin {

fn finish(&self, app: &mut App) {
let Ok(render_app) = app.get_sub_app_mut(RenderApp) else {
return
return;
};

render_app
Expand Down
5 changes: 4 additions & 1 deletion crates/bevy_core_pipeline/src/bloom/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,10 @@ impl ViewNode for BloomNode {
pipeline_cache.get_render_pipeline(downsampling_pipeline_ids.main),
pipeline_cache.get_render_pipeline(upsampling_pipeline_ids.id_main),
pipeline_cache.get_render_pipeline(upsampling_pipeline_ids.id_final),
) else { return Ok(()) };
)
else {
return Ok(());
};

render_context.command_encoder().push_debug_group("bloom");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,15 @@ impl Node for CASNode {
let sharpening_pipeline = world.resource::<CASPipeline>();
let uniforms = world.resource::<ComponentUniforms<CASUniform>>();

let Ok((target, pipeline, uniform_index)) = self.query.get_manual(world, view_entity) else { return Ok(()) };
let Ok((target, pipeline, uniform_index)) = self.query.get_manual(world, view_entity)
else {
return Ok(());
};

let uniforms_id = uniforms.buffer().unwrap().id();
let Some(uniforms) = uniforms.binding() else { return Ok(()) };
let Some(uniforms) = uniforms.binding() else {
return Ok(());
};

let pipeline = pipeline_cache.get_render_pipeline(pipeline.0).unwrap();

Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_core_pipeline/src/msaa_writeback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub struct MsaaWritebackPlugin;
impl Plugin for MsaaWritebackPlugin {
fn build(&self, app: &mut App) {
let Ok(render_app) = app.get_sub_app_mut(RenderApp) else {
return
return;
};

render_app.add_systems(
Expand Down
14 changes: 7 additions & 7 deletions crates/bevy_core_pipeline/src/taa/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ impl Plugin for TemporalAntiAliasPlugin {
app.insert_resource(Msaa::Off)
.register_type::<TemporalAntiAliasSettings>();

let Ok(render_app) = app.get_sub_app_mut(RenderApp) else { return };
let Ok(render_app) = app.get_sub_app_mut(RenderApp) else {
return;
};

render_app
.init_resource::<SpecializedRenderPipelines<TAAPipeline>>()
Expand Down Expand Up @@ -86,7 +88,9 @@ impl Plugin for TemporalAntiAliasPlugin {
}

fn finish(&self, app: &mut App) {
let Ok(render_app) = app.get_sub_app_mut(RenderApp) else { return };
let Ok(render_app) = app.get_sub_app_mut(RenderApp) else {
return;
};

render_app.init_resource::<TAAPipeline>();
}
Expand Down Expand Up @@ -188,11 +192,7 @@ impl ViewNode for TAANode {
) else {
return Ok(());
};
let (
Some(taa_pipeline),
Some(prepass_motion_vectors_texture),
Some(prepass_depth_texture),
) = (
let (Some(taa_pipeline), Some(prepass_motion_vectors_texture), Some(prepass_depth_texture)) = (
pipeline_cache.get_render_pipeline(taa_pipeline_id.0),
&prepass_textures.motion_vectors,
&prepass_textures.depth,
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/macros/src/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ pub fn derive_world_query_impl(input: TokenStream) -> TokenStream {
"#[derive(WorldQuery)]` only supports structs",
)
.into_compile_error()
.into()
.into();
};

let mut field_attrs = Vec::new();
Expand Down
15 changes: 11 additions & 4 deletions crates/bevy_ecs/macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,17 @@ pub fn impl_param_set(_input: TokenStream) -> TokenStream {
pub fn derive_system_param(input: TokenStream) -> TokenStream {
let token_stream = input.clone();
let ast = parse_macro_input!(input as DeriveInput);
let syn::Data::Struct(syn::DataStruct { fields: field_definitions, .. }) = ast.data else {
return syn::Error::new(ast.span(), "Invalid `SystemParam` type: expected a `struct`")
.into_compile_error()
.into();
let syn::Data::Struct(syn::DataStruct {
fields: field_definitions,
..
}) = ast.data
else {
return syn::Error::new(
ast.span(),
"Invalid `SystemParam` type: expected a `struct`",
)
.into_compile_error()
.into();
};
let path = bevy_ecs_path();

Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_ecs/src/schedule/schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -550,8 +550,8 @@ impl ScheduleGraph {
let Some(prev) = config_iter.next() else {
return AddSystemsInnerResult {
nodes: Vec::new(),
densely_chained: true
}
densely_chained: true,
};
};
let mut previous_result = self.add_systems_inner(prev, true);
densely_chained = previous_result.densely_chained;
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/schedule/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl<T> Hash for SystemTypeSet<T> {
}
impl<T> Clone for SystemTypeSet<T> {
fn clone(&self) -> Self {
Self(PhantomData)
*self
}
}

Expand Down
5 changes: 3 additions & 2 deletions crates/bevy_ecs/src/world/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1770,8 +1770,9 @@ impl World {
f: impl FnOnce(&mut World, &mut Schedule) -> R,
) -> Result<R, TryRunScheduleError> {
let label = label.as_ref();
let Some((extracted_label, mut schedule))
= self.get_resource_mut::<Schedules>().and_then(|mut s| s.remove_entry(label))
let Some((extracted_label, mut schedule)) = self
.get_resource_mut::<Schedules>()
.and_then(|mut s| s.remove_entry(label))
else {
return Err(TryRunScheduleError(label.dyn_clone()));
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ error[E0277]: the trait bound `bevy_ecs::query::Changed<Foo>: ArchetypeFilter` i
| required by a bound introduced by this call
|
= help: the following other types implement trait `ArchetypeFilter`:
()
(F0, F1)
(F0, F1, F2)
(F0, F1, F2, F3)
(F0, F1, F2, F3, F4)
(F0, F1, F2, F3, F4, F5)
(F0, F1, F2, F3, F4, F5, F6)
(F0, F1, F2, F3, F4, F5, F6, F7)
With<T>
Without<T>
Or<()>
Or<(F0,)>
Or<(F0, F1)>
Or<(F0, F1, F2)>
Or<(F0, F1, F2, F3)>
Or<(F0, F1, F2, F3, F4)>
and $N others
= note: required for `QueryIter<'_, '_, &Foo, bevy_ecs::query::Changed<Foo>>` to implement `ExactSizeIterator`
note: required by a bound in `is_exact_size_iterator`
Expand All @@ -32,14 +32,14 @@ error[E0277]: the trait bound `bevy_ecs::query::Added<Foo>: ArchetypeFilter` is
| required by a bound introduced by this call
|
= help: the following other types implement trait `ArchetypeFilter`:
()
(F0, F1)
(F0, F1, F2)
(F0, F1, F2, F3)
(F0, F1, F2, F3, F4)
(F0, F1, F2, F3, F4, F5)
(F0, F1, F2, F3, F4, F5, F6)
(F0, F1, F2, F3, F4, F5, F6, F7)
With<T>
Without<T>
Or<()>
Or<(F0,)>
Or<(F0, F1)>
Or<(F0, F1, F2)>
Or<(F0, F1, F2, F3)>
Or<(F0, F1, F2, F3, F4)>
and $N others
= note: required for `QueryIter<'_, '_, &Foo, bevy_ecs::query::Added<Foo>>` to implement `ExactSizeIterator`
note: required by a bound in `is_exact_size_iterator`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ error[E0277]: the trait bound `&mut A: ReadOnlyWorldQuery` is not satisfied
| required by a bound introduced by this call
|
= help: the following other types implement trait `ReadOnlyWorldQuery`:
&T
()
(F0, F1)
(F0, F1, F2)
(F0, F1, F2, F3)
(F0, F1, F2, F3, F4)
(F0, F1, F2, F3, F4, F5)
(F0, F1, F2, F3, F4, F5, F6)
bevy_ecs::change_detection::Ref<'__w, T>
Has<T>
AnyOf<()>
AnyOf<(F0,)>
AnyOf<(F0, F1)>
AnyOf<(F0, F1, F2)>
AnyOf<(F0, F1, F2, F3)>
AnyOf<(F0, F1, F2, F3, F4)>
and $N others
= note: `ReadOnlyWorldQuery` is implemented for `&A`, but not for `&mut A`
= note: required for `QueryCombinationIter<'_, '_, &mut A, (), _>` to implement `Iterator`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ error[E0277]: the trait bound `&mut A: ReadOnlyWorldQuery` is not satisfied
| required by a bound introduced by this call
|
= help: the following other types implement trait `ReadOnlyWorldQuery`:
&T
()
(F0, F1)
(F0, F1, F2)
(F0, F1, F2, F3)
(F0, F1, F2, F3, F4)
(F0, F1, F2, F3, F4, F5)
(F0, F1, F2, F3, F4, F5, F6)
bevy_ecs::change_detection::Ref<'__w, T>
Has<T>
AnyOf<()>
AnyOf<(F0,)>
AnyOf<(F0, F1)>
AnyOf<(F0, F1, F2)>
AnyOf<(F0, F1, F2, F3)>
AnyOf<(F0, F1, F2, F3, F4)>
and $N others
= note: `ReadOnlyWorldQuery` is implemented for `&A`, but not for `&mut A`
= note: required for `QueryManyIter<'_, '_, &mut A, (), std::array::IntoIter<bevy_ecs::entity::Entity, 1>>` to implement `Iterator`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ error[E0277]: the trait bound `&'static mut Foo: ReadOnlyWorldQuery` is not sati
| ^^^^^^^ the trait `ReadOnlyWorldQuery` is not implemented for `&'static mut Foo`
|
= help: the following other types implement trait `ReadOnlyWorldQuery`:
&T
()
(F0, F1)
(F0, F1, F2)
(F0, F1, F2, F3)
(F0, F1, F2, F3, F4)
(F0, F1, F2, F3, F4, F5)
(F0, F1, F2, F3, F4, F5, F6)
bevy_ecs::change_detection::Ref<'__w, T>
Has<T>
AnyOf<()>
AnyOf<(F0,)>
AnyOf<(F0, F1)>
AnyOf<(F0, F1, F2)>
AnyOf<(F0, F1, F2, F3)>
AnyOf<(F0, F1, F2, F3, F4)>
and $N others
= note: `ReadOnlyWorldQuery` is implemented for `&'static Foo`, but not for `&'static mut Foo`
= note: required for `bevy_ecs::system::Query<'_, '_, &'static mut Foo>` to implement `ReadOnlySystemParam`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ error[E0277]: the trait bound `&'static mut Foo: ReadOnlyWorldQuery` is not sati
| ^^^^^^^^^^^^^^^^ the trait `ReadOnlyWorldQuery` is not implemented for `&'static mut Foo`
|
= help: the following other types implement trait `ReadOnlyWorldQuery`:
&T
()
(F0, F1)
(F0, F1, F2)
(F0, F1, F2, F3)
(F0, F1, F2, F3, F4)
(F0, F1, F2, F3, F4, F5)
(F0, F1, F2, F3, F4, F5, F6)
MutableUnmarked
MutableMarkedReadOnly
NestedMutableUnmarked
bevy_ecs::change_detection::Ref<'__w, T>
Has<T>
AnyOf<()>
AnyOf<(F0,)>
AnyOf<(F0, F1)>
and $N others
note: required by a bound in `_::assert_readonly`
--> tests/ui/world_query_derive.rs:7:10
Expand All @@ -28,14 +28,14 @@ error[E0277]: the trait bound `MutableMarked: ReadOnlyWorldQuery` is not satisfi
| ^^^^^^^^^^^^^ the trait `ReadOnlyWorldQuery` is not implemented for `MutableMarked`
|
= help: the following other types implement trait `ReadOnlyWorldQuery`:
&T
()
(F0, F1)
(F0, F1, F2)
(F0, F1, F2, F3)
(F0, F1, F2, F3, F4)
(F0, F1, F2, F3, F4, F5)
(F0, F1, F2, F3, F4, F5, F6)
MutableUnmarked
MutableMarkedReadOnly
NestedMutableUnmarked
bevy_ecs::change_detection::Ref<'__w, T>
Has<T>
AnyOf<()>
AnyOf<(F0,)>
AnyOf<(F0, F1)>
and $N others
note: required by a bound in `_::assert_readonly`
--> tests/ui/world_query_derive.rs:18:10
Expand Down
Loading

0 comments on commit a788e31

Please sign in to comment.