From 1ff4b987554590150d35626219fd8ec573a131f7 Mon Sep 17 00:00:00 2001 From: Jakob Hellermann Date: Mon, 29 May 2023 09:23:50 +0200 Subject: [PATCH] fix new clippy lints before they reach stable (#8700) # Objective - fix clippy lints early to make sure CI doesn't break when they get promoted to stable - have a noise-free `clippy` experience for nightly users ## Solution - `cargo clippy --fix` - replace `filter_map(|x| x.ok())` with `map_while(|x| x.ok())` to fix potential infinite loop in case of IO error --- examples/2d/mesh2d_manual.rs | 2 +- examples/3d/blend_modes.rs | 2 +- examples/3d/parallax_mapping.rs | 2 +- examples/3d/skybox.rs | 2 +- examples/3d/spotlight.rs | 2 +- examples/3d/tonemapping.rs | 2 +- examples/diagnostics/log_diagnostics.rs | 2 +- examples/games/contributors.rs | 2 +- examples/stress_tests/bevymark.rs | 2 +- examples/stress_tests/many_animated_sprites.rs | 2 +- examples/stress_tests/many_buttons.rs | 2 +- examples/stress_tests/many_cubes.rs | 2 +- examples/stress_tests/many_gizmos.rs | 2 +- examples/stress_tests/many_glyphs.rs | 2 +- examples/stress_tests/many_lights.rs | 2 +- examples/stress_tests/many_sprites.rs | 2 +- examples/stress_tests/text_pipeline.rs | 2 +- examples/stress_tests/transform_hierarchy.rs | 2 +- examples/ui/text.rs | 2 +- examples/window/window_resizing.rs | 2 +- 20 files changed, 20 insertions(+), 20 deletions(-) diff --git a/examples/2d/mesh2d_manual.rs b/examples/2d/mesh2d_manual.rs index 0ad142a561..0c55580d49 100644 --- a/examples/2d/mesh2d_manual.rs +++ b/examples/2d/mesh2d_manual.rs @@ -99,7 +99,7 @@ fn star( // We can now spawn the entities for the star and the camera commands.spawn(( // We use a marker component to identify the custom colored meshes - ColoredMesh2d::default(), + ColoredMesh2d, // The `Handle` needs to be wrapped in a `Mesh2dHandle` to use 2d rendering instead of 3d Mesh2dHandle(meshes.add(star)), // This bundle's components are needed for something to be rendered diff --git a/examples/3d/blend_modes.rs b/examples/3d/blend_modes.rs index 262728dbfc..4dd76d8faf 100644 --- a/examples/3d/blend_modes.rs +++ b/examples/3d/blend_modes.rs @@ -302,7 +302,7 @@ fn example_control_system( let randomize_colors = input.just_pressed(KeyCode::C); for (material_handle, controls) in &controllable { - let mut material = materials.get_mut(material_handle).unwrap(); + let material = materials.get_mut(material_handle).unwrap(); material.base_color.set_a(state.alpha); if controls.color && randomize_colors { diff --git a/examples/3d/parallax_mapping.rs b/examples/3d/parallax_mapping.rs index 31df37e37d..8260f9b3f3 100644 --- a/examples/3d/parallax_mapping.rs +++ b/examples/3d/parallax_mapping.rs @@ -378,7 +378,7 @@ fn update_normal( return; } if let Some(normal) = normal.0.as_ref() { - if let Some(mut image) = images.get_mut(normal) { + if let Some(image) = images.get_mut(normal) { image.texture_descriptor.format = TextureFormat::Rgba8Unorm; *already_ran = true; } diff --git a/examples/3d/skybox.rs b/examples/3d/skybox.rs index 0ce8237cd6..986114bfdb 100644 --- a/examples/3d/skybox.rs +++ b/examples/3d/skybox.rs @@ -145,7 +145,7 @@ fn asset_loaded( && asset_server.get_load_state(cubemap.image_handle.clone_weak()) == LoadState::Loaded { info!("Swapping to {}...", CUBEMAPS[cubemap.index].0); - let mut image = images.get_mut(&cubemap.image_handle).unwrap(); + let image = images.get_mut(&cubemap.image_handle).unwrap(); // NOTE: PNGs do not have any metadata that could indicate they contain a cubemap texture, // so they appear as one texture. The following code reconfigures the texture as necessary. if image.texture_descriptor.array_layer_count() == 1 { diff --git a/examples/3d/spotlight.rs b/examples/3d/spotlight.rs index d49ceb869a..38ee6e11b5 100644 --- a/examples/3d/spotlight.rs +++ b/examples/3d/spotlight.rs @@ -10,7 +10,7 @@ use rand::{thread_rng, Rng}; fn main() { App::new() .add_plugins(DefaultPlugins) - .add_plugin(FrameTimeDiagnosticsPlugin::default()) + .add_plugin(FrameTimeDiagnosticsPlugin) .add_plugin(LogDiagnosticsPlugin::default()) .add_systems(Startup, setup) .add_systems(Update, (light_sway, movement)) diff --git a/examples/3d/tonemapping.rs b/examples/3d/tonemapping.rs index 1d120081d8..6b9bb09eb0 100644 --- a/examples/3d/tonemapping.rs +++ b/examples/3d/tonemapping.rs @@ -430,7 +430,7 @@ fn update_color_grading_settings( mut selected_parameter: ResMut, ) { let method = tonemapping.single(); - let mut color_grading = per_method_settings.settings.get_mut(method).unwrap(); + let color_grading = per_method_settings.settings.get_mut(method).unwrap(); let mut dt = time.delta_seconds() * 0.25; if keys.pressed(KeyCode::Left) { dt = -dt; diff --git a/examples/diagnostics/log_diagnostics.rs b/examples/diagnostics/log_diagnostics.rs index 436bba684f..2cfb1e6cc8 100644 --- a/examples/diagnostics/log_diagnostics.rs +++ b/examples/diagnostics/log_diagnostics.rs @@ -9,7 +9,7 @@ fn main() { App::new() .add_plugins(DefaultPlugins) // Adds frame time diagnostics - .add_plugin(FrameTimeDiagnosticsPlugin::default()) + .add_plugin(FrameTimeDiagnosticsPlugin) // Adds a system that prints diagnostics to the console .add_plugin(LogDiagnosticsPlugin::default()) // Any plugin can register diagnostics diff --git a/examples/games/contributors.rs b/examples/games/contributors.rs index f5eb0462fe..1ca223c35d 100644 --- a/examples/games/contributors.rs +++ b/examples/games/contributors.rs @@ -334,7 +334,7 @@ fn contributors() -> Result { let contributors = BufReader::new(stdout) .lines() - .filter_map(|x| x.ok()) + .map_while(|x| x.ok()) .collect(); Ok(contributors) diff --git a/examples/stress_tests/bevymark.rs b/examples/stress_tests/bevymark.rs index 4518b804e7..5bb09e205b 100644 --- a/examples/stress_tests/bevymark.rs +++ b/examples/stress_tests/bevymark.rs @@ -37,7 +37,7 @@ fn main() { }), ..default() })) - .add_plugin(FrameTimeDiagnosticsPlugin::default()) + .add_plugin(FrameTimeDiagnosticsPlugin) .add_plugin(LogDiagnosticsPlugin::default()) .insert_resource(BevyCounter { count: 0, diff --git a/examples/stress_tests/many_animated_sprites.rs b/examples/stress_tests/many_animated_sprites.rs index e6286c39c7..a5dd281de7 100644 --- a/examples/stress_tests/many_animated_sprites.rs +++ b/examples/stress_tests/many_animated_sprites.rs @@ -21,7 +21,7 @@ fn main() { App::new() // Since this is also used as a benchmark, we want it to display performance data. .add_plugin(LogDiagnosticsPlugin::default()) - .add_plugin(FrameTimeDiagnosticsPlugin::default()) + .add_plugin(FrameTimeDiagnosticsPlugin) .add_plugins(DefaultPlugins.set(WindowPlugin { primary_window: Some(Window { present_mode: PresentMode::AutoNoVsync, diff --git a/examples/stress_tests/many_buttons.rs b/examples/stress_tests/many_buttons.rs index 94a7ddc951..19d424a1df 100644 --- a/examples/stress_tests/many_buttons.rs +++ b/examples/stress_tests/many_buttons.rs @@ -30,7 +30,7 @@ fn main() { }), ..default() })) - .add_plugin(FrameTimeDiagnosticsPlugin::default()) + .add_plugin(FrameTimeDiagnosticsPlugin) .add_plugin(LogDiagnosticsPlugin::default()) .add_systems(Startup, setup) .add_systems(Update, button_system); diff --git a/examples/stress_tests/many_cubes.rs b/examples/stress_tests/many_cubes.rs index 6d0d7db3f1..dc20c4fa36 100644 --- a/examples/stress_tests/many_cubes.rs +++ b/examples/stress_tests/many_cubes.rs @@ -28,7 +28,7 @@ fn main() { }), ..default() })) - .add_plugin(FrameTimeDiagnosticsPlugin::default()) + .add_plugin(FrameTimeDiagnosticsPlugin) .add_plugin(LogDiagnosticsPlugin::default()) .add_systems(Startup, setup) .add_systems(Update, (move_camera, print_mesh_count)) diff --git a/examples/stress_tests/many_gizmos.rs b/examples/stress_tests/many_gizmos.rs index 817a2e8aae..dc60b40977 100644 --- a/examples/stress_tests/many_gizmos.rs +++ b/examples/stress_tests/many_gizmos.rs @@ -18,7 +18,7 @@ fn main() { }), ..default() })) - .add_plugin(FrameTimeDiagnosticsPlugin::default()) + .add_plugin(FrameTimeDiagnosticsPlugin) .insert_resource(Config { line_count: 50_000, fancy: false, diff --git a/examples/stress_tests/many_glyphs.rs b/examples/stress_tests/many_glyphs.rs index 73aa78c08e..77127b57ca 100644 --- a/examples/stress_tests/many_glyphs.rs +++ b/examples/stress_tests/many_glyphs.rs @@ -21,7 +21,7 @@ fn main() { }), ..default() })) - .add_plugin(FrameTimeDiagnosticsPlugin::default()) + .add_plugin(FrameTimeDiagnosticsPlugin) .add_plugin(LogDiagnosticsPlugin::default()) .add_systems(Startup, setup); diff --git a/examples/stress_tests/many_lights.rs b/examples/stress_tests/many_lights.rs index c00e8c6cf5..bf81668536 100644 --- a/examples/stress_tests/many_lights.rs +++ b/examples/stress_tests/many_lights.rs @@ -24,7 +24,7 @@ fn main() { }), ..default() })) - .add_plugin(FrameTimeDiagnosticsPlugin::default()) + .add_plugin(FrameTimeDiagnosticsPlugin) .add_plugin(LogDiagnosticsPlugin::default()) .add_systems(Startup, setup) .add_systems(Update, (move_camera, print_light_count)) diff --git a/examples/stress_tests/many_sprites.rs b/examples/stress_tests/many_sprites.rs index bc8423d86d..87776ef61e 100644 --- a/examples/stress_tests/many_sprites.rs +++ b/examples/stress_tests/many_sprites.rs @@ -29,7 +29,7 @@ fn main() { )) // Since this is also used as a benchmark, we want it to display performance data. .add_plugin(LogDiagnosticsPlugin::default()) - .add_plugin(FrameTimeDiagnosticsPlugin::default()) + .add_plugin(FrameTimeDiagnosticsPlugin) .add_plugins(DefaultPlugins.set(WindowPlugin { primary_window: Some(Window { present_mode: PresentMode::AutoNoVsync, diff --git a/examples/stress_tests/text_pipeline.rs b/examples/stress_tests/text_pipeline.rs index 9eaaeedc1d..64ffe57ae7 100644 --- a/examples/stress_tests/text_pipeline.rs +++ b/examples/stress_tests/text_pipeline.rs @@ -18,7 +18,7 @@ fn main() { }), ..default() })) - .add_plugin(FrameTimeDiagnosticsPlugin::default()) + .add_plugin(FrameTimeDiagnosticsPlugin) .add_plugin(LogDiagnosticsPlugin::default()) .add_systems(Startup, spawn) .add_systems(Update, update_text_bounds) diff --git a/examples/stress_tests/transform_hierarchy.rs b/examples/stress_tests/transform_hierarchy.rs index 47985fbbf6..18562fcd0d 100644 --- a/examples/stress_tests/transform_hierarchy.rs +++ b/examples/stress_tests/transform_hierarchy.rs @@ -184,7 +184,7 @@ fn main() { App::new() .insert_resource(cfg) .add_plugins(MinimalPlugins) - .add_plugin(TransformPlugin::default()) + .add_plugin(TransformPlugin) .add_systems(Startup, setup) // Updating transforms *must* be done before `CoreSet::PostUpdate` // or the hierarchy will momentarily be in an invalid state. diff --git a/examples/ui/text.rs b/examples/ui/text.rs index 0976e0f445..f6c5b82fff 100644 --- a/examples/ui/text.rs +++ b/examples/ui/text.rs @@ -11,7 +11,7 @@ use bevy::{ fn main() { App::new() .add_plugins(DefaultPlugins) - .add_plugin(FrameTimeDiagnosticsPlugin::default()) + .add_plugin(FrameTimeDiagnosticsPlugin) .add_systems(Startup, setup) .add_systems(Update, (text_update_system, text_color_system)) .run(); diff --git a/examples/window/window_resizing.rs b/examples/window/window_resizing.rs index 6f130f5fa5..5281454765 100644 --- a/examples/window/window_resizing.rs +++ b/examples/window/window_resizing.rs @@ -1,4 +1,4 @@ -///! This example illustrates how to resize windows, and how to respond to a window being resized. +//! This example illustrates how to resize windows, and how to respond to a window being resized. use bevy::{prelude::*, window::WindowResized}; fn main() {