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
commands.spawn((
// 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
Mesh2dHandle(meshes.add(star)),
// 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);
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 {

View file

@ -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;
}

View file

@ -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 {

View file

@ -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))

View file

@ -430,7 +430,7 @@ fn update_color_grading_settings(
mut selected_parameter: ResMut<SelectedParameter>,
) {
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;

View file

@ -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

View file

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

View file

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

View file

@ -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,

View file

@ -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);

View file

@ -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))

View file

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

View file

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

View file

@ -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))

View file

@ -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,

View file

@ -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)

View file

@ -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.

View file

@ -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();

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};
fn main() {