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
This commit is contained in:
Jakob Hellermann 2023-05-29 09:23:50 +02:00 committed by GitHub
parent 5e3ae770ac
commit 1ff4b98755
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 20 additions and 20 deletions

View File

@ -99,7 +99,7 @@ fn star(
// We can now spawn the entities for the star and the camera // We can now spawn the entities for the star and the camera
commands.spawn(( commands.spawn((
// We use a marker component to identify the custom colored meshes // We use a marker component to identify the custom colored meshes
ColoredMesh2d::default(), ColoredMesh2d,
// The `Handle<Mesh>` needs to be wrapped in a `Mesh2dHandle` to use 2d rendering instead of 3d // The `Handle<Mesh>` needs to be wrapped in a `Mesh2dHandle` to use 2d rendering instead of 3d
Mesh2dHandle(meshes.add(star)), Mesh2dHandle(meshes.add(star)),
// This bundle's components are needed for something to be rendered // This bundle's components are needed for something to be rendered

View File

@ -302,7 +302,7 @@ fn example_control_system(
let randomize_colors = input.just_pressed(KeyCode::C); let randomize_colors = input.just_pressed(KeyCode::C);
for (material_handle, controls) in &controllable { 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); material.base_color.set_a(state.alpha);
if controls.color && randomize_colors { if controls.color && randomize_colors {

View File

@ -378,7 +378,7 @@ fn update_normal(
return; return;
} }
if let Some(normal) = normal.0.as_ref() { 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; image.texture_descriptor.format = TextureFormat::Rgba8Unorm;
*already_ran = true; *already_ran = true;
} }

View File

@ -145,7 +145,7 @@ fn asset_loaded(
&& asset_server.get_load_state(cubemap.image_handle.clone_weak()) == LoadState::Loaded && asset_server.get_load_state(cubemap.image_handle.clone_weak()) == LoadState::Loaded
{ {
info!("Swapping to {}...", CUBEMAPS[cubemap.index].0); 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, // 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. // so they appear as one texture. The following code reconfigures the texture as necessary.
if image.texture_descriptor.array_layer_count() == 1 { if image.texture_descriptor.array_layer_count() == 1 {

View File

@ -10,7 +10,7 @@ use rand::{thread_rng, Rng};
fn main() { fn main() {
App::new() App::new()
.add_plugins(DefaultPlugins) .add_plugins(DefaultPlugins)
.add_plugin(FrameTimeDiagnosticsPlugin::default()) .add_plugin(FrameTimeDiagnosticsPlugin)
.add_plugin(LogDiagnosticsPlugin::default()) .add_plugin(LogDiagnosticsPlugin::default())
.add_systems(Startup, setup) .add_systems(Startup, setup)
.add_systems(Update, (light_sway, movement)) .add_systems(Update, (light_sway, movement))

View File

@ -430,7 +430,7 @@ fn update_color_grading_settings(
mut selected_parameter: ResMut<SelectedParameter>, mut selected_parameter: ResMut<SelectedParameter>,
) { ) {
let method = tonemapping.single(); 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; let mut dt = time.delta_seconds() * 0.25;
if keys.pressed(KeyCode::Left) { if keys.pressed(KeyCode::Left) {
dt = -dt; dt = -dt;

View File

@ -9,7 +9,7 @@ fn main() {
App::new() App::new()
.add_plugins(DefaultPlugins) .add_plugins(DefaultPlugins)
// Adds frame time diagnostics // Adds frame time diagnostics
.add_plugin(FrameTimeDiagnosticsPlugin::default()) .add_plugin(FrameTimeDiagnosticsPlugin)
// Adds a system that prints diagnostics to the console // Adds a system that prints diagnostics to the console
.add_plugin(LogDiagnosticsPlugin::default()) .add_plugin(LogDiagnosticsPlugin::default())
// Any plugin can register diagnostics // Any plugin can register diagnostics

View File

@ -334,7 +334,7 @@ fn contributors() -> Result<Contributors, LoadContributorsError> {
let contributors = BufReader::new(stdout) let contributors = BufReader::new(stdout)
.lines() .lines()
.filter_map(|x| x.ok()) .map_while(|x| x.ok())
.collect(); .collect();
Ok(contributors) Ok(contributors)

View File

@ -37,7 +37,7 @@ fn main() {
}), }),
..default() ..default()
})) }))
.add_plugin(FrameTimeDiagnosticsPlugin::default()) .add_plugin(FrameTimeDiagnosticsPlugin)
.add_plugin(LogDiagnosticsPlugin::default()) .add_plugin(LogDiagnosticsPlugin::default())
.insert_resource(BevyCounter { .insert_resource(BevyCounter {
count: 0, count: 0,

View File

@ -21,7 +21,7 @@ fn main() {
App::new() App::new()
// Since this is also used as a benchmark, we want it to display performance data. // Since this is also used as a benchmark, we want it to display performance data.
.add_plugin(LogDiagnosticsPlugin::default()) .add_plugin(LogDiagnosticsPlugin::default())
.add_plugin(FrameTimeDiagnosticsPlugin::default()) .add_plugin(FrameTimeDiagnosticsPlugin)
.add_plugins(DefaultPlugins.set(WindowPlugin { .add_plugins(DefaultPlugins.set(WindowPlugin {
primary_window: Some(Window { primary_window: Some(Window {
present_mode: PresentMode::AutoNoVsync, present_mode: PresentMode::AutoNoVsync,

View File

@ -30,7 +30,7 @@ fn main() {
}), }),
..default() ..default()
})) }))
.add_plugin(FrameTimeDiagnosticsPlugin::default()) .add_plugin(FrameTimeDiagnosticsPlugin)
.add_plugin(LogDiagnosticsPlugin::default()) .add_plugin(LogDiagnosticsPlugin::default())
.add_systems(Startup, setup) .add_systems(Startup, setup)
.add_systems(Update, button_system); .add_systems(Update, button_system);

View File

@ -28,7 +28,7 @@ fn main() {
}), }),
..default() ..default()
})) }))
.add_plugin(FrameTimeDiagnosticsPlugin::default()) .add_plugin(FrameTimeDiagnosticsPlugin)
.add_plugin(LogDiagnosticsPlugin::default()) .add_plugin(LogDiagnosticsPlugin::default())
.add_systems(Startup, setup) .add_systems(Startup, setup)
.add_systems(Update, (move_camera, print_mesh_count)) .add_systems(Update, (move_camera, print_mesh_count))

View File

@ -18,7 +18,7 @@ fn main() {
}), }),
..default() ..default()
})) }))
.add_plugin(FrameTimeDiagnosticsPlugin::default()) .add_plugin(FrameTimeDiagnosticsPlugin)
.insert_resource(Config { .insert_resource(Config {
line_count: 50_000, line_count: 50_000,
fancy: false, fancy: false,

View File

@ -21,7 +21,7 @@ fn main() {
}), }),
..default() ..default()
})) }))
.add_plugin(FrameTimeDiagnosticsPlugin::default()) .add_plugin(FrameTimeDiagnosticsPlugin)
.add_plugin(LogDiagnosticsPlugin::default()) .add_plugin(LogDiagnosticsPlugin::default())
.add_systems(Startup, setup); .add_systems(Startup, setup);

View File

@ -24,7 +24,7 @@ fn main() {
}), }),
..default() ..default()
})) }))
.add_plugin(FrameTimeDiagnosticsPlugin::default()) .add_plugin(FrameTimeDiagnosticsPlugin)
.add_plugin(LogDiagnosticsPlugin::default()) .add_plugin(LogDiagnosticsPlugin::default())
.add_systems(Startup, setup) .add_systems(Startup, setup)
.add_systems(Update, (move_camera, print_light_count)) .add_systems(Update, (move_camera, print_light_count))

View File

@ -29,7 +29,7 @@ fn main() {
)) ))
// Since this is also used as a benchmark, we want it to display performance data. // Since this is also used as a benchmark, we want it to display performance data.
.add_plugin(LogDiagnosticsPlugin::default()) .add_plugin(LogDiagnosticsPlugin::default())
.add_plugin(FrameTimeDiagnosticsPlugin::default()) .add_plugin(FrameTimeDiagnosticsPlugin)
.add_plugins(DefaultPlugins.set(WindowPlugin { .add_plugins(DefaultPlugins.set(WindowPlugin {
primary_window: Some(Window { primary_window: Some(Window {
present_mode: PresentMode::AutoNoVsync, present_mode: PresentMode::AutoNoVsync,

View File

@ -18,7 +18,7 @@ fn main() {
}), }),
..default() ..default()
})) }))
.add_plugin(FrameTimeDiagnosticsPlugin::default()) .add_plugin(FrameTimeDiagnosticsPlugin)
.add_plugin(LogDiagnosticsPlugin::default()) .add_plugin(LogDiagnosticsPlugin::default())
.add_systems(Startup, spawn) .add_systems(Startup, spawn)
.add_systems(Update, update_text_bounds) .add_systems(Update, update_text_bounds)

View File

@ -184,7 +184,7 @@ fn main() {
App::new() App::new()
.insert_resource(cfg) .insert_resource(cfg)
.add_plugins(MinimalPlugins) .add_plugins(MinimalPlugins)
.add_plugin(TransformPlugin::default()) .add_plugin(TransformPlugin)
.add_systems(Startup, setup) .add_systems(Startup, setup)
// Updating transforms *must* be done before `CoreSet::PostUpdate` // Updating transforms *must* be done before `CoreSet::PostUpdate`
// or the hierarchy will momentarily be in an invalid state. // or the hierarchy will momentarily be in an invalid state.

View File

@ -11,7 +11,7 @@ use bevy::{
fn main() { fn main() {
App::new() App::new()
.add_plugins(DefaultPlugins) .add_plugins(DefaultPlugins)
.add_plugin(FrameTimeDiagnosticsPlugin::default()) .add_plugin(FrameTimeDiagnosticsPlugin)
.add_systems(Startup, setup) .add_systems(Startup, setup)
.add_systems(Update, (text_update_system, text_color_system)) .add_systems(Update, (text_update_system, text_color_system))
.run(); .run();

View File

@ -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}; use bevy::{prelude::*, window::WindowResized};
fn main() { fn main() {