From 4c20239bfcd1ec2bf3f43f7f84dea08afb4d2abf Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Fri, 21 Feb 2025 20:31:19 +1100 Subject: [PATCH 01/34] WIP --- examples/2d/cpu_draw.rs | 4 ++-- examples/3d/decal.rs | 2 +- examples/3d/fog.rs | 8 +++---- examples/animation/animated_mesh_events.rs | 2 +- examples/animation/animation_graph.rs | 2 +- examples/asset/asset_loading.rs | 6 ++--- examples/asset/multi_asset_sync.rs | 2 +- examples/camera/first_person_view_model.rs | 2 +- examples/ecs/observers.rs | 6 ++--- examples/ecs/parallel_query.rs | 2 +- examples/games/alien_cake_addict.rs | 6 ++--- examples/games/contributors.rs | 4 ++-- examples/gizmos/axes.rs | 18 +++++++------- examples/stress_tests/bevymark.rs | 24 +++++++++---------- .../stress_tests/many_animated_sprites.rs | 8 +++---- examples/stress_tests/many_cubes.rs | 4 ++-- examples/stress_tests/many_sprites.rs | 6 ++--- examples/stress_tests/many_text2d.rs | 6 ++--- examples/stress_tests/transform_hierarchy.rs | 10 ++++---- examples/transforms/align.rs | 8 +++---- examples/ui/button.rs | 2 +- examples/ui/font_atlas_debug.rs | 2 +- 22 files changed, 67 insertions(+), 67 deletions(-) diff --git a/examples/2d/cpu_draw.rs b/examples/2d/cpu_draw.rs index adf7f63b90c44..f142f50d1d214 100644 --- a/examples/2d/cpu_draw.rs +++ b/examples/2d/cpu_draw.rs @@ -101,7 +101,7 @@ fn draw( ) { if *i == 0 { // Generate a random color on first run. - *draw_color = Color::linear_rgb(seeded_rng.0.gen(), seeded_rng.0.gen(), seeded_rng.0.gen()); + *draw_color = Color::linear_rgb(seeded_rng.0.r#gen(), seeded_rng.0.r#gen(), seeded_rng.0.r#gen()); } // Get the image from Bevy's asset storage. @@ -124,7 +124,7 @@ fn draw( // If the old color is our current color, change our drawing color. let tolerance = 1.0 / 255.0; if old_color.distance(&draw_color) <= tolerance { - *draw_color = Color::linear_rgb(seeded_rng.0.gen(), seeded_rng.0.gen(), seeded_rng.0.gen()); + *draw_color = Color::linear_rgb(seeded_rng.0.r#gen(), seeded_rng.0.r#gen(), seeded_rng.0.r#gen()); } // Set the new color, but keep old alpha value from image. diff --git a/examples/3d/decal.rs b/examples/3d/decal.rs index 2f27af3bb6b3c..7fd45cd53cee6 100644 --- a/examples/3d/decal.rs +++ b/examples/3d/decal.rs @@ -64,7 +64,7 @@ fn setup( let mut rng = ChaCha8Rng::seed_from_u64(19878367467713); for i in 0..num_obs { for j in 0..num_obs { - let rotation_axis: [f32; 3] = rng.gen(); + let rotation_axis: [f32; 3] = rng.r#gen(); let rotation_vec: Vec3 = rotation_axis.into(); let rotation: u32 = rng.gen_range(0..360); let transform = Transform::from_xyz( diff --git a/examples/3d/fog.rs b/examples/3d/fog.rs index 1df8c3ce4f3dc..ed2a2a0dd6867 100644 --- a/examples/3d/fog.rs +++ b/examples/3d/fog.rs @@ -186,8 +186,8 @@ fn update_system( // Linear Fog Controls if let FogFalloff::Linear { - ref mut start, - ref mut end, + start, + end, } = &mut fog.falloff { text.push_str("\nA / S - Move Start Distance\nZ / X - Move End Distance"); @@ -207,7 +207,7 @@ fn update_system( } // Exponential Fog Controls - if let FogFalloff::Exponential { ref mut density } = &mut fog.falloff { + if let FogFalloff::Exponential { density } = &mut fog.falloff { text.push_str("\nA / S - Change Density"); if keycode.pressed(KeyCode::KeyA) { @@ -222,7 +222,7 @@ fn update_system( } // ExponentialSquared Fog Controls - if let FogFalloff::ExponentialSquared { ref mut density } = &mut fog.falloff { + if let FogFalloff::ExponentialSquared { density } = &mut fog.falloff { text.push_str("\nA / S - Change Density"); if keycode.pressed(KeyCode::KeyA) { diff --git a/examples/animation/animated_mesh_events.rs b/examples/animation/animated_mesh_events.rs index 2c79aa88dcf5b..2048f573fd704 100644 --- a/examples/animation/animated_mesh_events.rs +++ b/examples/animation/animated_mesh_events.rs @@ -50,7 +50,7 @@ fn observe_on_step( let translation = transforms.get(trigger.target()).unwrap().translation(); // Spawn a bunch of particles. for _ in 0..14 { - let horizontal = seeded_rng.0.gen::() * seeded_rng.0.gen_range(8.0..12.0); + let horizontal = seeded_rng.0.r#gen::() * seeded_rng.0.gen_range(8.0..12.0); let vertical = seeded_rng.0.gen_range(0.0..4.0); let size = seeded_rng.0.gen_range(0.2..1.0); diff --git a/examples/animation/animation_graph.rs b/examples/animation/animation_graph.rs index afe01c288c6d1..76da8a6644ef1 100644 --- a/examples/animation/animation_graph.rs +++ b/examples/animation/animation_graph.rs @@ -299,7 +299,7 @@ fn setup_node_rects(commands: &mut Commands) { Outline::new(Val::Px(1.), Val::ZERO, Color::WHITE), )); - if let NodeType::Clip(ref clip) = node_type { + if let NodeType::Clip(clip) = node_type { container.insert(( Interaction::None, RelativeCursorPosition::default(), diff --git a/examples/asset/asset_loading.rs b/examples/asset/asset_loading.rs index 49d2dca279025..88867ea458b8b 100644 --- a/examples/asset/asset_loading.rs +++ b/examples/asset/asset_loading.rs @@ -36,14 +36,14 @@ fn setup( ); // All assets end up in their Assets collection once they are done loading: - if let Some(sphere) = meshes.get(&sphere_handle) { + match meshes.get(&sphere_handle) { Some(sphere) => { // You might notice that this doesn't run! This is because assets load in parallel without // blocking. When an asset has loaded, it will appear in relevant Assets // collection. info!("{:?}", sphere.primitive_topology()); - } else { + } _ => { info!("sphere hasn't loaded yet"); - } + }} // You can load all assets in a folder like this. They will be loaded in parallel without // blocking. The LoadedFolder asset holds handles to each asset in the folder. These are all diff --git a/examples/asset/multi_asset_sync.rs b/examples/asset/multi_asset_sync.rs index 5ec34b0d46a81..758bb4a06d01c 100644 --- a/examples/asset/multi_asset_sync.rs +++ b/examples/asset/multi_asset_sync.rs @@ -105,7 +105,7 @@ impl AssetBarrier { } /// Wait for all [`AssetBarrierGuard`]s to be dropped asynchronously. - pub fn wait_async(&self) -> impl Future + 'static { + pub fn wait_async(&self) -> impl Future + 'static + use<> { let shared = self.0.clone(); async move { loop { diff --git a/examples/camera/first_person_view_model.rs b/examples/camera/first_person_view_model.rs index 78168eac5ddbf..c23e745c4cb03 100644 --- a/examples/camera/first_person_view_model.rs +++ b/examples/camera/first_person_view_model.rs @@ -243,7 +243,7 @@ fn change_fov( input: Res>, mut world_model_projection: Single<&mut Projection, With>, ) { - let Projection::Perspective(ref mut perspective) = world_model_projection.as_mut() else { + let Projection::Perspective(perspective) = world_model_projection.as_mut() else { unreachable!( "The `Projection` component was explicitly built with `Projection::Perspective`" ); diff --git a/examples/ecs/observers.rs b/examples/ecs/observers.rs index 6d8027f01dbcd..0f057db100118 100644 --- a/examples/ecs/observers.rs +++ b/examples/ecs/observers.rs @@ -52,10 +52,10 @@ impl Mine { fn random(rand: &mut ChaCha8Rng) -> Self { Mine { pos: Vec2::new( - (rand.gen::() - 0.5) * 1200.0, - (rand.gen::() - 0.5) * 600.0, + (rand.r#gen::() - 0.5) * 1200.0, + (rand.r#gen::() - 0.5) * 600.0, ), - size: 4.0 + rand.gen::() * 16.0, + size: 4.0 + rand.r#gen::() * 16.0, } } } diff --git a/examples/ecs/parallel_query.rs b/examples/ecs/parallel_query.rs index 18bc3fc183419..24a862b173bc9 100644 --- a/examples/ecs/parallel_query.rs +++ b/examples/ecs/parallel_query.rs @@ -19,7 +19,7 @@ fn spawn_system(mut commands: Commands, asset_server: Res) { Sprite::from_image(texture.clone()), Transform::from_scale(Vec3::splat(0.1)) .with_translation(Vec2::splat(0.0).extend(z as f32)), - Velocity(20.0 * Vec2::new(rng.gen::() - 0.5, rng.gen::() - 0.5)), + Velocity(20.0 * Vec2::new(rng.r#gen::() - 0.5, rng.r#gen::() - 0.5)), )); } } diff --git a/examples/games/alien_cake_addict.rs b/examples/games/alien_cake_addict.rs index 06a2b9891d5d8..67267a8b6fac2 100644 --- a/examples/games/alien_cake_addict.rs +++ b/examples/games/alien_cake_addict.rs @@ -271,7 +271,7 @@ fn focus_camera( ) { const SPEED: f32 = 2.0; // if there is both a player and a bonus, target the mid-point of them - if let (Some(player_entity), Some(bonus_entity)) = (game.player.entity, game.bonus.entity) { + match (game.player.entity, game.bonus.entity) { (Some(player_entity), Some(bonus_entity)) => { let transform_query = transforms.p1(); if let (Ok(player_transform), Ok(bonus_transform)) = ( transform_query.get(player_entity), @@ -282,14 +282,14 @@ fn focus_camera( .lerp(bonus_transform.translation, 0.5); } // otherwise, if there is only a player, target the player - } else if let Some(player_entity) = game.player.entity { + } _ => if let Some(player_entity) = game.player.entity { if let Ok(player_transform) = transforms.p1().get(player_entity) { game.camera_should_focus = player_transform.translation; } // otherwise, target the middle } else { game.camera_should_focus = Vec3::from(RESET_FOCUS); - } + }} // calculate the camera motion based on the difference between where the camera is looking // and where it should be looking; the greater the distance, the faster the motion; // smooth out the camera movement using the frame time diff --git a/examples/games/contributors.rs b/examples/games/contributors.rs index 59f03eba6e3e2..30a9ce8a9ffb9 100644 --- a/examples/games/contributors.rs +++ b/examples/games/contributors.rs @@ -98,14 +98,14 @@ fn setup_contributor_selection( let transform = Transform::from_xyz( rng.gen_range(-400.0..400.0), rng.gen_range(0.0..400.0), - rng.gen(), + rng.r#gen(), ); let dir = rng.gen_range(-1.0..1.0); let velocity = Vec3::new(dir * 500.0, 0.0, 0.0); let hue = name_to_hue(&name); // Some sprites should be flipped for variety - let flipped = rng.gen(); + let flipped = rng.r#gen(); let entity = commands .spawn(( diff --git a/examples/gizmos/axes.rs b/examples/gizmos/axes.rs index 1ecfa340bace8..d90d498ec9984 100644 --- a/examples/gizmos/axes.rs +++ b/examples/gizmos/axes.rs @@ -147,22 +147,22 @@ fn random_transform(rng: &mut impl Rng) -> Transform { } fn random_translation(rng: &mut impl Rng) -> Vec3 { - let x = rng.gen::() * (TRANSLATION_BOUND_UPPER_X - TRANSLATION_BOUND_LOWER_X) + let x = rng.r#gen::() * (TRANSLATION_BOUND_UPPER_X - TRANSLATION_BOUND_LOWER_X) + TRANSLATION_BOUND_LOWER_X; - let y = rng.gen::() * (TRANSLATION_BOUND_UPPER_Y - TRANSLATION_BOUND_LOWER_Y) + let y = rng.r#gen::() * (TRANSLATION_BOUND_UPPER_Y - TRANSLATION_BOUND_LOWER_Y) + TRANSLATION_BOUND_LOWER_Y; - let z = rng.gen::() * (TRANSLATION_BOUND_UPPER_Z - TRANSLATION_BOUND_LOWER_Z) + let z = rng.r#gen::() * (TRANSLATION_BOUND_UPPER_Z - TRANSLATION_BOUND_LOWER_Z) + TRANSLATION_BOUND_LOWER_Z; Vec3::new(x, y, z) } fn random_scale(rng: &mut impl Rng) -> Vec3 { - let x_factor_log = rng.gen::() * (SCALING_BOUND_UPPER_LOG - SCALING_BOUND_LOWER_LOG) + let x_factor_log = rng.r#gen::() * (SCALING_BOUND_UPPER_LOG - SCALING_BOUND_LOWER_LOG) + SCALING_BOUND_LOWER_LOG; - let y_factor_log = rng.gen::() * (SCALING_BOUND_UPPER_LOG - SCALING_BOUND_LOWER_LOG) + let y_factor_log = rng.r#gen::() * (SCALING_BOUND_UPPER_LOG - SCALING_BOUND_LOWER_LOG) + SCALING_BOUND_LOWER_LOG; - let z_factor_log = rng.gen::() * (SCALING_BOUND_UPPER_LOG - SCALING_BOUND_LOWER_LOG) + let z_factor_log = rng.r#gen::() * (SCALING_BOUND_UPPER_LOG - SCALING_BOUND_LOWER_LOG) + SCALING_BOUND_LOWER_LOG; Vec3::new( @@ -186,14 +186,14 @@ fn elerp(v1: Vec3, v2: Vec3, t: f32) -> Vec3 { fn random_rotation(rng: &mut impl Rng) -> Quat { let dir = random_direction(rng); - let angle = rng.gen::() * 2. * PI; + let angle = rng.r#gen::() * 2. * PI; Quat::from_axis_angle(dir, angle) } fn random_direction(rng: &mut impl Rng) -> Vec3 { - let height = rng.gen::() * 2. - 1.; - let theta = rng.gen::() * 2. * PI; + let height = rng.r#gen::() * 2. - 1.; + let theta = rng.r#gen::() * 2. * PI; build_direction(height, theta) } diff --git a/examples/stress_tests/bevymark.rs b/examples/stress_tests/bevymark.rs index ae1d5ac5bfdb5..1ee719d93f85c 100644 --- a/examples/stress_tests/bevymark.rs +++ b/examples/stress_tests/bevymark.rs @@ -345,7 +345,7 @@ fn mouse_handler( let rng = rng.as_mut().unwrap(); if mouse_button_input.just_released(MouseButton::Left) { - counter.color = Color::linear_rgb(rng.gen(), rng.gen(), rng.gen()); + counter.color = Color::linear_rgb(rng.r#gen(), rng.r#gen(), rng.r#gen()); } if mouse_button_input.pressed(MouseButton::Left) { @@ -371,7 +371,7 @@ fn bird_velocity_transform( waves: Option, dt: f32, ) -> (Transform, Vec3) { - let mut velocity = Vec3::new(MAX_VELOCITY * (velocity_rng.gen::() - 0.5), 0., 0.); + let mut velocity = Vec3::new(MAX_VELOCITY * (velocity_rng.r#gen::() - 0.5), 0., 0.); if let Some(waves) = waves { // Step the movement and handle collisions as if the wave had been spawned at fixed time intervals @@ -414,7 +414,7 @@ fn spawn_birds( let bird_z = if args.ordered_z { (current_count + count) as f32 * 0.00001 } else { - bird_resources.transform_rng.gen::() + bird_resources.transform_rng.r#gen::() }; let (transform, velocity) = bird_velocity_transform( @@ -427,9 +427,9 @@ fn spawn_birds( let color = if args.vary_per_instance { Color::linear_rgb( - bird_resources.color_rng.gen(), - bird_resources.color_rng.gen(), - bird_resources.color_rng.gen(), + bird_resources.color_rng.r#gen(), + bird_resources.color_rng.r#gen(), + bird_resources.color_rng.r#gen(), ) } else { color @@ -457,7 +457,7 @@ fn spawn_birds( let bird_z = if args.ordered_z { (current_count + count) as f32 * 0.00001 } else { - bird_resources.transform_rng.gen::() + bird_resources.transform_rng.r#gen::() }; let (transform, velocity) = bird_velocity_transform( @@ -492,9 +492,9 @@ fn spawn_birds( counter.count += spawn_count; counter.color = Color::linear_rgb( - bird_resources.color_rng.gen(), - bird_resources.color_rng.gen(), - bird_resources.color_rng.gen(), + bird_resources.color_rng.r#gen(), + bird_resources.color_rng.r#gen(), + bird_resources.color_rng.r#gen(), ); } @@ -575,7 +575,7 @@ fn init_textures(textures: &mut Vec>, args: &Args, images: &mut As // This isn't strictly required in practical use unless you need your app to be deterministic. let mut color_rng = ChaCha8Rng::seed_from_u64(42); while textures.len() < args.material_texture_count { - let pixel = [color_rng.gen(), color_rng.gen(), color_rng.gen(), 255]; + let pixel = [color_rng.r#gen(), color_rng.r#gen(), color_rng.r#gen(), 255]; textures.push(images.add(Image::new_fill( Extent3d { width: BIRD_TEXTURE_SIZE as u32, @@ -622,7 +622,7 @@ fn init_materials( materials.extend( std::iter::repeat_with(|| { assets.add(ColorMaterial { - color: Color::srgb_u8(color_rng.gen(), color_rng.gen(), color_rng.gen()), + color: Color::srgb_u8(color_rng.r#gen(), color_rng.r#gen(), color_rng.r#gen()), texture: textures.choose(&mut texture_rng).cloned(), alpha_mode, }) diff --git a/examples/stress_tests/many_animated_sprites.rs b/examples/stress_tests/many_animated_sprites.rs index 3266735877ce2..e34a03195ae27 100644 --- a/examples/stress_tests/many_animated_sprites.rs +++ b/examples/stress_tests/many_animated_sprites.rs @@ -75,11 +75,11 @@ fn setup( for y in -half_y..half_y { for x in -half_x..half_x { let position = Vec2::new(x as f32, y as f32); - let translation = (position * tile_size).extend(rng.gen::()); - let rotation = Quat::from_rotation_z(rng.gen::()); - let scale = Vec3::splat(rng.gen::() * 2.0); + let translation = (position * tile_size).extend(rng.r#gen::()); + let rotation = Quat::from_rotation_z(rng.r#gen::()); + let scale = Vec3::splat(rng.r#gen::() * 2.0); let mut timer = Timer::from_seconds(0.1, TimerMode::Repeating); - timer.set_elapsed(Duration::from_secs_f32(rng.gen::())); + timer.set_elapsed(Duration::from_secs_f32(rng.r#gen::())); commands.spawn(( Sprite { diff --git a/examples/stress_tests/many_cubes.rs b/examples/stress_tests/many_cubes.rs index 6cf7f40845eb6..1d8a50313152f 100644 --- a/examples/stress_tests/many_cubes.rs +++ b/examples/stress_tests/many_cubes.rs @@ -262,7 +262,7 @@ fn init_textures(args: &Args, images: &mut Assets) -> Vec> // This isn't strictly required in practical use unless you need your app to be deterministic. let mut color_rng = ChaCha8Rng::seed_from_u64(42); let color_bytes: Vec = (0..(args.material_texture_count * 4)) - .map(|i| if (i % 4) == 3 { 255 } else { color_rng.gen() }) + .map(|i| if (i % 4) == 3 { 255 } else { color_rng.r#gen() }) .collect(); color_bytes .chunks(4) @@ -311,7 +311,7 @@ fn init_materials( materials.extend( std::iter::repeat_with(|| { assets.add(StandardMaterial { - base_color: Color::srgb_u8(color_rng.gen(), color_rng.gen(), color_rng.gen()), + base_color: Color::srgb_u8(color_rng.r#gen(), color_rng.r#gen(), color_rng.r#gen()), base_color_texture: textures.choose(&mut texture_rng).cloned(), ..default() }) diff --git a/examples/stress_tests/many_sprites.rs b/examples/stress_tests/many_sprites.rs index 0931822e91e9f..5bf65efb2d357 100644 --- a/examples/stress_tests/many_sprites.rs +++ b/examples/stress_tests/many_sprites.rs @@ -77,9 +77,9 @@ fn setup(mut commands: Commands, assets: Res, color_tint: Res()); - let rotation = Quat::from_rotation_z(rng.gen::()); - let scale = Vec3::splat(rng.gen::() * 2.0); + let translation = (position * tile_size).extend(rng.r#gen::()); + let rotation = Quat::from_rotation_z(rng.r#gen::()); + let scale = Vec3::splat(rng.r#gen::() * 2.0); sprites.push(( Sprite { diff --git a/examples/stress_tests/many_text2d.rs b/examples/stress_tests/many_text2d.rs index 22a7d8251739e..65c133a813c77 100644 --- a/examples/stress_tests/many_text2d.rs +++ b/examples/stress_tests/many_text2d.rs @@ -122,9 +122,9 @@ fn setup(mut commands: Commands, font: Res, args: Res) { for y in -half_y..half_y { for x in -half_x..half_x { let position = Vec2::new(x as f32, y as f32); - let translation = (position * tile_size).extend(rng.gen::()); - let rotation = Quat::from_rotation_z(rng.gen::()); - let scale = Vec3::splat(rng.gen::() * 2.0); + let translation = (position * tile_size).extend(rng.r#gen::()); + let rotation = Quat::from_rotation_z(rng.r#gen::()); + let scale = Vec3::splat(rng.r#gen::() * 2.0); let color = Hsla::hsl(rng.gen_range(0.0..360.0), 0.8, 0.8); text2ds.push(( diff --git a/examples/stress_tests/transform_hierarchy.rs b/examples/stress_tests/transform_hierarchy.rs index 67448051e7547..5f717fe9d2d7e 100644 --- a/examples/stress_tests/transform_hierarchy.rs +++ b/examples/stress_tests/transform_hierarchy.rs @@ -298,8 +298,8 @@ fn setup(mut commands: Commands, cfg: Res) { &mut commands, &cfg.update_filter, Transform::from_xyz( - rng.gen::() * 500.0 - 250.0, - rng.gen::() * 500.0 - 250.0, + rng.r#gen::() * 500.0 - 250.0, + rng.r#gen::() * 500.0 - 250.0, 0.0, ), )); @@ -315,8 +315,8 @@ fn setup(mut commands: Commands, cfg: Res) { ..cfg.update_filter }, Transform::from_xyz( - rng.gen::() * 500.0 - 250.0, - rng.gen::() * 500.0 - 250.0, + rng.r#gen::() * 500.0 - 250.0, + rng.r#gen::() * 500.0 - 250.0, 0.0, ), )); @@ -405,7 +405,7 @@ fn spawn_tree( let mut cmd = commands.spawn_empty(); // check whether or not to update this node - let update = (rng.gen::() <= update_filter.probability) + let update = (rng.r#gen::() <= update_filter.probability) && (depth >= update_filter.min_depth && depth <= update_filter.max_depth); if update { diff --git a/examples/transforms/align.rs b/examples/transforms/align.rs index da3e52eaa2465..7e9fdd37790e1 100644 --- a/examples/transforms/align.rs +++ b/examples/transforms/align.rs @@ -75,8 +75,8 @@ fn setup( )); // Initialize random axes - let first = seeded_rng.gen(); - let second = seeded_rng.gen(); + let first = seeded_rng.r#gen(); + let second = seeded_rng.r#gen(); commands.spawn(RandomAxes(first, second)); // Finally, our ship that is going to rotate @@ -165,8 +165,8 @@ fn handle_keypress( ) { if keyboard.just_pressed(KeyCode::KeyR) { // Randomize the target axes - let first = seeded_rng.0.gen(); - let second = seeded_rng.0.gen(); + let first = seeded_rng.0.r#gen(); + let second = seeded_rng.0.r#gen(); **random_axes = RandomAxes(first, second); // Stop the ship and set it up to transform from its present orientation to the new one diff --git a/examples/ui/button.rs b/examples/ui/button.rs index 5f6c615736ac0..33210b4df6f89 100644 --- a/examples/ui/button.rs +++ b/examples/ui/button.rs @@ -57,7 +57,7 @@ fn setup(mut commands: Commands, assets: Res) { commands.spawn(button(&assets)); } -fn button(asset_server: &AssetServer) -> impl Bundle { +fn button(asset_server: &AssetServer) -> impl Bundle + use<> { ( Node { width: Val::Percent(100.0), diff --git a/examples/ui/font_atlas_debug.rs b/examples/ui/font_atlas_debug.rs index 32059e7e2e25b..06aa4b5bae48c 100644 --- a/examples/ui/font_atlas_debug.rs +++ b/examples/ui/font_atlas_debug.rs @@ -74,7 +74,7 @@ fn text_update_system( } for mut text in &mut query { - let c = seeded_rng.gen::() as char; + let c = seeded_rng.r#gen::() as char; let string = &mut **text; if !string.contains(c) { string.push(c); From 468fd12921d591079ffa73bb2e4b50fc44447fcf Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Fri, 21 Feb 2025 20:40:08 +1100 Subject: [PATCH 02/34] Switch to Edition 2024 --- Cargo.toml | 4 ++-- benches/Cargo.toml | 2 +- crates/bevy_a11y/Cargo.toml | 2 +- crates/bevy_animation/Cargo.toml | 2 +- crates/bevy_app/Cargo.toml | 2 +- crates/bevy_asset/Cargo.toml | 2 +- crates/bevy_asset/macros/Cargo.toml | 2 +- crates/bevy_audio/Cargo.toml | 2 +- crates/bevy_color/Cargo.toml | 4 ++-- crates/bevy_color/crates/gen_tests/Cargo.toml | 2 +- crates/bevy_core_pipeline/Cargo.toml | 2 +- crates/bevy_derive/Cargo.toml | 2 +- crates/bevy_derive/compile_fail/Cargo.toml | 2 +- crates/bevy_dev_tools/Cargo.toml | 2 +- crates/bevy_diagnostic/Cargo.toml | 2 +- crates/bevy_dylib/Cargo.toml | 2 +- crates/bevy_ecs/Cargo.toml | 4 ++-- crates/bevy_ecs/compile_fail/Cargo.toml | 2 +- crates/bevy_ecs/macros/Cargo.toml | 2 +- crates/bevy_encase_derive/Cargo.toml | 2 +- crates/bevy_gilrs/Cargo.toml | 2 +- crates/bevy_gizmos/Cargo.toml | 2 +- crates/bevy_gizmos/macros/Cargo.toml | 2 +- crates/bevy_gltf/Cargo.toml | 2 +- crates/bevy_image/Cargo.toml | 2 +- crates/bevy_input/Cargo.toml | 2 +- crates/bevy_input_focus/Cargo.toml | 4 ++-- crates/bevy_internal/Cargo.toml | 2 +- crates/bevy_log/Cargo.toml | 2 +- crates/bevy_macro_utils/Cargo.toml | 2 +- crates/bevy_math/Cargo.toml | 4 ++-- crates/bevy_mesh/Cargo.toml | 2 +- crates/bevy_mikktspace/Cargo.toml | 4 ++-- crates/bevy_pbr/Cargo.toml | 2 +- crates/bevy_picking/Cargo.toml | 2 +- crates/bevy_platform_support/Cargo.toml | 2 +- crates/bevy_ptr/Cargo.toml | 4 ++-- crates/bevy_reflect/Cargo.toml | 4 ++-- crates/bevy_reflect/compile_fail/Cargo.toml | 2 +- crates/bevy_reflect/derive/Cargo.toml | 2 +- crates/bevy_reflect/src/map.rs | 7 ++++--- crates/bevy_remote/Cargo.toml | 2 +- crates/bevy_render/Cargo.toml | 2 +- crates/bevy_render/macros/Cargo.toml | 2 +- crates/bevy_scene/Cargo.toml | 2 +- crates/bevy_sprite/Cargo.toml | 2 +- crates/bevy_state/Cargo.toml | 2 +- crates/bevy_state/macros/Cargo.toml | 2 +- crates/bevy_tasks/Cargo.toml | 2 +- crates/bevy_text/Cargo.toml | 2 +- crates/bevy_time/Cargo.toml | 2 +- crates/bevy_transform/Cargo.toml | 2 +- crates/bevy_ui/Cargo.toml | 2 +- crates/bevy_utils/Cargo.toml | 2 +- crates/bevy_window/Cargo.toml | 2 +- crates/bevy_winit/Cargo.toml | 2 +- errors/Cargo.toml | 2 +- examples/mobile/Cargo.toml | 2 +- examples/mobile/android_basic/Cargo.toml | 2 +- tests-integration/remapped-test/Cargo.toml | 2 +- tests-integration/simple-ecs-test/Cargo.toml | 2 +- tools/build-easefunction-graphs/Cargo.toml | 2 +- tools/build-templated-pages/Cargo.toml | 2 +- tools/build-wasm-example/Cargo.toml | 2 +- tools/ci/Cargo.toml | 2 +- tools/compile_fail_utils/Cargo.toml | 2 +- tools/example-showcase/Cargo.toml | 2 +- 67 files changed, 78 insertions(+), 77 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f5efb88019769..54a63a635ebb8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bevy" version = "0.16.0-dev" -edition = "2021" +edition = "2024" categories = ["game-engines", "graphics", "gui", "rendering"] description = "A refreshingly simple data-driven game engine and app framework" exclude = ["assets/", "tools/", ".github/", "crates/", "examples/wasm/assets/"] @@ -10,7 +10,7 @@ keywords = ["game", "engine", "gamedev", "graphics", "bevy"] license = "MIT OR Apache-2.0" repository = "https://github.com/bevyengine/bevy" documentation = "https://docs.rs/bevy" -rust-version = "1.83.0" +rust-version = "1.85.0" [workspace] resolver = "2" diff --git a/benches/Cargo.toml b/benches/Cargo.toml index d4b032eab0339..7e19a58cc0e55 100644 --- a/benches/Cargo.toml +++ b/benches/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "benches" -edition = "2021" +edition = "2024" description = "Benchmarks that test Bevy's performance" publish = false license = "MIT OR Apache-2.0" diff --git a/crates/bevy_a11y/Cargo.toml b/crates/bevy_a11y/Cargo.toml index 0037ccf29dc88..4da1040620cf1 100644 --- a/crates/bevy_a11y/Cargo.toml +++ b/crates/bevy_a11y/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bevy_a11y" version = "0.16.0-dev" -edition = "2021" +edition = "2024" description = "Provides accessibility support for Bevy Engine" homepage = "https://bevyengine.org" repository = "https://github.com/bevyengine/bevy" diff --git a/crates/bevy_animation/Cargo.toml b/crates/bevy_animation/Cargo.toml index 5b906fed7c496..a1e890017a769 100644 --- a/crates/bevy_animation/Cargo.toml +++ b/crates/bevy_animation/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bevy_animation" version = "0.16.0-dev" -edition = "2021" +edition = "2024" description = "Provides animation functionality for Bevy Engine" homepage = "https://bevyengine.org" repository = "https://github.com/bevyengine/bevy" diff --git a/crates/bevy_app/Cargo.toml b/crates/bevy_app/Cargo.toml index e4fb9748c7ebc..d62428abdaa4e 100644 --- a/crates/bevy_app/Cargo.toml +++ b/crates/bevy_app/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bevy_app" version = "0.16.0-dev" -edition = "2021" +edition = "2024" description = "Provides core App functionality for Bevy Engine" homepage = "https://bevyengine.org" repository = "https://github.com/bevyengine/bevy" diff --git a/crates/bevy_asset/Cargo.toml b/crates/bevy_asset/Cargo.toml index 7022eb4d5ab2a..f462cac503a9b 100644 --- a/crates/bevy_asset/Cargo.toml +++ b/crates/bevy_asset/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bevy_asset" version = "0.16.0-dev" -edition = "2021" +edition = "2024" description = "Provides asset functionality for Bevy Engine" homepage = "https://bevyengine.org" repository = "https://github.com/bevyengine/bevy" diff --git a/crates/bevy_asset/macros/Cargo.toml b/crates/bevy_asset/macros/Cargo.toml index 9b6c4f56a19ad..43562ae8063fd 100644 --- a/crates/bevy_asset/macros/Cargo.toml +++ b/crates/bevy_asset/macros/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bevy_asset_macros" version = "0.16.0-dev" -edition = "2021" +edition = "2024" description = "Derive implementations for bevy_asset" homepage = "https://bevyengine.org" repository = "https://github.com/bevyengine/bevy" diff --git a/crates/bevy_audio/Cargo.toml b/crates/bevy_audio/Cargo.toml index 4d7967977e78f..e6e875bc7cb58 100644 --- a/crates/bevy_audio/Cargo.toml +++ b/crates/bevy_audio/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bevy_audio" version = "0.16.0-dev" -edition = "2021" +edition = "2024" description = "Provides audio functionality for Bevy Engine" homepage = "https://bevyengine.org" repository = "https://github.com/bevyengine/bevy" diff --git a/crates/bevy_color/Cargo.toml b/crates/bevy_color/Cargo.toml index 7115963e7f025..b1ab628e3aa46 100644 --- a/crates/bevy_color/Cargo.toml +++ b/crates/bevy_color/Cargo.toml @@ -1,13 +1,13 @@ [package] name = "bevy_color" version = "0.16.0-dev" -edition = "2021" +edition = "2024" description = "Types for representing and manipulating color values" homepage = "https://bevyengine.org" repository = "https://github.com/bevyengine/bevy" license = "MIT OR Apache-2.0" keywords = ["bevy", "color"] -rust-version = "1.83.0" +rust-version = "1.85.0" [dependencies] bevy_math = { path = "../bevy_math", version = "0.16.0-dev", default-features = false, features = [ diff --git a/crates/bevy_color/crates/gen_tests/Cargo.toml b/crates/bevy_color/crates/gen_tests/Cargo.toml index 357e7aaba6f06..e0f5940d505a8 100644 --- a/crates/bevy_color/crates/gen_tests/Cargo.toml +++ b/crates/bevy_color/crates/gen_tests/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "gen_tests" version = "0.1.0" -edition = "2021" +edition = "2024" publish = false [workspace] diff --git a/crates/bevy_core_pipeline/Cargo.toml b/crates/bevy_core_pipeline/Cargo.toml index 3994040369d70..1530a116ad2b2 100644 --- a/crates/bevy_core_pipeline/Cargo.toml +++ b/crates/bevy_core_pipeline/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bevy_core_pipeline" version = "0.16.0-dev" -edition = "2021" +edition = "2024" authors = [ "Bevy Contributors ", "Carter Anderson ", diff --git a/crates/bevy_derive/Cargo.toml b/crates/bevy_derive/Cargo.toml index 3cac10ce09f08..1c4cb4adccf98 100644 --- a/crates/bevy_derive/Cargo.toml +++ b/crates/bevy_derive/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bevy_derive" version = "0.16.0-dev" -edition = "2021" +edition = "2024" description = "Provides derive implementations for Bevy Engine" homepage = "https://bevyengine.org" repository = "https://github.com/bevyengine/bevy" diff --git a/crates/bevy_derive/compile_fail/Cargo.toml b/crates/bevy_derive/compile_fail/Cargo.toml index 45dcf8aaafbe7..a9ad3e95e1179 100644 --- a/crates/bevy_derive/compile_fail/Cargo.toml +++ b/crates/bevy_derive/compile_fail/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bevy_derive_compile_fail" -edition = "2021" +edition = "2024" description = "Compile fail tests for Bevy Engine's various macros" homepage = "https://bevyengine.org" repository = "https://github.com/bevyengine/bevy" diff --git a/crates/bevy_dev_tools/Cargo.toml b/crates/bevy_dev_tools/Cargo.toml index 0b9618d20d9eb..ad0f2c515ca26 100644 --- a/crates/bevy_dev_tools/Cargo.toml +++ b/crates/bevy_dev_tools/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bevy_dev_tools" version = "0.16.0-dev" -edition = "2021" +edition = "2024" description = "Collection of developer tools for the Bevy Engine" homepage = "https://bevyengine.org" repository = "https://github.com/bevyengine/bevy" diff --git a/crates/bevy_diagnostic/Cargo.toml b/crates/bevy_diagnostic/Cargo.toml index a21e09eb9a8ac..80afd7022f038 100644 --- a/crates/bevy_diagnostic/Cargo.toml +++ b/crates/bevy_diagnostic/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bevy_diagnostic" version = "0.16.0-dev" -edition = "2021" +edition = "2024" description = "Provides diagnostic functionality for Bevy Engine" homepage = "https://bevyengine.org" repository = "https://github.com/bevyengine/bevy" diff --git a/crates/bevy_dylib/Cargo.toml b/crates/bevy_dylib/Cargo.toml index de96856f92b48..26aec33b8358c 100644 --- a/crates/bevy_dylib/Cargo.toml +++ b/crates/bevy_dylib/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bevy_dylib" version = "0.16.0-dev" -edition = "2021" +edition = "2024" description = "Force the Bevy Engine to be dynamically linked for faster linking" homepage = "https://bevyengine.org" repository = "https://github.com/bevyengine/bevy" diff --git a/crates/bevy_ecs/Cargo.toml b/crates/bevy_ecs/Cargo.toml index bd3d02d0308eb..89a13c5e9a162 100644 --- a/crates/bevy_ecs/Cargo.toml +++ b/crates/bevy_ecs/Cargo.toml @@ -1,14 +1,14 @@ [package] name = "bevy_ecs" version = "0.16.0-dev" -edition = "2021" +edition = "2024" description = "Bevy Engine's entity component system" homepage = "https://bevyengine.org" repository = "https://github.com/bevyengine/bevy" license = "MIT OR Apache-2.0" keywords = ["ecs", "game", "bevy"] categories = ["game-engines", "data-structures"] -rust-version = "1.83.0" +rust-version = "1.85.0" [features] default = ["std", "bevy_reflect", "async_executor"] diff --git a/crates/bevy_ecs/compile_fail/Cargo.toml b/crates/bevy_ecs/compile_fail/Cargo.toml index 76f7ec8b8aaa4..48e3857f53acd 100644 --- a/crates/bevy_ecs/compile_fail/Cargo.toml +++ b/crates/bevy_ecs/compile_fail/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bevy_ecs_compile_fail" -edition = "2021" +edition = "2024" description = "Compile fail tests for Bevy Engine's entity component system" homepage = "https://bevyengine.org" repository = "https://github.com/bevyengine/bevy" diff --git a/crates/bevy_ecs/macros/Cargo.toml b/crates/bevy_ecs/macros/Cargo.toml index f1ea54894a1bb..3325a102de3ba 100644 --- a/crates/bevy_ecs/macros/Cargo.toml +++ b/crates/bevy_ecs/macros/Cargo.toml @@ -2,7 +2,7 @@ name = "bevy_ecs_macros" version = "0.16.0-dev" description = "Bevy ECS Macros" -edition = "2021" +edition = "2024" license = "MIT OR Apache-2.0" [lib] diff --git a/crates/bevy_encase_derive/Cargo.toml b/crates/bevy_encase_derive/Cargo.toml index f35c44db3d43c..b2f1b92d82bee 100644 --- a/crates/bevy_encase_derive/Cargo.toml +++ b/crates/bevy_encase_derive/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bevy_encase_derive" version = "0.16.0-dev" -edition = "2021" +edition = "2024" description = "Bevy derive macro for encase" homepage = "https://bevyengine.org" repository = "https://github.com/bevyengine/bevy" diff --git a/crates/bevy_gilrs/Cargo.toml b/crates/bevy_gilrs/Cargo.toml index 9b3996c05f387..eff9c4bf4f12b 100644 --- a/crates/bevy_gilrs/Cargo.toml +++ b/crates/bevy_gilrs/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bevy_gilrs" version = "0.16.0-dev" -edition = "2021" +edition = "2024" description = "Gamepad system made using Gilrs for Bevy Engine" homepage = "https://bevyengine.org" repository = "https://github.com/bevyengine/bevy" diff --git a/crates/bevy_gizmos/Cargo.toml b/crates/bevy_gizmos/Cargo.toml index 6e51c609442a7..3a264c6244609 100644 --- a/crates/bevy_gizmos/Cargo.toml +++ b/crates/bevy_gizmos/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bevy_gizmos" version = "0.16.0-dev" -edition = "2021" +edition = "2024" description = "Provides gizmos for Bevy Engine" homepage = "https://bevyengine.org" repository = "https://github.com/bevyengine/bevy" diff --git a/crates/bevy_gizmos/macros/Cargo.toml b/crates/bevy_gizmos/macros/Cargo.toml index 3862914d7218c..b38a3c5374bf0 100644 --- a/crates/bevy_gizmos/macros/Cargo.toml +++ b/crates/bevy_gizmos/macros/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bevy_gizmos_macros" version = "0.16.0-dev" -edition = "2021" +edition = "2024" description = "Derive implementations for bevy_gizmos" homepage = "https://bevyengine.org" repository = "https://github.com/bevyengine/bevy" diff --git a/crates/bevy_gltf/Cargo.toml b/crates/bevy_gltf/Cargo.toml index da0d97ad9670a..9df182f70d64e 100644 --- a/crates/bevy_gltf/Cargo.toml +++ b/crates/bevy_gltf/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bevy_gltf" version = "0.16.0-dev" -edition = "2021" +edition = "2024" description = "Bevy Engine GLTF loading" homepage = "https://bevyengine.org" repository = "https://github.com/bevyengine/bevy" diff --git a/crates/bevy_image/Cargo.toml b/crates/bevy_image/Cargo.toml index ceab1de1ce33e..f503315adec74 100644 --- a/crates/bevy_image/Cargo.toml +++ b/crates/bevy_image/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bevy_image" version = "0.16.0-dev" -edition = "2021" +edition = "2024" description = "Provides image types for Bevy Engine" homepage = "https://bevyengine.org" repository = "https://github.com/bevyengine/bevy" diff --git a/crates/bevy_input/Cargo.toml b/crates/bevy_input/Cargo.toml index fbbec96a760ad..2b09ed5e21136 100644 --- a/crates/bevy_input/Cargo.toml +++ b/crates/bevy_input/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bevy_input" version = "0.16.0-dev" -edition = "2021" +edition = "2024" description = "Provides input functionality for Bevy Engine" homepage = "https://bevyengine.org" repository = "https://github.com/bevyengine/bevy" diff --git a/crates/bevy_input_focus/Cargo.toml b/crates/bevy_input_focus/Cargo.toml index 49aaed4dc8ba4..72a159cf03063 100644 --- a/crates/bevy_input_focus/Cargo.toml +++ b/crates/bevy_input_focus/Cargo.toml @@ -1,13 +1,13 @@ [package] name = "bevy_input_focus" version = "0.16.0-dev" -edition = "2021" +edition = "2024" description = "Keyboard focus management" homepage = "https://bevyengine.org" repository = "https://github.com/bevyengine/bevy" license = "MIT OR Apache-2.0" keywords = ["bevy"] -rust-version = "1.83.0" +rust-version = "1.85.0" [features] default = ["std", "bevy_reflect", "bevy_ecs/async_executor"] diff --git a/crates/bevy_internal/Cargo.toml b/crates/bevy_internal/Cargo.toml index 0ac089a94c6f9..6c4f977e276fa 100644 --- a/crates/bevy_internal/Cargo.toml +++ b/crates/bevy_internal/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bevy_internal" version = "0.16.0-dev" -edition = "2021" +edition = "2024" description = "An internal Bevy crate used to facilitate optional dynamic linking via the 'dynamic_linking' feature" homepage = "https://bevyengine.org" repository = "https://github.com/bevyengine/bevy" diff --git a/crates/bevy_log/Cargo.toml b/crates/bevy_log/Cargo.toml index 6110734f9b326..1eca34f498fa5 100644 --- a/crates/bevy_log/Cargo.toml +++ b/crates/bevy_log/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bevy_log" version = "0.16.0-dev" -edition = "2021" +edition = "2024" description = "Provides logging for Bevy Engine" homepage = "https://bevyengine.org" repository = "https://github.com/bevyengine/bevy" diff --git a/crates/bevy_macro_utils/Cargo.toml b/crates/bevy_macro_utils/Cargo.toml index 4fb0e8291bf64..fd13328673e86 100644 --- a/crates/bevy_macro_utils/Cargo.toml +++ b/crates/bevy_macro_utils/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bevy_macro_utils" version = "0.16.0-dev" -edition = "2021" +edition = "2024" description = "A collection of utils for Bevy Engine" homepage = "https://bevyengine.org" repository = "https://github.com/bevyengine/bevy" diff --git a/crates/bevy_math/Cargo.toml b/crates/bevy_math/Cargo.toml index a4c098d20a649..d7e4f83ce6b22 100644 --- a/crates/bevy_math/Cargo.toml +++ b/crates/bevy_math/Cargo.toml @@ -1,13 +1,13 @@ [package] name = "bevy_math" version = "0.16.0-dev" -edition = "2021" +edition = "2024" description = "Provides math functionality for Bevy Engine" homepage = "https://bevyengine.org" repository = "https://github.com/bevyengine/bevy" license = "MIT OR Apache-2.0" keywords = ["bevy"] -rust-version = "1.83.0" +rust-version = "1.85.0" [dependencies] glam = { version = "0.29", default-features = false, features = ["bytemuck"] } diff --git a/crates/bevy_mesh/Cargo.toml b/crates/bevy_mesh/Cargo.toml index ffcc2f72e2969..7d0ffdf5b6921 100644 --- a/crates/bevy_mesh/Cargo.toml +++ b/crates/bevy_mesh/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bevy_mesh" version = "0.16.0-dev" -edition = "2021" +edition = "2024" description = "Provides mesh types for Bevy Engine" homepage = "https://bevyengine.org" repository = "https://github.com/bevyengine/bevy" diff --git a/crates/bevy_mikktspace/Cargo.toml b/crates/bevy_mikktspace/Cargo.toml index 0ab431aa8fa9d..08eca4cc6977e 100644 --- a/crates/bevy_mikktspace/Cargo.toml +++ b/crates/bevy_mikktspace/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bevy_mikktspace" version = "0.16.0-dev" -edition = "2021" +edition = "2024" authors = [ "Benjamin Wasty ", "David Harvey-Macaulay ", @@ -13,7 +13,7 @@ homepage = "https://bevyengine.org" repository = "https://github.com/bevyengine/bevy" license = "Zlib AND (MIT OR Apache-2.0)" keywords = ["bevy", "3D", "graphics", "algorithm", "tangent"] -rust-version = "1.76.0" +rust-version = "1.85.0" [features] default = ["std"] diff --git a/crates/bevy_pbr/Cargo.toml b/crates/bevy_pbr/Cargo.toml index 0b97ceedb9245..970bef928b4e4 100644 --- a/crates/bevy_pbr/Cargo.toml +++ b/crates/bevy_pbr/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bevy_pbr" version = "0.16.0-dev" -edition = "2021" +edition = "2024" description = "Adds PBR rendering to Bevy Engine" homepage = "https://bevyengine.org" repository = "https://github.com/bevyengine/bevy" diff --git a/crates/bevy_picking/Cargo.toml b/crates/bevy_picking/Cargo.toml index 70d470ffc134f..55d8e02162ebf 100644 --- a/crates/bevy_picking/Cargo.toml +++ b/crates/bevy_picking/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bevy_picking" version = "0.16.0-dev" -edition = "2021" +edition = "2024" description = "Provides screen picking functionality for Bevy Engine" homepage = "https://bevyengine.org" repository = "https://github.com/bevyengine/bevy" diff --git a/crates/bevy_platform_support/Cargo.toml b/crates/bevy_platform_support/Cargo.toml index 630b928f2d164..cd45267b5faaf 100644 --- a/crates/bevy_platform_support/Cargo.toml +++ b/crates/bevy_platform_support/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bevy_platform_support" version = "0.16.0-dev" -edition = "2021" +edition = "2024" description = "Platform compatibility support for Bevy Engine" homepage = "https://bevyengine.org" repository = "https://github.com/bevyengine/bevy" diff --git a/crates/bevy_ptr/Cargo.toml b/crates/bevy_ptr/Cargo.toml index d2c3db4fbc73c..0f56880bd41da 100644 --- a/crates/bevy_ptr/Cargo.toml +++ b/crates/bevy_ptr/Cargo.toml @@ -1,13 +1,13 @@ [package] name = "bevy_ptr" version = "0.16.0-dev" -edition = "2021" +edition = "2024" description = "Utilities for working with untyped pointers in a more safe way" homepage = "https://bevyengine.org" repository = "https://github.com/bevyengine/bevy" license = "MIT OR Apache-2.0" keywords = ["bevy", "no_std"] -rust-version = "1.81.0" +rust-version = "1.85.0" [dependencies] diff --git a/crates/bevy_reflect/Cargo.toml b/crates/bevy_reflect/Cargo.toml index c15784d22d3a0..e2bfbd46ddcd7 100644 --- a/crates/bevy_reflect/Cargo.toml +++ b/crates/bevy_reflect/Cargo.toml @@ -1,13 +1,13 @@ [package] name = "bevy_reflect" version = "0.16.0-dev" -edition = "2021" +edition = "2024" description = "Dynamically interact with rust types" homepage = "https://bevyengine.org" repository = "https://github.com/bevyengine/bevy" license = "MIT OR Apache-2.0" keywords = ["bevy"] -rust-version = "1.81.0" +rust-version = "1.85.0" [features] default = ["std", "smallvec", "debug"] diff --git a/crates/bevy_reflect/compile_fail/Cargo.toml b/crates/bevy_reflect/compile_fail/Cargo.toml index 14e5eb2264f82..178711c5d03b0 100644 --- a/crates/bevy_reflect/compile_fail/Cargo.toml +++ b/crates/bevy_reflect/compile_fail/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bevy_reflect_compile_fail" -edition = "2021" +edition = "2024" description = "Compile fail tests for Bevy Engine's reflection system" homepage = "https://bevyengine.org" repository = "https://github.com/bevyengine/bevy" diff --git a/crates/bevy_reflect/derive/Cargo.toml b/crates/bevy_reflect/derive/Cargo.toml index bbdca03ca72dc..45899d52ff357 100644 --- a/crates/bevy_reflect/derive/Cargo.toml +++ b/crates/bevy_reflect/derive/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bevy_reflect_derive" version = "0.16.0-dev" -edition = "2021" +edition = "2024" description = "Derive implementations for bevy_reflect" homepage = "https://bevyengine.org" repository = "https://github.com/bevyengine/bevy" diff --git a/crates/bevy_reflect/src/map.rs b/crates/bevy_reflect/src/map.rs index f71689d598804..bc6f2fbc85a0d 100644 --- a/crates/bevy_reflect/src/map.rs +++ b/crates/bevy_reflect/src/map.rs @@ -189,7 +189,7 @@ impl MapInfo { macro_rules! hash_error { ( $key:expr ) => {{ let type_path = (*$key).reflect_type_path(); - if !$key.is_dynamic() { + let error = if !$key.is_dynamic() { format!( "the given key of type `{}` does not support hashing", type_path @@ -205,8 +205,9 @@ macro_rules! hash_error { s.type_path() ), } - } - .as_str() + }; + + error.as_str() }} } diff --git a/crates/bevy_remote/Cargo.toml b/crates/bevy_remote/Cargo.toml index 9d2f6f25f8d0a..d6c26a76c5fdc 100644 --- a/crates/bevy_remote/Cargo.toml +++ b/crates/bevy_remote/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bevy_remote" version = "0.16.0-dev" -edition = "2021" +edition = "2024" description = "The Bevy Remote Protocol" homepage = "https://bevyengine.org" repository = "https://github.com/bevyengine/bevy" diff --git a/crates/bevy_render/Cargo.toml b/crates/bevy_render/Cargo.toml index 4167185632fa3..7da865a0d219f 100644 --- a/crates/bevy_render/Cargo.toml +++ b/crates/bevy_render/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bevy_render" version = "0.16.0-dev" -edition = "2021" +edition = "2024" description = "Provides rendering functionality for Bevy Engine" homepage = "https://bevyengine.org" repository = "https://github.com/bevyengine/bevy" diff --git a/crates/bevy_render/macros/Cargo.toml b/crates/bevy_render/macros/Cargo.toml index 237cc516c5372..c3fc40b23e2fb 100644 --- a/crates/bevy_render/macros/Cargo.toml +++ b/crates/bevy_render/macros/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bevy_render_macros" version = "0.16.0-dev" -edition = "2021" +edition = "2024" description = "Derive implementations for bevy_render" homepage = "https://bevyengine.org" repository = "https://github.com/bevyengine/bevy" diff --git a/crates/bevy_scene/Cargo.toml b/crates/bevy_scene/Cargo.toml index ac263fe734e83..617ad93248f4f 100644 --- a/crates/bevy_scene/Cargo.toml +++ b/crates/bevy_scene/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bevy_scene" version = "0.16.0-dev" -edition = "2021" +edition = "2024" description = "Provides scene functionality for Bevy Engine" homepage = "https://bevyengine.org" repository = "https://github.com/bevyengine/bevy" diff --git a/crates/bevy_sprite/Cargo.toml b/crates/bevy_sprite/Cargo.toml index dc9c10154fe88..78c22edf9b1f9 100644 --- a/crates/bevy_sprite/Cargo.toml +++ b/crates/bevy_sprite/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bevy_sprite" version = "0.16.0-dev" -edition = "2021" +edition = "2024" description = "Provides sprite functionality for Bevy Engine" homepage = "https://bevyengine.org" repository = "https://github.com/bevyengine/bevy" diff --git a/crates/bevy_state/Cargo.toml b/crates/bevy_state/Cargo.toml index e6ef17c192640..9425961023faa 100644 --- a/crates/bevy_state/Cargo.toml +++ b/crates/bevy_state/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bevy_state" version = "0.16.0-dev" -edition = "2021" +edition = "2024" description = "Finite state machines for Bevy" homepage = "https://bevyengine.org" repository = "https://github.com/bevyengine/bevy" diff --git a/crates/bevy_state/macros/Cargo.toml b/crates/bevy_state/macros/Cargo.toml index 2b734d2d1c637..2f569f395ef03 100644 --- a/crates/bevy_state/macros/Cargo.toml +++ b/crates/bevy_state/macros/Cargo.toml @@ -2,7 +2,7 @@ name = "bevy_state_macros" version = "0.16.0-dev" description = "Macros for bevy_state" -edition = "2021" +edition = "2024" license = "MIT OR Apache-2.0" [lib] diff --git a/crates/bevy_tasks/Cargo.toml b/crates/bevy_tasks/Cargo.toml index 1020c6112d3b1..089aa917c1e27 100644 --- a/crates/bevy_tasks/Cargo.toml +++ b/crates/bevy_tasks/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bevy_tasks" version = "0.16.0-dev" -edition = "2021" +edition = "2024" description = "A task executor for Bevy Engine" homepage = "https://bevyengine.org" repository = "https://github.com/bevyengine/bevy" diff --git a/crates/bevy_text/Cargo.toml b/crates/bevy_text/Cargo.toml index a5e8dea07db51..2966f30d7ed16 100644 --- a/crates/bevy_text/Cargo.toml +++ b/crates/bevy_text/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bevy_text" version = "0.16.0-dev" -edition = "2021" +edition = "2024" description = "Provides text functionality for Bevy Engine" homepage = "https://bevyengine.org" repository = "https://github.com/bevyengine/bevy" diff --git a/crates/bevy_time/Cargo.toml b/crates/bevy_time/Cargo.toml index f209e01740db3..97fcda1b0cd6b 100644 --- a/crates/bevy_time/Cargo.toml +++ b/crates/bevy_time/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bevy_time" version = "0.16.0-dev" -edition = "2021" +edition = "2024" description = "Provides time functionality for Bevy Engine" homepage = "https://bevyengine.org" repository = "https://github.com/bevyengine/bevy" diff --git a/crates/bevy_transform/Cargo.toml b/crates/bevy_transform/Cargo.toml index 706f38b682cdd..96032c2c59f82 100644 --- a/crates/bevy_transform/Cargo.toml +++ b/crates/bevy_transform/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bevy_transform" version = "0.16.0-dev" -edition = "2021" +edition = "2024" description = "Provides transform functionality for Bevy Engine" homepage = "https://bevyengine.org" repository = "https://github.com/bevyengine/bevy" diff --git a/crates/bevy_ui/Cargo.toml b/crates/bevy_ui/Cargo.toml index c287ede55b5a3..2273f401d0dcd 100644 --- a/crates/bevy_ui/Cargo.toml +++ b/crates/bevy_ui/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bevy_ui" version = "0.16.0-dev" -edition = "2021" +edition = "2024" description = "A custom ECS-driven UI framework built specifically for Bevy Engine" homepage = "https://bevyengine.org" repository = "https://github.com/bevyengine/bevy" diff --git a/crates/bevy_utils/Cargo.toml b/crates/bevy_utils/Cargo.toml index 1b8682f2087c3..ce50c4c45f34a 100644 --- a/crates/bevy_utils/Cargo.toml +++ b/crates/bevy_utils/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bevy_utils" version = "0.16.0-dev" -edition = "2021" +edition = "2024" description = "A collection of utils for Bevy Engine" homepage = "https://bevyengine.org" repository = "https://github.com/bevyengine/bevy" diff --git a/crates/bevy_window/Cargo.toml b/crates/bevy_window/Cargo.toml index eb6dd3d782e81..2920c88361221 100644 --- a/crates/bevy_window/Cargo.toml +++ b/crates/bevy_window/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bevy_window" version = "0.16.0-dev" -edition = "2021" +edition = "2024" description = "Provides windowing functionality for Bevy Engine" homepage = "https://bevyengine.org" repository = "https://github.com/bevyengine/bevy" diff --git a/crates/bevy_winit/Cargo.toml b/crates/bevy_winit/Cargo.toml index 9df34c2142d7d..fa57f117fb650 100644 --- a/crates/bevy_winit/Cargo.toml +++ b/crates/bevy_winit/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bevy_winit" version = "0.16.0-dev" -edition = "2021" +edition = "2024" description = "A winit window and input backend for Bevy Engine" homepage = "https://bevyengine.org" repository = "https://github.com/bevyengine/bevy" diff --git a/errors/Cargo.toml b/errors/Cargo.toml index 8e11214e7d847..cfe187ebbddf1 100644 --- a/errors/Cargo.toml +++ b/errors/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "errors" -edition = "2021" +edition = "2024" description = "Documentation and tests for Bevy's error codes" publish = false license = "MIT OR Apache-2.0" diff --git a/examples/mobile/Cargo.toml b/examples/mobile/Cargo.toml index f23ff7e7ed7b8..d54c7deee36fb 100644 --- a/examples/mobile/Cargo.toml +++ b/examples/mobile/Cargo.toml @@ -2,7 +2,7 @@ name = "bevy_mobile_example" # Version is required by `cargo-apk`, though this value will never change. version = "0.0.0" -edition = "2021" +edition = "2024" description = "Example for building an iOS or Android app with Bevy" publish = false license = "MIT OR Apache-2.0" diff --git a/examples/mobile/android_basic/Cargo.toml b/examples/mobile/android_basic/Cargo.toml index 85e996a1b1b01..d1cc7fe470139 100644 --- a/examples/mobile/android_basic/Cargo.toml +++ b/examples/mobile/android_basic/Cargo.toml @@ -2,7 +2,7 @@ name = "bevy_mobile_example" # Version is required by `cargo-apk`, though this value will never change. version = "0.0.0" -edition = "2021" +edition = "2024" description = "Example for building an iOS or Android app with Bevy" publish = false license = "MIT OR Apache-2.0" diff --git a/tests-integration/remapped-test/Cargo.toml b/tests-integration/remapped-test/Cargo.toml index 808692ada0a7e..9a8feaa640064 100644 --- a/tests-integration/remapped-test/Cargo.toml +++ b/tests-integration/remapped-test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "remapped-test" -edition = "2021" +edition = "2024" [dependencies] bevi = { path = "../../", package = "bevy" } diff --git a/tests-integration/simple-ecs-test/Cargo.toml b/tests-integration/simple-ecs-test/Cargo.toml index b61c40eb6c7bd..d7e3abf37dfc5 100644 --- a/tests-integration/simple-ecs-test/Cargo.toml +++ b/tests-integration/simple-ecs-test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "simple-ecs-test" -edition = "2021" +edition = "2024" # We depend on bevy in both normal and dev dependencies to verify that the proc macros still work. diff --git a/tools/build-easefunction-graphs/Cargo.toml b/tools/build-easefunction-graphs/Cargo.toml index 3fac58b26644d..697ea0df1fa8c 100644 --- a/tools/build-easefunction-graphs/Cargo.toml +++ b/tools/build-easefunction-graphs/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "build-easefunction-graphs" -edition = "2021" +edition = "2024" description = "Tool that generates a svg for each EaseFunction to be included in the docs" publish = false license = "MIT OR Apache-2.0" diff --git a/tools/build-templated-pages/Cargo.toml b/tools/build-templated-pages/Cargo.toml index d19e553dd3781..70e5d827a2de2 100644 --- a/tools/build-templated-pages/Cargo.toml +++ b/tools/build-templated-pages/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "build-templated-pages" -edition = "2021" +edition = "2024" description = "Tool that checks and fixes undocumented features and examples" publish = false license = "MIT OR Apache-2.0" diff --git a/tools/build-wasm-example/Cargo.toml b/tools/build-wasm-example/Cargo.toml index 2ed005c0a1281..561297f29992f 100644 --- a/tools/build-wasm-example/Cargo.toml +++ b/tools/build-wasm-example/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "build-wasm-example" -edition = "2021" +edition = "2024" description = "Tool for building example for Wasm" publish = false license = "MIT OR Apache-2.0" diff --git a/tools/ci/Cargo.toml b/tools/ci/Cargo.toml index baf019789570e..65d6b7b1be7b2 100644 --- a/tools/ci/Cargo.toml +++ b/tools/ci/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ci" -edition = "2021" +edition = "2024" description = "Tool that enables running CI checks locally." publish = false license = "MIT OR Apache-2.0" diff --git a/tools/compile_fail_utils/Cargo.toml b/tools/compile_fail_utils/Cargo.toml index 96c56b4da6f38..7fa33d79620df 100644 --- a/tools/compile_fail_utils/Cargo.toml +++ b/tools/compile_fail_utils/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "compile_fail_utils" -edition = "2021" +edition = "2024" description = "Utils for compile tests used in the engine" homepage = "https://bevyengine.org" repository = "https://github.com/bevyengine/bevy" diff --git a/tools/example-showcase/Cargo.toml b/tools/example-showcase/Cargo.toml index c24b90b5767ec..f97dab44a7e1c 100644 --- a/tools/example-showcase/Cargo.toml +++ b/tools/example-showcase/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "example-showcase" -edition = "2021" +edition = "2024" description = "Tool for running examples or generating a showcase page for the website." publish = false license = "MIT OR Apache-2.0" From c260f13c134b973f8c02fabf406edd6e203dad75 Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Fri, 21 Feb 2025 20:42:23 +1100 Subject: [PATCH 03/34] bevy_ptr --- crates/bevy_ptr/src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/bevy_ptr/src/lib.rs b/crates/bevy_ptr/src/lib.rs index adb72409f96fb..e09cdb519f7a3 100644 --- a/crates/bevy_ptr/src/lib.rs +++ b/crates/bevy_ptr/src/lib.rs @@ -413,9 +413,10 @@ impl<'a> OwningPtr<'a> { /// Consumes a value and creates an [`OwningPtr`] to it while ensuring a double drop does not happen. #[inline] pub fn make) -> R, R>(val: T, f: F) -> R { + let mut val = ManuallyDrop::new(val); // SAFETY: The value behind the pointer will not get dropped or observed later, // so it's safe to promote it to an owning pointer. - f(unsafe { Self::make_internal(&mut ManuallyDrop::new(val)) }) + f(unsafe { Self::make_internal(&mut val) }) } } From c82e1fad62c769ba95126e8d156e088ab799312a Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Fri, 21 Feb 2025 20:42:30 +1100 Subject: [PATCH 04/34] bevy_tasks --- crates/bevy_tasks/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/bevy_tasks/src/lib.rs b/crates/bevy_tasks/src/lib.rs index 220f3dcae2631..6055960060ac8 100644 --- a/crates/bevy_tasks/src/lib.rs +++ b/crates/bevy_tasks/src/lib.rs @@ -33,8 +33,8 @@ pub use conditional_send::*; /// Use [`ConditionalSendFuture`] for a future with an optional Send trait bound, as on certain platforms (eg. Wasm), /// futures aren't Send. -pub trait ConditionalSendFuture: core::future::Future + ConditionalSend {} -impl ConditionalSendFuture for T {} +pub trait ConditionalSendFuture: Future + ConditionalSend {} +impl ConditionalSendFuture for T {} use alloc::boxed::Box; From 19c84dd9dbd140f520eb7e9076410ce19935efa5 Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Fri, 21 Feb 2025 20:42:38 +1100 Subject: [PATCH 05/34] bevy_reflect --- crates/bevy_reflect/src/map.rs | 8 +++----- crates/bevy_reflect/src/set.rs | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/crates/bevy_reflect/src/map.rs b/crates/bevy_reflect/src/map.rs index bc6f2fbc85a0d..1ce685b127854 100644 --- a/crates/bevy_reflect/src/map.rs +++ b/crates/bevy_reflect/src/map.rs @@ -189,7 +189,7 @@ impl MapInfo { macro_rules! hash_error { ( $key:expr ) => {{ let type_path = (*$key).reflect_type_path(); - let error = if !$key.is_dynamic() { + if !$key.is_dynamic() { format!( "the given key of type `{}` does not support hashing", type_path @@ -205,9 +205,7 @@ macro_rules! hash_error { s.type_path() ), } - }; - - error.as_str() + } }} } @@ -245,7 +243,7 @@ impl DynamicMap { } fn internal_hash(value: &dyn PartialReflect) -> u64 { - value.reflect_hash().expect(hash_error!(value)) + value.reflect_hash().expect(&hash_error!(value)) } fn internal_eq<'a>( diff --git a/crates/bevy_reflect/src/set.rs b/crates/bevy_reflect/src/set.rs index 52b4e8b9a100e..799499a8adcd7 100644 --- a/crates/bevy_reflect/src/set.rs +++ b/crates/bevy_reflect/src/set.rs @@ -167,7 +167,7 @@ impl DynamicSet { } fn internal_hash(value: &dyn PartialReflect) -> u64 { - value.reflect_hash().expect(hash_error!(value)) + value.reflect_hash().expect(&hash_error!(value)) } fn internal_eq( From 7307a59066cc3506a3d12df32725b05147e5ce46 Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Fri, 21 Feb 2025 20:42:44 +1100 Subject: [PATCH 06/34] bevy_ecs_macros --- crates/bevy_ecs/macros/src/component.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bevy_ecs/macros/src/component.rs b/crates/bevy_ecs/macros/src/component.rs index 76732c0b895ac..0d455f6cc7fa1 100644 --- a/crates/bevy_ecs/macros/src/component.rs +++ b/crates/bevy_ecs/macros/src/component.rs @@ -257,7 +257,7 @@ pub fn derive_component(input: TokenStream) -> TokenStream { fn visit_entities(data: &Data, bevy_ecs_path: &Path, is_relationship: bool) -> TokenStream2 { match data { - Data::Struct(DataStruct { ref fields, .. }) => { + Data::Struct(DataStruct { fields, .. }) => { let mut visited_fields = Vec::new(); let mut visited_indices = Vec::new(); match fields { From 044d5575d9ebe798f3d88d8230cb515ee133d023 Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Fri, 21 Feb 2025 20:44:30 +1100 Subject: [PATCH 07/34] bevy_math --- crates/bevy_math/src/sampling/shape_sampling.rs | 6 +++--- crates/bevy_math/src/sampling/standard.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/bevy_math/src/sampling/shape_sampling.rs b/crates/bevy_math/src/sampling/shape_sampling.rs index d1371114bd6d3..3be0ead1da98e 100644 --- a/crates/bevy_math/src/sampling/shape_sampling.rs +++ b/crates/bevy_math/src/sampling/shape_sampling.rs @@ -234,7 +234,7 @@ impl ShapeSample for Rectangle { fn sample_boundary(&self, rng: &mut R) -> Vec2 { let primary_side = rng.gen_range(-1.0..1.0); - let other_side = if rng.gen() { -1.0 } else { 1.0 }; + let other_side = if rng.r#gen() { -1.0 } else { 1.0 }; if self.half_size.x + self.half_size.y > 0.0 { if rng.gen_bool((self.half_size.x / (self.half_size.x + self.half_size.y)) as f64) { @@ -261,7 +261,7 @@ impl ShapeSample for Cuboid { fn sample_boundary(&self, rng: &mut R) -> Vec3 { let primary_side1 = rng.gen_range(-1.0..1.0); let primary_side2 = rng.gen_range(-1.0..1.0); - let other_side = if rng.gen() { -1.0 } else { 1.0 }; + let other_side = if rng.r#gen() { -1.0 } else { 1.0 }; if let Ok(dist) = WeightedIndex::new([ self.half_size.y * self.half_size.z, @@ -425,7 +425,7 @@ impl ShapeSample for Cylinder { if self.radius + 2.0 * self.half_height > 0.0 { if rng.gen_bool((self.radius / (self.radius + 2.0 * self.half_height)) as f64) { let Vec2 { x, y: z } = self.base().sample_interior(rng); - if rng.gen() { + if rng.r#gen() { Vec3::new(x, self.half_height, z) } else { Vec3::new(x, -self.half_height, z) diff --git a/crates/bevy_math/src/sampling/standard.rs b/crates/bevy_math/src/sampling/standard.rs index 6750d5c6d5fac..7de8270e30ea1 100644 --- a/crates/bevy_math/src/sampling/standard.rs +++ b/crates/bevy_math/src/sampling/standard.rs @@ -49,7 +49,7 @@ where { /// Construct a value of this type uniformly at random using `rng` as the source of randomness. fn from_rng(rng: &mut R) -> Self { - rng.gen() + rng.r#gen() } } From de9ab7bf373d48b8f6305b58568831b26b91bf46 Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Fri, 21 Feb 2025 20:44:43 +1100 Subject: [PATCH 08/34] bevy_ecs --- crates/bevy_ecs/src/schedule/graph/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bevy_ecs/src/schedule/graph/mod.rs b/crates/bevy_ecs/src/schedule/graph/mod.rs index ed25b612ea86a..a7ef79dbe113c 100644 --- a/crates/bevy_ecs/src/schedule/graph/mod.rs +++ b/crates/bevy_ecs/src/schedule/graph/mod.rs @@ -276,7 +276,7 @@ pub fn simple_cycles_in_component(graph: &DiGraph, scc: &[NodeId]) -> Vec Date: Fri, 21 Feb 2025 20:50:53 +1100 Subject: [PATCH 09/34] bevy_mesh --- crates/bevy_mesh/src/mesh.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/crates/bevy_mesh/src/mesh.rs b/crates/bevy_mesh/src/mesh.rs index a07924df2d021..44b313434e299 100644 --- a/crates/bevy_mesh/src/mesh.rs +++ b/crates/bevy_mesh/src/mesh.rs @@ -881,7 +881,7 @@ impl Mesh { "mesh transform scale cannot be zero on more than one axis" ); - if let Some(VertexAttributeValues::Float32x3(ref mut positions)) = + if let Some(VertexAttributeValues::Float32x3(positions)) = self.attribute_mut(Mesh::ATTRIBUTE_POSITION) { // Apply scale, rotation, and translation to vertex positions @@ -898,7 +898,7 @@ impl Mesh { return; } - if let Some(VertexAttributeValues::Float32x3(ref mut normals)) = + if let Some(VertexAttributeValues::Float32x3(normals)) = self.attribute_mut(Mesh::ATTRIBUTE_NORMAL) { // Transform normals, taking into account non-uniform scaling and rotation @@ -909,7 +909,7 @@ impl Mesh { }); } - if let Some(VertexAttributeValues::Float32x3(ref mut tangents)) = + if let Some(VertexAttributeValues::Float32x3(tangents)) = self.attribute_mut(Mesh::ATTRIBUTE_TANGENT) { // Transform tangents, taking into account non-uniform scaling and rotation @@ -936,7 +936,7 @@ impl Mesh { return; } - if let Some(VertexAttributeValues::Float32x3(ref mut positions)) = + if let Some(VertexAttributeValues::Float32x3(positions)) = self.attribute_mut(Mesh::ATTRIBUTE_POSITION) { // Apply translation to vertex positions @@ -958,7 +958,7 @@ impl Mesh { /// /// `Aabb` of entities with modified mesh are not updated automatically. pub fn rotate_by(&mut self, rotation: Quat) { - if let Some(VertexAttributeValues::Float32x3(ref mut positions)) = + if let Some(VertexAttributeValues::Float32x3(positions)) = self.attribute_mut(Mesh::ATTRIBUTE_POSITION) { // Apply rotation to vertex positions @@ -972,7 +972,7 @@ impl Mesh { return; } - if let Some(VertexAttributeValues::Float32x3(ref mut normals)) = + if let Some(VertexAttributeValues::Float32x3(normals)) = self.attribute_mut(Mesh::ATTRIBUTE_NORMAL) { // Transform normals @@ -981,7 +981,7 @@ impl Mesh { }); } - if let Some(VertexAttributeValues::Float32x3(ref mut tangents)) = + if let Some(VertexAttributeValues::Float32x3(tangents)) = self.attribute_mut(Mesh::ATTRIBUTE_TANGENT) { // Transform tangents @@ -1010,7 +1010,7 @@ impl Mesh { "mesh transform scale cannot be zero on more than one axis" ); - if let Some(VertexAttributeValues::Float32x3(ref mut positions)) = + if let Some(VertexAttributeValues::Float32x3(positions)) = self.attribute_mut(Mesh::ATTRIBUTE_POSITION) { // Apply scale to vertex positions @@ -1024,7 +1024,7 @@ impl Mesh { return; } - if let Some(VertexAttributeValues::Float32x3(ref mut normals)) = + if let Some(VertexAttributeValues::Float32x3(normals)) = self.attribute_mut(Mesh::ATTRIBUTE_NORMAL) { // Transform normals, taking into account non-uniform scaling @@ -1033,7 +1033,7 @@ impl Mesh { }); } - if let Some(VertexAttributeValues::Float32x3(ref mut tangents)) = + if let Some(VertexAttributeValues::Float32x3(tangents)) = self.attribute_mut(Mesh::ATTRIBUTE_TANGENT) { // Transform tangents, taking into account non-uniform scaling @@ -1096,7 +1096,7 @@ impl Mesh { /// Normalize joint weights so they sum to 1. pub fn normalize_joint_weights(&mut self) { if let Some(joints) = self.attribute_mut(Self::ATTRIBUTE_JOINT_WEIGHT) { - let VertexAttributeValues::Float32x4(ref mut joints) = joints else { + let VertexAttributeValues::Float32x4(joints) = joints else { panic!("unexpected joint weight format"); }; From d6d9ace7e2acd0bcb8e127aa2bf4fb5763f4e02a Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Fri, 21 Feb 2025 20:51:00 +1100 Subject: [PATCH 10/34] bevy_window --- crates/bevy_window/src/window.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bevy_window/src/window.rs b/crates/bevy_window/src/window.rs index 1acf96ee416ac..92455a908b2eb 100644 --- a/crates/bevy_window/src/window.rs +++ b/crates/bevy_window/src/window.rs @@ -663,7 +663,7 @@ impl WindowResizeConstraints { /// Will output warnings if it isn't. #[must_use] pub fn check_constraints(&self) -> Self { - let WindowResizeConstraints { + let &WindowResizeConstraints { mut min_width, mut min_height, mut max_width, From f85712bf724933ba31527e250cdc5e28b76cc358 Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Fri, 21 Feb 2025 21:14:36 +1100 Subject: [PATCH 11/34] benches --- benches/benches/bevy_ecs/change_detection.rs | 10 +++++----- benches/benches/bevy_ecs/world/entity_hash.rs | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/benches/benches/bevy_ecs/change_detection.rs b/benches/benches/bevy_ecs/change_detection.rs index 84a8d4c39e64a..92f3251abc2b4 100644 --- a/benches/benches/bevy_ecs/change_detection.rs +++ b/benches/benches/bevy_ecs/change_detection.rs @@ -95,7 +95,7 @@ fn all_added_detection_generic(group: &mut BenchGroup, e let query = generic_filter_query::>(&mut world); (world, query) }, - |(ref mut world, ref mut query)| { + |(world, query)| { let mut count = 0; for entity in query.iter(world) { black_box(entity); @@ -143,7 +143,7 @@ fn all_changed_detection_generic + Default + let query = generic_filter_query::>(&mut world); (world, query) }, - |(ref mut world, ref mut query)| { + |(world, query)| { let mut count = 0; for entity in query.iter(world) { black_box(entity); @@ -196,7 +196,7 @@ fn few_changed_detection_generic + Default + let query = generic_filter_query::>(&mut world); (world, query) }, - |(ref mut world, ref mut query)| { + |(world, query)| { for entity in query.iter(world) { black_box(entity); } @@ -237,7 +237,7 @@ fn none_changed_detection_generic + Default>( let query = generic_filter_query::>(&mut world); (world, query) }, - |(ref mut world, ref mut query)| { + |(world, query)| { let mut count = 0; for entity in query.iter(world) { black_box(entity); @@ -343,7 +343,7 @@ fn multiple_archetype_none_changed_detection_generic< let query = generic_filter_query::>(&mut world); (world, query) }, - |(ref mut world, ref mut query)| { + |(world, query)| { let mut count = 0; for entity in query.iter(world) { black_box(entity); diff --git a/benches/benches/bevy_ecs/world/entity_hash.rs b/benches/benches/bevy_ecs/world/entity_hash.rs index 5e92443bf1dbb..008b2cbbaa358 100644 --- a/benches/benches/bevy_ecs/world/entity_hash.rs +++ b/benches/benches/bevy_ecs/world/entity_hash.rs @@ -11,16 +11,16 @@ fn make_entity(rng: &mut impl Rng, size: usize) -> Entity { // * For ids, half are in [0, size), half are unboundedly larger. // * For generations, half are in [1, 3), half are unboundedly larger. - let x: f64 = rng.gen(); + let x: f64 = rng.r#gen(); let id = -(1.0 - x).log2() * (size as f64); - let x: f64 = rng.gen(); - let gen = 1.0 + -(1.0 - x).log2() * 2.0; + let x: f64 = rng.r#gen(); + let r#gen = 1.0 + -(1.0 - x).log2() * 2.0; // this is not reliable, but we're internal so a hack is ok - let bits = ((gen as u64) << 32) | (id as u64); + let bits = ((r#gen as u64) << 32) | (id as u64); let e = Entity::from_bits(bits); assert_eq!(e.index(), id as u32); - assert_eq!(e.generation(), gen as u32); + assert_eq!(e.generation(), r#gen as u32); e } From f8396dd0bf78140fe6ce3dcfb595cb5bb0ca09b0 Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Fri, 21 Feb 2025 21:45:08 +1100 Subject: [PATCH 12/34] bevy_core_pipeline --- crates/bevy_core_pipeline/src/bloom/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/bevy_core_pipeline/src/bloom/mod.rs b/crates/bevy_core_pipeline/src/bloom/mod.rs index 938f2f243be81..295b04c6ad0f1 100644 --- a/crates/bevy_core_pipeline/src/bloom/mod.rs +++ b/crates/bevy_core_pipeline/src/bloom/mod.rs @@ -152,7 +152,8 @@ impl ViewNode for BloomNode { render_context.command_encoder().push_debug_group("bloom"); let diagnostics = render_context.diagnostic_recorder(); - let time_span = diagnostics.time_span(render_context.command_encoder(), "bloom"); + let command_encoder = render_context.command_encoder(); + let time_span = diagnostics.time_span(command_encoder, "bloom"); // First downsample pass { From 7b44419eeaa97e6d2e71c7c19004c5a472382040 Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Fri, 21 Feb 2025 21:45:21 +1100 Subject: [PATCH 13/34] bevy_ecs_macros --- crates/bevy_ecs/macros/src/component.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/bevy_ecs/macros/src/component.rs b/crates/bevy_ecs/macros/src/component.rs index 0d455f6cc7fa1..13f41c3b3ab28 100644 --- a/crates/bevy_ecs/macros/src/component.rs +++ b/crates/bevy_ecs/macros/src/component.rs @@ -343,8 +343,8 @@ fn visit_entities(data: &Data, bevy_ecs_path: &Path, is_relationship: bool) -> T let field_member = ident_or_index(field.ident.as_ref(), index); let field_ident = format_ident!("field_{}", field_member); - variant_fields.push(quote!(#field_member: ref #field_ident)); - variant_fields_mut.push(quote!(#field_member: ref mut #field_ident)); + variant_fields.push(quote!(#field_member: #field_ident)); + variant_fields_mut.push(quote!(#field_member: #field_ident)); visit_variant_fields.push(quote!(#field_ident.visit_entities(&mut func);)); visit_variant_fields_mut From 8c20f88a7d1ebb31a31db584bca2ab1aee3fc9dd Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Fri, 21 Feb 2025 21:45:33 +1100 Subject: [PATCH 14/34] bevy_ecs --- crates/bevy_ecs/src/lib.rs | 7 ------- crates/bevy_ecs/src/observer/mod.rs | 14 +++++++++----- crates/bevy_ecs/src/schedule/mod.rs | 2 +- crates/bevy_ecs/src/schedule/schedule.rs | 2 +- crates/bevy_ecs/src/schedule/stepping.rs | 4 +++- crates/bevy_ecs/src/system/mod.rs | 2 +- 6 files changed, 15 insertions(+), 16 deletions(-) diff --git a/crates/bevy_ecs/src/lib.rs b/crates/bevy_ecs/src/lib.rs index 26b888f2302ce..8d415d7469183 100644 --- a/crates/bevy_ecs/src/lib.rs +++ b/crates/bevy_ecs/src/lib.rs @@ -2,13 +2,6 @@ unsafe_op_in_unsafe_fn, reason = "See #11590. To be removed once all applicable unsafe code has an unsafe block with a safety comment." )] -#![cfg_attr( - test, - expect( - dependency_on_unit_never_type_fallback, - reason = "See #17340. To be removed once Edition 2024 is released" - ) -)] #![doc = include_str!("../README.md")] #![cfg_attr( any(docsrs, docsrs_dep), diff --git a/crates/bevy_ecs/src/observer/mod.rs b/crates/bevy_ecs/src/observer/mod.rs index c44e961368985..525e9751a684e 100644 --- a/crates/bevy_ecs/src/observer/mod.rs +++ b/crates/bevy_ecs/src/observer/mod.rs @@ -1116,7 +1116,7 @@ mod tests { let mut world = World::new(); let observer = world - .add_observer(|_: Trigger| { + .add_observer(|_: Trigger| -> () { panic!("Observer triggered after being despawned.") }) .id(); @@ -1137,8 +1137,8 @@ mod tests { }); let observer = world - .add_observer(|_: Trigger| { - panic!("Observer triggered after being despawned.") + .add_observer(|_: Trigger| -> () { + panic!("Observer triggered after being despawned."); }) .flush(); world.despawn(observer); @@ -1168,7 +1168,9 @@ mod tests { world .spawn_empty() - .observe(|_: Trigger| panic!("Trigger routed to non-targeted entity.")); + .observe(|_: Trigger| -> () { + panic!("Trigger routed to non-targeted entity."); + }); world.add_observer(move |obs: Trigger, mut res: ResMut| { assert_eq!(obs.target(), Entity::PLACEHOLDER); res.observed("event_a"); @@ -1189,7 +1191,9 @@ mod tests { world .spawn_empty() - .observe(|_: Trigger| panic!("Trigger routed to non-targeted entity.")); + .observe(|_: Trigger| -> () { + panic!("Trigger routed to non-targeted entity."); + }); let entity = world .spawn_empty() .observe(|_: Trigger, mut res: ResMut| res.observed("a_1")) diff --git a/crates/bevy_ecs/src/schedule/mod.rs b/crates/bevy_ecs/src/schedule/mod.rs index eb48b2c4fe342..d7a66faa63d68 100644 --- a/crates/bevy_ecs/src/schedule/mod.rs +++ b/crates/bevy_ecs/src/schedule/mod.rs @@ -1192,7 +1192,7 @@ mod tests { let mut schedule = Schedule::new(TestSchedule); schedule .set_executor_kind($executor) - .add_systems(|| panic!("Executor ignored Stepping")); + .add_systems(|| -> () { panic!("Executor ignored Stepping") }); // Add our schedule to stepping & and enable stepping; this should // prevent any systems in the schedule from running diff --git a/crates/bevy_ecs/src/schedule/schedule.rs b/crates/bevy_ecs/src/schedule/schedule.rs index a613a8745fb9e..ef6c457332916 100644 --- a/crates/bevy_ecs/src/schedule/schedule.rs +++ b/crates/bevy_ecs/src/schedule/schedule.rs @@ -2064,7 +2064,7 @@ mod tests { schedule.configure_sets(Set.run_if(|| false)); schedule.add_systems( - (|| panic!("This system must not run")) + (|| -> () { panic!("This system must not run"); }) .ambiguous_with(|| ()) .in_set(Set), ); diff --git a/crates/bevy_ecs/src/schedule/stepping.rs b/crates/bevy_ecs/src/schedule/stepping.rs index f26da4cad370a..9b23fe9313841 100644 --- a/crates/bevy_ecs/src/schedule/stepping.rs +++ b/crates/bevy_ecs/src/schedule/stepping.rs @@ -1348,7 +1348,9 @@ mod tests { // // first system will be configured as `run_if(|| false)`, so it can // just panic if called - let first_system = move || panic!("first_system should not be run"); + let first_system = move || -> () { + panic!("first_system should not be run"); + }; // The second system, we need to know when it has been called, so we'll // add a resource for tracking if it has been run. The system will diff --git a/crates/bevy_ecs/src/system/mod.rs b/crates/bevy_ecs/src/system/mod.rs index 4fe489d253d1e..43f9c612d13c3 100644 --- a/crates/bevy_ecs/src/system/mod.rs +++ b/crates/bevy_ecs/src/system/mod.rs @@ -1648,7 +1648,7 @@ mod tests { #[should_panic] fn panic_inside_system() { let mut world = World::new(); - run_system(&mut world, || panic!("this system panics")); + run_system(&mut world, || -> () { panic!("this system panics"); }); } #[test] From e1ec1879392e03659a41d5baccbb166b724bf411 Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Fri, 21 Feb 2025 21:45:42 +1100 Subject: [PATCH 15/34] bevy_pbr --- crates/bevy_pbr/src/material.rs | 10 +++++----- crates/bevy_pbr/src/render/gpu_preprocess.rs | 10 +++++----- crates/bevy_pbr/src/render/mesh.rs | 6 +++--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/crates/bevy_pbr/src/material.rs b/crates/bevy_pbr/src/material.rs index a1c31fe26b737..d91ff14633af9 100644 --- a/crates/bevy_pbr/src/material.rs +++ b/crates/bevy_pbr/src/material.rs @@ -1228,8 +1228,8 @@ impl RenderAsset for PreparedMaterial { render_device, pipeline, default_opaque_render_method, - ref mut bind_group_allocator, - ref mut render_material_bindings, + bind_group_allocator, + render_material_bindings, opaque_draw_functions, alpha_mask_draw_functions, transmissive_draw_functions, @@ -1238,7 +1238,7 @@ impl RenderAsset for PreparedMaterial { alpha_mask_prepass_draw_functions, opaque_deferred_draw_functions, alpha_mask_deferred_draw_functions, - ref mut material_param, + material_param, ): &mut SystemParamItem, ) -> Result> { let draw_opaque_pbr = opaque_draw_functions.read().id::>(); @@ -1385,8 +1385,8 @@ impl RenderAsset for PreparedMaterial { _, _, _, - ref mut bind_group_allocator, - ref mut render_material_bindings, + bind_group_allocator, + render_material_bindings, .., ): &mut SystemParamItem, ) { diff --git a/crates/bevy_pbr/src/render/gpu_preprocess.rs b/crates/bevy_pbr/src/render/gpu_preprocess.rs index fbb54cb1e2871..e6f8addeed551 100644 --- a/crates/bevy_pbr/src/render/gpu_preprocess.rs +++ b/crates/bevy_pbr/src/render/gpu_preprocess.rs @@ -918,8 +918,8 @@ impl Node for LateGpuPreprocessNode { .. }, Some(PhasePreprocessBindGroups::IndirectOcclusionCulling { - late_indexed: ref maybe_late_indexed_bind_group, - late_non_indexed: ref maybe_late_non_indexed_bind_group, + late_indexed: maybe_late_indexed_bind_group, + late_non_indexed: maybe_late_non_indexed_bind_group, .. }), Some(late_indexed_indirect_parameters_buffer), @@ -1747,9 +1747,9 @@ pub fn prepare_preprocess_bind_groups( ) { // Grab the `BatchedInstanceBuffers`. let BatchedInstanceBuffers { - current_input_buffer: ref current_input_buffer_vec, - previous_input_buffer: ref previous_input_buffer_vec, - ref phase_instance_buffers, + current_input_buffer: current_input_buffer_vec, + previous_input_buffer: previous_input_buffer_vec, + phase_instance_buffers, } = batched_instance_buffers.into_inner(); let (Some(current_input_buffer), Some(previous_input_buffer)) = ( diff --git a/crates/bevy_pbr/src/render/mesh.rs b/crates/bevy_pbr/src/render/mesh.rs index caaa5877f5388..e9e21a6a66f36 100644 --- a/crates/bevy_pbr/src/render/mesh.rs +++ b/crates/bevy_pbr/src/render/mesh.rs @@ -1617,7 +1617,7 @@ pub fn collect_meshes_for_gpu_building( skin_uniforms: Res, frame_count: Res, ) { - let RenderMeshInstances::GpuBuilding(ref mut render_mesh_instances) = + let RenderMeshInstances::GpuBuilding(render_mesh_instances) = render_mesh_instances.into_inner() else { return; @@ -1625,8 +1625,8 @@ pub fn collect_meshes_for_gpu_building( // Collect render mesh instances. Build up the uniform buffer. let gpu_preprocessing::BatchedInstanceBuffers { - ref mut current_input_buffer, - ref mut previous_input_buffer, + current_input_buffer, + previous_input_buffer, .. } = batched_instance_buffers.into_inner(); From b93109ed736cd04c957fa13d16272267d47e566d Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Fri, 21 Feb 2025 21:45:53 +1100 Subject: [PATCH 16/34] bevy_render --- crates/bevy_render/src/batching/gpu_preprocessing.rs | 8 ++++---- crates/bevy_render/src/mesh/allocator.rs | 10 +++++----- crates/bevy_render/src/mesh/mod.rs | 2 +- crates/bevy_render/src/render_phase/mod.rs | 8 ++++---- .../bevy_render/src/render_resource/pipeline_cache.rs | 2 +- crates/bevy_render/src/renderer/mod.rs | 2 +- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/crates/bevy_render/src/batching/gpu_preprocessing.rs b/crates/bevy_render/src/batching/gpu_preprocessing.rs index 661bc901f41b9..3e29f72ba5840 100644 --- a/crates/bevy_render/src/batching/gpu_preprocessing.rs +++ b/crates/bevy_render/src/batching/gpu_preprocessing.rs @@ -1580,7 +1580,7 @@ pub fn batch_and_prepare_binned_render_phase( } // Reserve space in the occlusion culling buffers, if necessary. - if let Some(ref mut gpu_occlusion_culling_buffers) = gpu_occlusion_culling_buffers { + if let Some(gpu_occlusion_culling_buffers) = gpu_occlusion_culling_buffers { gpu_occlusion_culling_buffers .late_indexed .add_multiple(indexed_preparer.work_item_count); @@ -1985,9 +1985,9 @@ pub fn write_batched_instance_buffers( GFBD: GetFullBatchData, { let BatchedInstanceBuffers { - ref mut current_input_buffer, - ref mut previous_input_buffer, - ref mut phase_instance_buffers, + current_input_buffer, + previous_input_buffer, + phase_instance_buffers, } = gpu_array_buffer.into_inner(); current_input_buffer diff --git a/crates/bevy_render/src/mesh/allocator.rs b/crates/bevy_render/src/mesh/allocator.rs index 712fbc6272e8c..3af1ce1ea83fc 100644 --- a/crates/bevy_render/src/mesh/allocator.rs +++ b/crates/bevy_render/src/mesh/allocator.rs @@ -409,7 +409,7 @@ impl MeshAllocator { slab_id: SlabId, ) -> Option { match self.slabs.get(&slab_id)? { - Slab::General(ref general_slab) => { + Slab::General(general_slab) => { let slab_allocation = general_slab.resident_allocations.get(mesh_id)?; Some(MeshBufferSlice { buffer: general_slab.buffer.as_ref()?, @@ -420,7 +420,7 @@ impl MeshAllocator { }) } - Slab::LargeObject(ref large_object_slab) => { + Slab::LargeObject(large_object_slab) => { let buffer = large_object_slab.buffer.as_ref()?; Some(MeshBufferSlice { buffer, @@ -555,7 +555,7 @@ impl MeshAllocator { match *slab { Slab::General(ref mut general_slab) => { - let (Some(ref buffer), Some(allocated_range)) = ( + let (Some(buffer), Some(allocated_range)) = ( &general_slab.buffer, general_slab.pending_allocations.remove(mesh_id), ) else { @@ -706,7 +706,7 @@ impl MeshAllocator { // that succeeds. let mut mesh_allocation = None; for &slab_id in &*candidate_slabs { - let Some(Slab::General(ref mut slab)) = self.slabs.get_mut(&slab_id) else { + let Some(Slab::General(slab)) = self.slabs.get_mut(&slab_id) else { unreachable!("Slab not found") }; @@ -763,7 +763,7 @@ impl MeshAllocator { // Mark the allocation as pending. Don't copy it in just yet; further // meshes loaded this frame may result in its final allocation location // changing. - if let Some(Slab::General(ref mut general_slab)) = + if let Some(Slab::General(general_slab)) = self.slabs.get_mut(&mesh_allocation.slab_id) { general_slab diff --git a/crates/bevy_render/src/mesh/mod.rs b/crates/bevy_render/src/mesh/mod.rs index 40fb08d987bc6..fbd530c14da42 100644 --- a/crates/bevy_render/src/mesh/mod.rs +++ b/crates/bevy_render/src/mesh/mod.rs @@ -208,7 +208,7 @@ impl RenderAsset for RenderMesh { fn prepare_asset( mesh: Self::SourceAsset, _: AssetId, - (images, ref mut mesh_vertex_buffer_layouts): &mut SystemParamItem, + (images, mesh_vertex_buffer_layouts): &mut SystemParamItem, ) -> Result> { let morph_targets = match mesh.morph_targets() { Some(mt) => { diff --git a/crates/bevy_render/src/render_phase/mod.rs b/crates/bevy_render/src/render_phase/mod.rs index ede05bb2fc618..9c538a1377c1a 100644 --- a/crates/bevy_render/src/render_phase/mod.rs +++ b/crates/bevy_render/src/render_phase/mod.rs @@ -712,7 +712,7 @@ where } }, }, - UnbatchableBinnedEntityIndexSet::Dense(ref dynamic_offsets) => { + UnbatchableBinnedEntityIndexSet::Dense(dynamic_offsets) => { dynamic_offsets[entity_index].clone() } }; @@ -1003,7 +1003,7 @@ impl UnbatchableBinnedEntityIndexSet { }, }) } - UnbatchableBinnedEntityIndexSet::Dense(ref indices) => { + UnbatchableBinnedEntityIndexSet::Dense(indices) => { indices.get(entity_index as usize).cloned() } } @@ -1223,7 +1223,7 @@ impl UnbatchableBinnedEntityIndexSet { } UnbatchableBinnedEntityIndexSet::Sparse { - ref mut instance_range, + instance_range, first_indirect_parameters_index, } if instance_range.end == indices.instance_index && ((first_indirect_parameters_index.is_none() @@ -1261,7 +1261,7 @@ impl UnbatchableBinnedEntityIndexSet { *self = UnbatchableBinnedEntityIndexSet::Dense(new_dynamic_offsets); } - UnbatchableBinnedEntityIndexSet::Dense(ref mut dense_indices) => { + UnbatchableBinnedEntityIndexSet::Dense(dense_indices) => { dense_indices.push(indices); } } diff --git a/crates/bevy_render/src/render_resource/pipeline_cache.rs b/crates/bevy_render/src/render_resource/pipeline_cache.rs index fb82a495d2c62..7be7d1f724c43 100644 --- a/crates/bevy_render/src/render_resource/pipeline_cache.rs +++ b/crates/bevy_render/src/render_resource/pipeline_cache.rs @@ -882,7 +882,7 @@ impl PipelineCache { }; } - CachedPipelineState::Creating(ref mut task) => { + CachedPipelineState::Creating(task) => { match bevy_tasks::futures::check_ready(task) { Some(Ok(pipeline)) => { cached_pipeline.state = CachedPipelineState::Ok(pipeline); diff --git a/crates/bevy_render/src/renderer/mod.rs b/crates/bevy_render/src/renderer/mod.rs index 5845234191f63..7d81db5a19402 100644 --- a/crates/bevy_render/src/renderer/mod.rs +++ b/crates/bevy_render/src/renderer/mod.rs @@ -421,7 +421,7 @@ impl<'w> RenderContext<'w> { /// Gets the diagnostics recorder, used to track elapsed time and pipeline statistics /// of various render and compute passes. - pub fn diagnostic_recorder(&self) -> impl RecordDiagnostics { + pub fn diagnostic_recorder(&self) -> impl RecordDiagnostics + use<> { self.diagnostics_recorder.clone() } From c8bd66e41f272e103db743b9109ecdce2966d7e2 Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Fri, 21 Feb 2025 21:46:02 +1100 Subject: [PATCH 17/34] bevy_transform --- crates/bevy_transform/src/systems.rs | 55 ++++++++++++++++------------ 1 file changed, 32 insertions(+), 23 deletions(-) diff --git a/crates/bevy_transform/src/systems.rs b/crates/bevy_transform/src/systems.rs index 697e8af3b73cf..5f070c2ed65d3 100644 --- a/crates/bevy_transform/src/systems.rs +++ b/crates/bevy_transform/src/systems.rs @@ -452,30 +452,39 @@ mod test { app.world_mut() .spawn(Transform::IDENTITY) .add_children(&[child]); + + let mut child_entity = app + .world_mut() + .entity_mut(child); + + let mut grandchild_entity = temp + .entity_mut(grandchild); + + #[expect( + unsafe_code, + reason = "ChildOf is not mutable but this is for a test to produce a scenario that cannot happen" + )] + // SAFETY: ChildOf is not mutable but this is for a test to produce a scenario that cannot happen + let mut a = unsafe { + child_entity + .get_mut_assume_mutable::() + .unwrap() + }; + + // SAFETY: ChildOf is not mutable but this is for a test to produce a scenario that cannot happen + #[expect( + unsafe_code, + reason = "ChildOf is not mutable but this is for a test to produce a scenario that cannot happen" + )] + let mut b = unsafe { + grandchild_entity + .get_mut_assume_mutable::() + .unwrap() + }; + core::mem::swap( - #[expect( - unsafe_code, - reason = "ChildOf is not mutable but this is for a test to produce a scenario that cannot happen" - )] - // SAFETY: ChildOf is not mutable but this is for a test to produce a scenario that cannot happen - unsafe { - &mut *app - .world_mut() - .entity_mut(child) - .get_mut_assume_mutable::() - .unwrap() - }, - // SAFETY: ChildOf is not mutable but this is for a test to produce a scenario that cannot happen - #[expect( - unsafe_code, - reason = "ChildOf is not mutable but this is for a test to produce a scenario that cannot happen" - )] - unsafe { - &mut *temp - .entity_mut(grandchild) - .get_mut_assume_mutable::() - .unwrap() - }, + a.as_mut(), + b.as_mut(), ); app.update(); From 051970280c976f840c9c03b0771bbd54b74fcd43 Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Fri, 21 Feb 2025 21:46:08 +1100 Subject: [PATCH 18/34] bevy_ui --- crates/bevy_ui/src/render/ui_material_pipeline.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bevy_ui/src/render/ui_material_pipeline.rs b/crates/bevy_ui/src/render/ui_material_pipeline.rs index 202f3749222f5..8267668c0b297 100644 --- a/crates/bevy_ui/src/render/ui_material_pipeline.rs +++ b/crates/bevy_ui/src/render/ui_material_pipeline.rs @@ -597,7 +597,7 @@ impl RenderAsset for PreparedUiMaterial { fn prepare_asset( material: Self::SourceAsset, _: AssetId, - (render_device, pipeline, ref mut material_param): &mut SystemParamItem, + (render_device, pipeline, material_param): &mut SystemParamItem, ) -> Result> { match material.as_bind_group(&pipeline.ui_layout, render_device, material_param) { Ok(prepared) => Ok(PreparedUiMaterial { From 1984e6c506551586e34fd7f8206e2a7552f60e35 Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Fri, 21 Feb 2025 21:46:37 +1100 Subject: [PATCH 19/34] cargo fmt --- benches/benches/bevy_ecs/change_detection.rs | 4 +- benches/benches/bevy_ecs/components/mod.rs | 2 +- benches/benches/bevy_ecs/empty_archetypes.rs | 2 +- benches/benches/bevy_ecs/entity_cloning.rs | 2 +- benches/benches/bevy_ecs/events/mod.rs | 2 +- .../iteration/iter_frag_foreach_wide.rs | 22 +- .../iter_frag_foreach_wide_sparse.rs | 22 +- .../bevy_ecs/iteration/iter_frag_wide.rs | 22 +- .../iteration/iter_frag_wide_sparse.rs | 22 +- .../iteration/iter_simple_foreach_hybrid.rs | 2 +- .../iteration/iter_simple_foreach_wide.rs | 8 +- .../iter_simple_foreach_wide_sparse_set.rs | 8 +- .../bevy_ecs/iteration/iter_simple_wide.rs | 8 +- .../iteration/iter_simple_wide_sparse_set.rs | 8 +- benches/benches/bevy_ecs/iteration/mod.rs | 2 +- .../par_iter_simple_foreach_hybrid.rs | 2 +- .../benches/bevy_ecs/observers/propagation.rs | 2 +- benches/benches/bevy_ecs/observers/simple.rs | 2 +- benches/benches/bevy_ecs/world/entity_hash.rs | 2 +- benches/benches/bevy_ecs/world/world_get.rs | 2 +- benches/benches/bevy_math/bezier.rs | 4 +- .../bevy_picking/ray_mesh_intersection.rs | 2 +- benches/benches/bevy_reflect/function.rs | 2 +- benches/benches/bevy_reflect/list.rs | 4 +- benches/benches/bevy_reflect/map.rs | 4 +- benches/benches/bevy_reflect/path.rs | 4 +- benches/benches/bevy_reflect/struct.rs | 4 +- benches/benches/bevy_render/render_layers.rs | 2 +- benches/benches/bevy_render/torus.rs | 2 +- benches/benches/bevy_tasks/iter.rs | 2 +- crates/bevy_a11y/src/lib.rs | 4 +- crates/bevy_animation/src/animation_curves.rs | 6 +- crates/bevy_animation/src/gltf_curves.rs | 11 +- crates/bevy_animation/src/graph.rs | 6 +- crates/bevy_animation/src/lib.rs | 8 +- crates/bevy_animation/src/transition.rs | 4 +- crates/bevy_animation/src/util.rs | 6 +- crates/bevy_app/src/app.rs | 2 +- crates/bevy_app/src/lib.rs | 2 +- crates/bevy_app/src/plugin.rs | 2 +- crates/bevy_app/src/plugin_group.rs | 3 +- crates/bevy_app/src/schedule_runner.rs | 4 +- .../bevy_app/src/terminal_ctrl_c_handler.rs | 4 +- crates/bevy_asset/macros/src/lib.rs | 2 +- crates/bevy_asset/src/assets.rs | 4 +- crates/bevy_asset/src/direct_access_ext.rs | 2 +- crates/bevy_asset/src/handle.rs | 12 +- crates/bevy_asset/src/id.rs | 4 +- crates/bevy_asset/src/io/android.rs | 2 +- .../src/io/embedded/embedded_watcher.rs | 6 +- crates/bevy_asset/src/io/embedded/mod.rs | 12 +- crates/bevy_asset/src/io/file/file_asset.rs | 6 +- crates/bevy_asset/src/io/file/file_watcher.rs | 14 +- .../bevy_asset/src/io/file/sync_file_asset.rs | 6 +- crates/bevy_asset/src/io/memory.rs | 2 +- crates/bevy_asset/src/io/mod.rs | 2 +- crates/bevy_asset/src/io/processor_gated.rs | 2 +- crates/bevy_asset/src/io/source.rs | 26 +- crates/bevy_asset/src/io/wasm.rs | 6 +- crates/bevy_asset/src/lib.rs | 41 ++- crates/bevy_asset/src/loader.rs | 14 +- crates/bevy_asset/src/loader_builders.rs | 4 +- crates/bevy_asset/src/meta.rs | 6 +- crates/bevy_asset/src/path.rs | 10 +- crates/bevy_asset/src/processor/mod.rs | 55 ++-- crates/bevy_asset/src/processor/process.rs | 16 +- crates/bevy_asset/src/reflect.rs | 2 +- crates/bevy_asset/src/saver.rs | 4 +- crates/bevy_asset/src/server/info.rs | 16 +- crates/bevy_asset/src/server/loaders.rs | 14 +- crates/bevy_asset/src/server/mod.rs | 22 +- crates/bevy_asset/src/transformer.rs | 4 +- crates/bevy_audio/src/audio_source.rs | 2 +- crates/bevy_audio/src/lib.rs | 2 +- crates/bevy_audio/src/pitch.rs | 2 +- crates/bevy_color/src/color.rs | 4 +- crates/bevy_color/src/color_gradient.rs | 4 +- crates/bevy_color/src/color_ops.rs | 4 +- crates/bevy_color/src/color_range.rs | 2 +- crates/bevy_color/src/hwba.rs | 2 +- crates/bevy_color/src/laba.rs | 6 +- crates/bevy_color/src/lcha.rs | 8 +- crates/bevy_color/src/linear_rgba.rs | 6 +- crates/bevy_color/src/oklaba.rs | 6 +- crates/bevy_color/src/oklcha.rs | 6 +- crates/bevy_color/src/srgba.rs | 6 +- crates/bevy_color/src/xyza.rs | 8 +- .../src/auto_exposure/buffers.rs | 6 +- .../src/auto_exposure/compensation_curve.rs | 4 +- .../src/auto_exposure/mod.rs | 8 +- .../src/auto_exposure/node.rs | 2 +- .../src/auto_exposure/settings.rs | 2 +- crates/bevy_core_pipeline/src/blit/mod.rs | 4 +- .../src/bloom/downsampling_pipeline.rs | 2 +- crates/bevy_core_pipeline/src/bloom/mod.rs | 12 +- .../bevy_core_pipeline/src/bloom/settings.rs | 2 +- .../src/bloom/upsampling_pipeline.rs | 4 +- .../src/contrast_adaptive_sharpening/mod.rs | 6 +- .../src/core_2d/camera_2d.rs | 2 +- crates/bevy_core_pipeline/src/core_2d/mod.rs | 8 +- .../src/core_3d/camera_3d.rs | 2 +- crates/bevy_core_pipeline/src/core_3d/mod.rs | 20 +- .../src/deferred/copy_lighting_id.rs | 4 +- crates/bevy_core_pipeline/src/dof/mod.rs | 20 +- .../src/experimental/mip_generation/mod.rs | 12 +- .../src/fullscreen_vertex_shader/mod.rs | 2 +- crates/bevy_core_pipeline/src/fxaa/mod.rs | 6 +- .../bevy_core_pipeline/src/motion_blur/mod.rs | 8 +- .../src/motion_blur/node.rs | 2 +- .../src/motion_blur/pipeline.rs | 10 +- .../bevy_core_pipeline/src/msaa_writeback.rs | 2 +- crates/bevy_core_pipeline/src/oit/mod.rs | 16 +- .../bevy_core_pipeline/src/oit/resolve/mod.rs | 10 +- .../src/post_process/mod.rs | 10 +- crates/bevy_core_pipeline/src/prepass/mod.rs | 2 +- crates/bevy_core_pipeline/src/skybox/mod.rs | 8 +- .../bevy_core_pipeline/src/skybox/prepass.rs | 16 +- crates/bevy_core_pipeline/src/smaa/mod.rs | 12 +- crates/bevy_core_pipeline/src/taa/mod.rs | 10 +- .../bevy_core_pipeline/src/tonemapping/mod.rs | 6 +- .../src/tonemapping/node.rs | 2 +- .../bevy_core_pipeline/src/upscaling/mod.rs | 2 +- crates/bevy_derive/src/bevy_main.rs | 2 +- crates/bevy_derive/src/derefs.rs | 6 +- crates/bevy_derive/src/enum_variant_meta.rs | 4 +- crates/bevy_derive/src/lib.rs | 2 +- .../bevy_dev_tools/src/ci_testing/systems.rs | 2 +- crates/bevy_dev_tools/src/fps_overlay.rs | 4 +- crates/bevy_dev_tools/src/picking_debug.rs | 2 +- .../src/frame_count_diagnostics_plugin.rs | 4 +- .../src/frame_time_diagnostics_plugin.rs | 4 +- crates/bevy_diagnostic/src/lib.rs | 2 +- .../system_information_diagnostics_plugin.rs | 2 +- crates/bevy_ecs/macros/src/component.rs | 12 +- crates/bevy_ecs/macros/src/lib.rs | 6 +- crates/bevy_ecs/macros/src/query_data.rs | 4 +- crates/bevy_ecs/macros/src/query_filter.rs | 2 +- crates/bevy_ecs/macros/src/states.rs | 2 +- crates/bevy_ecs/src/bundle.rs | 2 +- crates/bevy_ecs/src/change_detection.rs | 4 +- crates/bevy_ecs/src/component.rs | 2 +- crates/bevy_ecs/src/entity/clone_entities.rs | 14 +- crates/bevy_ecs/src/entity/map_entities.rs | 12 +- crates/bevy_ecs/src/entity/mod.rs | 4 +- crates/bevy_ecs/src/entity/unique_slice.rs | 4 +- crates/bevy_ecs/src/entity/unique_vec.rs | 4 +- crates/bevy_ecs/src/entity/visit_entities.rs | 2 +- crates/bevy_ecs/src/event/collections.rs | 2 +- crates/bevy_ecs/src/event/mod.rs | 26 +- crates/bevy_ecs/src/lib.rs | 64 +++-- crates/bevy_ecs/src/name.rs | 6 +- crates/bevy_ecs/src/observer/mod.rs | 16 +- crates/bevy_ecs/src/query/access.rs | 2 +- crates/bevy_ecs/src/query/fetch.rs | 6 +- crates/bevy_ecs/src/query/filter.rs | 12 +- crates/bevy_ecs/src/query/iter.rs | 4 +- crates/bevy_ecs/src/query/mod.rs | 20 +- crates/bevy_ecs/src/query/state.rs | 17 +- crates/bevy_ecs/src/query/world_query.rs | 2 +- crates/bevy_ecs/src/reflect/bundle.rs | 2 +- crates/bevy_ecs/src/reflect/component.rs | 16 +- .../bevy_ecs/src/reflect/entity_commands.rs | 10 +- crates/bevy_ecs/src/reflect/mod.rs | 4 +- crates/bevy_ecs/src/reflect/resource.rs | 2 +- crates/bevy_ecs/src/relationship/mod.rs | 11 +- .../relationship_source_collection.rs | 2 +- crates/bevy_ecs/src/removal_detection.rs | 2 +- .../schedule/auto_insert_apply_deferred.rs | 4 +- crates/bevy_ecs/src/schedule/condition.rs | 2 +- crates/bevy_ecs/src/schedule/config.rs | 2 +- crates/bevy_ecs/src/schedule/executor/mod.rs | 4 +- .../src/schedule/executor/multi_threaded.rs | 6 +- .../bevy_ecs/src/schedule/executor/simple.rs | 2 +- .../src/schedule/executor/single_threaded.rs | 2 +- crates/bevy_ecs/src/schedule/graph/node.rs | 2 +- crates/bevy_ecs/src/schedule/schedule.rs | 32 ++- crates/bevy_ecs/src/schedule/set.rs | 2 +- crates/bevy_ecs/src/storage/resource.rs | 2 +- crates/bevy_ecs/src/storage/table/mod.rs | 2 +- crates/bevy_ecs/src/system/adapter_system.rs | 2 +- crates/bevy_ecs/src/system/builder.rs | 26 +- crates/bevy_ecs/src/system/combinator.rs | 2 +- .../bevy_ecs/src/system/commands/command.rs | 2 +- .../src/system/commands/entity_command.rs | 14 +- crates/bevy_ecs/src/system/commands/mod.rs | 10 +- .../src/system/exclusive_function_system.rs | 6 +- crates/bevy_ecs/src/system/function_system.rs | 24 +- crates/bevy_ecs/src/system/mod.rs | 32 ++- crates/bevy_ecs/src/system/observer_system.rs | 4 +- crates/bevy_ecs/src/system/query.rs | 10 +- crates/bevy_ecs/src/system/schedule_system.rs | 4 +- crates/bevy_ecs/src/system/system.rs | 10 +- crates/bevy_ecs/src/system/system_param.rs | 34 ++- crates/bevy_ecs/src/system/system_registry.rs | 12 +- crates/bevy_ecs/src/world/command_queue.rs | 8 +- crates/bevy_ecs/src/world/deferred_world.rs | 4 +- crates/bevy_ecs/src/world/entity_fetch.rs | 6 +- crates/bevy_ecs/src/world/entity_ref.rs | 24 +- crates/bevy_ecs/src/world/error.rs | 4 +- .../bevy_ecs/src/world/filtered_resource.rs | 2 +- crates/bevy_ecs/src/world/mod.rs | 77 ++++-- crates/bevy_ecs/src/world/reflect.rs | 8 +- crates/bevy_gilrs/src/gilrs_system.rs | 4 +- crates/bevy_gilrs/src/lib.rs | 2 +- crates/bevy_gilrs/src/rumble.rs | 4 +- crates/bevy_gizmos/macros/src/lib.rs | 2 +- crates/bevy_gizmos/src/aabb.rs | 6 +- crates/bevy_gizmos/src/arrows.rs | 2 +- crates/bevy_gizmos/src/circles.rs | 2 +- crates/bevy_gizmos/src/config.rs | 12 +- crates/bevy_gizmos/src/curves.rs | 2 +- crates/bevy_gizmos/src/gizmos.rs | 2 +- crates/bevy_gizmos/src/grid.rs | 8 +- crates/bevy_gizmos/src/lib.rs | 34 ++- crates/bevy_gizmos/src/light.rs | 11 +- crates/bevy_gizmos/src/pipeline_2d.rs | 16 +- crates/bevy_gizmos/src/pipeline_3d.rs | 16 +- crates/bevy_gizmos/src/primitives/dim2.rs | 11 +- crates/bevy_gizmos/src/primitives/dim3.rs | 2 +- crates/bevy_gizmos/src/primitives/helpers.rs | 2 +- crates/bevy_gizmos/src/retained.rs | 16 +- crates/bevy_gltf/src/lib.rs | 4 +- crates/bevy_gltf/src/loader.rs | 62 +++-- crates/bevy_image/src/basis.rs | 2 +- crates/bevy_image/src/dds.rs | 2 +- .../src/dynamic_texture_atlas_builder.rs | 6 +- crates/bevy_image/src/exr_texture_loader.rs | 2 +- crates/bevy_image/src/hdr_texture_loader.rs | 2 +- crates/bevy_image/src/image.rs | 6 +- crates/bevy_image/src/image_loader.rs | 2 +- crates/bevy_image/src/ktx2.rs | 8 +- crates/bevy_image/src/lib.rs | 2 +- crates/bevy_image/src/texture_atlas.rs | 2 +- .../bevy_image/src/texture_atlas_builder.rs | 4 +- crates/bevy_input/src/axis.rs | 2 +- crates/bevy_input/src/button_input.rs | 2 +- crates/bevy_input/src/gamepad.rs | 234 ++++++++++-------- crates/bevy_input/src/lib.rs | 16 +- crates/bevy_input/src/mouse.rs | 2 +- crates/bevy_input/src/touch.rs | 20 +- crates/bevy_input_focus/src/autofocus.rs | 2 +- .../src/directional_navigation.rs | 2 +- crates/bevy_input_focus/src/lib.rs | 4 +- crates/bevy_input_focus/src/tab_navigation.rs | 8 +- crates/bevy_internal/src/default_plugins.rs | 2 +- crates/bevy_internal/src/prelude.rs | 8 +- crates/bevy_log/src/android_tracing.rs | 4 +- crates/bevy_log/src/lib.rs | 16 +- crates/bevy_macro_utils/src/attrs.rs | 4 +- crates/bevy_macro_utils/src/fq_std.rs | 2 +- crates/bevy_macro_utils/src/label.rs | 2 +- crates/bevy_macro_utils/src/shape.rs | 2 +- .../bevy_math/src/bounding/bounded2d/mod.rs | 9 +- .../src/bounding/bounded2d/primitive_impls.rs | 4 +- .../src/bounding/bounded3d/extrusion.rs | 4 +- .../bevy_math/src/bounding/bounded3d/mod.rs | 8 +- .../src/bounding/bounded3d/primitive_impls.rs | 6 +- crates/bevy_math/src/bounding/raycast2d.rs | 8 +- crates/bevy_math/src/bounding/raycast3d.rs | 8 +- crates/bevy_math/src/common_traits.rs | 2 +- .../src/cubic_splines/curve_impls.rs | 2 +- crates/bevy_math/src/cubic_splines/mod.rs | 42 ++-- crates/bevy_math/src/curve/adaptors.rs | 6 +- crates/bevy_math/src/curve/cores.rs | 6 +- .../src/curve/derivatives/adaptor_impls.rs | 4 +- crates/bevy_math/src/curve/easing.rs | 4 +- crates/bevy_math/src/curve/interval.rs | 16 +- crates/bevy_math/src/curve/mod.rs | 6 +- crates/bevy_math/src/curve/sample_curves.rs | 4 +- crates/bevy_math/src/direction.rs | 2 +- crates/bevy_math/src/isometry.rs | 2 +- crates/bevy_math/src/lib.rs | 10 +- crates/bevy_math/src/ops.rs | 6 +- crates/bevy_math/src/primitives/dim2.rs | 4 +- crates/bevy_math/src/primitives/dim3.rs | 4 +- crates/bevy_math/src/primitives/polygon.rs | 2 +- crates/bevy_math/src/primitives/serde.rs | 2 +- crates/bevy_math/src/ray.rs | 73 +++--- crates/bevy_math/src/rects/irect.rs | 2 +- crates/bevy_math/src/rects/rect.rs | 2 +- crates/bevy_math/src/rects/urect.rs | 12 +- crates/bevy_math/src/rotation2d.rs | 46 ++-- .../bevy_math/src/sampling/mesh_sampling.rs | 2 +- .../bevy_math/src/sampling/shape_sampling.rs | 4 +- crates/bevy_math/src/sampling/standard.rs | 4 +- crates/bevy_mesh/src/conversions.rs | 6 +- crates/bevy_mesh/src/mesh.rs | 18 +- crates/bevy_mesh/src/primitives/dim2.rs | 7 +- .../bevy_mesh/src/primitives/dim3/capsule.rs | 2 +- crates/bevy_mesh/src/primitives/dim3/cone.rs | 4 +- .../src/primitives/dim3/conical_frustum.rs | 2 +- .../bevy_mesh/src/primitives/dim3/cuboid.rs | 2 +- crates/bevy_mesh/src/primitives/dim3/plane.rs | 2 +- .../bevy_mesh/src/primitives/dim3/sphere.rs | 4 +- crates/bevy_mesh/src/primitives/dim3/torus.rs | 2 +- .../src/primitives/dim3/triangle3d.rs | 2 +- crates/bevy_mesh/src/primitives/extrusion.rs | 6 +- crates/bevy_mikktspace/src/generated.rs | 14 +- .../bevy_mikktspace/tests/regression_test.rs | 2 +- crates/bevy_pbr/src/atmosphere/mod.rs | 34 +-- crates/bevy_pbr/src/atmosphere/node.rs | 2 +- crates/bevy_pbr/src/atmosphere/resources.rs | 2 +- crates/bevy_pbr/src/cluster/assign.rs | 10 +- crates/bevy_pbr/src/cluster/mod.rs | 10 +- crates/bevy_pbr/src/components.rs | 4 +- crates/bevy_pbr/src/decal/clustered.rs | 14 +- crates/bevy_pbr/src/decal/forward.rs | 8 +- crates/bevy_pbr/src/deferred/mod.rs | 20 +- crates/bevy_pbr/src/extended_material.rs | 2 +- crates/bevy_pbr/src/fog.rs | 4 +- crates/bevy_pbr/src/lib.rs | 8 +- crates/bevy_pbr/src/light/mod.rs | 2 +- .../src/light_probe/environment_map.rs | 10 +- .../src/light_probe/irradiance_volume.rs | 12 +- crates/bevy_pbr/src/light_probe/mod.rs | 10 +- crates/bevy_pbr/src/lightmap/mod.rs | 10 +- crates/bevy_pbr/src/material.rs | 21 +- crates/bevy_pbr/src/material_bind_groups.rs | 2 +- crates/bevy_pbr/src/mesh_material.rs | 2 +- crates/bevy_pbr/src/meshlet/asset.rs | 2 +- crates/bevy_pbr/src/meshlet/from_mesh.rs | 14 +- .../bevy_pbr/src/meshlet/instance_manager.rs | 6 +- .../src/meshlet/material_pipeline_prepare.rs | 4 +- .../src/meshlet/material_shade_nodes.rs | 2 +- .../src/meshlet/meshlet_mesh_manager.rs | 12 +- crates/bevy_pbr/src/meshlet/mod.rs | 26 +- .../bevy_pbr/src/meshlet/persistent_buffer.rs | 2 +- crates/bevy_pbr/src/meshlet/pipelines.rs | 2 +- .../bevy_pbr/src/meshlet/resource_manager.rs | 2 +- .../meshlet/visibility_buffer_raster_node.rs | 2 +- crates/bevy_pbr/src/pbr_material.rs | 2 +- crates/bevy_pbr/src/prepass/mod.rs | 26 +- .../bevy_pbr/src/prepass/prepass_bindings.rs | 4 +- crates/bevy_pbr/src/render/fog.rs | 4 +- crates/bevy_pbr/src/render/gpu_preprocess.rs | 12 +- crates/bevy_pbr/src/render/light.rs | 18 +- crates/bevy_pbr/src/render/mesh.rs | 25 +- crates/bevy_pbr/src/render/mesh_bindings.rs | 8 +- .../bevy_pbr/src/render/mesh_view_bindings.rs | 25 +- crates/bevy_pbr/src/render/mod.rs | 2 +- crates/bevy_pbr/src/render/morph.rs | 4 +- crates/bevy_pbr/src/render/skin.rs | 4 +- crates/bevy_pbr/src/ssao/mod.rs | 16 +- crates/bevy_pbr/src/ssr/mod.rs | 20 +- crates/bevy_pbr/src/volumetric_fog/mod.rs | 14 +- crates/bevy_pbr/src/volumetric_fog/render.rs | 16 +- crates/bevy_pbr/src/wireframe.rs | 4 +- crates/bevy_picking/src/backend.rs | 6 +- crates/bevy_picking/src/events.rs | 2 +- crates/bevy_picking/src/hover.rs | 2 +- crates/bevy_picking/src/input.rs | 2 +- crates/bevy_picking/src/lib.rs | 8 +- crates/bevy_picking/src/mesh_picking/mod.rs | 4 +- .../mesh_picking/ray_cast/intersections.rs | 8 +- .../src/mesh_picking/ray_cast/mod.rs | 8 +- .../bevy_platform_support/src/sync/atomic.rs | 4 +- crates/bevy_platform_support/src/time.rs | 4 +- .../derive/src/container_attributes.rs | 13 +- .../derive/src/custom_attributes.rs | 2 +- crates/bevy_reflect/derive/src/derive_data.rs | 24 +- .../bevy_reflect/derive/src/documentation.rs | 2 +- .../derive/src/field_attributes.rs | 6 +- .../bevy_reflect/derive/src/from_reflect.rs | 4 +- .../bevy_reflect/derive/src/impls/opaque.rs | 2 +- .../bevy_reflect/derive/src/impls/structs.rs | 4 +- .../derive/src/impls/tuple_structs.rs | 4 +- crates/bevy_reflect/derive/src/impls/typed.rs | 2 +- crates/bevy_reflect/derive/src/lib.rs | 2 +- .../bevy_reflect/derive/src/reflect_opaque.rs | 2 +- crates/bevy_reflect/derive/src/remote.rs | 6 +- .../bevy_reflect/derive/src/serialization.rs | 2 +- crates/bevy_reflect/derive/src/string_expr.rs | 4 +- .../bevy_reflect/derive/src/struct_utility.rs | 2 +- .../derive/src/trait_reflection.rs | 2 +- crates/bevy_reflect/derive/src/type_path.rs | 3 +- .../derive/src/where_clause_options.rs | 4 +- crates/bevy_reflect/examples/reflect_docs.rs | 5 +- crates/bevy_reflect/src/array.rs | 6 +- crates/bevy_reflect/src/attributes.rs | 10 +- crates/bevy_reflect/src/enums/dynamic_enum.rs | 6 +- crates/bevy_reflect/src/enums/enum_trait.rs | 4 +- crates/bevy_reflect/src/enums/helpers.rs | 2 +- crates/bevy_reflect/src/enums/mod.rs | 194 +++++++++------ crates/bevy_reflect/src/enums/variants.rs | 2 +- crates/bevy_reflect/src/fields.rs | 4 +- crates/bevy_reflect/src/func/args/arg.rs | 2 +- crates/bevy_reflect/src/func/args/info.rs | 2 +- crates/bevy_reflect/src/func/args/list.rs | 4 +- .../bevy_reflect/src/func/dynamic_function.rs | 15 +- .../src/func/dynamic_function_internal.rs | 2 +- .../src/func/dynamic_function_mut.rs | 2 +- crates/bevy_reflect/src/func/error.rs | 6 +- crates/bevy_reflect/src/func/function.rs | 4 +- crates/bevy_reflect/src/func/info.rs | 4 +- crates/bevy_reflect/src/func/mod.rs | 2 +- crates/bevy_reflect/src/func/reflect_fn.rs | 4 +- .../bevy_reflect/src/func/reflect_fn_mut.rs | 4 +- crates/bevy_reflect/src/func/signature.rs | 2 +- crates/bevy_reflect/src/impls/glam.rs | 6 +- crates/bevy_reflect/src/impls/petgraph.rs | 2 +- crates/bevy_reflect/src/impls/smallvec.rs | 8 +- crates/bevy_reflect/src/impls/smol_str.rs | 2 +- crates/bevy_reflect/src/impls/std.rs | 40 +-- crates/bevy_reflect/src/impls/uuid.rs | 2 +- crates/bevy_reflect/src/impls/wgpu_types.rs | 2 +- crates/bevy_reflect/src/lib.rs | 41 +-- crates/bevy_reflect/src/list.rs | 6 +- crates/bevy_reflect/src/map.rs | 6 +- crates/bevy_reflect/src/path/error.rs | 46 ++-- crates/bevy_reflect/src/reflect.rs | 6 +- crates/bevy_reflect/src/serde/de/arrays.rs | 2 +- .../bevy_reflect/src/serde/de/deserializer.rs | 4 +- crates/bevy_reflect/src/serde/de/enums.rs | 8 +- crates/bevy_reflect/src/serde/de/helpers.rs | 2 +- crates/bevy_reflect/src/serde/de/lists.rs | 2 +- crates/bevy_reflect/src/serde/de/maps.rs | 2 +- crates/bevy_reflect/src/serde/de/mod.rs | 24 +- crates/bevy_reflect/src/serde/de/options.rs | 4 +- .../src/serde/de/registration_utils.rs | 2 +- .../src/serde/de/registrations.rs | 2 +- crates/bevy_reflect/src/serde/de/sets.rs | 2 +- .../bevy_reflect/src/serde/de/struct_utils.rs | 4 +- crates/bevy_reflect/src/serde/de/structs.rs | 2 +- .../src/serde/de/tuple_structs.rs | 4 +- .../bevy_reflect/src/serde/de/tuple_utils.rs | 6 +- crates/bevy_reflect/src/serde/de/tuples.rs | 2 +- crates/bevy_reflect/src/serde/mod.rs | 12 +- crates/bevy_reflect/src/serde/ser/arrays.rs | 4 +- .../src/serde/ser/custom_serialization.rs | 15 +- crates/bevy_reflect/src/serde/ser/enums.rs | 4 +- crates/bevy_reflect/src/serde/ser/lists.rs | 4 +- crates/bevy_reflect/src/serde/ser/maps.rs | 4 +- crates/bevy_reflect/src/serde/ser/mod.rs | 2 +- .../bevy_reflect/src/serde/ser/serializer.rs | 4 +- crates/bevy_reflect/src/serde/ser/sets.rs | 4 +- crates/bevy_reflect/src/serde/ser/structs.rs | 4 +- .../src/serde/ser/tuple_structs.rs | 4 +- crates/bevy_reflect/src/serde/ser/tuples.rs | 4 +- crates/bevy_reflect/src/serde/type_data.rs | 2 +- crates/bevy_reflect/src/set.rs | 8 +- crates/bevy_reflect/src/struct_trait.rs | 4 +- crates/bevy_reflect/src/tuple.rs | 7 +- crates/bevy_reflect/src/tuple_struct.rs | 4 +- crates/bevy_reflect/src/type_registry.rs | 4 +- crates/bevy_remote/src/builtin_methods.rs | 12 +- crates/bevy_remote/src/http.rs | 7 +- crates/bevy_remote/src/lib.rs | 2 +- .../bevy_render/macros/src/as_bind_group.rs | 30 ++- .../macros/src/extract_component.rs | 2 +- .../macros/src/extract_resource.rs | 2 +- crates/bevy_render/macros/src/lib.rs | 4 +- crates/bevy_render/src/alpha.rs | 2 +- .../src/batching/gpu_preprocessing.rs | 8 +- .../src/batching/no_gpu_preprocessing.rs | 2 +- crates/bevy_render/src/camera/camera.rs | 13 +- crates/bevy_render/src/camera/mod.rs | 4 +- crates/bevy_render/src/camera/projection.rs | 6 +- crates/bevy_render/src/diagnostic/mod.rs | 2 +- .../src/experimental/occlusion_culling/mod.rs | 4 +- crates/bevy_render/src/extract_component.rs | 4 +- crates/bevy_render/src/extract_instances.rs | 2 +- crates/bevy_render/src/globals.rs | 4 +- .../src/gpu_component_array_buffer.rs | 2 +- crates/bevy_render/src/gpu_readback.rs | 6 +- crates/bevy_render/src/lib.rs | 12 +- crates/bevy_render/src/mesh/allocator.rs | 14 +- crates/bevy_render/src/mesh/components.rs | 2 +- crates/bevy_render/src/mesh/mod.rs | 6 +- crates/bevy_render/src/primitives/mod.rs | 2 +- crates/bevy_render/src/render_asset.rs | 2 +- .../bevy_render/src/render_graph/context.rs | 12 +- crates/bevy_render/src/render_graph/graph.rs | 4 +- crates/bevy_render/src/render_graph/mod.rs | 4 +- crates/bevy_render/src/render_graph/node.rs | 2 +- crates/bevy_render/src/render_phase/draw.rs | 4 +- .../src/render_phase/draw_state.rs | 42 +--- crates/bevy_render/src/render_phase/mod.rs | 13 +- .../render_resource/batched_uniform_buffer.rs | 2 +- .../src/render_resource/bind_group.rs | 4 +- .../bind_group_layout_entries.rs | 4 +- .../src/render_resource/buffer_vec.rs | 4 +- .../src/render_resource/gpu_array_buffer.rs | 4 +- crates/bevy_render/src/render_resource/mod.rs | 21 +- .../src/render_resource/pipeline_cache.rs | 20 +- .../render_resource/pipeline_specializer.rs | 2 +- .../bevy_render/src/render_resource/shader.rs | 2 +- .../src/render_resource/storage_buffer.rs | 6 +- .../src/render_resource/uniform_buffer.rs | 4 +- .../bevy_render/src/renderer/graph_runner.rs | 6 +- crates/bevy_render/src/renderer/mod.rs | 6 +- .../bevy_render/src/renderer/render_device.rs | 10 +- crates/bevy_render/src/storage.rs | 6 +- crates/bevy_render/src/sync_world.rs | 6 +- crates/bevy_render/src/texture/gpu_image.rs | 2 +- crates/bevy_render/src/texture/mod.rs | 4 +- .../bevy_render/src/texture/texture_cache.rs | 2 +- crates/bevy_render/src/view/mod.rs | 10 +- crates/bevy_render/src/view/visibility/mod.rs | 4 +- .../bevy_render/src/view/visibility/range.rs | 8 +- .../src/view/visibility/render_layers.rs | 2 +- crates/bevy_render/src/view/window/mod.rs | 2 +- .../bevy_render/src/view/window/screenshot.rs | 16 +- crates/bevy_scene/src/components.rs | 4 +- crates/bevy_scene/src/dynamic_scene.rs | 8 +- .../bevy_scene/src/dynamic_scene_builder.rs | 20 +- crates/bevy_scene/src/scene.rs | 2 +- crates/bevy_scene/src/scene_filter.rs | 2 +- crates/bevy_scene/src/scene_loader.rs | 4 +- crates/bevy_scene/src/scene_spawner.rs | 14 +- crates/bevy_scene/src/serde.rs | 23 +- crates/bevy_sprite/src/lib.rs | 30 +-- .../bevy_sprite/src/mesh2d/color_material.rs | 2 +- crates/bevy_sprite/src/mesh2d/material.rs | 8 +- crates/bevy_sprite/src/mesh2d/mesh.rs | 28 +-- crates/bevy_sprite/src/mesh2d/wireframe2d.rs | 4 +- crates/bevy_sprite/src/picking_backend.rs | 2 +- crates/bevy_sprite/src/render/mod.rs | 12 +- crates/bevy_sprite/src/sprite.rs | 4 +- crates/bevy_sprite/src/texture_slice/mod.rs | 7 +- .../bevy_sprite/src/texture_slice/slicer.rs | 2 +- crates/bevy_state/macros/src/states.rs | 2 +- crates/bevy_state/src/app.rs | 10 +- crates/bevy_state/src/lib.rs | 6 +- .../src/state/freely_mutable_state.rs | 2 +- crates/bevy_state/src/state/mod.rs | 8 +- crates/bevy_state/src/state/state_set.rs | 8 +- crates/bevy_tasks/src/task_pool.rs | 3 +- crates/bevy_text/src/bounds.rs | 2 +- crates/bevy_text/src/font_atlas.rs | 2 +- crates/bevy_text/src/font_atlas_set.rs | 2 +- crates/bevy_text/src/font_loader.rs | 2 +- crates/bevy_text/src/lib.rs | 10 +- crates/bevy_text/src/pipeline.rs | 6 +- crates/bevy_text/src/text.rs | 27 +- crates/bevy_text/src/text2d.rs | 21 +- crates/bevy_time/src/lib.rs | 12 +- crates/bevy_time/src/stopwatch.rs | 2 +- crates/bevy_time/src/time.rs | 2 +- .../src/components/global_transform.rs | 4 +- crates/bevy_transform/src/helper.rs | 8 +- crates/bevy_transform/src/systems.rs | 39 ++- crates/bevy_ui/src/accessibility.rs | 2 +- .../src/experimental/ghost_hierarchy.rs | 2 +- crates/bevy_ui/src/focus.rs | 4 +- crates/bevy_ui/src/geometry.rs | 2 +- crates/bevy_ui/src/layout/mod.rs | 47 ++-- crates/bevy_ui/src/layout/ui_surface.rs | 12 +- crates/bevy_ui/src/lib.rs | 10 +- crates/bevy_ui/src/measurement.rs | 2 +- crates/bevy_ui/src/picking_backend.rs | 2 +- crates/bevy_ui/src/render/box_shadow.rs | 8 +- crates/bevy_ui/src/render/debug_overlay.rs | 4 +- crates/bevy_ui/src/render/mod.rs | 8 +- crates/bevy_ui/src/render/render_pass.rs | 2 +- .../src/render/ui_material_pipeline.rs | 2 +- .../src/render/ui_texture_slice_pipeline.rs | 2 +- crates/bevy_ui/src/stack.rs | 2 +- crates/bevy_ui/src/ui_material.rs | 4 +- crates/bevy_ui/src/ui_node.rs | 2 +- crates/bevy_ui/src/update.rs | 4 +- crates/bevy_ui/src/widget/button.rs | 4 +- crates/bevy_ui/src/widget/image.rs | 2 +- crates/bevy_ui/src/widget/label.rs | 2 +- crates/bevy_ui/src/widget/text.rs | 10 +- crates/bevy_window/src/system_cursor.rs | 2 +- crates/bevy_window/src/window.rs | 2 +- crates/bevy_winit/src/converters.rs | 2 +- crates/bevy_winit/src/cursor.rs | 20 +- crates/bevy_winit/src/custom_cursor.rs | 4 +- crates/bevy_winit/src/lib.rs | 4 +- crates/bevy_winit/src/state.rs | 8 +- crates/bevy_winit/src/system.rs | 6 +- crates/bevy_winit/src/winit_windows.rs | 6 +- examples/2d/cpu_draw.rs | 12 +- examples/2d/mesh2d_arcs.rs | 2 +- examples/2d/mesh2d_manual.rs | 12 +- examples/2d/wireframe_2d.rs | 2 +- examples/3d/atmosphere.rs | 2 +- examples/3d/auto_exposure.rs | 2 +- examples/3d/clearcoat.rs | 2 +- examples/3d/clustered_decals.rs | 6 +- examples/3d/edit_material_on_gltf.rs | 4 +- examples/3d/fog.rs | 6 +- examples/3d/irradiance_volumes.rs | 2 +- examples/3d/meshlet.rs | 9 +- examples/3d/occlusion_culling.rs | 4 +- examples/3d/pcss.rs | 2 +- examples/3d/rotate_environment_map.rs | 2 +- examples/3d/ssr.rs | 2 +- examples/3d/visibility_range.rs | 2 +- examples/3d/volumetric_fog.rs | 2 +- examples/3d/wireframe.rs | 2 +- examples/animation/animated_transform.rs | 2 +- examples/animation/animated_ui.rs | 4 +- examples/animation/custom_skinned_mesh.rs | 2 +- examples/animation/eased_motion.rs | 2 +- examples/app/headless.rs | 4 +- examples/app/headless_renderer.rs | 4 +- examples/app/log_layers.rs | 2 +- examples/app/log_layers_ecs.rs | 2 +- examples/app/no_renderer.rs | 2 +- examples/asset/asset_decompression.rs | 2 +- examples/asset/asset_loading.rs | 19 +- examples/asset/custom_asset.rs | 2 +- examples/asset/embedded_asset.rs | 2 +- examples/asset/extra_source.rs | 2 +- examples/asset/multi_asset_sync.rs | 2 +- examples/asset/processing/asset_processing.rs | 3 +- examples/async_tasks/async_compute.rs | 2 +- .../external_source_external_thread.rs | 2 +- examples/ecs/fallible_systems.rs | 2 +- examples/ecs/iter_combinations.rs | 8 +- examples/ecs/observer_propagation.rs | 2 +- examples/ecs/run_conditions.rs | 4 +- examples/ecs/system_piping.rs | 2 +- examples/games/alien_cake_addict.rs | 39 +-- examples/games/game_menu.rs | 6 +- examples/math/bounding_2d.rs | 2 +- examples/math/cubic_splines.rs | 2 +- examples/math/custom_primitives.rs | 2 +- examples/math/random_sampling.rs | 2 +- examples/math/sampling_primitives.rs | 2 +- examples/movement/smooth_follow.rs | 2 +- examples/reflection/dynamic_types.rs | 32 ++- examples/reflection/function_reflection.rs | 2 +- examples/reflection/reflection.rs | 2 +- examples/remote/client.rs | 4 +- examples/remote/server.rs | 2 +- .../shader/compute_shader_game_of_life.rs | 2 +- examples/shader/custom_phase_item.rs | 6 +- examples/shader/custom_post_processing.rs | 2 +- examples/shader/custom_render_phase.rs | 18 +- examples/shader/custom_shader_instancing.rs | 6 +- examples/shader/gpu_readback.rs | 2 +- examples/shader/specialized_mesh_pipeline.rs | 6 +- examples/shader/texture_binding_array.rs | 4 +- examples/stress_tests/bevymark.rs | 2 +- examples/stress_tests/many_components.rs | 2 +- examples/stress_tests/many_cubes.rs | 2 +- examples/stress_tests/many_lights.rs | 4 +- examples/stress_tests/many_text2d.rs | 2 +- .../tools/scene_viewer/scene_viewer_plugin.rs | 4 +- examples/ui/directional_navigation.rs | 2 +- examples/ui/tab_navigation.rs | 2 +- examples/window/custom_user_event.rs | 2 +- examples/window/screenshot.rs | 2 +- tools/build-easefunction-graphs/src/main.rs | 2 +- tools/build-wasm-example/src/main.rs | 2 +- tools/ci/src/commands/compile.rs | 2 +- tools/ci/src/commands/doc.rs | 2 +- tools/ci/src/commands/integration_test.rs | 2 +- tools/ci/src/commands/lints.rs | 2 +- tools/compile_fail_utils/src/lib.rs | 2 +- tools/example-showcase/src/main.rs | 6 +- 654 files changed, 2776 insertions(+), 2297 deletions(-) diff --git a/benches/benches/bevy_ecs/change_detection.rs b/benches/benches/bevy_ecs/change_detection.rs index 92f3251abc2b4..88214c81f31ff 100644 --- a/benches/benches/bevy_ecs/change_detection.rs +++ b/benches/benches/bevy_ecs/change_detection.rs @@ -7,8 +7,8 @@ use bevy_ecs::{ query::QueryFilter, world::World, }; -use criterion::{criterion_group, Criterion}; -use rand::{prelude::SliceRandom, SeedableRng}; +use criterion::{Criterion, criterion_group}; +use rand::{SeedableRng, prelude::SliceRandom}; use rand_chacha::ChaCha8Rng; criterion_group!( diff --git a/benches/benches/bevy_ecs/components/mod.rs b/benches/benches/bevy_ecs/components/mod.rs index aec44ed27c9d0..165c66bf3a009 100644 --- a/benches/benches/bevy_ecs/components/mod.rs +++ b/benches/benches/bevy_ecs/components/mod.rs @@ -9,7 +9,7 @@ mod insert_simple; mod insert_simple_unbatched; use archetype_updates::*; -use criterion::{criterion_group, Criterion}; +use criterion::{Criterion, criterion_group}; criterion_group!( benches, diff --git a/benches/benches/bevy_ecs/empty_archetypes.rs b/benches/benches/bevy_ecs/empty_archetypes.rs index e5e7639066fe8..e959a7ae56188 100644 --- a/benches/benches/bevy_ecs/empty_archetypes.rs +++ b/benches/benches/bevy_ecs/empty_archetypes.rs @@ -1,7 +1,7 @@ use core::hint::black_box; use bevy_ecs::{component::Component, prelude::*, schedule::ExecutorKind, world::World}; -use criterion::{criterion_group, BenchmarkId, Criterion}; +use criterion::{BenchmarkId, Criterion, criterion_group}; criterion_group!(benches, empty_archetypes); diff --git a/benches/benches/bevy_ecs/entity_cloning.rs b/benches/benches/bevy_ecs/entity_cloning.rs index 7c474cc4f8aaf..d049330938e4f 100644 --- a/benches/benches/bevy_ecs/entity_cloning.rs +++ b/benches/benches/bevy_ecs/entity_cloning.rs @@ -9,7 +9,7 @@ use bevy_ecs::reflect::AppTypeRegistry; use bevy_ecs::{component::Component, world::World}; use bevy_math::Mat4; use bevy_reflect::{GetTypeRegistration, Reflect}; -use criterion::{criterion_group, Bencher, Criterion, Throughput}; +use criterion::{Bencher, Criterion, Throughput, criterion_group}; criterion_group!( benches, diff --git a/benches/benches/bevy_ecs/events/mod.rs b/benches/benches/bevy_ecs/events/mod.rs index 4367c45c3e28d..0785de1a03206 100644 --- a/benches/benches/bevy_ecs/events/mod.rs +++ b/benches/benches/bevy_ecs/events/mod.rs @@ -1,7 +1,7 @@ mod iter; mod send; -use criterion::{criterion_group, Criterion}; +use criterion::{Criterion, criterion_group}; criterion_group!(benches, send, iter); diff --git a/benches/benches/bevy_ecs/iteration/iter_frag_foreach_wide.rs b/benches/benches/bevy_ecs/iteration/iter_frag_foreach_wide.rs index 0ea09053b8251..dc336aba4d54d 100644 --- a/benches/benches/bevy_ecs/iteration/iter_frag_foreach_wide.rs +++ b/benches/benches/bevy_ecs/iteration/iter_frag_foreach_wide.rs @@ -58,17 +58,17 @@ impl<'w> Benchmark<'w> { #[inline(never)] pub fn run(&mut self) { self.1.iter_mut(&mut self.0).for_each(|mut data| { - data.0 .0 *= 2.0; - data.1 .0 *= 2.0; - data.2 .0 *= 2.0; - data.3 .0 *= 2.0; - data.4 .0 *= 2.0; - data.5 .0 *= 2.0; - data.6 .0 *= 2.0; - data.7 .0 *= 2.0; - data.8 .0 *= 2.0; - data.9 .0 *= 2.0; - data.10 .0 *= 2.0; + data.0.0 *= 2.0; + data.1.0 *= 2.0; + data.2.0 *= 2.0; + data.3.0 *= 2.0; + data.4.0 *= 2.0; + data.5.0 *= 2.0; + data.6.0 *= 2.0; + data.7.0 *= 2.0; + data.8.0 *= 2.0; + data.9.0 *= 2.0; + data.10.0 *= 2.0; }); } } diff --git a/benches/benches/bevy_ecs/iteration/iter_frag_foreach_wide_sparse.rs b/benches/benches/bevy_ecs/iteration/iter_frag_foreach_wide_sparse.rs index 6949d1b90d23b..77e85f7495267 100644 --- a/benches/benches/bevy_ecs/iteration/iter_frag_foreach_wide_sparse.rs +++ b/benches/benches/bevy_ecs/iteration/iter_frag_foreach_wide_sparse.rs @@ -68,17 +68,17 @@ impl<'w> Benchmark<'w> { #[inline(never)] pub fn run(&mut self) { self.1.iter_mut(&mut self.0).for_each(|mut data| { - data.0 .0 *= 2.0; - data.1 .0 *= 2.0; - data.2 .0 *= 2.0; - data.3 .0 *= 2.0; - data.4 .0 *= 2.0; - data.5 .0 *= 2.0; - data.6 .0 *= 2.0; - data.7 .0 *= 2.0; - data.8 .0 *= 2.0; - data.9 .0 *= 2.0; - data.10 .0 *= 2.0; + data.0.0 *= 2.0; + data.1.0 *= 2.0; + data.2.0 *= 2.0; + data.3.0 *= 2.0; + data.4.0 *= 2.0; + data.5.0 *= 2.0; + data.6.0 *= 2.0; + data.7.0 *= 2.0; + data.8.0 *= 2.0; + data.9.0 *= 2.0; + data.10.0 *= 2.0; }); } } diff --git a/benches/benches/bevy_ecs/iteration/iter_frag_wide.rs b/benches/benches/bevy_ecs/iteration/iter_frag_wide.rs index 84442c78e547c..b76e95938ceba 100644 --- a/benches/benches/bevy_ecs/iteration/iter_frag_wide.rs +++ b/benches/benches/bevy_ecs/iteration/iter_frag_wide.rs @@ -58,17 +58,17 @@ impl<'w> Benchmark<'w> { #[inline(never)] pub fn run(&mut self) { for mut data in self.1.iter_mut(&mut self.0) { - data.0 .0 *= 2.0; - data.1 .0 *= 2.0; - data.2 .0 *= 2.0; - data.3 .0 *= 2.0; - data.4 .0 *= 2.0; - data.5 .0 *= 2.0; - data.6 .0 *= 2.0; - data.7 .0 *= 2.0; - data.8 .0 *= 2.0; - data.9 .0 *= 2.0; - data.10 .0 *= 2.0; + data.0.0 *= 2.0; + data.1.0 *= 2.0; + data.2.0 *= 2.0; + data.3.0 *= 2.0; + data.4.0 *= 2.0; + data.5.0 *= 2.0; + data.6.0 *= 2.0; + data.7.0 *= 2.0; + data.8.0 *= 2.0; + data.9.0 *= 2.0; + data.10.0 *= 2.0; } } } diff --git a/benches/benches/bevy_ecs/iteration/iter_frag_wide_sparse.rs b/benches/benches/bevy_ecs/iteration/iter_frag_wide_sparse.rs index 928ffea0731be..08fd075e898b0 100644 --- a/benches/benches/bevy_ecs/iteration/iter_frag_wide_sparse.rs +++ b/benches/benches/bevy_ecs/iteration/iter_frag_wide_sparse.rs @@ -68,17 +68,17 @@ impl<'w> Benchmark<'w> { #[inline(never)] pub fn run(&mut self) { for mut data in self.1.iter_mut(&mut self.0) { - data.0 .0 *= 2.0; - data.1 .0 *= 2.0; - data.2 .0 *= 2.0; - data.3 .0 *= 2.0; - data.4 .0 *= 2.0; - data.5 .0 *= 2.0; - data.6 .0 *= 2.0; - data.7 .0 *= 2.0; - data.8 .0 *= 2.0; - data.9 .0 *= 2.0; - data.10 .0 *= 2.0; + data.0.0 *= 2.0; + data.1.0 *= 2.0; + data.2.0 *= 2.0; + data.3.0 *= 2.0; + data.4.0 *= 2.0; + data.5.0 *= 2.0; + data.6.0 *= 2.0; + data.7.0 *= 2.0; + data.8.0 *= 2.0; + data.9.0 *= 2.0; + data.10.0 *= 2.0; } } } diff --git a/benches/benches/bevy_ecs/iteration/iter_simple_foreach_hybrid.rs b/benches/benches/bevy_ecs/iteration/iter_simple_foreach_hybrid.rs index e6ee627e1849f..ce1a93a21438f 100644 --- a/benches/benches/bevy_ecs/iteration/iter_simple_foreach_hybrid.rs +++ b/benches/benches/bevy_ecs/iteration/iter_simple_foreach_hybrid.rs @@ -1,5 +1,5 @@ use bevy_ecs::prelude::*; -use rand::{prelude::SliceRandom, SeedableRng}; +use rand::{SeedableRng, prelude::SliceRandom}; use rand_chacha::ChaCha8Rng; #[derive(Component, Copy, Clone)] diff --git a/benches/benches/bevy_ecs/iteration/iter_simple_foreach_wide.rs b/benches/benches/bevy_ecs/iteration/iter_simple_foreach_wide.rs index 7dbd11d1e0499..f89991e1febcc 100644 --- a/benches/benches/bevy_ecs/iteration/iter_simple_foreach_wide.rs +++ b/benches/benches/bevy_ecs/iteration/iter_simple_foreach_wide.rs @@ -58,10 +58,10 @@ impl<'w> Benchmark<'w> { #[inline(never)] pub fn run(&mut self) { self.1.iter_mut(&mut self.0).for_each(|mut item| { - item.1 .0 += item.0 .0; - item.3 .0 += item.2 .0; - item.5 .0 += item.4 .0; - item.7 .0 += item.6 .0; + item.1.0 += item.0.0; + item.3.0 += item.2.0; + item.5.0 += item.4.0; + item.7.0 += item.6.0; }); } } diff --git a/benches/benches/bevy_ecs/iteration/iter_simple_foreach_wide_sparse_set.rs b/benches/benches/bevy_ecs/iteration/iter_simple_foreach_wide_sparse_set.rs index f520ffde42662..c04ea68d7d299 100644 --- a/benches/benches/bevy_ecs/iteration/iter_simple_foreach_wide_sparse_set.rs +++ b/benches/benches/bevy_ecs/iteration/iter_simple_foreach_wide_sparse_set.rs @@ -60,10 +60,10 @@ impl<'w> Benchmark<'w> { #[inline(never)] pub fn run(&mut self) { self.1.iter_mut(&mut self.0).for_each(|mut item| { - item.1 .0 += item.0 .0; - item.3 .0 += item.2 .0; - item.5 .0 += item.4 .0; - item.7 .0 += item.6 .0; + item.1.0 += item.0.0; + item.3.0 += item.2.0; + item.5.0 += item.4.0; + item.7.0 += item.6.0; }); } } diff --git a/benches/benches/bevy_ecs/iteration/iter_simple_wide.rs b/benches/benches/bevy_ecs/iteration/iter_simple_wide.rs index 7d013b3bf6003..2851447437ae5 100644 --- a/benches/benches/bevy_ecs/iteration/iter_simple_wide.rs +++ b/benches/benches/bevy_ecs/iteration/iter_simple_wide.rs @@ -58,10 +58,10 @@ impl<'w> Benchmark<'w> { #[inline(never)] pub fn run(&mut self) { for mut item in self.1.iter_mut(&mut self.0) { - item.1 .0 += item.0 .0; - item.3 .0 += item.2 .0; - item.5 .0 += item.4 .0; - item.7 .0 += item.6 .0; + item.1.0 += item.0.0; + item.3.0 += item.2.0; + item.5.0 += item.4.0; + item.7.0 += item.6.0; } } } diff --git a/benches/benches/bevy_ecs/iteration/iter_simple_wide_sparse_set.rs b/benches/benches/bevy_ecs/iteration/iter_simple_wide_sparse_set.rs index 28a6dbd85dc28..ecea4ee71e2ee 100644 --- a/benches/benches/bevy_ecs/iteration/iter_simple_wide_sparse_set.rs +++ b/benches/benches/bevy_ecs/iteration/iter_simple_wide_sparse_set.rs @@ -60,10 +60,10 @@ impl<'w> Benchmark<'w> { #[inline(never)] pub fn run(&mut self) { for mut item in self.1.iter_mut(&mut self.0) { - item.1 .0 += item.0 .0; - item.3 .0 += item.2 .0; - item.5 .0 += item.4 .0; - item.7 .0 += item.6 .0; + item.1.0 += item.0.0; + item.3.0 += item.2.0; + item.5.0 += item.4.0; + item.7.0 += item.6.0; } } } diff --git a/benches/benches/bevy_ecs/iteration/mod.rs b/benches/benches/bevy_ecs/iteration/mod.rs index 0fa7aced2894a..129354be6c66a 100644 --- a/benches/benches/bevy_ecs/iteration/mod.rs +++ b/benches/benches/bevy_ecs/iteration/mod.rs @@ -20,7 +20,7 @@ mod iter_simple_wide_sparse_set; mod par_iter_simple; mod par_iter_simple_foreach_hybrid; -use criterion::{criterion_group, Criterion}; +use criterion::{Criterion, criterion_group}; use heavy_compute::*; criterion_group!( diff --git a/benches/benches/bevy_ecs/iteration/par_iter_simple_foreach_hybrid.rs b/benches/benches/bevy_ecs/iteration/par_iter_simple_foreach_hybrid.rs index 9dbcba87852f7..0c2c31bad9db2 100644 --- a/benches/benches/bevy_ecs/iteration/par_iter_simple_foreach_hybrid.rs +++ b/benches/benches/bevy_ecs/iteration/par_iter_simple_foreach_hybrid.rs @@ -1,6 +1,6 @@ use bevy_ecs::prelude::*; use bevy_tasks::{ComputeTaskPool, TaskPool}; -use rand::{prelude::SliceRandom, SeedableRng}; +use rand::{SeedableRng, prelude::SliceRandom}; use rand_chacha::ChaCha8Rng; #[derive(Component, Copy, Clone)] diff --git a/benches/benches/bevy_ecs/observers/propagation.rs b/benches/benches/bevy_ecs/observers/propagation.rs index 65c15f7308deb..ad10768abafdc 100644 --- a/benches/benches/bevy_ecs/observers/propagation.rs +++ b/benches/benches/bevy_ecs/observers/propagation.rs @@ -3,7 +3,7 @@ use core::hint::black_box; use bevy_ecs::prelude::*; use criterion::Criterion; use rand::SeedableRng; -use rand::{seq::IteratorRandom, Rng}; +use rand::{Rng, seq::IteratorRandom}; use rand_chacha::ChaCha8Rng; const DENSITY: usize = 20; // percent of nodes with listeners diff --git a/benches/benches/bevy_ecs/observers/simple.rs b/benches/benches/bevy_ecs/observers/simple.rs index bf2dd236d60ea..6716758cc3d07 100644 --- a/benches/benches/bevy_ecs/observers/simple.rs +++ b/benches/benches/bevy_ecs/observers/simple.rs @@ -3,7 +3,7 @@ use core::hint::black_box; use bevy_ecs::{entity::Entity, event::Event, observer::Trigger, world::World}; use criterion::Criterion; -use rand::{prelude::SliceRandom, SeedableRng}; +use rand::{SeedableRng, prelude::SliceRandom}; use rand_chacha::ChaCha8Rng; fn deterministic_rand() -> ChaCha8Rng { ChaCha8Rng::seed_from_u64(42) diff --git a/benches/benches/bevy_ecs/world/entity_hash.rs b/benches/benches/bevy_ecs/world/entity_hash.rs index 008b2cbbaa358..f8329e986e843 100644 --- a/benches/benches/bevy_ecs/world/entity_hash.rs +++ b/benches/benches/bevy_ecs/world/entity_hash.rs @@ -1,4 +1,4 @@ -use bevy_ecs::entity::{hash_set::EntityHashSet, Entity}; +use bevy_ecs::entity::{Entity, hash_set::EntityHashSet}; use criterion::{BenchmarkId, Criterion, Throughput}; use rand::{Rng, SeedableRng}; use rand_chacha::ChaCha8Rng; diff --git a/benches/benches/bevy_ecs/world/world_get.rs b/benches/benches/bevy_ecs/world/world_get.rs index 283b984186150..9b9867bec5c26 100644 --- a/benches/benches/bevy_ecs/world/world_get.rs +++ b/benches/benches/bevy_ecs/world/world_get.rs @@ -8,7 +8,7 @@ use bevy_ecs::{ world::World, }; use criterion::Criterion; -use rand::{prelude::SliceRandom, SeedableRng}; +use rand::{SeedableRng, prelude::SliceRandom}; use rand_chacha::ChaCha8Rng; #[derive(Component, Default)] diff --git a/benches/benches/bevy_math/bezier.rs b/benches/benches/bevy_math/bezier.rs index 27affcaa71317..30176ab38da6f 100644 --- a/benches/benches/bevy_math/bezier.rs +++ b/benches/benches/bevy_math/bezier.rs @@ -1,8 +1,8 @@ use benches::bench; -use bevy_math::{prelude::*, VectorSpace}; +use bevy_math::{VectorSpace, prelude::*}; use core::hint::black_box; use criterion::{ - criterion_group, measurement::Measurement, BatchSize, BenchmarkGroup, BenchmarkId, Criterion, + BatchSize, BenchmarkGroup, BenchmarkId, Criterion, criterion_group, measurement::Measurement, }; criterion_group!(benches, segment_ease, curve_position, curve_iter_positions); diff --git a/benches/benches/bevy_picking/ray_mesh_intersection.rs b/benches/benches/bevy_picking/ray_mesh_intersection.rs index ee81f1ac7fd87..27894c7c62f79 100644 --- a/benches/benches/bevy_picking/ray_mesh_intersection.rs +++ b/benches/benches/bevy_picking/ray_mesh_intersection.rs @@ -4,7 +4,7 @@ use std::time::Duration; use benches::bench; use bevy_math::{Dir3, Mat4, Ray3d, Vec3}; use bevy_picking::mesh_picking::ray_cast::{self, Backfaces}; -use criterion::{criterion_group, AxisScale, BenchmarkId, Criterion, PlotConfiguration}; +use criterion::{AxisScale, BenchmarkId, Criterion, PlotConfiguration, criterion_group}; criterion_group!(benches, bench); diff --git a/benches/benches/bevy_reflect/function.rs b/benches/benches/bevy_reflect/function.rs index ff4c8dca2ffc0..2592f737cb371 100644 --- a/benches/benches/bevy_reflect/function.rs +++ b/benches/benches/bevy_reflect/function.rs @@ -2,7 +2,7 @@ use core::hint::black_box; use benches::bench; use bevy_reflect::func::{ArgList, IntoFunction, IntoFunctionMut, TypedFunction}; -use criterion::{criterion_group, BatchSize, BenchmarkId, Criterion}; +use criterion::{BatchSize, BenchmarkId, Criterion, criterion_group}; criterion_group!( benches, diff --git a/benches/benches/bevy_reflect/list.rs b/benches/benches/bevy_reflect/list.rs index 872c2dd0cb898..7173b3fb0fce1 100644 --- a/benches/benches/bevy_reflect/list.rs +++ b/benches/benches/bevy_reflect/list.rs @@ -3,8 +3,8 @@ use core::{hint::black_box, iter, time::Duration}; use benches::bench; use bevy_reflect::{DynamicList, List}; use criterion::{ - criterion_group, measurement::Measurement, AxisScale, BatchSize, BenchmarkGroup, BenchmarkId, - Criterion, PlotConfiguration, Throughput, + AxisScale, BatchSize, BenchmarkGroup, BenchmarkId, Criterion, PlotConfiguration, Throughput, + criterion_group, measurement::Measurement, }; criterion_group!( diff --git a/benches/benches/bevy_reflect/map.rs b/benches/benches/bevy_reflect/map.rs index 4525ed8598926..985ac6ecb2b43 100644 --- a/benches/benches/bevy_reflect/map.rs +++ b/benches/benches/bevy_reflect/map.rs @@ -4,8 +4,8 @@ use benches::bench; use bevy_platform_support::collections::HashMap; use bevy_reflect::{DynamicMap, Map}; use criterion::{ - criterion_group, measurement::Measurement, AxisScale, BatchSize, BenchmarkGroup, BenchmarkId, - Criterion, PlotConfiguration, Throughput, + AxisScale, BatchSize, BenchmarkGroup, BenchmarkId, Criterion, PlotConfiguration, Throughput, + criterion_group, measurement::Measurement, }; criterion_group!( diff --git a/benches/benches/bevy_reflect/path.rs b/benches/benches/bevy_reflect/path.rs index c0d8bfe0da732..60cddd30ec23b 100644 --- a/benches/benches/bevy_reflect/path.rs +++ b/benches/benches/bevy_reflect/path.rs @@ -2,8 +2,8 @@ use core::{fmt::Write, hint::black_box, str, time::Duration}; use benches::bench; use bevy_reflect::ParsedPath; -use criterion::{criterion_group, BatchSize, BenchmarkId, Criterion, Throughput}; -use rand::{distributions::Uniform, Rng, SeedableRng}; +use criterion::{BatchSize, BenchmarkId, Criterion, Throughput, criterion_group}; +use rand::{Rng, SeedableRng, distributions::Uniform}; use rand_chacha::ChaCha8Rng; criterion_group!(benches, parse_reflect_path); diff --git a/benches/benches/bevy_reflect/struct.rs b/benches/benches/bevy_reflect/struct.rs index d8f25554c36ba..051d92ce6b243 100644 --- a/benches/benches/bevy_reflect/struct.rs +++ b/benches/benches/bevy_reflect/struct.rs @@ -3,8 +3,8 @@ use core::{hint::black_box, time::Duration}; use benches::bench; use bevy_reflect::{DynamicStruct, GetField, PartialReflect, Reflect, Struct}; use criterion::{ - criterion_group, measurement::Measurement, AxisScale, BatchSize, BenchmarkGroup, BenchmarkId, - Criterion, PlotConfiguration, Throughput, + AxisScale, BatchSize, BenchmarkGroup, BenchmarkId, Criterion, PlotConfiguration, Throughput, + criterion_group, measurement::Measurement, }; criterion_group!( diff --git a/benches/benches/bevy_render/render_layers.rs b/benches/benches/bevy_render/render_layers.rs index d460a7bc96c48..6fa21030da247 100644 --- a/benches/benches/bevy_render/render_layers.rs +++ b/benches/benches/bevy_render/render_layers.rs @@ -1,6 +1,6 @@ use core::hint::black_box; -use criterion::{criterion_group, Criterion}; +use criterion::{Criterion, criterion_group}; use bevy_render::view::RenderLayers; diff --git a/benches/benches/bevy_render/torus.rs b/benches/benches/bevy_render/torus.rs index dcadd09180f9d..a6a1857a232a8 100644 --- a/benches/benches/bevy_render/torus.rs +++ b/benches/benches/bevy_render/torus.rs @@ -1,6 +1,6 @@ use core::hint::black_box; -use criterion::{criterion_group, Criterion}; +use criterion::{Criterion, criterion_group}; use bevy_render::mesh::TorusMeshBuilder; diff --git a/benches/benches/bevy_tasks/iter.rs b/benches/benches/bevy_tasks/iter.rs index 7fe00ecb794db..c76b62737f2e6 100644 --- a/benches/benches/bevy_tasks/iter.rs +++ b/benches/benches/bevy_tasks/iter.rs @@ -1,7 +1,7 @@ use core::hint::black_box; use bevy_tasks::{ParallelIterator, TaskPoolBuilder}; -use criterion::{criterion_group, BenchmarkId, Criterion}; +use criterion::{BenchmarkId, Criterion, criterion_group}; struct ParChunks<'a, T>(core::slice::Chunks<'a, T>); impl<'a, T> ParallelIterator> for ParChunks<'a, T> diff --git a/crates/bevy_a11y/src/lib.rs b/crates/bevy_a11y/src/lib.rs index ccc7edf536c3c..10769ab3196a7 100644 --- a/crates/bevy_a11y/src/lib.rs +++ b/crates/bevy_a11y/src/lib.rs @@ -33,8 +33,8 @@ use bevy_ecs::{ #[cfg(feature = "bevy_reflect")] use { - bevy_ecs::reflect::ReflectResource, bevy_reflect::std_traits::ReflectDefault, - bevy_reflect::Reflect, + bevy_ecs::reflect::ReflectResource, bevy_reflect::Reflect, + bevy_reflect::std_traits::ReflectDefault, }; #[cfg(feature = "serialize")] diff --git a/crates/bevy_animation/src/animation_curves.rs b/crates/bevy_animation/src/animation_curves.rs index 4c944cdf6dd7e..0fd258325be2b 100644 --- a/crates/bevy_animation/src/animation_curves.rs +++ b/crates/bevy_animation/src/animation_curves.rs @@ -90,20 +90,20 @@ use core::{ }; use crate::{ + AnimationEntityMut, AnimationEvaluationError, graph::AnimationNodeIndex, prelude::{Animatable, BlendInput}, - AnimationEntityMut, AnimationEvaluationError, }; use bevy_ecs::component::{Component, Mutable}; use bevy_math::curve::{ + Curve, Interval, cores::{UnevenCore, UnevenCoreError}, iterable::IterableCurve, - Curve, Interval, }; use bevy_platform_support::hash::Hashed; use bevy_reflect::{FromReflect, Reflect, Reflectable, TypeInfo, Typed}; use bevy_render::mesh::morph::MorphWeights; -use downcast_rs::{impl_downcast, Downcast}; +use downcast_rs::{Downcast, impl_downcast}; /// A value on a component that Bevy can animate. /// diff --git a/crates/bevy_animation/src/gltf_curves.rs b/crates/bevy_animation/src/gltf_curves.rs index d5b2cbb6b984e..fcb4fc4d7d47a 100644 --- a/crates/bevy_animation/src/gltf_curves.rs +++ b/crates/bevy_animation/src/gltf_curves.rs @@ -1,8 +1,9 @@ //! Concrete curve structures used to load glTF curves into the animation system. use bevy_math::{ + Quat, Vec4, VectorSpace, curve::{cores::*, iterable::IterableCurve, *}, - vec4, Quat, Vec4, VectorSpace, + vec4, }; use bevy_reflect::Reflect; use either::Either; @@ -247,10 +248,10 @@ where | InterpolationDatum::RightTail(v) => Either::Left(v.iter().cloned()), InterpolationDatum::Between(u, v, s) => { - let interpolated = - u.iter() - .zip(v.iter()) - .map(move |(x, y)| if s >= 1.0 { y.clone() } else { x.clone() }); + let interpolated = u + .iter() + .zip(v.iter()) + .map(move |(x, y)| if s >= 1.0 { y.clone() } else { x.clone() }); Either::Right(interpolated) } } diff --git a/crates/bevy_animation/src/graph.rs b/crates/bevy_animation/src/graph.rs index 1729841f02641..82a5180848d5e 100644 --- a/crates/bevy_animation/src/graph.rs +++ b/crates/bevy_animation/src/graph.rs @@ -7,7 +7,7 @@ use core::{ use std::io::{self, Write}; use bevy_asset::{ - io::Reader, Asset, AssetEvent, AssetId, AssetLoader, AssetPath, Assets, Handle, LoadContext, + Asset, AssetEvent, AssetId, AssetLoader, AssetPath, Assets, Handle, LoadContext, io::Reader, }; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::{ @@ -18,11 +18,11 @@ use bevy_ecs::{ system::{Res, ResMut}, }; use bevy_platform_support::collections::HashMap; -use bevy_reflect::{prelude::ReflectDefault, Reflect, ReflectSerialize}; +use bevy_reflect::{Reflect, ReflectSerialize, prelude::ReflectDefault}; use derive_more::derive::From; use petgraph::{ - graph::{DiGraph, NodeIndex}, Direction, + graph::{DiGraph, NodeIndex}, }; use ron::de::SpannedError; use serde::{Deserialize, Serialize}; diff --git a/crates/bevy_animation/src/lib.rs b/crates/bevy_animation/src/lib.rs index 8663ea3f3f970..43757a7e2a00b 100644 --- a/crates/bevy_animation/src/lib.rs +++ b/crates/bevy_animation/src/lib.rs @@ -36,7 +36,7 @@ use bevy_asset::{Asset, AssetApp, AssetEvents, Assets}; use bevy_ecs::{prelude::*, world::EntityMutExcept}; use bevy_math::FloatOrd; use bevy_platform_support::{collections::HashMap, hash::NoOpHash}; -use bevy_reflect::{prelude::ReflectDefault, Reflect, TypePath}; +use bevy_reflect::{Reflect, TypePath, prelude::ReflectDefault}; use bevy_time::Time; use bevy_transform::TransformSystem; use bevy_utils::{PreHashMap, PreHashMapExt, TypeIdMap}; @@ -52,15 +52,15 @@ use uuid::Uuid; pub mod prelude { #[doc(hidden)] pub use crate::{ - animatable::*, animation_curves::*, graph::*, transition::*, AnimationClip, - AnimationPlayer, AnimationPlugin, VariableCurve, + AnimationClip, AnimationPlayer, AnimationPlugin, VariableCurve, animatable::*, + animation_curves::*, graph::*, transition::*, }; } use crate::{ animation_curves::AnimationCurve, graph::{AnimationGraph, AnimationGraphAssetLoader, AnimationNodeIndex}, - transition::{advance_transitions, expire_completed_transitions, AnimationTransitions}, + transition::{AnimationTransitions, advance_transitions, expire_completed_transitions}, }; use alloc::sync::Arc; diff --git a/crates/bevy_animation/src/transition.rs b/crates/bevy_animation/src/transition.rs index c94378208b3a7..18954cc2ffbd5 100644 --- a/crates/bevy_animation/src/transition.rs +++ b/crates/bevy_animation/src/transition.rs @@ -8,11 +8,11 @@ use bevy_ecs::{ reflect::ReflectComponent, system::{Query, Res}, }; -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; use bevy_time::Time; use core::time::Duration; -use crate::{graph::AnimationNodeIndex, ActiveAnimation, AnimationPlayer}; +use crate::{ActiveAnimation, AnimationPlayer, graph::AnimationNodeIndex}; /// Manages fade-out of animation blend factors, allowing for smooth transitions /// between animations. diff --git a/crates/bevy_animation/src/util.rs b/crates/bevy_animation/src/util.rs index 67aaf8116e365..13e9fd20c062b 100644 --- a/crates/bevy_animation/src/util.rs +++ b/crates/bevy_animation/src/util.rs @@ -2,9 +2,5 @@ /// Returns `a` if `t < 1.0`, otherwise returns `b`. #[inline] pub(crate) fn step_unclamped(a: T, b: T, t: f32) -> T { - if t < 1.0 { - a - } else { - b - } + if t < 1.0 { a } else { b } } diff --git a/crates/bevy_app/src/app.rs b/crates/bevy_app/src/app.rs index cee160f0e7049..38b06221e4392 100644 --- a/crates/bevy_app/src/app.rs +++ b/crates/bevy_app/src/app.rs @@ -10,7 +10,7 @@ use alloc::{ pub use bevy_derive::AppLabel; use bevy_ecs::{ component::RequiredComponentsError, - event::{event_update_system, EventCursor}, + event::{EventCursor, event_update_system}, intern::Interned, prelude::*, result::{Error, SystemErrorContext}, diff --git a/crates/bevy_app/src/lib.rs b/crates/bevy_app/src/lib.rs index 489b5415e30a3..46b9c47333132 100644 --- a/crates/bevy_app/src/lib.rs +++ b/crates/bevy_app/src/lib.rs @@ -53,6 +53,7 @@ pub use terminal_ctrl_c_handler::*; pub mod prelude { #[doc(hidden)] pub use crate::{ + Plugin, PluginGroup, app::{App, AppExit}, main_schedule::{ First, FixedFirst, FixedLast, FixedPostUpdate, FixedPreUpdate, FixedUpdate, Last, Main, @@ -60,7 +61,6 @@ pub mod prelude { RunFixedMainLoopSystem, SpawnScene, Startup, Update, }, sub_app::SubApp, - Plugin, PluginGroup, }; #[cfg(feature = "bevy_tasks")] diff --git a/crates/bevy_app/src/plugin.rs b/crates/bevy_app/src/plugin.rs index dc26e273f42c7..a270acb9df0da 100644 --- a/crates/bevy_app/src/plugin.rs +++ b/crates/bevy_app/src/plugin.rs @@ -1,6 +1,6 @@ use crate::App; use core::any::Any; -use downcast_rs::{impl_downcast, Downcast}; +use downcast_rs::{Downcast, impl_downcast}; /// A collection of Bevy app logic and configuration. /// diff --git a/crates/bevy_app/src/plugin_group.rs b/crates/bevy_app/src/plugin_group.rs index dca847f77f8ee..69cfaf8646cb0 100644 --- a/crates/bevy_app/src/plugin_group.rs +++ b/crates/bevy_app/src/plugin_group.rs @@ -525,8 +525,7 @@ impl PluginGroupBuilder { { panic!( "Error adding plugin {} in group {}: plugin was already added in application", - plugin_name, - self.group_name + plugin_name, self.group_name ); } } diff --git a/crates/bevy_app/src/schedule_runner.rs b/crates/bevy_app/src/schedule_runner.rs index 2a0e1f966a49e..61f6c3dad2c64 100644 --- a/crates/bevy_app/src/schedule_runner.rs +++ b/crates/bevy_app/src/schedule_runner.rs @@ -1,7 +1,7 @@ use crate::{ + PluginsState, app::{App, AppExit}, plugin::Plugin, - PluginsState, }; use bevy_platform_support::time::Instant; use core::time::Duration; @@ -10,7 +10,7 @@ use core::time::Duration; use { alloc::{boxed::Box, rc::Rc}, core::cell::RefCell, - wasm_bindgen::{prelude::*, JsCast}, + wasm_bindgen::{JsCast, prelude::*}, }; /// Determines the method used to run an [`App`]'s [`Schedule`](bevy_ecs::schedule::Schedule). diff --git a/crates/bevy_app/src/terminal_ctrl_c_handler.rs b/crates/bevy_app/src/terminal_ctrl_c_handler.rs index 0eb34ccdbe98e..c063c677d2c1f 100644 --- a/crates/bevy_app/src/terminal_ctrl_c_handler.rs +++ b/crates/bevy_app/src/terminal_ctrl_c_handler.rs @@ -63,7 +63,9 @@ impl Plugin for TerminalCtrlCHandlerPlugin { match result { Ok(()) => {} Err(ctrlc::Error::MultipleHandlers) => { - log::info!("Skipping installing `Ctrl+C` handler as one was already installed. Please call `TerminalCtrlCHandlerPlugin::gracefully_exit` in your own `Ctrl+C` handler if you want Bevy to gracefully exit on `Ctrl+C`."); + log::info!( + "Skipping installing `Ctrl+C` handler as one was already installed. Please call `TerminalCtrlCHandlerPlugin::gracefully_exit` in your own `Ctrl+C` handler if you want Bevy to gracefully exit on `Ctrl+C`." + ); } Err(err) => log::warn!("Failed to set `Ctrl+C` handler: {err}"), } diff --git a/crates/bevy_asset/macros/src/lib.rs b/crates/bevy_asset/macros/src/lib.rs index 443bd09ab9b36..b969db1d66038 100644 --- a/crates/bevy_asset/macros/src/lib.rs +++ b/crates/bevy_asset/macros/src/lib.rs @@ -4,7 +4,7 @@ use bevy_macro_utils::BevyManifest; use proc_macro::{Span, TokenStream}; use quote::{format_ident, quote}; -use syn::{parse_macro_input, Data, DeriveInput, Path}; +use syn::{Data, DeriveInput, Path, parse_macro_input}; pub(crate) fn bevy_asset_path() -> Path { BevyManifest::shared().get_path("bevy_asset") diff --git a/crates/bevy_asset/src/assets.rs b/crates/bevy_asset/src/assets.rs index ebc9a0f588722..0e26bddcbcc1c 100644 --- a/crates/bevy_asset/src/assets.rs +++ b/crates/bevy_asset/src/assets.rs @@ -634,7 +634,9 @@ impl<'a, A: Asset> Iterator for AssetsMutIterator<'a, A> { /// An error returned when an [`AssetIndex`] has an invalid generation. #[derive(Error, Debug)] -#[error("AssetIndex {index:?} has an invalid generation. The current generation is: '{current_generation}'.")] +#[error( + "AssetIndex {index:?} has an invalid generation. The current generation is: '{current_generation}'." +)] pub struct InvalidGenerationError { index: AssetIndex, current_generation: u32, diff --git a/crates/bevy_asset/src/direct_access_ext.rs b/crates/bevy_asset/src/direct_access_ext.rs index 792d523a30063..baa5f60a2f6bc 100644 --- a/crates/bevy_asset/src/direct_access_ext.rs +++ b/crates/bevy_asset/src/direct_access_ext.rs @@ -3,7 +3,7 @@ use bevy_ecs::world::World; -use crate::{meta::Settings, Asset, AssetPath, AssetServer, Assets, Handle}; +use crate::{Asset, AssetPath, AssetServer, Assets, Handle, meta::Settings}; /// An extension trait for methods for working with assets directly from a [`World`]. pub trait DirectAssetAccessExt { diff --git a/crates/bevy_asset/src/handle.rs b/crates/bevy_asset/src/handle.rs index f2401c951b5a2..15217ed837469 100644 --- a/crates/bevy_asset/src/handle.rs +++ b/crates/bevy_asset/src/handle.rs @@ -1,9 +1,9 @@ use crate::{ - meta::MetaTransform, Asset, AssetId, AssetIndexAllocator, AssetPath, InternalAssetId, - UntypedAssetId, + Asset, AssetId, AssetIndexAllocator, AssetPath, InternalAssetId, UntypedAssetId, + meta::MetaTransform, }; use alloc::sync::Arc; -use bevy_reflect::{std_traits::ReflectDefault, Reflect, TypePath}; +use bevy_reflect::{Reflect, TypePath, std_traits::ReflectDefault}; use core::{ any::TypeId, hash::{Hash, Hasher}, @@ -700,7 +700,11 @@ mod tests { let from_reflect_handle: Handle = FromReflect::from_reflect(&*cloned_handle).unwrap(); - assert_eq!(Arc::strong_count(strong), 3, "Converting the reflected value back to a handle should increase the strong count to 3"); + assert_eq!( + Arc::strong_count(strong), + 3, + "Converting the reflected value back to a handle should increase the strong count to 3" + ); assert!( from_reflect_handle.is_strong(), "The cloned handle should still be strong" diff --git a/crates/bevy_asset/src/id.rs b/crates/bevy_asset/src/id.rs index 4caf546163a75..d44529b2c1f2b 100644 --- a/crates/bevy_asset/src/id.rs +++ b/crates/bevy_asset/src/id.rs @@ -418,7 +418,9 @@ impl TryFrom for AssetId { #[non_exhaustive] pub enum UntypedAssetIdConversionError { /// Caused when trying to convert an [`UntypedAssetId`] into an [`AssetId`] of the wrong type. - #[error("This UntypedAssetId is for {found:?} and cannot be converted into an AssetId<{expected:?}>")] + #[error( + "This UntypedAssetId is for {found:?} and cannot be converted into an AssetId<{expected:?}>" + )] TypeIdMismatch { /// The [`TypeId`] of the asset that we are trying to convert to. expected: TypeId, diff --git a/crates/bevy_asset/src/io/android.rs b/crates/bevy_asset/src/io/android.rs index 67ca8e339a22c..98fc045668e67 100644 --- a/crates/bevy_asset/src/io/android.rs +++ b/crates/bevy_asset/src/io/android.rs @@ -1,4 +1,4 @@ -use crate::io::{get_meta_path, AssetReader, AssetReaderError, PathStream, Reader, VecReader}; +use crate::io::{AssetReader, AssetReaderError, PathStream, Reader, VecReader, get_meta_path}; use alloc::{borrow::ToOwned, boxed::Box, ffi::CString, vec::Vec}; use futures_lite::stream; use std::path::Path; diff --git a/crates/bevy_asset/src/io/embedded/embedded_watcher.rs b/crates/bevy_asset/src/io/embedded/embedded_watcher.rs index 89ac9b3826a8f..743e13de80c62 100644 --- a/crates/bevy_asset/src/io/embedded/embedded_watcher.rs +++ b/crates/bevy_asset/src/io/embedded/embedded_watcher.rs @@ -1,12 +1,12 @@ use crate::io::{ - file::{get_asset_path, get_base_path, new_asset_event_debouncer, FilesystemEventHandler}, - memory::Dir, AssetSourceEvent, AssetWatcher, + file::{FilesystemEventHandler, get_asset_path, get_base_path, new_asset_event_debouncer}, + memory::Dir, }; use alloc::{boxed::Box, sync::Arc, vec::Vec}; use bevy_platform_support::collections::HashMap; use core::time::Duration; -use notify_debouncer_full::{notify::RecommendedWatcher, Debouncer, RecommendedCache}; +use notify_debouncer_full::{Debouncer, RecommendedCache, notify::RecommendedWatcher}; use parking_lot::RwLock; use std::{ fs::File, diff --git a/crates/bevy_asset/src/io/embedded/mod.rs b/crates/bevy_asset/src/io/embedded/mod.rs index fce5149462247..be2ea1129099a 100644 --- a/crates/bevy_asset/src/io/embedded/mod.rs +++ b/crates/bevy_asset/src/io/embedded/mod.rs @@ -5,8 +5,8 @@ mod embedded_watcher; pub use embedded_watcher::*; use crate::io::{ - memory::{Dir, MemoryAssetReader, Value}, AssetSource, AssetSourceBuilders, + memory::{Dir, MemoryAssetReader, Value}, }; use alloc::boxed::Box; use bevy_ecs::resource::Resource; @@ -139,9 +139,7 @@ impl EmbeddedAssetRegistry { /// [`embedded_asset`]: crate::embedded_asset #[macro_export] macro_rules! embedded_path { - ($path_str: expr) => {{ - embedded_path!("src", $path_str) - }}; + ($path_str: expr) => {{ embedded_path!("src", $path_str) }}; ($source_path: expr, $path_str: expr) => {{ let crate_name = module_path!().split(':').next().unwrap(); @@ -251,9 +249,7 @@ pub fn _embedded_asset_path( /// [`embedded_path`]: crate::embedded_path #[macro_export] macro_rules! embedded_asset { - ($app: ident, $path: expr) => {{ - $crate::embedded_asset!($app, "src", $path) - }}; + ($app: ident, $path: expr) => {{ $crate::embedded_asset!($app, "src", $path) }}; ($app: ident, $source_path: expr, $path: expr) => {{ let mut embedded = $app @@ -333,7 +329,7 @@ macro_rules! load_internal_binary_asset { #[cfg(test)] mod tests { - use super::{EmbeddedAssetRegistry, _embedded_asset_path}; + use super::{_embedded_asset_path, EmbeddedAssetRegistry}; use std::path::Path; // Relative paths show up if this macro is being invoked by a local crate. diff --git a/crates/bevy_asset/src/io/file/file_asset.rs b/crates/bevy_asset/src/io/file/file_asset.rs index f65680217bc2a..42bffeb8d804a 100644 --- a/crates/bevy_asset/src/io/file/file_asset.rs +++ b/crates/bevy_asset/src/io/file/file_asset.rs @@ -1,8 +1,8 @@ use crate::io::{ - get_meta_path, AssetReader, AssetReaderError, AssetWriter, AssetWriterError, AsyncSeekForward, - PathStream, Reader, Writer, + AssetReader, AssetReaderError, AssetWriter, AssetWriterError, AsyncSeekForward, PathStream, + Reader, Writer, get_meta_path, }; -use async_fs::{read_dir, File}; +use async_fs::{File, read_dir}; use futures_io::AsyncSeek; use futures_lite::StreamExt; diff --git a/crates/bevy_asset/src/io/file/file_watcher.rs b/crates/bevy_asset/src/io/file/file_watcher.rs index 64d3e711c975a..0922db8717dc6 100644 --- a/crates/bevy_asset/src/io/file/file_watcher.rs +++ b/crates/bevy_asset/src/io/file/file_watcher.rs @@ -6,13 +6,11 @@ use alloc::borrow::ToOwned; use core::time::Duration; use crossbeam_channel::Sender; use notify_debouncer_full::{ - new_debouncer, + DebounceEventResult, Debouncer, RecommendedCache, new_debouncer, notify::{ - self, + self, RecommendedWatcher, RecursiveMode, event::{AccessKind, AccessMode, CreateKind, ModifyKind, RemoveKind, RenameMode}, - RecommendedWatcher, RecursiveMode, }, - DebounceEventResult, Debouncer, RecommendedCache, }; use std::path::{Path, PathBuf}; use tracing::error; @@ -190,13 +188,13 @@ pub(crate) fn new_asset_event_debouncer( } (true, false) => { error!( - "Asset metafile {old_path:?} was changed to asset file {new_path:?}, which is not supported. Try restarting your app to see if configuration is still valid" - ); + "Asset metafile {old_path:?} was changed to asset file {new_path:?}, which is not supported. Try restarting your app to see if configuration is still valid" + ); } (false, true) => { error!( - "Asset file {old_path:?} was changed to meta file {new_path:?}, which is not supported. Try restarting your app to see if configuration is still valid" - ); + "Asset file {old_path:?} was changed to meta file {new_path:?}, which is not supported. Try restarting your app to see if configuration is still valid" + ); } } } diff --git a/crates/bevy_asset/src/io/file/sync_file_asset.rs b/crates/bevy_asset/src/io/file/sync_file_asset.rs index 7533256204a8d..38255efba0a09 100644 --- a/crates/bevy_asset/src/io/file/sync_file_asset.rs +++ b/crates/bevy_asset/src/io/file/sync_file_asset.rs @@ -2,14 +2,14 @@ use futures_io::{AsyncRead, AsyncWrite}; use futures_lite::Stream; use crate::io::{ - get_meta_path, AssetReader, AssetReaderError, AssetWriter, AssetWriterError, AsyncSeekForward, - PathStream, Reader, Writer, + AssetReader, AssetReaderError, AssetWriter, AssetWriterError, AsyncSeekForward, PathStream, + Reader, Writer, get_meta_path, }; use alloc::{borrow::ToOwned, boxed::Box, vec::Vec}; use core::{pin::Pin, task::Poll}; use std::{ - fs::{read_dir, File}, + fs::{File, read_dir}, io::{Read, Seek, Write}, path::{Path, PathBuf}, }; diff --git a/crates/bevy_asset/src/io/memory.rs b/crates/bevy_asset/src/io/memory.rs index 5b9e5389c2199..3806c0954c828 100644 --- a/crates/bevy_asset/src/io/memory.rs +++ b/crates/bevy_asset/src/io/memory.rs @@ -3,7 +3,7 @@ use alloc::{borrow::ToOwned, boxed::Box, sync::Arc, vec::Vec}; use bevy_platform_support::collections::HashMap; use core::{pin::Pin, task::Poll}; use futures_io::AsyncRead; -use futures_lite::{ready, Stream}; +use futures_lite::{Stream, ready}; use parking_lot::RwLock; use std::path::{Path, PathBuf}; diff --git a/crates/bevy_asset/src/io/mod.rs b/crates/bevy_asset/src/io/mod.rs index aa7256bbd927b..814703bc4c096 100644 --- a/crates/bevy_asset/src/io/mod.rs +++ b/crates/bevy_asset/src/io/mod.rs @@ -30,7 +30,7 @@ use core::{ task::{Context, Poll}, }; use futures_io::{AsyncRead, AsyncWrite}; -use futures_lite::{ready, Stream}; +use futures_lite::{Stream, ready}; use std::path::{Path, PathBuf}; use thiserror::Error; diff --git a/crates/bevy_asset/src/io/processor_gated.rs b/crates/bevy_asset/src/io/processor_gated.rs index da439f56f5e18..b1e606f9ca4f7 100644 --- a/crates/bevy_asset/src/io/processor_gated.rs +++ b/crates/bevy_asset/src/io/processor_gated.rs @@ -1,7 +1,7 @@ use crate::{ + AssetPath, io::{AssetReader, AssetReaderError, AssetSourceId, PathStream, Reader}, processor::{AssetProcessorData, ProcessStatus}, - AssetPath, }; use alloc::{borrow::ToOwned, boxed::Box, sync::Arc, vec::Vec}; use async_lock::RwLockReadGuardArc; diff --git a/crates/bevy_asset/src/io/source.rs b/crates/bevy_asset/src/io/source.rs index 58c5006a8047e..d8e4d822b599d 100644 --- a/crates/bevy_asset/src/io/source.rs +++ b/crates/bevy_asset/src/io/source.rs @@ -1,5 +1,5 @@ use crate::{ - io::{processor_gated::ProcessorGatedReader, AssetSourceEvent, AssetWatcher}, + io::{AssetSourceEvent, AssetWatcher, processor_gated::ProcessorGatedReader}, processor::AssetProcessorData, }; use alloc::{ @@ -240,10 +240,12 @@ impl AssetSourceBuilder { /// Will use the given `watcher` function to construct unprocessed [`AssetWatcher`] instances. pub fn with_watcher( mut self, - watcher: impl FnMut(crossbeam_channel::Sender) -> Option> - + Send - + Sync - + 'static, + watcher: impl FnMut( + crossbeam_channel::Sender, + ) -> Option> + + Send + + Sync + + 'static, ) -> Self { self.watcher = Some(Box::new(watcher)); self @@ -270,10 +272,12 @@ impl AssetSourceBuilder { /// Will use the given `watcher` function to construct processed [`AssetWatcher`] instances. pub fn with_processed_watcher( mut self, - watcher: impl FnMut(crossbeam_channel::Sender) -> Option> - + Send - + Sync - + 'static, + watcher: impl FnMut( + crossbeam_channel::Sender, + ) -> Option> + + Send + + Sync + + 'static, ) -> Self { self.processed_watcher = Some(Box::new(watcher)); self @@ -532,8 +536,8 @@ impl AssetSource { path: String, file_debounce_wait_time: Duration, ) -> impl FnMut(crossbeam_channel::Sender) -> Option> - + Send - + Sync { + + Send + + Sync { move |sender: crossbeam_channel::Sender| { #[cfg(all( feature = "file_watcher", diff --git a/crates/bevy_asset/src/io/wasm.rs b/crates/bevy_asset/src/io/wasm.rs index 125543fc113a4..75c77fdb5c4e0 100644 --- a/crates/bevy_asset/src/io/wasm.rs +++ b/crates/bevy_asset/src/io/wasm.rs @@ -1,11 +1,11 @@ use crate::io::{ - get_meta_path, AssetReader, AssetReaderError, EmptyPathStream, PathStream, Reader, VecReader, + AssetReader, AssetReaderError, EmptyPathStream, PathStream, Reader, VecReader, get_meta_path, }; use alloc::{borrow::ToOwned, boxed::Box, format}; -use js_sys::{Uint8Array, JSON}; +use js_sys::{JSON, Uint8Array}; use std::path::{Path, PathBuf}; use tracing::error; -use wasm_bindgen::{prelude::wasm_bindgen, JsCast, JsValue}; +use wasm_bindgen::{JsCast, JsValue, prelude::wasm_bindgen}; use wasm_bindgen_futures::JsFuture; use web_sys::Response; diff --git a/crates/bevy_asset/src/lib.rs b/crates/bevy_asset/src/lib.rs index f0b8e92a9320d..a7bbd8aa385a0 100644 --- a/crates/bevy_asset/src/lib.rs +++ b/crates/bevy_asset/src/lib.rs @@ -208,7 +208,7 @@ pub use ron; pub use uuid; use crate::{ - io::{embedded::EmbeddedAssetRegistry, AssetSourceBuilder, AssetSourceBuilders, AssetSourceId}, + io::{AssetSourceBuilder, AssetSourceBuilders, AssetSourceId, embedded::EmbeddedAssetRegistry}, processor::{AssetProcessor, Process}, }; use alloc::{ @@ -536,7 +536,10 @@ impl AssetApp for App { ) -> &mut Self { let id = AssetSourceId::from_static(id); if self.world().get_resource::().is_some() { - error!("{} must be registered before `AssetPlugin` (typically added as part of `DefaultPlugins`)", id); + error!( + "{} must be registered before `AssetPlugin` (typically added as part of `DefaultPlugins`)", + id + ); } { @@ -630,16 +633,16 @@ pub struct AssetEvents; #[cfg(test)] mod tests { use crate::{ + Asset, AssetApp, AssetEvent, AssetId, AssetLoadError, AssetLoadFailedEvent, AssetPath, + AssetPlugin, AssetServer, Assets, folder::LoadedFolder, handle::Handle, io::{ + AssetReader, AssetReaderError, AssetSource, AssetSourceId, Reader, gated::{GateOpener, GatedReader}, memory::{Dir, MemoryAssetReader}, - AssetReader, AssetReaderError, AssetSource, AssetSourceId, Reader, }, loader::{AssetLoader, LoadContext}, - Asset, AssetApp, AssetEvent, AssetId, AssetLoadError, AssetLoadFailedEvent, AssetPath, - AssetPlugin, AssetServer, Assets, }; use alloc::{ boxed::Box, @@ -863,7 +866,9 @@ mod tests { fn load_dependencies() { // The particular usage of GatedReader in this test will cause deadlocking if running single-threaded #[cfg(not(feature = "multi_threaded"))] - panic!("This test requires the \"multi_threaded\" feature, otherwise it will deadlock.\ncargo test --package bevy_asset --features multi_threaded"); + panic!( + "This test requires the \"multi_threaded\" feature, otherwise it will deadlock.\ncargo test --package bevy_asset --features multi_threaded" + ); let dir = Dir::default(); @@ -1171,7 +1176,9 @@ mod tests { fn failure_load_states() { // The particular usage of GatedReader in this test will cause deadlocking if running single-threaded #[cfg(not(feature = "multi_threaded"))] - panic!("This test requires the \"multi_threaded\" feature, otherwise it will deadlock.\ncargo test --package bevy_asset --features multi_threaded"); + panic!( + "This test requires the \"multi_threaded\" feature, otherwise it will deadlock.\ncargo test --package bevy_asset --features multi_threaded" + ); let dir = Dir::default(); @@ -1288,9 +1295,11 @@ mod tests { assert!(asset_server.load_state(a_id).is_loaded()); assert!(asset_server.dependency_load_state(a_id).is_loaded()); - assert!(asset_server - .recursive_dependency_load_state(a_id) - .is_failed()); + assert!( + asset_server + .recursive_dependency_load_state(a_id) + .is_failed() + ); assert!(asset_server.is_loaded(a_id)); assert!(asset_server.is_loaded_with_direct_dependencies(a_id)); @@ -1304,7 +1313,9 @@ mod tests { fn dependency_load_states() { // The particular usage of GatedReader in this test will cause deadlocking if running single-threaded #[cfg(not(feature = "multi_threaded"))] - panic!("This test requires the \"multi_threaded\" feature, otherwise it will deadlock.\ncargo test --package bevy_asset --features multi_threaded"); + panic!( + "This test requires the \"multi_threaded\" feature, otherwise it will deadlock.\ncargo test --package bevy_asset --features multi_threaded" + ); let a_path = "a.cool.ron"; let a_ron = r#" @@ -1443,7 +1454,9 @@ mod tests { fn manual_asset_management() { // The particular usage of GatedReader in this test will cause deadlocking if running single-threaded #[cfg(not(feature = "multi_threaded"))] - panic!("This test requires the \"multi_threaded\" feature, otherwise it will deadlock.\ncargo test --package bevy_asset --features multi_threaded"); + panic!( + "This test requires the \"multi_threaded\" feature, otherwise it will deadlock.\ncargo test --package bevy_asset --features multi_threaded" + ); let dir = Dir::default(); let dep_path = "dep.cool.ron"; @@ -1544,7 +1557,9 @@ mod tests { fn load_folder() { // The particular usage of GatedReader in this test will cause deadlocking if running single-threaded #[cfg(not(feature = "multi_threaded"))] - panic!("This test requires the \"multi_threaded\" feature, otherwise it will deadlock.\ncargo test --package bevy_asset --features multi_threaded"); + panic!( + "This test requires the \"multi_threaded\" feature, otherwise it will deadlock.\ncargo test --package bevy_asset --features multi_threaded" + ); let dir = Dir::default(); diff --git a/crates/bevy_asset/src/loader.rs b/crates/bevy_asset/src/loader.rs index 3be672e0c194d..6b1bded0cf418 100644 --- a/crates/bevy_asset/src/loader.rs +++ b/crates/bevy_asset/src/loader.rs @@ -1,10 +1,10 @@ use crate::{ + Asset, AssetLoadError, AssetServer, AssetServerMode, Assets, Handle, UntypedAssetId, + UntypedHandle, io::{AssetReaderError, MissingAssetSourceError, MissingProcessedAssetReaderError, Reader}, loader_builders::{Deferred, NestedLoader, StaticTyped}, meta::{AssetHash, AssetMeta, AssetMetaDyn, ProcessedInfoMinimal, Settings}, path::AssetPath, - Asset, AssetLoadError, AssetServer, AssetServerMode, Assets, Handle, UntypedAssetId, - UntypedHandle, }; use alloc::{ boxed::Box, @@ -17,7 +17,7 @@ use bevy_log::warn; use bevy_platform_support::collections::{HashMap, HashSet}; use bevy_tasks::{BoxedFuture, ConditionalSendFuture}; use core::any::{Any, TypeId}; -use downcast_rs::{impl_downcast, Downcast}; +use downcast_rs::{Downcast, impl_downcast}; use ron::error::SpannedError; use serde::{Deserialize, Serialize}; use std::path::{Path, PathBuf}; @@ -508,7 +508,9 @@ impl<'a> LoadContext<'a> { ); for (label, asset) in labeled_assets { if self.labeled_assets.insert(label.clone(), asset).is_some() { - warn!("A labeled asset with the label \"{label}\" already exists. Replacing with the new asset."); + warn!( + "A labeled asset with the label \"{label}\" already exists. Replacing with the new asset." + ); } } handle @@ -658,6 +660,8 @@ pub enum ReadAssetBytesError { path: PathBuf, source: std::io::Error, }, - #[error("The LoadContext for this read_asset_bytes call requires hash metadata, but it was not provided. This is likely an internal implementation error.")] + #[error( + "The LoadContext for this read_asset_bytes call requires hash metadata, but it was not provided. This is likely an internal implementation error." + )] MissingAssetHash, } diff --git a/crates/bevy_asset/src/loader_builders.rs b/crates/bevy_asset/src/loader_builders.rs index 630ab1f92cd18..f02a79c516bcf 100644 --- a/crates/bevy_asset/src/loader_builders.rs +++ b/crates/bevy_asset/src/loader_builders.rs @@ -2,10 +2,10 @@ //! [`LoadContext::loader`]. use crate::{ - io::Reader, - meta::{meta_transform_settings, AssetMetaDyn, MetaTransform, Settings}, Asset, AssetLoadError, AssetPath, CompleteErasedLoadedAsset, CompleteLoadedAsset, ErasedAssetLoader, Handle, LoadContext, LoadDirectError, LoadedUntypedAsset, UntypedHandle, + io::Reader, + meta::{AssetMetaDyn, MetaTransform, Settings, meta_transform_settings}, }; use alloc::{borrow::ToOwned, boxed::Box, sync::Arc}; use core::any::TypeId; diff --git a/crates/bevy_asset/src/meta.rs b/crates/bevy_asset/src/meta.rs index 0e972261198cc..d870ba1c7cd14 100644 --- a/crates/bevy_asset/src/meta.rs +++ b/crates/bevy_asset/src/meta.rs @@ -5,10 +5,10 @@ use alloc::{ }; use crate::{ - loader::AssetLoader, processor::Process, Asset, AssetPath, DeserializeMetaError, - VisitAssetDependencies, + Asset, AssetPath, DeserializeMetaError, VisitAssetDependencies, loader::AssetLoader, + processor::Process, }; -use downcast_rs::{impl_downcast, Downcast}; +use downcast_rs::{Downcast, impl_downcast}; use ron::ser::PrettyConfig; use serde::{Deserialize, Serialize}; use tracing::error; diff --git a/crates/bevy_asset/src/path.rs b/crates/bevy_asset/src/path.rs index 3038c52fbadbe..e2345c38e02ed 100644 --- a/crates/bevy_asset/src/path.rs +++ b/crates/bevy_asset/src/path.rs @@ -10,7 +10,7 @@ use core::{ hash::Hash, ops::Deref, }; -use serde::{de::Visitor, Deserialize, Serialize}; +use serde::{Deserialize, Serialize, de::Visitor}; use std::path::{Path, PathBuf}; use thiserror::Error; @@ -89,10 +89,14 @@ pub enum ParseAssetPathError { #[error("Asset label must not contain a `://` substring")] InvalidLabelSyntax, /// Error that occurs when a path string has an [`AssetPath::source`] delimiter `://` with no characters preceding it. E.g. `://file.test`. - #[error("Asset source must be at least one character. Either specify the source before the '://' or remove the `://`")] + #[error( + "Asset source must be at least one character. Either specify the source before the '://' or remove the `://`" + )] MissingSource, /// Error that occurs when a path string has an [`AssetPath::label`] delimiter `#` with no characters succeeding it. E.g. `file.test#` - #[error("Asset label must be at least one character. Either specify the label after the '#' or remove the '#'")] + #[error( + "Asset label must be at least one character. Either specify the label after the '#' or remove the '#'" + )] MissingLabel, } diff --git a/crates/bevy_asset/src/processor/mod.rs b/crates/bevy_asset/src/processor/mod.rs index bfc9a295d86d3..eed13a28b1f19 100644 --- a/crates/bevy_asset/src/processor/mod.rs +++ b/crates/bevy_asset/src/processor/mod.rs @@ -44,17 +44,17 @@ pub use log::*; pub use process::*; use crate::{ + AssetLoadError, AssetMetaCheck, AssetPath, AssetServer, AssetServerMode, DeserializeMetaError, + MissingAssetLoaderForExtensionError, io::{ AssetReaderError, AssetSource, AssetSourceBuilders, AssetSourceEvent, AssetSourceId, AssetSources, AssetWriterError, ErasedAssetReader, ErasedAssetWriter, MissingAssetSourceError, }, meta::{ - get_asset_hash, get_full_asset_hash, AssetAction, AssetActionMinimal, AssetHash, AssetMeta, - AssetMetaDyn, AssetMetaMinimal, ProcessedInfo, ProcessedInfoMinimal, + AssetAction, AssetActionMinimal, AssetHash, AssetMeta, AssetMetaDyn, AssetMetaMinimal, + ProcessedInfo, ProcessedInfoMinimal, get_asset_hash, get_full_asset_hash, }, - AssetLoadError, AssetMetaCheck, AssetPath, AssetServer, AssetServerMode, DeserializeMetaError, - MissingAssetLoaderForExtensionError, }; use alloc::{borrow::ToOwned, boxed::Box, collections::VecDeque, sync::Arc, vec, vec::Vec}; use bevy_ecs::prelude::*; @@ -428,7 +428,9 @@ impl AssetProcessor { // then we automatically clean up this folder if err.kind() != ErrorKind::NotFound { let asset_path = AssetPath::from_path(path).with_source(source.id()); - error!("Failed to remove destination folder that no longer exists in {asset_path}: {err}"); + error!( + "Failed to remove destination folder that no longer exists in {asset_path}: {err}" + ); } } } @@ -653,14 +655,18 @@ impl AssetProcessor { info.processed_info = minimal.processed_info; } Err(err) => { - trace!("Removing processed data for {asset_path} because meta could not be parsed: {err}"); + trace!( + "Removing processed data for {asset_path} because meta could not be parsed: {err}" + ); self.remove_processed_asset_and_meta(source, asset_path.path()) .await; } } } Err(err) => { - trace!("Removing processed data for {asset_path} because meta failed to load: {err}"); + trace!( + "Removing processed data for {asset_path} because meta failed to load: {err}" + ); self.remove_processed_asset_and_meta(source, asset_path.path()) .await; } @@ -700,7 +706,9 @@ impl AssetProcessor { async fn clean_empty_processed_ancestor_folders(&self, source: &AssetSource, path: &Path) { // As a safety precaution don't delete absolute paths to avoid deleting folders outside of the destination folder if path.is_absolute() { - error!("Attempted to clean up ancestor folders of an absolute path. This is unsafe so the operation was skipped."); + error!( + "Attempted to clean up ancestor folders of an absolute path. This is unsafe so the operation was skipped." + ); return; } while let Some(parent) = path.parent() { @@ -812,7 +820,7 @@ impl AssetProcessor { return Err(ProcessError::ReadAssetMetaError { path: asset_path.clone(), err, - }) + }); } }; @@ -926,11 +934,15 @@ impl AssetProcessor { if let Err(err) = ProcessorTransactionLog::validate().await { let state_is_valid = match err { ValidateLogError::ReadLogError(err) => { - error!("Failed to read processor log file. Processed assets cannot be validated so they must be re-generated {err}"); + error!( + "Failed to read processor log file. Processed assets cannot be validated so they must be re-generated {err}" + ); false } ValidateLogError::UnrecoverableError => { - error!("Encountered an unrecoverable error in the last run. Processed assets cannot be validated so they must be re-generated"); + error!( + "Encountered an unrecoverable error in the last run. Processed assets cannot be validated so they must be re-generated" + ); false } ValidateLogError::EntryErrors(entry_errors) => { @@ -944,7 +956,9 @@ impl AssetProcessor { break; } LogEntryError::UnfinishedTransaction(path) => { - debug!("Asset {path:?} did not finish processing. Clearing state for that asset"); + debug!( + "Asset {path:?} did not finish processing. Clearing state for that asset" + ); let mut unrecoverable_err = |message: &dyn core::fmt::Display| { error!("Failed to remove asset {path:?}: {message}"); state_is_valid = false; @@ -954,7 +968,9 @@ impl AssetProcessor { continue; }; let Ok(processed_writer) = source.processed_writer() else { - unrecoverable_err(&"AssetSource does not have a processed AssetWriter registered"); + unrecoverable_err( + &"AssetSource does not have a processed AssetWriter registered", + ); continue; }; @@ -986,7 +1002,9 @@ impl AssetProcessor { }; if !state_is_valid { - error!("Processed asset transaction log state was invalid and unrecoverable for some reason (see previous logs). Removing processed assets and starting fresh."); + error!( + "Processed asset transaction log state was invalid and unrecoverable for some reason (see previous logs). Removing processed assets and starting fresh." + ); for source in self.sources().iter_processed() { let Ok(processed_writer) = source.processed_writer() else { continue; @@ -995,7 +1013,9 @@ impl AssetProcessor { .remove_assets_in_directory(Path::new("")) .await { - panic!("Processed assets were in a bad state. To correct this, the asset processor attempted to remove all processed assets and start from scratch. This failed. There is no way to continue. Try restarting, or deleting imported asset folder manually. {err}"); + panic!( + "Processed assets were in a bad state. To correct this, the asset processor attempted to remove all processed assets and start from scratch. This failed. There is no way to continue. Try restarting, or deleting imported asset folder manually. {err}" + ); } } } @@ -1003,7 +1023,10 @@ impl AssetProcessor { let mut log = self.data.log.write().await; *log = match ProcessorTransactionLog::new().await { Ok(log) => Some(log), - Err(err) => panic!("Failed to initialize asset processor log. This cannot be recovered. Try restarting. If that doesn't work, try deleting processed asset folder. {}", err), + Err(err) => panic!( + "Failed to initialize asset processor log. This cannot be recovered. Try restarting. If that doesn't work, try deleting processed asset folder. {}", + err + ), }; } } diff --git a/crates/bevy_asset/src/processor/process.rs b/crates/bevy_asset/src/processor/process.rs index d2202d2334d23..f987f662d90a3 100644 --- a/crates/bevy_asset/src/processor/process.rs +++ b/crates/bevy_asset/src/processor/process.rs @@ -1,4 +1,6 @@ use crate::{ + AssetLoadError, AssetLoader, AssetPath, CompleteErasedLoadedAsset, DeserializeMetaError, + MissingAssetLoaderForExtensionError, MissingAssetLoaderForTypeNameError, io::{ AssetReaderError, AssetWriterError, MissingAssetWriterError, MissingProcessedAssetReaderError, MissingProcessedAssetWriterError, SliceReader, Writer, @@ -7,8 +9,6 @@ use crate::{ processor::AssetProcessor, saver::{AssetSaver, SavedAsset}, transformer::{AssetTransformer, IdentityAssetTransformer, TransformedAsset}, - AssetLoadError, AssetLoader, AssetPath, CompleteErasedLoadedAsset, DeserializeMetaError, - MissingAssetLoaderForExtensionError, MissingAssetLoaderForTypeNameError, }; use alloc::{ borrow::ToOwned, @@ -96,10 +96,10 @@ pub struct LoadTransformAndSaveSettings, - S: AssetSaver, - > LoadTransformAndSave + L: AssetLoader, + T: AssetTransformer, + S: AssetSaver, +> LoadTransformAndSave { pub fn new(transformer: T, saver: S) -> Self { LoadTransformAndSave { @@ -148,7 +148,9 @@ pub enum ProcessError { DeserializeMetaError(#[from] DeserializeMetaError), #[error(transparent)] AssetLoadError(#[from] AssetLoadError), - #[error("The wrong meta type was passed into a processor. This is probably an internal implementation error.")] + #[error( + "The wrong meta type was passed into a processor. This is probably an internal implementation error." + )] WrongMetaType, #[error("Encountered an error while saving the asset: {0}")] #[from(ignore)] diff --git a/crates/bevy_asset/src/reflect.rs b/crates/bevy_asset/src/reflect.rs index 5c436c10610f0..2743b5a14c5c8 100644 --- a/crates/bevy_asset/src/reflect.rs +++ b/crates/bevy_asset/src/reflect.rs @@ -1,7 +1,7 @@ use alloc::boxed::Box; use core::any::{Any, TypeId}; -use bevy_ecs::world::{unsafe_world_cell::UnsafeWorldCell, World}; +use bevy_ecs::world::{World, unsafe_world_cell::UnsafeWorldCell}; use bevy_reflect::{FromReflect, FromType, PartialReflect, Reflect}; use crate::{Asset, AssetId, Assets, Handle, UntypedAssetId, UntypedHandle}; diff --git a/crates/bevy_asset/src/saver.rs b/crates/bevy_asset/src/saver.rs index 3b187e96ef88a..d4136c1e80865 100644 --- a/crates/bevy_asset/src/saver.rs +++ b/crates/bevy_asset/src/saver.rs @@ -1,6 +1,6 @@ use crate::{ - io::Writer, meta::Settings, transformer::TransformedAsset, Asset, AssetLoader, - CompleteErasedLoadedAsset, ErasedLoadedAsset, Handle, LabeledAsset, UntypedHandle, + Asset, AssetLoader, CompleteErasedLoadedAsset, ErasedLoadedAsset, Handle, LabeledAsset, + UntypedHandle, io::Writer, meta::Settings, transformer::TransformedAsset, }; use alloc::boxed::Box; use atomicow::CowArc; diff --git a/crates/bevy_asset/src/server/info.rs b/crates/bevy_asset/src/server/info.rs index e519bf86aeebf..00974987974ea 100644 --- a/crates/bevy_asset/src/server/info.rs +++ b/crates/bevy_asset/src/server/info.rs @@ -1,8 +1,8 @@ use crate::{ - meta::{AssetHash, MetaTransform}, Asset, AssetHandleProvider, AssetLoadError, AssetPath, DependencyLoadState, ErasedLoadedAsset, Handle, InternalAssetEvent, LoadState, RecursiveDependencyLoadState, StrongHandle, UntypedAssetId, UntypedHandle, + meta::{AssetHash, MetaTransform}, }; use alloc::{ borrow::ToOwned, @@ -11,7 +11,7 @@ use alloc::{ vec::Vec, }; use bevy_ecs::world::World; -use bevy_platform_support::collections::{hash_map::Entry, HashMap, HashSet}; +use bevy_platform_support::collections::{HashMap, HashSet, hash_map::Entry}; use bevy_tasks::Task; use bevy_utils::TypeIdMap; use core::{any::TypeId, task::Waker}; @@ -782,12 +782,16 @@ pub(crate) fn unwrap_with_context( Err(GetOrCreateHandleInternalError::HandleMissingButTypeIdNotSpecified) => None, Err(GetOrCreateHandleInternalError::MissingHandleProviderError(_)) => match type_info { Either::Left(type_name) => { - panic!("Cannot allocate an Asset Handle of type '{type_name}' because the asset type has not been initialized. \ - Make sure you have called `app.init_asset::<{type_name}>()`"); + panic!( + "Cannot allocate an Asset Handle of type '{type_name}' because the asset type has not been initialized. \ + Make sure you have called `app.init_asset::<{type_name}>()`" + ); } Either::Right(type_id) => { - panic!("Cannot allocate an AssetHandle of type '{type_id:?}' because the asset type has not been initialized. \ - Make sure you have called `app.init_asset::<(actual asset type)>()`") + panic!( + "Cannot allocate an AssetHandle of type '{type_id:?}' because the asset type has not been initialized. \ + Make sure you have called `app.init_asset::<(actual asset type)>()`" + ) } }, } diff --git a/crates/bevy_asset/src/server/loaders.rs b/crates/bevy_asset/src/server/loaders.rs index 1250ff666ae9f..1d5a30d8e7dd7 100644 --- a/crates/bevy_asset/src/server/loaders.rs +++ b/crates/bevy_asset/src/server/loaders.rs @@ -73,8 +73,10 @@ impl AssetLoaders { list.push(loader_index); } if !duplicate_extensions.is_empty() { - warn!("Duplicate AssetLoader registered for Asset type `{loader_asset_type_name}` with extensions `{duplicate_extensions:?}`. \ - Loader must be specified in a .meta file in order to load assets of this type with these extensions."); + warn!( + "Duplicate AssetLoader registered for Asset type `{loader_asset_type_name}` with extensions `{duplicate_extensions:?}`. \ + Loader must be specified in a .meta file in order to load assets of this type with these extensions." + ); } self.type_name_to_loader.insert(type_name, loader_index); @@ -139,8 +141,10 @@ impl AssetLoaders { list.push(loader_index); } if !duplicate_extensions.is_empty() { - warn!("Duplicate AssetLoader preregistered for Asset type `{loader_asset_type_name}` with extensions `{duplicate_extensions:?}`. \ - Loader must be specified in a .meta file in order to load assets of this type with these extensions."); + warn!( + "Duplicate AssetLoader preregistered for Asset type `{loader_asset_type_name}` with extensions `{duplicate_extensions:?}`. \ + Loader must be specified in a .meta file in order to load assets of this type with these extensions." + ); } self.type_id_to_loaders @@ -346,7 +350,7 @@ mod tests { use core::marker::PhantomData; use std::{ path::Path, - sync::mpsc::{channel, Receiver, Sender}, + sync::mpsc::{Receiver, Sender, channel}, }; use bevy_reflect::TypePath; diff --git a/crates/bevy_asset/src/server/mod.rs b/crates/bevy_asset/src/server/mod.rs index e65bbd2b6acb7..9518e0e697e5d 100644 --- a/crates/bevy_asset/src/server/mod.rs +++ b/crates/bevy_asset/src/server/mod.rs @@ -2,6 +2,9 @@ mod info; mod loaders; use crate::{ + Asset, AssetEvent, AssetHandleProvider, AssetId, AssetLoadFailedEvent, AssetMetaCheck, Assets, + CompleteErasedLoadedAsset, DeserializeMetaError, ErasedLoadedAsset, Handle, LoadedUntypedAsset, + UntypedAssetId, UntypedAssetLoadFailedEvent, UntypedHandle, folder::LoadedFolder, io::{ AssetReaderError, AssetSource, AssetSourceEvent, AssetSourceId, AssetSources, @@ -9,13 +12,10 @@ use crate::{ }, loader::{AssetLoader, ErasedAssetLoader, LoadContext, LoadedAsset}, meta::{ - loader_settings_meta_transform, AssetActionMinimal, AssetMetaDyn, AssetMetaMinimal, - MetaTransform, Settings, + AssetActionMinimal, AssetMetaDyn, AssetMetaMinimal, MetaTransform, Settings, + loader_settings_meta_transform, }, path::AssetPath, - Asset, AssetEvent, AssetHandleProvider, AssetId, AssetLoadFailedEvent, AssetMetaCheck, Assets, - CompleteErasedLoadedAsset, DeserializeMetaError, ErasedLoadedAsset, Handle, LoadedUntypedAsset, - UntypedAssetId, UntypedAssetLoadFailedEvent, UntypedHandle, }; use alloc::{borrow::ToOwned, boxed::Box, vec, vec::Vec}; use alloc::{ @@ -1261,12 +1261,12 @@ impl AssetServer { AssetActionMinimal::Process { .. } => { return Err(AssetLoadError::CannotLoadProcessedAsset { path: asset_path.clone_owned(), - }) + }); } AssetActionMinimal::Ignore => { return Err(AssetLoadError::CannotLoadIgnoredAsset { path: asset_path.clone_owned(), - }) + }); } }; let loader = self.get_asset_loader_with_type_name(&loader_name).await?; @@ -1742,14 +1742,18 @@ impl RecursiveDependencyLoadState { reason = "Adding docs to the variants would not add information beyond the error message and the names" )] pub enum AssetLoadError { - #[error("Requested handle of type {requested:?} for asset '{path}' does not match actual asset type '{actual_asset_name}', which used loader '{loader_name}'")] + #[error( + "Requested handle of type {requested:?} for asset '{path}' does not match actual asset type '{actual_asset_name}', which used loader '{loader_name}'" + )] RequestedHandleTypeMismatch { path: AssetPath<'static>, requested: TypeId, actual_asset_name: &'static str, loader_name: &'static str, }, - #[error("Could not find an asset loader matching: Loader Name: {loader_name:?}; Asset Type: {loader_name:?}; Extension: {extension:?}; Path: {asset_path:?};")] + #[error( + "Could not find an asset loader matching: Loader Name: {loader_name:?}; Asset Type: {loader_name:?}; Extension: {extension:?}; Path: {asset_path:?};" + )] MissingAssetLoader { loader_name: Option, asset_type_id: Option, diff --git a/crates/bevy_asset/src/transformer.rs b/crates/bevy_asset/src/transformer.rs index d2573582f16f0..7eed5b565a2a3 100644 --- a/crates/bevy_asset/src/transformer.rs +++ b/crates/bevy_asset/src/transformer.rs @@ -1,6 +1,6 @@ use crate::{ - meta::Settings, Asset, CompleteErasedLoadedAsset, ErasedLoadedAsset, Handle, LabeledAsset, - UntypedHandle, + Asset, CompleteErasedLoadedAsset, ErasedLoadedAsset, Handle, LabeledAsset, UntypedHandle, + meta::Settings, }; use alloc::boxed::Box; use atomicow::CowArc; diff --git a/crates/bevy_audio/src/audio_source.rs b/crates/bevy_audio/src/audio_source.rs index 9cf3ca988b0b1..250e0df4e7db5 100644 --- a/crates/bevy_audio/src/audio_source.rs +++ b/crates/bevy_audio/src/audio_source.rs @@ -1,5 +1,5 @@ use alloc::sync::Arc; -use bevy_asset::{io::Reader, Asset, AssetLoader, LoadContext}; +use bevy_asset::{Asset, AssetLoader, LoadContext, io::Reader}; use bevy_reflect::TypePath; use std::io::Cursor; diff --git a/crates/bevy_audio/src/lib.rs b/crates/bevy_audio/src/lib.rs index babae2f8a9be9..3f57cf6f24661 100644 --- a/crates/bevy_audio/src/lib.rs +++ b/crates/bevy_audio/src/lib.rs @@ -52,7 +52,7 @@ pub use audio_source::*; pub use pitch::*; pub use volume::*; -pub use rodio::{cpal::Sample as CpalSample, source::Source, Sample}; +pub use rodio::{Sample, cpal::Sample as CpalSample, source::Source}; pub use sinks::*; use bevy_app::prelude::*; diff --git a/crates/bevy_audio/src/pitch.rs b/crates/bevy_audio/src/pitch.rs index d85b9b31cf071..e511356b9d662 100644 --- a/crates/bevy_audio/src/pitch.rs +++ b/crates/bevy_audio/src/pitch.rs @@ -2,8 +2,8 @@ use crate::Decodable; use bevy_asset::Asset; use bevy_reflect::TypePath; use rodio::{ - source::{SineWave, TakeDuration}, Source, + source::{SineWave, TakeDuration}, }; /// A source of sine wave sound diff --git a/crates/bevy_color/src/color.rs b/crates/bevy_color/src/color.rs index d4754d204eff5..c2995daea95a7 100644 --- a/crates/bevy_color/src/color.rs +++ b/crates/bevy_color/src/color.rs @@ -1,6 +1,6 @@ use crate::{ - color_difference::EuclideanDistance, Alpha, Hsla, Hsva, Hue, Hwba, Laba, Lcha, LinearRgba, - Luminance, Mix, Oklaba, Oklcha, Srgba, StandardColor, Xyza, + Alpha, Hsla, Hsva, Hue, Hwba, Laba, Lcha, LinearRgba, Luminance, Mix, Oklaba, Oklcha, Srgba, + StandardColor, Xyza, color_difference::EuclideanDistance, }; #[cfg(feature = "bevy_reflect")] use bevy_reflect::prelude::*; diff --git a/crates/bevy_color/src/color_gradient.rs b/crates/bevy_color/src/color_gradient.rs index b087205bb6b49..5fa2c2c894f75 100644 --- a/crates/bevy_color/src/color_gradient.rs +++ b/crates/bevy_color/src/color_gradient.rs @@ -1,8 +1,8 @@ use crate::Mix; use alloc::vec::Vec; use bevy_math::curve::{ - cores::{EvenCore, EvenCoreError}, Curve, Interval, + cores::{EvenCore, EvenCoreError}, }; /// A curve whose samples are defined by a collection of colors. @@ -75,7 +75,7 @@ where #[cfg(test)] mod tests { use super::*; - use crate::{palettes::basic, Srgba}; + use crate::{Srgba, palettes::basic}; use bevy_math::curve::{Curve, CurveExt}; #[test] diff --git a/crates/bevy_color/src/color_ops.rs b/crates/bevy_color/src/color_ops.rs index 235c8c8bf3ae1..745a4c9c27d63 100644 --- a/crates/bevy_color/src/color_ops.rs +++ b/crates/bevy_color/src/color_ops.rs @@ -1,4 +1,4 @@ -use bevy_math::{ops, Vec3, Vec4}; +use bevy_math::{Vec3, Vec4, ops}; /// Methods for changing the luminance of a color. Note that these methods are not /// guaranteed to produce consistent results across color spaces, @@ -140,7 +140,7 @@ mod tests { use core::fmt::Debug; use super::*; - use crate::{testing::assert_approx_eq, Hsla}; + use crate::{Hsla, testing::assert_approx_eq}; #[test] fn test_rotate_hue() { diff --git a/crates/bevy_color/src/color_range.rs b/crates/bevy_color/src/color_range.rs index 48afa5418225d..8448eb187ccd7 100644 --- a/crates/bevy_color/src/color_range.rs +++ b/crates/bevy_color/src/color_range.rs @@ -22,7 +22,7 @@ impl ColorRange for Range { #[cfg(test)] mod tests { use super::*; - use crate::{palettes::basic, LinearRgba, Srgba}; + use crate::{LinearRgba, Srgba, palettes::basic}; #[test] fn test_color_range() { diff --git a/crates/bevy_color/src/hwba.rs b/crates/bevy_color/src/hwba.rs index 459b5d82dc4fd..10c22121fd033 100644 --- a/crates/bevy_color/src/hwba.rs +++ b/crates/bevy_color/src/hwba.rs @@ -5,7 +5,7 @@ use crate::{ Alpha, ColorToComponents, Gray, Hue, Lcha, LinearRgba, Mix, Srgba, StandardColor, Xyza, }; -use bevy_math::{ops, Vec3, Vec4}; +use bevy_math::{Vec3, Vec4, ops}; #[cfg(feature = "bevy_reflect")] use bevy_reflect::prelude::*; diff --git a/crates/bevy_color/src/laba.rs b/crates/bevy_color/src/laba.rs index 39ac37f8ffa1a..b09f86b4a7028 100644 --- a/crates/bevy_color/src/laba.rs +++ b/crates/bevy_color/src/laba.rs @@ -1,8 +1,8 @@ use crate::{ - impl_componentwise_vector_space, Alpha, ColorToComponents, Gray, Hsla, Hsva, Hwba, LinearRgba, - Luminance, Mix, Oklaba, Srgba, StandardColor, Xyza, + Alpha, ColorToComponents, Gray, Hsla, Hsva, Hwba, LinearRgba, Luminance, Mix, Oklaba, Srgba, + StandardColor, Xyza, impl_componentwise_vector_space, }; -use bevy_math::{ops, Vec3, Vec4}; +use bevy_math::{Vec3, Vec4, ops}; #[cfg(feature = "bevy_reflect")] use bevy_reflect::prelude::*; diff --git a/crates/bevy_color/src/lcha.rs b/crates/bevy_color/src/lcha.rs index f1437d34969aa..85b3c7c93d943 100644 --- a/crates/bevy_color/src/lcha.rs +++ b/crates/bevy_color/src/lcha.rs @@ -2,7 +2,7 @@ use crate::{ Alpha, ColorToComponents, Gray, Hue, Laba, LinearRgba, Luminance, Mix, Srgba, StandardColor, Xyza, }; -use bevy_math::{ops, Vec3, Vec4}; +use bevy_math::{Vec3, Vec4, ops}; #[cfg(feature = "bevy_reflect")] use bevy_reflect::prelude::*; @@ -279,11 +279,7 @@ impl From for Lcha { let h = { let h = ops::atan2(b.to_radians(), a.to_radians()).to_degrees(); - if h < 0.0 { - h + 360.0 - } else { - h - } + if h < 0.0 { h + 360.0 } else { h } }; let chroma = c.clamp(0.0, 1.5); diff --git a/crates/bevy_color/src/linear_rgba.rs b/crates/bevy_color/src/linear_rgba.rs index d1781bfc4192c..a2dda83568e52 100644 --- a/crates/bevy_color/src/linear_rgba.rs +++ b/crates/bevy_color/src/linear_rgba.rs @@ -1,8 +1,8 @@ use crate::{ - color_difference::EuclideanDistance, impl_componentwise_vector_space, Alpha, ColorToComponents, - ColorToPacked, Gray, Luminance, Mix, StandardColor, + Alpha, ColorToComponents, ColorToPacked, Gray, Luminance, Mix, StandardColor, + color_difference::EuclideanDistance, impl_componentwise_vector_space, }; -use bevy_math::{ops, Vec3, Vec4}; +use bevy_math::{Vec3, Vec4, ops}; #[cfg(feature = "bevy_reflect")] use bevy_reflect::prelude::*; use bytemuck::{Pod, Zeroable}; diff --git a/crates/bevy_color/src/oklaba.rs b/crates/bevy_color/src/oklaba.rs index 1281109d02a96..d4af0870e4efa 100644 --- a/crates/bevy_color/src/oklaba.rs +++ b/crates/bevy_color/src/oklaba.rs @@ -1,8 +1,8 @@ use crate::{ - color_difference::EuclideanDistance, impl_componentwise_vector_space, Alpha, ColorToComponents, - Gray, Hsla, Hsva, Hwba, Lcha, LinearRgba, Luminance, Mix, Srgba, StandardColor, Xyza, + Alpha, ColorToComponents, Gray, Hsla, Hsva, Hwba, Lcha, LinearRgba, Luminance, Mix, Srgba, + StandardColor, Xyza, color_difference::EuclideanDistance, impl_componentwise_vector_space, }; -use bevy_math::{ops, FloatPow, Vec3, Vec4}; +use bevy_math::{FloatPow, Vec3, Vec4, ops}; #[cfg(feature = "bevy_reflect")] use bevy_reflect::prelude::*; diff --git a/crates/bevy_color/src/oklcha.rs b/crates/bevy_color/src/oklcha.rs index 70c150ed0fc97..194e775f00d29 100644 --- a/crates/bevy_color/src/oklcha.rs +++ b/crates/bevy_color/src/oklcha.rs @@ -1,8 +1,8 @@ use crate::{ - color_difference::EuclideanDistance, Alpha, ColorToComponents, Gray, Hsla, Hsva, Hue, Hwba, - Laba, Lcha, LinearRgba, Luminance, Mix, Oklaba, Srgba, StandardColor, Xyza, + Alpha, ColorToComponents, Gray, Hsla, Hsva, Hue, Hwba, Laba, Lcha, LinearRgba, Luminance, Mix, + Oklaba, Srgba, StandardColor, Xyza, color_difference::EuclideanDistance, }; -use bevy_math::{ops, FloatPow, Vec3, Vec4}; +use bevy_math::{FloatPow, Vec3, Vec4, ops}; #[cfg(feature = "bevy_reflect")] use bevy_reflect::prelude::*; diff --git a/crates/bevy_color/src/srgba.rs b/crates/bevy_color/src/srgba.rs index 49e40792b7d3e..0821d88d53a4c 100644 --- a/crates/bevy_color/src/srgba.rs +++ b/crates/bevy_color/src/srgba.rs @@ -1,10 +1,10 @@ use crate::{ - color_difference::EuclideanDistance, impl_componentwise_vector_space, Alpha, ColorToComponents, - ColorToPacked, Gray, LinearRgba, Luminance, Mix, StandardColor, Xyza, + Alpha, ColorToComponents, ColorToPacked, Gray, LinearRgba, Luminance, Mix, StandardColor, Xyza, + color_difference::EuclideanDistance, impl_componentwise_vector_space, }; #[cfg(feature = "alloc")] use alloc::{format, string::String}; -use bevy_math::{ops, Vec3, Vec4}; +use bevy_math::{Vec3, Vec4, ops}; #[cfg(feature = "bevy_reflect")] use bevy_reflect::prelude::*; use thiserror::Error; diff --git a/crates/bevy_color/src/xyza.rs b/crates/bevy_color/src/xyza.rs index a9fb422bef110..d6a831b899c8d 100644 --- a/crates/bevy_color/src/xyza.rs +++ b/crates/bevy_color/src/xyza.rs @@ -1,6 +1,6 @@ use crate::{ - impl_componentwise_vector_space, Alpha, ColorToComponents, Gray, LinearRgba, Luminance, Mix, - StandardColor, + Alpha, ColorToComponents, Gray, LinearRgba, Luminance, Mix, StandardColor, + impl_componentwise_vector_space, }; use bevy_math::{Vec3, Vec4}; #[cfg(feature = "bevy_reflect")] @@ -245,8 +245,8 @@ impl From for LinearRgba { mod tests { use super::*; use crate::{ - color_difference::EuclideanDistance, test_colors::TEST_COLORS, testing::assert_approx_eq, - Srgba, + Srgba, color_difference::EuclideanDistance, test_colors::TEST_COLORS, + testing::assert_approx_eq, }; #[test] diff --git a/crates/bevy_core_pipeline/src/auto_exposure/buffers.rs b/crates/bevy_core_pipeline/src/auto_exposure/buffers.rs index cc16cd4630d6d..b0492b74ab397 100644 --- a/crates/bevy_core_pipeline/src/auto_exposure/buffers.rs +++ b/crates/bevy_core_pipeline/src/auto_exposure/buffers.rs @@ -1,13 +1,13 @@ use bevy_ecs::prelude::*; -use bevy_platform_support::collections::{hash_map::Entry, HashMap}; +use bevy_platform_support::collections::{HashMap, hash_map::Entry}; use bevy_render::{ + Extract, render_resource::{StorageBuffer, UniformBuffer}, renderer::{RenderDevice, RenderQueue}, sync_world::RenderEntity, - Extract, }; -use super::{pipeline::AutoExposureUniform, AutoExposure}; +use super::{AutoExposure, pipeline::AutoExposureUniform}; #[derive(Resource, Default)] pub(super) struct AutoExposureBuffers { diff --git a/crates/bevy_core_pipeline/src/auto_exposure/compensation_curve.rs b/crates/bevy_core_pipeline/src/auto_exposure/compensation_curve.rs index 7a89de331c19c..0028a721442ce 100644 --- a/crates/bevy_core_pipeline/src/auto_exposure/compensation_curve.rs +++ b/crates/bevy_core_pipeline/src/auto_exposure/compensation_curve.rs @@ -1,6 +1,6 @@ use bevy_asset::prelude::*; -use bevy_ecs::system::{lifetimeless::SRes, SystemParamItem}; -use bevy_math::{cubic_splines::CubicGenerator, FloatExt, Vec2}; +use bevy_ecs::system::{SystemParamItem, lifetimeless::SRes}; +use bevy_math::{FloatExt, Vec2, cubic_splines::CubicGenerator}; use bevy_reflect::prelude::*; use bevy_render::{ render_asset::{RenderAsset, RenderAssetUsages}, diff --git a/crates/bevy_core_pipeline/src/auto_exposure/mod.rs b/crates/bevy_core_pipeline/src/auto_exposure/mod.rs index f94a61d09be16..ffe41663c334d 100644 --- a/crates/bevy_core_pipeline/src/auto_exposure/mod.rs +++ b/crates/bevy_core_pipeline/src/auto_exposure/mod.rs @@ -1,7 +1,8 @@ use bevy_app::prelude::*; -use bevy_asset::{load_internal_asset, AssetApp, Assets, Handle}; +use bevy_asset::{AssetApp, Assets, Handle, load_internal_asset}; use bevy_ecs::prelude::*; use bevy_render::{ + ExtractSchedule, Render, RenderApp, RenderSet, extract_component::ExtractComponentPlugin, render_asset::RenderAssetPlugin, render_graph::RenderGraphApp, @@ -9,7 +10,6 @@ use bevy_render::{ Buffer, BufferDescriptor, BufferUsages, PipelineCache, Shader, SpecializedComputePipelines, }, renderer::RenderDevice, - ExtractSchedule, Render, RenderApp, RenderSet, }; mod buffers; @@ -18,11 +18,11 @@ mod node; mod pipeline; mod settings; -use buffers::{extract_buffers, prepare_buffers, AutoExposureBuffers}; +use buffers::{AutoExposureBuffers, extract_buffers, prepare_buffers}; pub use compensation_curve::{AutoExposureCompensationCurve, AutoExposureCompensationCurveError}; use node::AutoExposureNode; use pipeline::{ - AutoExposurePass, AutoExposurePipeline, ViewAutoExposurePipeline, METERING_SHADER_HANDLE, + AutoExposurePass, AutoExposurePipeline, METERING_SHADER_HANDLE, ViewAutoExposurePipeline, }; pub use settings::AutoExposure; diff --git a/crates/bevy_core_pipeline/src/auto_exposure/node.rs b/crates/bevy_core_pipeline/src/auto_exposure/node.rs index 222efe5c62bd0..171d2aa5ea8ea 100644 --- a/crates/bevy_core_pipeline/src/auto_exposure/node.rs +++ b/crates/bevy_core_pipeline/src/auto_exposure/node.rs @@ -1,8 +1,8 @@ use super::{ + AutoExposureResources, buffers::AutoExposureBuffers, compensation_curve::GpuAutoExposureCompensationCurve, pipeline::{AutoExposurePipeline, ViewAutoExposurePipeline}, - AutoExposureResources, }; use bevy_ecs::{ query::QueryState, diff --git a/crates/bevy_core_pipeline/src/auto_exposure/settings.rs b/crates/bevy_core_pipeline/src/auto_exposure/settings.rs index b5039030ac969..e938989f9ff85 100644 --- a/crates/bevy_core_pipeline/src/auto_exposure/settings.rs +++ b/crates/bevy_core_pipeline/src/auto_exposure/settings.rs @@ -4,7 +4,7 @@ use super::compensation_curve::AutoExposureCompensationCurve; use bevy_asset::Handle; use bevy_ecs::{prelude::Component, reflect::ReflectComponent}; use bevy_image::Image; -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; use bevy_render::extract_component::ExtractComponent; use bevy_utils::default; diff --git a/crates/bevy_core_pipeline/src/blit/mod.rs b/crates/bevy_core_pipeline/src/blit/mod.rs index 53c54c6d2d7aa..8dc4bb57bfa28 100644 --- a/crates/bevy_core_pipeline/src/blit/mod.rs +++ b/crates/bevy_core_pipeline/src/blit/mod.rs @@ -1,13 +1,13 @@ use bevy_app::{App, Plugin}; -use bevy_asset::{load_internal_asset, weak_handle, Handle}; +use bevy_asset::{Handle, load_internal_asset, weak_handle}; use bevy_ecs::prelude::*; use bevy_render::{ + RenderApp, render_resource::{ binding_types::{sampler, texture_2d}, *, }, renderer::RenderDevice, - RenderApp, }; use crate::fullscreen_vertex_shader::fullscreen_shader_vertex_state; diff --git a/crates/bevy_core_pipeline/src/bloom/downsampling_pipeline.rs b/crates/bevy_core_pipeline/src/bloom/downsampling_pipeline.rs index 544b420bfdb68..cbbc0da4680f4 100644 --- a/crates/bevy_core_pipeline/src/bloom/downsampling_pipeline.rs +++ b/crates/bevy_core_pipeline/src/bloom/downsampling_pipeline.rs @@ -1,4 +1,4 @@ -use super::{Bloom, BLOOM_SHADER_HANDLE, BLOOM_TEXTURE_FORMAT}; +use super::{BLOOM_SHADER_HANDLE, BLOOM_TEXTURE_FORMAT, Bloom}; use crate::fullscreen_vertex_shader::fullscreen_shader_vertex_state; use bevy_ecs::{ prelude::{Component, Entity}, diff --git a/crates/bevy_core_pipeline/src/bloom/mod.rs b/crates/bevy_core_pipeline/src/bloom/mod.rs index 295b04c6ad0f1..a64323517bae9 100644 --- a/crates/bevy_core_pipeline/src/bloom/mod.rs +++ b/crates/bevy_core_pipeline/src/bloom/mod.rs @@ -10,10 +10,11 @@ use crate::{ core_3d::graph::{Core3d, Node3d}, }; use bevy_app::{App, Plugin}; -use bevy_asset::{load_internal_asset, weak_handle, Handle}; +use bevy_asset::{Handle, load_internal_asset, weak_handle}; use bevy_ecs::{prelude::*, query::QueryItem}; -use bevy_math::{ops, UVec2}; +use bevy_math::{UVec2, ops}; use bevy_render::{ + Render, RenderApp, RenderSet, camera::ExtractedCamera, diagnostic::RecordDiagnostics, extract_component::{ @@ -24,14 +25,13 @@ use bevy_render::{ renderer::{RenderContext, RenderDevice}, texture::{CachedTexture, TextureCache}, view::ViewTarget, - Render, RenderApp, RenderSet, }; use downsampling_pipeline::{ - prepare_downsampling_pipeline, BloomDownsamplingPipeline, BloomDownsamplingPipelineIds, - BloomUniforms, + BloomDownsamplingPipeline, BloomDownsamplingPipelineIds, BloomUniforms, + prepare_downsampling_pipeline, }; use upsampling_pipeline::{ - prepare_upsampling_pipeline, BloomUpsamplingPipeline, UpsamplingPipelineIds, + BloomUpsamplingPipeline, UpsamplingPipelineIds, prepare_upsampling_pipeline, }; const BLOOM_SHADER_HANDLE: Handle = weak_handle!("c9190ddc-573b-4472-8b21-573cab502b73"); diff --git a/crates/bevy_core_pipeline/src/bloom/settings.rs b/crates/bevy_core_pipeline/src/bloom/settings.rs index 2e22875a35f12..fded0e5f2dcb8 100644 --- a/crates/bevy_core_pipeline/src/bloom/settings.rs +++ b/crates/bevy_core_pipeline/src/bloom/settings.rs @@ -1,7 +1,7 @@ use super::downsampling_pipeline::BloomUniforms; use bevy_ecs::{prelude::Component, query::QueryItem, reflect::ReflectComponent}; use bevy_math::{AspectRatio, URect, UVec4, Vec2, Vec4}; -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; use bevy_render::{extract_component::ExtractComponent, prelude::Camera}; /// Applies a bloom effect to an HDR-enabled 2d or 3d camera. diff --git a/crates/bevy_core_pipeline/src/bloom/upsampling_pipeline.rs b/crates/bevy_core_pipeline/src/bloom/upsampling_pipeline.rs index e4c4ed4a647f9..6992636ea6ed1 100644 --- a/crates/bevy_core_pipeline/src/bloom/upsampling_pipeline.rs +++ b/crates/bevy_core_pipeline/src/bloom/upsampling_pipeline.rs @@ -1,6 +1,6 @@ use super::{ - downsampling_pipeline::BloomUniforms, Bloom, BloomCompositeMode, BLOOM_SHADER_HANDLE, - BLOOM_TEXTURE_FORMAT, + BLOOM_SHADER_HANDLE, BLOOM_TEXTURE_FORMAT, Bloom, BloomCompositeMode, + downsampling_pipeline::BloomUniforms, }; use crate::fullscreen_vertex_shader::fullscreen_shader_vertex_state; use bevy_ecs::{ diff --git a/crates/bevy_core_pipeline/src/contrast_adaptive_sharpening/mod.rs b/crates/bevy_core_pipeline/src/contrast_adaptive_sharpening/mod.rs index 586108469451f..60e4791e65883 100644 --- a/crates/bevy_core_pipeline/src/contrast_adaptive_sharpening/mod.rs +++ b/crates/bevy_core_pipeline/src/contrast_adaptive_sharpening/mod.rs @@ -4,11 +4,12 @@ use crate::{ fullscreen_vertex_shader::fullscreen_shader_vertex_state, }; use bevy_app::prelude::*; -use bevy_asset::{load_internal_asset, weak_handle, Handle}; +use bevy_asset::{Handle, load_internal_asset, weak_handle}; use bevy_ecs::{prelude::*, query::QueryItem}; use bevy_image::BevyDefault as _; -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; use bevy_render::{ + Render, RenderApp, RenderSet, extract_component::{ExtractComponent, ExtractComponentPlugin, UniformComponentPlugin}, prelude::Camera, render_graph::RenderGraphApp, @@ -18,7 +19,6 @@ use bevy_render::{ }, renderer::RenderDevice, view::{ExtractedView, ViewTarget}, - Render, RenderApp, RenderSet, }; mod node; diff --git a/crates/bevy_core_pipeline/src/core_2d/camera_2d.rs b/crates/bevy_core_pipeline/src/core_2d/camera_2d.rs index 9780ddd31f63e..d51aa2f1f9ce9 100644 --- a/crates/bevy_core_pipeline/src/core_2d/camera_2d.rs +++ b/crates/bevy_core_pipeline/src/core_2d/camera_2d.rs @@ -3,7 +3,7 @@ use crate::{ tonemapping::{DebandDither, Tonemapping}, }; use bevy_ecs::prelude::*; -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; use bevy_render::{ camera::{Camera, CameraProjection, CameraRenderGraph, OrthographicProjection, Projection}, extract_component::ExtractComponent, diff --git a/crates/bevy_core_pipeline/src/core_2d/mod.rs b/crates/bevy_core_pipeline/src/core_2d/mod.rs index f32775727772f..7704bebd54799 100644 --- a/crates/bevy_core_pipeline/src/core_2d/mod.rs +++ b/crates/bevy_core_pipeline/src/core_2d/mod.rs @@ -48,13 +48,14 @@ use bevy_app::{App, Plugin}; use bevy_ecs::prelude::*; use bevy_math::FloatOrd; use bevy_render::{ + Extract, ExtractSchedule, Render, RenderApp, RenderSet, camera::{Camera, ExtractedCamera}, extract_component::ExtractComponentPlugin, render_graph::{EmptyNode, RenderGraphApp, ViewNodeRunner}, render_phase::{ - sort_phase_system, BinnedPhaseItem, CachedRenderPipelinePhaseItem, DrawFunctionId, - DrawFunctions, PhaseItem, PhaseItemExtraIndex, SortedPhaseItem, ViewBinnedRenderPhases, - ViewSortedRenderPhases, + BinnedPhaseItem, CachedRenderPipelinePhaseItem, DrawFunctionId, DrawFunctions, PhaseItem, + PhaseItemExtraIndex, SortedPhaseItem, ViewBinnedRenderPhases, ViewSortedRenderPhases, + sort_phase_system, }, render_resource::{ BindGroupId, CachedRenderPipelineId, Extent3d, TextureDescriptor, TextureDimension, @@ -64,7 +65,6 @@ use bevy_render::{ sync_world::MainEntity, texture::TextureCache, view::{Msaa, ViewDepthTexture}, - Extract, ExtractSchedule, Render, RenderApp, RenderSet, }; use self::graph::{Core2d, Node2d}; diff --git a/crates/bevy_core_pipeline/src/core_3d/camera_3d.rs b/crates/bevy_core_pipeline/src/core_3d/camera_3d.rs index 418d3b8d482a3..20fce333acb1b 100644 --- a/crates/bevy_core_pipeline/src/core_3d/camera_3d.rs +++ b/crates/bevy_core_pipeline/src/core_3d/camera_3d.rs @@ -3,7 +3,7 @@ use crate::{ tonemapping::{DebandDither, Tonemapping}, }; use bevy_ecs::prelude::*; -use bevy_reflect::{std_traits::ReflectDefault, Reflect, ReflectDeserialize, ReflectSerialize}; +use bevy_reflect::{Reflect, ReflectDeserialize, ReflectSerialize, std_traits::ReflectDefault}; use bevy_render::{ camera::{Camera, CameraRenderGraph, Exposure, Projection}, extract_component::ExtractComponent, diff --git a/crates/bevy_core_pipeline/src/core_3d/mod.rs b/crates/bevy_core_pipeline/src/core_3d/mod.rs index fa092b7fd494c..f748a729dcb3c 100644 --- a/crates/bevy_core_pipeline/src/core_3d/mod.rs +++ b/crates/bevy_core_pipeline/src/core_3d/mod.rs @@ -74,7 +74,7 @@ use bevy_render::{ experimental::occlusion_culling::OcclusionCulling, mesh::allocator::SlabId, render_phase::PhaseItemBatchSetKey, - view::{prepare_view_targets, NoIndirectDrawing, RetainedViewEntity}, + view::{NoIndirectDrawing, RetainedViewEntity, prepare_view_targets}, }; pub use camera_3d::*; pub use main_opaque_pass_3d_node::*; @@ -88,14 +88,15 @@ use bevy_image::BevyDefault; use bevy_math::FloatOrd; use bevy_platform_support::collections::{HashMap, HashSet}; use bevy_render::{ + Extract, ExtractSchedule, Render, RenderApp, RenderSet, camera::{Camera, ExtractedCamera}, extract_component::ExtractComponentPlugin, prelude::Msaa, render_graph::{EmptyNode, RenderGraphApp, ViewNodeRunner}, render_phase::{ - sort_phase_system, BinnedPhaseItem, CachedRenderPipelinePhaseItem, DrawFunctionId, - DrawFunctions, PhaseItem, PhaseItemExtraIndex, SortedPhaseItem, ViewBinnedRenderPhases, - ViewSortedRenderPhases, + BinnedPhaseItem, CachedRenderPipelinePhaseItem, DrawFunctionId, DrawFunctions, PhaseItem, + PhaseItemExtraIndex, SortedPhaseItem, ViewBinnedRenderPhases, ViewSortedRenderPhases, + sort_phase_system, }, render_resource::{ CachedRenderPipelineId, Extent3d, FilterMode, Sampler, SamplerDescriptor, Texture, @@ -105,7 +106,6 @@ use bevy_render::{ sync_world::{MainEntity, RenderEntity}, texture::{ColorAttachment, TextureCache}, view::{ExtractedView, ViewDepthTexture, ViewTarget}, - Extract, ExtractSchedule, Render, RenderApp, RenderSet, }; use nonmax::NonMaxU32; use tracing::warn; @@ -113,17 +113,17 @@ use tracing::warn; use crate::{ core_3d::main_transmissive_pass_3d_node::MainTransmissivePass3dNode, deferred::{ + AlphaMask3dDeferred, DEFERRED_LIGHTING_PASS_ID_FORMAT, DEFERRED_PREPASS_FORMAT, + Opaque3dDeferred, copy_lighting_id::CopyDeferredLightingIdNode, node::{EarlyDeferredGBufferPrepassNode, LateDeferredGBufferPrepassNode}, - AlphaMask3dDeferred, Opaque3dDeferred, DEFERRED_LIGHTING_PASS_ID_FORMAT, - DEFERRED_PREPASS_FORMAT, }, dof::DepthOfFieldNode, prepass::{ + AlphaMask3dPrepass, DeferredPrepass, DepthPrepass, MOTION_VECTOR_PREPASS_FORMAT, + MotionVectorPrepass, NORMAL_PREPASS_FORMAT, NormalPrepass, Opaque3dPrepass, + OpaqueNoLightmap3dBatchSetKey, OpaqueNoLightmap3dBinKey, ViewPrepassTextures, node::{EarlyPrepassNode, LatePrepassNode}, - AlphaMask3dPrepass, DeferredPrepass, DepthPrepass, MotionVectorPrepass, NormalPrepass, - Opaque3dPrepass, OpaqueNoLightmap3dBatchSetKey, OpaqueNoLightmap3dBinKey, - ViewPrepassTextures, MOTION_VECTOR_PREPASS_FORMAT, NORMAL_PREPASS_FORMAT, }, skybox::SkyboxPlugin, tonemapping::TonemappingNode, diff --git a/crates/bevy_core_pipeline/src/deferred/copy_lighting_id.rs b/crates/bevy_core_pipeline/src/deferred/copy_lighting_id.rs index 966be880c28ce..7df4ed4a027c4 100644 --- a/crates/bevy_core_pipeline/src/deferred/copy_lighting_id.rs +++ b/crates/bevy_core_pipeline/src/deferred/copy_lighting_id.rs @@ -3,16 +3,16 @@ use crate::{ prepass::{DeferredPrepass, ViewPrepassTextures}, }; use bevy_app::prelude::*; -use bevy_asset::{load_internal_asset, weak_handle, Handle}; +use bevy_asset::{Handle, load_internal_asset, weak_handle}; use bevy_ecs::prelude::*; use bevy_math::UVec2; use bevy_render::{ + Render, RenderApp, RenderSet, camera::ExtractedCamera, render_resource::{binding_types::texture_2d, *}, renderer::RenderDevice, texture::{CachedTexture, TextureCache}, view::ViewTarget, - Render, RenderApp, RenderSet, }; use bevy_ecs::query::QueryItem; diff --git a/crates/bevy_core_pipeline/src/dof/mod.rs b/crates/bevy_core_pipeline/src/dof/mod.rs index 028bc97350f56..2e8128704e207 100644 --- a/crates/bevy_core_pipeline/src/dof/mod.rs +++ b/crates/bevy_core_pipeline/src/dof/mod.rs @@ -15,7 +15,7 @@ //! [Depth of field]: https://en.wikipedia.org/wiki/Depth_of_field use bevy_app::{App, Plugin}; -use bevy_asset::{load_internal_asset, weak_handle, Handle}; +use bevy_asset::{Handle, load_internal_asset, weak_handle}; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::{ component::Component, @@ -24,38 +24,38 @@ use bevy_ecs::{ reflect::ReflectComponent, resource::Resource, schedule::IntoSystemConfigs as _, - system::{lifetimeless::Read, Commands, Query, Res, ResMut}, + system::{Commands, Query, Res, ResMut, lifetimeless::Read}, world::{FromWorld, World}, }; use bevy_image::BevyDefault as _; use bevy_math::ops; -use bevy_reflect::{prelude::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, prelude::ReflectDefault}; use bevy_render::{ + Extract, ExtractSchedule, Render, RenderApp, RenderSet, camera::{PhysicalCameraParameters, Projection}, extract_component::{ComponentUniforms, DynamicUniformIndex, UniformComponentPlugin}, render_graph::{ NodeRunError, RenderGraphApp as _, RenderGraphContext, ViewNode, ViewNodeRunner, }, render_resource::{ - binding_types::{ - sampler, texture_2d, texture_depth_2d, texture_depth_2d_multisampled, uniform_buffer, - }, BindGroup, BindGroupEntries, BindGroupLayout, BindGroupLayoutEntries, CachedRenderPipelineId, ColorTargetState, ColorWrites, FilterMode, FragmentState, LoadOp, Operations, PipelineCache, RenderPassColorAttachment, RenderPassDescriptor, RenderPipelineDescriptor, Sampler, SamplerBindingType, SamplerDescriptor, Shader, ShaderStages, ShaderType, SpecializedRenderPipeline, SpecializedRenderPipelines, StoreOp, TextureDescriptor, TextureDimension, TextureFormat, TextureSampleType, TextureUsages, + binding_types::{ + sampler, texture_2d, texture_depth_2d, texture_depth_2d_multisampled, uniform_buffer, + }, }, renderer::{RenderContext, RenderDevice}, sync_component::SyncComponentPlugin, sync_world::RenderEntity, texture::{CachedTexture, TextureCache}, view::{ - prepare_view_targets, ExtractedView, Msaa, ViewDepthTexture, ViewTarget, ViewUniform, - ViewUniformOffset, ViewUniforms, + ExtractedView, Msaa, ViewDepthTexture, ViewTarget, ViewUniform, ViewUniformOffset, + ViewUniforms, prepare_view_targets, }, - Extract, ExtractSchedule, Render, RenderApp, RenderSet, }; use bevy_utils::{default, once}; use smallvec::SmallVec; @@ -63,8 +63,8 @@ use tracing::{info, warn}; use crate::{ core_3d::{ - graph::{Core3d, Node3d}, Camera3d, DEPTH_TEXTURE_SAMPLING_SUPPORTED, + graph::{Core3d, Node3d}, }, fullscreen_vertex_shader::fullscreen_shader_vertex_state, }; diff --git a/crates/bevy_core_pipeline/src/experimental/mip_generation/mod.rs b/crates/bevy_core_pipeline/src/experimental/mip_generation/mod.rs index f324193983f3c..642c8b1b1fd9f 100644 --- a/crates/bevy_core_pipeline/src/experimental/mip_generation/mod.rs +++ b/crates/bevy_core_pipeline/src/experimental/mip_generation/mod.rs @@ -8,26 +8,26 @@ use core::array; use bevy_app::{App, Plugin}; -use bevy_asset::{load_internal_asset, weak_handle, Handle}; +use bevy_asset::{Handle, load_internal_asset, weak_handle}; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::{ component::Component, entity::Entity, - prelude::{resource_exists, Without}, + prelude::{Without, resource_exists}, query::{Or, QueryState, With}, resource::Resource, schedule::IntoSystemConfigs as _, - system::{lifetimeless::Read, Commands, Local, Query, Res, ResMut}, + system::{Commands, Local, Query, Res, ResMut, lifetimeless::Read}, world::{FromWorld, World}, }; -use bevy_math::{uvec2, UVec2, Vec4Swizzles as _}; +use bevy_math::{UVec2, Vec4Swizzles as _, uvec2}; use bevy_render::{ + Render, RenderApp, RenderSet, experimental::occlusion_culling::{ OcclusionCulling, OcclusionCullingSubview, OcclusionCullingSubviewEntities, }, render_graph::{Node, NodeRunError, RenderGraphApp, RenderGraphContext}, render_resource::{ - binding_types::{sampler, texture_2d, texture_2d_multisampled, texture_storage_2d}, BindGroup, BindGroupEntries, BindGroupLayout, BindGroupLayoutEntries, CachedComputePipelineId, ComputePassDescriptor, ComputePipeline, ComputePipelineDescriptor, DownlevelFlags, Extent3d, IntoBinding, PipelineCache, PushConstantRange, Sampler, @@ -35,11 +35,11 @@ use bevy_render::{ SpecializedComputePipelines, StorageTextureAccess, TextureAspect, TextureDescriptor, TextureDimension, TextureFormat, TextureSampleType, TextureUsages, TextureView, TextureViewDescriptor, TextureViewDimension, + binding_types::{sampler, texture_2d, texture_2d_multisampled, texture_storage_2d}, }, renderer::{RenderAdapter, RenderContext, RenderDevice}, texture::TextureCache, view::{ExtractedView, NoIndirectDrawing, ViewDepthTexture}, - Render, RenderApp, RenderSet, }; use bitflags::bitflags; diff --git a/crates/bevy_core_pipeline/src/fullscreen_vertex_shader/mod.rs b/crates/bevy_core_pipeline/src/fullscreen_vertex_shader/mod.rs index fee17d1ec6412..80bfc9de1b37e 100644 --- a/crates/bevy_core_pipeline/src/fullscreen_vertex_shader/mod.rs +++ b/crates/bevy_core_pipeline/src/fullscreen_vertex_shader/mod.rs @@ -1,4 +1,4 @@ -use bevy_asset::{weak_handle, Handle}; +use bevy_asset::{Handle, weak_handle}; use bevy_render::{prelude::Shader, render_resource::VertexState}; pub const FULLSCREEN_SHADER_HANDLE: Handle = diff --git a/crates/bevy_core_pipeline/src/fxaa/mod.rs b/crates/bevy_core_pipeline/src/fxaa/mod.rs index b8904bb1f9ffc..86c36d9f96e7d 100644 --- a/crates/bevy_core_pipeline/src/fxaa/mod.rs +++ b/crates/bevy_core_pipeline/src/fxaa/mod.rs @@ -4,11 +4,12 @@ use crate::{ fullscreen_vertex_shader::fullscreen_shader_vertex_state, }; use bevy_app::prelude::*; -use bevy_asset::{load_internal_asset, weak_handle, Handle}; +use bevy_asset::{Handle, load_internal_asset, weak_handle}; use bevy_ecs::prelude::*; use bevy_image::BevyDefault as _; -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; use bevy_render::{ + Render, RenderApp, RenderSet, extract_component::{ExtractComponent, ExtractComponentPlugin}, prelude::Camera, render_graph::{RenderGraphApp, ViewNodeRunner}, @@ -18,7 +19,6 @@ use bevy_render::{ }, renderer::RenderDevice, view::{ExtractedView, ViewTarget}, - Render, RenderApp, RenderSet, }; use bevy_utils::default; diff --git a/crates/bevy_core_pipeline/src/motion_blur/mod.rs b/crates/bevy_core_pipeline/src/motion_blur/mod.rs index 7703698f1ab10..962c3ae57e0f6 100644 --- a/crates/bevy_core_pipeline/src/motion_blur/mod.rs +++ b/crates/bevy_core_pipeline/src/motion_blur/mod.rs @@ -7,20 +7,20 @@ use crate::{ prepass::{DepthPrepass, MotionVectorPrepass}, }; use bevy_app::{App, Plugin}; -use bevy_asset::{load_internal_asset, weak_handle, Handle}; +use bevy_asset::{Handle, load_internal_asset, weak_handle}; use bevy_ecs::{ - component::{require, Component}, + component::{Component, require}, query::With, reflect::ReflectComponent, schedule::IntoSystemConfigs, }; -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; use bevy_render::{ + Render, RenderApp, RenderSet, camera::Camera, extract_component::{ExtractComponent, ExtractComponentPlugin, UniformComponentPlugin}, render_graph::{RenderGraphApp, ViewNodeRunner}, render_resource::{Shader, ShaderType, SpecializedRenderPipelines}, - Render, RenderApp, RenderSet, }; pub mod node; diff --git a/crates/bevy_core_pipeline/src/motion_blur/node.rs b/crates/bevy_core_pipeline/src/motion_blur/node.rs index 2497bd633deda..ca0de254cbccf 100644 --- a/crates/bevy_core_pipeline/src/motion_blur/node.rs +++ b/crates/bevy_core_pipeline/src/motion_blur/node.rs @@ -14,8 +14,8 @@ use bevy_render::{ use crate::prepass::ViewPrepassTextures; use super::{ - pipeline::{MotionBlurPipeline, MotionBlurPipelineId}, MotionBlur, + pipeline::{MotionBlurPipeline, MotionBlurPipelineId}, }; #[derive(Default)] diff --git a/crates/bevy_core_pipeline/src/motion_blur/pipeline.rs b/crates/bevy_core_pipeline/src/motion_blur/pipeline.rs index 61bb7b60ce42e..f92d054d0d986 100644 --- a/crates/bevy_core_pipeline/src/motion_blur/pipeline.rs +++ b/crates/bevy_core_pipeline/src/motion_blur/pipeline.rs @@ -10,15 +10,15 @@ use bevy_image::BevyDefault as _; use bevy_render::{ globals::GlobalsUniform, render_resource::{ - binding_types::{ - sampler, texture_2d, texture_2d_multisampled, texture_depth_2d, - texture_depth_2d_multisampled, uniform_buffer_sized, - }, BindGroupLayout, BindGroupLayoutEntries, CachedRenderPipelineId, ColorTargetState, ColorWrites, FragmentState, MultisampleState, PipelineCache, PrimitiveState, RenderPipelineDescriptor, Sampler, SamplerBindingType, SamplerDescriptor, ShaderDefVal, ShaderStages, ShaderType, SpecializedRenderPipeline, SpecializedRenderPipelines, TextureFormat, TextureSampleType, + binding_types::{ + sampler, texture_2d, texture_2d_multisampled, texture_depth_2d, + texture_depth_2d_multisampled, uniform_buffer_sized, + }, }, renderer::RenderDevice, view::{ExtractedView, Msaa, ViewTarget}, @@ -26,7 +26,7 @@ use bevy_render::{ use crate::fullscreen_vertex_shader::fullscreen_shader_vertex_state; -use super::{MotionBlur, MOTION_BLUR_SHADER_HANDLE}; +use super::{MOTION_BLUR_SHADER_HANDLE, MotionBlur}; #[derive(Resource)] pub struct MotionBlurPipeline { diff --git a/crates/bevy_core_pipeline/src/msaa_writeback.rs b/crates/bevy_core_pipeline/src/msaa_writeback.rs index f9c543aeff03c..403ec3cfd4b42 100644 --- a/crates/bevy_core_pipeline/src/msaa_writeback.rs +++ b/crates/bevy_core_pipeline/src/msaa_writeback.rs @@ -7,12 +7,12 @@ use bevy_app::{App, Plugin}; use bevy_color::LinearRgba; use bevy_ecs::{prelude::*, query::QueryItem}; use bevy_render::{ + Render, RenderApp, RenderSet, camera::ExtractedCamera, render_graph::{NodeRunError, RenderGraphApp, RenderGraphContext, ViewNode, ViewNodeRunner}, render_resource::*, renderer::RenderContext, view::{Msaa, ViewTarget}, - Render, RenderApp, RenderSet, }; /// This enables "msaa writeback" support for the `core_2d` and `core_3d` pipelines, which can be enabled on cameras diff --git a/crates/bevy_core_pipeline/src/oit/mod.rs b/crates/bevy_core_pipeline/src/oit/mod.rs index 63083f5ed7f77..3d17673d0c7c6 100644 --- a/crates/bevy_core_pipeline/src/oit/mod.rs +++ b/crates/bevy_core_pipeline/src/oit/mod.rs @@ -1,13 +1,14 @@ //! Order Independent Transparency (OIT) for 3d rendering. See [`OrderIndependentTransparencyPlugin`] for more details. use bevy_app::prelude::*; -use bevy_asset::{load_internal_asset, weak_handle, Handle}; +use bevy_asset::{Handle, load_internal_asset, weak_handle}; use bevy_ecs::{component::*, prelude::*}; use bevy_math::UVec2; use bevy_platform_support::collections::HashSet; use bevy_platform_support::time::Instant; use bevy_reflect::Reflect; use bevy_render::{ + Render, RenderApp, RenderSet, camera::{Camera, ExtractedCamera}, extract_component::{ExtractComponent, ExtractComponentPlugin}, render_graph::{RenderGraphApp, ViewNodeRunner}, @@ -16,18 +17,17 @@ use bevy_render::{ }, renderer::{RenderDevice, RenderQueue}, view::Msaa, - Render, RenderApp, RenderSet, }; use bevy_window::PrimaryWindow; use resolve::{ - node::{OitResolveNode, OitResolvePass}, OitResolvePlugin, + node::{OitResolveNode, OitResolvePass}, }; use tracing::{trace, warn}; use crate::core_3d::{ - graph::{Core3d, Node3d}, Camera3d, + graph::{Core3d, Node3d}, }; /// Module that defines the necessary systems to resolve the OIT buffer and render it to the screen. @@ -74,8 +74,12 @@ impl Component for OrderIndependentTransparencySettings { Some(|world, context| { if let Some(value) = world.get::(context.entity) { if value.layer_count > 32 { - warn!("{}OrderIndependentTransparencySettings layer_count set to {} might be too high.", - context.caller.map(|location|format!("{location}: ")).unwrap_or_default(), + warn!( + "{}OrderIndependentTransparencySettings layer_count set to {} might be too high.", + context + .caller + .map(|location| format!("{location}: ")) + .unwrap_or_default(), value.layer_count ); } diff --git a/crates/bevy_core_pipeline/src/oit/resolve/mod.rs b/crates/bevy_core_pipeline/src/oit/resolve/mod.rs index f73192b19dec9..5b27c169c782d 100644 --- a/crates/bevy_core_pipeline/src/oit/resolve/mod.rs +++ b/crates/bevy_core_pipeline/src/oit/resolve/mod.rs @@ -3,7 +3,7 @@ use crate::{ oit::OrderIndependentTransparencySettings, }; use bevy_app::Plugin; -use bevy_asset::{load_internal_asset, weak_handle, Handle}; +use bevy_asset::{Handle, load_internal_asset, weak_handle}; use bevy_derive::Deref; use bevy_ecs::{ entity::{hash_map::EntityHashMap, hash_set::EntityHashSet}, @@ -11,16 +11,16 @@ use bevy_ecs::{ }; use bevy_image::BevyDefault as _; use bevy_render::{ + Render, RenderApp, RenderSet, render_resource::{ - binding_types::{storage_buffer_sized, texture_depth_2d, uniform_buffer}, BindGroup, BindGroupEntries, BindGroupLayout, BindGroupLayoutEntries, BlendComponent, BlendState, CachedRenderPipelineId, ColorTargetState, ColorWrites, DownlevelFlags, FragmentState, MultisampleState, PipelineCache, PrimitiveState, RenderPipelineDescriptor, Shader, ShaderDefVal, ShaderStages, TextureFormat, + binding_types::{storage_buffer_sized, texture_depth_2d, uniform_buffer}, }, renderer::{RenderAdapter, RenderDevice}, view::{ExtractedView, ViewTarget, ViewUniform, ViewUniforms}, - Render, RenderApp, RenderSet, }; use tracing::warn; @@ -57,7 +57,9 @@ impl Plugin for OitResolvePlugin { .flags .contains(DownlevelFlags::FRAGMENT_WRITABLE_STORAGE) { - warn!("OrderIndependentTransparencyPlugin not loaded. GPU lacks support: DownlevelFlags::FRAGMENT_WRITABLE_STORAGE."); + warn!( + "OrderIndependentTransparencyPlugin not loaded. GPU lacks support: DownlevelFlags::FRAGMENT_WRITABLE_STORAGE." + ); return; } diff --git a/crates/bevy_core_pipeline/src/post_process/mod.rs b/crates/bevy_core_pipeline/src/post_process/mod.rs index c8b1da4497363..5721873854eda 100644 --- a/crates/bevy_core_pipeline/src/post_process/mod.rs +++ b/crates/bevy_core_pipeline/src/post_process/mod.rs @@ -3,7 +3,7 @@ //! Currently, this consists only of chromatic aberration. use bevy_app::{App, Plugin}; -use bevy_asset::{load_internal_asset, weak_handle, Assets, Handle}; +use bevy_asset::{Assets, Handle, load_internal_asset, weak_handle}; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::{ component::Component, @@ -12,12 +12,13 @@ use bevy_ecs::{ reflect::ReflectComponent, resource::Resource, schedule::IntoSystemConfigs as _, - system::{lifetimeless::Read, Commands, Query, Res, ResMut}, + system::{Commands, Query, Res, ResMut, lifetimeless::Read}, world::{FromWorld, World}, }; use bevy_image::{BevyDefault, Image}; -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; use bevy_render::{ + Render, RenderApp, RenderSet, camera::Camera, extract_component::{ExtractComponent, ExtractComponentPlugin}, render_asset::{RenderAssetUsages, RenderAssets}, @@ -25,18 +26,17 @@ use bevy_render::{ NodeRunError, RenderGraphApp as _, RenderGraphContext, ViewNode, ViewNodeRunner, }, render_resource::{ - binding_types::{sampler, texture_2d, uniform_buffer}, BindGroupEntries, BindGroupLayout, BindGroupLayoutEntries, CachedRenderPipelineId, ColorTargetState, ColorWrites, DynamicUniformBuffer, Extent3d, FilterMode, FragmentState, Operations, PipelineCache, RenderPassColorAttachment, RenderPassDescriptor, RenderPipelineDescriptor, Sampler, SamplerBindingType, SamplerDescriptor, Shader, ShaderStages, ShaderType, SpecializedRenderPipeline, SpecializedRenderPipelines, TextureDimension, TextureFormat, TextureSampleType, + binding_types::{sampler, texture_2d, uniform_buffer}, }, renderer::{RenderContext, RenderDevice, RenderQueue}, texture::GpuImage, view::{ExtractedView, ViewTarget}, - Render, RenderApp, RenderSet, }; use bevy_utils::prelude::default; diff --git a/crates/bevy_core_pipeline/src/prepass/mod.rs b/crates/bevy_core_pipeline/src/prepass/mod.rs index 1e663a79a48b6..db4b486b9837c 100644 --- a/crates/bevy_core_pipeline/src/prepass/mod.rs +++ b/crates/bevy_core_pipeline/src/prepass/mod.rs @@ -33,7 +33,7 @@ use crate::deferred::{DEFERRED_LIGHTING_PASS_ID_FORMAT, DEFERRED_PREPASS_FORMAT} use bevy_asset::UntypedAssetId; use bevy_ecs::prelude::*; use bevy_math::Mat4; -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; use bevy_render::mesh::allocator::SlabId; use bevy_render::render_phase::PhaseItemBatchSetKey; use bevy_render::sync_world::MainEntity; diff --git a/crates/bevy_core_pipeline/src/skybox/mod.rs b/crates/bevy_core_pipeline/src/skybox/mod.rs index 6e1a8422768a8..8e92cd559c2f6 100644 --- a/crates/bevy_core_pipeline/src/skybox/mod.rs +++ b/crates/bevy_core_pipeline/src/skybox/mod.rs @@ -1,5 +1,5 @@ use bevy_app::{App, Plugin}; -use bevy_asset::{load_internal_asset, weak_handle, Handle}; +use bevy_asset::{Handle, load_internal_asset, weak_handle}; use bevy_ecs::{ prelude::{Component, Entity}, query::{QueryItem, With}, @@ -10,8 +10,9 @@ use bevy_ecs::{ }; use bevy_image::{BevyDefault, Image}; use bevy_math::{Mat4, Quat}; -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; use bevy_render::{ + Render, RenderApp, RenderSet, camera::Exposure, extract_component::{ ComponentUniforms, DynamicUniformIndex, ExtractComponent, ExtractComponentPlugin, @@ -25,10 +26,9 @@ use bevy_render::{ renderer::RenderDevice, texture::GpuImage, view::{ExtractedView, Msaa, ViewTarget, ViewUniform, ViewUniforms}, - Render, RenderApp, RenderSet, }; use bevy_transform::components::Transform; -use prepass::{SkyboxPrepassPipeline, SKYBOX_PREPASS_SHADER_HANDLE}; +use prepass::{SKYBOX_PREPASS_SHADER_HANDLE, SkyboxPrepassPipeline}; use crate::{core_3d::CORE_3D_DEPTH_FORMAT, prepass::PreviousViewUniforms}; diff --git a/crates/bevy_core_pipeline/src/skybox/prepass.rs b/crates/bevy_core_pipeline/src/skybox/prepass.rs index 658660bbc62ff..88037e3b5115b 100644 --- a/crates/bevy_core_pipeline/src/skybox/prepass.rs +++ b/crates/bevy_core_pipeline/src/skybox/prepass.rs @@ -1,6 +1,6 @@ //! Adds motion vector support to skyboxes. See [`SkyboxPrepassPipeline`] for details. -use bevy_asset::{weak_handle, Handle}; +use bevy_asset::{Handle, weak_handle}; use bevy_ecs::{ component::Component, entity::Entity, @@ -11,10 +11,10 @@ use bevy_ecs::{ }; use bevy_render::{ render_resource::{ - binding_types::uniform_buffer, BindGroup, BindGroupEntries, BindGroupLayout, - BindGroupLayoutEntries, CachedRenderPipelineId, CompareFunction, DepthStencilState, - FragmentState, MultisampleState, PipelineCache, RenderPipelineDescriptor, Shader, - ShaderStages, SpecializedRenderPipeline, SpecializedRenderPipelines, + BindGroup, BindGroupEntries, BindGroupLayout, BindGroupLayoutEntries, + CachedRenderPipelineId, CompareFunction, DepthStencilState, FragmentState, + MultisampleState, PipelineCache, RenderPipelineDescriptor, Shader, ShaderStages, + SpecializedRenderPipeline, SpecializedRenderPipelines, binding_types::uniform_buffer, }, renderer::RenderDevice, view::{Msaa, ViewUniform, ViewUniforms}, @@ -22,12 +22,12 @@ use bevy_render::{ use bevy_utils::prelude::default; use crate::{ + Skybox, core_3d::CORE_3D_DEPTH_FORMAT, prepass::{ - prepass_target_descriptors, MotionVectorPrepass, NormalPrepass, PreviousViewData, - PreviousViewUniforms, + MotionVectorPrepass, NormalPrepass, PreviousViewData, PreviousViewUniforms, + prepass_target_descriptors, }, - Skybox, }; pub const SKYBOX_PREPASS_SHADER_HANDLE: Handle = diff --git a/crates/bevy_core_pipeline/src/smaa/mod.rs b/crates/bevy_core_pipeline/src/smaa/mod.rs index fb066a3ce538c..c708e124ef170 100644 --- a/crates/bevy_core_pipeline/src/smaa/mod.rs +++ b/crates/bevy_core_pipeline/src/smaa/mod.rs @@ -38,7 +38,7 @@ use crate::{ use bevy_app::{App, Plugin}; #[cfg(feature = "smaa_luts")] use bevy_asset::load_internal_binary_asset; -use bevy_asset::{load_internal_asset, weak_handle, Handle}; +use bevy_asset::{Handle, load_internal_asset, weak_handle}; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::{ component::Component, @@ -47,13 +47,14 @@ use bevy_ecs::{ reflect::ReflectComponent, resource::Resource, schedule::IntoSystemConfigs as _, - system::{lifetimeless::Read, Commands, Query, Res, ResMut}, + system::{Commands, Query, Res, ResMut, lifetimeless::Read}, world::{FromWorld, World}, }; use bevy_image::{BevyDefault, Image}; -use bevy_math::{vec4, Vec4}; -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_math::{Vec4, vec4}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; use bevy_render::{ + Render, RenderApp, RenderSet, camera::ExtractedCamera, extract_component::{ExtractComponent, ExtractComponentPlugin}, render_asset::RenderAssets, @@ -61,7 +62,6 @@ use bevy_render::{ NodeRunError, RenderGraphApp as _, RenderGraphContext, ViewNode, ViewNodeRunner, }, render_resource::{ - binding_types::{sampler, texture_2d, uniform_buffer}, AddressMode, BindGroup, BindGroupEntries, BindGroupLayout, BindGroupLayoutEntries, CachedRenderPipelineId, ColorTargetState, ColorWrites, CompareFunction, DepthStencilState, DynamicUniformBuffer, Extent3d, FilterMode, FragmentState, LoadOp, MultisampleState, @@ -72,11 +72,11 @@ use bevy_render::{ StencilFaceState, StencilOperation, StencilState, StoreOp, TextureDescriptor, TextureDimension, TextureFormat, TextureSampleType, TextureUsages, TextureView, VertexState, + binding_types::{sampler, texture_2d, uniform_buffer}, }, renderer::{RenderContext, RenderDevice, RenderQueue}, texture::{CachedTexture, GpuImage, TextureCache}, view::{ExtractedView, ViewTarget}, - Render, RenderApp, RenderSet, }; use bevy_utils::prelude::default; diff --git a/crates/bevy_core_pipeline/src/taa/mod.rs b/crates/bevy_core_pipeline/src/taa/mod.rs index 55eb25ae02ebf..c672b156007f3 100644 --- a/crates/bevy_core_pipeline/src/taa/mod.rs +++ b/crates/bevy_core_pipeline/src/taa/mod.rs @@ -5,10 +5,10 @@ use crate::{ prepass::{DepthPrepass, MotionVectorPrepass, ViewPrepassTextures}, }; use bevy_app::{App, Plugin}; -use bevy_asset::{load_internal_asset, weak_handle, Handle}; +use bevy_asset::{Handle, load_internal_asset, weak_handle}; use bevy_diagnostic::FrameCount; use bevy_ecs::{ - prelude::{require, Component, Entity, ReflectComponent}, + prelude::{Component, Entity, ReflectComponent, require}, query::{QueryItem, With}, resource::Resource, schedule::IntoSystemConfigs, @@ -17,26 +17,26 @@ use bevy_ecs::{ }; use bevy_image::BevyDefault as _; use bevy_math::vec2; -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; use bevy_render::{ + ExtractSchedule, MainWorld, Render, RenderApp, RenderSet, camera::{ExtractedCamera, MipBias, TemporalJitter}, prelude::{Camera, Projection}, render_graph::{NodeRunError, RenderGraphApp, RenderGraphContext, ViewNode, ViewNodeRunner}, render_resource::{ - binding_types::{sampler, texture_2d, texture_depth_2d}, BindGroupEntries, BindGroupLayout, BindGroupLayoutEntries, CachedRenderPipelineId, ColorTargetState, ColorWrites, Extent3d, FilterMode, FragmentState, MultisampleState, Operations, PipelineCache, PrimitiveState, RenderPassColorAttachment, RenderPassDescriptor, RenderPipelineDescriptor, Sampler, SamplerBindingType, SamplerDescriptor, Shader, ShaderStages, SpecializedRenderPipeline, SpecializedRenderPipelines, TextureDescriptor, TextureDimension, TextureFormat, TextureSampleType, TextureUsages, + binding_types::{sampler, texture_2d, texture_depth_2d}, }, renderer::{RenderContext, RenderDevice}, sync_component::SyncComponentPlugin, sync_world::RenderEntity, texture::{CachedTexture, TextureCache}, view::{ExtractedView, Msaa, ViewTarget}, - ExtractSchedule, MainWorld, Render, RenderApp, RenderSet, }; use tracing::warn; diff --git a/crates/bevy_core_pipeline/src/tonemapping/mod.rs b/crates/bevy_core_pipeline/src/tonemapping/mod.rs index 443b81327a8e6..9b90e0761180e 100644 --- a/crates/bevy_core_pipeline/src/tonemapping/mod.rs +++ b/crates/bevy_core_pipeline/src/tonemapping/mod.rs @@ -1,10 +1,11 @@ use crate::fullscreen_vertex_shader::fullscreen_shader_vertex_state; use bevy_app::prelude::*; -use bevy_asset::{load_internal_asset, weak_handle, Assets, Handle}; +use bevy_asset::{Assets, Handle, load_internal_asset, weak_handle}; use bevy_ecs::prelude::*; use bevy_image::{CompressedImageFormats, Image, ImageSampler, ImageType}; -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; use bevy_render::{ + Render, RenderApp, RenderSet, camera::Camera, extract_component::{ExtractComponent, ExtractComponentPlugin}, extract_resource::{ExtractResource, ExtractResourcePlugin}, @@ -16,7 +17,6 @@ use bevy_render::{ renderer::RenderDevice, texture::{FallbackImage, GpuImage}, view::{ExtractedView, ViewTarget, ViewUniform}, - Render, RenderApp, RenderSet, }; use bitflags::bitflags; #[cfg(not(feature = "tonemapping_luts"))] diff --git a/crates/bevy_core_pipeline/src/tonemapping/node.rs b/crates/bevy_core_pipeline/src/tonemapping/node.rs index 0f8f6edc49eb2..ca88dfc610814 100644 --- a/crates/bevy_core_pipeline/src/tonemapping/node.rs +++ b/crates/bevy_core_pipeline/src/tonemapping/node.rs @@ -15,7 +15,7 @@ use bevy_render::{ view::{ViewTarget, ViewUniformOffset, ViewUniforms}, }; -use super::{get_lut_bindings, Tonemapping}; +use super::{Tonemapping, get_lut_bindings}; #[derive(Default)] pub struct TonemappingNode { diff --git a/crates/bevy_core_pipeline/src/upscaling/mod.rs b/crates/bevy_core_pipeline/src/upscaling/mod.rs index 89f3f8d09e44a..f57551c71656f 100644 --- a/crates/bevy_core_pipeline/src/upscaling/mod.rs +++ b/crates/bevy_core_pipeline/src/upscaling/mod.rs @@ -3,10 +3,10 @@ use bevy_app::prelude::*; use bevy_ecs::prelude::*; use bevy_platform_support::collections::HashSet; use bevy_render::{ + Render, RenderApp, RenderSet, camera::{CameraOutputMode, ExtractedCamera}, render_resource::*, view::ViewTarget, - Render, RenderApp, RenderSet, }; mod node; diff --git a/crates/bevy_derive/src/bevy_main.rs b/crates/bevy_derive/src/bevy_main.rs index 8111a31338b56..9af4f54bdc8a8 100644 --- a/crates/bevy_derive/src/bevy_main.rs +++ b/crates/bevy_derive/src/bevy_main.rs @@ -1,6 +1,6 @@ use proc_macro::TokenStream; use quote::quote; -use syn::{parse_macro_input, ItemFn}; +use syn::{ItemFn, parse_macro_input}; pub fn bevy_main(_attr: TokenStream, item: TokenStream) -> TokenStream { let input = parse_macro_input!(item as ItemFn); diff --git a/crates/bevy_derive/src/derefs.rs b/crates/bevy_derive/src/derefs.rs index 0dd3b152bfda5..d5e1c3a2ded30 100644 --- a/crates/bevy_derive/src/derefs.rs +++ b/crates/bevy_derive/src/derefs.rs @@ -1,6 +1,6 @@ use proc_macro::{Span, TokenStream}; use quote::quote; -use syn::{parse_macro_input, Data, DeriveInput, Field, Index, Member, Type}; +use syn::{Data, DeriveInput, Field, Index, Member, Type, parse_macro_input}; const DEREF: &str = "Deref"; const DEREF_MUT: &str = "DerefMut"; @@ -93,7 +93,9 @@ fn get_deref_field(ast: &DeriveInput, is_mut: bool) -> syn::Result<(Member, &Typ } else { Err(syn::Error::new( Span::call_site().into(), - format!("deriving {deref_kind} on multi-field structs requires one field to have the {deref_attr_str} attribute"), + format!( + "deriving {deref_kind} on multi-field structs requires one field to have the {deref_attr_str} attribute" + ), )) } } diff --git a/crates/bevy_derive/src/enum_variant_meta.rs b/crates/bevy_derive/src/enum_variant_meta.rs index afe400b09ab29..9d7eee4ff6286 100644 --- a/crates/bevy_derive/src/enum_variant_meta.rs +++ b/crates/bevy_derive/src/enum_variant_meta.rs @@ -1,6 +1,6 @@ use proc_macro::{Span, TokenStream}; use quote::quote; -use syn::{parse_macro_input, Data, DeriveInput}; +use syn::{Data, DeriveInput, parse_macro_input}; pub fn derive_enum_variant_meta(input: TokenStream) -> TokenStream { let ast = parse_macro_input!(input as DeriveInput); @@ -9,7 +9,7 @@ pub fn derive_enum_variant_meta(input: TokenStream) -> TokenStream { _ => { return syn::Error::new(Span::call_site().into(), "Only enums are supported") .into_compile_error() - .into() + .into(); } }; diff --git a/crates/bevy_derive/src/lib.rs b/crates/bevy_derive/src/lib.rs index 2636ffc57d13f..46960bc9740dd 100644 --- a/crates/bevy_derive/src/lib.rs +++ b/crates/bevy_derive/src/lib.rs @@ -12,7 +12,7 @@ mod bevy_main; mod derefs; mod enum_variant_meta; -use bevy_macro_utils::{derive_label, BevyManifest}; +use bevy_macro_utils::{BevyManifest, derive_label}; use proc_macro::TokenStream; use quote::format_ident; diff --git a/crates/bevy_dev_tools/src/ci_testing/systems.rs b/crates/bevy_dev_tools/src/ci_testing/systems.rs index f9570133c0bba..068e62711571a 100644 --- a/crates/bevy_dev_tools/src/ci_testing/systems.rs +++ b/crates/bevy_dev_tools/src/ci_testing/systems.rs @@ -1,7 +1,7 @@ use super::config::*; use bevy_app::AppExit; use bevy_ecs::prelude::*; -use bevy_render::view::screenshot::{save_to_disk, Screenshot}; +use bevy_render::view::screenshot::{Screenshot, save_to_disk}; use tracing::{debug, info}; pub(crate) fn send_events(world: &mut World, mut current_frame: Local) { diff --git a/crates/bevy_dev_tools/src/fps_overlay.rs b/crates/bevy_dev_tools/src/fps_overlay.rs index 358a7f20455ed..4c2e292973e07 100644 --- a/crates/bevy_dev_tools/src/fps_overlay.rs +++ b/crates/bevy_dev_tools/src/fps_overlay.rs @@ -11,15 +11,15 @@ use bevy_ecs::{ prelude::Local, query::With, resource::Resource, - schedule::{common_conditions::resource_changed, IntoSystemConfigs}, + schedule::{IntoSystemConfigs, common_conditions::resource_changed}, system::{Commands, Query, Res}, }; use bevy_render::view::Visibility; use bevy_text::{Font, TextColor, TextFont, TextSpan}; use bevy_time::Time; use bevy_ui::{ - widget::{Text, TextUiWriter}, GlobalZIndex, Node, PositionType, + widget::{Text, TextUiWriter}, }; use core::time::Duration; diff --git a/crates/bevy_dev_tools/src/picking_debug.rs b/crates/bevy_dev_tools/src/picking_debug.rs index 37defb557811a..fbf7e6baef541 100644 --- a/crates/bevy_dev_tools/src/picking_debug.rs +++ b/crates/bevy_dev_tools/src/picking_debug.rs @@ -8,7 +8,7 @@ use bevy_picking::backend::HitData; use bevy_picking::hover::HoverMap; use bevy_picking::pointer::{Location, PointerId, PointerPress}; use bevy_picking::prelude::*; -use bevy_picking::{pointer, PickSet}; +use bevy_picking::{PickSet, pointer}; use bevy_reflect::prelude::*; use bevy_render::prelude::*; use bevy_text::prelude::*; diff --git a/crates/bevy_diagnostic/src/frame_count_diagnostics_plugin.rs b/crates/bevy_diagnostic/src/frame_count_diagnostics_plugin.rs index 12a45ddd00251..23c8b9c06425c 100644 --- a/crates/bevy_diagnostic/src/frame_count_diagnostics_plugin.rs +++ b/crates/bevy_diagnostic/src/frame_count_diagnostics_plugin.rs @@ -3,8 +3,8 @@ use bevy_ecs::prelude::*; #[cfg(feature = "serialize")] use serde::{ - de::{Error, Visitor}, Deserialize, Deserializer, Serialize, Serializer, + de::{Error, Visitor}, }; /// Maintains a count of frames rendered since the start of the application. @@ -91,7 +91,7 @@ mod tests { mod serde_tests { use super::*; - use serde_test::{assert_tokens, Token}; + use serde_test::{Token, assert_tokens}; #[test] fn test_serde_frame_count() { diff --git a/crates/bevy_diagnostic/src/frame_time_diagnostics_plugin.rs b/crates/bevy_diagnostic/src/frame_time_diagnostics_plugin.rs index 22b6176fa2856..016c7e7c0cc07 100644 --- a/crates/bevy_diagnostic/src/frame_time_diagnostics_plugin.rs +++ b/crates/bevy_diagnostic/src/frame_time_diagnostics_plugin.rs @@ -1,6 +1,6 @@ use crate::{ - Diagnostic, DiagnosticPath, Diagnostics, FrameCount, RegisterDiagnostic, - DEFAULT_MAX_HISTORY_LENGTH, + DEFAULT_MAX_HISTORY_LENGTH, Diagnostic, DiagnosticPath, Diagnostics, FrameCount, + RegisterDiagnostic, }; use bevy_app::prelude::*; use bevy_ecs::prelude::*; diff --git a/crates/bevy_diagnostic/src/lib.rs b/crates/bevy_diagnostic/src/lib.rs index e5098d6c6f46c..17500ea528cff 100644 --- a/crates/bevy_diagnostic/src/lib.rs +++ b/crates/bevy_diagnostic/src/lib.rs @@ -27,7 +27,7 @@ mod system_information_diagnostics_plugin; pub use diagnostic::*; pub use entity_count_diagnostics_plugin::EntityCountDiagnosticsPlugin; -pub use frame_count_diagnostics_plugin::{update_frame_count, FrameCount, FrameCountPlugin}; +pub use frame_count_diagnostics_plugin::{FrameCount, FrameCountPlugin, update_frame_count}; pub use frame_time_diagnostics_plugin::FrameTimeDiagnosticsPlugin; pub use log_diagnostics_plugin::LogDiagnosticsPlugin; #[cfg(feature = "sysinfo_plugin")] diff --git a/crates/bevy_diagnostic/src/system_information_diagnostics_plugin.rs b/crates/bevy_diagnostic/src/system_information_diagnostics_plugin.rs index 55616fca4b961..dc6ae37185f18 100644 --- a/crates/bevy_diagnostic/src/system_information_diagnostics_plugin.rs +++ b/crates/bevy_diagnostic/src/system_information_diagnostics_plugin.rs @@ -71,7 +71,7 @@ pub mod internal { use bevy_ecs::resource::Resource; use bevy_ecs::{prelude::ResMut, system::Local}; use bevy_platform_support::time::Instant; - use bevy_tasks::{available_parallelism, block_on, poll_once, AsyncComputeTaskPool, Task}; + use bevy_tasks::{AsyncComputeTaskPool, Task, available_parallelism, block_on, poll_once}; use log::info; use std::sync::Mutex; use sysinfo::{CpuRefreshKind, MemoryRefreshKind, RefreshKind, System}; diff --git a/crates/bevy_ecs/macros/src/component.rs b/crates/bevy_ecs/macros/src/component.rs index 13f41c3b3ab28..0ec47285bf80c 100644 --- a/crates/bevy_ecs/macros/src/component.rs +++ b/crates/bevy_ecs/macros/src/component.rs @@ -1,16 +1,15 @@ use proc_macro::{TokenStream, TokenTree}; use proc_macro2::{Span, TokenStream as TokenStream2}; -use quote::{format_ident, quote, ToTokens}; +use quote::{ToTokens, format_ident, quote}; use std::collections::HashSet; use syn::{ - parenthesized, + Data, DataStruct, DeriveInput, ExprClosure, ExprPath, Fields, Ident, Index, LitStr, Member, + Path, Result, Token, Visibility, parenthesized, parse::Parse, parse_macro_input, parse_quote, punctuated::Punctuated, spanned::Spanned, token::{Comma, Paren}, - Data, DataStruct, DeriveInput, ExprClosure, ExprPath, Fields, Ident, Index, LitStr, Member, - Path, Result, Token, Visibility, }; pub fn derive_event(input: TokenStream) -> TokenStream { @@ -711,7 +710,10 @@ fn derive_relationship_target( { if let Some(first) = unnamed_fields.unnamed.first() { if first.vis != Visibility::Inherited { - return Err(syn::Error::new(first.span(), "The collection in RelationshipTarget must be private to prevent users from directly mutating it, which could invalidate the correctness of relationships.")); + return Err(syn::Error::new( + first.span(), + "The collection in RelationshipTarget must be private to prevent users from directly mutating it, which could invalidate the correctness of relationships.", + )); } first.ty.clone() } else { diff --git a/crates/bevy_ecs/macros/src/lib.rs b/crates/bevy_ecs/macros/src/lib.rs index f61889651df1e..9e5d233ee61ee 100644 --- a/crates/bevy_ecs/macros/src/lib.rs +++ b/crates/bevy_ecs/macros/src/lib.rs @@ -10,13 +10,13 @@ mod states; mod world_query; use crate::{query_data::derive_query_data_impl, query_filter::derive_query_filter_impl}; -use bevy_macro_utils::{derive_label, ensure_no_collision, get_struct_fields, BevyManifest}; +use bevy_macro_utils::{BevyManifest, derive_label, ensure_no_collision, get_struct_fields}; use proc_macro::TokenStream; use proc_macro2::{Span, TokenStream as TokenStream2}; use quote::{format_ident, quote}; use syn::{ - parse_macro_input, parse_quote, punctuated::Punctuated, spanned::Spanned, token::Comma, - ConstParam, Data, DataStruct, DeriveInput, GenericParam, Index, TypeParam, + ConstParam, Data, DataStruct, DeriveInput, GenericParam, Index, TypeParam, parse_macro_input, + parse_quote, punctuated::Punctuated, spanned::Spanned, token::Comma, }; enum BundleFieldKind { diff --git a/crates/bevy_ecs/macros/src/query_data.rs b/crates/bevy_ecs/macros/src/query_data.rs index ffac58ef1d313..c27dde978f898 100644 --- a/crates/bevy_ecs/macros/src/query_data.rs +++ b/crates/bevy_ecs/macros/src/query_data.rs @@ -3,8 +3,8 @@ use proc_macro::TokenStream; use proc_macro2::{Ident, Span}; use quote::{format_ident, quote}; use syn::{ - parse_macro_input, parse_quote, punctuated::Punctuated, token, token::Comma, Attribute, Data, - DataStruct, DeriveInput, Field, Index, Meta, + Attribute, Data, DataStruct, DeriveInput, Field, Index, Meta, parse_macro_input, parse_quote, + punctuated::Punctuated, token, token::Comma, }; use crate::{ diff --git a/crates/bevy_ecs/macros/src/query_filter.rs b/crates/bevy_ecs/macros/src/query_filter.rs index c7ddb9cc83521..ea8ff2a77a6d5 100644 --- a/crates/bevy_ecs/macros/src/query_filter.rs +++ b/crates/bevy_ecs/macros/src/query_filter.rs @@ -2,7 +2,7 @@ use bevy_macro_utils::ensure_no_collision; use proc_macro::TokenStream; use proc_macro2::{Ident, Span}; use quote::{format_ident, quote}; -use syn::{parse_macro_input, parse_quote, Data, DataStruct, DeriveInput, Index}; +use syn::{Data, DataStruct, DeriveInput, Index, parse_macro_input, parse_quote}; use crate::{bevy_ecs_path, world_query::world_query_impl}; diff --git a/crates/bevy_ecs/macros/src/states.rs b/crates/bevy_ecs/macros/src/states.rs index ff69812aea380..d0ed1bb79f2dd 100644 --- a/crates/bevy_ecs/macros/src/states.rs +++ b/crates/bevy_ecs/macros/src/states.rs @@ -1,6 +1,6 @@ use proc_macro::TokenStream; use quote::{format_ident, quote}; -use syn::{parse_macro_input, spanned::Spanned, DeriveInput, Pat, Path, Result}; +use syn::{DeriveInput, Pat, Path, Result, parse_macro_input, spanned::Spanned}; use crate::bevy_ecs_path; diff --git a/crates/bevy_ecs/src/bundle.rs b/crates/bevy_ecs/src/bundle.rs index fcfd514f68838..7561bc1f00f6b 100644 --- a/crates/bevy_ecs/src/bundle.rs +++ b/crates/bevy_ecs/src/bundle.rs @@ -19,7 +19,7 @@ use crate::{ prelude::World, query::DebugCheckedUnwrap, storage::{SparseSetIndex, SparseSets, Storages, Table, TableRow}, - world::{unsafe_world_cell::UnsafeWorldCell, EntityWorldMut, ON_ADD, ON_INSERT, ON_REPLACE}, + world::{EntityWorldMut, ON_ADD, ON_INSERT, ON_REPLACE, unsafe_world_cell::UnsafeWorldCell}, }; use alloc::{boxed::Box, vec, vec::Vec}; use bevy_platform_support::collections::{HashMap, HashSet}; diff --git a/crates/bevy_ecs/src/change_detection.rs b/crates/bevy_ecs/src/change_detection.rs index 8731fb8eb7863..12f02d558c36a 100644 --- a/crates/bevy_ecs/src/change_detection.rs +++ b/crates/bevy_ecs/src/change_detection.rs @@ -1476,8 +1476,8 @@ mod tests { use crate::{ change_detection::{ - MaybeLocation, Mut, NonSendMut, Ref, ResMut, TicksMut, CHECK_TICK_THRESHOLD, - MAX_CHANGE_AGE, + CHECK_TICK_THRESHOLD, MAX_CHANGE_AGE, MaybeLocation, Mut, NonSendMut, Ref, ResMut, + TicksMut, }, component::{Component, ComponentTicks, Tick}, system::{IntoSystem, Single, System}, diff --git a/crates/bevy_ecs/src/component.rs b/crates/bevy_ecs/src/component.rs index 0eaa329c61a30..0cc28c68026a9 100644 --- a/crates/bevy_ecs/src/component.rs +++ b/crates/bevy_ecs/src/component.rs @@ -3,7 +3,7 @@ use crate::{ archetype::ArchetypeFlags, bundle::BundleInfo, - change_detection::{MaybeLocation, MAX_CHANGE_AGE}, + change_detection::{MAX_CHANGE_AGE, MaybeLocation}, entity::{ComponentCloneCtx, Entity}, query::DebugCheckedUnwrap, resource::Resource, diff --git a/crates/bevy_ecs/src/entity/clone_entities.rs b/crates/bevy_ecs/src/entity/clone_entities.rs index 389f30ff8d7b2..6d7f5d8ad16c1 100644 --- a/crates/bevy_ecs/src/entity/clone_entities.rs +++ b/crates/bevy_ecs/src/entity/clone_entities.rs @@ -8,8 +8,8 @@ use core::{any::TypeId, ptr::NonNull}; use alloc::boxed::Box; use crate::component::{ComponentCloneBehavior, ComponentCloneFn}; -use crate::entity::hash_map::EntityHashMap; use crate::entity::EntityMapper; +use crate::entity::hash_map::EntityHashMap; use crate::system::Commands; use crate::{ bundle::Bundle, @@ -817,7 +817,7 @@ mod tests { use super::ComponentCloneCtx; use crate::{ component::{Component, ComponentCloneBehavior, ComponentDescriptor, StorageType}, - entity::{hash_map::EntityHashMap, Entity, EntityCloner}, + entity::{Entity, EntityCloner, hash_map::EntityHashMap}, prelude::{ChildOf, Children, Resource}, reflect::AppTypeRegistry, reflect::{ReflectComponent, ReflectFromWorld}, @@ -840,7 +840,7 @@ mod tests { system::Commands, }; use alloc::vec; - use bevy_reflect::{std_traits::ReflectDefault, FromType, Reflect, ReflectFromPtr}; + use bevy_reflect::{FromType, Reflect, ReflectFromPtr, std_traits::ReflectDefault}; #[test] fn clone_entity_using_reflect() { @@ -989,9 +989,11 @@ mod tests { EntityCloner::build(&mut world).clone_entity(e, e_clone); - assert!(world - .get::(e_clone) - .is_some_and(|comp| *comp == A { field: 10 })); + assert!( + world + .get::(e_clone) + .is_some_and(|comp| *comp == A { field: 10 }) + ); } #[test] diff --git a/crates/bevy_ecs/src/entity/map_entities.rs b/crates/bevy_ecs/src/entity/map_entities.rs index caa02eaeac2bd..97325f3f61db2 100644 --- a/crates/bevy_ecs/src/entity/map_entities.rs +++ b/crates/bevy_ecs/src/entity/map_entities.rs @@ -1,10 +1,10 @@ use crate::{ entity::Entity, - identifier::masks::{IdentifierMask, HIGH_MASK}, + identifier::masks::{HIGH_MASK, IdentifierMask}, world::World, }; -use super::{hash_map::EntityHashMap, VisitEntitiesMut}; +use super::{VisitEntitiesMut, hash_map::EntityHashMap}; /// Operation to map all contained [`Entity`] fields in a type to new values. /// @@ -114,11 +114,7 @@ impl EntityMapper for () { impl EntityMapper for (Entity, Entity) { #[inline] fn get_mapped(&mut self, source: Entity) -> Entity { - if source == self.0 { - self.1 - } else { - source - } + if source == self.0 { self.1 } else { source } } fn set_mapped(&mut self, _source: Entity, _target: Entity) {} @@ -247,7 +243,7 @@ impl<'m> SceneEntityMapper<'m> { #[cfg(test)] mod tests { use crate::{ - entity::{hash_map::EntityHashMap, Entity, EntityMapper, SceneEntityMapper}, + entity::{Entity, EntityMapper, SceneEntityMapper, hash_map::EntityHashMap}, world::World, }; diff --git a/crates/bevy_ecs/src/entity/mod.rs b/crates/bevy_ecs/src/entity/mod.rs index 853cb7e4818dc..c15a1da341281 100644 --- a/crates/bevy_ecs/src/entity/mod.rs +++ b/crates/bevy_ecs/src/entity/mod.rs @@ -74,10 +74,10 @@ use crate::{ archetype::{ArchetypeId, ArchetypeRow}, change_detection::MaybeLocation, identifier::{ + Identifier, error::IdentifierError, kinds::IdKind, - masks::{IdentifierMask, HIGH_MASK}, - Identifier, + masks::{HIGH_MASK, IdentifierMask}, }, storage::{SparseSetIndex, TableId, TableRow}, }; diff --git a/crates/bevy_ecs/src/entity/unique_slice.rs b/crates/bevy_ecs/src/entity/unique_slice.rs index f3a6f66de7e87..0de009551e67b 100644 --- a/crates/bevy_ecs/src/entity/unique_slice.rs +++ b/crates/bevy_ecs/src/entity/unique_slice.rs @@ -21,8 +21,8 @@ use alloc::{ }; use super::{ - unique_vec, EntitySet, EntitySetIterator, FromEntitySetIterator, TrustedEntityBorrow, - UniqueEntityIter, UniqueEntityVec, + EntitySet, EntitySetIterator, FromEntitySetIterator, TrustedEntityBorrow, UniqueEntityIter, + UniqueEntityVec, unique_vec, }; /// A slice that contains only unique entities. diff --git a/crates/bevy_ecs/src/entity/unique_vec.rs b/crates/bevy_ecs/src/entity/unique_vec.rs index 9ea1f9c7a6b39..3ea438997dcc1 100644 --- a/crates/bevy_ecs/src/entity/unique_vec.rs +++ b/crates/bevy_ecs/src/entity/unique_vec.rs @@ -17,8 +17,8 @@ use alloc::{ }; use super::{ - unique_slice, EntitySet, FromEntitySetIterator, TrustedEntityBorrow, UniqueEntityIter, - UniqueEntitySlice, + EntitySet, FromEntitySetIterator, TrustedEntityBorrow, UniqueEntityIter, UniqueEntitySlice, + unique_slice, }; /// A `Vec` that contains only unique entities. diff --git a/crates/bevy_ecs/src/entity/visit_entities.rs b/crates/bevy_ecs/src/entity/visit_entities.rs index 734c96e1132b9..e302eafa8fb4c 100644 --- a/crates/bevy_ecs/src/entity/visit_entities.rs +++ b/crates/bevy_ecs/src/entity/visit_entities.rs @@ -57,7 +57,7 @@ impl VisitEntitiesMut for Entity { #[cfg(test)] mod tests { use crate::{ - entity::{hash_map::EntityHashMap, MapEntities, SceneEntityMapper}, + entity::{MapEntities, SceneEntityMapper, hash_map::EntityHashMap}, world::World, }; use alloc::{string::String, vec, vec::Vec}; diff --git a/crates/bevy_ecs/src/event/collections.rs b/crates/bevy_ecs/src/event/collections.rs index faa52ecd189af..70555e30e639f 100644 --- a/crates/bevy_ecs/src/event/collections.rs +++ b/crates/bevy_ecs/src/event/collections.rs @@ -11,7 +11,7 @@ use core::{ #[cfg(feature = "bevy_reflect")] use { bevy_ecs::reflect::ReflectResource, - bevy_reflect::{std_traits::ReflectDefault, Reflect}, + bevy_reflect::{Reflect, std_traits::ReflectDefault}, }; /// An event collection that represents the events that occurred within the last two diff --git a/crates/bevy_ecs/src/event/mod.rs b/crates/bevy_ecs/src/event/mod.rs index 9c19dc16895e7..a8aa9c547e418 100644 --- a/crates/bevy_ecs/src/event/mod.rs +++ b/crates/bevy_ecs/src/event/mod.rs @@ -25,7 +25,7 @@ pub use mutator::EventMutator; pub use reader::EventReader; pub use registry::{EventRegistry, ShouldUpdateEvents}; pub use update::{ - event_update_condition, event_update_system, signal_event_update_system, EventUpdates, + EventUpdates, event_update_condition, event_update_system, signal_event_update_system, }; pub use writer::EventWriter; @@ -157,9 +157,11 @@ mod tests { events.update(); events.send(TestEvent { i: 3 }); - assert!(reader - .read(&events) - .eq([TestEvent { i: 2 }, TestEvent { i: 3 }].iter())); + assert!( + reader + .read(&events) + .eq([TestEvent { i: 2 }, TestEvent { i: 3 }].iter()) + ); } #[test] @@ -170,9 +172,11 @@ mod tests { #[test] fn test_events_drain_and_read() { events_clear_and_read_impl(|events| { - assert!(events - .drain() - .eq(vec![TestEvent { i: 0 }, TestEvent { i: 1 }].into_iter())); + assert!( + events + .drain() + .eq(vec![TestEvent { i: 0 }, TestEvent { i: 1 }].into_iter()) + ); }); } @@ -288,9 +292,11 @@ mod tests { let mut reader = events.get_cursor(); events.extend(vec![TestEvent { i: 0 }, TestEvent { i: 1 }]); - assert!(reader - .read(&events) - .eq([TestEvent { i: 0 }, TestEvent { i: 1 }].iter())); + assert!( + reader + .read(&events) + .eq([TestEvent { i: 0 }, TestEvent { i: 1 }].iter()) + ); } // Cursor diff --git a/crates/bevy_ecs/src/lib.rs b/crates/bevy_ecs/src/lib.rs index 8d415d7469183..26845da910b9c 100644 --- a/crates/bevy_ecs/src/lib.rs +++ b/crates/bevy_ecs/src/lib.rs @@ -72,7 +72,7 @@ pub mod prelude { bundle::Bundle, change_detection::{DetectChanges, DetectChangesMut, Mut, Ref}, children, - component::{require, Component}, + component::{Component, require}, entity::{Entity, EntityBorrow, EntityMapper}, event::{Event, EventMutator, EventReader, EventWriter, Events}, hierarchy::{ChildOf, ChildSpawner, ChildSpawnerCommands, Children}, @@ -85,8 +85,8 @@ pub mod prelude { resource::Resource, result::{Error, Result}, schedule::{ - apply_deferred, common_conditions::*, ApplyDeferred, Condition, IntoSystemConfigs, - IntoSystemSet, IntoSystemSetConfigs, Schedule, Schedules, SystemSet, + ApplyDeferred, Condition, IntoSystemConfigs, IntoSystemSet, IntoSystemSetConfigs, + Schedule, Schedules, SystemSet, apply_deferred, common_conditions::*, }, spawn::{Spawn, SpawnRelated}, system::{ @@ -132,7 +132,7 @@ mod tests { use crate::{ bundle::Bundle, change_detection::Ref, - component::{require, Component, ComponentId, RequiredComponents, RequiredComponentsError}, + component::{Component, ComponentId, RequiredComponents, RequiredComponentsError, require}, entity::Entity, entity_disabling::DefaultQueryFilters, prelude::Or, @@ -910,15 +910,19 @@ mod tests { 1 ); assert!(world.query::<&A>().get(&world, a).is_ok()); - assert!(world - .query_filtered::<(), Added>() - .get(&world, a) - .is_ok()); + assert!( + world + .query_filtered::<(), Added>() + .get(&world, a) + .is_ok() + ); assert!(world.query::<&A>().get(&world, a).is_ok()); - assert!(world - .query_filtered::<(), Added>() - .get(&world, a) - .is_ok()); + assert!( + world + .query_filtered::<(), Added>() + .get(&world, a) + .is_ok() + ); world.clear_trackers(); @@ -933,15 +937,19 @@ mod tests { 0 ); assert!(world.query::<&A>().get(&world, a).is_ok()); - assert!(world - .query_filtered::<(), Added>() - .get(&world, a) - .is_err()); + assert!( + world + .query_filtered::<(), Added>() + .get(&world, a) + .is_err() + ); assert!(world.query::<&A>().get(&world, a).is_ok()); - assert!(world - .query_filtered::<(), Added>() - .get(&world, a) - .is_err()); + assert!( + world + .query_filtered::<(), Added>() + .get(&world, a) + .is_err() + ); } #[test] @@ -1114,7 +1122,11 @@ mod tests { // ensure changing an entity's archetypes also moves its changed state world.entity_mut(e1).insert(C); - assert_eq!(get_filtered::>(&mut world), [e3, e1].into_iter().collect::>(), "changed entities list should not change (although the order will due to archetype moves)"); + assert_eq!( + get_filtered::>(&mut world), + [e3, e1].into_iter().collect::>(), + "changed entities list should not change (although the order will due to archetype moves)" + ); // spawning a new SparseStored entity should not change existing changed state world.entity_mut(e1).insert(SparseStored(0)); @@ -1824,7 +1836,11 @@ mod tests { assert_eq!( component_values, - [(Some(&A(0)), &B(1), &C), (Some(&A(0)), &B(2), &C), (None, &B(3), &C)], + [ + (Some(&A(0)), &B(1), &C), + (Some(&A(0)), &B(2), &C), + (None, &B(3), &C) + ], "all entities should have had their B component replaced, received C component, and had their A component (or lack thereof) unchanged" ); } @@ -2482,8 +2498,8 @@ mod tests { } #[test] - fn runtime_required_components_deep_require_does_not_override_shallow_require_deep_subtree_after_shallow( - ) { + fn runtime_required_components_deep_require_does_not_override_shallow_require_deep_subtree_after_shallow() + { #[derive(Component)] struct A; #[derive(Component, Default)] diff --git a/crates/bevy_ecs/src/name.rs b/crates/bevy_ecs/src/name.rs index 9c38b28481e7f..5c6bd8bfe01ac 100644 --- a/crates/bevy_ecs/src/name.rs +++ b/crates/bevy_ecs/src/name.rs @@ -16,15 +16,15 @@ use core::{ use { alloc::string::ToString, serde::{ - de::{Error, Visitor}, Deserialize, Deserializer, Serialize, Serializer, + de::{Error, Visitor}, }, }; #[cfg(feature = "bevy_reflect")] use { crate::reflect::ReflectComponent, - bevy_reflect::{std_traits::ReflectDefault, Reflect}, + bevy_reflect::{Reflect, std_traits::ReflectDefault}, }; #[cfg(all(feature = "serialize", feature = "bevy_reflect"))] @@ -286,7 +286,7 @@ mod tests { mod serde_tests { use super::Name; - use serde_test::{assert_tokens, Token}; + use serde_test::{Token, assert_tokens}; #[test] fn test_serde_name() { diff --git a/crates/bevy_ecs/src/observer/mod.rs b/crates/bevy_ecs/src/observer/mod.rs index 525e9751a684e..ca715db051d9c 100644 --- a/crates/bevy_ecs/src/observer/mod.rs +++ b/crates/bevy_ecs/src/observer/mod.rs @@ -1166,11 +1166,9 @@ mod tests { let mut world = World::new(); world.init_resource::(); - world - .spawn_empty() - .observe(|_: Trigger| -> () { - panic!("Trigger routed to non-targeted entity."); - }); + world.spawn_empty().observe(|_: Trigger| -> () { + panic!("Trigger routed to non-targeted entity."); + }); world.add_observer(move |obs: Trigger, mut res: ResMut| { assert_eq!(obs.target(), Entity::PLACEHOLDER); res.observed("event_a"); @@ -1189,11 +1187,9 @@ mod tests { let mut world = World::new(); world.init_resource::(); - world - .spawn_empty() - .observe(|_: Trigger| -> () { - panic!("Trigger routed to non-targeted entity."); - }); + world.spawn_empty().observe(|_: Trigger| -> () { + panic!("Trigger routed to non-targeted entity."); + }); let entity = world .spawn_empty() .observe(|_: Trigger, mut res: ResMut| res.observed("a_1")) diff --git a/crates/bevy_ecs/src/query/access.rs b/crates/bevy_ecs/src/query/access.rs index 089d6914c6358..397835b677f41 100644 --- a/crates/bevy_ecs/src/query/access.rs +++ b/crates/bevy_ecs/src/query/access.rs @@ -1360,7 +1360,7 @@ impl Default for FilteredAccessSet { #[cfg(test)] mod tests { use crate::query::{ - access::AccessFilters, Access, AccessConflicts, FilteredAccess, FilteredAccessSet, + Access, AccessConflicts, FilteredAccess, FilteredAccessSet, access::AccessFilters, }; use alloc::vec; use core::marker::PhantomData; diff --git a/crates/bevy_ecs/src/query/fetch.rs b/crates/bevy_ecs/src/query/fetch.rs index 08e06d03f4478..2a7cdec7de0a9 100644 --- a/crates/bevy_ecs/src/query/fetch.rs +++ b/crates/bevy_ecs/src/query/fetch.rs @@ -7,8 +7,8 @@ use crate::{ query::{Access, DebugCheckedUnwrap, FilteredAccess, WorldQuery}, storage::{ComponentSparseSet, Table, TableRow}, world::{ - unsafe_world_cell::UnsafeWorldCell, EntityMut, EntityMutExcept, EntityRef, EntityRefExcept, - FilteredEntityMut, FilteredEntityRef, Mut, Ref, World, + EntityMut, EntityMutExcept, EntityRef, EntityRefExcept, FilteredEntityMut, + FilteredEntityRef, Mut, Ref, World, unsafe_world_cell::UnsafeWorldCell, }, }; use bevy_ptr::{ThinSlicePtr, UnsafeCellDeref}; @@ -2473,7 +2473,7 @@ mod tests { use bevy_ecs_macros::QueryData; use super::*; - use crate::system::{assert_is_system, Query}; + use crate::system::{Query, assert_is_system}; #[derive(Component)] pub struct A; diff --git a/crates/bevy_ecs/src/query/filter.rs b/crates/bevy_ecs/src/query/filter.rs index 9e4f36a9655f6..3b3f77a0cc727 100644 --- a/crates/bevy_ecs/src/query/filter.rs +++ b/crates/bevy_ecs/src/query/filter.rs @@ -4,7 +4,7 @@ use crate::{ entity::Entity, query::{DebugCheckedUnwrap, FilteredAccess, StorageSwitch, WorldQuery}, storage::{ComponentSparseSet, Table, TableRow}, - world::{unsafe_world_cell::UnsafeWorldCell, World}, + world::{World, unsafe_world_cell::UnsafeWorldCell}, }; use bevy_ptr::{ThinSlicePtr, UnsafeCellDeref}; use core::{cell::UnsafeCell, marker::PhantomData}; @@ -724,7 +724,10 @@ unsafe impl WorldQuery for Added { #[inline] fn update_component_access(&id: &ComponentId, access: &mut FilteredAccess) { if access.access().has_component_write(id) { - panic!("$state_name<{}> conflicts with a previous access in this query. Shared access cannot coincide with exclusive access.",core::any::type_name::()); + panic!( + "$state_name<{}> conflicts with a previous access in this query. Shared access cannot coincide with exclusive access.", + core::any::type_name::() + ); } access.add_component_read(id); } @@ -951,7 +954,10 @@ unsafe impl WorldQuery for Changed { #[inline] fn update_component_access(&id: &ComponentId, access: &mut FilteredAccess) { if access.access().has_component_write(id) { - panic!("$state_name<{}> conflicts with a previous access in this query. Shared access cannot coincide with exclusive access.",core::any::type_name::()); + panic!( + "$state_name<{}> conflicts with a previous access in this query. Shared access cannot coincide with exclusive access.", + core::any::type_name::() + ); } access.add_component_read(id); } diff --git a/crates/bevy_ecs/src/query/iter.rs b/crates/bevy_ecs/src/query/iter.rs index d81ce7b85928f..53a1519a9820b 100644 --- a/crates/bevy_ecs/src/query/iter.rs +++ b/crates/bevy_ecs/src/query/iter.rs @@ -7,8 +7,8 @@ use crate::{ query::{ArchetypeFilter, DebugCheckedUnwrap, QueryState, StorageId}, storage::{Table, TableRow, Tables}, world::{ - unsafe_world_cell::UnsafeWorldCell, EntityMut, EntityMutExcept, EntityRef, EntityRefExcept, - FilteredEntityMut, FilteredEntityRef, + EntityMut, EntityMutExcept, EntityRef, EntityRefExcept, FilteredEntityMut, + FilteredEntityRef, unsafe_world_cell::UnsafeWorldCell, }, }; use alloc::vec::Vec; diff --git a/crates/bevy_ecs/src/query/mod.rs b/crates/bevy_ecs/src/query/mod.rs index 7f304b7b712b5..c285d7bf837f6 100644 --- a/crates/bevy_ecs/src/query/mod.rs +++ b/crates/bevy_ecs/src/query/mod.rs @@ -113,8 +113,8 @@ mod tests { }, schedule::{IntoSystemConfigs, Schedule}, storage::{Table, TableRow}, - system::{assert_is_system, IntoSystem, Query, System, SystemState}, - world::{unsafe_world_cell::UnsafeWorldCell, World}, + system::{IntoSystem, Query, System, SystemState, assert_is_system}, + world::{World, unsafe_world_cell::UnsafeWorldCell}, }; use alloc::{vec, vec::Vec}; use bevy_ecs_macros::QueryFilter; @@ -920,11 +920,15 @@ mod tests { let mut write_res = IntoSystem::into_system(write_res); write_res.initialize(&mut world); - assert!(read_query - .archetype_component_access() - .is_compatible(read_res.archetype_component_access())); - assert!(!read_query - .archetype_component_access() - .is_compatible(write_res.archetype_component_access())); + assert!( + read_query + .archetype_component_access() + .is_compatible(read_res.archetype_component_access()) + ); + assert!( + !read_query + .archetype_component_access() + .is_compatible(write_res.archetype_component_access()) + ); } } diff --git a/crates/bevy_ecs/src/query/state.rs b/crates/bevy_ecs/src/query/state.rs index 1e851285dcb03..211cd668ed255 100644 --- a/crates/bevy_ecs/src/query/state.rs +++ b/crates/bevy_ecs/src/query/state.rs @@ -7,7 +7,7 @@ use crate::{ query::{Access, FilteredAccess, QueryCombinationIter, QueryIter, QueryParIter, WorldQuery}, storage::{SparseSetIndex, TableId}, system::Query, - world::{unsafe_world_cell::UnsafeWorldCell, World, WorldId}, + world::{World, WorldId, unsafe_world_cell::UnsafeWorldCell}, }; #[cfg(all(not(target_arch = "wasm32"), feature = "multi_threaded"))] @@ -591,7 +591,9 @@ impl QueryState { #[track_caller] #[cold] fn panic_mismatched(this: WorldId, other: WorldId) -> ! { - panic!("Encountered a mismatched World. This QueryState was created from {this:?}, but a method was called using {other:?}."); + panic!( + "Encountered a mismatched World. This QueryState was created from {this:?}, but a method was called using {other:?}." + ); } if self.world_id != world_id { @@ -761,7 +763,8 @@ impl QueryState { assert!( component_access.is_subset(&self.component_access), "Transmuted state for {} attempts to access terms that are not allowed by original state {}.", - core::any::type_name::<(NewD, NewF)>(), core::any::type_name::<(D, F)>() + core::any::type_name::<(NewD, NewF)>(), + core::any::type_name::<(D, F)>() ); QueryState { @@ -855,11 +858,15 @@ impl QueryState { assert!( component_access.is_subset(&joined_component_access), "Joined state for {} attempts to access terms that are not allowed by state {} joined with {}.", - core::any::type_name::<(NewD, NewF)>(), core::any::type_name::<(D, F)>(), core::any::type_name::<(OtherD, OtherF)>() + core::any::type_name::<(NewD, NewF)>(), + core::any::type_name::<(D, F)>(), + core::any::type_name::<(OtherD, OtherF)>() ); if self.archetype_generation != other.archetype_generation { - warn!("You have tried to join queries with different archetype_generations. This could lead to unpredictable results."); + warn!( + "You have tried to join queries with different archetype_generations. This could lead to unpredictable results." + ); } // the join is dense of both the queries were dense. diff --git a/crates/bevy_ecs/src/query/world_query.rs b/crates/bevy_ecs/src/query/world_query.rs index da147770e0fcf..82b14da2d6383 100644 --- a/crates/bevy_ecs/src/query/world_query.rs +++ b/crates/bevy_ecs/src/query/world_query.rs @@ -3,7 +3,7 @@ use crate::{ component::{ComponentId, Components, Tick}, query::FilteredAccess, storage::Table, - world::{unsafe_world_cell::UnsafeWorldCell, World}, + world::{World, unsafe_world_cell::UnsafeWorldCell}, }; use variadics_please::all_tuples; diff --git a/crates/bevy_ecs/src/reflect/bundle.rs b/crates/bevy_ecs/src/reflect/bundle.rs index b7acf69d6aad9..8f763b7edf2b5 100644 --- a/crates/bevy_ecs/src/reflect/bundle.rs +++ b/crates/bevy_ecs/src/reflect/bundle.rs @@ -17,7 +17,7 @@ use bevy_reflect::{ FromReflect, FromType, PartialReflect, Reflect, ReflectRef, TypePath, TypeRegistry, }; -use super::{from_reflect_with_fallback, ReflectComponent}; +use super::{ReflectComponent, from_reflect_with_fallback}; /// A struct used to operate on reflected [`Bundle`] trait of a type. /// diff --git a/crates/bevy_ecs/src/reflect/component.rs b/crates/bevy_ecs/src/reflect/component.rs index bffd2e9c290b7..db9ad6fb09a80 100644 --- a/crates/bevy_ecs/src/reflect/component.rs +++ b/crates/bevy_ecs/src/reflect/component.rs @@ -64,8 +64,8 @@ use crate::{ entity::{Entity, EntityMapper}, prelude::Component, world::{ - unsafe_world_cell::UnsafeEntityCell, EntityMut, EntityWorldMut, FilteredEntityMut, - FilteredEntityRef, World, + EntityMut, EntityWorldMut, FilteredEntityMut, FilteredEntityRef, World, + unsafe_world_cell::UnsafeEntityCell, }, }; use bevy_reflect::{FromReflect, FromType, PartialReflect, Reflect, TypePath, TypeRegistry}; @@ -313,7 +313,9 @@ impl FromType for ReflectComponent { apply: |mut entity, reflected_component| { if !C::Mutability::MUTABLE { let name = ShortName::of::(); - panic!("Cannot call `ReflectComponent::apply` on component {name}. It is immutable, and cannot modified through reflection"); + panic!( + "Cannot call `ReflectComponent::apply` on component {name}. It is immutable, and cannot modified through reflection" + ); } // SAFETY: guard ensures `C` is a mutable component @@ -361,7 +363,9 @@ impl FromType for ReflectComponent { reflect_mut: |entity| { if !C::Mutability::MUTABLE { let name = ShortName::of::(); - panic!("Cannot call `ReflectComponent::reflect_mut` on component {name}. It is immutable, and cannot modified through reflection"); + panic!( + "Cannot call `ReflectComponent::reflect_mut` on component {name}. It is immutable, and cannot modified through reflection" + ); } // SAFETY: guard ensures `C` is a mutable component @@ -374,7 +378,9 @@ impl FromType for ReflectComponent { reflect_unchecked_mut: |entity| { if !C::Mutability::MUTABLE { let name = ShortName::of::(); - panic!("Cannot call `ReflectComponent::reflect_unchecked_mut` on component {name}. It is immutable, and cannot modified through reflection"); + panic!( + "Cannot call `ReflectComponent::reflect_unchecked_mut` on component {name}. It is immutable, and cannot modified through reflection" + ); } // SAFETY: reflect_unchecked_mut is an unsafe function pointer used by diff --git a/crates/bevy_ecs/src/reflect/entity_commands.rs b/crates/bevy_ecs/src/reflect/entity_commands.rs index 9aef8105a53ca..f5cb80cebdb5a 100644 --- a/crates/bevy_ecs/src/reflect/entity_commands.rs +++ b/crates/bevy_ecs/src/reflect/entity_commands.rs @@ -349,11 +349,15 @@ fn insert_reflect_with_registry_ref( .expect("component should represent a type."); let type_path = type_info.type_path(); let Ok(mut entity) = world.get_entity_mut(entity) else { - panic!("error[B0003]: Could not insert a reflected component (of type {type_path}) for entity {entity}, which {}. See: https://bevyengine.org/learn/errors/b0003", - world.entities().entity_does_not_exist_error_details(entity)); + panic!( + "error[B0003]: Could not insert a reflected component (of type {type_path}) for entity {entity}, which {}. See: https://bevyengine.org/learn/errors/b0003", + world.entities().entity_does_not_exist_error_details(entity) + ); }; let Some(type_registration) = type_registry.get(type_info.type_id()) else { - panic!("`{type_path}` should be registered in type registry via `App::register_type<{type_path}>`"); + panic!( + "`{type_path}` should be registered in type registry via `App::register_type<{type_path}>`" + ); }; if let Some(reflect_component) = type_registration.data::() { diff --git a/crates/bevy_ecs/src/reflect/mod.rs b/crates/bevy_ecs/src/reflect/mod.rs index 4d94945afc1e9..50c42530dcbc0 100644 --- a/crates/bevy_ecs/src/reflect/mod.rs +++ b/crates/bevy_ecs/src/reflect/mod.rs @@ -7,8 +7,8 @@ use core::{ use crate::{resource::Resource, world::World}; use bevy_reflect::{ - std_traits::ReflectDefault, PartialReflect, Reflect, ReflectFromReflect, TypePath, - TypeRegistry, TypeRegistryArc, + PartialReflect, Reflect, ReflectFromReflect, TypePath, TypeRegistry, TypeRegistryArc, + std_traits::ReflectDefault, }; mod bundle; diff --git a/crates/bevy_ecs/src/reflect/resource.rs b/crates/bevy_ecs/src/reflect/resource.rs index 34e593a6ef00e..67f9d3024909c 100644 --- a/crates/bevy_ecs/src/reflect/resource.rs +++ b/crates/bevy_ecs/src/reflect/resource.rs @@ -8,7 +8,7 @@ use crate::{ change_detection::Mut, component::ComponentId, resource::Resource, - world::{unsafe_world_cell::UnsafeWorldCell, FilteredResources, FilteredResourcesMut, World}, + world::{FilteredResources, FilteredResourcesMut, World, unsafe_world_cell::UnsafeWorldCell}, }; use bevy_reflect::{FromReflect, FromType, PartialReflect, Reflect, TypePath, TypeRegistry}; diff --git a/crates/bevy_ecs/src/relationship/mod.rs b/crates/bevy_ecs/src/relationship/mod.rs index 540b049541bd9..404e2b801536c 100644 --- a/crates/bevy_ecs/src/relationship/mod.rs +++ b/crates/bevy_ecs/src/relationship/mod.rs @@ -14,9 +14,10 @@ use crate::{ component::{Component, HookContext, Mutable}, entity::{ComponentCloneCtx, Entity}, system::{ + Commands, command::HandleError, entity_command::{self, CommandWithEntity}, - error_handler, Commands, + error_handler, }, world::{DeferredWorld, EntityWorldMut}, }; @@ -78,7 +79,9 @@ pub trait Relationship: Component + Sized { if target_entity == entity { warn!( "{}The {}({target_entity:?}) relationship on entity {entity:?} points to itself. The invalid {} relationship has been removed.", - caller.map(|location|format!("{location}: ")).unwrap_or_default(), + caller + .map(|location| format!("{location}: ")) + .unwrap_or_default(), core::any::type_name::(), core::any::type_name::() ); @@ -98,7 +101,9 @@ pub trait Relationship: Component + Sized { } else { warn!( "{}The {}({target_entity:?}) relationship on entity {entity:?} relates to an entity that does not exist. The invalid {} relationship has been removed.", - caller.map(|location|format!("{location}: ")).unwrap_or_default(), + caller + .map(|location| format!("{location}: ")) + .unwrap_or_default(), core::any::type_name::(), core::any::type_name::() ); diff --git a/crates/bevy_ecs/src/relationship/relationship_source_collection.rs b/crates/bevy_ecs/src/relationship/relationship_source_collection.rs index 013cdd63aaf2b..5627e7649a3bf 100644 --- a/crates/bevy_ecs/src/relationship/relationship_source_collection.rs +++ b/crates/bevy_ecs/src/relationship/relationship_source_collection.rs @@ -1,4 +1,4 @@ -use crate::entity::{hash_set::EntityHashSet, Entity}; +use crate::entity::{Entity, hash_set::EntityHashSet}; use alloc::vec::Vec; use smallvec::SmallVec; diff --git a/crates/bevy_ecs/src/removal_detection.rs b/crates/bevy_ecs/src/removal_detection.rs index a1480a1923144..bbfe6ac12771c 100644 --- a/crates/bevy_ecs/src/removal_detection.rs +++ b/crates/bevy_ecs/src/removal_detection.rs @@ -7,7 +7,7 @@ use crate::{ prelude::Local, storage::SparseSet, system::{ReadOnlySystemParam, SystemMeta, SystemParam}, - world::{unsafe_world_cell::UnsafeWorldCell, World}, + world::{World, unsafe_world_cell::UnsafeWorldCell}, }; use derive_more::derive::Into; diff --git a/crates/bevy_ecs/src/schedule/auto_insert_apply_deferred.rs b/crates/bevy_ecs/src/schedule/auto_insert_apply_deferred.rs index 8ad4725d86f95..901779127d421 100644 --- a/crates/bevy_ecs/src/schedule/auto_insert_apply_deferred.rs +++ b/crates/bevy_ecs/src/schedule/auto_insert_apply_deferred.rs @@ -6,8 +6,8 @@ use crate::system::IntoSystem; use crate::world::World; use super::{ - is_apply_deferred, ApplyDeferred, DiGraph, Direction, NodeId, ReportCycles, ScheduleBuildError, - ScheduleBuildPass, ScheduleGraph, SystemNode, + ApplyDeferred, DiGraph, Direction, NodeId, ReportCycles, ScheduleBuildError, ScheduleBuildPass, + ScheduleGraph, SystemNode, is_apply_deferred, }; /// A [`ScheduleBuildPass`] that inserts [`ApplyDeferred`] systems into the schedule graph diff --git a/crates/bevy_ecs/src/schedule/condition.rs b/crates/bevy_ecs/src/schedule/condition.rs index 1bd0e9f4da304..26316f7fbd2c6 100644 --- a/crates/bevy_ecs/src/schedule/condition.rs +++ b/crates/bevy_ecs/src/schedule/condition.rs @@ -1262,7 +1262,7 @@ where #[cfg(test)] mod tests { - use super::{common_conditions::*, Condition}; + use super::{Condition, common_conditions::*}; use crate::query::With; use crate::{ change_detection::ResMut, diff --git a/crates/bevy_ecs/src/schedule/config.rs b/crates/bevy_ecs/src/schedule/config.rs index 898cf674245d2..e2f04de785953 100644 --- a/crates/bevy_ecs/src/schedule/config.rs +++ b/crates/bevy_ecs/src/schedule/config.rs @@ -4,11 +4,11 @@ use variadics_please::all_tuples; use crate::{ result::Result, schedule::{ + Chain, auto_insert_apply_deferred::IgnoreDeferred, condition::{BoxedCondition, Condition}, graph::{Ambiguity, Dependency, DependencyKind, GraphInfo}, set::{InternedSystemSet, IntoSystemSet, SystemSet}, - Chain, }, system::{BoxedSystem, InfallibleSystemWrapper, IntoSystem, ScheduleSystem, System}, }; diff --git a/crates/bevy_ecs/src/schedule/executor/mod.rs b/crates/bevy_ecs/src/schedule/executor/mod.rs index c99d263e046df..427927cede91c 100644 --- a/crates/bevy_ecs/src/schedule/executor/mod.rs +++ b/crates/bevy_ecs/src/schedule/executor/mod.rs @@ -21,7 +21,7 @@ use crate::{ result::{Error, Result, SystemErrorContext}, schedule::{BoxedCondition, InternedSystemSet, NodeId, SystemTypeSet}, system::{ScheduleSystem, System, SystemIn}, - world::{unsafe_world_cell::UnsafeWorldCell, DeferredWorld, World}, + world::{DeferredWorld, World, unsafe_world_cell::UnsafeWorldCell}, }; /// Types that can run a [`SystemSchedule`] on a [`World`]. @@ -267,7 +267,7 @@ mod __rust_begin_short_backtrace { use crate::{ result::Result, system::{ReadOnlySystem, ScheduleSystem}, - world::{unsafe_world_cell::UnsafeWorldCell, World}, + world::{World, unsafe_world_cell::UnsafeWorldCell}, }; /// # Safety diff --git a/crates/bevy_ecs/src/schedule/executor/multi_threaded.rs b/crates/bevy_ecs/src/schedule/executor/multi_threaded.rs index e78cb666aedd4..23ef0995c8213 100644 --- a/crates/bevy_ecs/src/schedule/executor/multi_threaded.rs +++ b/crates/bevy_ecs/src/schedule/executor/multi_threaded.rs @@ -11,16 +11,16 @@ use std::{ }; #[cfg(feature = "trace")] -use tracing::{info_span, Span}; +use tracing::{Span, info_span}; use crate::{ archetype::ArchetypeComponentId, prelude::Resource, query::Access, result::{Error, Result, SystemErrorContext}, - schedule::{is_apply_deferred, BoxedCondition, ExecutorKind, SystemExecutor, SystemSchedule}, + schedule::{BoxedCondition, ExecutorKind, SystemExecutor, SystemSchedule, is_apply_deferred}, system::ScheduleSystem, - world::{unsafe_world_cell::UnsafeWorldCell, World}, + world::{World, unsafe_world_cell::UnsafeWorldCell}, }; use super::__rust_begin_short_backtrace; diff --git a/crates/bevy_ecs/src/schedule/executor/simple.rs b/crates/bevy_ecs/src/schedule/executor/simple.rs index ad01c324e9ea5..1ad2a6d599ea9 100644 --- a/crates/bevy_ecs/src/schedule/executor/simple.rs +++ b/crates/bevy_ecs/src/schedule/executor/simple.rs @@ -10,7 +10,7 @@ use std::eprintln; use crate::{ result::{Error, SystemErrorContext}, schedule::{ - executor::is_apply_deferred, BoxedCondition, ExecutorKind, SystemExecutor, SystemSchedule, + BoxedCondition, ExecutorKind, SystemExecutor, SystemSchedule, executor::is_apply_deferred, }, world::World, }; diff --git a/crates/bevy_ecs/src/schedule/executor/single_threaded.rs b/crates/bevy_ecs/src/schedule/executor/single_threaded.rs index b5c44085d5db3..7e4a1051c0c1c 100644 --- a/crates/bevy_ecs/src/schedule/executor/single_threaded.rs +++ b/crates/bevy_ecs/src/schedule/executor/single_threaded.rs @@ -9,7 +9,7 @@ use std::eprintln; use crate::{ result::{Error, SystemErrorContext}, - schedule::{is_apply_deferred, BoxedCondition, ExecutorKind, SystemExecutor, SystemSchedule}, + schedule::{BoxedCondition, ExecutorKind, SystemExecutor, SystemSchedule, is_apply_deferred}, world::World, }; diff --git a/crates/bevy_ecs/src/schedule/graph/node.rs b/crates/bevy_ecs/src/schedule/graph/node.rs index e4af143fc7a78..423c7045340b1 100644 --- a/crates/bevy_ecs/src/schedule/graph/node.rs +++ b/crates/bevy_ecs/src/schedule/graph/node.rs @@ -31,8 +31,8 @@ impl NodeId { /// Compare this [`NodeId`] with another. pub const fn cmp(&self, other: &Self) -> core::cmp::Ordering { - use core::cmp::Ordering::{Equal, Greater, Less}; use NodeId::{Set, System}; + use core::cmp::Ordering::{Equal, Greater, Less}; match (self, other) { (System(a), System(b)) | (Set(a), Set(b)) => match a.checked_sub(*b) { diff --git a/crates/bevy_ecs/src/schedule/schedule.rs b/crates/bevy_ecs/src/schedule/schedule.rs index ef6c457332916..9ad2bce84c3fa 100644 --- a/crates/bevy_ecs/src/schedule/schedule.rs +++ b/crates/bevy_ecs/src/schedule/schedule.rs @@ -11,7 +11,7 @@ use alloc::{ vec::Vec, }; use bevy_platform_support::collections::{HashMap, HashSet}; -use bevy_utils::{default, TypeIdMap}; +use bevy_utils::{TypeIdMap, default}; use core::{ any::{Any, TypeId}, fmt::{Debug, Write}, @@ -35,8 +35,8 @@ use crate::{ }; use crate::{query::AccessConflicts, storage::SparseSetIndex}; -pub use stepping::Stepping; use Direction::{Incoming, Outgoing}; +pub use stepping::Stepping; /// Resource that stores [`Schedule`]s mapped to [`ScheduleLabel`]s excluding the current running [`Schedule`]. #[derive(Default, Resource)] @@ -1855,9 +1855,9 @@ impl ScheduleGraph { let n_ambiguities = ambiguities.len(); let mut message = format!( - "{n_ambiguities} pairs of systems with conflicting data access have indeterminate execution order. \ + "{n_ambiguities} pairs of systems with conflicting data access have indeterminate execution order. \ Consider adding `before`, `after`, or `ambiguous_with` relationships between these:\n", - ); + ); for (name_a, name_b, conflicts) in self.conflicts_to_string(ambiguities, components) { writeln!(message, " -- {name_a} and {name_b}").unwrap(); @@ -1942,13 +1942,19 @@ pub enum ScheduleBuildError { #[error("System dependencies contain cycle(s).\n{0}")] DependencyCycle(String), /// Tried to order a system (set) relative to a system set it belongs to. - #[error("`{0}` and `{1}` have both `in_set` and `before`-`after` relationships (these might be transitive). This combination is unsolvable as a system cannot run before or after a set it belongs to.")] + #[error( + "`{0}` and `{1}` have both `in_set` and `before`-`after` relationships (these might be transitive). This combination is unsolvable as a system cannot run before or after a set it belongs to." + )] CrossDependency(String, String), /// Tried to order system sets that share systems. - #[error("`{0}` and `{1}` have a `before`-`after` relationship (which may be transitive) but share systems.")] + #[error( + "`{0}` and `{1}` have a `before`-`after` relationship (which may be transitive) but share systems." + )] SetsHaveOrderButIntersect(String, String), /// Tried to order a system (set) relative to all instances of some system function. - #[error("Tried to order against `{0}` in a schedule that has more than one `{0}` instance. `{0}` is a `SystemTypeSet` and cannot be used for ordering if ambiguous. Use a different set without this restriction.")] + #[error( + "Tried to order against `{0}` in a schedule that has more than one `{0}` instance. `{0}` is a `SystemTypeSet` and cannot be used for ordering if ambiguous. Use a different set without this restriction." + )] SystemTypeSetAmbiguity(String), /// Systems with conflicting access have indeterminate run order. /// @@ -2038,8 +2044,8 @@ mod tests { use crate::{ prelude::{Res, Resource}, schedule::{ - tests::ResMut, IntoSystemConfigs, IntoSystemSetConfigs, Schedule, - ScheduleBuildSettings, SystemSet, + IntoSystemConfigs, IntoSystemSetConfigs, Schedule, ScheduleBuildSettings, SystemSet, + tests::ResMut, }, system::Commands, world::World, @@ -2064,9 +2070,11 @@ mod tests { schedule.configure_sets(Set.run_if(|| false)); schedule.add_systems( - (|| -> () { panic!("This system must not run"); }) - .ambiguous_with(|| ()) - .in_set(Set), + (|| -> () { + panic!("This system must not run"); + }) + .ambiguous_with(|| ()) + .in_set(Set), ); schedule.run(&mut world); } diff --git a/crates/bevy_ecs/src/schedule/set.rs b/crates/bevy_ecs/src/schedule/set.rs index 896c7ed050ecc..7a0bfc0675cee 100644 --- a/crates/bevy_ecs/src/schedule/set.rs +++ b/crates/bevy_ecs/src/schedule/set.rs @@ -218,7 +218,7 @@ where mod tests { use crate::{ resource::Resource, - schedule::{tests::ResMut, Schedule}, + schedule::{Schedule, tests::ResMut}, }; use super::*; diff --git a/crates/bevy_ecs/src/storage/resource.rs b/crates/bevy_ecs/src/storage/resource.rs index 078acade7d9ef..2f253153f73d4 100644 --- a/crates/bevy_ecs/src/storage/resource.rs +++ b/crates/bevy_ecs/src/storage/resource.rs @@ -2,7 +2,7 @@ use crate::{ archetype::ArchetypeComponentId, change_detection::{MaybeLocation, MutUntyped, TicksMut}, component::{ComponentId, ComponentTicks, Components, Tick, TickCells}, - storage::{blob_vec::BlobVec, SparseSet}, + storage::{SparseSet, blob_vec::BlobVec}, }; use alloc::string::String; use bevy_ptr::{OwningPtr, Ptr, UnsafeCellDeref}; diff --git a/crates/bevy_ecs/src/storage/table/mod.rs b/crates/bevy_ecs/src/storage/table/mod.rs index 159a716c4ed05..0d6f42df599d5 100644 --- a/crates/bevy_ecs/src/storage/table/mod.rs +++ b/crates/bevy_ecs/src/storage/table/mod.rs @@ -3,7 +3,7 @@ use crate::{ component::{ComponentId, ComponentInfo, ComponentTicks, Components, Tick}, entity::Entity, query::DebugCheckedUnwrap, - storage::{blob_vec::BlobVec, ImmutableSparseSet, SparseSet}, + storage::{ImmutableSparseSet, SparseSet, blob_vec::BlobVec}, }; use alloc::{boxed::Box, vec, vec::Vec}; use bevy_platform_support::collections::HashMap; diff --git a/crates/bevy_ecs/src/system/adapter_system.rs b/crates/bevy_ecs/src/system/adapter_system.rs index 27e812928c8a1..38dfcaa7a5857 100644 --- a/crates/bevy_ecs/src/system/adapter_system.rs +++ b/crates/bevy_ecs/src/system/adapter_system.rs @@ -3,7 +3,7 @@ use alloc::{borrow::Cow, vec::Vec}; use super::{IntoSystem, ReadOnlySystem, System}; use crate::{ schedule::InternedSystemSet, - system::{input::SystemInput, SystemIn}, + system::{SystemIn, input::SystemInput}, world::unsafe_world_cell::UnsafeWorldCell, }; diff --git a/crates/bevy_ecs/src/system/builder.rs b/crates/bevy_ecs/src/system/builder.rs index 6261b9e35587e..ca1d5868f2728 100644 --- a/crates/bevy_ecs/src/system/builder.rs +++ b/crates/bevy_ecs/src/system/builder.rs @@ -16,7 +16,7 @@ use crate::{ }; use core::fmt::Debug; -use super::{init_query_param, Res, ResMut, SystemState}; +use super::{Res, ResMut, SystemState, init_query_param}; /// A builder that can create a [`SystemParam`]. /// @@ -201,8 +201,8 @@ impl ParamBuilder { } /// Helper method for adding a filtered [`Query`] as a param, equivalent to `of::>()` - pub fn query_filtered<'w, 's, D: QueryData + 'static, F: QueryFilter + 'static>( - ) -> impl SystemParamBuilder> { + pub fn query_filtered<'w, 's, D: QueryData + 'static, F: QueryFilter + 'static>() + -> impl SystemParamBuilder> { Self } } @@ -283,12 +283,12 @@ impl<'a, D: QueryData, F: QueryFilter> // SAFETY: Calls `init_query_param`, just like `Query::init_state`. unsafe impl< - 'w, - 's, - D: QueryData + 'static, - F: QueryFilter + 'static, - T: FnOnce(&mut QueryBuilder), - > SystemParamBuilder> for QueryParamBuilder + 'w, + 's, + D: QueryData + 'static, + F: QueryFilter + 'static, + T: FnOnce(&mut QueryBuilder), +> SystemParamBuilder> for QueryParamBuilder { fn build(self, world: &mut World, system_meta: &mut SystemMeta) -> QueryState { let mut builder = QueryBuilder::new(world); @@ -609,7 +609,9 @@ unsafe impl<'w, 's, T: FnOnce(&mut FilteredResourcesBuilder)> if !conflicts.is_empty() { let accesses = conflicts.format_conflict_list(world); let system_name = &meta.name; - panic!("error[B0002]: FilteredResources in system {system_name} accesses resources(s){accesses} in a way that conflicts with a previous system parameter. Consider removing the duplicate access. See: https://bevyengine.org/learn/errors/b0002"); + panic!( + "error[B0002]: FilteredResources in system {system_name} accesses resources(s){accesses} in a way that conflicts with a previous system parameter. Consider removing the duplicate access. See: https://bevyengine.org/learn/errors/b0002" + ); } if access.has_read_all_resources() { @@ -673,7 +675,9 @@ unsafe impl<'w, 's, T: FnOnce(&mut FilteredResourcesMutBuilder)> if !conflicts.is_empty() { let accesses = conflicts.format_conflict_list(world); let system_name = &meta.name; - panic!("error[B0002]: FilteredResourcesMut in system {system_name} accesses resources(s){accesses} in a way that conflicts with a previous system parameter. Consider removing the duplicate access. See: https://bevyengine.org/learn/errors/b0002"); + panic!( + "error[B0002]: FilteredResourcesMut in system {system_name} accesses resources(s){accesses} in a way that conflicts with a previous system parameter. Consider removing the duplicate access. See: https://bevyengine.org/learn/errors/b0002" + ); } if access.has_read_all_resources() { diff --git a/crates/bevy_ecs/src/system/combinator.rs b/crates/bevy_ecs/src/system/combinator.rs index f6e696a106a96..6244e86669824 100644 --- a/crates/bevy_ecs/src/system/combinator.rs +++ b/crates/bevy_ecs/src/system/combinator.rs @@ -7,7 +7,7 @@ use crate::{ prelude::World, query::Access, schedule::InternedSystemSet, - system::{input::SystemInput, SystemIn}, + system::{SystemIn, input::SystemInput}, world::unsafe_world_cell::UnsafeWorldCell, }; diff --git a/crates/bevy_ecs/src/system/commands/command.rs b/crates/bevy_ecs/src/system/commands/command.rs index 68035560d018e..d7144fbcfbf21 100644 --- a/crates/bevy_ecs/src/system/commands/command.rs +++ b/crates/bevy_ecs/src/system/commands/command.rs @@ -13,7 +13,7 @@ use crate::{ resource::Resource, result::{Error, Result}, schedule::ScheduleLabel, - system::{error_handler, IntoSystem, SystemId, SystemInput}, + system::{IntoSystem, SystemId, SystemInput, error_handler}, world::{FromWorld, SpawnBatchIter, World}, }; diff --git a/crates/bevy_ecs/src/system/commands/entity_command.rs b/crates/bevy_ecs/src/system/commands/entity_command.rs index 20dd9e0289f2c..e72121a0d2d92 100644 --- a/crates/bevy_ecs/src/system/commands/entity_command.rs +++ b/crates/bevy_ecs/src/system/commands/entity_command.rs @@ -14,8 +14,8 @@ use crate::{ entity::{Entity, EntityClonerBuilder}, event::Event, result::Result, - system::{command::HandleError, Command, IntoObserverSystem}, - world::{error::EntityMutableFetchError, EntityWorldMut, FromWorld, World}, + system::{Command, IntoObserverSystem, command::HandleError}, + world::{EntityWorldMut, FromWorld, World, error::EntityMutableFetchError}, }; use bevy_ptr::OwningPtr; @@ -101,7 +101,7 @@ impl CommandWithEntity> fo self, entity: Entity, ) -> impl Command> - + HandleError> { + + HandleError> { move |world: &mut World| -> Result<(), EntityMutableFetchError> { let entity = world.get_entity_mut(entity)?; self.apply(entity); @@ -111,10 +111,10 @@ impl CommandWithEntity> fo } impl< - C: EntityCommand>, - T, - Err: core::fmt::Debug + core::fmt::Display + Send + Sync + 'static, - > CommandWithEntity>> for C + C: EntityCommand>, + T, + Err: core::fmt::Debug + core::fmt::Display + Send + Sync + 'static, +> CommandWithEntity>> for C { fn with_entity( self, diff --git a/crates/bevy_ecs/src/system/commands/mod.rs b/crates/bevy_ecs/src/system/commands/mod.rs index 04d0940a44c65..c4ffa5422e34a 100644 --- a/crates/bevy_ecs/src/system/commands/mod.rs +++ b/crates/bevy_ecs/src/system/commands/mod.rs @@ -27,12 +27,12 @@ use crate::{ result::Error, schedule::ScheduleLabel, system::{ - command::HandleError, entity_command::CommandWithEntity, input::SystemInput, Deferred, - IntoObserverSystem, IntoSystem, RegisteredSystem, SystemId, + Deferred, IntoObserverSystem, IntoSystem, RegisteredSystem, SystemId, command::HandleError, + entity_command::CommandWithEntity, input::SystemInput, }, world::{ - command_queue::RawCommandQueue, unsafe_world_cell::UnsafeWorldCell, CommandQueue, - EntityWorldMut, FromWorld, World, + CommandQueue, EntityWorldMut, FromWorld, World, command_queue::RawCommandQueue, + unsafe_world_cell::UnsafeWorldCell, }, }; @@ -2201,7 +2201,7 @@ impl<'a, T: Component> EntityEntryCommands<'a, T> { #[cfg(test)] mod tests { use crate::{ - component::{require, Component}, + component::{Component, require}, resource::Resource, system::Commands, world::{CommandQueue, FromWorld, World}, diff --git a/crates/bevy_ecs/src/system/exclusive_function_system.rs b/crates/bevy_ecs/src/system/exclusive_function_system.rs index 2b1c081d51db0..c0989aa7ad156 100644 --- a/crates/bevy_ecs/src/system/exclusive_function_system.rs +++ b/crates/bevy_ecs/src/system/exclusive_function_system.rs @@ -4,10 +4,10 @@ use crate::{ query::Access, schedule::{InternedSystemSet, SystemSet}, system::{ - check_system_change_tick, ExclusiveSystemParam, ExclusiveSystemParamItem, IntoSystem, - System, SystemIn, SystemInput, SystemMeta, + ExclusiveSystemParam, ExclusiveSystemParamItem, IntoSystem, System, SystemIn, SystemInput, + SystemMeta, check_system_change_tick, }, - world::{unsafe_world_cell::UnsafeWorldCell, World}, + world::{World, unsafe_world_cell::UnsafeWorldCell}, }; use alloc::{borrow::Cow, vec, vec::Vec}; diff --git a/crates/bevy_ecs/src/system/function_system.rs b/crates/bevy_ecs/src/system/function_system.rs index 0f3950d1d4ba6..151a5ec95a73a 100644 --- a/crates/bevy_ecs/src/system/function_system.rs +++ b/crates/bevy_ecs/src/system/function_system.rs @@ -5,10 +5,10 @@ use crate::{ query::{Access, FilteredAccessSet}, schedule::{InternedSystemSet, SystemSet}, system::{ - check_system_change_tick, ReadOnlySystemParam, System, SystemIn, SystemInput, SystemParam, - SystemParamItem, + ReadOnlySystemParam, System, SystemIn, SystemInput, SystemParam, SystemParamItem, + check_system_change_tick, }, - world::{unsafe_world_cell::UnsafeWorldCell, DeferredWorld, World, WorldId}, + world::{DeferredWorld, World, WorldId, unsafe_world_cell::UnsafeWorldCell}, }; use alloc::{borrow::Cow, vec, vec::Vec}; @@ -16,7 +16,7 @@ use core::marker::PhantomData; use variadics_please::all_tuples; #[cfg(feature = "trace")] -use tracing::{info_span, Span}; +use tracing::{Span, info_span}; use super::{IntoSystem, ReadOnlySystem, SystemParamBuilder}; @@ -537,7 +537,9 @@ impl SystemState { #[track_caller] #[cold] fn panic_mismatched(this: WorldId, other: WorldId) -> ! { - panic!("Encountered a mismatched World. This SystemState was created from {this:?}, but a method was called using {other:?}."); + panic!( + "Encountered a mismatched World. This SystemState was created from {this:?}, but a method was called using {other:?}." + ); } if !self.matches_world(world_id) { @@ -568,7 +570,11 @@ impl SystemState { /// This method only accesses world metadata. #[inline] pub fn update_archetypes_unsafe_world_cell(&mut self, world: UnsafeWorldCell) { - assert_eq!(self.world_id, world.id(), "Encountered a mismatched World. A System cannot be used with Worlds other than the one it was initialized with."); + assert_eq!( + self.world_id, + world.id(), + "Encountered a mismatched World. A System cannot be used with Worlds other than the one it was initialized with." + ); let archetypes = world.archetypes(); let old_generation = @@ -880,7 +886,11 @@ where fn update_archetype_component_access(&mut self, world: UnsafeWorldCell) { let state = self.state.as_mut().expect(Self::ERROR_UNINITIALIZED); - assert_eq!(state.world_id, world.id(), "Encountered a mismatched World. A System cannot be used with Worlds other than the one it was initialized with."); + assert_eq!( + state.world_id, + world.id(), + "Encountered a mismatched World. A System cannot be used with Worlds other than the one it was initialized with." + ); let archetypes = world.archetypes(); let old_generation = diff --git a/crates/bevy_ecs/src/system/mod.rs b/crates/bevy_ecs/src/system/mod.rs index 43f9c612d13c3..df7f34fc2eb49 100644 --- a/crates/bevy_ecs/src/system/mod.rs +++ b/crates/bevy_ecs/src/system/mod.rs @@ -341,8 +341,8 @@ mod tests { resource::Resource, result::Result, schedule::{ - common_conditions::resource_exists, ApplyDeferred, Condition, IntoSystemConfigs, - Schedule, + ApplyDeferred, Condition, IntoSystemConfigs, Schedule, + common_conditions::resource_exists, }, system::{ Commands, In, IntoSystem, Local, NonSend, NonSendMut, ParamSet, Query, Res, ResMut, @@ -1490,9 +1490,11 @@ mod tests { system.initialize(&mut world); system.update_archetype_component_access(world.as_unsafe_world_cell()); let archetype_component_access = system.archetype_component_access(); - assert!(expected_ids - .iter() - .all(|id| archetype_component_access.has_component_read(*id))); + assert!( + expected_ids + .iter() + .all(|id| archetype_component_access.has_component_read(*id)) + ); // add some entities with archetypes that should match and save their ids expected_ids.insert( @@ -1517,9 +1519,11 @@ mod tests { // update system and verify its accesses are correct system.update_archetype_component_access(world.as_unsafe_world_cell()); let archetype_component_access = system.archetype_component_access(); - assert!(expected_ids - .iter() - .all(|id| archetype_component_access.has_component_read(*id))); + assert!( + expected_ids + .iter() + .all(|id| archetype_component_access.has_component_read(*id)) + ); // one more round expected_ids.insert( @@ -1532,9 +1536,11 @@ mod tests { world.spawn((A, B, D)); system.update_archetype_component_access(world.as_unsafe_world_cell()); let archetype_component_access = system.archetype_component_access(); - assert!(expected_ids - .iter() - .all(|id| archetype_component_access.has_component_read(*id))); + assert!( + expected_ids + .iter() + .all(|id| archetype_component_access.has_component_read(*id)) + ); } #[test] @@ -1648,7 +1654,9 @@ mod tests { #[should_panic] fn panic_inside_system() { let mut world = World::new(); - run_system(&mut world, || -> () { panic!("this system panics"); }); + run_system(&mut world, || -> () { + panic!("this system panics"); + }); } #[test] diff --git a/crates/bevy_ecs/src/system/observer_system.rs b/crates/bevy_ecs/src/system/observer_system.rs index 8a8f82d99e361..6cdd2ccdb2d00 100644 --- a/crates/bevy_ecs/src/system/observer_system.rs +++ b/crates/bevy_ecs/src/system/observer_system.rs @@ -8,8 +8,8 @@ use crate::{ query::Access, result::Result, schedule::{Fallible, Infallible}, - system::{input::SystemIn, System}, - world::{unsafe_world_cell::UnsafeWorldCell, DeferredWorld, World}, + system::{System, input::SystemIn}, + world::{DeferredWorld, World, unsafe_world_cell::UnsafeWorldCell}, }; use super::IntoSystem; diff --git a/crates/bevy_ecs/src/system/query.rs b/crates/bevy_ecs/src/system/query.rs index a0457dc667b71..2ec95b25f2752 100644 --- a/crates/bevy_ecs/src/system/query.rs +++ b/crates/bevy_ecs/src/system/query.rs @@ -2596,10 +2596,12 @@ mod tests { // We don't care about aliased mutability for the read-only equivalent // SAFETY: Query does not access world data. - assert!(query_state - .query_mut(&mut world) - .get_many_inner::<10>(entities.clone().try_into().unwrap()) - .is_ok()); + assert!( + query_state + .query_mut(&mut world) + .get_many_inner::<10>(entities.clone().try_into().unwrap()) + .is_ok() + ); assert_eq!( query_state diff --git a/crates/bevy_ecs/src/system/schedule_system.rs b/crates/bevy_ecs/src/system/schedule_system.rs index e0005f06f46d9..cba0cb760b674 100644 --- a/crates/bevy_ecs/src/system/schedule_system.rs +++ b/crates/bevy_ecs/src/system/schedule_system.rs @@ -5,8 +5,8 @@ use crate::{ component::{ComponentId, Tick}, query::Access, result::Result, - system::{input::SystemIn, BoxedSystem, System}, - world::{unsafe_world_cell::UnsafeWorldCell, DeferredWorld, World}, + system::{BoxedSystem, System, input::SystemIn}, + world::{DeferredWorld, World, unsafe_world_cell::UnsafeWorldCell}, }; use super::IntoSystem; diff --git a/crates/bevy_ecs/src/system/system.rs b/crates/bevy_ecs/src/system/system.rs index d0990e907f8ec..e3959163ad891 100644 --- a/crates/bevy_ecs/src/system/system.rs +++ b/crates/bevy_ecs/src/system/system.rs @@ -11,8 +11,8 @@ use crate::{ component::{ComponentId, Tick}, query::Access, schedule::InternedSystemSet, - system::{input::SystemInput, SystemIn}, - world::{unsafe_world_cell::UnsafeWorldCell, DeferredWorld, World}, + system::{SystemIn, input::SystemInput}, + world::{DeferredWorld, World, unsafe_world_cell::UnsafeWorldCell}, }; use alloc::{borrow::Cow, boxed::Box, vec::Vec}; @@ -73,7 +73,7 @@ pub trait System: Send + Sync + 'static { /// point before this one, with the same exact [`World`]. If [`System::update_archetype_component_access`] /// panics (or otherwise does not return for any reason), this method must not be called. unsafe fn run_unsafe(&mut self, input: SystemIn<'_, Self>, world: UnsafeWorldCell) - -> Self::Out; + -> Self::Out; /// Runs the system with the given input in the world. /// @@ -366,7 +366,9 @@ pub enum RunSystemError { /// System could not be run due to parameters that failed validation. /// /// This can occur because the data required by the system was not present in the world. - #[error("The data required by the system {0:?} was not found in the world and the system did not run due to failed parameter validation.")] + #[error( + "The data required by the system {0:?} was not found in the world and the system did not run due to failed parameter validation." + )] InvalidParams(Cow<'static, str>), } diff --git a/crates/bevy_ecs/src/system/system_param.rs b/crates/bevy_ecs/src/system/system_param.rs index 8ef804a926be5..73616dae19708 100644 --- a/crates/bevy_ecs/src/system/system_param.rs +++ b/crates/bevy_ecs/src/system/system_param.rs @@ -13,8 +13,8 @@ use crate::{ storage::ResourceData, system::{Query, Single, SystemMeta}, world::{ - unsafe_world_cell::UnsafeWorldCell, DeferredWorld, FilteredResources, FilteredResourcesMut, - FromWorld, World, + DeferredWorld, FilteredResources, FilteredResourcesMut, FromWorld, World, + unsafe_world_cell::UnsafeWorldCell, }, }; use alloc::{borrow::ToOwned, boxed::Box, vec::Vec}; @@ -373,7 +373,11 @@ fn assert_component_access_compatibility( if !accesses.is_empty() { accesses.push(' '); } - panic!("error[B0001]: Query<{}, {}> in system {system_name} accesses component(s) {accesses}in a way that conflicts with a previous system parameter. Consider using `Without` to create disjoint Queries or merging conflicting Queries into a `ParamSet`. See: https://bevyengine.org/learn/errors/b0001", ShortName(query_type), ShortName(filter_type)); + panic!( + "error[B0001]: Query<{}, {}> in system {system_name} accesses component(s) {accesses}in a way that conflicts with a previous system parameter. Consider using `Without` to create disjoint Queries or merging conflicting Queries into a `ParamSet`. See: https://bevyengine.org/learn/errors/b0001", + ShortName(query_type), + ShortName(filter_type) + ); } // SAFETY: Relevant query ComponentId and ArchetypeComponentId access is applied to SystemMeta. If @@ -933,11 +937,15 @@ unsafe impl<'a, T: Resource> SystemParam for ResMut<'a, T> { if combined_access.has_resource_write(component_id) { panic!( "error[B0002]: ResMut<{}> in system {} conflicts with a previous ResMut<{0}> access. Consider removing the duplicate access. See: https://bevyengine.org/learn/errors/b0002", - core::any::type_name::(), system_meta.name); + core::any::type_name::(), + system_meta.name + ); } else if combined_access.has_resource_read(component_id) { panic!( "error[B0002]: ResMut<{}> in system {} conflicts with a previous Res<{0}> access. Consider removing the duplicate access. See: https://bevyengine.org/learn/errors/b0002", - core::any::type_name::(), system_meta.name); + core::any::type_name::(), + system_meta.name + ); } system_meta .component_access_set @@ -1042,7 +1050,9 @@ unsafe impl SystemParam for &'_ World { .archetype_component_access .is_compatible(&access) { - panic!("&World conflicts with a previous mutable system parameter. Allowing this would break Rust's mutability rules"); + panic!( + "&World conflicts with a previous mutable system parameter. Allowing this would break Rust's mutability rules" + ); } system_meta.archetype_component_access.extend(&access); @@ -1054,7 +1064,9 @@ unsafe impl SystemParam for &'_ World { .get_conflicts_single(&filtered_access) .is_empty() { - panic!("&World conflicts with a previous mutable system parameter. Allowing this would break Rust's mutability rules"); + panic!( + "&World conflicts with a previous mutable system parameter. Allowing this would break Rust's mutability rules" + ); } system_meta.component_access_set.add(filtered_access); } @@ -1612,11 +1624,15 @@ unsafe impl<'a, T: 'static> SystemParam for NonSendMut<'a, T> { if combined_access.has_component_write(component_id) { panic!( "error[B0002]: NonSendMut<{}> in system {} conflicts with a previous mutable resource access ({0}). Consider removing the duplicate access. See: https://bevyengine.org/learn/errors/b0002", - core::any::type_name::(), system_meta.name); + core::any::type_name::(), + system_meta.name + ); } else if combined_access.has_component_read(component_id) { panic!( "error[B0002]: NonSendMut<{}> in system {} conflicts with a previous immutable resource access ({0}). Consider removing the duplicate access. See: https://bevyengine.org/learn/errors/b0002", - core::any::type_name::(), system_meta.name); + core::any::type_name::(), + system_meta.name + ); } system_meta .component_access_set diff --git a/crates/bevy_ecs/src/system/system_registry.rs b/crates/bevy_ecs/src/system/system_registry.rs index 2d849dda95666..52b74ee5d073c 100644 --- a/crates/bevy_ecs/src/system/system_registry.rs +++ b/crates/bevy_ecs/src/system/system_registry.rs @@ -3,11 +3,11 @@ use crate::reflect::ReflectComponent; use crate::{ change_detection::Mut, entity::Entity, - system::{input::SystemInput, BoxedSystem, IntoSystem, System}, + system::{BoxedSystem, IntoSystem, System, input::SystemInput}, world::World, }; use alloc::boxed::Box; -use bevy_ecs_macros::{require, Component, Resource}; +use bevy_ecs_macros::{Component, Resource, require}; #[cfg(feature = "bevy_reflect")] use bevy_reflect::Reflect; use core::marker::PhantomData; @@ -477,7 +477,9 @@ pub enum RegisteredSystemError { /// System could not be run due to parameters that failed validation. /// /// This can occur because the data required by the system was not present in the world. - #[error("The data required by the system {0:?} was not found in the world and the system did not run due to failed parameter validation.")] + #[error( + "The data required by the system {0:?} was not found in the world and the system did not run due to failed parameter validation." + )] InvalidParams(SystemId), } @@ -536,8 +538,8 @@ mod tests { fn local_variables() { // The `Local` begins at the default value of 0 fn doubling(last_counter: Local, mut counter: ResMut) { - counter.0 += last_counter.0 .0; - last_counter.0 .0 = counter.0; + counter.0 += last_counter.0.0; + last_counter.0.0 = counter.0; } let mut world = World::new(); diff --git a/crates/bevy_ecs/src/world/command_queue.rs b/crates/bevy_ecs/src/world/command_queue.rs index e8f820c0661f4..b4f9cf613d060 100644 --- a/crates/bevy_ecs/src/world/command_queue.rs +++ b/crates/bevy_ecs/src/world/command_queue.rs @@ -6,9 +6,9 @@ use alloc::{boxed::Box, vec::Vec}; use bevy_ptr::{OwningPtr, Unaligned}; use core::{ fmt::Debug, - mem::{size_of, MaybeUninit}, + mem::{MaybeUninit, size_of}, panic::AssertUnwindSafe, - ptr::{addr_of_mut, NonNull}, + ptr::{NonNull, addr_of_mut}, }; use log::warn; @@ -311,7 +311,9 @@ impl RawCommandQueue { impl Drop for CommandQueue { fn drop(&mut self) { if !self.bytes.is_empty() { - warn!("CommandQueue has un-applied commands being dropped. Did you forget to call SystemState::apply?"); + warn!( + "CommandQueue has un-applied commands being dropped. Did you forget to call SystemState::apply?" + ); } // SAFETY: A reference is always a valid pointer unsafe { self.get_raw().apply_or_drop_queued(None) }; diff --git a/crates/bevy_ecs/src/world/deferred_world.rs b/crates/bevy_ecs/src/world/deferred_world.rs index 654d35266e29a..9e0622e1500b6 100644 --- a/crates/bevy_ecs/src/world/deferred_world.rs +++ b/crates/bevy_ecs/src/world/deferred_world.rs @@ -12,10 +12,10 @@ use crate::{ resource::Resource, system::{Commands, Query}, traversal::Traversal, - world::{error::EntityMutableFetchError, WorldEntityFetch}, + world::{WorldEntityFetch, error::EntityMutableFetchError}, }; -use super::{unsafe_world_cell::UnsafeWorldCell, Mut, World, ON_INSERT, ON_REPLACE}; +use super::{Mut, ON_INSERT, ON_REPLACE, World, unsafe_world_cell::UnsafeWorldCell}; /// A [`World`] reference that disallows structural ECS changes. /// This includes initializing resources, registering components or spawning entities. diff --git a/crates/bevy_ecs/src/world/entity_fetch.rs b/crates/bevy_ecs/src/world/entity_fetch.rs index e731582f48b85..cddb6effa584d 100644 --- a/crates/bevy_ecs/src/world/entity_fetch.rs +++ b/crates/bevy_ecs/src/world/entity_fetch.rs @@ -2,10 +2,10 @@ use alloc::vec::Vec; use core::mem::MaybeUninit; use crate::{ - entity::{hash_map::EntityHashMap, hash_set::EntityHashSet, Entity, EntityDoesNotExistError}, + entity::{Entity, EntityDoesNotExistError, hash_map::EntityHashMap, hash_set::EntityHashSet}, world::{ - error::EntityMutableFetchError, unsafe_world_cell::UnsafeWorldCell, EntityMut, EntityRef, - EntityWorldMut, + EntityMut, EntityRef, EntityWorldMut, error::EntityMutableFetchError, + unsafe_world_cell::UnsafeWorldCell, }, }; diff --git a/crates/bevy_ecs/src/world/entity_ref.rs b/crates/bevy_ecs/src/world/entity_ref.rs index 17367e56df70f..f36e0c7ff1850 100644 --- a/crates/bevy_ecs/src/world/entity_ref.rs +++ b/crates/bevy_ecs/src/world/entity_ref.rs @@ -18,8 +18,8 @@ use crate::{ storage::Storages, system::IntoObserverSystem, world::{ - error::EntityComponentError, unsafe_world_cell::UnsafeEntityCell, DeferredWorld, Mut, Ref, - World, ON_DESPAWN, ON_REMOVE, ON_REPLACE, + DeferredWorld, Mut, ON_DESPAWN, ON_REMOVE, ON_REPLACE, Ref, World, + error::EntityComponentError, unsafe_world_cell::UnsafeEntityCell, }, }; use alloc::vec::Vec; @@ -4493,8 +4493,8 @@ mod tests { change_detection::{MaybeLocation, MutUntyped}, component::ComponentId, prelude::*, - system::{assert_is_system, RunSystemOnce as _}, - world::{error::EntityComponentError, DeferredWorld, FilteredEntityMut, FilteredEntityRef}, + system::{RunSystemOnce as _, assert_is_system}, + world::{DeferredWorld, FilteredEntityMut, FilteredEntityRef, error::EntityComponentError}, }; use super::{EntityMutExcept, EntityRefExcept}; @@ -5003,9 +5003,11 @@ mod tests { fn system(_: Query<&mut TestComponent>, mut query: Query>) { for mut entity_mut in query.iter_mut() { - assert!(entity_mut - .get_mut::() - .is_some_and(|component| component.0 == 0)); + assert!( + entity_mut + .get_mut::() + .is_some_and(|component| component.0 == 0) + ); } } } @@ -5021,9 +5023,11 @@ mod tests { fn system(_: Query<&mut TestComponent>, mut query: Query>) { for mut entity_mut in query.iter_mut() { - assert!(entity_mut - .get_mut::() - .is_some_and(|component| component.0 == 0)); + assert!( + entity_mut + .get_mut::() + .is_some_and(|component| component.0 == 0) + ); } } } diff --git a/crates/bevy_ecs/src/world/error.rs b/crates/bevy_ecs/src/world/error.rs index 1542a128512d6..d9597a9bbe349 100644 --- a/crates/bevy_ecs/src/world/error.rs +++ b/crates/bevy_ecs/src/world/error.rs @@ -21,7 +21,9 @@ pub struct TryRunScheduleError(pub InternedScheduleLabel); /// [`World::try_insert_batch`]: crate::world::World::try_insert_batch /// [`World::try_insert_batch_if_new`]: crate::world::World::try_insert_batch_if_new #[derive(thiserror::Error, Debug, Clone)] -#[error("Could not insert bundles of type {bundle_type} into the entities with the following IDs because they do not exist: {entities:?}")] +#[error( + "Could not insert bundles of type {bundle_type} into the entities with the following IDs because they do not exist: {entities:?}" +)] pub struct TryInsertBatchError { /// The bundles' type name. pub bundle_type: &'static str, diff --git a/crates/bevy_ecs/src/world/filtered_resource.rs b/crates/bevy_ecs/src/world/filtered_resource.rs index e5197e05703b6..269e3ae000837 100644 --- a/crates/bevy_ecs/src/world/filtered_resource.rs +++ b/crates/bevy_ecs/src/world/filtered_resource.rs @@ -3,7 +3,7 @@ use crate::{ component::{ComponentId, Tick}, query::Access, resource::Resource, - world::{unsafe_world_cell::UnsafeWorldCell, World}, + world::{World, unsafe_world_cell::UnsafeWorldCell}, }; use bevy_ptr::{Ptr, UnsafeCellDeref}; diff --git a/crates/bevy_ecs/src/world/mod.rs b/crates/bevy_ecs/src/world/mod.rs index db812ff1652a7..4ae12262b9c7f 100644 --- a/crates/bevy_ecs/src/world/mod.rs +++ b/crates/bevy_ecs/src/world/mod.rs @@ -15,7 +15,7 @@ pub mod unsafe_world_cell; pub mod reflect; pub use crate::{ - change_detection::{Mut, Ref, CHECK_TICK_THRESHOLD}, + change_detection::{CHECK_TICK_THRESHOLD, Mut, Ref}, world::command_queue::CommandQueue, }; pub use bevy_ecs_macros::FromWorld; @@ -264,7 +264,11 @@ impl World { /// Will panic if `T` exists in any archetypes. pub fn register_component_hooks(&mut self) -> &mut ComponentHooks { let index = self.register_component::(); - assert!(!self.archetypes.archetypes.iter().any(|a| a.contains(index)), "Components hooks cannot be modified if the component already exists in an archetype, use register_component if {} may already be in use", core::any::type_name::()); + assert!( + !self.archetypes.archetypes.iter().any(|a| a.contains(index)), + "Components hooks cannot be modified if the component already exists in an archetype, use register_component if {} may already be in use", + core::any::type_name::() + ); // SAFETY: We just created this component unsafe { self.components.get_hooks_mut(index).debug_checked_unwrap() } } @@ -276,7 +280,11 @@ impl World { &mut self, id: ComponentId, ) -> Option<&mut ComponentHooks> { - assert!(!self.archetypes.archetypes.iter().any(|a| a.contains(id)), "Components hooks cannot be modified if the component already exists in an archetype, use register_component if the component with id {:?} may already be in use", id); + assert!( + !self.archetypes.archetypes.iter().any(|a| a.contains(id)), + "Components hooks cannot be modified if the component already exists in an archetype, use register_component if the component with id {:?} may already be in use", + id + ); self.components.get_hooks_mut(id) } @@ -2396,11 +2404,20 @@ impl World { .insert(entity, location, bundle, insert_mode, caller) }; } else { - panic!("error[B0003]: Could not insert a bundle (of type `{}`) for entity {entity}, which {}. See: https://bevyengine.org/learn/errors/b0003", core::any::type_name::(), self.entities.entity_does_not_exist_error_details(entity)); + panic!( + "error[B0003]: Could not insert a bundle (of type `{}`) for entity {entity}, which {}. See: https://bevyengine.org/learn/errors/b0003", + core::any::type_name::(), + self.entities.entity_does_not_exist_error_details(entity) + ); } } } else { - panic!("error[B0003]: Could not insert a bundle (of type `{}`) for entity {first_entity}, which {}. See: https://bevyengine.org/learn/errors/b0003", core::any::type_name::(), self.entities.entity_does_not_exist_error_details(first_entity)); + panic!( + "error[B0003]: Could not insert a bundle (of type `{}`) for entity {first_entity}, which {}. See: https://bevyengine.org/learn/errors/b0003", + core::any::type_name::(), + self.entities + .entity_does_not_exist_error_details(first_entity) + ); } } } @@ -2626,10 +2643,12 @@ impl World { changed_by: caller.as_mut(), }; let result = f(self, value_mut); - assert!(!self.contains_resource::(), + assert!( + !self.contains_resource::(), "Resource `{}` was inserted during a call to World::resource_scope.\n\ This is not allowed as the original resource is reinserted to the world after the closure is invoked.", - core::any::type_name::()); + core::any::type_name::() + ); OwningPtr::make(value, |ptr| { // SAFETY: pointer is of type R @@ -3423,7 +3442,9 @@ impl World { let old = self.resource_mut::().insert(schedule); if old.is_some() { - warn!("Schedule `{label:?}` was inserted during a call to `World::schedule_scope`: its value has been overwritten"); + warn!( + "Schedule `{label:?}` was inserted during a call to `World::schedule_scope`: its value has been overwritten" + ); } Ok(value) @@ -4149,13 +4170,17 @@ mod tests { assert!(world.get_entity(e1).is_ok()); assert!(world.get_entity([e1, e2]).is_ok()); - assert!(world - .get_entity(&[e1, e2] /* this is an array not a slice */) - .is_ok()); + assert!( + world + .get_entity(&[e1, e2] /* this is an array not a slice */) + .is_ok() + ); assert!(world.get_entity(&vec![e1, e2][..]).is_ok()); - assert!(world - .get_entity(&EntityHashSet::from_iter([e1, e2])) - .is_ok()); + assert!( + world + .get_entity(&EntityHashSet::from_iter([e1, e2])) + .is_ok() + ); world.entity_mut(e1).despawn(); @@ -4199,13 +4224,17 @@ mod tests { assert!(world.get_entity_mut(e1).is_ok()); assert!(world.get_entity_mut([e1, e2]).is_ok()); - assert!(world - .get_entity_mut(&[e1, e2] /* this is an array not a slice */) - .is_ok()); + assert!( + world + .get_entity_mut(&[e1, e2] /* this is an array not a slice */) + .is_ok() + ); assert!(world.get_entity_mut(&vec![e1, e2][..]).is_ok()); - assert!(world - .get_entity_mut(&EntityHashSet::from_iter([e1, e2])) - .is_ok()); + assert!( + world + .get_entity_mut(&EntityHashSet::from_iter([e1, e2])) + .is_ok() + ); assert_eq!( Err(EntityMutableFetchError::AliasedMutability(e1)), @@ -4222,9 +4251,11 @@ mod tests { world.get_entity_mut(&vec![e1, e2, e1][..]).map(|_| {}) ); // Aliased mutability isn't allowed by HashSets - assert!(world - .get_entity_mut(&EntityHashSet::from_iter([e1, e2, e1])) - .is_ok()); + assert!( + world + .get_entity_mut(&EntityHashSet::from_iter([e1, e2, e1])) + .is_ok() + ); world.entity_mut(e1).despawn(); diff --git a/crates/bevy_ecs/src/world/reflect.rs b/crates/bevy_ecs/src/world/reflect.rs index 4337416aa2dc9..a8df06e1e781c 100644 --- a/crates/bevy_ecs/src/world/reflect.rs +++ b/crates/bevy_ecs/src/world/reflect.rs @@ -213,7 +213,9 @@ pub enum GetComponentReflectError { NoCorrespondingComponentId(TypeId), /// The given [`Entity`] does not have a [`Component`] corresponding to the given [`TypeId`]. - #[error("The given `Entity` {entity} does not have a `{component_name:?}` component ({component_id:?}, which corresponds to {type_id:?})")] + #[error( + "The given `Entity` {entity} does not have a `{component_name:?}` component ({component_id:?}, which corresponds to {type_id:?})" + )] EntityDoesNotHaveComponent { /// The given [`Entity`]. entity: Entity, @@ -241,7 +243,9 @@ pub enum GetComponentReflectError { /// [`TypeRegistry`]: bevy_reflect::TypeRegistry /// [`ReflectFromPtr`]: bevy_reflect::ReflectFromPtr /// [`App::register_type`]: ../../../bevy_app/struct.App.html#method.register_type - #[error("The `World`'s `TypeRegistry` did not contain `TypeData` for `ReflectFromPtr` for the given {0:?} (did you call `App::register_type()`?)")] + #[error( + "The `World`'s `TypeRegistry` did not contain `TypeData` for `ReflectFromPtr` for the given {0:?} (did you call `App::register_type()`?)" + )] MissingReflectFromPtrTypeData(TypeId), } diff --git a/crates/bevy_gilrs/src/gilrs_system.rs b/crates/bevy_gilrs/src/gilrs_system.rs index 05f9aa02e9692..1bb900e8bbce9 100644 --- a/crates/bevy_gilrs/src/gilrs_system.rs +++ b/crates/bevy_gilrs/src/gilrs_system.rs @@ -1,6 +1,6 @@ use crate::{ - converter::{convert_axis, convert_button}, Gilrs, GilrsGamepads, + converter::{convert_axis, convert_button}, }; use bevy_ecs::event::EventWriter; use bevy_ecs::prelude::Commands; @@ -11,7 +11,7 @@ use bevy_input::gamepad::{ GamepadConnection, GamepadConnectionEvent, RawGamepadAxisChangedEvent, RawGamepadButtonChangedEvent, RawGamepadEvent, }; -use gilrs::{ev::filter::axis_dpad_to_button, EventType, Filter}; +use gilrs::{EventType, Filter, ev::filter::axis_dpad_to_button}; pub fn gilrs_event_startup_system( mut commands: Commands, diff --git a/crates/bevy_gilrs/src/lib.rs b/crates/bevy_gilrs/src/lib.rs index b9f1443e5b245..3b143173f2aad 100644 --- a/crates/bevy_gilrs/src/lib.rs +++ b/crates/bevy_gilrs/src/lib.rs @@ -22,7 +22,7 @@ use bevy_platform_support::collections::HashMap; use bevy_utils::synccell::SyncCell; use gilrs::GilrsBuilder; use gilrs_system::{gilrs_event_startup_system, gilrs_event_system}; -use rumble::{play_gilrs_rumble, RunningRumbleEffects}; +use rumble::{RunningRumbleEffects, play_gilrs_rumble}; use tracing::error; #[cfg_attr(not(target_arch = "wasm32"), derive(Resource))] diff --git a/crates/bevy_gilrs/src/rumble.rs b/crates/bevy_gilrs/src/rumble.rs index 53a0c945cedef..e91fa7b1d6006 100644 --- a/crates/bevy_gilrs/src/rumble.rs +++ b/crates/bevy_gilrs/src/rumble.rs @@ -9,8 +9,8 @@ use bevy_time::{Real, Time}; use bevy_utils::synccell::SyncCell; use core::time::Duration; use gilrs::{ - ff::{self, BaseEffect, BaseEffectType, Repeat, Replay}, GamepadId, + ff::{self, BaseEffect, BaseEffectType, Repeat, Replay}, }; use thiserror::Error; use tracing::{debug, warn}; @@ -155,7 +155,7 @@ pub(crate) fn play_gilrs_rumble( debug!("Tried to rumble {gamepad:?}, but it doesn't support force feedback"); } else { warn!( - "Tried to handle rumble request for {gamepad:?} but an error occurred: {err}" + "Tried to handle rumble request for {gamepad:?} but an error occurred: {err}" ); } } diff --git a/crates/bevy_gizmos/macros/src/lib.rs b/crates/bevy_gizmos/macros/src/lib.rs index 441882d4b01ab..464f4ad0d0240 100644 --- a/crates/bevy_gizmos/macros/src/lib.rs +++ b/crates/bevy_gizmos/macros/src/lib.rs @@ -5,7 +5,7 @@ use bevy_macro_utils::BevyManifest; use proc_macro::TokenStream; use quote::quote; -use syn::{parse_macro_input, parse_quote, DeriveInput, Path}; +use syn::{DeriveInput, Path, parse_macro_input, parse_quote}; /// Implements the [`GizmoConfigGroup`] trait for a gizmo config group type. #[proc_macro_derive(GizmoConfigGroup)] diff --git a/crates/bevy_gizmos/src/aabb.rs b/crates/bevy_gizmos/src/aabb.rs index 605a4c2e88c6a..c2430f11ccf1d 100644 --- a/crates/bevy_gizmos/src/aabb.rs +++ b/crates/bevy_gizmos/src/aabb.rs @@ -10,17 +10,17 @@ use bevy_ecs::{ schedule::IntoSystemConfigs, system::{Query, Res}, }; -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; use bevy_render::primitives::Aabb; use bevy_transform::{ - components::{GlobalTransform, Transform}, TransformSystem, + components::{GlobalTransform, Transform}, }; use crate::{ + AppGizmoBuilder, config::{GizmoConfigGroup, GizmoConfigStore}, gizmos::Gizmos, - AppGizmoBuilder, }; /// A [`Plugin`] that provides visualization of [`Aabb`]s for debugging. diff --git a/crates/bevy_gizmos/src/arrows.rs b/crates/bevy_gizmos/src/arrows.rs index 74fbdc97262b5..ac20e6712bbf0 100644 --- a/crates/bevy_gizmos/src/arrows.rs +++ b/crates/bevy_gizmos/src/arrows.rs @@ -5,8 +5,8 @@ use crate::{gizmos::GizmoBuffer, prelude::GizmoConfigGroup}; use bevy_color::{ - palettes::basic::{BLUE, GREEN, RED}, Color, + palettes::basic::{BLUE, GREEN, RED}, }; use bevy_math::{Quat, Vec2, Vec3, Vec3Swizzles}; use bevy_transform::TransformPoint; diff --git a/crates/bevy_gizmos/src/circles.rs b/crates/bevy_gizmos/src/circles.rs index e5a49398083ab..1adddb442f76b 100644 --- a/crates/bevy_gizmos/src/circles.rs +++ b/crates/bevy_gizmos/src/circles.rs @@ -5,7 +5,7 @@ use crate::{gizmos::GizmoBuffer, prelude::GizmoConfigGroup}; use bevy_color::Color; -use bevy_math::{ops, Isometry2d, Isometry3d, Quat, Vec2, Vec3}; +use bevy_math::{Isometry2d, Isometry3d, Quat, Vec2, Vec3, ops}; use core::f32::consts::TAU; pub(crate) const DEFAULT_CIRCLE_RESOLUTION: u32 = 32; diff --git a/crates/bevy_gizmos/src/config.rs b/crates/bevy_gizmos/src/config.rs index bba3ff284cb2e..4d98457688b14 100644 --- a/crates/bevy_gizmos/src/config.rs +++ b/crates/bevy_gizmos/src/config.rs @@ -9,7 +9,7 @@ pub use bevy_gizmos_macros::GizmoConfigGroup; use {crate::GizmoAsset, bevy_asset::Handle, bevy_ecs::component::Component}; use bevy_ecs::{reflect::ReflectResource, resource::Resource}; -use bevy_reflect::{std_traits::ReflectDefault, Reflect, TypePath}; +use bevy_reflect::{Reflect, TypePath, std_traits::ReflectDefault}; use bevy_utils::TypeIdMap; use core::{ any::TypeId, @@ -111,7 +111,10 @@ impl GizmoConfigStore { /// Returns [`GizmoConfig`] and [`GizmoConfigGroup`] associated with [`GizmoConfigGroup`] `T` pub fn config(&self) -> (&GizmoConfig, &T) { let Some((config, ext)) = self.get_config_dyn(&TypeId::of::()) else { - panic!("Requested config {} does not exist in `GizmoConfigStore`! Did you forget to add it using `app.init_gizmo_group()`?", T::type_path()); + panic!( + "Requested config {} does not exist in `GizmoConfigStore`! Did you forget to add it using `app.init_gizmo_group()`?", + T::type_path() + ); }; // hash map invariant guarantees that &dyn Reflect is of correct type T let ext = ext.as_any().downcast_ref().unwrap(); @@ -130,7 +133,10 @@ impl GizmoConfigStore { /// Returns mutable [`GizmoConfig`] and [`GizmoConfigGroup`] associated with [`GizmoConfigGroup`] `T` pub fn config_mut(&mut self) -> (&mut GizmoConfig, &mut T) { let Some((config, ext)) = self.get_config_mut_dyn(&TypeId::of::()) else { - panic!("Requested config {} does not exist in `GizmoConfigStore`! Did you forget to add it using `app.init_gizmo_group()`?", T::type_path()); + panic!( + "Requested config {} does not exist in `GizmoConfigStore`! Did you forget to add it using `app.init_gizmo_group()`?", + T::type_path() + ); }; // hash map invariant guarantees that &dyn Reflect is of correct type T let ext = ext.as_any_mut().downcast_mut().unwrap(); diff --git a/crates/bevy_gizmos/src/curves.rs b/crates/bevy_gizmos/src/curves.rs index 2d7a350ca29dc..f2b106a17196d 100644 --- a/crates/bevy_gizmos/src/curves.rs +++ b/crates/bevy_gizmos/src/curves.rs @@ -5,8 +5,8 @@ use bevy_color::Color; use bevy_math::{ - curve::{Curve, CurveExt}, Vec2, Vec3, + curve::{Curve, CurveExt}, }; use crate::{gizmos::GizmoBuffer, prelude::GizmoConfigGroup}; diff --git a/crates/bevy_gizmos/src/gizmos.rs b/crates/bevy_gizmos/src/gizmos.rs index b1fe363f510cb..9762569e13f78 100644 --- a/crates/bevy_gizmos/src/gizmos.rs +++ b/crates/bevy_gizmos/src/gizmos.rs @@ -12,7 +12,7 @@ use bevy_ecs::{ component::Tick, resource::Resource, system::{Deferred, ReadOnlySystemParam, Res, SystemBuffer, SystemMeta, SystemParam}, - world::{unsafe_world_cell::UnsafeWorldCell, World}, + world::{World, unsafe_world_cell::UnsafeWorldCell}, }; use bevy_math::{Isometry2d, Isometry3d, Vec2, Vec3}; use bevy_reflect::Reflect; diff --git a/crates/bevy_gizmos/src/grid.rs b/crates/bevy_gizmos/src/grid.rs index 42742e196c77c..f76eac9be4cc5 100644 --- a/crates/bevy_gizmos/src/grid.rs +++ b/crates/bevy_gizmos/src/grid.rs @@ -5,7 +5,7 @@ use crate::{gizmos::GizmoBuffer, prelude::GizmoConfigGroup}; use bevy_color::Color; -use bevy_math::{ops, Isometry2d, Isometry3d, Quat, UVec2, UVec3, Vec2, Vec3, Vec3Swizzles}; +use bevy_math::{Isometry2d, Isometry3d, Quat, UVec2, UVec3, Vec2, Vec3, Vec3Swizzles, ops}; /// A builder returned by [`GizmoBuffer::grid_3d`] pub struct GridBuilder3d<'a, Config, Clear> @@ -365,11 +365,7 @@ fn draw_grid( #[inline] fn or_zero(cond: bool, val: Vec3) -> Vec3 { - if cond { - val - } else { - Vec3::ZERO - } + if cond { val } else { Vec3::ZERO } } // Offset between two adjacent grid cells along the x/y-axis and accounting for skew. diff --git a/crates/bevy_gizmos/src/lib.rs b/crates/bevy_gizmos/src/lib.rs index fdc2243233916..3582c5346026b 100644 --- a/crates/bevy_gizmos/src/lib.rs +++ b/crates/bevy_gizmos/src/lib.rs @@ -64,6 +64,7 @@ pub mod prelude { #[doc(hidden)] pub use crate::{ + AppGizmoBuilder, GizmoAsset, config::{ DefaultGizmoConfigGroup, GizmoConfig, GizmoConfigGroup, GizmoConfigStore, GizmoLineConfig, GizmoLineJoint, GizmoLineStyle, @@ -71,7 +72,6 @@ pub mod prelude { gizmos::Gizmos, primitives::{dim2::GizmoPrimitive2d, dim3::GizmoPrimitive3d}, retained::Gizmo, - AppGizmoBuilder, GizmoAsset, }; #[cfg(all(feature = "bevy_pbr", feature = "bevy_render"))] @@ -79,7 +79,7 @@ pub mod prelude { } use bevy_app::{App, FixedFirst, FixedLast, Last, Plugin, RunFixedMainLoop}; -use bevy_asset::{weak_handle, Asset, AssetApp, AssetId, Assets, Handle}; +use bevy_asset::{Asset, AssetApp, AssetId, Assets, Handle, weak_handle}; use bevy_ecs::{ resource::Resource, schedule::{IntoSystemConfigs, SystemSet}, @@ -104,23 +104,23 @@ use { entity::Entity, query::ROQueryItem, system::{ - lifetimeless::{Read, SRes}, Commands, SystemParamItem, + lifetimeless::{Read, SRes}, }, }, bevy_math::{Affine3, Affine3A}, bevy_render::{ + Extract, ExtractSchedule, Render, RenderApp, RenderSet, extract_component::{ComponentUniforms, DynamicUniformIndex, UniformComponentPlugin}, render_asset::{PrepareAssetError, RenderAsset, RenderAssetPlugin, RenderAssets}, render_phase::{PhaseItem, RenderCommand, RenderCommandResult, TrackedRenderPass}, render_resource::{ - binding_types::uniform_buffer, BindGroup, BindGroupEntries, BindGroupLayout, - BindGroupLayoutEntries, Buffer, BufferInitDescriptor, BufferUsages, Shader, - ShaderStages, ShaderType, VertexFormat, + BindGroup, BindGroupEntries, BindGroupLayout, BindGroupLayoutEntries, Buffer, + BufferInitDescriptor, BufferUsages, Shader, ShaderStages, ShaderType, VertexFormat, + binding_types::uniform_buffer, }, renderer::RenderDevice, sync_world::{MainEntity, TemporaryRenderEntity}, - Extract, ExtractSchedule, Render, RenderApp, RenderSet, }, bytemuck::cast_slice, }; @@ -194,16 +194,22 @@ impl Plugin for GizmoPlugin { if app.is_plugin_added::() { app.add_plugins(pipeline_2d::LineGizmo2dPlugin); } else { - tracing::warn!("bevy_sprite feature is enabled but bevy_sprite::SpritePlugin was not detected. Are you sure you loaded GizmoPlugin after SpritePlugin?"); + tracing::warn!( + "bevy_sprite feature is enabled but bevy_sprite::SpritePlugin was not detected. Are you sure you loaded GizmoPlugin after SpritePlugin?" + ); } #[cfg(feature = "bevy_pbr")] if app.is_plugin_added::() { app.add_plugins(pipeline_3d::LineGizmo3dPlugin); } else { - tracing::warn!("bevy_pbr feature is enabled but bevy_pbr::PbrPlugin was not detected. Are you sure you loaded GizmoPlugin after PbrPlugin?"); + tracing::warn!( + "bevy_pbr feature is enabled but bevy_pbr::PbrPlugin was not detected. Are you sure you loaded GizmoPlugin after PbrPlugin?" + ); } } else { - tracing::warn!("bevy_render feature is enabled but RenderApp was not detected. Are you sure you loaded GizmoPlugin after RenderPlugin?"); + tracing::warn!( + "bevy_render feature is enabled but RenderApp was not detected. Are you sure you loaded GizmoPlugin after RenderPlugin?" + ); } } @@ -453,10 +459,14 @@ fn extract_gizmo_data( } = config.line.style { if gap_scale <= 0.0 { - once!(warn!("When using gizmos with the line style `GizmoLineStyle::Dashed{{..}}` the gap scale should be greater than zero.")); + once!(warn!( + "When using gizmos with the line style `GizmoLineStyle::Dashed{{..}}` the gap scale should be greater than zero." + )); } if line_scale <= 0.0 { - once!(warn!("When using gizmos with the line style `GizmoLineStyle::Dashed{{..}}` the line scale should be greater than zero.")); + once!(warn!( + "When using gizmos with the line style `GizmoLineStyle::Dashed{{..}}` the line scale should be greater than zero." + )); } (gap_scale, line_scale) } else { diff --git a/crates/bevy_gizmos/src/light.rs b/crates/bevy_gizmos/src/light.rs index d6df0b7d3bb20..dc01045fd2ecc 100644 --- a/crates/bevy_gizmos/src/light.rs +++ b/crates/bevy_gizmos/src/light.rs @@ -6,8 +6,8 @@ use crate::primitives::dim3::GizmoPrimitive3d; use bevy_app::{Plugin, PostUpdate}; use bevy_color::{ - palettes::basic::{BLUE, GREEN, RED}, Color, Oklcha, + palettes::basic::{BLUE, GREEN, RED}, }; use bevy_ecs::{ component::Component, @@ -18,18 +18,17 @@ use bevy_ecs::{ system::{Query, Res}, }; use bevy_math::{ - ops, + Isometry3d, Quat, Vec3, ops, primitives::{Cone, Sphere}, - Isometry3d, Quat, Vec3, }; use bevy_pbr::{DirectionalLight, PointLight, SpotLight}; -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; -use bevy_transform::{components::GlobalTransform, TransformSystem}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_transform::{TransformSystem, components::GlobalTransform}; use crate::{ + AppGizmoBuilder, config::{GizmoConfigGroup, GizmoConfigStore}, gizmos::Gizmos, - AppGizmoBuilder, }; /// Draws a standard sphere for the radius and an axis sphere for the range. diff --git a/crates/bevy_gizmos/src/pipeline_2d.rs b/crates/bevy_gizmos/src/pipeline_2d.rs index 72a2428ff0b5b..ea7ff04838f39 100644 --- a/crates/bevy_gizmos/src/pipeline_2d.rs +++ b/crates/bevy_gizmos/src/pipeline_2d.rs @@ -1,11 +1,11 @@ use crate::{ + DrawLineGizmo, DrawLineJointGizmo, GizmoRenderSystem, GpuLineGizmo, LINE_JOINT_SHADER_HANDLE, + LINE_SHADER_HANDLE, LineGizmoUniformBindgroupLayout, SetLineGizmoBindGroup, config::{GizmoLineJoint, GizmoLineStyle, GizmoMeshConfig}, - line_gizmo_vertex_buffer_layouts, line_joint_gizmo_vertex_buffer_layouts, DrawLineGizmo, - DrawLineJointGizmo, GizmoRenderSystem, GpuLineGizmo, LineGizmoUniformBindgroupLayout, - SetLineGizmoBindGroup, LINE_JOINT_SHADER_HANDLE, LINE_SHADER_HANDLE, + line_gizmo_vertex_buffer_layouts, line_joint_gizmo_vertex_buffer_layouts, }; use bevy_app::{App, Plugin}; -use bevy_core_pipeline::core_2d::{Transparent2d, CORE_2D_DEPTH_FORMAT}; +use bevy_core_pipeline::core_2d::{CORE_2D_DEPTH_FORMAT, Transparent2d}; use bevy_ecs::{ prelude::Entity, @@ -18,14 +18,14 @@ use bevy_image::BevyDefault as _; use bevy_math::FloatOrd; use bevy_render::sync_world::MainEntity; use bevy_render::{ - render_asset::{prepare_assets, RenderAssets}, + Render, RenderApp, RenderSet, + render_asset::{RenderAssets, prepare_assets}, render_phase::{ AddRenderCommand, DrawFunctions, PhaseItemExtraIndex, SetItemPipeline, ViewSortedRenderPhases, }, render_resource::*, view::{ExtractedView, Msaa, RenderLayers, ViewTarget}, - Render, RenderApp, RenderSet, }; use bevy_sprite::{Mesh2dPipeline, Mesh2dPipelineKey, SetMesh2dViewBindGroup}; use tracing::error; @@ -214,7 +214,9 @@ impl SpecializedRenderPipeline for LineJointGizmoPipeline { ]; if key.joints == GizmoLineJoint::None { - error!("There is no entry point for line joints with GizmoLineJoints::None. Please consider aborting the drawing process before reaching this stage."); + error!( + "There is no entry point for line joints with GizmoLineJoints::None. Please consider aborting the drawing process before reaching this stage." + ); }; let entry_point = match key.joints { diff --git a/crates/bevy_gizmos/src/pipeline_3d.rs b/crates/bevy_gizmos/src/pipeline_3d.rs index f7806b64d65bf..e96c97252a058 100644 --- a/crates/bevy_gizmos/src/pipeline_3d.rs +++ b/crates/bevy_gizmos/src/pipeline_3d.rs @@ -1,12 +1,12 @@ use crate::{ + DrawLineGizmo, DrawLineJointGizmo, GizmoRenderSystem, GpuLineGizmo, LINE_JOINT_SHADER_HANDLE, + LINE_SHADER_HANDLE, LineGizmoUniformBindgroupLayout, SetLineGizmoBindGroup, config::{GizmoLineJoint, GizmoLineStyle, GizmoMeshConfig}, - line_gizmo_vertex_buffer_layouts, line_joint_gizmo_vertex_buffer_layouts, DrawLineGizmo, - DrawLineJointGizmo, GizmoRenderSystem, GpuLineGizmo, LineGizmoUniformBindgroupLayout, - SetLineGizmoBindGroup, LINE_JOINT_SHADER_HANDLE, LINE_SHADER_HANDLE, + line_gizmo_vertex_buffer_layouts, line_joint_gizmo_vertex_buffer_layouts, }; use bevy_app::{App, Plugin}; use bevy_core_pipeline::{ - core_3d::{Transparent3d, CORE_3D_DEPTH_FORMAT}, + core_3d::{CORE_3D_DEPTH_FORMAT, Transparent3d}, prepass::{DeferredPrepass, DepthPrepass, MotionVectorPrepass, NormalPrepass}, }; @@ -22,14 +22,14 @@ use bevy_image::BevyDefault as _; use bevy_pbr::{MeshPipeline, MeshPipelineKey, SetMeshViewBindGroup}; use bevy_render::sync_world::MainEntity; use bevy_render::{ - render_asset::{prepare_assets, RenderAssets}, + Render, RenderApp, RenderSet, + render_asset::{RenderAssets, prepare_assets}, render_phase::{ AddRenderCommand, DrawFunctions, PhaseItemExtraIndex, SetItemPipeline, ViewSortedRenderPhases, }, render_resource::*, view::{ExtractedView, Msaa, RenderLayers, ViewTarget}, - Render, RenderApp, RenderSet, }; use tracing::error; @@ -218,7 +218,9 @@ impl SpecializedRenderPipeline for LineJointGizmoPipeline { let layout = vec![view_layout, self.uniform_layout.clone()]; if key.joints == GizmoLineJoint::None { - error!("There is no entry point for line joints with GizmoLineJoints::None. Please consider aborting the drawing process before reaching this stage."); + error!( + "There is no entry point for line joints with GizmoLineJoints::None. Please consider aborting the drawing process before reaching this stage." + ); }; let entry_point = match key.joints { diff --git a/crates/bevy_gizmos/src/primitives/dim2.rs b/crates/bevy_gizmos/src/primitives/dim2.rs index d38ba3ab4ca95..5cfdfd46b0bfb 100644 --- a/crates/bevy_gizmos/src/primitives/dim2.rs +++ b/crates/bevy_gizmos/src/primitives/dim2.rs @@ -6,12 +6,12 @@ use super::helpers::*; use bevy_color::Color; use bevy_math::{ + Dir2, Isometry2d, Rot2, Vec2, primitives::{ Annulus, Arc2d, BoxedPolygon, BoxedPolyline2d, Capsule2d, Circle, CircularSector, CircularSegment, Ellipse, Line2d, Plane2d, Polygon, Polyline2d, Primitive2d, Rectangle, RegularPolygon, Rhombus, Segment2d, Triangle2d, }, - Dir2, Isometry2d, Rot2, Vec2, }; use crate::{gizmos::GizmoBuffer, prelude::GizmoConfigGroup}; @@ -389,7 +389,14 @@ where } // transform points from the reference unit square to capsule "rectangle" - let [top_left, top_right, bottom_left, bottom_right, top_center, bottom_center] = [ + let [ + top_left, + top_right, + bottom_left, + bottom_right, + top_center, + bottom_center, + ] = [ [-1.0, 1.0], [1.0, 1.0], [-1.0, -1.0], diff --git a/crates/bevy_gizmos/src/primitives/dim3.rs b/crates/bevy_gizmos/src/primitives/dim3.rs index 31a2274e841b4..16caa39b33a4d 100644 --- a/crates/bevy_gizmos/src/primitives/dim3.rs +++ b/crates/bevy_gizmos/src/primitives/dim3.rs @@ -4,11 +4,11 @@ use super::helpers::*; use bevy_color::Color; use bevy_math::{ + Dir3, Isometry3d, Quat, UVec2, Vec2, Vec3, primitives::{ BoxedPolyline3d, Capsule3d, Cone, ConicalFrustum, Cuboid, Cylinder, Line3d, Plane3d, Polyline3d, Primitive3d, Segment3d, Sphere, Tetrahedron, Torus, Triangle3d, }, - Dir3, Isometry3d, Quat, UVec2, Vec2, Vec3, }; use crate::{circles::SphereBuilder, gizmos::GizmoBuffer, prelude::GizmoConfigGroup}; diff --git a/crates/bevy_gizmos/src/primitives/helpers.rs b/crates/bevy_gizmos/src/primitives/helpers.rs index 37253b14a9ac9..fdbaa223852bf 100644 --- a/crates/bevy_gizmos/src/primitives/helpers.rs +++ b/crates/bevy_gizmos/src/primitives/helpers.rs @@ -1,6 +1,6 @@ use core::f32::consts::TAU; -use bevy_math::{ops, Vec2}; +use bevy_math::{Vec2, ops}; /// Calculates the `nth` coordinate of a circle. /// diff --git a/crates/bevy_gizmos/src/retained.rs b/crates/bevy_gizmos/src/retained.rs index 435f417552463..b41f592210d88 100644 --- a/crates/bevy_gizmos/src/retained.rs +++ b/crates/bevy_gizmos/src/retained.rs @@ -4,7 +4,7 @@ use core::ops::{Deref, DerefMut}; use bevy_asset::Handle; use bevy_ecs::{ - component::{require, Component}, + component::{Component, require}, reflect::ReflectComponent, }; use bevy_reflect::Reflect; @@ -12,19 +12,19 @@ use bevy_transform::components::Transform; #[cfg(feature = "bevy_render")] use { - crate::{config::GizmoLineJoint, LineGizmoUniform}, + crate::{LineGizmoUniform, config::GizmoLineJoint}, bevy_ecs::{ entity::Entity, system::{Commands, Local, Query}, }, - bevy_render::{view::RenderLayers, Extract}, + bevy_render::{Extract, view::RenderLayers}, bevy_transform::components::GlobalTransform, }; use crate::{ + GizmoAsset, config::{ErasedGizmoConfigGroup, GizmoLineConfig}, gizmos::GizmoBuffer, - GizmoAsset, }; impl Deref for GizmoAsset { @@ -125,10 +125,14 @@ pub(crate) fn extract_linegizmos( } = gizmo.line_config.style { if gap_scale <= 0.0 { - once!(warn!("when using gizmos with the line style `GizmoLineStyle::Dashed{{..}}` the gap scale should be greater than zero")); + once!(warn!( + "when using gizmos with the line style `GizmoLineStyle::Dashed{{..}}` the gap scale should be greater than zero" + )); } if line_scale <= 0.0 { - once!(warn!("when using gizmos with the line style `GizmoLineStyle::Dashed{{..}}` the line scale should be greater than zero")); + once!(warn!( + "when using gizmos with the line style `GizmoLineStyle::Dashed{{..}}` the line scale should be greater than zero" + )); } (gap_scale, line_scale) } else { diff --git a/crates/bevy_gltf/src/lib.rs b/crates/bevy_gltf/src/lib.rs index 27f0ad00bbc47..b52768aedd2b6 100644 --- a/crates/bevy_gltf/src/lib.rs +++ b/crates/bevy_gltf/src/lib.rs @@ -105,9 +105,9 @@ use bevy_asset::{Asset, AssetApp, AssetPath, Handle}; use bevy_ecs::{prelude::Component, reflect::ReflectComponent}; use bevy_image::CompressedImageFormats; use bevy_pbr::StandardMaterial; -use bevy_reflect::{std_traits::ReflectDefault, Reflect, TypePath}; +use bevy_reflect::{Reflect, TypePath, std_traits::ReflectDefault}; use bevy_render::{ - mesh::{skinning::SkinnedMeshInverseBindposes, Mesh, MeshVertexAttribute}, + mesh::{Mesh, MeshVertexAttribute, skinning::SkinnedMeshInverseBindposes}, renderer::RenderDevice, }; use bevy_scene::Scene; diff --git a/crates/bevy_gltf/src/loader.rs b/crates/bevy_gltf/src/loader.rs index 1a8e170ee793f..9ffe7e6ec7cdb 100644 --- a/crates/bevy_gltf/src/loader.rs +++ b/crates/bevy_gltf/src/loader.rs @@ -1,15 +1,15 @@ use crate::{ - vertex_attributes::convert_attribute, Gltf, GltfAssetLabel, GltfExtras, GltfMaterialExtras, - GltfMaterialName, GltfMeshExtras, GltfNode, GltfSceneExtras, GltfSkin, + Gltf, GltfAssetLabel, GltfExtras, GltfMaterialExtras, GltfMaterialName, GltfMeshExtras, + GltfNode, GltfSceneExtras, GltfSkin, vertex_attributes::convert_attribute, }; use bevy_asset::{ - io::Reader, AssetLoadError, AssetLoader, Handle, LoadContext, ReadAssetBytesError, + AssetLoadError, AssetLoader, Handle, LoadContext, ReadAssetBytesError, io::Reader, }; use bevy_color::{Color, LinearRgba}; use bevy_core_pipeline::prelude::Camera3d; use bevy_ecs::{ - entity::{hash_map::EntityHashMap, Entity}, + entity::{Entity, hash_map::EntityHashMap}, hierarchy::ChildSpawner, name::Name, world::World, @@ -20,17 +20,17 @@ use bevy_image::{ }; use bevy_math::{Affine2, Mat4, Vec3}; use bevy_pbr::{ - DirectionalLight, MeshMaterial3d, PointLight, SpotLight, StandardMaterial, UvChannel, - MAX_JOINTS, + DirectionalLight, MAX_JOINTS, MeshMaterial3d, PointLight, SpotLight, StandardMaterial, + UvChannel, }; use bevy_platform_support::collections::{HashMap, HashSet}; use bevy_render::{ alpha::AlphaMode, camera::{Camera, OrthographicProjection, PerspectiveProjection, Projection, ScalingMode}, mesh::{ + Indices, Mesh, Mesh3d, MeshVertexAttribute, VertexAttributeValues, morph::{MeshMorphWeights, MorphAttributes, MorphTargetImage, MorphWeights}, skinning::{SkinnedMesh, SkinnedMeshInverseBindposes}, - Indices, Mesh, Mesh3d, MeshVertexAttribute, VertexAttributeValues, }, primitives::Aabb, render_asset::RenderAssetUsages, @@ -43,12 +43,12 @@ use bevy_tasks::IoTaskPool; use bevy_transform::components::Transform; use fixedbitset::FixedBitSet; use gltf::{ + Document, Material, Node, Primitive, Semantic, accessor::Iter, image::Source, json, - mesh::{util::ReadIndices, Mode}, + mesh::{Mode, util::ReadIndices}, texture::{Info, MagFilter, MinFilter, TextureTransform, WrappingMode}, - Document, Material, Node, Primitive, Semantic, }; use itertools::Itertools; use serde::{Deserialize, Serialize}; @@ -57,7 +57,7 @@ use serde::{Deserialize, Serialize}; feature = "pbr_multi_layer_material_textures" ))] use serde_json::Map; -use serde_json::{value, Value}; +use serde_json::{Value, value}; use std::{ io::Error, path::{Path, PathBuf}, @@ -66,7 +66,7 @@ use thiserror::Error; use tracing::{error, info_span, warn}; #[cfg(feature = "bevy_animation")] use { - bevy_animation::{prelude::*, AnimationTarget, AnimationTargetId}, + bevy_animation::{AnimationTarget, AnimationTargetId, prelude::*}, smallvec::SmallVec, }; @@ -275,10 +275,10 @@ async fn load_gltf<'a, 'b, 'c>( #[cfg(feature = "bevy_animation")] let (animations, named_animations, animation_roots) = { - use bevy_animation::{animated_field, animation_curves::*, gltf_curves::*, VariableCurve}; + use bevy_animation::{VariableCurve, animated_field, animation_curves::*, gltf_curves::*}; use bevy_math::{ - curve::{ConstantCurve, Interval, UnevenSampleAutoCurve}, Quat, Vec4, + curve::{ConstantCurve, Interval, UnevenSampleAutoCurve}, }; use gltf::animation::util::ReadOutputs; let mut animations = vec![]; @@ -653,13 +653,15 @@ async fn load_gltf<'a, 'b, 'c>( if [Semantic::Joints(0), Semantic::Weights(0)].contains(&semantic) { if !meshes_on_skinned_nodes.contains(&gltf_mesh.index()) { warn!( - "Ignoring attribute {:?} for skinned mesh {} used on non skinned nodes (NODE_SKINNED_MESH_WITHOUT_SKIN)", - semantic, - primitive_label - ); + "Ignoring attribute {:?} for skinned mesh {} used on non skinned nodes (NODE_SKINNED_MESH_WITHOUT_SKIN)", + semantic, primitive_label + ); continue; } else if meshes_on_non_skinned_nodes.contains(&gltf_mesh.index()) { - error!("Skinned mesh {} used on both skinned and non skin nodes, this is likely to cause an error (NODE_SKINNED_MESH_WITHOUT_SKIN)", primitive_label); + error!( + "Skinned mesh {} used on both skinned and non skin nodes, this is likely to cause an error (NODE_SKINNED_MESH_WITHOUT_SKIN)", + primitive_label + ); } } match convert_attribute( @@ -717,7 +719,11 @@ async fn load_gltf<'a, 'b, 'c>( mesh.compute_flat_normals(); let vertex_count_after = mesh.count_vertices(); if vertex_count_before != vertex_count_after { - tracing::debug!("Missing vertex normals in indexed geometry, computing them as flat. Vertex count increased from {} to {}", vertex_count_before, vertex_count_after); + tracing::debug!( + "Missing vertex normals in indexed geometry, computing them as flat. Vertex count increased from {} to {}", + vertex_count_before, + vertex_count_after + ); } else { tracing::debug!( "Missing vertex normals in indexed geometry, computing them as flat." @@ -734,7 +740,8 @@ async fn load_gltf<'a, 'b, 'c>( && material_needs_tangents(&primitive.material()) { tracing::debug!( - "Missing vertex tangents for {}, computing them using the mikktspace algorithm. Consider using a tool such as Blender to pre-compute the tangents.", file_name + "Missing vertex tangents for {}, computing them using the mikktspace algorithm. Consider using a tool such as Blender to pre-compute the tangents.", + file_name ); let generate_tangents_span = info_span!("generate_tangents", name = file_name); @@ -1413,7 +1420,8 @@ fn warn_on_differing_texture_transforms( .unwrap_or_else(|| "default".to_string()); warn!( "Only texture transforms on base color textures are supported, but {material_name} ({material_index}) \ - has a texture transform on {texture_name} (index {}), which will be ignored.", info.texture().index() + has a texture transform on {texture_name} (index {}), which will be ignored.", + info.texture().index() ); } } @@ -1988,9 +1996,9 @@ impl<'s> Iterator for PrimitiveMorphAttributesIter<'s> { type Item = MorphAttributes; fn next(&mut self) -> Option { - let position = self.0 .0.as_mut().and_then(Iterator::next); - let normal = self.0 .1.as_mut().and_then(Iterator::next); - let tangent = self.0 .2.as_mut().and_then(Iterator::next); + let position = self.0.0.as_mut().and_then(Iterator::next); + let normal = self.0.1.as_mut().and_then(Iterator::next); + let tangent = self.0.2.as_mut().and_then(Iterator::next); if position.is_none() && normal.is_none() && tangent.is_none() { return None; } @@ -2383,15 +2391,15 @@ mod test { use crate::{Gltf, GltfAssetLabel, GltfNode, GltfSkin}; use bevy_app::{App, TaskPoolPlugin}; use bevy_asset::{ + AssetApp, AssetPlugin, AssetServer, Assets, Handle, LoadState, io::{ - memory::{Dir, MemoryAssetReader}, AssetSource, AssetSourceId, + memory::{Dir, MemoryAssetReader}, }, - AssetApp, AssetPlugin, AssetServer, Assets, Handle, LoadState, }; use bevy_ecs::{resource::Resource, world::World}; use bevy_log::LogPlugin; - use bevy_render::mesh::{skinning::SkinnedMeshInverseBindposes, MeshPlugin}; + use bevy_render::mesh::{MeshPlugin, skinning::SkinnedMeshInverseBindposes}; use bevy_scene::ScenePlugin; fn test_app(dir: Dir) -> App { diff --git a/crates/bevy_image/src/basis.rs b/crates/bevy_image/src/basis.rs index 553140b0024bf..141d4d2caa308 100644 --- a/crates/bevy_image/src/basis.rs +++ b/crates/bevy_image/src/basis.rs @@ -113,7 +113,7 @@ pub fn basis_buffer_to_image( basis_texture_type => { return Err(TextureError::UnsupportedTextureFormat(format!( "{basis_texture_type:?}", - ))) + ))); } }; image.data = Some(transcoded); diff --git a/crates/bevy_image/src/dds.rs b/crates/bevy_image/src/dds.rs index 5198fb366a311..3254a2ad068cf 100644 --- a/crates/bevy_image/src/dds.rs +++ b/crates/bevy_image/src/dds.rs @@ -272,7 +272,7 @@ pub fn dds_format_to_texture_format( _ => { return Err(TextureError::UnsupportedTextureFormat(format!( "{dxgi_format:?}", - ))) + ))); } } } else { diff --git a/crates/bevy_image/src/dynamic_texture_atlas_builder.rs b/crates/bevy_image/src/dynamic_texture_atlas_builder.rs index 6e013aba29a45..b9eef1b0e7c4c 100644 --- a/crates/bevy_image/src/dynamic_texture_atlas_builder.rs +++ b/crates/bevy_image/src/dynamic_texture_atlas_builder.rs @@ -1,7 +1,7 @@ use crate::{Image, TextureAtlasLayout, TextureFormatPixelInfo as _}; use bevy_asset::RenderAssetUsages; use bevy_math::{URect, UVec2}; -use guillotiere::{size2, Allocation, AtlasAllocator}; +use guillotiere::{Allocation, AtlasAllocator, size2}; use thiserror::Error; use tracing::error; @@ -63,7 +63,9 @@ impl DynamicTextureAtlasBuilder { )); if let Some(allocation) = allocation { assert!( - atlas_texture.asset_usage.contains(RenderAssetUsages::MAIN_WORLD), + atlas_texture + .asset_usage + .contains(RenderAssetUsages::MAIN_WORLD), "The atlas_texture image must have the RenderAssetUsages::MAIN_WORLD usage flag set" ); diff --git a/crates/bevy_image/src/exr_texture_loader.rs b/crates/bevy_image/src/exr_texture_loader.rs index d9b89dd21e152..878e04d89c2ac 100644 --- a/crates/bevy_image/src/exr_texture_loader.rs +++ b/crates/bevy_image/src/exr_texture_loader.rs @@ -1,5 +1,5 @@ use crate::{Image, TextureFormatPixelInfo}; -use bevy_asset::{io::Reader, AssetLoader, LoadContext, RenderAssetUsages}; +use bevy_asset::{AssetLoader, LoadContext, RenderAssetUsages, io::Reader}; use image::ImageDecoder; use serde::{Deserialize, Serialize}; use thiserror::Error; diff --git a/crates/bevy_image/src/hdr_texture_loader.rs b/crates/bevy_image/src/hdr_texture_loader.rs index 3177e94865809..a0ee9418c9d56 100644 --- a/crates/bevy_image/src/hdr_texture_loader.rs +++ b/crates/bevy_image/src/hdr_texture_loader.rs @@ -1,6 +1,6 @@ use crate::{Image, TextureFormatPixelInfo}; use bevy_asset::RenderAssetUsages; -use bevy_asset::{io::Reader, AssetLoader, LoadContext}; +use bevy_asset::{AssetLoader, LoadContext, io::Reader}; use image::DynamicImage; use serde::{Deserialize, Serialize}; use thiserror::Error; diff --git a/crates/bevy_image/src/image.rs b/crates/bevy_image/src/image.rs index e9a1ef2ddc420..927d608c9dc57 100644 --- a/crates/bevy_image/src/image.rs +++ b/crates/bevy_image/src/image.rs @@ -5,7 +5,7 @@ use super::dds::*; #[cfg(feature = "ktx2")] use super::ktx2::*; #[cfg(feature = "bevy_reflect")] -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; use bevy_asset::{Asset, RenderAssetUsages}; use bevy_color::{Color, ColorToComponents, Gray, LinearRgba, Srgba, Xyza}; @@ -856,7 +856,9 @@ impl Image { 0, ); } else { - warn!("Resized an uninitialized image. Directly modify image.texture_descriptor.size instead"); + warn!( + "Resized an uninitialized image. Directly modify image.texture_descriptor.size instead" + ); } } diff --git a/crates/bevy_image/src/image_loader.rs b/crates/bevy_image/src/image_loader.rs index 949ee78e49d4b..cbc71f4b7cec8 100644 --- a/crates/bevy_image/src/image_loader.rs +++ b/crates/bevy_image/src/image_loader.rs @@ -1,5 +1,5 @@ use crate::image::{Image, ImageFormat, ImageType, TextureError}; -use bevy_asset::{io::Reader, AssetLoader, LoadContext, RenderAssetUsages}; +use bevy_asset::{AssetLoader, LoadContext, RenderAssetUsages, io::Reader}; use thiserror::Error; use super::{CompressedImageFormats, ImageSampler}; diff --git a/crates/bevy_image/src/ktx2.rs b/crates/bevy_image/src/ktx2.rs index a45b77a2a8fc9..c59f34424f290 100644 --- a/crates/bevy_image/src/ktx2.rs +++ b/crates/bevy_image/src/ktx2.rs @@ -1081,7 +1081,7 @@ pub fn ktx2_dfd_to_texture_format( return Err(TextureError::UnsupportedTextureFormat(format!( "Invalid ETC2 sample channel type: {}", sample.channel_type - ))) + ))); } } } @@ -1143,7 +1143,7 @@ pub fn ktx2_dfd_to_texture_format( return Err(TextureError::UnsupportedTextureFormat(format!( "Invalid ASTC dimension: {} x {}", d.0, d.1 - ))) + ))); } }, channel: if is_srgb { @@ -1178,7 +1178,7 @@ pub fn ktx2_dfd_to_texture_format( channel_type => { return Err(TextureError::UnsupportedTextureFormat(format!( "Invalid KTX2 UASTC channel type: {channel_type}", - ))) + ))); } }), )); @@ -1489,7 +1489,7 @@ pub fn ktx2_format_to_texture_format( _ => { return Err(TextureError::UnsupportedTextureFormat(format!( "{ktx2_format:?}" - ))) + ))); } }) } diff --git a/crates/bevy_image/src/lib.rs b/crates/bevy_image/src/lib.rs index 55f74a5f14d35..8f3ba82f710f2 100644 --- a/crates/bevy_image/src/lib.rs +++ b/crates/bevy_image/src/lib.rs @@ -4,9 +4,9 @@ extern crate alloc; pub mod prelude { pub use crate::{ + BevyDefault as _, Image, ImageFormat, TextureAtlasBuilder, TextureError, dynamic_texture_atlas_builder::DynamicTextureAtlasBuilder, texture_atlas::{TextureAtlas, TextureAtlasLayout, TextureAtlasSources}, - BevyDefault as _, Image, ImageFormat, TextureAtlasBuilder, TextureError, }; } diff --git a/crates/bevy_image/src/texture_atlas.rs b/crates/bevy_image/src/texture_atlas.rs index 36e2acd86456b..68f0f4443b72b 100644 --- a/crates/bevy_image/src/texture_atlas.rs +++ b/crates/bevy_image/src/texture_atlas.rs @@ -3,7 +3,7 @@ use bevy_asset::{Asset, AssetApp as _, AssetId, Assets, Handle}; use bevy_math::{URect, UVec2}; use bevy_platform_support::collections::HashMap; #[cfg(feature = "bevy_reflect")] -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; #[cfg(feature = "serialize")] use bevy_reflect::{ReflectDeserialize, ReflectSerialize}; diff --git a/crates/bevy_image/src/texture_atlas_builder.rs b/crates/bevy_image/src/texture_atlas_builder.rs index 443660eefc424..3421e6e3b123e 100644 --- a/crates/bevy_image/src/texture_atlas_builder.rs +++ b/crates/bevy_image/src/texture_atlas_builder.rs @@ -2,8 +2,8 @@ use bevy_asset::{AssetId, RenderAssetUsages}; use bevy_math::{URect, UVec2}; use bevy_platform_support::collections::HashMap; use rectangle_pack::{ - contains_smallest_box, pack_rects, volume_heuristic, GroupedRectsToPlace, PackedLocation, - RectToInsert, TargetBin, + GroupedRectsToPlace, PackedLocation, RectToInsert, TargetBin, contains_smallest_box, + pack_rects, volume_heuristic, }; use thiserror::Error; use tracing::{debug, error, warn}; diff --git a/crates/bevy_input/src/axis.rs b/crates/bevy_input/src/axis.rs index acdf0135f0eda..a60dcba8d435b 100644 --- a/crates/bevy_input/src/axis.rs +++ b/crates/bevy_input/src/axis.rs @@ -88,7 +88,7 @@ where #[cfg(test)] mod tests { - use crate::{gamepad::GamepadButton, Axis}; + use crate::{Axis, gamepad::GamepadButton}; #[test] fn test_axis_set() { diff --git a/crates/bevy_input/src/button_input.rs b/crates/bevy_input/src/button_input.rs index a1086edf66e78..8c32d0e7c0a9d 100644 --- a/crates/bevy_input/src/button_input.rs +++ b/crates/bevy_input/src/button_input.rs @@ -6,7 +6,7 @@ use core::hash::Hash; #[cfg(feature = "bevy_reflect")] use { bevy_ecs::reflect::ReflectResource, - bevy_reflect::{std_traits::ReflectDefault, Reflect}, + bevy_reflect::{Reflect, std_traits::ReflectDefault}, }; /// A "press-able" input of type `T`. diff --git a/crates/bevy_input/src/gamepad.rs b/crates/bevy_input/src/gamepad.rs index 2da9916a7ed7a..bfc28be93211d 100644 --- a/crates/bevy_input/src/gamepad.rs +++ b/crates/bevy_input/src/gamepad.rs @@ -15,11 +15,11 @@ use bevy_ecs::{ prelude::require, system::{Commands, Query}, }; -use bevy_math::ops; use bevy_math::Vec2; +use bevy_math::ops; use bevy_platform_support::collections::HashMap; #[cfg(feature = "bevy_reflect")] -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; #[cfg(all(feature = "serialize", feature = "bevy_reflect"))] use bevy_reflect::{ReflectDeserialize, ReflectSerialize}; use derive_more::derive::From; @@ -267,7 +267,11 @@ pub enum AxisSettingsError { #[error("invalid livezone_upperbound {0}, expected value [0.0..=1.0]")] LiveZoneUpperBoundOutOfRange(f32), /// Parameter `livezone_lowerbound` was not less than or equal to parameter `deadzone_lowerbound`. - #[error("invalid parameter values livezone_lowerbound {} deadzone_lowerbound {}, expected livezone_lowerbound <= deadzone_lowerbound", livezone_lowerbound, deadzone_lowerbound)] + #[error( + "invalid parameter values livezone_lowerbound {} deadzone_lowerbound {}, expected livezone_lowerbound <= deadzone_lowerbound", + livezone_lowerbound, + deadzone_lowerbound + )] LiveZoneLowerBoundGreaterThanDeadZoneLowerBound { /// The value of the `livezone_lowerbound` parameter. livezone_lowerbound: f32, @@ -275,7 +279,11 @@ pub enum AxisSettingsError { deadzone_lowerbound: f32, }, /// Parameter `deadzone_upperbound` was not less than or equal to parameter `livezone_upperbound`. - #[error("invalid parameter values livezone_upperbound {} deadzone_upperbound {}, expected deadzone_upperbound <= livezone_upperbound", livezone_upperbound, deadzone_upperbound)] + #[error( + "invalid parameter values livezone_upperbound {} deadzone_upperbound {}, expected deadzone_upperbound <= livezone_upperbound", + livezone_upperbound, + deadzone_upperbound + )] DeadZoneUpperBoundGreaterThanLiveZoneUpperBound { /// The value of the `livezone_upperbound` parameter. livezone_upperbound: f32, @@ -297,7 +305,11 @@ pub enum ButtonSettingsError { #[error("invalid press_threshold {0}, expected [0.0..=1.0]")] PressThresholdOutOfRange(f32), /// Parameter `release_threshold` was not less than or equal to `press_threshold`. - #[error("invalid parameter values release_threshold {} press_threshold {}, expected release_threshold <= press_threshold", release_threshold, press_threshold)] + #[error( + "invalid parameter values release_threshold {} press_threshold {}, expected release_threshold <= press_threshold", + release_threshold, + press_threshold + )] ReleaseThresholdGreaterThanPressThreshold { /// The value of the `press_threshold` parameter. press_threshold: f32, @@ -1476,7 +1488,10 @@ pub fn gamepad_connection_system( } GamepadConnection::Disconnected => { let Some(mut gamepad) = commands.get_entity(id) else { - warn!("Gamepad {} removed before handling disconnection event. You can ignore this if you manually removed it.", id); + warn!( + "Gamepad {} removed before handling disconnection event. You can ignore this if you manually removed it.", + id + ); continue; }; // Gamepad entities are left alive to preserve their state (e.g. [`GamepadSettings`]). @@ -1751,13 +1766,13 @@ impl GamepadRumbleRequest { #[cfg(test)] mod tests { use super::{ - gamepad_connection_system, gamepad_event_processing_system, AxisSettings, - AxisSettingsError, ButtonAxisSettings, ButtonSettings, ButtonSettingsError, Gamepad, - GamepadAxis, GamepadAxisChangedEvent, GamepadButton, GamepadButtonChangedEvent, + AxisSettings, AxisSettingsError, ButtonAxisSettings, ButtonSettings, ButtonSettingsError, + Gamepad, GamepadAxis, GamepadAxisChangedEvent, GamepadButton, GamepadButtonChangedEvent, GamepadButtonStateChangedEvent, GamepadConnection::{Connected, Disconnected}, GamepadConnectionEvent, GamepadEvent, GamepadSettings, RawGamepadAxisChangedEvent, - RawGamepadButtonChangedEvent, RawGamepadEvent, + RawGamepadButtonChangedEvent, RawGamepadEvent, gamepad_connection_system, + gamepad_event_processing_system, }; use crate::ButtonState; use alloc::string::ToString; @@ -1835,7 +1850,8 @@ mod tests { ) { let actual = settings.filter(new_raw_value, old_raw_value); assert_eq!( - expected, actual.map(|f| f.scaled.to_f32()), + expected, + actual.map(|f| f.scaled.to_f32()), "Testing filtering for {settings:?} with new_raw_value = {new_raw_value:?}, old_raw_value = {old_raw_value:?}", ); } @@ -2243,35 +2259,39 @@ mod tests { ctx.send_gamepad_disconnection_event(entity); ctx.update(); // Gamepad component should be removed - assert!(ctx - .app - .world_mut() - .query::<&Gamepad>() - .get(ctx.app.world(), entity) - .is_err()); + assert!( + ctx.app + .world_mut() + .query::<&Gamepad>() + .get(ctx.app.world(), entity) + .is_err() + ); // Settings should be kept - assert!(ctx - .app - .world_mut() - .query::<&GamepadSettings>() - .get(ctx.app.world(), entity) - .is_ok()); + assert!( + ctx.app + .world_mut() + .query::<&GamepadSettings>() + .get(ctx.app.world(), entity) + .is_ok() + ); // Mistakenly sending a second disconnection event shouldn't break anything ctx.send_gamepad_disconnection_event(entity); ctx.update(); - assert!(ctx - .app - .world_mut() - .query::<&Gamepad>() - .get(ctx.app.world(), entity) - .is_err()); - assert!(ctx - .app - .world_mut() - .query::<&GamepadSettings>() - .get(ctx.app.world(), entity) - .is_ok()); + assert!( + ctx.app + .world_mut() + .query::<&Gamepad>() + .get(ctx.app.world(), entity) + .is_err() + ); + assert!( + ctx.app + .world_mut() + .query::<&GamepadSettings>() + .get(ctx.app.world(), entity) + .is_ok() + ); } #[test] @@ -2289,19 +2309,21 @@ mod tests { ctx.send_gamepad_disconnection_event(entity); ctx.update(); // Gamepad component should be removed - assert!(ctx - .app - .world_mut() - .query::<&Gamepad>() - .get(ctx.app.world(), entity) - .is_err()); + assert!( + ctx.app + .world_mut() + .query::<&Gamepad>() + .get(ctx.app.world(), entity) + .is_err() + ); // Settings should be kept - assert!(ctx - .app - .world_mut() - .query::<&GamepadSettings>() - .get(ctx.app.world(), entity) - .is_ok()); + assert!( + ctx.app + .world_mut() + .query::<&GamepadSettings>() + .get(ctx.app.world(), entity) + .is_ok() + ); } #[test] @@ -2369,12 +2391,13 @@ mod tests { .len(), 0 ); - assert!(ctx - .app - .world_mut() - .query::<(Entity, &GamepadSettings)>() - .get(ctx.app.world(), entity) - .is_ok()); + assert!( + ctx.app + .world_mut() + .query::<(Entity, &GamepadSettings)>() + .get(ctx.app.world(), entity) + .is_ok() + ); } #[test] @@ -2684,13 +2707,14 @@ mod tests { assert_eq!(event.button, GamepadButton::DPadDown); assert_eq!(event.state, ButtonState::Pressed); } - assert!(ctx - .app - .world_mut() - .query::<&Gamepad>() - .get(ctx.app.world(), entity) - .unwrap() - .pressed(GamepadButton::DPadDown)); + assert!( + ctx.app + .world_mut() + .query::<&Gamepad>() + .get(ctx.app.world(), entity) + .unwrap() + .pressed(GamepadButton::DPadDown) + ); ctx.app .world_mut() @@ -2705,13 +2729,14 @@ mod tests { .len(), 0 ); - assert!(ctx - .app - .world_mut() - .query::<&Gamepad>() - .get(ctx.app.world(), entity) - .unwrap() - .pressed(GamepadButton::DPadDown)); + assert!( + ctx.app + .world_mut() + .query::<&Gamepad>() + .get(ctx.app.world(), entity) + .unwrap() + .pressed(GamepadButton::DPadDown) + ); } #[test] @@ -2730,23 +2755,25 @@ mod tests { ctx.update(); // Check it is flagged for this frame - assert!(ctx - .app - .world_mut() - .query::<&Gamepad>() - .get(ctx.app.world(), entity) - .unwrap() - .just_pressed(GamepadButton::DPadDown)); + assert!( + ctx.app + .world_mut() + .query::<&Gamepad>() + .get(ctx.app.world(), entity) + .unwrap() + .just_pressed(GamepadButton::DPadDown) + ); ctx.update(); //Check it clears next frame - assert!(!ctx - .app - .world_mut() - .query::<&Gamepad>() - .get(ctx.app.world(), entity) - .unwrap() - .just_pressed(GamepadButton::DPadDown)); + assert!( + !ctx.app + .world_mut() + .query::<&Gamepad>() + .get(ctx.app.world(), entity) + .unwrap() + .just_pressed(GamepadButton::DPadDown) + ); } #[test] fn gamepad_buttons_released() { @@ -2789,13 +2816,14 @@ mod tests { assert_eq!(event.button, GamepadButton::DPadDown); assert_eq!(event.state, ButtonState::Released); } - assert!(!ctx - .app - .world_mut() - .query::<&Gamepad>() - .get(ctx.app.world(), entity) - .unwrap() - .pressed(GamepadButton::DPadDown)); + assert!( + !ctx.app + .world_mut() + .query::<&Gamepad>() + .get(ctx.app.world(), entity) + .unwrap() + .pressed(GamepadButton::DPadDown) + ); ctx.app .world_mut() .resource_mut::>() @@ -2834,23 +2862,25 @@ mod tests { ctx.update(); // Check it is flagged for this frame - assert!(ctx - .app - .world_mut() - .query::<&Gamepad>() - .get(ctx.app.world(), entity) - .unwrap() - .just_released(GamepadButton::DPadDown)); + assert!( + ctx.app + .world_mut() + .query::<&Gamepad>() + .get(ctx.app.world(), entity) + .unwrap() + .just_released(GamepadButton::DPadDown) + ); ctx.update(); //Check it clears next frame - assert!(!ctx - .app - .world_mut() - .query::<&Gamepad>() - .get(ctx.app.world(), entity) - .unwrap() - .just_released(GamepadButton::DPadDown)); + assert!( + !ctx.app + .world_mut() + .query::<&Gamepad>() + .get(ctx.app.world(), entity) + .unwrap() + .just_released(GamepadButton::DPadDown) + ); } #[test] diff --git a/crates/bevy_input/src/lib.rs b/crates/bevy_input/src/lib.rs index 2da2c89cce8ca..ca0a6085c5e85 100644 --- a/crates/bevy_input/src/lib.rs +++ b/crates/bevy_input/src/lib.rs @@ -36,11 +36,11 @@ pub use button_input::*; pub mod prelude { #[doc(hidden)] pub use crate::{ + Axis, ButtonInput, gamepad::{Gamepad, GamepadAxis, GamepadButton, GamepadSettings}, keyboard::KeyCode, mouse::MouseButton, touch::{TouchInput, Touches}, - Axis, ButtonInput, }; } @@ -49,22 +49,22 @@ use bevy_ecs::prelude::*; #[cfg(feature = "bevy_reflect")] use bevy_reflect::Reflect; use gestures::*; -use keyboard::{keyboard_input_system, KeyCode, KeyboardFocusLost, KeyboardInput}; +use keyboard::{KeyCode, KeyboardFocusLost, KeyboardInput, keyboard_input_system}; use mouse::{ - accumulate_mouse_motion_system, accumulate_mouse_scroll_system, mouse_button_input_system, AccumulatedMouseMotion, AccumulatedMouseScroll, MouseButton, MouseButtonInput, MouseMotion, - MouseWheel, + MouseWheel, accumulate_mouse_motion_system, accumulate_mouse_scroll_system, + mouse_button_input_system, }; -use touch::{touch_screen_input_system, TouchInput, Touches}; +use touch::{TouchInput, Touches, touch_screen_input_system}; #[cfg(feature = "bevy_reflect")] use gamepad::Gamepad; use gamepad::{ - gamepad_connection_system, gamepad_event_processing_system, GamepadAxis, - GamepadAxisChangedEvent, GamepadButton, GamepadButtonChangedEvent, + GamepadAxis, GamepadAxisChangedEvent, GamepadButton, GamepadButtonChangedEvent, GamepadButtonStateChangedEvent, GamepadConnection, GamepadConnectionEvent, GamepadEvent, GamepadInput, GamepadRumbleRequest, GamepadSettings, RawGamepadAxisChangedEvent, - RawGamepadButtonChangedEvent, RawGamepadEvent, + RawGamepadButtonChangedEvent, RawGamepadEvent, gamepad_connection_system, + gamepad_event_processing_system, }; #[cfg(all(feature = "serialize", feature = "bevy_reflect"))] diff --git a/crates/bevy_input/src/mouse.rs b/crates/bevy_input/src/mouse.rs index 977b6e0aea3bb..8f6b926116f6e 100644 --- a/crates/bevy_input/src/mouse.rs +++ b/crates/bevy_input/src/mouse.rs @@ -12,7 +12,7 @@ use bevy_math::Vec2; #[cfg(feature = "bevy_reflect")] use { bevy_ecs::reflect::ReflectResource, - bevy_reflect::{std_traits::ReflectDefault, Reflect}, + bevy_reflect::{Reflect, std_traits::ReflectDefault}, }; #[cfg(all(feature = "serialize", feature = "bevy_reflect"))] diff --git a/crates/bevy_input/src/touch.rs b/crates/bevy_input/src/touch.rs index e1784c13fdfea..78ef52ab2c156 100644 --- a/crates/bevy_input/src/touch.rs +++ b/crates/bevy_input/src/touch.rs @@ -454,7 +454,7 @@ mod test { #[test] fn touch_update() { - use crate::{touch::Touch, Touches}; + use crate::{Touches, touch::Touch}; use bevy_math::Vec2; let mut touches = Touches::default(); @@ -485,7 +485,7 @@ mod test { #[test] fn touch_process() { - use crate::{touch::TouchPhase, TouchInput, Touches}; + use crate::{TouchInput, Touches, touch::TouchPhase}; use bevy_ecs::entity::Entity; use bevy_math::Vec2; @@ -570,7 +570,7 @@ mod test { // See https://github.com/bevyengine/bevy/issues/12442 #[test] fn touch_process_multi_event() { - use crate::{touch::TouchPhase, TouchInput, Touches}; + use crate::{TouchInput, Touches, touch::TouchPhase}; use bevy_ecs::entity::Entity; use bevy_math::Vec2; @@ -632,7 +632,7 @@ mod test { #[test] fn touch_pressed() { - use crate::{touch::TouchPhase, TouchInput, Touches}; + use crate::{TouchInput, Touches, touch::TouchPhase}; use bevy_ecs::entity::Entity; use bevy_math::Vec2; @@ -659,7 +659,7 @@ mod test { #[test] fn touch_released() { - use crate::{touch::TouchPhase, TouchInput, Touches}; + use crate::{TouchInput, Touches, touch::TouchPhase}; use bevy_ecs::entity::Entity; use bevy_math::Vec2; @@ -686,7 +686,7 @@ mod test { #[test] fn touch_canceled() { - use crate::{touch::TouchPhase, TouchInput, Touches}; + use crate::{TouchInput, Touches, touch::TouchPhase}; use bevy_ecs::entity::Entity; use bevy_math::Vec2; @@ -712,7 +712,7 @@ mod test { #[test] fn release_touch() { - use crate::{touch::TouchPhase, TouchInput, Touches}; + use crate::{TouchInput, Touches, touch::TouchPhase}; use bevy_ecs::entity::Entity; use bevy_math::Vec2; @@ -738,7 +738,7 @@ mod test { #[test] fn release_all_touches() { - use crate::{touch::TouchPhase, TouchInput, Touches}; + use crate::{TouchInput, Touches, touch::TouchPhase}; use bevy_ecs::entity::Entity; use bevy_math::Vec2; @@ -776,7 +776,7 @@ mod test { #[test] fn clear_touches() { - use crate::{touch::TouchPhase, TouchInput, Touches}; + use crate::{TouchInput, Touches, touch::TouchPhase}; use bevy_ecs::entity::Entity; use bevy_math::Vec2; @@ -826,7 +826,7 @@ mod test { #[test] fn reset_all_touches() { - use crate::{touch::TouchPhase, TouchInput, Touches}; + use crate::{TouchInput, Touches, touch::TouchPhase}; use bevy_ecs::entity::Entity; use bevy_math::Vec2; diff --git a/crates/bevy_input_focus/src/autofocus.rs b/crates/bevy_input_focus/src/autofocus.rs index dc3b0919d2a7d..8cf4c99f1e2db 100644 --- a/crates/bevy_input_focus/src/autofocus.rs +++ b/crates/bevy_input_focus/src/autofocus.rs @@ -5,7 +5,7 @@ use bevy_ecs::{component::HookContext, prelude::*, world::DeferredWorld}; use crate::InputFocus; #[cfg(feature = "bevy_reflect")] -use bevy_reflect::{prelude::*, Reflect}; +use bevy_reflect::{Reflect, prelude::*}; /// Indicates that this widget should automatically receive [`InputFocus`]. /// diff --git a/crates/bevy_input_focus/src/directional_navigation.rs b/crates/bevy_input_focus/src/directional_navigation.rs index d42b7653f6592..25f53fbd9d94f 100644 --- a/crates/bevy_input_focus/src/directional_navigation.rs +++ b/crates/bevy_input_focus/src/directional_navigation.rs @@ -27,7 +27,7 @@ use thiserror::Error; use crate::InputFocus; #[cfg(feature = "bevy_reflect")] -use bevy_reflect::{prelude::*, Reflect}; +use bevy_reflect::{Reflect, prelude::*}; /// A plugin that sets up the directional navigation systems and resources. #[derive(Default)] diff --git a/crates/bevy_input_focus/src/lib.rs b/crates/bevy_input_focus/src/lib.rs index 0ec0b428978e9..8e232f1808c43 100644 --- a/crates/bevy_input_focus/src/lib.rs +++ b/crates/bevy_input_focus/src/lib.rs @@ -37,7 +37,7 @@ use bevy_window::{PrimaryWindow, Window}; use core::fmt::Debug; #[cfg(feature = "bevy_reflect")] -use bevy_reflect::{prelude::*, Reflect}; +use bevy_reflect::{Reflect, prelude::*}; /// Resource representing which entity has input focus, if any. Input events (other than pointer-like inputs) will be /// dispatched to the current focus entity, or to the primary window if no entity has focus. @@ -364,8 +364,8 @@ mod tests { component::HookContext, observer::Trigger, system::RunSystemOnce, world::DeferredWorld, }; use bevy_input::{ - keyboard::{Key, KeyCode}, ButtonState, InputPlugin, + keyboard::{Key, KeyCode}, }; use bevy_window::WindowResolution; use smol_str::SmolStr; diff --git a/crates/bevy_input_focus/src/tab_navigation.rs b/crates/bevy_input_focus/src/tab_navigation.rs index 683e5d12d5fe8..f827cb5869456 100644 --- a/crates/bevy_input_focus/src/tab_navigation.rs +++ b/crates/bevy_input_focus/src/tab_navigation.rs @@ -35,8 +35,8 @@ use bevy_ecs::{ system::{Commands, Query, Res, ResMut, SystemParam}, }; use bevy_input::{ - keyboard::{KeyCode, KeyboardInput}, ButtonInput, ButtonState, + keyboard::{KeyCode, KeyboardInput}, }; use bevy_window::PrimaryWindow; use log::warn; @@ -47,7 +47,7 @@ use crate::{FocusedInput, InputFocus, InputFocusVisible}; #[cfg(feature = "bevy_reflect")] use { bevy_ecs::prelude::ReflectComponent, - bevy_reflect::{prelude::*, Reflect}, + bevy_reflect::{Reflect, prelude::*}, }; /// A component which indicates that an entity wants to participate in tab navigation. @@ -135,7 +135,9 @@ pub enum TabNavigationError { #[error("Failed to navigate to next focusable entity")] FailedToNavigateToNextFocusableEntity, /// No tab group for the current focus entity was found. - #[error("No tab group found for currently focused entity {previous_focus}. Users will not be able to navigate back to this entity.")] + #[error( + "No tab group found for currently focused entity {previous_focus}. Users will not be able to navigate back to this entity." + )] NoTabGroupForCurrentFocus { /// The entity that was previously focused, /// and is missing its tab group. diff --git a/crates/bevy_internal/src/default_plugins.rs b/crates/bevy_internal/src/default_plugins.rs index d9aee3017a2ee..383da24835e81 100644 --- a/crates/bevy_internal/src/default_plugins.rs +++ b/crates/bevy_internal/src/default_plugins.rs @@ -1,4 +1,4 @@ -use bevy_app::{plugin_group, Plugin}; +use bevy_app::{Plugin, plugin_group}; plugin_group! { /// This plugin group will add all the default plugins for a *Bevy* application: diff --git a/crates/bevy_internal/src/prelude.rs b/crates/bevy_internal/src/prelude.rs index 1c19c7ccc14a0..9d79df63e9cb8 100644 --- a/crates/bevy_internal/src/prelude.rs +++ b/crates/bevy_internal/src/prelude.rs @@ -1,8 +1,8 @@ #[doc(hidden)] pub use crate::{ - app::prelude::*, ecs::prelude::*, input::prelude::*, log::prelude::*, math::prelude::*, - reflect::prelude::*, time::prelude::*, transform::prelude::*, utils::prelude::*, - DefaultPlugins, MinimalPlugins, + DefaultPlugins, MinimalPlugins, app::prelude::*, ecs::prelude::*, input::prelude::*, + log::prelude::*, math::prelude::*, reflect::prelude::*, time::prelude::*, + transform::prelude::*, utils::prelude::*, }; #[doc(hidden)] @@ -13,7 +13,7 @@ pub use crate::window::prelude::*; #[cfg(feature = "bevy_image")] pub use crate::image::prelude::*; -pub use bevy_derive::{bevy_main, Deref, DerefMut}; +pub use bevy_derive::{Deref, DerefMut, bevy_main}; #[doc(hidden)] #[cfg(feature = "bevy_asset")] diff --git a/crates/bevy_log/src/android_tracing.rs b/crates/bevy_log/src/android_tracing.rs index ba0b3b7a27a38..3210d207a23b5 100644 --- a/crates/bevy_log/src/android_tracing.rs +++ b/crates/bevy_log/src/android_tracing.rs @@ -1,11 +1,11 @@ use alloc::ffi::CString; use core::fmt::{Debug, Write}; use tracing::{ + Event, Id, Level, Subscriber, field::Field, span::{Attributes, Record}, - Event, Id, Level, Subscriber, }; -use tracing_subscriber::{field::Visit, layer::Context, registry::LookupSpan, Layer}; +use tracing_subscriber::{Layer, field::Visit, layer::Context, registry::LookupSpan}; #[derive(Default)] pub(crate) struct AndroidLayer; diff --git a/crates/bevy_log/src/lib.rs b/crates/bevy_log/src/lib.rs index f0743f022de0f..368d9cbccea3b 100644 --- a/crates/bevy_log/src/lib.rs +++ b/crates/bevy_log/src/lib.rs @@ -47,24 +47,24 @@ pub mod prelude { pub use bevy_utils::once; pub use tracing::{ - self, debug, debug_span, error, error_span, info, info_span, trace, trace_span, warn, - warn_span, Level, + self, Level, debug, debug_span, error, error_span, info, info_span, trace, trace_span, warn, + warn_span, }; pub use tracing_subscriber; use bevy_app::{App, Plugin}; use tracing_log::LogTracer; use tracing_subscriber::{ + EnvFilter, Layer, filter::{FromEnvError, ParseError}, prelude::*, registry::Registry, - EnvFilter, Layer, }; #[cfg(feature = "tracing-chrome")] use { bevy_ecs::resource::Resource, bevy_utils::synccell::SyncCell, - tracing_subscriber::fmt::{format::DefaultFields, FormattedFields}, + tracing_subscriber::fmt::{FormattedFields, format::DefaultFields}, }; /// Wrapper resource for `tracing-chrome`'s flush guard. @@ -371,8 +371,12 @@ impl Plugin for LogPlugin { (true, true) => error!( "Could not set global logger and tracing subscriber as they are already set. Consider disabling LogPlugin." ), - (true, false) => error!("Could not set global logger as it is already set. Consider disabling LogPlugin."), - (false, true) => error!("Could not set global tracing subscriber as it is already set. Consider disabling LogPlugin."), + (true, false) => error!( + "Could not set global logger as it is already set. Consider disabling LogPlugin." + ), + (false, true) => error!( + "Could not set global tracing subscriber as it is already set. Consider disabling LogPlugin." + ), (false, false) => (), } } diff --git a/crates/bevy_macro_utils/src/attrs.rs b/crates/bevy_macro_utils/src/attrs.rs index 9e000f217bbe3..92fa0056dd1c0 100644 --- a/crates/bevy_macro_utils/src/attrs.rs +++ b/crates/bevy_macro_utils/src/attrs.rs @@ -28,7 +28,9 @@ pub fn get_lit_bool(attr_name: Symbol, value: &Expr) -> syn::Result { } else { Err(syn::Error::new_spanned( value, - format!("expected {attr_name} attribute to be a bool value, `true` or `false`: `{attr_name} = ...`"), + format!( + "expected {attr_name} attribute to be a bool value, `true` or `false`: `{attr_name} = ...`" + ), ))? } } diff --git a/crates/bevy_macro_utils/src/fq_std.rs b/crates/bevy_macro_utils/src/fq_std.rs index c350d101ad71a..2a76a2a5dcd34 100644 --- a/crates/bevy_macro_utils/src/fq_std.rs +++ b/crates/bevy_macro_utils/src/fq_std.rs @@ -37,7 +37,7 @@ //! ``` use proc_macro2::TokenStream; -use quote::{quote, ToTokens}; +use quote::{ToTokens, quote}; /// Fully Qualified (FQ) short name for [`std::any::Any`] pub struct FQAny; diff --git a/crates/bevy_macro_utils/src/label.rs b/crates/bevy_macro_utils/src/label.rs index 1fc540c9c4ea3..2ead810073881 100644 --- a/crates/bevy_macro_utils/src/label.rs +++ b/crates/bevy_macro_utils/src/label.rs @@ -1,7 +1,7 @@ use proc_macro::{TokenStream, TokenTree}; use quote::{quote, quote_spanned}; use std::collections::HashSet; -use syn::{spanned::Spanned, Ident}; +use syn::{Ident, spanned::Spanned}; /// Finds an identifier that will not conflict with the specified set of tokens. /// diff --git a/crates/bevy_macro_utils/src/shape.rs b/crates/bevy_macro_utils/src/shape.rs index 2d0124d62a8f9..1b5d900aefdf0 100644 --- a/crates/bevy_macro_utils/src/shape.rs +++ b/crates/bevy_macro_utils/src/shape.rs @@ -1,5 +1,5 @@ use proc_macro::Span; -use syn::{punctuated::Punctuated, token::Comma, Data, DataStruct, Error, Field, Fields}; +use syn::{Data, DataStruct, Error, Field, Fields, punctuated::Punctuated, token::Comma}; /// Get the fields of a data structure if that structure is a struct with named fields; /// otherwise, return a compile error that points to the site of the macro invocation. diff --git a/crates/bevy_math/src/bounding/bounded2d/mod.rs b/crates/bevy_math/src/bounding/bounded2d/mod.rs index c5be831a86f86..47a012b5d8a29 100644 --- a/crates/bevy_math/src/bounding/bounded2d/mod.rs +++ b/crates/bevy_math/src/bounding/bounded2d/mod.rs @@ -2,9 +2,8 @@ mod primitive_impls; use super::{BoundingVolume, IntersectsVolume}; use crate::{ - ops, + FloatPow, Isometry2d, ops, prelude::{Mat2, Rot2, Vec2}, - FloatPow, Isometry2d, }; #[cfg(feature = "bevy_reflect")] @@ -263,8 +262,9 @@ impl IntersectsVolume for Aabb2d { mod aabb2d_tests { use super::Aabb2d; use crate::{ + Vec2, bounding::{BoundingCircle, BoundingVolume, IntersectsVolume}, - ops, Vec2, + ops, }; #[test] @@ -614,8 +614,9 @@ impl IntersectsVolume for BoundingCircle { mod bounding_circle_tests { use super::BoundingCircle; use crate::{ + Vec2, bounding::{BoundingVolume, IntersectsVolume}, - ops, Vec2, + ops, }; #[test] diff --git a/crates/bevy_math/src/bounding/bounded2d/primitive_impls.rs b/crates/bevy_math/src/bounding/bounded2d/primitive_impls.rs index e1fe6afd774d5..cf1f2d8f47132 100644 --- a/crates/bevy_math/src/bounding/bounded2d/primitive_impls.rs +++ b/crates/bevy_math/src/bounding/bounded2d/primitive_impls.rs @@ -1,13 +1,13 @@ //! Contains [`Bounded2d`] implementations for [geometric primitives](crate::primitives). use crate::{ + Dir2, Isometry2d, Mat2, Rot2, Vec2, bounding::BoundingVolume, ops, primitives::{ Annulus, Arc2d, Capsule2d, Circle, CircularSector, CircularSegment, Ellipse, Line2d, Plane2d, Polygon, Polyline2d, Rectangle, RegularPolygon, Rhombus, Segment2d, Triangle2d, }, - Dir2, Isometry2d, Mat2, Rot2, Vec2, }; use core::f32::consts::{FRAC_PI_2, PI, TAU}; @@ -446,6 +446,7 @@ mod tests { use glam::Vec2; use crate::{ + Dir2, Isometry2d, Rot2, bounding::Bounded2d, ops::{self, FloatPow}, primitives::{ @@ -453,7 +454,6 @@ mod tests { Plane2d, Polygon, Polyline2d, Rectangle, RegularPolygon, Rhombus, Segment2d, Triangle2d, }, - Dir2, Isometry2d, Rot2, }; #[test] diff --git a/crates/bevy_math/src/bounding/bounded3d/extrusion.rs b/crates/bevy_math/src/bounding/bounded3d/extrusion.rs index 47d5d6676356a..98331164e19e0 100644 --- a/crates/bevy_math/src/bounding/bounded3d/extrusion.rs +++ b/crates/bevy_math/src/bounding/bounded3d/extrusion.rs @@ -3,13 +3,13 @@ use core::f32::consts::FRAC_PI_2; use glam::{Vec2, Vec3A, Vec3Swizzles}; use crate::{ + Isometry2d, Isometry3d, Quat, Rot2, bounding::{BoundingCircle, BoundingVolume}, ops, primitives::{ Capsule2d, Cuboid, Cylinder, Ellipse, Extrusion, Line2d, Polygon, Polyline2d, Primitive2d, Rectangle, RegularPolygon, Segment2d, Triangle2d, }, - Isometry2d, Isometry3d, Quat, Rot2, }; #[cfg(feature = "alloc")] @@ -270,13 +270,13 @@ mod tests { use glam::{EulerRot, Quat, Vec2, Vec3, Vec3A}; use crate::{ + Dir2, Isometry3d, bounding::{Bounded3d, BoundingVolume}, ops, primitives::{ Capsule2d, Circle, Ellipse, Extrusion, Line2d, Polygon, Polyline2d, Rectangle, RegularPolygon, Segment2d, Triangle2d, }, - Dir2, Isometry3d, }; #[test] diff --git a/crates/bevy_math/src/bounding/bounded3d/mod.rs b/crates/bevy_math/src/bounding/bounded3d/mod.rs index c4f3c979f67cb..c5f53b83b137b 100644 --- a/crates/bevy_math/src/bounding/bounded3d/mod.rs +++ b/crates/bevy_math/src/bounding/bounded3d/mod.rs @@ -5,8 +5,8 @@ use glam::Mat3; use super::{BoundingVolume, IntersectsVolume}; use crate::{ - ops::{self, FloatPow}, Isometry3d, Quat, Vec3A, + ops::{self, FloatPow}, }; #[cfg(feature = "bevy_reflect")] @@ -267,8 +267,9 @@ impl IntersectsVolume for Aabb3d { mod aabb3d_tests { use super::Aabb3d; use crate::{ + Quat, Vec3, Vec3A, bounding::{BoundingSphere, BoundingVolume, IntersectsVolume}, - ops, Quat, Vec3, Vec3A, + ops, }; #[test] @@ -646,8 +647,9 @@ mod bounding_sphere_tests { use super::BoundingSphere; use crate::{ + Quat, Vec3, Vec3A, bounding::{BoundingVolume, IntersectsVolume}, - ops, Quat, Vec3, Vec3A, + ops, }; #[test] diff --git a/crates/bevy_math/src/bounding/bounded3d/primitive_impls.rs b/crates/bevy_math/src/bounding/bounded3d/primitive_impls.rs index 1f4e2a1666d17..7baf43e36f540 100644 --- a/crates/bevy_math/src/bounding/bounded3d/primitive_impls.rs +++ b/crates/bevy_math/src/bounding/bounded3d/primitive_impls.rs @@ -1,13 +1,13 @@ //! Contains [`Bounded3d`] implementations for [geometric primitives](crate::primitives). use crate::{ + Isometry2d, Isometry3d, Mat3, Vec2, Vec3, Vec3A, bounding::{Bounded2d, BoundingCircle, BoundingVolume}, ops, primitives::{ Capsule3d, Cone, ConicalFrustum, Cuboid, Cylinder, InfinitePlane3d, Line3d, Polyline3d, Segment3d, Sphere, Torus, Triangle2d, Triangle3d, }, - Isometry2d, Isometry3d, Mat3, Vec2, Vec3, Vec3A, }; #[cfg(feature = "alloc")] @@ -376,16 +376,16 @@ impl Bounded3d for Triangle3d { #[cfg(test)] mod tests { - use crate::{bounding::BoundingVolume, ops, Isometry3d}; + use crate::{Isometry3d, bounding::BoundingVolume, ops}; use glam::{Quat, Vec3, Vec3A}; use crate::{ + Dir3, bounding::Bounded3d, primitives::{ Capsule3d, Cone, ConicalFrustum, Cuboid, Cylinder, InfinitePlane3d, Line3d, Polyline3d, Segment3d, Sphere, Torus, Triangle3d, }, - Dir3, }; #[test] diff --git a/crates/bevy_math/src/bounding/raycast2d.rs b/crates/bevy_math/src/bounding/raycast2d.rs index 3b46bcfba62c3..5c50875e6447d 100644 --- a/crates/bevy_math/src/bounding/raycast2d.rs +++ b/crates/bevy_math/src/bounding/raycast2d.rs @@ -1,7 +1,7 @@ use super::{Aabb2d, BoundingCircle, IntersectsVolume}; use crate::{ - ops::{self, FloatPow}, Dir2, Ray2d, Vec2, + ops::{self, FloatPow}, }; #[cfg(feature = "bevy_reflect")] @@ -67,11 +67,7 @@ impl RayCast2d { let tmin = tmin_x.max(tmin_y).max(0.); let tmax = tmax_y.min(tmax_x).min(self.max); - if tmin <= tmax { - Some(tmin) - } else { - None - } + if tmin <= tmax { Some(tmin) } else { None } } /// Get the distance of an intersection with a [`BoundingCircle`], if any. diff --git a/crates/bevy_math/src/bounding/raycast3d.rs b/crates/bevy_math/src/bounding/raycast3d.rs index bfd5d17a0dd8c..45023edf5b69e 100644 --- a/crates/bevy_math/src/bounding/raycast3d.rs +++ b/crates/bevy_math/src/bounding/raycast3d.rs @@ -1,7 +1,7 @@ use super::{Aabb3d, BoundingSphere, IntersectsVolume}; use crate::{ - ops::{self, FloatPow}, Dir3A, Ray3d, Vec3A, + ops::{self, FloatPow}, }; #[cfg(feature = "bevy_reflect")] @@ -64,11 +64,7 @@ impl RayCast3d { let tmin = tmin.max_element().max(0.); let tmax = tmax.min_element().min(self.max); - if tmin <= tmax { - Some(tmin) - } else { - None - } + if tmin <= tmax { Some(tmin) } else { None } } /// Get the distance of an intersection with a [`BoundingSphere`], if any. diff --git a/crates/bevy_math/src/common_traits.rs b/crates/bevy_math/src/common_traits.rs index a9a8ef910a86e..80004a9a35505 100644 --- a/crates/bevy_math/src/common_traits.rs +++ b/crates/bevy_math/src/common_traits.rs @@ -1,6 +1,6 @@ //! This module contains abstract mathematical traits shared by types used in `bevy_math`. -use crate::{ops, Dir2, Dir3, Dir3A, Quat, Rot2, Vec2, Vec3, Vec3A, Vec4}; +use crate::{Dir2, Dir3, Dir3A, Quat, Rot2, Vec2, Vec3, Vec3A, Vec4, ops}; use core::{ fmt::Debug, ops::{Add, Div, Mul, Neg, Sub}, diff --git a/crates/bevy_math/src/cubic_splines/curve_impls.rs b/crates/bevy_math/src/cubic_splines/curve_impls.rs index 85fd9fb6adab6..520ad5aad3287 100644 --- a/crates/bevy_math/src/cubic_splines/curve_impls.rs +++ b/crates/bevy_math/src/cubic_splines/curve_impls.rs @@ -1,8 +1,8 @@ use super::{CubicSegment, RationalSegment}; use crate::common_traits::{VectorSpace, WithDerivative, WithTwoDerivatives}; use crate::curve::{ - derivatives::{SampleDerivative, SampleTwoDerivatives}, Curve, Interval, + derivatives::{SampleDerivative, SampleTwoDerivatives}, }; #[cfg(feature = "alloc")] diff --git a/crates/bevy_math/src/cubic_splines/mod.rs b/crates/bevy_math/src/cubic_splines/mod.rs index 32e13f6720a92..8e9b12352654c 100644 --- a/crates/bevy_math/src/cubic_splines/mod.rs +++ b/crates/bevy_math/src/cubic_splines/mod.rs @@ -3,11 +3,11 @@ #[cfg(feature = "curve")] mod curve_impls; use crate::{ - ops::{self, FloatPow}, Vec2, VectorSpace, + ops::{self, FloatPow}, }; #[cfg(feature = "bevy_reflect")] -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; use thiserror::Error; #[cfg(feature = "alloc")] use {alloc::vec, alloc::vec::Vec, core::iter::once, itertools::Itertools}; @@ -925,7 +925,9 @@ impl CyclicCubicGenerator

for LinearSpline

for LinearSpline

{ /// An error indicating that a spline construction didn't have enough control points to generate a curve. #[derive(Clone, Debug, Error)] -#[error( - "Not enough data to build curve: needed at least {expected} control points but was only given {given}" -)] +#[error("Not enough data to build curve: needed at least {expected} control points but was only given {given}")] pub struct InsufficientDataError { expected: usize, given: usize, @@ -1624,7 +1622,7 @@ mod tests { ops::{self, FloatPow}, }; use alloc::vec::Vec; - use glam::{Vec2, vec2}; + use glam::{vec2, Vec2}; /// How close two floats can be and still be considered equal const FLOAT_EQ: f32 = 1e-5; @@ -1707,26 +1705,18 @@ mod tests { assert!(curve.position(3.).abs_diff_eq(p3, FLOAT_EQ)); // Tangents at segment endpoints - assert!( - curve - .velocity(0.) - .abs_diff_eq((p1 - p0) * tension * 2., FLOAT_EQ) - ); - assert!( - curve - .velocity(1.) - .abs_diff_eq((p2 - p0) * tension, FLOAT_EQ) - ); - assert!( - curve - .velocity(2.) - .abs_diff_eq((p3 - p1) * tension, FLOAT_EQ) - ); - assert!( - curve - .velocity(3.) - .abs_diff_eq((p3 - p2) * tension * 2., FLOAT_EQ) - ); + assert!(curve + .velocity(0.) + .abs_diff_eq((p1 - p0) * tension * 2., FLOAT_EQ)); + assert!(curve + .velocity(1.) + .abs_diff_eq((p2 - p0) * tension, FLOAT_EQ)); + assert!(curve + .velocity(2.) + .abs_diff_eq((p3 - p1) * tension, FLOAT_EQ)); + assert!(curve + .velocity(3.) + .abs_diff_eq((p3 - p2) * tension * 2., FLOAT_EQ)); } /// Test that [`RationalCurve`] properly generalizes [`CubicCurve`]. A Cubic upgraded to a rational diff --git a/crates/bevy_math/src/curve/adaptors.rs b/crates/bevy_math/src/curve/adaptors.rs index a3b6c48781a0e..afc34837d3b13 100644 --- a/crates/bevy_math/src/curve/adaptors.rs +++ b/crates/bevy_math/src/curve/adaptors.rs @@ -1,10 +1,10 @@ //! Adaptors used by the Curve API for transforming and combining curves together. -use super::Curve; use super::interval::*; +use super::Curve; -use crate::VectorSpace; use crate::ops; +use crate::VectorSpace; use core::any::type_name; use core::fmt::{self, Debug}; use core::marker::PhantomData; @@ -12,7 +12,7 @@ use core::marker::PhantomData; #[cfg(feature = "bevy_reflect")] use { alloc::format, - bevy_reflect::{FromReflect, Reflect, TypePath, utility::GenericTypePathCell}, + bevy_reflect::{utility::GenericTypePathCell, FromReflect, Reflect, TypePath}, }; #[cfg(feature = "bevy_reflect")] diff --git a/crates/bevy_math/src/curve/cores.rs b/crates/bevy_math/src/curve/cores.rs index ee154d61bcb31..838d0d116d440 100644 --- a/crates/bevy_math/src/curve/cores.rs +++ b/crates/bevy_math/src/curve/cores.rs @@ -507,9 +507,7 @@ pub enum ChunkedUnevenCoreError { }, /// Tried to infer the width, but the ratio of lengths wasn't an integer, so no such length exists. - #[error( - "The length of the list of values ({values_len}) was not divisible by that of the list of times ({times_len})" - )] + #[error("The length of the list of values ({values_len}) was not divisible by that of the list of times ({times_len})")] NonDivisibleLengths { /// The length of the value buffer. values_len: usize, @@ -700,7 +698,7 @@ mod tests { use super::{ChunkedUnevenCore, EvenCore, UnevenCore}; use crate::curve::{cores::InterpolationDatum, interval}; use alloc::vec; - use approx::{AbsDiffEq, assert_abs_diff_eq}; + use approx::{assert_abs_diff_eq, AbsDiffEq}; fn approx_between(datum: InterpolationDatum, start: T, end: T, p: f32) -> bool where diff --git a/crates/bevy_math/src/curve/derivatives/adaptor_impls.rs b/crates/bevy_math/src/curve/derivatives/adaptor_impls.rs index 1d59959a23321..a499526b78338 100644 --- a/crates/bevy_math/src/curve/derivatives/adaptor_impls.rs +++ b/crates/bevy_math/src/curve/derivatives/adaptor_impls.rs @@ -4,11 +4,11 @@ use super::{SampleDerivative, SampleTwoDerivatives}; use crate::common_traits::{HasTangent, Sum, VectorSpace, WithDerivative, WithTwoDerivatives}; use crate::curve::{ - Curve, adaptors::{ ChainCurve, ConstantCurve, ContinuationCurve, CurveReparamCurve, ForeverCurve, GraphCurve, LinearReparamCurve, PingPongCurve, RepeatCurve, ReverseCurve, ZipCurve, }, + Curve, }; // -- ConstantCurve @@ -454,7 +454,7 @@ mod tests { use super::*; use crate::cubic_splines::{CubicBezier, CubicCardinalSpline, CubicCurve, CubicGenerator}; use crate::curve::{Curve, CurveExt, Interval}; - use crate::{Vec2, Vec3, vec2}; + use crate::{vec2, Vec2, Vec3}; fn test_curve() -> CubicCurve { let control_pts = [[ diff --git a/crates/bevy_math/src/curve/easing.rs b/crates/bevy_math/src/curve/easing.rs index b6612576f2e9c..18f42d3f13f24 100644 --- a/crates/bevy_math/src/curve/easing.rs +++ b/crates/bevy_math/src/curve/easing.rs @@ -4,8 +4,8 @@ //! [easing functions]: EaseFunction use crate::{ - Dir2, Dir3, Dir3A, Isometry2d, Isometry3d, Quat, Rot2, VectorSpace, curve::{Curve, CurveExt, FunctionCurve, Interval}, + Dir2, Dir3, Dir3A, Isometry2d, Isometry3d, Quat, Rot2, VectorSpace, }; use variadics_please::all_tuples_enumerated; @@ -597,7 +597,7 @@ pub enum EaseFunction { mod easing_functions { use core::f32::consts::{FRAC_PI_2, FRAC_PI_3, PI}; - use crate::{FloatPow, ops}; + use crate::{ops, FloatPow}; #[inline] pub(crate) fn linear(t: f32) -> f32 { diff --git a/crates/bevy_math/src/curve/interval.rs b/crates/bevy_math/src/curve/interval.rs index 31b159b707b98..007e523c95be6 100644 --- a/crates/bevy_math/src/curve/interval.rs +++ b/crates/bevy_math/src/curve/interval.rs @@ -202,7 +202,7 @@ mod tests { use super::*; use alloc::vec::Vec; - use approx::{AbsDiffEq, assert_abs_diff_eq}; + use approx::{assert_abs_diff_eq, AbsDiffEq}; #[test] fn make_intervals() { @@ -265,16 +265,14 @@ mod tests { let ivl6 = Interval::EVERYWHERE; assert!(ivl1.intersect(ivl2).is_ok_and(|ivl| ivl == Interval::UNIT)); - assert!( - ivl1.intersect(ivl3) - .is_ok_and(|ivl| ivl == interval(-1.0, 0.0).unwrap()) - ); + assert!(ivl1 + .intersect(ivl3) + .is_ok_and(|ivl| ivl == interval(-1.0, 0.0).unwrap())); assert!(ivl2.intersect(ivl3).is_err()); assert!(ivl1.intersect(ivl4).is_ok_and(|ivl| ivl == Interval::UNIT)); - assert!( - ivl1.intersect(ivl5) - .is_ok_and(|ivl| ivl == interval(-1.0, 0.0).unwrap()) - ); + assert!(ivl1 + .intersect(ivl5) + .is_ok_and(|ivl| ivl == interval(-1.0, 0.0).unwrap())); assert!(ivl4.intersect(ivl5).is_err()); assert_eq!(ivl1.intersect(ivl6).unwrap(), ivl1); assert_eq!(ivl4.intersect(ivl6).unwrap(), ivl4); diff --git a/crates/bevy_math/src/curve/mod.rs b/crates/bevy_math/src/curve/mod.rs index 51246de724461..94e7b0151e226 100644 --- a/crates/bevy_math/src/curve/mod.rs +++ b/crates/bevy_math/src/curve/mod.rs @@ -298,7 +298,7 @@ pub mod sample_curves; // bevy_math::curve re-exports all commonly-needed curve-related items. pub use adaptors::*; pub use easing::*; -pub use interval::{Interval, interval}; +pub use interval::{interval, Interval}; #[cfg(feature = "alloc")] pub use { @@ -1004,9 +1004,9 @@ pub enum ResamplingError { #[cfg(test)] mod tests { use super::*; - use crate::{Quat, ops}; + use crate::{ops, Quat}; use alloc::vec::Vec; - use approx::{AbsDiffEq, assert_abs_diff_eq}; + use approx::{assert_abs_diff_eq, AbsDiffEq}; use core::f32::consts::TAU; use glam::*; diff --git a/crates/bevy_math/src/curve/sample_curves.rs b/crates/bevy_math/src/curve/sample_curves.rs index d43cc016a32c5..f0fa928abba57 100644 --- a/crates/bevy_math/src/curve/sample_curves.rs +++ b/crates/bevy_math/src/curve/sample_curves.rs @@ -10,7 +10,7 @@ use core::any::type_name; use core::fmt::{self, Debug}; #[cfg(feature = "bevy_reflect")] -use bevy_reflect::{Reflect, TypePath, utility::GenericTypePathCell}; +use bevy_reflect::{utility::GenericTypePathCell, Reflect, TypePath}; #[cfg(feature = "bevy_reflect")] mod paths { @@ -370,7 +370,7 @@ mod tests { //! - 'static closures //! - function pointers use super::{SampleCurve, UnevenSampleCurve}; - use crate::{VectorSpace, curve::Interval}; + use crate::{curve::Interval, VectorSpace}; use alloc::boxed::Box; use bevy_reflect::Reflect; diff --git a/crates/bevy_math/src/direction.rs b/crates/bevy_math/src/direction.rs index 8b99d1fa30e48..e61e84ee1a129 100644 --- a/crates/bevy_math/src/direction.rs +++ b/crates/bevy_math/src/direction.rs @@ -1,6 +1,6 @@ use crate::{ - Quat, Rot2, Vec2, Vec3, Vec3A, primitives::{Primitive2d, Primitive3d}, + Quat, Rot2, Vec2, Vec3, Vec3A, }; use core::f32::consts::FRAC_1_SQRT_2; diff --git a/crates/bevy_math/src/isometry.rs b/crates/bevy_math/src/isometry.rs index 59764587b10e0..1d88736d3bd2e 100644 --- a/crates/bevy_math/src/isometry.rs +++ b/crates/bevy_math/src/isometry.rs @@ -7,7 +7,7 @@ use core::ops::Mul; use approx::{AbsDiffEq, RelativeEq, UlpsEq}; #[cfg(feature = "bevy_reflect")] -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; #[cfg(all(feature = "bevy_reflect", feature = "serialize"))] use bevy_reflect::{ReflectDeserialize, ReflectSerialize}; diff --git a/crates/bevy_math/src/lib.rs b/crates/bevy_math/src/lib.rs index 9c7a8b4adc27a..20d458db72d23 100644 --- a/crates/bevy_math/src/lib.rs +++ b/crates/bevy_math/src/lib.rs @@ -71,15 +71,15 @@ pub use sampling::{FromRng, ShapeSample}; pub mod prelude { #[doc(hidden)] pub use crate::{ - BVec2, BVec3, BVec3A, BVec4, BVec4A, EulerRot, FloatExt, IRect, IVec2, IVec3, IVec4, - Isometry2d, Isometry3d, Mat2, Mat3, Mat3A, Mat4, Quat, Ray2d, Ray3d, Rect, Rot2, - StableInterpolate, URect, UVec2, UVec3, UVec4, Vec2, Vec2Swizzles, Vec3, Vec3A, - Vec3Swizzles, Vec4, Vec4Swizzles, bvec2, bvec3, bvec3a, bvec4, bvec4a, + bvec2, bvec3, bvec3a, bvec4, bvec4a, cubic_splines::{CubicNurbsError, CubicSegment, RationalSegment}, direction::{Dir2, Dir3, Dir3A}, ivec2, ivec3, ivec4, mat2, mat3, mat3a, mat4, ops, primitives::*, - quat, uvec2, uvec3, uvec4, vec2, vec3, vec3a, vec4, + quat, uvec2, uvec3, uvec4, vec2, vec3, vec3a, vec4, BVec2, BVec3, BVec3A, BVec4, BVec4A, + EulerRot, FloatExt, IRect, IVec2, IVec3, IVec4, Isometry2d, Isometry3d, Mat2, Mat3, Mat3A, + Mat4, Quat, Ray2d, Ray3d, Rect, Rot2, StableInterpolate, URect, UVec2, UVec3, UVec4, Vec2, + Vec2Swizzles, Vec3, Vec3A, Vec3Swizzles, Vec4, Vec4Swizzles, }; #[doc(hidden)] diff --git a/crates/bevy_math/src/ops.rs b/crates/bevy_math/src/ops.rs index 2bcceb43a6759..e9d27ac54a83a 100644 --- a/crates/bevy_math/src/ops.rs +++ b/crates/bevy_math/src/ops.rs @@ -463,7 +463,11 @@ mod libm_ops_for_no_std { let result = libm::remainderf(x, y); // libm::remainderf has a range of -y/2 to +y/2 - if result < 0. { result + y } else { result } + if result < 0. { + result + y + } else { + result + } } /// Computes the absolute value of x. diff --git a/crates/bevy_math/src/primitives/dim2.rs b/crates/bevy_math/src/primitives/dim2.rs index 8867999f13fc3..c336edac45a76 100644 --- a/crates/bevy_math/src/primitives/dim2.rs +++ b/crates/bevy_math/src/primitives/dim2.rs @@ -4,15 +4,15 @@ use thiserror::Error; use super::{Measured2d, Primitive2d, WindingOrder}; use crate::{ - Dir2, Rot2, Vec2, ops::{self, FloatPow}, + Dir2, Rot2, Vec2, }; #[cfg(feature = "alloc")] use super::polygon::is_polygon_simple; #[cfg(feature = "bevy_reflect")] -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; #[cfg(all(feature = "serialize", feature = "bevy_reflect"))] use bevy_reflect::{ReflectDeserialize, ReflectSerialize}; diff --git a/crates/bevy_math/src/primitives/dim3.rs b/crates/bevy_math/src/primitives/dim3.rs index ec0c1b33452de..a828fa8247587 100644 --- a/crates/bevy_math/src/primitives/dim3.rs +++ b/crates/bevy_math/src/primitives/dim3.rs @@ -2,12 +2,12 @@ use core::f32::consts::{FRAC_PI_3, PI}; use super::{Circle, Measured2d, Measured3d, Primitive2d, Primitive3d}; use crate::{ - Dir3, InvalidDirectionError, Isometry3d, Mat3, Vec2, Vec3, ops::{self, FloatPow}, + Dir3, InvalidDirectionError, Isometry3d, Mat3, Vec2, Vec3, }; #[cfg(feature = "bevy_reflect")] -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; #[cfg(all(feature = "serialize", feature = "bevy_reflect"))] use bevy_reflect::{ReflectDeserialize, ReflectSerialize}; use glam::Quat; diff --git a/crates/bevy_math/src/primitives/polygon.rs b/crates/bevy_math/src/primitives/polygon.rs index afa8d55db5b4a..20d35b552c827 100644 --- a/crates/bevy_math/src/primitives/polygon.rs +++ b/crates/bevy_math/src/primitives/polygon.rs @@ -322,7 +322,7 @@ pub fn is_polygon_simple(vertices: &[Vec2]) -> bool { #[cfg(test)] mod tests { - use crate::{Vec2, primitives::polygon::is_polygon_simple}; + use crate::{primitives::polygon::is_polygon_simple, Vec2}; #[test] fn complex_polygon() { diff --git a/crates/bevy_math/src/primitives/serde.rs b/crates/bevy_math/src/primitives/serde.rs index 91dff0c278b02..7db6be9700114 100644 --- a/crates/bevy_math/src/primitives/serde.rs +++ b/crates/bevy_math/src/primitives/serde.rs @@ -6,9 +6,9 @@ pub(crate) mod array { use core::marker::PhantomData; use serde::{ - Deserialize, Deserializer, Serialize, Serializer, de::{SeqAccess, Visitor}, ser::SerializeTuple, + Deserialize, Deserializer, Serialize, Serializer, }; pub fn serialize( diff --git a/crates/bevy_math/src/ray.rs b/crates/bevy_math/src/ray.rs index 07364e7bb4a3c..273ed61fa4b97 100644 --- a/crates/bevy_math/src/ray.rs +++ b/crates/bevy_math/src/ray.rs @@ -1,6 +1,7 @@ use crate::{ - Dir2, Dir3, Vec2, Vec3, ops, + ops, primitives::{InfinitePlane3d, Plane2d}, + Dir2, Dir3, Vec2, Vec3, }; #[cfg(feature = "bevy_reflect")] @@ -109,36 +110,31 @@ mod tests { ray.intersect_plane(Vec2::Y, Plane2d::new(Vec2::NEG_Y)), Some(1.0) ); - assert!( - ray.intersect_plane(Vec2::NEG_Y, Plane2d::new(Vec2::Y)) - .is_none() - ); - assert!( - ray.intersect_plane(Vec2::NEG_Y, Plane2d::new(Vec2::NEG_Y)) - .is_none() - ); + assert!(ray + .intersect_plane(Vec2::NEG_Y, Plane2d::new(Vec2::Y)) + .is_none()); + assert!(ray + .intersect_plane(Vec2::NEG_Y, Plane2d::new(Vec2::NEG_Y)) + .is_none()); // Diagonal assert_eq!( ray.intersect_plane(Vec2::Y, Plane2d::new(Vec2::ONE)), Some(1.0) ); - assert!( - ray.intersect_plane(Vec2::NEG_Y, Plane2d::new(Vec2::ONE)) - .is_none() - ); + assert!(ray + .intersect_plane(Vec2::NEG_Y, Plane2d::new(Vec2::ONE)) + .is_none()); // Parallel - assert!( - ray.intersect_plane(Vec2::X, Plane2d::new(Vec2::X)) - .is_none() - ); + assert!(ray + .intersect_plane(Vec2::X, Plane2d::new(Vec2::X)) + .is_none()); // Parallel with simulated rounding error - assert!( - ray.intersect_plane(Vec2::X, Plane2d::new(Vec2::X + Vec2::Y * f32::EPSILON)) - .is_none() - ); + assert!(ray + .intersect_plane(Vec2::X, Plane2d::new(Vec2::X + Vec2::Y * f32::EPSILON)) + .is_none()); } #[test] @@ -154,38 +150,33 @@ mod tests { ray.intersect_plane(Vec3::Z, InfinitePlane3d::new(Vec3::NEG_Z)), Some(1.0) ); - assert!( - ray.intersect_plane(Vec3::NEG_Z, InfinitePlane3d::new(Vec3::Z)) - .is_none() - ); - assert!( - ray.intersect_plane(Vec3::NEG_Z, InfinitePlane3d::new(Vec3::NEG_Z)) - .is_none() - ); + assert!(ray + .intersect_plane(Vec3::NEG_Z, InfinitePlane3d::new(Vec3::Z)) + .is_none()); + assert!(ray + .intersect_plane(Vec3::NEG_Z, InfinitePlane3d::new(Vec3::NEG_Z)) + .is_none()); // Diagonal assert_eq!( ray.intersect_plane(Vec3::Z, InfinitePlane3d::new(Vec3::ONE)), Some(1.0) ); - assert!( - ray.intersect_plane(Vec3::NEG_Z, InfinitePlane3d::new(Vec3::ONE)) - .is_none() - ); + assert!(ray + .intersect_plane(Vec3::NEG_Z, InfinitePlane3d::new(Vec3::ONE)) + .is_none()); // Parallel - assert!( - ray.intersect_plane(Vec3::X, InfinitePlane3d::new(Vec3::X)) - .is_none() - ); + assert!(ray + .intersect_plane(Vec3::X, InfinitePlane3d::new(Vec3::X)) + .is_none()); // Parallel with simulated rounding error - assert!( - ray.intersect_plane( + assert!(ray + .intersect_plane( Vec3::X, InfinitePlane3d::new(Vec3::X + Vec3::Z * f32::EPSILON) ) - .is_none() - ); + .is_none()); } } diff --git a/crates/bevy_math/src/rects/irect.rs b/crates/bevy_math/src/rects/irect.rs index 6fc7acd476a46..73e830f085e29 100644 --- a/crates/bevy_math/src/rects/irect.rs +++ b/crates/bevy_math/src/rects/irect.rs @@ -1,7 +1,7 @@ use crate::{IVec2, Rect, URect}; #[cfg(feature = "bevy_reflect")] -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; #[cfg(all(feature = "serialize", feature = "bevy_reflect"))] use bevy_reflect::{ReflectDeserialize, ReflectSerialize}; diff --git a/crates/bevy_math/src/rects/rect.rs b/crates/bevy_math/src/rects/rect.rs index a0d6ab4a60cf2..901a569a71f4e 100644 --- a/crates/bevy_math/src/rects/rect.rs +++ b/crates/bevy_math/src/rects/rect.rs @@ -1,7 +1,7 @@ use crate::{IRect, URect, Vec2}; #[cfg(feature = "bevy_reflect")] -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; #[cfg(all(feature = "serialize", feature = "bevy_reflect"))] use bevy_reflect::{ReflectDeserialize, ReflectSerialize}; diff --git a/crates/bevy_math/src/rects/urect.rs b/crates/bevy_math/src/rects/urect.rs index 7f47c43c46d8d..54127504654ca 100644 --- a/crates/bevy_math/src/rects/urect.rs +++ b/crates/bevy_math/src/rects/urect.rs @@ -1,7 +1,7 @@ use crate::{IRect, Rect, UVec2}; #[cfg(feature = "bevy_reflect")] -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; #[cfg(all(feature = "serialize", feature = "bevy_reflect"))] use bevy_reflect::{ReflectDeserialize, ReflectSerialize}; @@ -101,10 +101,7 @@ impl URect { /// ``` #[inline] pub fn from_center_size(origin: UVec2, size: UVec2) -> Self { - assert!( - origin.cmpge(size / 2).all(), - "Origin must always be greater than or equal to (size / 2) otherwise the rectangle is undefined! Origin was {origin} and size was {size}" - ); + assert!(origin.cmpge(size / 2).all(), "Origin must always be greater than or equal to (size / 2) otherwise the rectangle is undefined! Origin was {origin} and size was {size}"); let half_size = size / 2; Self::from_center_half_size(origin, half_size) } @@ -125,10 +122,7 @@ impl URect { /// ``` #[inline] pub fn from_center_half_size(origin: UVec2, half_size: UVec2) -> Self { - assert!( - origin.cmpge(half_size).all(), - "Origin must always be greater than or equal to half_size otherwise the rectangle is undefined! Origin was {origin} and half_size was {half_size}" - ); + assert!(origin.cmpge(half_size).all(), "Origin must always be greater than or equal to half_size otherwise the rectangle is undefined! Origin was {origin} and half_size was {half_size}"); Self { min: origin - half_size, max: origin + half_size, diff --git a/crates/bevy_math/src/rotation2d.rs b/crates/bevy_math/src/rotation2d.rs index 167ed0bc8d700..3f5d3031cf1a9 100644 --- a/crates/bevy_math/src/rotation2d.rs +++ b/crates/bevy_math/src/rotation2d.rs @@ -8,7 +8,7 @@ use crate::{ }; #[cfg(feature = "bevy_reflect")] -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; #[cfg(all(feature = "serialize", feature = "bevy_reflect"))] use bevy_reflect::{ReflectDeserialize, ReflectSerialize}; @@ -518,7 +518,7 @@ mod tests { use approx::assert_relative_eq; - use crate::{Dir2, Rot2, Vec2, ops}; + use crate::{ops, Dir2, Rot2, Vec2}; #[test] fn creation() { @@ -656,37 +656,31 @@ mod tests { #[test] fn try_normalize() { // Valid - assert!( - Rot2 { - sin: 10.0, - cos: 5.0, - } - .try_normalize() - .is_some() - ); + assert!(Rot2 { + sin: 10.0, + cos: 5.0, + } + .try_normalize() + .is_some()); // NaN - assert!( - Rot2 { - sin: f32::NAN, - cos: 5.0, - } - .try_normalize() - .is_none() - ); + assert!(Rot2 { + sin: f32::NAN, + cos: 5.0, + } + .try_normalize() + .is_none()); // Zero assert!(Rot2 { sin: 0.0, cos: 0.0 }.try_normalize().is_none()); // Non-finite - assert!( - Rot2 { - sin: f32::INFINITY, - cos: 5.0, - } - .try_normalize() - .is_none() - ); + assert!(Rot2 { + sin: f32::INFINITY, + cos: 5.0, + } + .try_normalize() + .is_none()); } #[test] diff --git a/crates/bevy_math/src/sampling/mesh_sampling.rs b/crates/bevy_math/src/sampling/mesh_sampling.rs index 8e4def3fecde5..898198dea4261 100644 --- a/crates/bevy_math/src/sampling/mesh_sampling.rs +++ b/crates/bevy_math/src/sampling/mesh_sampling.rs @@ -1,8 +1,8 @@ //! Functionality related to random sampling from triangle meshes. use crate::{ - ShapeSample, Vec3, primitives::{Measured2d, Triangle3d}, + ShapeSample, Vec3, }; use alloc::vec::Vec; use rand::Rng; diff --git a/crates/bevy_math/src/sampling/shape_sampling.rs b/crates/bevy_math/src/sampling/shape_sampling.rs index 6dc6324362153..3be0ead1da98e 100644 --- a/crates/bevy_math/src/sampling/shape_sampling.rs +++ b/crates/bevy_math/src/sampling/shape_sampling.rs @@ -40,10 +40,10 @@ use core::f32::consts::{PI, TAU}; -use crate::{NormedVectorSpace, Vec2, Vec3, ops, primitives::*}; +use crate::{ops, primitives::*, NormedVectorSpace, Vec2, Vec3}; use rand::{ - Rng, distributions::{Distribution, WeightedIndex}, + Rng, }; /// Exposes methods to uniformly sample a variety of primitive shapes. diff --git a/crates/bevy_math/src/sampling/standard.rs b/crates/bevy_math/src/sampling/standard.rs index 8ec2e99265800..7de8270e30ea1 100644 --- a/crates/bevy_math/src/sampling/standard.rs +++ b/crates/bevy_math/src/sampling/standard.rs @@ -24,12 +24,12 @@ use core::f32::consts::TAU; use crate::{ - Dir2, Dir3, Dir3A, Quat, Rot2, ShapeSample, Vec3A, primitives::{Circle, Sphere}, + Dir2, Dir3, Dir3A, Quat, Rot2, ShapeSample, Vec3A, }; use rand::{ - Rng, distributions::{Distribution, Standard}, + Rng, }; /// Ergonomics trait for a type with a [`Standard`] distribution, allowing values to be generated diff --git a/crates/bevy_mesh/src/conversions.rs b/crates/bevy_mesh/src/conversions.rs index 506ba7341d47c..f68c2d6f74321 100644 --- a/crates/bevy_mesh/src/conversions.rs +++ b/crates/bevy_mesh/src/conversions.rs @@ -453,9 +453,7 @@ mod tests { error.to_string(), "cannot convert VertexAttributeValues::Uint32x4 to alloc::vec::Vec" ); - assert_eq!( - format!("{error:?}"), - "FromVertexAttributeError { from: Uint32x4([[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]), variant: \"Uint32x4\", into: \"alloc::vec::Vec\" }" - ); + assert_eq!(format!("{error:?}"), + "FromVertexAttributeError { from: Uint32x4([[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]), variant: \"Uint32x4\", into: \"alloc::vec::Vec\" }"); } } diff --git a/crates/bevy_mesh/src/mesh.rs b/crates/bevy_mesh/src/mesh.rs index 9594a812ba49f..44b313434e299 100644 --- a/crates/bevy_mesh/src/mesh.rs +++ b/crates/bevy_mesh/src/mesh.rs @@ -2,10 +2,10 @@ use bevy_transform::components::Transform; pub use wgpu_types::PrimitiveTopology; use super::{ - FourIterators, GenerateTangentsError, Indices, MeshAttributeData, MeshTrianglesError, - MeshVertexAttribute, MeshVertexAttributeId, MeshVertexBufferLayout, MeshVertexBufferLayoutRef, + face_area_normal, face_normal, generate_tangents_for_mesh, scale_normal, FourIterators, + GenerateTangentsError, Indices, MeshAttributeData, MeshTrianglesError, MeshVertexAttribute, + MeshVertexAttributeId, MeshVertexBufferLayout, MeshVertexBufferLayoutRef, MeshVertexBufferLayouts, MeshWindingInvertError, VertexAttributeValues, VertexBufferLayout, - face_area_normal, face_normal, generate_tangents_for_mesh, scale_normal, }; use alloc::collections::BTreeMap; use bevy_asset::{Asset, Handle, RenderAssetUsages}; @@ -442,10 +442,8 @@ impl Mesh { .map(|data| data.attribute.name.to_string()) .unwrap_or_else(|| format!("{attribute_id:?}")); - warn!( - "{name} has a different vertex count ({attribute_len}) than other attributes ({previous_vertex_count}) in this mesh, \ - all attributes will be truncated to match the smallest." - ); + warn!("{name} has a different vertex count ({attribute_len}) than other attributes ({previous_vertex_count}) in this mesh, \ + all attributes will be truncated to match the smallest."); vertex_count = Some(core::cmp::min(previous_vertex_count, attribute_len)); } } else { @@ -851,7 +849,7 @@ impl Mesh { other_attribute: other .attribute_data(attribute.id) .map(|data| data.attribute), - }); + }) } } } @@ -1238,11 +1236,11 @@ pub struct MergeMeshError { #[cfg(test)] mod tests { use super::Mesh; - use crate::PrimitiveTopology; use crate::mesh::{Indices, MeshWindingInvertError, VertexAttributeValues}; + use crate::PrimitiveTopology; use bevy_asset::RenderAssetUsages; - use bevy_math::Vec3; use bevy_math::primitives::Triangle3d; + use bevy_math::Vec3; use bevy_transform::components::Transform; #[test] diff --git a/crates/bevy_mesh/src/primitives/dim2.rs b/crates/bevy_mesh/src/primitives/dim2.rs index 131052c3c1b6a..16440e9b00f34 100644 --- a/crates/bevy_mesh/src/primitives/dim2.rs +++ b/crates/bevy_mesh/src/primitives/dim2.rs @@ -1,15 +1,16 @@ use core::f32::consts::FRAC_PI_2; -use crate::{Indices, Mesh, PerimeterSegment, primitives::dim3::triangle3d}; +use crate::{primitives::dim3::triangle3d, Indices, Mesh, PerimeterSegment}; use bevy_asset::RenderAssetUsages; use super::{Extrudable, MeshBuilder, Meshable}; use bevy_math::{ - FloatExt, Vec2, ops, + ops, primitives::{ Annulus, Capsule2d, Circle, CircularSector, CircularSegment, ConvexPolygon, Ellipse, Rectangle, RegularPolygon, Rhombus, Triangle2d, Triangle3d, WindingOrder, }, + FloatExt, Vec2, }; use bevy_reflect::prelude::*; use wgpu_types::PrimitiveTopology; @@ -1174,7 +1175,7 @@ impl From for Mesh { #[cfg(test)] mod tests { - use bevy_math::{FloatOrd, prelude::Annulus, primitives::RegularPolygon}; + use bevy_math::{prelude::Annulus, primitives::RegularPolygon, FloatOrd}; use bevy_platform_support::collections::HashSet; use crate::{Mesh, MeshBuilder, Meshable, VertexAttributeValues}; diff --git a/crates/bevy_mesh/src/primitives/dim3/capsule.rs b/crates/bevy_mesh/src/primitives/dim3/capsule.rs index 6ceb5817225ae..81c7f77306085 100644 --- a/crates/bevy_mesh/src/primitives/dim3/capsule.rs +++ b/crates/bevy_mesh/src/primitives/dim3/capsule.rs @@ -1,6 +1,6 @@ use crate::{Indices, Mesh, MeshBuilder, Meshable, PrimitiveTopology}; use bevy_asset::RenderAssetUsages; -use bevy_math::{Vec2, Vec3, ops, primitives::Capsule3d}; +use bevy_math::{ops, primitives::Capsule3d, Vec2, Vec3}; use bevy_reflect::prelude::*; /// Manner in which UV coordinates are distributed vertically. diff --git a/crates/bevy_mesh/src/primitives/dim3/cone.rs b/crates/bevy_mesh/src/primitives/dim3/cone.rs index 1ae9678df1006..fde442537025e 100644 --- a/crates/bevy_mesh/src/primitives/dim3/cone.rs +++ b/crates/bevy_mesh/src/primitives/dim3/cone.rs @@ -1,6 +1,6 @@ use crate::{Indices, Mesh, MeshBuilder, Meshable, PrimitiveTopology}; use bevy_asset::RenderAssetUsages; -use bevy_math::{Vec3, ops, primitives::Cone}; +use bevy_math::{ops, primitives::Cone, Vec3}; use bevy_reflect::prelude::*; /// Anchoring options for [`ConeMeshBuilder`] @@ -191,7 +191,7 @@ impl From for Mesh { #[cfg(test)] mod tests { use crate::{Mesh, MeshBuilder, Meshable, VertexAttributeValues}; - use bevy_math::{Vec2, primitives::Cone}; + use bevy_math::{primitives::Cone, Vec2}; /// Rounds floats to handle floating point error in tests. fn round_floats(points: &mut [[f32; N]]) { diff --git a/crates/bevy_mesh/src/primitives/dim3/conical_frustum.rs b/crates/bevy_mesh/src/primitives/dim3/conical_frustum.rs index 2a1a7eda13ecd..a90e9f972dc5c 100644 --- a/crates/bevy_mesh/src/primitives/dim3/conical_frustum.rs +++ b/crates/bevy_mesh/src/primitives/dim3/conical_frustum.rs @@ -1,6 +1,6 @@ use crate::{Indices, Mesh, MeshBuilder, Meshable, PrimitiveTopology}; use bevy_asset::RenderAssetUsages; -use bevy_math::{Vec3, ops, primitives::ConicalFrustum}; +use bevy_math::{ops, primitives::ConicalFrustum, Vec3}; use bevy_reflect::prelude::*; /// A builder used for creating a [`Mesh`] with a [`ConicalFrustum`] shape. diff --git a/crates/bevy_mesh/src/primitives/dim3/cuboid.rs b/crates/bevy_mesh/src/primitives/dim3/cuboid.rs index 96391f4794f4d..30689ab1318c6 100644 --- a/crates/bevy_mesh/src/primitives/dim3/cuboid.rs +++ b/crates/bevy_mesh/src/primitives/dim3/cuboid.rs @@ -1,6 +1,6 @@ use crate::{Indices, Mesh, MeshBuilder, Meshable, PrimitiveTopology}; use bevy_asset::RenderAssetUsages; -use bevy_math::{Vec3, primitives::Cuboid}; +use bevy_math::{primitives::Cuboid, Vec3}; use bevy_reflect::prelude::*; /// A builder used for creating a [`Mesh`] with a [`Cuboid`] shape. diff --git a/crates/bevy_mesh/src/primitives/dim3/plane.rs b/crates/bevy_mesh/src/primitives/dim3/plane.rs index c723469b270c2..9a2621a163194 100644 --- a/crates/bevy_mesh/src/primitives/dim3/plane.rs +++ b/crates/bevy_mesh/src/primitives/dim3/plane.rs @@ -1,6 +1,6 @@ use crate::{Indices, Mesh, MeshBuilder, Meshable, PrimitiveTopology}; use bevy_asset::RenderAssetUsages; -use bevy_math::{Dir3, Quat, Vec2, Vec3, primitives::Plane3d}; +use bevy_math::{primitives::Plane3d, Dir3, Quat, Vec2, Vec3}; use bevy_reflect::prelude::*; /// A builder used for creating a [`Mesh`] with a [`Plane3d`] shape. diff --git a/crates/bevy_mesh/src/primitives/dim3/sphere.rs b/crates/bevy_mesh/src/primitives/dim3/sphere.rs index 083582b58ac76..686887b13e9db 100644 --- a/crates/bevy_mesh/src/primitives/dim3/sphere.rs +++ b/crates/bevy_mesh/src/primitives/dim3/sphere.rs @@ -10,9 +10,7 @@ use thiserror::Error; #[derive(Clone, Copy, Debug, Error)] pub enum IcosphereError { /// The icosphere has too many vertices. - #[error( - "Cannot create an icosphere of {subdivisions} subdivisions due to there being too many vertices being generated: {number_of_resulting_points}. (Limited to 65535 vertices or 79 subdivisions)" - )] + #[error("Cannot create an icosphere of {subdivisions} subdivisions due to there being too many vertices being generated: {number_of_resulting_points}. (Limited to 65535 vertices or 79 subdivisions)")] TooManyVertices { /// The number of subdivisions used. 79 is the largest allowed value for a mesh to be generated. subdivisions: u32, diff --git a/crates/bevy_mesh/src/primitives/dim3/torus.rs b/crates/bevy_mesh/src/primitives/dim3/torus.rs index 5520e907811f7..6d9c802e6cbd9 100644 --- a/crates/bevy_mesh/src/primitives/dim3/torus.rs +++ b/crates/bevy_mesh/src/primitives/dim3/torus.rs @@ -1,6 +1,6 @@ use crate::{Indices, Mesh, MeshBuilder, Meshable, PrimitiveTopology}; use bevy_asset::RenderAssetUsages; -use bevy_math::{Vec3, ops, primitives::Torus}; +use bevy_math::{ops, primitives::Torus, Vec3}; use bevy_reflect::prelude::*; use core::ops::RangeInclusive; diff --git a/crates/bevy_mesh/src/primitives/dim3/triangle3d.rs b/crates/bevy_mesh/src/primitives/dim3/triangle3d.rs index 6bcafa7405b4c..f605dbeaf1761 100644 --- a/crates/bevy_mesh/src/primitives/dim3/triangle3d.rs +++ b/crates/bevy_mesh/src/primitives/dim3/triangle3d.rs @@ -1,6 +1,6 @@ use crate::{Indices, Mesh, MeshBuilder, Meshable, PrimitiveTopology}; use bevy_asset::RenderAssetUsages; -use bevy_math::{Vec3, primitives::Triangle3d}; +use bevy_math::{primitives::Triangle3d, Vec3}; use bevy_reflect::prelude::*; /// A builder used for creating a [`Mesh`] with a [`Triangle3d`] shape. diff --git a/crates/bevy_mesh/src/primitives/extrusion.rs b/crates/bevy_mesh/src/primitives/extrusion.rs index 863a1bca277c1..2a9e5d7551caa 100644 --- a/crates/bevy_mesh/src/primitives/extrusion.rs +++ b/crates/bevy_mesh/src/primitives/extrusion.rs @@ -1,6 +1,6 @@ use bevy_math::{ - Vec2, Vec3, primitives::{Annulus, Capsule2d, Circle, Ellipse, Extrusion, Primitive2d}, + Vec2, Vec3, }; use super::{MeshBuilder, Meshable}; @@ -207,9 +207,7 @@ where } }, _ => { - panic!( - "Meshes used with Extrusions must have a primitive topology of `PrimitiveTopology::TriangleList`" - ); + panic!("Meshes used with Extrusions must have a primitive topology of `PrimitiveTopology::TriangleList`"); } }; } diff --git a/crates/bevy_mikktspace/src/generated.rs b/crates/bevy_mikktspace/src/generated.rs index 24c02bca12b2a..8e6a2b27b398b 100644 --- a/crates/bevy_mikktspace/src/generated.rs +++ b/crates/bevy_mikktspace/src/generated.rs @@ -50,7 +50,7 @@ use core::ptr::{self, null_mut}; use glam::Vec3; -use crate::{Geometry, face_vert_to_index, get_normal, get_position, get_tex_coord}; +use crate::{face_vert_to_index, get_normal, get_position, get_tex_coord, Geometry}; #[derive(Copy, Clone)] pub struct STSpace { @@ -1669,7 +1669,11 @@ unsafe fn MergeVertsFast( if iL == iR { let bReadyRightSwap_0: bool = (*pTmpVert.offset(iR as isize)).vert[channel as usize] < fSep; - if bReadyRightSwap_0 { iL += 1 } else { iR -= 1 } + if bReadyRightSwap_0 { + iL += 1 + } else { + iR -= 1 + } } if iL_in < iR { MergeVertsFast(piTriList_in_and_out, pTmpVert, geometry, iL_in, iR); @@ -1690,7 +1694,11 @@ unsafe fn FindGridCell(fMin: f32, fMax: f32, fVal: f32) -> usize { let fIndex = g_iCells as f32 * ((fVal - fMin) / (fMax - fMin)); let iIndex = fIndex as isize; return if iIndex < g_iCells as isize { - if iIndex >= 0 { iIndex as usize } else { 0 } + if iIndex >= 0 { + iIndex as usize + } else { + 0 + } } else { g_iCells - 1 }; diff --git a/crates/bevy_mikktspace/tests/regression_test.rs b/crates/bevy_mikktspace/tests/regression_test.rs index 76959cf16a143..a0632b76e29b5 100644 --- a/crates/bevy_mikktspace/tests/regression_test.rs +++ b/crates/bevy_mikktspace/tests/regression_test.rs @@ -5,7 +5,7 @@ clippy::useless_conversion )] -use bevy_mikktspace::{Geometry, generate_tangents}; +use bevy_mikktspace::{generate_tangents, Geometry}; use glam::{Vec2, Vec3}; pub type Face = [u32; 3]; diff --git a/crates/bevy_pbr/src/atmosphere/mod.rs b/crates/bevy_pbr/src/atmosphere/mod.rs index 2339c3fc2e4f4..f525c0e2b8d3d 100644 --- a/crates/bevy_pbr/src/atmosphere/mod.rs +++ b/crates/bevy_pbr/src/atmosphere/mod.rs @@ -36,44 +36,44 @@ use bevy_app::{App, Plugin}; use bevy_asset::load_internal_asset; use bevy_core_pipeline::core_3d::graph::Node3d; use bevy_ecs::{ - component::{Component, require}, + component::{require, Component}, query::{Changed, QueryItem, With}, schedule::IntoSystemConfigs, - system::{Query, lifetimeless::Read}, + system::{lifetimeless::Read, Query}, }; use bevy_math::{UVec2, UVec3, Vec3}; use bevy_reflect::Reflect; -use bevy_render::{ - Render, RenderApp, RenderSet, - extract_component::{ExtractComponent, ExtractComponentPlugin}, - render_graph::{RenderGraphApp, ViewNodeRunner}, - render_resource::{Shader, TextureFormat, TextureUsages}, - renderer::RenderAdapter, -}; use bevy_render::{ extract_component::UniformComponentPlugin, render_resource::{DownlevelFlags, ShaderType, SpecializedRenderPipelines}, renderer::RenderDevice, settings::WgpuFeatures, }; +use bevy_render::{ + extract_component::{ExtractComponent, ExtractComponentPlugin}, + render_graph::{RenderGraphApp, ViewNodeRunner}, + render_resource::{Shader, TextureFormat, TextureUsages}, + renderer::RenderAdapter, + Render, RenderApp, RenderSet, +}; -use bevy_core_pipeline::core_3d::{Camera3d, graph::Core3d}; +use bevy_core_pipeline::core_3d::{graph::Core3d, Camera3d}; use resources::{ - AtmosphereTransforms, RenderSkyBindGroupLayouts, prepare_atmosphere_transforms, - queue_render_sky_pipelines, + prepare_atmosphere_transforms, queue_render_sky_pipelines, AtmosphereTransforms, + RenderSkyBindGroupLayouts, }; use tracing::warn; use self::{ node::{AtmosphereLutsNode, AtmosphereNode, RenderSkyNode}, resources::{ - AtmosphereBindGroupLayouts, AtmosphereLutPipelines, AtmosphereSamplers, - prepare_atmosphere_bind_groups, prepare_atmosphere_textures, + prepare_atmosphere_bind_groups, prepare_atmosphere_textures, AtmosphereBindGroupLayouts, + AtmosphereLutPipelines, AtmosphereSamplers, }, }; mod shaders { - use bevy_asset::{Handle, weak_handle}; + use bevy_asset::{weak_handle, Handle}; use bevy_render::render_resource::Shader; pub const TYPES: Handle = weak_handle!("ef7e147e-30a0-4513-bae3-ddde2a6c20c5"); @@ -183,9 +183,7 @@ impl Plugin for AtmospherePlugin { .allowed_usages .contains(TextureUsages::STORAGE_BINDING) { - warn!( - "AtmospherePlugin not loaded. GPU lacks support: TextureFormat::Rgba16Float does not support TextureUsages::STORAGE_BINDING." - ); + warn!("AtmospherePlugin not loaded. GPU lacks support: TextureFormat::Rgba16Float does not support TextureUsages::STORAGE_BINDING."); return; } diff --git a/crates/bevy_pbr/src/atmosphere/node.rs b/crates/bevy_pbr/src/atmosphere/node.rs index 54a91138a7887..851447d760fc3 100644 --- a/crates/bevy_pbr/src/atmosphere/node.rs +++ b/crates/bevy_pbr/src/atmosphere/node.rs @@ -11,11 +11,11 @@ use bevy_render::{ use crate::ViewLightsUniformOffset; use super::{ - Atmosphere, AtmosphereSettings, resources::{ AtmosphereBindGroups, AtmosphereLutPipelines, AtmosphereTransformsOffset, RenderSkyPipelineId, }, + Atmosphere, AtmosphereSettings, }; #[derive(PartialEq, Eq, Debug, Copy, Clone, Hash, RenderLabel)] diff --git a/crates/bevy_pbr/src/atmosphere/resources.rs b/crates/bevy_pbr/src/atmosphere/resources.rs index c73e8b1154020..71bf26da2d75a 100644 --- a/crates/bevy_pbr/src/atmosphere/resources.rs +++ b/crates/bevy_pbr/src/atmosphere/resources.rs @@ -21,7 +21,7 @@ use bevy_render::{ use crate::{GpuLights, LightMeta}; -use super::{Atmosphere, AtmosphereSettings, shaders}; +use super::{shaders, Atmosphere, AtmosphereSettings}; #[derive(Resource)] pub(crate) struct AtmosphereBindGroupLayouts { diff --git a/crates/bevy_pbr/src/cluster/assign.rs b/crates/bevy_pbr/src/cluster/assign.rs index 46a7d305dc978..36a4aadfb31d6 100644 --- a/crates/bevy_pbr/src/cluster/assign.rs +++ b/crates/bevy_pbr/src/cluster/assign.rs @@ -6,8 +6,8 @@ use bevy_ecs::{ system::{Commands, Local, Query, Res, ResMut}, }; use bevy_math::{ - Mat4, UVec3, Vec2, Vec3, Vec3A, Vec3Swizzles as _, Vec4, Vec4Swizzles as _, ops::{self, sin_cos}, + Mat4, UVec3, Vec2, Vec3, Vec3A, Vec3Swizzles as _, Vec4, Vec4Swizzles as _, }; use bevy_render::{ camera::Camera, @@ -21,12 +21,12 @@ use bevy_utils::prelude::default; use tracing::warn; use crate::{ - CLUSTERED_FORWARD_STORAGE_BUFFER_COUNT, ClusterConfig, ClusterFarZMode, Clusters, - ExtractedPointLight, GlobalVisibleClusterableObjects, LightProbe, - MAX_UNIFORM_BUFFER_CLUSTERABLE_OBJECTS, PointLight, SpotLight, ViewClusterBindings, - VisibleClusterableObjects, VolumetricLight, decal::{self, clustered::ClusteredDecal}, prelude::EnvironmentMapLight, + ClusterConfig, ClusterFarZMode, Clusters, ExtractedPointLight, GlobalVisibleClusterableObjects, + LightProbe, PointLight, SpotLight, ViewClusterBindings, VisibleClusterableObjects, + VolumetricLight, CLUSTERED_FORWARD_STORAGE_BUFFER_COUNT, + MAX_UNIFORM_BUFFER_CLUSTERABLE_OBJECTS, }; const NDC_MIN: Vec2 = Vec2::NEG_ONE; diff --git a/crates/bevy_pbr/src/cluster/mod.rs b/crates/bevy_pbr/src/cluster/mod.rs index 818281df01900..d8a1466320383 100644 --- a/crates/bevy_pbr/src/cluster/mod.rs +++ b/crates/bevy_pbr/src/cluster/mod.rs @@ -5,18 +5,17 @@ use core::num::NonZero; use bevy_core_pipeline::core_3d::Camera3d; use bevy_ecs::{ component::Component, - entity::{Entity, hash_map::EntityHashMap}, + entity::{hash_map::EntityHashMap, Entity}, query::{With, Without}, reflect::ReflectComponent, resource::Resource, system::{Commands, Query, Res}, world::{FromWorld, World}, }; -use bevy_math::{AspectRatio, UVec2, UVec3, UVec4, Vec3Swizzles as _, Vec4, uvec4}; +use bevy_math::{uvec4, AspectRatio, UVec2, UVec3, UVec4, Vec3Swizzles as _, Vec4}; use bevy_platform_support::collections::HashSet; -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::{ - Extract, camera::Camera, render_resource::{ BindingResource, BufferBindingType, ShaderSize as _, ShaderType, StorageBuffer, @@ -24,11 +23,12 @@ use bevy_render::{ }, renderer::{RenderDevice, RenderQueue}, sync_world::RenderEntity, + Extract, }; use tracing::warn; -use crate::MeshPipeline; pub(crate) use crate::cluster::assign::assign_objects_to_clusters; +use crate::MeshPipeline; pub(crate) mod assign; diff --git a/crates/bevy_pbr/src/components.rs b/crates/bevy_pbr/src/components.rs index 8557c5e9ede9e..d5418910eb37e 100644 --- a/crates/bevy_pbr/src/components.rs +++ b/crates/bevy_pbr/src/components.rs @@ -1,8 +1,8 @@ use bevy_derive::{Deref, DerefMut}; use bevy_ecs::component::Component; -use bevy_ecs::entity::{Entity, hash_map::EntityHashMap}; +use bevy_ecs::entity::{hash_map::EntityHashMap, Entity}; use bevy_ecs::reflect::ReflectComponent; -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::sync_world::MainEntity; /// Collection of mesh entities visible for 3D lighting. /// diff --git a/crates/bevy_pbr/src/decal/clustered.rs b/crates/bevy_pbr/src/decal/clustered.rs index f5a6d19ba235e..43edcd0bc34d5 100644 --- a/crates/bevy_pbr/src/decal/clustered.rs +++ b/crates/bevy_pbr/src/decal/clustered.rs @@ -17,11 +17,11 @@ use core::{num::NonZero, ops::Deref}; use bevy_app::{App, Plugin}; -use bevy_asset::{AssetId, Handle, load_internal_asset, weak_handle}; +use bevy_asset::{load_internal_asset, weak_handle, AssetId, Handle}; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::{ - component::{Component, require}, - entity::{Entity, hash_map::EntityHashMap}, + component::{require, Component}, + entity::{hash_map::EntityHashMap, Entity}, prelude::ReflectComponent, query::With, resource::Resource, @@ -33,23 +33,23 @@ use bevy_math::Mat4; use bevy_platform_support::collections::HashMap; use bevy_reflect::Reflect; use bevy_render::{ - Extract, ExtractSchedule, Render, RenderApp, RenderSet, extract_component::{ExtractComponent, ExtractComponentPlugin}, render_asset::RenderAssets, render_resource::{ - BindGroupLayoutEntryBuilder, Buffer, BufferUsages, RawBufferVec, Sampler, - SamplerBindingType, Shader, ShaderType, TextureSampleType, TextureView, binding_types, + binding_types, BindGroupLayoutEntryBuilder, Buffer, BufferUsages, RawBufferVec, Sampler, + SamplerBindingType, Shader, ShaderType, TextureSampleType, TextureView, }, renderer::{RenderAdapter, RenderDevice, RenderQueue}, sync_world::RenderEntity, texture::{FallbackImage, GpuImage}, view::{self, ViewVisibility, Visibility, VisibilityClass}, + Extract, ExtractSchedule, Render, RenderApp, RenderSet, }; use bevy_transform::{components::GlobalTransform, prelude::Transform}; use bytemuck::{Pod, Zeroable}; use crate::{ - GlobalClusterableObjectMeta, LightVisibilityClass, binding_arrays_are_usable, prepare_lights, + binding_arrays_are_usable, prepare_lights, GlobalClusterableObjectMeta, LightVisibilityClass, }; /// The handle to the `clustered.wgsl` shader. diff --git a/crates/bevy_pbr/src/decal/forward.rs b/crates/bevy_pbr/src/decal/forward.rs index a4103c7654c95..7732f1d3a4ab3 100644 --- a/crates/bevy_pbr/src/decal/forward.rs +++ b/crates/bevy_pbr/src/decal/forward.rs @@ -3,18 +3,18 @@ use crate::{ MaterialPlugin, StandardMaterial, }; use bevy_app::{App, Plugin}; -use bevy_asset::{Asset, Assets, Handle, load_internal_asset, weak_handle}; -use bevy_ecs::component::{Component, require}; -use bevy_math::{Quat, Vec2, Vec3, prelude::Rectangle}; +use bevy_asset::{load_internal_asset, weak_handle, Asset, Assets, Handle}; +use bevy_ecs::component::{require, Component}; +use bevy_math::{prelude::Rectangle, Quat, Vec2, Vec3}; use bevy_reflect::{Reflect, TypePath}; use bevy_render::{ - RenderDebugFlags, alpha::AlphaMode, mesh::{Mesh, Mesh3d, MeshBuilder, MeshVertexBufferLayoutRef, Meshable}, render_resource::{ AsBindGroup, CompareFunction, RenderPipelineDescriptor, Shader, SpecializedMeshPipelineError, }, + RenderDebugFlags, }; const FORWARD_DECAL_MESH_HANDLE: Handle = diff --git a/crates/bevy_pbr/src/deferred/mod.rs b/crates/bevy_pbr/src/deferred/mod.rs index aa44f53d9d998..c7d7e04636150 100644 --- a/crates/bevy_pbr/src/deferred/mod.rs +++ b/crates/bevy_pbr/src/deferred/mod.rs @@ -1,20 +1,20 @@ use crate::{ - DistanceFog, MeshPipelineKey, ShadowFilteringMethod, ViewFogUniformOffset, - ViewLightsUniformOffset, + graph::NodePbr, irradiance_volume::IrradianceVolume, prelude::EnvironmentMapLight, + MeshPipeline, MeshViewBindGroup, RenderViewLightProbes, ScreenSpaceAmbientOcclusion, + ScreenSpaceReflectionsUniform, ViewEnvironmentMapUniformOffset, ViewLightProbesUniformOffset, + ViewScreenSpaceReflectionsUniformOffset, TONEMAPPING_LUT_SAMPLER_BINDING_INDEX, + TONEMAPPING_LUT_TEXTURE_BINDING_INDEX, }; use crate::{ - MeshPipeline, MeshViewBindGroup, RenderViewLightProbes, ScreenSpaceAmbientOcclusion, - ScreenSpaceReflectionsUniform, TONEMAPPING_LUT_SAMPLER_BINDING_INDEX, - TONEMAPPING_LUT_TEXTURE_BINDING_INDEX, ViewEnvironmentMapUniformOffset, - ViewLightProbesUniformOffset, ViewScreenSpaceReflectionsUniformOffset, graph::NodePbr, - irradiance_volume::IrradianceVolume, prelude::EnvironmentMapLight, + DistanceFog, MeshPipelineKey, ShadowFilteringMethod, ViewFogUniformOffset, + ViewLightsUniformOffset, }; use bevy_app::prelude::*; -use bevy_asset::{Handle, load_internal_asset, weak_handle}; +use bevy_asset::{load_internal_asset, weak_handle, Handle}; use bevy_core_pipeline::{ core_3d::graph::{Core3d, Node3d}, deferred::{ - DEFERRED_LIGHTING_PASS_ID_DEPTH_FORMAT, copy_lighting_id::DeferredLightingIdDepthTexture, + copy_lighting_id::DeferredLightingIdDepthTexture, DEFERRED_LIGHTING_PASS_ID_DEPTH_FORMAT, }, prepass::{DeferredPrepass, DepthPrepass, MotionVectorPrepass, NormalPrepass}, tonemapping::{DebandDither, Tonemapping}, @@ -22,7 +22,6 @@ use bevy_core_pipeline::{ use bevy_ecs::{prelude::*, query::QueryItem}; use bevy_image::BevyDefault as _; use bevy_render::{ - Render, RenderApp, RenderSet, extract_component::{ ComponentUniforms, ExtractComponent, ExtractComponentPlugin, UniformComponentPlugin, }, @@ -30,6 +29,7 @@ use bevy_render::{ render_resource::{binding_types::uniform_buffer, *}, renderer::{RenderContext, RenderDevice}, view::{ExtractedView, ViewTarget, ViewUniformOffset}, + Render, RenderApp, RenderSet, }; pub struct DeferredPbrLightingPlugin; diff --git a/crates/bevy_pbr/src/extended_material.rs b/crates/bevy_pbr/src/extended_material.rs index 05af20454c320..68690439030fc 100644 --- a/crates/bevy_pbr/src/extended_material.rs +++ b/crates/bevy_pbr/src/extended_material.rs @@ -1,6 +1,6 @@ use bevy_asset::{Asset, Handle}; use bevy_ecs::system::SystemParamItem; -use bevy_reflect::{Reflect, impl_type_path}; +use bevy_reflect::{impl_type_path, Reflect}; use bevy_render::{ alpha::AlphaMode, mesh::MeshVertexBufferLayoutRef, diff --git a/crates/bevy_pbr/src/fog.rs b/crates/bevy_pbr/src/fog.rs index 17e175d942daa..831ec6928c424 100644 --- a/crates/bevy_pbr/src/fog.rs +++ b/crates/bevy_pbr/src/fog.rs @@ -1,7 +1,7 @@ use bevy_color::{Color, ColorToComponents, LinearRgba}; use bevy_ecs::prelude::*; -use bevy_math::{Vec3, ops}; -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_math::{ops, Vec3}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::{extract_component::ExtractComponent, prelude::Camera}; /// Configures the “classic” computer graphics [distance fog](https://en.wikipedia.org/wiki/Distance_fog) effect, diff --git a/crates/bevy_pbr/src/lib.rs b/crates/bevy_pbr/src/lib.rs index abea389b7e019..543a4665fc54d 100644 --- a/crates/bevy_pbr/src/lib.rs +++ b/crates/bevy_pbr/src/lib.rs @@ -74,8 +74,8 @@ pub mod prelude { #[doc(hidden)] pub use crate::{ fog::{DistanceFog, FogFalloff}, - light::{AmbientLight, DirectionalLight, PointLight, SpotLight, light_consts}, - light_probe::{LightProbe, environment_map::EnvironmentMapLight}, + light::{light_consts, AmbientLight, DirectionalLight, PointLight, SpotLight}, + light_probe::{environment_map::EnvironmentMapLight, LightProbe}, material::{Material, MaterialPlugin}, mesh_material::MeshMaterial3d, parallax::ParallaxMappingMethod, @@ -124,12 +124,11 @@ pub mod graph { use crate::{deferred::DeferredPbrLightingPlugin, graph::NodePbr}; use bevy_app::prelude::*; -use bevy_asset::{AssetApp, Assets, Handle, load_internal_asset, weak_handle}; +use bevy_asset::{load_internal_asset, weak_handle, AssetApp, Assets, Handle}; use bevy_core_pipeline::core_3d::graph::{Core3d, Node3d}; use bevy_ecs::prelude::*; use bevy_image::Image; use bevy_render::{ - ExtractSchedule, Render, RenderApp, RenderDebugFlags, RenderSet, alpha::AlphaMode, camera::{CameraUpdateSystem, Projection}, extract_component::ExtractComponentPlugin, @@ -140,6 +139,7 @@ use bevy_render::{ sync_component::SyncComponentPlugin, texture::GpuImage, view::VisibilitySystems, + ExtractSchedule, Render, RenderApp, RenderDebugFlags, RenderSet, }; use bevy_transform::TransformSystem; diff --git a/crates/bevy_pbr/src/light/mod.rs b/crates/bevy_pbr/src/light/mod.rs index 1f62ee19885a3..1c9dc61374a1e 100644 --- a/crates/bevy_pbr/src/light/mod.rs +++ b/crates/bevy_pbr/src/light/mod.rs @@ -4,7 +4,7 @@ use bevy_ecs::{ entity::{hash_map::EntityHashMap, hash_set::EntityHashSet}, prelude::*, }; -use bevy_math::{Mat4, Vec3A, Vec4, ops}; +use bevy_math::{ops, Mat4, Vec3A, Vec4}; use bevy_reflect::prelude::*; use bevy_render::{ camera::{Camera, CameraProjection, Projection}, diff --git a/crates/bevy_pbr/src/light_probe/environment_map.rs b/crates/bevy_pbr/src/light_probe/environment_map.rs index 9d2299c344ff4..8069f2acac752 100644 --- a/crates/bevy_pbr/src/light_probe/environment_map.rs +++ b/crates/bevy_pbr/src/light_probe/environment_map.rs @@ -44,20 +44,20 @@ //! //! [several pre-filtered environment maps]: https://github.com/KhronosGroup/glTF-Sample-Environments -use bevy_asset::{AssetId, Handle, weak_handle}; +use bevy_asset::{weak_handle, AssetId, Handle}; use bevy_ecs::{ component::Component, query::QueryItem, reflect::ReflectComponent, system::lifetimeless::Read, }; use bevy_image::Image; use bevy_math::Quat; -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::{ extract_instances::ExtractInstance, render_asset::RenderAssets, render_resource::{ + binding_types::{self, uniform_buffer}, BindGroupLayoutEntryBuilder, Sampler, SamplerBindingType, Shader, ShaderStages, TextureSampleType, TextureView, - binding_types::{self, uniform_buffer}, }, renderer::{RenderAdapter, RenderDevice}, texture::{FallbackImage, GpuImage}, @@ -66,8 +66,8 @@ use bevy_render::{ use core::{num::NonZero, ops::Deref}; use crate::{ - EnvironmentMapUniform, MAX_VIEW_LIGHT_PROBES, add_cubemap_texture_view, - binding_arrays_are_usable, + add_cubemap_texture_view, binding_arrays_are_usable, EnvironmentMapUniform, + MAX_VIEW_LIGHT_PROBES, }; use super::{LightProbeComponent, RenderViewLightProbes}; diff --git a/crates/bevy_pbr/src/light_probe/irradiance_volume.rs b/crates/bevy_pbr/src/light_probe/irradiance_volume.rs index bf5c8e2409374..799329e98284b 100644 --- a/crates/bevy_pbr/src/light_probe/irradiance_volume.rs +++ b/crates/bevy_pbr/src/light_probe/irradiance_volume.rs @@ -137,8 +137,8 @@ use bevy_image::Image; use bevy_render::{ render_asset::RenderAssets, render_resource::{ - BindGroupLayoutEntryBuilder, Sampler, SamplerBindingType, Shader, TextureSampleType, - TextureView, binding_types, + binding_types, BindGroupLayoutEntryBuilder, Sampler, SamplerBindingType, Shader, + TextureSampleType, TextureView, }, renderer::{RenderAdapter, RenderDevice}, texture::{FallbackImage, GpuImage}, @@ -146,12 +146,12 @@ use bevy_render::{ use bevy_utils::default; use core::{num::NonZero, ops::Deref}; -use bevy_asset::{AssetId, Handle, weak_handle}; -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_asset::{weak_handle, AssetId, Handle}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use crate::{ - MAX_VIEW_LIGHT_PROBES, RenderViewLightProbes, add_cubemap_texture_view, - binding_arrays_are_usable, + add_cubemap_texture_view, binding_arrays_are_usable, RenderViewLightProbes, + MAX_VIEW_LIGHT_PROBES, }; use super::LightProbeComponent; diff --git a/crates/bevy_pbr/src/light_probe/mod.rs b/crates/bevy_pbr/src/light_probe/mod.rs index 34870950711c5..3ef3e78db85f4 100644 --- a/crates/bevy_pbr/src/light_probe/mod.rs +++ b/crates/bevy_pbr/src/light_probe/mod.rs @@ -1,11 +1,11 @@ //! Light probes for baked global illumination. use bevy_app::{App, Plugin}; -use bevy_asset::{AssetId, Handle, load_internal_asset, weak_handle}; +use bevy_asset::{load_internal_asset, weak_handle, AssetId, Handle}; use bevy_core_pipeline::core_3d::Camera3d; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::{ - component::{Component, require}, + component::{require, Component}, entity::Entity, query::With, reflect::ReflectComponent, @@ -16,9 +16,8 @@ use bevy_ecs::{ use bevy_image::Image; use bevy_math::{Affine3A, FloatOrd, Mat4, Vec3A, Vec4}; use bevy_platform_support::collections::HashMap; -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::{ - Extract, ExtractSchedule, Render, RenderApp, RenderSet, extract_instances::ExtractInstancesPlugin, primitives::{Aabb, Frustum}, render_asset::RenderAssets, @@ -28,6 +27,7 @@ use bevy_render::{ sync_world::RenderEntity, texture::{FallbackImage, GpuImage}, view::{ExtractedView, Visibility}, + Extract, ExtractSchedule, Render, RenderApp, RenderSet, }; use bevy_transform::{components::Transform, prelude::GlobalTransform}; use tracing::error; @@ -37,7 +37,7 @@ use core::{hash::Hash, ops::Deref}; use crate::{ irradiance_volume::IRRADIANCE_VOLUME_SHADER_HANDLE, light_probe::environment_map::{ - ENVIRONMENT_MAP_SHADER_HANDLE, EnvironmentMapIds, EnvironmentMapLight, + EnvironmentMapIds, EnvironmentMapLight, ENVIRONMENT_MAP_SHADER_HANDLE, }, }; diff --git a/crates/bevy_pbr/src/lightmap/mod.rs b/crates/bevy_pbr/src/lightmap/mod.rs index dae7f322f434b..afaa71d7926bd 100644 --- a/crates/bevy_pbr/src/lightmap/mod.rs +++ b/crates/bevy_pbr/src/lightmap/mod.rs @@ -32,7 +32,7 @@ //! [`bevy-baked-gi`]: https://github.com/pcwalton/bevy-baked-gi use bevy_app::{App, Plugin}; -use bevy_asset::{AssetId, Handle, load_internal_asset, weak_handle}; +use bevy_asset::{load_internal_asset, weak_handle, AssetId, Handle}; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::{ component::Component, @@ -46,17 +46,17 @@ use bevy_ecs::{ world::{FromWorld, World}, }; use bevy_image::Image; -use bevy_math::{Rect, UVec2, uvec2, vec4}; +use bevy_math::{uvec2, vec4, Rect, UVec2}; use bevy_platform_support::collections::HashSet; -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::{ - Extract, ExtractSchedule, RenderApp, render_asset::RenderAssets, render_resource::{Sampler, Shader, TextureView, WgpuSampler, WgpuTextureView}, renderer::RenderAdapter, sync_world::MainEntity, texture::{FallbackImage, GpuImage}, view::ViewVisibility, + Extract, ExtractSchedule, RenderApp, }; use bevy_render::{renderer::RenderDevice, sync_world::MainEntityHashMap}; use bevy_utils::default; @@ -64,7 +64,7 @@ use fixedbitset::FixedBitSet; use nonmax::{NonMaxU16, NonMaxU32}; use tracing::error; -use crate::{ExtractMeshesSet, binding_arrays_are_usable}; +use crate::{binding_arrays_are_usable, ExtractMeshesSet}; /// The ID of the lightmap shader. pub const LIGHTMAP_SHADER_HANDLE: Handle = diff --git a/crates/bevy_pbr/src/material.rs b/crates/bevy_pbr/src/material.rs index 7593a6f7c7535..d91ff14633af9 100644 --- a/crates/bevy_pbr/src/material.rs +++ b/crates/bevy_pbr/src/material.rs @@ -3,8 +3,8 @@ use crate::material_bind_groups::{ }; #[cfg(feature = "meshlet")] use crate::meshlet::{ - InstanceManager, prepare_material_meshlet_meshes_main_opaque_pass, - queue_material_meshlet_meshes, + prepare_material_meshlet_meshes_main_opaque_pass, queue_material_meshlet_meshes, + InstanceManager, }; use crate::*; use bevy_asset::prelude::AssetChanged; @@ -25,18 +25,17 @@ use bevy_ecs::system::SystemChangeTick; use bevy_ecs::{ prelude::*, system::{ - SystemParamItem, lifetimeless::{SRes, SResMut}, + SystemParamItem, }, }; use bevy_platform_support::collections::{HashMap, HashSet}; use bevy_platform_support::hash::FixedHasher; -use bevy_reflect::Reflect; use bevy_reflect::std_traits::ReflectDefault; +use bevy_reflect::Reflect; use bevy_render::mesh::mark_3d_meshes_as_changed_if_their_assets_changed; use bevy_render::renderer::RenderQueue; use bevy_render::{ - Extract, batching::gpu_preprocessing::GpuPreprocessingSupport, extract_resource::ExtractResource, mesh::{Mesh3d, MeshVertexBufferLayoutRef, RenderMesh}, @@ -46,6 +45,7 @@ use bevy_render::{ renderer::RenderDevice, sync_world::MainEntity, view::{ExtractedView, Msaa, RenderVisibilityRanges, RetainedViewEntity, ViewVisibility}, + Extract, }; use bevy_render::{mesh::allocator::MeshAllocator, sync_world::MainEntityHashMap}; use bevy_render::{texture::FallbackImage, view::RenderVisibleEntities}; @@ -1381,9 +1381,14 @@ impl RenderAsset for PreparedMaterial { fn unload_asset( source_asset: AssetId, - (_, _, _, bind_group_allocator, render_material_bindings, ..): &mut SystemParamItem< - Self::Param, - >, + ( + _, + _, + _, + bind_group_allocator, + render_material_bindings, + .., + ): &mut SystemParamItem, ) { let Some(material_binding_id) = render_material_bindings.remove(&source_asset.untyped()) else { diff --git a/crates/bevy_pbr/src/material_bind_groups.rs b/crates/bevy_pbr/src/material_bind_groups.rs index 13a9b34014917..ea152d2272646 100644 --- a/crates/bevy_pbr/src/material_bind_groups.rs +++ b/crates/bevy_pbr/src/material_bind_groups.rs @@ -12,7 +12,7 @@ use bevy_ecs::{ world::{FromWorld, World}, }; use bevy_platform_support::collections::{HashMap, HashSet}; -use bevy_reflect::{Reflect, prelude::ReflectDefault}; +use bevy_reflect::{prelude::ReflectDefault, Reflect}; use bevy_render::{ render_resource::{ BindGroup, BindGroupEntry, BindGroupLayout, BindingNumber, BindingResource, diff --git a/crates/bevy_pbr/src/mesh_material.rs b/crates/bevy_pbr/src/mesh_material.rs index e5d9a6b3b683b..c3f81943ecbcf 100644 --- a/crates/bevy_pbr/src/mesh_material.rs +++ b/crates/bevy_pbr/src/mesh_material.rs @@ -2,7 +2,7 @@ use crate::Material; use bevy_asset::{AsAssetId, AssetId, Handle}; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::{component::Component, reflect::ReflectComponent}; -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use derive_more::derive::From; /// A [material](Material) used for rendering a [`Mesh3d`]. diff --git a/crates/bevy_pbr/src/meshlet/asset.rs b/crates/bevy_pbr/src/meshlet/asset.rs index 324dc53189ec3..c158650d1bd4c 100644 --- a/crates/bevy_pbr/src/meshlet/asset.rs +++ b/crates/bevy_pbr/src/meshlet/asset.rs @@ -1,8 +1,8 @@ use alloc::sync::Arc; use bevy_asset::{ - Asset, AssetLoader, AsyncReadExt, AsyncWriteExt, LoadContext, io::{Reader, Writer}, saver::{AssetSaver, SavedAsset}, + Asset, AssetLoader, AsyncReadExt, AsyncWriteExt, LoadContext, }; use bevy_math::{Vec2, Vec3}; use bevy_reflect::TypePath; diff --git a/crates/bevy_pbr/src/meshlet/from_mesh.rs b/crates/bevy_pbr/src/meshlet/from_mesh.rs index dcf867ea32a4e..7b959eef46887 100644 --- a/crates/bevy_pbr/src/meshlet/from_mesh.rs +++ b/crates/bevy_pbr/src/meshlet/from_mesh.rs @@ -2,7 +2,7 @@ use super::asset::{ Meshlet, MeshletBoundingSphere, MeshletBoundingSpheres, MeshletMesh, MeshletSimplificationError, }; use alloc::borrow::Cow; -use bevy_math::{IVec3, Vec2, Vec3, Vec3Swizzles, ops::log2}; +use bevy_math::{ops::log2, IVec3, Vec2, Vec3, Vec3Swizzles}; use bevy_platform_support::collections::HashMap; use bevy_render::{ mesh::{Indices, Mesh}, @@ -13,10 +13,10 @@ use core::{iter, ops::Range}; use half::f16; use itertools::Itertools; use meshopt::{ - Meshlets, SimplifyOptions, VertexDataAdapter, VertexStream, build_meshlets, - ffi::meshopt_Meshlet, generate_vertex_remap_multi, simplify_with_attributes_and_locks, + build_meshlets, ffi::meshopt_Meshlet, generate_vertex_remap_multi, + simplify_with_attributes_and_locks, Meshlets, SimplifyOptions, VertexDataAdapter, VertexStream, }; -use metis::{Graph, option::Opt}; +use metis::{option::Opt, Graph}; use smallvec::SmallVec; use thiserror::Error; @@ -705,7 +705,11 @@ fn octahedral_encode(v: Vec3) -> Vec2 { if n.x >= 0.0 { 1.0 } else { -1.0 }, if n.y >= 0.0 { 1.0 } else { -1.0 }, ); - if n.z >= 0.0 { n.xy() } else { octahedral_wrap } + if n.z >= 0.0 { + n.xy() + } else { + octahedral_wrap + } } // https://www.w3.org/TR/WGSL/#pack2x16snorm-builtin diff --git a/crates/bevy_pbr/src/meshlet/instance_manager.rs b/crates/bevy_pbr/src/meshlet/instance_manager.rs index 5fea0ffdee132..26f6432a1fdf7 100644 --- a/crates/bevy_pbr/src/meshlet/instance_manager.rs +++ b/crates/bevy_pbr/src/meshlet/instance_manager.rs @@ -1,4 +1,4 @@ -use super::{MeshletMesh, MeshletMesh3d, meshlet_mesh_manager::MeshletMeshManager}; +use super::{meshlet_mesh_manager::MeshletMeshManager, MeshletMesh, MeshletMesh3d}; use crate::{ Material, MeshFlags, MeshTransforms, MeshUniform, NotShadowCaster, NotShadowReceiver, PreviousGlobalTransform, RenderMaterialBindings, RenderMaterialInstances, @@ -6,7 +6,7 @@ use crate::{ }; use bevy_asset::{AssetEvent, AssetServer, Assets, UntypedAssetId}; use bevy_ecs::{ - entity::{Entities, Entity, hash_map::EntityHashMap}, + entity::{hash_map::EntityHashMap, Entities, Entity}, event::EventReader, query::Has, resource::Resource, @@ -14,7 +14,7 @@ use bevy_ecs::{ }; use bevy_platform_support::collections::{HashMap, HashSet}; use bevy_render::{ - MainWorld, render_resource::StorageBuffer, sync_world::MainEntity, view::RenderLayers, + render_resource::StorageBuffer, sync_world::MainEntity, view::RenderLayers, MainWorld, }; use bevy_transform::components::GlobalTransform; use core::ops::{DerefMut, Range}; diff --git a/crates/bevy_pbr/src/meshlet/material_pipeline_prepare.rs b/crates/bevy_pbr/src/meshlet/material_pipeline_prepare.rs index 55f5d0d5e67dc..2351c7756d9c2 100644 --- a/crates/bevy_pbr/src/meshlet/material_pipeline_prepare.rs +++ b/crates/bevy_pbr/src/meshlet/material_pipeline_prepare.rs @@ -1,6 +1,6 @@ use super::{ - MESHLET_MESH_MATERIAL_SHADER_HANDLE, instance_manager::InstanceManager, - resource_manager::ResourceManager, + instance_manager::InstanceManager, resource_manager::ResourceManager, + MESHLET_MESH_MATERIAL_SHADER_HANDLE, }; use crate::{ environment_map::EnvironmentMapLight, irradiance_volume::IrradianceVolume, diff --git a/crates/bevy_pbr/src/meshlet/material_shade_nodes.rs b/crates/bevy_pbr/src/meshlet/material_shade_nodes.rs index 1cf09f54ab9bc..9c2d432d8856a 100644 --- a/crates/bevy_pbr/src/meshlet/material_shade_nodes.rs +++ b/crates/bevy_pbr/src/meshlet/material_shade_nodes.rs @@ -1,10 +1,10 @@ use super::{ - InstanceManager, material_pipeline_prepare::{ MeshletViewMaterialsDeferredGBufferPrepass, MeshletViewMaterialsMainOpaquePass, MeshletViewMaterialsPrepass, }, resource_manager::{MeshletViewBindGroups, MeshletViewResources}, + InstanceManager, }; use crate::{ MeshViewBindGroup, PrepassViewBindGroup, ViewEnvironmentMapUniformOffset, ViewFogUniformOffset, diff --git a/crates/bevy_pbr/src/meshlet/meshlet_mesh_manager.rs b/crates/bevy_pbr/src/meshlet/meshlet_mesh_manager.rs index 81d1af032bcf6..2bc686fe43cc7 100644 --- a/crates/bevy_pbr/src/meshlet/meshlet_mesh_manager.rs +++ b/crates/bevy_pbr/src/meshlet/meshlet_mesh_manager.rs @@ -1,7 +1,7 @@ use super::{ - MeshletMesh, asset::{Meshlet, MeshletBoundingSpheres, MeshletSimplificationError}, persistent_buffer::PersistentGpuBuffer, + MeshletMesh, }; use alloc::sync::Arc; use bevy_asset::{AssetId, Assets}; @@ -116,15 +116,7 @@ impl MeshletMeshManager { pub fn remove(&mut self, asset_id: &AssetId) { if let Some( - [ - vertex_positions_slice, - vertex_normals_slice, - vertex_uvs_slice, - indices_slice, - meshlets_slice, - meshlet_bounding_spheres_slice, - meshlet_simplification_errors_slice, - ], + [vertex_positions_slice, vertex_normals_slice, vertex_uvs_slice, indices_slice, meshlets_slice, meshlet_bounding_spheres_slice, meshlet_simplification_errors_slice], ) = self.meshlet_mesh_slices.remove(asset_id) { self.vertex_positions diff --git a/crates/bevy_pbr/src/meshlet/mod.rs b/crates/bevy_pbr/src/meshlet/mod.rs index 33dbb6762d11d..4057f29e39a3c 100644 --- a/crates/bevy_pbr/src/meshlet/mod.rs +++ b/crates/bevy_pbr/src/meshlet/mod.rs @@ -26,18 +26,18 @@ pub mod graph { } pub(crate) use self::{ - instance_manager::{InstanceManager, queue_material_meshlet_meshes}, + instance_manager::{queue_material_meshlet_meshes, InstanceManager}, material_pipeline_prepare::{ prepare_material_meshlet_meshes_main_opaque_pass, prepare_material_meshlet_meshes_prepass, }, }; pub use self::asset::{ - MESHLET_MESH_ASSET_VERSION, MeshletMesh, MeshletMeshLoader, MeshletMeshSaver, + MeshletMesh, MeshletMeshLoader, MeshletMeshSaver, MESHLET_MESH_ASSET_VERSION, }; #[cfg(feature = "meshlet_processor")] pub use self::from_mesh::{ - MESHLET_DEFAULT_VERTEX_POSITION_QUANTIZATION_FACTOR, MeshToMeshletMeshConversionError, + MeshToMeshletMeshConversionError, MESHLET_DEFAULT_VERTEX_POSITION_QUANTIZATION_FACTOR, }; use self::{ graph::NodeMeshlet, @@ -49,37 +49,37 @@ use self::{ material_shade_nodes::{ MeshletDeferredGBufferPrepassNode, MeshletMainOpaquePass3dNode, MeshletPrepassNode, }, - meshlet_mesh_manager::{MeshletMeshManager, perform_pending_meshlet_mesh_writes}, + meshlet_mesh_manager::{perform_pending_meshlet_mesh_writes, MeshletMeshManager}, pipelines::*, resource_manager::{ - ResourceManager, prepare_meshlet_per_frame_resources, prepare_meshlet_view_bind_groups, + prepare_meshlet_per_frame_resources, prepare_meshlet_view_bind_groups, ResourceManager, }, visibility_buffer_raster_node::MeshletVisibilityBufferRasterPassNode, }; -use crate::{PreviousGlobalTransform, graph::NodePbr}; +use crate::{graph::NodePbr, PreviousGlobalTransform}; use bevy_app::{App, Plugin}; -use bevy_asset::{AssetApp, AssetId, Handle, load_internal_asset, weak_handle}; +use bevy_asset::{load_internal_asset, weak_handle, AssetApp, AssetId, Handle}; use bevy_core_pipeline::{ core_3d::graph::{Core3d, Node3d}, prepass::{DeferredPrepass, MotionVectorPrepass, NormalPrepass}, }; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::{ - component::{Component, require}, + component::{require, Component}, entity::Entity, query::Has, reflect::ReflectComponent, schedule::IntoSystemConfigs, system::{Commands, Query}, }; -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::{ - ExtractSchedule, Render, RenderApp, RenderSet, render_graph::{RenderGraphApp, ViewNodeRunner}, render_resource::Shader, renderer::RenderDevice, settings::WgpuFeatures, - view::{self, Msaa, Visibility, VisibilityClass, prepare_view_targets}, + view::{self, prepare_view_targets, Msaa, Visibility, VisibilityClass}, + ExtractSchedule, Render, RenderApp, RenderSet, }; use bevy_transform::components::Transform; use derive_more::From; @@ -319,9 +319,7 @@ fn configure_meshlet_views( ) { for (entity, msaa, normal_prepass, motion_vector_prepass, deferred_prepass) in &mut views_3d { if *msaa != Msaa::Off { - error!( - "MeshletPlugin can't be used with MSAA. Add Msaa::Off to your camera to use this plugin." - ); + error!("MeshletPlugin can't be used with MSAA. Add Msaa::Off to your camera to use this plugin."); std::process::exit(1); } diff --git a/crates/bevy_pbr/src/meshlet/persistent_buffer.rs b/crates/bevy_pbr/src/meshlet/persistent_buffer.rs index 63f29fd528926..85dec457f9808 100644 --- a/crates/bevy_pbr/src/meshlet/persistent_buffer.rs +++ b/crates/bevy_pbr/src/meshlet/persistent_buffer.rs @@ -1,7 +1,7 @@ use bevy_render::{ render_resource::{ BindingResource, Buffer, BufferAddress, BufferDescriptor, BufferUsages, - COPY_BUFFER_ALIGNMENT, CommandEncoderDescriptor, + CommandEncoderDescriptor, COPY_BUFFER_ALIGNMENT, }, renderer::{RenderDevice, RenderQueue}, }; diff --git a/crates/bevy_pbr/src/meshlet/pipelines.rs b/crates/bevy_pbr/src/meshlet/pipelines.rs index 8d08b356340d7..c25d896b8a385 100644 --- a/crates/bevy_pbr/src/meshlet/pipelines.rs +++ b/crates/bevy_pbr/src/meshlet/pipelines.rs @@ -1,5 +1,5 @@ use super::resource_manager::ResourceManager; -use bevy_asset::{Handle, weak_handle}; +use bevy_asset::{weak_handle, Handle}; use bevy_core_pipeline::{ core_3d::CORE_3D_DEPTH_FORMAT, experimental::mip_generation::DOWNSAMPLE_DEPTH_SHADER_HANDLE, fullscreen_vertex_shader::fullscreen_shader_vertex_state, diff --git a/crates/bevy_pbr/src/meshlet/resource_manager.rs b/crates/bevy_pbr/src/meshlet/resource_manager.rs index 85654a5af44fe..1d3828b95e184 100644 --- a/crates/bevy_pbr/src/meshlet/resource_manager.rs +++ b/crates/bevy_pbr/src/meshlet/resource_manager.rs @@ -8,7 +8,7 @@ use bevy_core_pipeline::{ }; use bevy_ecs::{ component::Component, - entity::{Entity, hash_map::EntityHashMap}, + entity::{hash_map::EntityHashMap, Entity}, query::AnyOf, resource::Resource, system::{Commands, Query, Res, ResMut}, diff --git a/crates/bevy_pbr/src/meshlet/visibility_buffer_raster_node.rs b/crates/bevy_pbr/src/meshlet/visibility_buffer_raster_node.rs index ace14f2df5df7..20054d2d2f53a 100644 --- a/crates/bevy_pbr/src/meshlet/visibility_buffer_raster_node.rs +++ b/crates/bevy_pbr/src/meshlet/visibility_buffer_raster_node.rs @@ -9,7 +9,7 @@ use bevy_ecs::{ query::QueryState, world::{FromWorld, World}, }; -use bevy_math::{UVec2, ops}; +use bevy_math::{ops, UVec2}; use bevy_render::{ camera::ExtractedCamera, render_graph::{Node, NodeRunError, RenderGraphContext}, diff --git a/crates/bevy_pbr/src/pbr_material.rs b/crates/bevy_pbr/src/pbr_material.rs index 543157f347149..44d1b960dff52 100644 --- a/crates/bevy_pbr/src/pbr_material.rs +++ b/crates/bevy_pbr/src/pbr_material.rs @@ -1,7 +1,7 @@ use bevy_asset::Asset; use bevy_color::{Alpha, ColorToComponents}; use bevy_math::{Affine2, Affine3, Mat2, Mat3, Vec2, Vec3, Vec4}; -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::{ mesh::MeshVertexBufferLayoutRef, render_asset::RenderAssets, render_resource::*, }; diff --git a/crates/bevy_pbr/src/prepass/mod.rs b/crates/bevy_pbr/src/prepass/mod.rs index 5288588adc3be..9b3420cbc20b5 100644 --- a/crates/bevy_pbr/src/prepass/mod.rs +++ b/crates/bevy_pbr/src/prepass/mod.rs @@ -1,42 +1,41 @@ mod prepass_bindings; use crate::{ - DrawMesh, EntitySpecializationTicks, Material, MaterialPipeline, MaterialPipelineKey, - MeshLayouts, MeshPipeline, MeshPipelineKey, OpaqueRendererMethod, PreparedMaterial, - RenderLightmaps, RenderMaterialInstances, RenderMeshInstanceFlags, RenderMeshInstances, - RenderPhaseType, SetMaterialBindGroup, SetMeshBindGroup, ShadowView, StandardMaterial, alpha_mode_pipeline_key, binding_arrays_are_usable, buffer_layout, collect_meshes_for_gpu_building, material_bind_groups::MaterialBindGroupAllocator, - queue_material_meshes, setup_morph_and_skinning_defs, skin, + queue_material_meshes, setup_morph_and_skinning_defs, skin, DrawMesh, + EntitySpecializationTicks, Material, MaterialPipeline, MaterialPipelineKey, MeshLayouts, + MeshPipeline, MeshPipelineKey, OpaqueRendererMethod, PreparedMaterial, RenderLightmaps, + RenderMaterialInstances, RenderMeshInstanceFlags, RenderMeshInstances, RenderPhaseType, + SetMaterialBindGroup, SetMeshBindGroup, ShadowView, StandardMaterial, }; use bevy_app::{App, Plugin, PreUpdate}; use bevy_render::{ - ExtractSchedule, Render, RenderApp, RenderDebugFlags, RenderSet, alpha::AlphaMode, batching::gpu_preprocessing::GpuPreprocessingSupport, - mesh::{Mesh3d, MeshVertexBufferLayoutRef, RenderMesh, allocator::MeshAllocator}, + mesh::{allocator::MeshAllocator, Mesh3d, MeshVertexBufferLayoutRef, RenderMesh}, render_asset::prepare_assets, render_resource::binding_types::uniform_buffer, renderer::RenderAdapter, sync_world::RenderEntity, view::{RenderVisibilityRanges, RetainedViewEntity, VISIBILITY_RANGES_STORAGE_BUFFER_COUNT}, + ExtractSchedule, Render, RenderApp, RenderDebugFlags, RenderSet, }; pub use prepass_bindings::*; -use bevy_asset::{AssetServer, Handle, load_internal_asset, weak_handle}; +use bevy_asset::{load_internal_asset, weak_handle, AssetServer, Handle}; use bevy_core_pipeline::{ core_3d::CORE_3D_DEPTH_FORMAT, deferred::*, prelude::Camera3d, prepass::*, }; use bevy_ecs::{ prelude::*, system::{ - SystemParamItem, lifetimeless::{Read, SRes}, + SystemParamItem, }, }; use bevy_math::{Affine3A, Vec4}; use bevy_render::{ - Extract, globals::{GlobalsBuffer, GlobalsUniform}, prelude::{Camera, Mesh}, render_asset::RenderAssets, @@ -44,23 +43,24 @@ use bevy_render::{ render_resource::*, renderer::{RenderDevice, RenderQueue}, view::{ExtractedView, Msaa, ViewUniform, ViewUniformOffset, ViewUniforms}, + Extract, }; use bevy_transform::prelude::GlobalTransform; use tracing::{error, warn}; #[cfg(feature = "meshlet")] use crate::meshlet::{ - InstanceManager, MeshletMesh3d, prepare_material_meshlet_meshes_prepass, - queue_material_meshlet_meshes, + prepare_material_meshlet_meshes_prepass, queue_material_meshlet_meshes, InstanceManager, + MeshletMesh3d, }; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::component::Tick; use bevy_ecs::system::SystemChangeTick; use bevy_platform_support::collections::HashMap; -use bevy_render::RenderSet::{PrepareAssets, PrepareResources}; use bevy_render::sync_world::MainEntityHashMap; use bevy_render::view::RenderVisibleEntities; +use bevy_render::RenderSet::{PrepareAssets, PrepareResources}; use core::{hash::Hash, marker::PhantomData}; pub const PREPASS_SHADER_HANDLE: Handle = diff --git a/crates/bevy_pbr/src/prepass/prepass_bindings.rs b/crates/bevy_pbr/src/prepass/prepass_bindings.rs index 8fdb369b0a85e..3c66625ed8254 100644 --- a/crates/bevy_pbr/src/prepass/prepass_bindings.rs +++ b/crates/bevy_pbr/src/prepass/prepass_bindings.rs @@ -1,10 +1,10 @@ use bevy_core_pipeline::prepass::ViewPrepassTextures; use bevy_render::render_resource::{ - BindGroupLayoutEntryBuilder, TextureAspect, TextureSampleType, TextureView, - TextureViewDescriptor, binding_types::{ texture_2d, texture_2d_multisampled, texture_depth_2d, texture_depth_2d_multisampled, }, + BindGroupLayoutEntryBuilder, TextureAspect, TextureSampleType, TextureView, + TextureViewDescriptor, }; use bevy_utils::default; diff --git a/crates/bevy_pbr/src/render/fog.rs b/crates/bevy_pbr/src/render/fog.rs index 855537bf9705c..9394380f7186d 100644 --- a/crates/bevy_pbr/src/render/fog.rs +++ b/crates/bevy_pbr/src/render/fog.rs @@ -1,14 +1,14 @@ use bevy_app::{App, Plugin}; -use bevy_asset::{Handle, load_internal_asset, weak_handle}; +use bevy_asset::{load_internal_asset, weak_handle, Handle}; use bevy_color::{ColorToComponents, LinearRgba}; use bevy_ecs::prelude::*; use bevy_math::{Vec3, Vec4}; use bevy_render::{ - Render, RenderApp, RenderSet, extract_component::ExtractComponentPlugin, render_resource::{DynamicUniformBuffer, Shader, ShaderType}, renderer::{RenderDevice, RenderQueue}, view::ExtractedView, + Render, RenderApp, RenderSet, }; use crate::{DistanceFog, FogFalloff}; diff --git a/crates/bevy_pbr/src/render/gpu_preprocess.rs b/crates/bevy_pbr/src/render/gpu_preprocess.rs index ea7be47b02b77..e6f8addeed551 100644 --- a/crates/bevy_pbr/src/render/gpu_preprocess.rs +++ b/crates/bevy_pbr/src/render/gpu_preprocess.rs @@ -9,7 +9,7 @@ use core::num::{NonZero, NonZeroU64}; use bevy_app::{App, Plugin}; -use bevy_asset::{Handle, load_internal_asset, weak_handle}; +use bevy_asset::{load_internal_asset, weak_handle, Handle}; use bevy_core_pipeline::{ core_3d::graph::{Core3d, Node3d}, experimental::mip_generation::ViewDepthPyramid, @@ -23,14 +23,13 @@ use bevy_ecs::{ query::{Has, Or, QueryState, With, Without}, resource::Resource, schedule::IntoSystemConfigs as _, - system::{Commands, Query, Res, ResMut, lifetimeless::Read}, + system::{lifetimeless::Read, Commands, Query, Res, ResMut}, world::{FromWorld, World}, }; use bevy_render::batching::gpu_preprocessing::{ IndirectParametersGpuMetadata, UntypedPhaseIndirectParametersBuffers, }; use bevy_render::{ - Render, RenderApp, RenderSet, batching::gpu_preprocessing::{ BatchedInstanceBuffers, GpuOcclusionCullingWorkItemBuffers, GpuPreprocessingSupport, IndirectBatchSet, IndirectParametersBuffers, IndirectParametersCpuMetadata, @@ -41,24 +40,25 @@ use bevy_render::{ experimental::occlusion_culling::OcclusionCulling, render_graph::{Node, NodeRunError, RenderGraphApp, RenderGraphContext}, render_resource::{ + binding_types::{storage_buffer, storage_buffer_read_only, texture_2d, uniform_buffer}, BindGroup, BindGroupEntries, BindGroupLayout, BindingResource, Buffer, BufferBinding, CachedComputePipelineId, ComputePassDescriptor, ComputePipelineDescriptor, DynamicBindGroupLayoutEntries, PipelineCache, PushConstantRange, RawBufferVec, Shader, ShaderStages, ShaderType, SpecializedComputePipeline, SpecializedComputePipelines, TextureSampleType, UninitBufferVec, - binding_types::{storage_buffer, storage_buffer_read_only, texture_2d, uniform_buffer}, }, renderer::{RenderContext, RenderDevice, RenderQueue}, settings::WgpuFeatures, view::{ExtractedView, NoIndirectDrawing, ViewUniform, ViewUniformOffset, ViewUniforms}, + Render, RenderApp, RenderSet, }; use bevy_utils::TypeIdMap; use bitflags::bitflags; -use smallvec::{SmallVec, smallvec}; +use smallvec::{smallvec, SmallVec}; use tracing::warn; use crate::{ - MeshCullingData, MeshCullingDataBuffer, MeshInputUniform, MeshUniform, graph::NodePbr, + graph::NodePbr, MeshCullingData, MeshCullingDataBuffer, MeshInputUniform, MeshUniform, }; use super::{ShadowView, ViewLightEntities}; diff --git a/crates/bevy_pbr/src/render/light.rs b/crates/bevy_pbr/src/render/light.rs index 1b1c3ce0849d0..5dc225d4662bc 100644 --- a/crates/bevy_pbr/src/render/light.rs +++ b/crates/bevy_pbr/src/render/light.rs @@ -3,7 +3,7 @@ use crate::material_bind_groups::MaterialBindGroupAllocator; use crate::*; use bevy_asset::UntypedAssetId; use bevy_color::ColorToComponents; -use bevy_core_pipeline::core_3d::{CORE_3D_DEPTH_FORMAT, Camera3d}; +use bevy_core_pipeline::core_3d::{Camera3d, CORE_3D_DEPTH_FORMAT}; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::component::Tick; use bevy_ecs::system::SystemChangeTick; @@ -12,7 +12,7 @@ use bevy_ecs::{ prelude::*, system::lifetimeless::Read, }; -use bevy_math::{Mat4, UVec4, Vec2, Vec3, Vec3Swizzles, Vec4, Vec4Swizzles, ops}; +use bevy_math::{ops, Mat4, UVec4, Vec2, Vec3, Vec3Swizzles, Vec4, Vec4Swizzles}; use bevy_platform_support::collections::{HashMap, HashSet}; use bevy_platform_support::hash::FixedHasher; use bevy_render::experimental::occlusion_culling::{ @@ -20,7 +20,12 @@ use bevy_render::experimental::occlusion_culling::{ }; use bevy_render::sync_world::MainEntityHashMap; use bevy_render::{ - Extract, + batching::gpu_preprocessing::{GpuPreprocessingMode, GpuPreprocessingSupport}, + camera::SortedCameras, + mesh::allocator::MeshAllocator, + view::{NoIndirectDrawing, RetainedViewEntity}, +}; +use bevy_render::{ diagnostic::RecordDiagnostics, mesh::RenderMesh, primitives::{CascadesFrusta, CubemapFrusta, Frustum, HalfSpace}, @@ -31,12 +36,7 @@ use bevy_render::{ renderer::{RenderContext, RenderDevice, RenderQueue}, texture::*, view::{ExtractedView, RenderLayers, ViewVisibility}, -}; -use bevy_render::{ - batching::gpu_preprocessing::{GpuPreprocessingMode, GpuPreprocessingSupport}, - camera::SortedCameras, - mesh::allocator::MeshAllocator, - view::{NoIndirectDrawing, RetainedViewEntity}, + Extract, }; use bevy_render::{ mesh::allocator::SlabId, diff --git a/crates/bevy_pbr/src/render/mesh.rs b/crates/bevy_pbr/src/render/mesh.rs index c98ac9668a00b..e9e21a6a66f36 100644 --- a/crates/bevy_pbr/src/render/mesh.rs +++ b/crates/bevy_pbr/src/render/mesh.rs @@ -1,10 +1,10 @@ use crate::material_bind_groups::{MaterialBindGroupIndex, MaterialBindGroupSlot}; use allocator::MeshAllocator; -use bevy_asset::{AssetId, UntypedAssetId, load_internal_asset}; +use bevy_asset::{load_internal_asset, AssetId, UntypedAssetId}; use bevy_core_pipeline::{ - core_3d::{AlphaMask3d, CORE_3D_DEPTH_FORMAT, Opaque3d, Transmissive3d, Transparent3d}, + core_3d::{AlphaMask3d, Opaque3d, Transmissive3d, Transparent3d, CORE_3D_DEPTH_FORMAT}, deferred::{AlphaMask3dDeferred, Opaque3dDeferred}, - oit::{OrderIndependentTransparencySettingsOffset, prepare_oit_buffers}, + oit::{prepare_oit_buffers, OrderIndependentTransparencySettingsOffset}, prepass::MotionVectorPrepass, }; use bevy_derive::{Deref, DerefMut}; @@ -12,21 +12,19 @@ use bevy_diagnostic::FrameCount; use bevy_ecs::{ prelude::*, query::ROQueryItem, - system::{SystemParamItem, SystemState, lifetimeless::*}, + system::{lifetimeless::*, SystemParamItem, SystemState}, }; use bevy_image::{BevyDefault, ImageSampler, TextureFormatPixelInfo}; use bevy_math::{Affine3, Rect, UVec2, Vec3, Vec4}; -use bevy_platform_support::collections::{HashMap, hash_map::Entry}; +use bevy_platform_support::collections::{hash_map::Entry, HashMap}; use bevy_render::{ - Extract, batching::{ - GetBatchData, GetFullBatchData, NoAutomaticBatching, gpu_preprocessing::{ self, GpuPreprocessingSupport, IndirectBatchSet, IndirectParametersBuffers, IndirectParametersCpuMetadata, IndirectParametersIndexed, IndirectParametersNonIndexed, InstanceInputUniformBuffer, UntypedPhaseIndirectParametersBuffers, }, - no_gpu_preprocessing, + no_gpu_preprocessing, GetBatchData, GetFullBatchData, NoAutomaticBatching, }, camera::Camera, mesh::{skinning::SkinnedMesh, *}, @@ -43,9 +41,10 @@ use bevy_render::{ self, NoFrustumCulling, NoIndirectDrawing, RenderVisibilityRanges, RetainedViewEntity, ViewTarget, ViewUniformOffset, ViewVisibility, VisibilityRange, }, + Extract, }; use bevy_transform::components::GlobalTransform; -use bevy_utils::{Parallel, TypeIdMap, default}; +use bevy_utils::{default, Parallel, TypeIdMap}; use core::any::TypeId; use core::mem::size_of; use material_bind_groups::MaterialBindingId; @@ -58,8 +57,8 @@ use crate::irradiance_volume::IrradianceVolume; use crate::{ render::{ morph::{ - MorphIndices, MorphUniforms, extract_morphs, no_automatic_morph_batching, - prepare_morphs, + extract_morphs, no_automatic_morph_batching, prepare_morphs, MorphIndices, + MorphUniforms, }, skin::no_automatic_skin_batching, }, @@ -71,14 +70,14 @@ use bevy_core_pipeline::prepass::{DeferredPrepass, DepthPrepass, NormalPrepass}; use bevy_core_pipeline::tonemapping::{DebandDither, Tonemapping}; use bevy_ecs::component::Tick; use bevy_ecs::system::SystemChangeTick; -use bevy_render::RenderSet::PrepareAssets; use bevy_render::camera::TemporalJitter; use bevy_render::prelude::Msaa; use bevy_render::sync_world::{MainEntity, MainEntityHashMap}; use bevy_render::view::ExtractedView; +use bevy_render::RenderSet::PrepareAssets; use bytemuck::{Pod, Zeroable}; use nonmax::{NonMaxU16, NonMaxU32}; -use smallvec::{SmallVec, smallvec}; +use smallvec::{smallvec, SmallVec}; use static_assertions::const_assert_eq; /// Provides support for rendering 3D meshes. diff --git a/crates/bevy_pbr/src/render/mesh_bindings.rs b/crates/bevy_pbr/src/render/mesh_bindings.rs index 0e3acd2816a94..51b28389dcd0c 100644 --- a/crates/bevy_pbr/src/render/mesh_bindings.rs +++ b/crates/bevy_pbr/src/render/mesh_bindings.rs @@ -7,7 +7,7 @@ use bevy_render::{ renderer::{RenderAdapter, RenderDevice}, }; -use crate::{LightmapSlab, binding_arrays_are_usable, render::skin::MAX_JOINTS}; +use crate::{binding_arrays_are_usable, render::skin::MAX_JOINTS, LightmapSlab}; const MORPH_WEIGHT_SIZE: usize = size_of::(); @@ -26,15 +26,15 @@ mod layout_entry { use core::num::NonZeroU32; use super::{JOINT_BUFFER_SIZE, MORPH_BUFFER_SIZE}; - use crate::{LIGHTMAPS_PER_SLAB, MeshUniform, render::skin}; + use crate::{render::skin, MeshUniform, LIGHTMAPS_PER_SLAB}; use bevy_render::{ render_resource::{ - BindGroupLayoutEntryBuilder, BufferSize, GpuArrayBuffer, SamplerBindingType, - ShaderStages, TextureSampleType, binding_types::{ sampler, storage_buffer_read_only_sized, texture_2d, texture_3d, uniform_buffer_sized, }, + BindGroupLayoutEntryBuilder, BufferSize, GpuArrayBuffer, SamplerBindingType, + ShaderStages, TextureSampleType, }, renderer::RenderDevice, }; diff --git a/crates/bevy_pbr/src/render/mesh_view_bindings.rs b/crates/bevy_pbr/src/render/mesh_view_bindings.rs index 4adf9feb7688f..796ae096c2e26 100644 --- a/crates/bevy_pbr/src/render/mesh_view_bindings.rs +++ b/crates/bevy_pbr/src/render/mesh_view_bindings.rs @@ -4,7 +4,7 @@ use bevy_core_pipeline::{ oit::{OitBuffers, OrderIndependentTransparencySettings}, prepass::ViewPrepassTextures, tonemapping::{ - Tonemapping, TonemappingLuts, get_lut_bind_group_layout_entries, get_lut_bindings, + get_lut_bind_group_layout_entries, get_lut_bindings, Tonemapping, TonemappingLuts, }, }; use bevy_derive::{Deref, DerefMut}; @@ -25,19 +25,14 @@ use bevy_render::{ renderer::{RenderAdapter, RenderDevice}, texture::{FallbackImage, FallbackImageMsaa, FallbackImageZero, GpuImage}, view::{ - Msaa, RenderVisibilityRanges, VISIBILITY_RANGES_STORAGE_BUFFER_COUNT, ViewUniform, - ViewUniforms, + Msaa, RenderVisibilityRanges, ViewUniform, ViewUniforms, + VISIBILITY_RANGES_STORAGE_BUFFER_COUNT, }, }; use core::{array, num::NonZero}; use environment_map::EnvironmentMapLight; use crate::{ - CLUSTERED_FORWARD_STORAGE_BUFFER_COUNT, EnvironmentMapUniformBuffer, FogMeta, - GlobalClusterableObjectMeta, GpuClusterableObjects, GpuFog, GpuLights, LightMeta, - LightProbesBuffer, LightProbesUniform, MeshPipeline, MeshPipelineKey, RenderViewLightProbes, - ScreenSpaceAmbientOcclusionResources, ScreenSpaceReflectionsBuffer, - ScreenSpaceReflectionsUniform, ShadowSamplers, ViewClusterBindings, ViewShadowBindings, decal::{ self, clustered::{ @@ -46,10 +41,14 @@ use crate::{ }, environment_map::{self, RenderViewEnvironmentMapBindGroupEntries}, irradiance_volume::{ - self, IRRADIANCE_VOLUMES_ARE_USABLE, IrradianceVolume, - RenderViewIrradianceVolumeBindGroupEntries, + self, IrradianceVolume, RenderViewIrradianceVolumeBindGroupEntries, + IRRADIANCE_VOLUMES_ARE_USABLE, }, - prepass, + prepass, EnvironmentMapUniformBuffer, FogMeta, GlobalClusterableObjectMeta, + GpuClusterableObjects, GpuFog, GpuLights, LightMeta, LightProbesBuffer, LightProbesUniform, + MeshPipeline, MeshPipelineKey, RenderViewLightProbes, ScreenSpaceAmbientOcclusionResources, + ScreenSpaceReflectionsBuffer, ScreenSpaceReflectionsUniform, ShadowSamplers, + ViewClusterBindings, ViewShadowBindings, CLUSTERED_FORWARD_STORAGE_BUFFER_COUNT, }; #[cfg(all(feature = "webgl", target_arch = "wasm32", not(feature = "webgpu")))] @@ -462,9 +461,7 @@ impl MeshPipelineViewLayouts { #[cfg(debug_assertions)] if layout.texture_count > MESH_PIPELINE_VIEW_LAYOUT_SAFE_MAX_TEXTURES { // Issue our own warning here because Naga's error message is a bit cryptic in this situation - once!(warn!( - "Too many textures in mesh pipeline view layout, this might cause us to hit `wgpu::Limits::max_sampled_textures_per_shader_stage` in some environments." - )); + once!(warn!("Too many textures in mesh pipeline view layout, this might cause us to hit `wgpu::Limits::max_sampled_textures_per_shader_stage` in some environments.")); } &layout.bind_group_layout diff --git a/crates/bevy_pbr/src/render/mod.rs b/crates/bevy_pbr/src/render/mod.rs index 13304aa5cd1ec..4b0a20ebecff5 100644 --- a/crates/bevy_pbr/src/render/mod.rs +++ b/crates/bevy_pbr/src/render/mod.rs @@ -13,4 +13,4 @@ pub use light::*; pub use mesh::*; pub use mesh_bindings::MeshLayouts; pub use mesh_view_bindings::*; -pub use skin::{MAX_JOINTS, SkinUniforms, extract_skins, prepare_skins}; +pub use skin::{extract_skins, prepare_skins, SkinUniforms, MAX_JOINTS}; diff --git a/crates/bevy_pbr/src/render/morph.rs b/crates/bevy_pbr/src/render/morph.rs index ae2f15ec158d4..4b1ed68ce87a3 100644 --- a/crates/bevy_pbr/src/render/morph.rs +++ b/crates/bevy_pbr/src/render/morph.rs @@ -3,12 +3,12 @@ use core::{iter, mem}; use bevy_ecs::prelude::*; use bevy_render::sync_world::MainEntityHashMap; use bevy_render::{ - Extract, batching::NoAutomaticBatching, - mesh::morph::{MAX_MORPH_WEIGHTS, MeshMorphWeights}, + mesh::morph::{MeshMorphWeights, MAX_MORPH_WEIGHTS}, render_resource::{BufferUsages, RawBufferVec}, renderer::{RenderDevice, RenderQueue}, view::ViewVisibility, + Extract, }; use bytemuck::NoUninit; diff --git a/crates/bevy_pbr/src/render/skin.rs b/crates/bevy_pbr/src/render/skin.rs index 39ee722c47b79..bec846a038e6a 100644 --- a/crates/bevy_pbr/src/render/skin.rs +++ b/crates/bevy_pbr/src/render/skin.rs @@ -1,19 +1,19 @@ use core::mem::{self, size_of}; use std::sync::OnceLock; -use bevy_asset::{Assets, prelude::AssetChanged}; +use bevy_asset::{prelude::AssetChanged, Assets}; use bevy_ecs::prelude::*; use bevy_math::Mat4; use bevy_platform_support::collections::hash_map::Entry; use bevy_render::render_resource::{Buffer, BufferDescriptor}; use bevy_render::sync_world::{MainEntity, MainEntityHashMap, MainEntityHashSet}; use bevy_render::{ - Extract, batching::NoAutomaticBatching, mesh::skinning::{SkinnedMesh, SkinnedMeshInverseBindposes}, render_resource::BufferUsages, renderer::{RenderDevice, RenderQueue}, view::ViewVisibility, + Extract, }; use bevy_transform::prelude::GlobalTransform; use offset_allocator::{Allocation, Allocator}; diff --git a/crates/bevy_pbr/src/ssao/mod.rs b/crates/bevy_pbr/src/ssao/mod.rs index 6e8a1ef423131..4d97f52cff4ff 100644 --- a/crates/bevy_pbr/src/ssao/mod.rs +++ b/crates/bevy_pbr/src/ssao/mod.rs @@ -1,13 +1,13 @@ use crate::NodePbr; use bevy_app::{App, Plugin}; -use bevy_asset::{Handle, load_internal_asset, weak_handle}; +use bevy_asset::{load_internal_asset, weak_handle, Handle}; use bevy_core_pipeline::{ core_3d::graph::{Core3d, Node3d}, prelude::Camera3d, prepass::{DepthPrepass, NormalPrepass, ViewPrepassTextures}, }; use bevy_ecs::{ - prelude::{Component, Entity, require}, + prelude::{require, Component, Entity}, query::{Has, QueryItem, With}, reflect::ReflectComponent, resource::Resource, @@ -15,9 +15,8 @@ use bevy_ecs::{ system::{Commands, Query, Res, ResMut}, world::{FromWorld, World}, }; -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::{ - Extract, ExtractSchedule, Render, RenderApp, RenderSet, camera::{ExtractedCamera, TemporalJitter}, extract_component::ExtractComponent, globals::{GlobalsBuffer, GlobalsUniform}, @@ -34,6 +33,7 @@ use bevy_render::{ sync_world::RenderEntity, texture::{CachedTexture, TextureCache}, view::{Msaa, ViewUniform, ViewUniformOffset, ViewUniforms}, + Extract, ExtractSchedule, Render, RenderApp, RenderSet, }; use bevy_utils::prelude::default; use core::mem; @@ -89,9 +89,7 @@ impl Plugin for ScreenSpaceAmbientOcclusionPlugin { .allowed_usages .contains(TextureUsages::STORAGE_BINDING) { - warn!( - "ScreenSpaceAmbientOcclusionPlugin not loaded. GPU lacks support: TextureFormat::R16Float does not support TextureUsages::STORAGE_BINDING." - ); + warn!("ScreenSpaceAmbientOcclusionPlugin not loaded. GPU lacks support: TextureFormat::R16Float does not support TextureUsages::STORAGE_BINDING."); return; } @@ -102,9 +100,7 @@ impl Plugin for ScreenSpaceAmbientOcclusionPlugin { .max_storage_textures_per_shader_stage < 5 { - warn!( - "ScreenSpaceAmbientOcclusionPlugin not loaded. GPU lacks support: Limits::max_storage_textures_per_shader_stage is less than 5." - ); + warn!("ScreenSpaceAmbientOcclusionPlugin not loaded. GPU lacks support: Limits::max_storage_textures_per_shader_stage is less than 5."); return; } diff --git a/crates/bevy_pbr/src/ssr/mod.rs b/crates/bevy_pbr/src/ssr/mod.rs index ac62cd7540770..15b783cef5d5f 100644 --- a/crates/bevy_pbr/src/ssr/mod.rs +++ b/crates/bevy_pbr/src/ssr/mod.rs @@ -1,52 +1,52 @@ //! Screen space reflections implemented via raymarching. use bevy_app::{App, Plugin}; -use bevy_asset::{Handle, load_internal_asset, weak_handle}; +use bevy_asset::{load_internal_asset, weak_handle, Handle}; use bevy_core_pipeline::{ core_3d::{ - DEPTH_TEXTURE_SAMPLING_SUPPORTED, graph::{Core3d, Node3d}, + DEPTH_TEXTURE_SAMPLING_SUPPORTED, }, fullscreen_vertex_shader, prepass::{DeferredPrepass, DepthPrepass, MotionVectorPrepass, NormalPrepass}, }; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::{ - component::{Component, require}, + component::{require, Component}, entity::Entity, query::{Has, QueryItem, With}, reflect::ReflectComponent, resource::Resource, schedule::IntoSystemConfigs as _, - system::{Commands, Query, Res, ResMut, lifetimeless::Read}, + system::{lifetimeless::Read, Commands, Query, Res, ResMut}, world::{FromWorld, World}, }; use bevy_image::BevyDefault as _; -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::render_graph::RenderGraph; use bevy_render::{ - Render, RenderApp, RenderSet, extract_component::{ExtractComponent, ExtractComponentPlugin}, render_graph::{NodeRunError, RenderGraphApp, RenderGraphContext, ViewNode, ViewNodeRunner}, render_resource::{ - AddressMode, BindGroupEntries, BindGroupLayout, BindGroupLayoutEntries, + binding_types, AddressMode, BindGroupEntries, BindGroupLayout, BindGroupLayoutEntries, CachedRenderPipelineId, ColorTargetState, ColorWrites, DynamicUniformBuffer, FilterMode, FragmentState, Operations, PipelineCache, RenderPassColorAttachment, RenderPassDescriptor, RenderPipelineDescriptor, Sampler, SamplerBindingType, SamplerDescriptor, Shader, ShaderStages, ShaderType, SpecializedRenderPipeline, SpecializedRenderPipelines, - TextureFormat, TextureSampleType, binding_types, + TextureFormat, TextureSampleType, }, renderer::{RenderAdapter, RenderContext, RenderDevice, RenderQueue}, view::{ExtractedView, Msaa, ViewTarget, ViewUniformOffset}, + Render, RenderApp, RenderSet, }; use bevy_utils::{once, prelude::default}; use tracing::info; use crate::{ + binding_arrays_are_usable, graph::NodePbr, prelude::EnvironmentMapLight, MeshPipelineViewLayoutKey, MeshPipelineViewLayouts, MeshViewBindGroup, RenderViewLightProbes, ViewEnvironmentMapUniformOffset, ViewFogUniformOffset, ViewLightProbesUniformOffset, - ViewLightsUniformOffset, binding_arrays_are_usable, graph::NodePbr, - prelude::EnvironmentMapLight, + ViewLightsUniformOffset, }; const SSR_SHADER_HANDLE: Handle = weak_handle!("0b559df2-0d61-4f53-bf62-aea16cf32787"); diff --git a/crates/bevy_pbr/src/volumetric_fog/mod.rs b/crates/bevy_pbr/src/volumetric_fog/mod.rs index ede171a456a8c..4b90d63afccb7 100644 --- a/crates/bevy_pbr/src/volumetric_fog/mod.rs +++ b/crates/bevy_pbr/src/volumetric_fog/mod.rs @@ -30,35 +30,35 @@ //! [Henyey-Greenstein phase function]: https://www.pbr-book.org/4ed/Volume_Scattering/Phase_Functions#TheHenyeyndashGreensteinPhaseFunction use bevy_app::{App, Plugin}; -use bevy_asset::{Assets, Handle, load_internal_asset}; +use bevy_asset::{load_internal_asset, Assets, Handle}; use bevy_color::Color; use bevy_core_pipeline::core_3d::{ graph::{Core3d, Node3d}, prepare_core_3d_depth_textures, }; use bevy_ecs::{ - component::{Component, require}, + component::{require, Component}, reflect::ReflectComponent, schedule::IntoSystemConfigs as _, }; use bevy_image::Image; use bevy_math::{ - Vec2, Vec3, primitives::{Cuboid, Plane3d}, + Vec2, Vec3, }; -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::{ - ExtractSchedule, Render, RenderApp, RenderSet, mesh::{Mesh, Meshable}, render_graph::{RenderGraphApp, ViewNodeRunner}, render_resource::{Shader, SpecializedRenderPipelines}, sync_component::SyncComponentPlugin, view::Visibility, + ExtractSchedule, Render, RenderApp, RenderSet, }; use bevy_transform::components::Transform; use render::{ - CUBE_MESH, PLANE_MESH, VOLUMETRIC_FOG_HANDLE, VolumetricFogNode, VolumetricFogPipeline, - VolumetricFogUniformBuffer, + VolumetricFogNode, VolumetricFogPipeline, VolumetricFogUniformBuffer, CUBE_MESH, PLANE_MESH, + VOLUMETRIC_FOG_HANDLE, }; use crate::graph::NodePbr; diff --git a/crates/bevy_pbr/src/volumetric_fog/render.rs b/crates/bevy_pbr/src/volumetric_fog/render.rs index d6b9b352f12c4..292ad1c86ae1a 100644 --- a/crates/bevy_pbr/src/volumetric_fog/render.rs +++ b/crates/bevy_pbr/src/volumetric_fog/render.rs @@ -2,7 +2,7 @@ use core::array; -use bevy_asset::{AssetId, Handle, weak_handle}; +use bevy_asset::{weak_handle, AssetId, Handle}; use bevy_color::ColorToComponents as _; use bevy_core_pipeline::{ core_3d::Camera3d, @@ -14,19 +14,21 @@ use bevy_ecs::{ entity::Entity, query::{Has, QueryItem, With}, resource::Resource, - system::{Commands, Local, Query, Res, ResMut, lifetimeless::Read}, + system::{lifetimeless::Read, Commands, Local, Query, Res, ResMut}, world::{FromWorld, World}, }; use bevy_image::{BevyDefault, Image}; -use bevy_math::{Mat3A, Mat4, Vec3, Vec3A, Vec4, Vec4Swizzles as _, vec4}; +use bevy_math::{vec4, Mat3A, Mat4, Vec3, Vec3A, Vec4, Vec4Swizzles as _}; use bevy_render::{ - Extract, mesh::{ - Mesh, MeshVertexBufferLayoutRef, RenderMesh, RenderMeshBufferInfo, allocator::MeshAllocator, + allocator::MeshAllocator, Mesh, MeshVertexBufferLayoutRef, RenderMesh, RenderMeshBufferInfo, }, render_asset::RenderAssets, render_graph::{NodeRunError, RenderGraphContext, ViewNode}, render_resource::{ + binding_types::{ + sampler, texture_3d, texture_depth_2d, texture_depth_2d_multisampled, uniform_buffer, + }, BindGroupLayout, BindGroupLayoutEntries, BindingResource, BlendComponent, BlendFactor, BlendOperation, BlendState, CachedRenderPipelineId, ColorTargetState, ColorWrites, DynamicBindGroupEntries, DynamicUniformBuffer, Face, FragmentState, LoadOp, @@ -34,14 +36,12 @@ use bevy_render::{ RenderPassDescriptor, RenderPipelineDescriptor, SamplerBindingType, Shader, ShaderStages, ShaderType, SpecializedRenderPipeline, SpecializedRenderPipelines, StoreOp, TextureFormat, TextureSampleType, TextureUsages, VertexState, - binding_types::{ - sampler, texture_3d, texture_depth_2d, texture_depth_2d_multisampled, uniform_buffer, - }, }, renderer::{RenderContext, RenderDevice, RenderQueue}, sync_world::RenderEntity, texture::GpuImage, view::{ExtractedView, Msaa, ViewDepthTexture, ViewTarget, ViewUniformOffset}, + Extract, }; use bevy_transform::components::GlobalTransform; use bevy_utils::prelude::default; diff --git a/crates/bevy_pbr/src/wireframe.rs b/crates/bevy_pbr/src/wireframe.rs index 494b68cbb9591..68862bbf711ed 100644 --- a/crates/bevy_pbr/src/wireframe.rs +++ b/crates/bevy_pbr/src/wireframe.rs @@ -1,9 +1,9 @@ use crate::{Material, MaterialPipeline, MaterialPipelineKey, MaterialPlugin, MeshMaterial3d}; use bevy_app::{Plugin, Startup, Update}; -use bevy_asset::{Asset, AssetApp, Assets, Handle, load_internal_asset, weak_handle}; +use bevy_asset::{load_internal_asset, weak_handle, Asset, AssetApp, Assets, Handle}; use bevy_color::{Color, LinearRgba}; use bevy_ecs::prelude::*; -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::{ extract_resource::ExtractResource, mesh::{Mesh3d, MeshVertexBufferLayoutRef}, diff --git a/crates/bevy_picking/src/backend.rs b/crates/bevy_picking/src/backend.rs index 3e6cf51e1ab79..5c18d57211af7 100644 --- a/crates/bevy_picking/src/backend.rs +++ b/crates/bevy_picking/src/backend.rs @@ -39,10 +39,10 @@ use bevy_reflect::Reflect; /// /// This includes the most common types in this module, re-exported for your convenience. pub mod prelude { - pub use super::{HitData, PointerHits, ray::RayMap}; + pub use super::{ray::RayMap, HitData, PointerHits}; pub use crate::{ - PickSet, Pickable, pointer::{PointerId, PointerLocation}, + PickSet, Pickable, }; } @@ -130,7 +130,7 @@ pub mod ray { use crate::backend::prelude::{PointerId, PointerLocation}; use bevy_ecs::prelude::*; use bevy_math::Ray3d; - use bevy_platform_support::collections::{HashMap, hash_map::Iter}; + use bevy_platform_support::collections::{hash_map::Iter, HashMap}; use bevy_reflect::Reflect; use bevy_render::camera::Camera; use bevy_transform::prelude::GlobalTransform; diff --git a/crates/bevy_picking/src/events.rs b/crates/bevy_picking/src/events.rs index 21898d104bd96..243208ca8ac06 100644 --- a/crates/bevy_picking/src/events.rs +++ b/crates/bevy_picking/src/events.rs @@ -50,7 +50,7 @@ use bevy_window::Window; use tracing::debug; use crate::{ - backend::{HitData, prelude::PointerLocation}, + backend::{prelude::PointerLocation, HitData}, hover::{HoverMap, PreviousHoverMap}, pointer::{Location, PointerAction, PointerButton, PointerId, PointerInput, PointerMap}, }; diff --git a/crates/bevy_picking/src/hover.rs b/crates/bevy_picking/src/hover.rs index 0150f8762830e..69edb6d9aa9f8 100644 --- a/crates/bevy_picking/src/hover.rs +++ b/crates/bevy_picking/src/hover.rs @@ -8,9 +8,9 @@ use core::fmt::Debug; use std::collections::HashSet; use crate::{ - Pickable, backend::{self, HitData}, pointer::{PointerAction, PointerId, PointerInput, PointerInteraction, PointerPress}, + Pickable, }; use bevy_derive::{Deref, DerefMut}; diff --git a/crates/bevy_picking/src/input.rs b/crates/bevy_picking/src/input.rs index e399d4dd4a637..eeb4adac15d3a 100644 --- a/crates/bevy_picking/src/input.rs +++ b/crates/bevy_picking/src/input.rs @@ -14,10 +14,10 @@ use bevy_app::prelude::*; use bevy_ecs::prelude::*; use bevy_input::{ - ButtonState, mouse::MouseWheel, prelude::*, touch::{TouchInput, TouchPhase}, + ButtonState, }; use bevy_math::Vec2; use bevy_platform_support::collections::{HashMap, HashSet}; diff --git a/crates/bevy_picking/src/lib.rs b/crates/bevy_picking/src/lib.rs index 2716b9b983f02..7b9c990aed62c 100644 --- a/crates/bevy_picking/src/lib.rs +++ b/crates/bevy_picking/src/lib.rs @@ -167,7 +167,7 @@ pub mod mesh_picking; pub mod pointer; pub mod window; -use bevy_app::{PluginGroupBuilder, prelude::*}; +use bevy_app::{prelude::*, PluginGroupBuilder}; use bevy_ecs::prelude::*; use bevy_reflect::prelude::*; @@ -178,13 +178,13 @@ pub mod prelude { #[cfg(feature = "bevy_mesh_picking_backend")] #[doc(hidden)] pub use crate::mesh_picking::{ - MeshPickingPlugin, MeshPickingSettings, RayCastPickable, ray_cast::{MeshRayCast, MeshRayCastSettings, RayCastBackfaces, RayCastVisibility}, + MeshPickingPlugin, MeshPickingSettings, RayCastPickable, }; #[doc(hidden)] pub use crate::{ - DefaultPickingPlugins, InteractionPlugin, Pickable, PickingPlugin, events::*, - input::PointerInputPlugin, pointer::PointerButton, + events::*, input::PointerInputPlugin, pointer::PointerButton, DefaultPickingPlugins, + InteractionPlugin, Pickable, PickingPlugin, }; } diff --git a/crates/bevy_picking/src/mesh_picking/mod.rs b/crates/bevy_picking/src/mesh_picking/mod.rs index 45fe2e89597ac..5860fbc2b51c9 100644 --- a/crates/bevy_picking/src/mesh_picking/mod.rs +++ b/crates/bevy_picking/src/mesh_picking/mod.rs @@ -16,9 +16,9 @@ pub mod ray_cast; use crate::{ - PickSet, - backend::{HitData, PointerHits, ray::RayMap}, + backend::{ray::RayMap, HitData, PointerHits}, prelude::*, + PickSet, }; use bevy_app::prelude::*; use bevy_ecs::prelude::*; diff --git a/crates/bevy_picking/src/mesh_picking/ray_cast/intersections.rs b/crates/bevy_picking/src/mesh_picking/ray_cast/intersections.rs index 9191343dd4588..d4ec97e1f3549 100644 --- a/crates/bevy_picking/src/mesh_picking/ray_cast/intersections.rs +++ b/crates/bevy_picking/src/mesh_picking/ray_cast/intersections.rs @@ -1,4 +1,4 @@ -use bevy_math::{Dir3, Mat4, Ray3d, Vec3, Vec3A, bounding::Aabb3d}; +use bevy_math::{bounding::Aabb3d, Dir3, Mat4, Ray3d, Vec3, Vec3A}; use bevy_reflect::Reflect; use bevy_render::mesh::{Indices, Mesh, PrimitiveTopology}; @@ -303,7 +303,11 @@ pub fn ray_aabb_intersection_3d(ray: Ray3d, aabb: &Aabb3d, model_to_world: &Mat4 let tmin = tmin.max_element().max(0.0); let tmax = tmax.min_element(); - if tmin <= tmax { Some(tmin) } else { None } + if tmin <= tmax { + Some(tmin) + } else { + None + } } #[cfg(test)] diff --git a/crates/bevy_picking/src/mesh_picking/ray_cast/mod.rs b/crates/bevy_picking/src/mesh_picking/ray_cast/mod.rs index c6608d5c23dcf..ef6f187416b46 100644 --- a/crates/bevy_picking/src/mesh_picking/ray_cast/mod.rs +++ b/crates/bevy_picking/src/mesh_picking/ray_cast/mod.rs @@ -6,15 +6,15 @@ mod intersections; use bevy_derive::{Deref, DerefMut}; -use bevy_math::{Ray3d, bounding::Aabb3d}; -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_math::{bounding::Aabb3d, Ray3d}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::mesh::Mesh; use intersections::*; -pub use intersections::{RayMeshHit, ray_aabb_intersection_3d, ray_mesh_intersection}; +pub use intersections::{ray_aabb_intersection_3d, ray_mesh_intersection, RayMeshHit}; use bevy_asset::{Assets, Handle}; -use bevy_ecs::{prelude::*, system::SystemParam, system::lifetimeless::Read}; +use bevy_ecs::{prelude::*, system::lifetimeless::Read, system::SystemParam}; use bevy_math::FloatOrd; use bevy_render::{prelude::*, primitives::Aabb}; use bevy_transform::components::GlobalTransform; diff --git a/crates/bevy_platform_support/src/sync/atomic.rs b/crates/bevy_platform_support/src/sync/atomic.rs index d4d1ec84a7c83..9e8eadb3df8de 100644 --- a/crates/bevy_platform_support/src/sync/atomic.rs +++ b/crates/bevy_platform_support/src/sync/atomic.rs @@ -6,8 +6,8 @@ //! feature gates in your own code. pub use atomic::{ - AtomicBool, AtomicI8, AtomicI16, AtomicI32, AtomicI64, AtomicIsize, AtomicPtr, AtomicU8, - AtomicU16, AtomicU32, AtomicU64, AtomicUsize, Ordering, + AtomicBool, AtomicI16, AtomicI32, AtomicI64, AtomicI8, AtomicIsize, AtomicPtr, AtomicU16, + AtomicU32, AtomicU64, AtomicU8, AtomicUsize, Ordering, }; #[cfg(not(feature = "portable-atomic"))] diff --git a/crates/bevy_platform_support/src/time.rs b/crates/bevy_platform_support/src/time.rs index f7a77987cd38f..79fc81c7fe85d 100644 --- a/crates/bevy_platform_support/src/time.rs +++ b/crates/bevy_platform_support/src/time.rs @@ -186,9 +186,7 @@ mod fallback { } #[cfg(not(any(target_arch = "x86", target_arch = "x86_64", target_arch = "aarch64")))] - panic!( - "An elapsed time getter has not been provided to `Instant`. Please use `Instant::set_elapsed(...)` before calling `Instant::now()`" - ); + panic!("An elapsed time getter has not been provided to `Instant`. Please use `Instant::set_elapsed(...)` before calling `Instant::now()`"); #[cfg(any(target_arch = "x86", target_arch = "x86_64", target_arch = "aarch64"))] return Duration::from_nanos(_nanos); diff --git a/crates/bevy_reflect/derive/src/container_attributes.rs b/crates/bevy_reflect/derive/src/container_attributes.rs index 4c8cd7ae7e5be..bdb94db06bc7e 100644 --- a/crates/bevy_reflect/derive/src/container_attributes.rs +++ b/crates/bevy_reflect/derive/src/container_attributes.rs @@ -13,8 +13,8 @@ use bevy_macro_utils::fq_std::{FQAny, FQOption}; use proc_macro2::{Ident, Span}; use quote::quote_spanned; use syn::{ - Expr, LitBool, MetaList, MetaNameValue, Path, Token, WhereClause, ext::IdentExt, parenthesized, - parse::ParseStream, spanned::Spanned, token, + ext::IdentExt, parenthesized, parse::ParseStream, spanned::Spanned, token, Expr, LitBool, + MetaList, MetaNameValue, Path, Token, WhereClause, }; mod kw { @@ -257,12 +257,9 @@ impl ContainerAttributes { let ident = input.parse::()?; if input.peek(token::Paren) { - return Err(syn::Error::new( - ident.span(), - format!( - "only [{DEBUG_ATTR:?}, {PARTIAL_EQ_ATTR:?}, {HASH_ATTR:?}] may specify custom functions", - ), - )); + return Err(syn::Error::new(ident.span(), format!( + "only [{DEBUG_ATTR:?}, {PARTIAL_EQ_ATTR:?}, {HASH_ATTR:?}] may specify custom functions", + ))); } let ident_name = ident.to_string(); diff --git a/crates/bevy_reflect/derive/src/custom_attributes.rs b/crates/bevy_reflect/derive/src/custom_attributes.rs index 78e42842c6645..f12b6d7c12480 100644 --- a/crates/bevy_reflect/derive/src/custom_attributes.rs +++ b/crates/bevy_reflect/derive/src/custom_attributes.rs @@ -1,6 +1,6 @@ use proc_macro2::TokenStream; use quote::quote; -use syn::{Expr, Path, Token, parse::ParseStream}; +use syn::{parse::ParseStream, Expr, Path, Token}; #[derive(Default, Clone)] pub(crate) struct CustomAttributes { diff --git a/crates/bevy_reflect/derive/src/derive_data.rs b/crates/bevy_reflect/derive/src/derive_data.rs index 9b736b8b1f426..e739c91ebb912 100644 --- a/crates/bevy_reflect/derive/src/derive_data.rs +++ b/crates/bevy_reflect/derive/src/derive_data.rs @@ -2,7 +2,6 @@ use core::fmt; use proc_macro2::Span; use crate::{ - REFLECT_ATTRIBUTE_NAME, TYPE_NAME_ATTRIBUTE_NAME, TYPE_PATH_ATTRIBUTE_NAME, container_attributes::{ContainerAttributes, FromReflectAttrs, TypePathAttrs}, field_attributes::FieldAttributes, remote::RemoteType, @@ -11,14 +10,15 @@ use crate::{ string_expr::StringExpr, type_path::parse_path_no_leading_colon, where_clause_options::WhereClauseOptions, + REFLECT_ATTRIBUTE_NAME, TYPE_NAME_ATTRIBUTE_NAME, TYPE_PATH_ATTRIBUTE_NAME, }; -use quote::{ToTokens, quote}; +use quote::{quote, ToTokens}; use syn::token::Comma; use crate::generics::generate_generics; use syn::{ - Data, DeriveInput, Field, Fields, GenericParam, Generics, Ident, LitStr, Meta, Path, - PathSegment, Type, TypeParam, Variant, parse_str, punctuated::Punctuated, spanned::Spanned, + parse_str, punctuated::Punctuated, spanned::Spanned, Data, DeriveInput, Field, Fields, + GenericParam, Generics, Ident, LitStr, Meta, Path, PathSegment, Type, TypeParam, Variant, }; pub(crate) enum ReflectDerive<'a> { @@ -202,9 +202,7 @@ impl<'a> ReflectDerive<'a> { else { return Err(syn::Error::new( pair.span(), - format_args!( - "`#[{TYPE_PATH_ATTRIBUTE_NAME} = \"...\"]` must be a string literal" - ), + format_args!("`#[{TYPE_PATH_ATTRIBUTE_NAME} = \"...\"]` must be a string literal"), )); }; @@ -221,9 +219,7 @@ impl<'a> ReflectDerive<'a> { else { return Err(syn::Error::new( pair.span(), - format_args!( - "`#[{TYPE_NAME_ATTRIBUTE_NAME} = \"...\"]` must be a string literal" - ), + format_args!("`#[{TYPE_NAME_ATTRIBUTE_NAME} = \"...\"]` must be a string literal"), )); }; @@ -250,9 +246,7 @@ impl<'a> ReflectDerive<'a> { (None, Some(name)) => { return Err(syn::Error::new( name.span(), - format!( - "cannot use `#[{TYPE_NAME_ATTRIBUTE_NAME} = \"...\"]` without a `#[{TYPE_PATH_ATTRIBUTE_NAME} = \"...\"]` attribute." - ), + format!("cannot use `#[{TYPE_NAME_ATTRIBUTE_NAME} = \"...\"]` without a `#[{TYPE_PATH_ATTRIBUTE_NAME} = \"...\"]` attribute."), )); } _ => (), @@ -272,9 +266,7 @@ impl<'a> ReflectDerive<'a> { { return Err(syn::Error::new( meta.type_path().span(), - format!( - "a #[{TYPE_PATH_ATTRIBUTE_NAME} = \"...\"] attribute must be specified when using {provenance}" - ), + format!("a #[{TYPE_PATH_ATTRIBUTE_NAME} = \"...\"] attribute must be specified when using {provenance}") )); } diff --git a/crates/bevy_reflect/derive/src/documentation.rs b/crates/bevy_reflect/derive/src/documentation.rs index 696b9da81226a..33aec4c4f3221 100644 --- a/crates/bevy_reflect/derive/src/documentation.rs +++ b/crates/bevy_reflect/derive/src/documentation.rs @@ -2,7 +2,7 @@ use bevy_macro_utils::fq_std::FQOption; use proc_macro2::TokenStream; -use quote::{ToTokens, quote}; +use quote::{quote, ToTokens}; use syn::{Attribute, Expr, ExprLit, Lit, Meta}; /// A struct used to represent a type's documentation, if any. diff --git a/crates/bevy_reflect/derive/src/field_attributes.rs b/crates/bevy_reflect/derive/src/field_attributes.rs index 233ee26fb33e6..6cddb50e61bda 100644 --- a/crates/bevy_reflect/derive/src/field_attributes.rs +++ b/crates/bevy_reflect/derive/src/field_attributes.rs @@ -5,11 +5,11 @@ //! the derive helper attribute for `Reflect`, which looks like: `#[reflect(ignore)]`. use crate::{ - REFLECT_ATTRIBUTE_NAME, attribute_parser::terminated_parser, - custom_attributes::CustomAttributes, + attribute_parser::terminated_parser, custom_attributes::CustomAttributes, + REFLECT_ATTRIBUTE_NAME, }; use quote::ToTokens; -use syn::{Attribute, LitStr, Meta, Token, Type, parse::ParseStream}; +use syn::{parse::ParseStream, Attribute, LitStr, Meta, Token, Type}; mod kw { syn::custom_keyword!(ignore); diff --git a/crates/bevy_reflect/derive/src/from_reflect.rs b/crates/bevy_reflect/derive/src/from_reflect.rs index aabfaee649fd4..d994cbd2f79a2 100644 --- a/crates/bevy_reflect/derive/src/from_reflect.rs +++ b/crates/bevy_reflect/derive/src/from_reflect.rs @@ -1,15 +1,15 @@ use crate::{ - ReflectMeta, ReflectStruct, container_attributes::REFLECT_DEFAULT, derive_data::ReflectEnum, enum_utility::{EnumVariantOutputData, FromReflectVariantBuilder, VariantBuilder}, field_attributes::DefaultBehavior, ident::ident_or_index, where_clause_options::WhereClauseOptions, + ReflectMeta, ReflectStruct, }; use bevy_macro_utils::fq_std::{FQClone, FQDefault, FQOption}; use proc_macro2::Span; -use quote::{ToTokens, quote}; +use quote::{quote, ToTokens}; use syn::{Field, Ident, Lit, LitInt, LitStr, Member}; /// Implements `FromReflect` for the given struct diff --git a/crates/bevy_reflect/derive/src/impls/opaque.rs b/crates/bevy_reflect/derive/src/impls/opaque.rs index 75f33bd6305cf..bdee656a964cc 100644 --- a/crates/bevy_reflect/derive/src/impls/opaque.rs +++ b/crates/bevy_reflect/derive/src/impls/opaque.rs @@ -1,7 +1,7 @@ use crate::{ - ReflectMeta, impls::{common_partial_reflect_methods, impl_full_reflect, impl_type_path, impl_typed}, where_clause_options::WhereClauseOptions, + ReflectMeta, }; use bevy_macro_utils::fq_std::{FQClone, FQOption, FQResult}; use quote::quote; diff --git a/crates/bevy_reflect/derive/src/impls/structs.rs b/crates/bevy_reflect/derive/src/impls/structs.rs index 46b2c2ab1e0d6..c1db19ca9c80b 100644 --- a/crates/bevy_reflect/derive/src/impls/structs.rs +++ b/crates/bevy_reflect/derive/src/impls/structs.rs @@ -1,10 +1,10 @@ use crate::{ - ReflectStruct, impls::{common_partial_reflect_methods, impl_full_reflect, impl_type_path, impl_typed}, struct_utility::FieldAccessors, + ReflectStruct, }; use bevy_macro_utils::fq_std::{FQDefault, FQOption, FQResult}; -use quote::{ToTokens, quote}; +use quote::{quote, ToTokens}; /// Implements `Struct`, `GetTypeRegistration`, and `Reflect` for the given derive data. pub(crate) fn impl_struct(reflect_struct: &ReflectStruct) -> proc_macro2::TokenStream { diff --git a/crates/bevy_reflect/derive/src/impls/tuple_structs.rs b/crates/bevy_reflect/derive/src/impls/tuple_structs.rs index dd61d5725fd82..a0037c64ca57e 100644 --- a/crates/bevy_reflect/derive/src/impls/tuple_structs.rs +++ b/crates/bevy_reflect/derive/src/impls/tuple_structs.rs @@ -1,10 +1,10 @@ use crate::{ - ReflectStruct, impls::{common_partial_reflect_methods, impl_full_reflect, impl_type_path, impl_typed}, struct_utility::FieldAccessors, + ReflectStruct, }; use bevy_macro_utils::fq_std::{FQDefault, FQOption, FQResult}; -use quote::{ToTokens, quote}; +use quote::{quote, ToTokens}; /// Implements `TupleStruct`, `GetTypeRegistration`, and `Reflect` for the given derive data. pub(crate) fn impl_tuple_struct(reflect_struct: &ReflectStruct) -> proc_macro2::TokenStream { diff --git a/crates/bevy_reflect/derive/src/impls/typed.rs b/crates/bevy_reflect/derive/src/impls/typed.rs index 6b7b7641e63b6..da8254d149339 100644 --- a/crates/bevy_reflect/derive/src/impls/typed.rs +++ b/crates/bevy_reflect/derive/src/impls/typed.rs @@ -5,7 +5,7 @@ use crate::{ }; use bevy_macro_utils::fq_std::FQOption; use proc_macro2::TokenStream; -use quote::{ToTokens, quote}; +use quote::{quote, ToTokens}; /// Returns an expression for a `NonGenericTypeCell` or `GenericTypeCell` to generate `'static` references. fn static_type_cell( diff --git a/crates/bevy_reflect/derive/src/lib.rs b/crates/bevy_reflect/derive/src/lib.rs index f01e2035e65a8..276371427b620 100644 --- a/crates/bevy_reflect/derive/src/lib.rs +++ b/crates/bevy_reflect/derive/src/lib.rs @@ -46,7 +46,7 @@ use derive_data::{ReflectImplSource, ReflectProvenance, ReflectTraitToImpl, Refl use proc_macro::TokenStream; use quote::quote; use reflect_opaque::ReflectOpaqueDef; -use syn::{DeriveInput, parse_macro_input}; +use syn::{parse_macro_input, DeriveInput}; use type_path::NamedTypePathDef; pub(crate) static REFLECT_ATTRIBUTE_NAME: &str = "reflect"; diff --git a/crates/bevy_reflect/derive/src/reflect_opaque.rs b/crates/bevy_reflect/derive/src/reflect_opaque.rs index 2edde061c76c3..7cebcd7aff16c 100644 --- a/crates/bevy_reflect/derive/src/reflect_opaque.rs +++ b/crates/bevy_reflect/derive/src/reflect_opaque.rs @@ -2,7 +2,7 @@ use crate::{ container_attributes::ContainerAttributes, derive_data::ReflectTraitToImpl, type_path::CustomPathDef, }; -use syn::{Attribute, Generics, Path, parenthesized, parse::ParseStream, token::Paren}; +use syn::{parenthesized, parse::ParseStream, token::Paren, Attribute, Generics, Path}; /// A struct used to define a simple reflection-opaque types (including primitives). /// diff --git a/crates/bevy_reflect/derive/src/remote.rs b/crates/bevy_reflect/derive/src/remote.rs index d3f82aa75eacc..13cbe681ed4c7 100644 --- a/crates/bevy_reflect/derive/src/remote.rs +++ b/crates/bevy_reflect/derive/src/remote.rs @@ -1,21 +1,21 @@ use crate::{ - REFLECT_ATTRIBUTE_NAME, ReflectDerive, derive_data::{ReflectImplSource, ReflectProvenance, ReflectTraitToImpl}, from_reflect, ident::ident_or_index, impls, impls::impl_assertions, + ReflectDerive, REFLECT_ATTRIBUTE_NAME, }; use bevy_macro_utils::fq_std::FQOption; use proc_macro::TokenStream; use proc_macro2::{Ident, Span}; use quote::{format_ident, quote, quote_spanned}; use syn::{ - DeriveInput, ExprPath, Generics, Member, PathArguments, Type, TypePath, parse::{Parse, ParseStream}, parse_macro_input, spanned::Spanned, token::PathSep, + DeriveInput, ExprPath, Generics, Member, PathArguments, Type, TypePath, }; /// Generates the remote wrapper type and implements all the necessary traits. @@ -473,7 +473,7 @@ impl<'a> RemoteType<'a> { return Err(syn::Error::new( arg.span(), "cannot use parenthesized type as remote type", - )); + )) } } } diff --git a/crates/bevy_reflect/derive/src/serialization.rs b/crates/bevy_reflect/derive/src/serialization.rs index 93474e571d243..75df7b7b930b2 100644 --- a/crates/bevy_reflect/derive/src/serialization.rs +++ b/crates/bevy_reflect/derive/src/serialization.rs @@ -5,7 +5,7 @@ use crate::{ use bevy_macro_utils::fq_std::FQDefault; use quote::quote; use std::collections::HashMap; -use syn::{Path, spanned::Spanned}; +use syn::{spanned::Spanned, Path}; type ReflectionIndex = usize; diff --git a/crates/bevy_reflect/derive/src/string_expr.rs b/crates/bevy_reflect/derive/src/string_expr.rs index a552f58bc90d3..cc48a90b91735 100644 --- a/crates/bevy_reflect/derive/src/string_expr.rs +++ b/crates/bevy_reflect/derive/src/string_expr.rs @@ -1,6 +1,6 @@ use proc_macro2::TokenStream; -use quote::{ToTokens, quote}; -use syn::{LitStr, spanned::Spanned}; +use quote::{quote, ToTokens}; +use syn::{spanned::Spanned, LitStr}; /// Contains tokens representing different kinds of string. #[derive(Clone)] diff --git a/crates/bevy_reflect/derive/src/struct_utility.rs b/crates/bevy_reflect/derive/src/struct_utility.rs index 87c9659ee1b48..09604419b6043 100644 --- a/crates/bevy_reflect/derive/src/struct_utility.rs +++ b/crates/bevy_reflect/derive/src/struct_utility.rs @@ -1,4 +1,4 @@ -use crate::{ReflectStruct, derive_data::StructField}; +use crate::{derive_data::StructField, ReflectStruct}; use quote::quote; /// A helper struct for creating remote-aware field accessors. diff --git a/crates/bevy_reflect/derive/src/trait_reflection.rs b/crates/bevy_reflect/derive/src/trait_reflection.rs index aa6d3ae769614..8df40e47a5fd0 100644 --- a/crates/bevy_reflect/derive/src/trait_reflection.rs +++ b/crates/bevy_reflect/derive/src/trait_reflection.rs @@ -1,7 +1,7 @@ use bevy_macro_utils::fq_std::{FQClone, FQOption, FQResult}; use proc_macro::TokenStream; use quote::quote; -use syn::{Attribute, ItemTrait, Token, parse::Parse, parse_macro_input}; +use syn::{parse::Parse, parse_macro_input, Attribute, ItemTrait, Token}; pub(crate) struct TraitInfo { item_trait: ItemTrait, diff --git a/crates/bevy_reflect/derive/src/type_path.rs b/crates/bevy_reflect/derive/src/type_path.rs index 6f26a6adeb1d8..3ef92981a33d9 100644 --- a/crates/bevy_reflect/derive/src/type_path.rs +++ b/crates/bevy_reflect/derive/src/type_path.rs @@ -1,8 +1,9 @@ use proc_macro2::Ident; use syn::{ - Generics, Path, PathSegment, Token, parenthesized, + parenthesized, parse::{Parse, ParseStream}, token::Paren, + Generics, Path, PathSegment, Token, }; pub(crate) fn parse_path_no_leading_colon(input: ParseStream) -> syn::Result { diff --git a/crates/bevy_reflect/derive/src/where_clause_options.rs b/crates/bevy_reflect/derive/src/where_clause_options.rs index dec1ab87fd04c..1551e008d017c 100644 --- a/crates/bevy_reflect/derive/src/where_clause_options.rs +++ b/crates/bevy_reflect/derive/src/where_clause_options.rs @@ -1,8 +1,8 @@ use crate::derive_data::ReflectMeta; use bevy_macro_utils::fq_std::{FQAny, FQSend, FQSync}; use proc_macro2::TokenStream; -use quote::{ToTokens, quote}; -use syn::{Token, Type, WhereClause, punctuated::Punctuated}; +use quote::{quote, ToTokens}; +use syn::{punctuated::Punctuated, Token, Type, WhereClause}; /// Options defining how to extend the `where` clause for reflection. pub(crate) struct WhereClauseOptions<'a, 'b> { diff --git a/crates/bevy_reflect/examples/reflect_docs.rs b/crates/bevy_reflect/examples/reflect_docs.rs index c3942438c2033..10852185c00d8 100644 --- a/crates/bevy_reflect/examples/reflect_docs.rs +++ b/crates/bevy_reflect/examples/reflect_docs.rs @@ -36,10 +36,7 @@ fn main() { // From here, we already have access to the struct's docs: let player_docs = player_info.docs().unwrap(); - assert_eq!( - " The struct that defines our player.\n\n # Example\n\n ```\n let player = Player::new(\"Urist McPlayer\");\n ```", - player_docs - ); + assert_eq!(" The struct that defines our player.\n\n # Example\n\n ```\n let player = Player::new(\"Urist McPlayer\");\n ```", player_docs); println!("=====[ Player ]=====\n{player_docs}"); // We can then iterate through our struct's fields to get their documentation as well: diff --git a/crates/bevy_reflect/src/array.rs b/crates/bevy_reflect/src/array.rs index 13c83b3cd1816..300e69c2a71e9 100644 --- a/crates/bevy_reflect/src/array.rs +++ b/crates/bevy_reflect/src/array.rs @@ -1,8 +1,8 @@ use crate::generics::impl_generic_info_methods; use crate::{ - ApplyError, Generics, MaybeTyped, PartialReflect, Reflect, ReflectKind, ReflectMut, - ReflectOwned, ReflectRef, Type, TypeInfo, TypePath, type_info::impl_type_methods, - utility::reflect_hasher, + type_info::impl_type_methods, utility::reflect_hasher, ApplyError, Generics, MaybeTyped, + PartialReflect, Reflect, ReflectKind, ReflectMut, ReflectOwned, ReflectRef, Type, TypeInfo, + TypePath, }; use alloc::{boxed::Box, vec::Vec}; use bevy_reflect_derive::impl_type_path; diff --git a/crates/bevy_reflect/src/attributes.rs b/crates/bevy_reflect/src/attributes.rs index 052aab92d1b26..a6edefab25c65 100644 --- a/crates/bevy_reflect/src/attributes.rs +++ b/crates/bevy_reflect/src/attributes.rs @@ -178,7 +178,7 @@ pub(crate) use impl_custom_attribute_methods; #[cfg(test)] mod tests { use super::*; - use crate::{TypeInfo, VariantInfo, type_info::Typed}; + use crate::{type_info::Typed, TypeInfo, VariantInfo}; use alloc::{format, string::String}; use core::ops::RangeInclusive; @@ -204,11 +204,9 @@ mod tests { let attributes = CustomAttributes::default().with_attribute(String::from("Hello, World!")); let value = attributes.get_by_id(TypeId::of::()).unwrap(); - assert!( - value - .reflect_partial_eq(&String::from("Hello, World!")) - .unwrap() - ); + assert!(value + .reflect_partial_eq(&String::from("Hello, World!")) + .unwrap()); } #[test] diff --git a/crates/bevy_reflect/src/enums/dynamic_enum.rs b/crates/bevy_reflect/src/enums/dynamic_enum.rs index c93f08bd9e178..d9e228c07eaae 100644 --- a/crates/bevy_reflect/src/enums/dynamic_enum.rs +++ b/crates/bevy_reflect/src/enums/dynamic_enum.rs @@ -1,9 +1,9 @@ use bevy_reflect_derive::impl_type_path; use crate::{ - ApplyError, DynamicStruct, DynamicTuple, Enum, PartialReflect, Reflect, ReflectKind, - ReflectMut, ReflectOwned, ReflectRef, Struct, Tuple, TypeInfo, VariantFieldIter, VariantType, - enum_debug, enum_hash, enum_partial_eq, + enum_debug, enum_hash, enum_partial_eq, ApplyError, DynamicStruct, DynamicTuple, Enum, + PartialReflect, Reflect, ReflectKind, ReflectMut, ReflectOwned, ReflectRef, Struct, Tuple, + TypeInfo, VariantFieldIter, VariantType, }; use alloc::{boxed::Box, string::String}; diff --git a/crates/bevy_reflect/src/enums/enum_trait.rs b/crates/bevy_reflect/src/enums/enum_trait.rs index 79c25e1ab8b14..d3f6550640012 100644 --- a/crates/bevy_reflect/src/enums/enum_trait.rs +++ b/crates/bevy_reflect/src/enums/enum_trait.rs @@ -1,8 +1,8 @@ use crate::generics::impl_generic_info_methods; use crate::{ - DynamicEnum, Generics, PartialReflect, Type, TypePath, VariantInfo, VariantType, - attributes::{CustomAttributes, impl_custom_attribute_methods}, + attributes::{impl_custom_attribute_methods, CustomAttributes}, type_info::impl_type_methods, + DynamicEnum, Generics, PartialReflect, Type, TypePath, VariantInfo, VariantType, }; use alloc::{boxed::Box, format, string::String}; use bevy_platform_support::collections::HashMap; diff --git a/crates/bevy_reflect/src/enums/helpers.rs b/crates/bevy_reflect/src/enums/helpers.rs index 7c69810539bef..659d0bd7bc823 100644 --- a/crates/bevy_reflect/src/enums/helpers.rs +++ b/crates/bevy_reflect/src/enums/helpers.rs @@ -1,4 +1,4 @@ -use crate::{Enum, PartialReflect, ReflectRef, VariantType, utility::reflect_hasher}; +use crate::{utility::reflect_hasher, Enum, PartialReflect, ReflectRef, VariantType}; use core::{ fmt::Debug, hash::{Hash, Hasher}, diff --git a/crates/bevy_reflect/src/enums/mod.rs b/crates/bevy_reflect/src/enums/mod.rs index 1bb5d18f56510..fd657ffa7f25a 100644 --- a/crates/bevy_reflect/src/enums/mod.rs +++ b/crates/bevy_reflect/src/enums/mod.rs @@ -50,22 +50,18 @@ mod tests { if let VariantInfo::Tuple(variant) = info.variant("B").unwrap() { assert!(variant.field_at(0).unwrap().is::()); assert!(variant.field_at(1).unwrap().is::()); - assert!( - variant - .field_at(0) - .unwrap() - .type_info() - .unwrap() - .is::() - ); - assert!( - variant - .field_at(1) - .unwrap() - .type_info() - .unwrap() - .is::() - ); + assert!(variant + .field_at(0) + .unwrap() + .type_info() + .unwrap() + .is::()); + assert!(variant + .field_at(1) + .unwrap() + .type_info() + .unwrap() + .is::()); } else { panic!("Expected `VariantInfo::Tuple`"); } @@ -76,14 +72,12 @@ mod tests { if let VariantInfo::Struct(variant) = info.variant("C").unwrap() { assert!(variant.field_at(0).unwrap().is::()); assert!(variant.field("foo").unwrap().is::()); - assert!( - variant - .field("foo") - .unwrap() - .type_info() - .unwrap() - .is::() - ); + assert!(variant + .field("foo") + .unwrap() + .type_info() + .unwrap() + .is::()); } else { panic!("Expected `VariantInfo::Struct`"); } @@ -235,16 +229,14 @@ mod tests { let value: &dyn Enum = &MyEnum::B(123, 321); assert_eq!(2, value.field_len()); let mut iter = value.iter_fields(); - assert!( - iter.next() - .and_then(|field| field.value().reflect_partial_eq(&123_usize)) - .unwrap_or_default() - ); - assert!( - iter.next() - .and_then(|field| field.value().reflect_partial_eq(&321_i32)) - .unwrap_or_default() - ); + assert!(iter + .next() + .and_then(|field| field.value().reflect_partial_eq(&123_usize)) + .unwrap_or_default()); + assert!(iter + .next() + .and_then(|field| field.value().reflect_partial_eq(&321_i32)) + .unwrap_or_default()); // === Struct === // let value: &dyn Enum = &MyEnum::C { @@ -253,22 +245,20 @@ mod tests { }; assert_eq!(2, value.field_len()); let mut iter = value.iter_fields(); - assert!( - iter.next() - .and_then(|field| field - .value() - .reflect_partial_eq(&1.23_f32) - .and(field.name().map(|name| name == "foo"))) - .unwrap_or_default() - ); - assert!( - iter.next() - .and_then(|field| field - .value() - .reflect_partial_eq(&true) - .and(field.name().map(|name| name == "bar"))) - .unwrap_or_default() - ); + assert!(iter + .next() + .and_then(|field| field + .value() + .reflect_partial_eq(&1.23_f32) + .and(field.name().map(|name| name == "foo"))) + .unwrap_or_default()); + assert!(iter + .next() + .and_then(|field| field + .value() + .reflect_partial_eq(&true) + .and(field.name().map(|name| name == "bar"))) + .unwrap_or_default()); } #[test] @@ -512,55 +502,45 @@ mod tests { // === MyEnum::A -> MyEnum::B === // value.apply(&MyEnum::B(123, 321)); - assert!( - value - .reflect_partial_eq(&MyEnum::B(123, 321)) - .unwrap_or_default() - ); + assert!(value + .reflect_partial_eq(&MyEnum::B(123, 321)) + .unwrap_or_default()); // === MyEnum::B -> MyEnum::B === // value.apply(&MyEnum::B(321, 123)); - assert!( - value - .reflect_partial_eq(&MyEnum::B(321, 123)) - .unwrap_or_default() - ); + assert!(value + .reflect_partial_eq(&MyEnum::B(321, 123)) + .unwrap_or_default()); // === MyEnum::B -> MyEnum::C === // value.apply(&MyEnum::C { foo: 1.23, bar: true, }); - assert!( - value - .reflect_partial_eq(&MyEnum::C { - foo: 1.23, - bar: true - }) - .unwrap_or_default() - ); + assert!(value + .reflect_partial_eq(&MyEnum::C { + foo: 1.23, + bar: true + }) + .unwrap_or_default()); // === MyEnum::C -> MyEnum::C === // value.apply(&MyEnum::C { foo: 3.21, bar: false, }); - assert!( - value - .reflect_partial_eq(&MyEnum::C { - foo: 3.21, - bar: false - }) - .unwrap_or_default() - ); + assert!(value + .reflect_partial_eq(&MyEnum::C { + foo: 3.21, + bar: false + }) + .unwrap_or_default()); // === MyEnum::C -> MyEnum::B === // value.apply(&MyEnum::B(123, 321)); - assert!( - value - .reflect_partial_eq(&MyEnum::B(123, 321)) - .unwrap_or_default() - ); + assert!(value + .reflect_partial_eq(&MyEnum::B(123, 321)) + .unwrap_or_default()); // === MyEnum::B -> MyEnum::A === // value.apply(&MyEnum::A); @@ -577,19 +557,15 @@ mod tests { // === MyEnum::A -> MyEnum::B === // value.set(Box::new(MyEnum::B(123, 321))).unwrap(); - assert!( - value - .reflect_partial_eq(&MyEnum::B(123, 321)) - .unwrap_or_default() - ); + assert!(value + .reflect_partial_eq(&MyEnum::B(123, 321)) + .unwrap_or_default()); // === MyEnum::B -> MyEnum::B === // value.set(Box::new(MyEnum::B(321, 123))).unwrap(); - assert!( - value - .reflect_partial_eq(&MyEnum::B(321, 123)) - .unwrap_or_default() - ); + assert!(value + .reflect_partial_eq(&MyEnum::B(321, 123)) + .unwrap_or_default()); // === MyEnum::B -> MyEnum::C === // value @@ -598,14 +574,12 @@ mod tests { bar: true, })) .unwrap(); - assert!( - value - .reflect_partial_eq(&MyEnum::C { - foo: 1.23, - bar: true - }) - .unwrap_or_default() - ); + assert!(value + .reflect_partial_eq(&MyEnum::C { + foo: 1.23, + bar: true + }) + .unwrap_or_default()); // === MyEnum::C -> MyEnum::C === // value @@ -614,22 +588,18 @@ mod tests { bar: false, })) .unwrap(); - assert!( - value - .reflect_partial_eq(&MyEnum::C { - foo: 3.21, - bar: false - }) - .unwrap_or_default() - ); + assert!(value + .reflect_partial_eq(&MyEnum::C { + foo: 3.21, + bar: false + }) + .unwrap_or_default()); // === MyEnum::C -> MyEnum::B === // value.set(Box::new(MyEnum::B(123, 321))).unwrap(); - assert!( - value - .reflect_partial_eq(&MyEnum::B(123, 321)) - .unwrap_or_default() - ); + assert!(value + .reflect_partial_eq(&MyEnum::B(123, 321)) + .unwrap_or_default()); // === MyEnum::B -> MyEnum::A === // value.set(Box::new(MyEnum::A)).unwrap(); diff --git a/crates/bevy_reflect/src/enums/variants.rs b/crates/bevy_reflect/src/enums/variants.rs index b610644569952..25e40334e7187 100644 --- a/crates/bevy_reflect/src/enums/variants.rs +++ b/crates/bevy_reflect/src/enums/variants.rs @@ -1,6 +1,6 @@ use crate::{ + attributes::{impl_custom_attribute_methods, CustomAttributes}, NamedField, UnnamedField, - attributes::{CustomAttributes, impl_custom_attribute_methods}, }; use alloc::boxed::Box; use bevy_platform_support::collections::HashMap; diff --git a/crates/bevy_reflect/src/fields.rs b/crates/bevy_reflect/src/fields.rs index 5608d9adbc7ce..3a521c21ccbee 100644 --- a/crates/bevy_reflect/src/fields.rs +++ b/crates/bevy_reflect/src/fields.rs @@ -1,7 +1,7 @@ use crate::{ - MaybeTyped, PartialReflect, Type, TypeInfo, TypePath, - attributes::{CustomAttributes, impl_custom_attribute_methods}, + attributes::{impl_custom_attribute_methods, CustomAttributes}, type_info::impl_type_methods, + MaybeTyped, PartialReflect, Type, TypeInfo, TypePath, }; use bevy_platform_support::sync::Arc; diff --git a/crates/bevy_reflect/src/func/args/arg.rs b/crates/bevy_reflect/src/func/args/arg.rs index 4af2c47f656c6..8ca03aafd36ff 100644 --- a/crates/bevy_reflect/src/func/args/arg.rs +++ b/crates/bevy_reflect/src/func/args/arg.rs @@ -1,6 +1,6 @@ use crate::{ - PartialReflect, Reflect, TypePath, func::args::{ArgError, FromArg, Ownership}, + PartialReflect, Reflect, TypePath, }; use alloc::{boxed::Box, string::ToString}; use core::ops::Deref; diff --git a/crates/bevy_reflect/src/func/args/info.rs b/crates/bevy_reflect/src/func/args/info.rs index 9e76cdfea327b..b1a81f3059a2e 100644 --- a/crates/bevy_reflect/src/func/args/info.rs +++ b/crates/bevy_reflect/src/func/args/info.rs @@ -1,9 +1,9 @@ use alloc::borrow::Cow; use crate::{ - Type, TypePath, func::args::{GetOwnership, Ownership}, type_info::impl_type_methods, + Type, TypePath, }; /// Type information for an [`Arg`] used in a [`DynamicFunction`] or [`DynamicFunctionMut`]. diff --git a/crates/bevy_reflect/src/func/args/list.rs b/crates/bevy_reflect/src/func/args/list.rs index 7f0995b1b59aa..ee0964e71a644 100644 --- a/crates/bevy_reflect/src/func/args/list.rs +++ b/crates/bevy_reflect/src/func/args/list.rs @@ -1,9 +1,9 @@ use crate::{ - PartialReflect, Reflect, TypePath, func::{ - ArgError, args::{Arg, ArgValue, FromArg}, + ArgError, }, + PartialReflect, Reflect, TypePath, }; use alloc::{ boxed::Box, diff --git a/crates/bevy_reflect/src/func/dynamic_function.rs b/crates/bevy_reflect/src/func/dynamic_function.rs index 392b2264744eb..c090442ce483f 100644 --- a/crates/bevy_reflect/src/func/dynamic_function.rs +++ b/crates/bevy_reflect/src/func/dynamic_function.rs @@ -1,14 +1,14 @@ use crate::{ __macro_exports::RegisterForReflection, - ApplyError, MaybeTyped, PartialReflect, Reflect, ReflectKind, ReflectMut, ReflectOwned, - ReflectRef, TypeInfo, TypePath, func::{ - DynamicFunctionMut, Function, FunctionOverloadError, FunctionResult, IntoFunction, - IntoFunctionMut, args::{ArgCount, ArgList}, dynamic_function_internal::DynamicFunctionInternal, info::FunctionInfo, + DynamicFunctionMut, Function, FunctionOverloadError, FunctionResult, IntoFunction, + IntoFunctionMut, }, + ApplyError, MaybeTyped, PartialReflect, Reflect, ReflectKind, ReflectMut, ReflectOwned, + ReflectRef, TypeInfo, TypePath, }; use alloc::{borrow::Cow, boxed::Box}; use bevy_platform_support::sync::Arc; @@ -480,9 +480,9 @@ impl<'env> IntoFunctionMut<'env, ()> for DynamicFunction<'env> { #[cfg(test)] mod tests { use super::*; - use crate::Type; use crate::func::signature::ArgumentSignature; use crate::func::{FunctionError, IntoReturn, SignatureInfo}; + use crate::Type; use alloc::{format, string::String, vec, vec::Vec}; use bevy_platform_support::collections::HashSet; use core::ops::Add; @@ -780,10 +780,7 @@ mod tests { let function = greet.into_function(); let debug = format!("{:?}", function); - assert_eq!( - debug, - "DynamicFunction(fn bevy_reflect::func::dynamic_function::tests::should_debug_dynamic_function::greet(_: &alloc::string::String) -> alloc::string::String)" - ); + assert_eq!(debug, "DynamicFunction(fn bevy_reflect::func::dynamic_function::tests::should_debug_dynamic_function::greet(_: &alloc::string::String) -> alloc::string::String)"); } #[test] diff --git a/crates/bevy_reflect/src/func/dynamic_function_internal.rs b/crates/bevy_reflect/src/func/dynamic_function_internal.rs index 076ccf3500fc3..65b98e5e13a67 100644 --- a/crates/bevy_reflect/src/func/dynamic_function_internal.rs +++ b/crates/bevy_reflect/src/func/dynamic_function_internal.rs @@ -185,8 +185,8 @@ impl Debug for DynamicFunctionInternal { #[cfg(test)] mod tests { use super::*; - use crate::Type; use crate::func::{FunctionInfo, SignatureInfo}; + use crate::Type; #[test] fn should_merge_single_into_single() { diff --git a/crates/bevy_reflect/src/func/dynamic_function_mut.rs b/crates/bevy_reflect/src/func/dynamic_function_mut.rs index 514eced2c6d55..b706ac620ac84 100644 --- a/crates/bevy_reflect/src/func/dynamic_function_mut.rs +++ b/crates/bevy_reflect/src/func/dynamic_function_mut.rs @@ -3,9 +3,9 @@ use bevy_platform_support::sync::Arc; use core::fmt::{Debug, Formatter}; use crate::func::{ - DynamicFunction, FunctionInfo, FunctionOverloadError, FunctionResult, IntoFunctionMut, args::{ArgCount, ArgList}, dynamic_function_internal::DynamicFunctionInternal, + DynamicFunction, FunctionInfo, FunctionOverloadError, FunctionResult, IntoFunctionMut, }; /// A [`Box`] containing a callback to a reflected function. diff --git a/crates/bevy_reflect/src/func/error.rs b/crates/bevy_reflect/src/func/error.rs index 812e1f9c5875b..d4407d9698428 100644 --- a/crates/bevy_reflect/src/func/error.rs +++ b/crates/bevy_reflect/src/func/error.rs @@ -1,7 +1,7 @@ use crate::func::signature::ArgumentSignature; use crate::func::{ - Return, args::{ArgCount, ArgError}, + Return, }; use alloc::borrow::Cow; use bevy_platform_support::collections::HashSet; @@ -20,9 +20,7 @@ pub enum FunctionError { #[error("received {received} arguments but expected one of {expected:?}")] ArgCountMismatch { expected: ArgCount, received: usize }, /// No overload was found for the given set of arguments. - #[error( - "no overload found for arguments with signature `{received:?}`, expected one of `{expected:?}`" - )] + #[error("no overload found for arguments with signature `{received:?}`, expected one of `{expected:?}`")] NoOverload { expected: HashSet, received: ArgumentSignature, diff --git a/crates/bevy_reflect/src/func/function.rs b/crates/bevy_reflect/src/func/function.rs index 615beddb32a31..2ae8c1877b4de 100644 --- a/crates/bevy_reflect/src/func/function.rs +++ b/crates/bevy_reflect/src/func/function.rs @@ -1,9 +1,9 @@ use crate::{ - PartialReflect, func::{ - DynamicFunction, FunctionInfo, FunctionResult, args::{ArgCount, ArgList}, + DynamicFunction, FunctionInfo, FunctionResult, }, + PartialReflect, }; use alloc::borrow::Cow; use core::fmt::Debug; diff --git a/crates/bevy_reflect/src/func/info.rs b/crates/bevy_reflect/src/func/info.rs index 25fc0b4342bc4..53737fd891dbd 100644 --- a/crates/bevy_reflect/src/func/info.rs +++ b/crates/bevy_reflect/src/func/info.rs @@ -2,11 +2,11 @@ use alloc::{borrow::Cow, boxed::Box, vec, vec::Vec}; use core::fmt::{Debug, Formatter}; use crate::{ - Type, TypePath, - func::FunctionOverloadError, func::args::{ArgCount, ArgCountOutOfBoundsError, ArgInfo, GetOwnership, Ownership}, func::signature::ArgumentSignature, + func::FunctionOverloadError, type_info::impl_type_methods, + Type, TypePath, }; use variadics_please::all_tuples; diff --git a/crates/bevy_reflect/src/func/mod.rs b/crates/bevy_reflect/src/func/mod.rs index cfedcab7e04cb..74a89282c6d2d 100644 --- a/crates/bevy_reflect/src/func/mod.rs +++ b/crates/bevy_reflect/src/func/mod.rs @@ -194,8 +194,8 @@ mod tests { use super::*; use crate::func::args::ArgCount; use crate::{ - TypePath, func::args::{ArgError, ArgList, Ownership}, + TypePath, }; #[test] diff --git a/crates/bevy_reflect/src/func/reflect_fn.rs b/crates/bevy_reflect/src/func/reflect_fn.rs index f8693c3ae5416..6ef7c22eb177a 100644 --- a/crates/bevy_reflect/src/func/reflect_fn.rs +++ b/crates/bevy_reflect/src/func/reflect_fn.rs @@ -1,12 +1,12 @@ use variadics_please::all_tuples; use crate::{ - Reflect, TypePath, func::{ - ArgList, FunctionError, FunctionResult, IntoReturn, ReflectFnMut, args::{ArgCount, FromArg}, macros::count_tokens, + ArgList, FunctionError, FunctionResult, IntoReturn, ReflectFnMut, }, + Reflect, TypePath, }; /// A reflection-based version of the [`Fn`] trait. diff --git a/crates/bevy_reflect/src/func/reflect_fn_mut.rs b/crates/bevy_reflect/src/func/reflect_fn_mut.rs index 25a3c4bfdd173..98db2b45907ef 100644 --- a/crates/bevy_reflect/src/func/reflect_fn_mut.rs +++ b/crates/bevy_reflect/src/func/reflect_fn_mut.rs @@ -1,12 +1,12 @@ use variadics_please::all_tuples; use crate::{ - Reflect, TypePath, func::{ - ArgList, FunctionError, FunctionResult, IntoReturn, args::{ArgCount, FromArg}, macros::count_tokens, + ArgList, FunctionError, FunctionResult, IntoReturn, }, + Reflect, TypePath, }; /// A reflection-based version of the [`FnMut`] trait. diff --git a/crates/bevy_reflect/src/func/signature.rs b/crates/bevy_reflect/src/func/signature.rs index 9421a54937309..c8862b35d0d90 100644 --- a/crates/bevy_reflect/src/func/signature.rs +++ b/crates/bevy_reflect/src/func/signature.rs @@ -11,9 +11,9 @@ //! //! [`FunctionInfo`]: crate::func::info::FunctionInfo -use crate::Type; use crate::func::args::ArgInfo; use crate::func::{ArgList, SignatureInfo}; +use crate::Type; use alloc::boxed::Box; use bevy_platform_support::collections::Equivalent; use core::borrow::Borrow; diff --git a/crates/bevy_reflect/src/impls/glam.rs b/crates/bevy_reflect/src/impls/glam.rs index db3e91c7eeb2a..653eb3edaa55b 100644 --- a/crates/bevy_reflect/src/impls/glam.rs +++ b/crates/bevy_reflect/src/impls/glam.rs @@ -1,4 +1,4 @@ -use crate::{ReflectDeserialize, ReflectSerialize, std_traits::ReflectDefault}; +use crate::{std_traits::ReflectDefault, ReflectDeserialize, ReflectSerialize}; use assert_type_match::assert_type_match; use bevy_reflect_derive::{impl_reflect, impl_reflect_opaque}; use glam::*; @@ -498,16 +498,16 @@ impl_reflect_opaque!(::glam::BVec4A(Debug, Default, Deserialize, Serialize)); mod tests { use alloc::{format, string::String}; use ron::{ + ser::{to_string_pretty, PrettyConfig}, Deserializer, - ser::{PrettyConfig, to_string_pretty}, }; use serde::de::DeserializeSeed; use static_assertions::assert_impl_all; use crate::{ - Enum, GetTypeRegistration, TypeRegistry, prelude::*, serde::{ReflectDeserializer, ReflectSerializer}, + Enum, GetTypeRegistration, TypeRegistry, }; use super::*; diff --git a/crates/bevy_reflect/src/impls/petgraph.rs b/crates/bevy_reflect/src/impls/petgraph.rs index f4d23f2084d41..2264c9cb4b9b2 100644 --- a/crates/bevy_reflect/src/impls/petgraph.rs +++ b/crates/bevy_reflect/src/impls/petgraph.rs @@ -1,4 +1,4 @@ -use crate::{ReflectDeserialize, ReflectSerialize, impl_reflect_opaque, prelude::ReflectDefault}; +use crate::{impl_reflect_opaque, prelude::ReflectDefault, ReflectDeserialize, ReflectSerialize}; impl_reflect_opaque!(::petgraph::graph::NodeIndex( Default, diff --git a/crates/bevy_reflect/src/impls/smallvec.rs b/crates/bevy_reflect/src/impls/smallvec.rs index de6c55cd18747..afb75aff8d997 100644 --- a/crates/bevy_reflect/src/impls/smallvec.rs +++ b/crates/bevy_reflect/src/impls/smallvec.rs @@ -4,10 +4,10 @@ use core::any::Any; use smallvec::{Array as SmallArray, SmallVec}; use crate::{ - ApplyError, FromReflect, FromType, Generics, GetTypeRegistration, List, ListInfo, ListIter, - MaybeTyped, PartialReflect, Reflect, ReflectFromPtr, ReflectKind, ReflectMut, ReflectOwned, - ReflectRef, TypeInfo, TypeParamInfo, TypePath, TypeRegistration, Typed, - utility::GenericTypeInfoCell, + utility::GenericTypeInfoCell, ApplyError, FromReflect, FromType, Generics, GetTypeRegistration, + List, ListInfo, ListIter, MaybeTyped, PartialReflect, Reflect, ReflectFromPtr, ReflectKind, + ReflectMut, ReflectOwned, ReflectRef, TypeInfo, TypeParamInfo, TypePath, TypeRegistration, + Typed, }; impl List for SmallVec diff --git a/crates/bevy_reflect/src/impls/smol_str.rs b/crates/bevy_reflect/src/impls/smol_str.rs index f2b08dea9356c..e2c09b206b3be 100644 --- a/crates/bevy_reflect/src/impls/smol_str.rs +++ b/crates/bevy_reflect/src/impls/smol_str.rs @@ -1,4 +1,4 @@ -use crate::{ReflectDeserialize, ReflectSerialize, std_traits::ReflectDefault}; +use crate::{std_traits::ReflectDefault, ReflectDeserialize, ReflectSerialize}; use bevy_reflect_derive::impl_reflect_opaque; impl_reflect_opaque!(::smol_str::SmolStr( diff --git a/crates/bevy_reflect/src/impls/std.rs b/crates/bevy_reflect/src/impls/std.rs index 185badad1c2e1..447e480f14273 100644 --- a/crates/bevy_reflect/src/impls/std.rs +++ b/crates/bevy_reflect/src/impls/std.rs @@ -4,16 +4,16 @@ )] use crate::{ + impl_type_path, map_apply, map_partial_eq, map_try_apply, + prelude::ReflectDefault, + reflect::impl_full_reflect, + set_apply, set_partial_eq, set_try_apply, + utility::{reflect_hasher, GenericTypeInfoCell, GenericTypePathCell, NonGenericTypeInfoCell}, ApplyError, Array, ArrayInfo, ArrayIter, DynamicMap, DynamicSet, DynamicTypePath, FromReflect, FromType, Generics, GetTypeRegistration, List, ListInfo, ListIter, Map, MapInfo, MapIter, MaybeTyped, OpaqueInfo, PartialReflect, Reflect, ReflectDeserialize, ReflectFromPtr, ReflectFromReflect, ReflectKind, ReflectMut, ReflectOwned, ReflectRef, ReflectSerialize, Set, SetInfo, TypeInfo, TypeParamInfo, TypePath, TypeRegistration, TypeRegistry, Typed, - impl_type_path, map_apply, map_partial_eq, map_try_apply, - prelude::ReflectDefault, - reflect::impl_full_reflect, - set_apply, set_partial_eq, set_try_apply, - utility::{GenericTypeInfoCell, GenericTypePathCell, NonGenericTypeInfoCell, reflect_hasher}, }; use alloc::{ borrow::{Cow, ToOwned}, @@ -2536,14 +2536,12 @@ mod tests { let a: &dyn Reflect = &a; let b: &dyn Reflect = &b; let c: &dyn Reflect = &c; - assert!( - a.reflect_partial_eq(b.as_partial_reflect()) - .unwrap_or_default() - ); - assert!( - !a.reflect_partial_eq(c.as_partial_reflect()) - .unwrap_or_default() - ); + assert!(a + .reflect_partial_eq(b.as_partial_reflect()) + .unwrap_or_default()); + assert!(!a + .reflect_partial_eq(c.as_partial_reflect()) + .unwrap_or_default()); } #[test] @@ -2559,16 +2557,12 @@ mod tests { let mut value = Some(123usize); - assert!( - value - .reflect_partial_eq(&Some(123usize)) - .unwrap_or_default() - ); - assert!( - !value - .reflect_partial_eq(&Some(321usize)) - .unwrap_or_default() - ); + assert!(value + .reflect_partial_eq(&Some(123usize)) + .unwrap_or_default()); + assert!(!value + .reflect_partial_eq(&Some(321usize)) + .unwrap_or_default()); assert_eq!("Some", value.variant_name()); assert_eq!("core::option::Option::Some", value.variant_path()); diff --git a/crates/bevy_reflect/src/impls/uuid.rs b/crates/bevy_reflect/src/impls/uuid.rs index afdf630fcacff..56beedd41ab41 100644 --- a/crates/bevy_reflect/src/impls/uuid.rs +++ b/crates/bevy_reflect/src/impls/uuid.rs @@ -1,4 +1,4 @@ -use crate::{ReflectDeserialize, ReflectSerialize, std_traits::ReflectDefault}; +use crate::{std_traits::ReflectDefault, ReflectDeserialize, ReflectSerialize}; use bevy_reflect_derive::impl_reflect_opaque; impl_reflect_opaque!(::uuid::Uuid( diff --git a/crates/bevy_reflect/src/impls/wgpu_types.rs b/crates/bevy_reflect/src/impls/wgpu_types.rs index 164007affce3b..b4a1750ba1242 100644 --- a/crates/bevy_reflect/src/impls/wgpu_types.rs +++ b/crates/bevy_reflect/src/impls/wgpu_types.rs @@ -1,4 +1,4 @@ -use crate::{ReflectDeserialize, ReflectSerialize, impl_reflect_opaque}; +use crate::{impl_reflect_opaque, ReflectDeserialize, ReflectSerialize}; impl_reflect_opaque!(::wgpu_types::TextureFormat( Debug, diff --git a/crates/bevy_reflect/src/lib.rs b/crates/bevy_reflect/src/lib.rs index b8420b71330a8..2845c716c5d54 100644 --- a/crates/bevy_reflect/src/lib.rs +++ b/crates/bevy_reflect/src/lib.rs @@ -622,9 +622,9 @@ pub mod prelude { #[doc(hidden)] pub use crate::{ - FromReflect, GetField, GetPath, GetTupleStructField, PartialReflect, Reflect, - ReflectDeserialize, ReflectFromReflect, ReflectPath, ReflectSerialize, Struct, TupleStruct, - TypePath, reflect_trait, + reflect_trait, FromReflect, GetField, GetPath, GetTupleStructField, PartialReflect, + Reflect, ReflectDeserialize, ReflectFromReflect, ReflectPath, ReflectSerialize, Struct, + TupleStruct, TypePath, }; #[cfg(feature = "functions")] @@ -723,7 +723,7 @@ pub mod __macro_exports { reason = "We don't need the exact value of Pi here." )] mod tests { - use ::serde::{Deserialize, Serialize, de::DeserializeSeed}; + use ::serde::{de::DeserializeSeed, Deserialize, Serialize}; use alloc::{ borrow::Cow, boxed::Box, @@ -741,8 +741,8 @@ mod tests { }; use disqualified::ShortName; use ron::{ + ser::{to_string_pretty, PrettyConfig}, Deserializer, - ser::{PrettyConfig, to_string_pretty}, }; use static_assertions::{assert_impl_all, assert_not_impl_all}; @@ -1012,17 +1012,13 @@ mod tests { // Assert let expected = MyStruct { foo: 123 }; - assert!( - expected - .reflect_partial_eq(reflected.as_partial_reflect()) - .unwrap_or_default() - ); + assert!(expected + .reflect_partial_eq(reflected.as_partial_reflect()) + .unwrap_or_default()); let not_expected = MyStruct { foo: 321 }; - assert!( - !not_expected - .reflect_partial_eq(reflected.as_partial_reflect()) - .unwrap_or_default() - ); + assert!(!not_expected + .reflect_partial_eq(reflected.as_partial_reflect()) + .unwrap_or_default()); } #[test] @@ -2013,9 +2009,7 @@ mod tests { let info = ::type_info(); assert_eq!( - Some( - " Some struct.\n\n # Example\n\n ```ignore (This is only used for a unit test, no need to doc test)\n let some_struct = SomeStruct;\n ```" - ), + Some(" Some struct.\n\n # Example\n\n ```ignore (This is only used for a unit test, no need to doc test)\n let some_struct = SomeStruct;\n ```"), info.docs() ); @@ -2027,9 +2021,7 @@ mod tests { let info = ::type_info(); assert_eq!( - Some( - "The compiler automatically converts `///`-style comments into `#[doc]` attributes.\nOf course, you _could_ use the attribute directly if you wanted to.\nBoth will be reflected." - ), + Some("The compiler automatically converts `///`-style comments into `#[doc]` attributes.\nOf course, you _could_ use the attribute directly if you wanted to.\nBoth will be reflected."), info.docs() ); @@ -2463,10 +2455,7 @@ bevy_reflect::tests::Test { // Can use `TypePath` let path = as TypePath>::type_path(); - assert_eq!( - "bevy_reflect::tests::can_opt_out_type_path::Foo", - path - ); + assert_eq!("bevy_reflect::tests::can_opt_out_type_path::Foo", path); // Can register the type let mut registry = TypeRegistry::default(); @@ -3038,7 +3027,7 @@ bevy_reflect::tests::Test { #[cfg(feature = "glam")] mod glam { use super::*; - use ::glam::{Quat, Vec3, quat, vec3}; + use ::glam::{quat, vec3, Quat, Vec3}; #[test] fn quat_serialization() { diff --git a/crates/bevy_reflect/src/list.rs b/crates/bevy_reflect/src/list.rs index 6806b21e33561..e0f019c4b26dc 100644 --- a/crates/bevy_reflect/src/list.rs +++ b/crates/bevy_reflect/src/list.rs @@ -9,9 +9,9 @@ use bevy_reflect_derive::impl_type_path; use crate::generics::impl_generic_info_methods; use crate::{ - ApplyError, FromReflect, Generics, MaybeTyped, PartialReflect, Reflect, ReflectKind, - ReflectMut, ReflectOwned, ReflectRef, Type, TypeInfo, TypePath, type_info::impl_type_methods, - utility::reflect_hasher, + type_info::impl_type_methods, utility::reflect_hasher, ApplyError, FromReflect, Generics, + MaybeTyped, PartialReflect, Reflect, ReflectKind, ReflectMut, ReflectOwned, ReflectRef, Type, + TypeInfo, TypePath, }; /// A trait used to power [list-like] operations via [reflection]. diff --git a/crates/bevy_reflect/src/map.rs b/crates/bevy_reflect/src/map.rs index 784caf65156b7..1ce685b127854 100644 --- a/crates/bevy_reflect/src/map.rs +++ b/crates/bevy_reflect/src/map.rs @@ -4,9 +4,9 @@ use bevy_platform_support::collections::HashTable; use bevy_reflect_derive::impl_type_path; use crate::{ - ApplyError, Generics, MaybeTyped, PartialReflect, Reflect, ReflectKind, ReflectMut, - ReflectOwned, ReflectRef, Type, TypeInfo, TypePath, generics::impl_generic_info_methods, - type_info::impl_type_methods, + generics::impl_generic_info_methods, type_info::impl_type_methods, ApplyError, Generics, + MaybeTyped, PartialReflect, Reflect, ReflectKind, ReflectMut, ReflectOwned, ReflectRef, Type, + TypeInfo, TypePath, }; use alloc::{boxed::Box, format, vec::Vec}; diff --git a/crates/bevy_reflect/src/path/error.rs b/crates/bevy_reflect/src/path/error.rs index b149446f0383b..0e900c8315ecb 100644 --- a/crates/bevy_reflect/src/path/error.rs +++ b/crates/bevy_reflect/src/path/error.rs @@ -89,28 +89,30 @@ impl fmt::Display for AccessError<'_> { write!(f, ": ")?; match kind { - AccessErrorKind::MissingField(type_accessed) => match access { - Access::Field(field) => write!( - f, - "The {type_accessed} accessed doesn't have {} `{}` field", - if let Some("a" | "e" | "i" | "o" | "u") = field.get(0..1) { - "an" - } else { - "a" - }, - access.display_value() - ), - Access::FieldIndex(_) => write!( - f, - "The {type_accessed} accessed doesn't have field index `{}`", - access.display_value(), - ), - Access::TupleIndex(_) | Access::ListIndex(_) => write!( - f, - "The {type_accessed} accessed doesn't have index `{}`", - access.display_value() - ), - }, + AccessErrorKind::MissingField(type_accessed) => { + match access { + Access::Field(field) => write!( + f, + "The {type_accessed} accessed doesn't have {} `{}` field", + if let Some("a" | "e" | "i" | "o" | "u") = field.get(0..1) { + "an" + } else { + "a" + }, + access.display_value() + ), + Access::FieldIndex(_) => write!( + f, + "The {type_accessed} accessed doesn't have field index `{}`", + access.display_value(), + ), + Access::TupleIndex(_) | Access::ListIndex(_) => write!( + f, + "The {type_accessed} accessed doesn't have index `{}`", + access.display_value() + ) + } + } AccessErrorKind::IncompatibleTypes { expected, actual } => write!( f, "Expected {} access to access a {expected}, found a {actual} instead.", diff --git a/crates/bevy_reflect/src/reflect.rs b/crates/bevy_reflect/src/reflect.rs index c7b4a7b2fa337..0898ff3630fe9 100644 --- a/crates/bevy_reflect/src/reflect.rs +++ b/crates/bevy_reflect/src/reflect.rs @@ -1,7 +1,7 @@ use crate::{ - DynamicTypePath, DynamicTyped, OpaqueInfo, ReflectKind, ReflectKindMismatchError, ReflectMut, - ReflectOwned, ReflectRef, TypeInfo, TypePath, Typed, array_debug, enum_debug, list_debug, - map_debug, set_debug, struct_debug, tuple_debug, tuple_struct_debug, + array_debug, enum_debug, list_debug, map_debug, set_debug, struct_debug, tuple_debug, + tuple_struct_debug, DynamicTypePath, DynamicTyped, OpaqueInfo, ReflectKind, + ReflectKindMismatchError, ReflectMut, ReflectOwned, ReflectRef, TypeInfo, TypePath, Typed, }; use alloc::boxed::Box; use core::{ diff --git a/crates/bevy_reflect/src/serde/de/arrays.rs b/crates/bevy_reflect/src/serde/de/arrays.rs index 2e386df629271..f1e0d60dd6154 100644 --- a/crates/bevy_reflect/src/serde/de/arrays.rs +++ b/crates/bevy_reflect/src/serde/de/arrays.rs @@ -1,6 +1,6 @@ use crate::{ + serde::{de::registration_utils::try_get_registration, TypedReflectDeserializer}, ArrayInfo, DynamicArray, TypeRegistry, - serde::{TypedReflectDeserializer, de::registration_utils::try_get_registration}, }; use alloc::{string::ToString, vec::Vec}; use core::{fmt, fmt::Formatter}; diff --git a/crates/bevy_reflect/src/serde/de/deserializer.rs b/crates/bevy_reflect/src/serde/de/deserializer.rs index b48f976190a40..1c20eaad07abc 100644 --- a/crates/bevy_reflect/src/serde/de/deserializer.rs +++ b/crates/bevy_reflect/src/serde/de/deserializer.rs @@ -2,15 +2,15 @@ use crate::serde::de::error_utils::TYPE_INFO_STACK; use crate::serde::{ReflectDeserializeWithRegistry, SerializationData}; use crate::{ - PartialReflect, ReflectDeserialize, TypeInfo, TypePath, TypeRegistration, TypeRegistry, serde::{ - TypeRegistrationDeserializer, de::{ arrays::ArrayVisitor, enums::EnumVisitor, error_utils::make_custom_error, lists::ListVisitor, maps::MapVisitor, options::OptionVisitor, sets::SetVisitor, structs::StructVisitor, tuple_structs::TupleStructVisitor, tuples::TupleVisitor, }, + TypeRegistrationDeserializer, }, + PartialReflect, ReflectDeserialize, TypeInfo, TypePath, TypeRegistration, TypeRegistry, }; use alloc::boxed::Box; use core::{fmt, fmt::Formatter}; diff --git a/crates/bevy_reflect/src/serde/de/enums.rs b/crates/bevy_reflect/src/serde/de/enums.rs index 72ee3b0271e5c..21cbf46f9ecb1 100644 --- a/crates/bevy_reflect/src/serde/de/enums.rs +++ b/crates/bevy_reflect/src/serde/de/enums.rs @@ -1,16 +1,16 @@ use crate::{ - DynamicEnum, DynamicStruct, DynamicTuple, DynamicVariant, EnumInfo, StructVariantInfo, - TupleVariantInfo, TypeRegistration, TypeRegistry, VariantInfo, serde::{ - TypedReflectDeserializer, de::{ error_utils::make_custom_error, helpers::ExpectedValues, registration_utils::try_get_registration, struct_utils::{visit_struct, visit_struct_seq}, - tuple_utils::{TupleLikeInfo, visit_tuple}, + tuple_utils::{visit_tuple, TupleLikeInfo}, }, + TypedReflectDeserializer, }, + DynamicEnum, DynamicStruct, DynamicTuple, DynamicVariant, EnumInfo, StructVariantInfo, + TupleVariantInfo, TypeRegistration, TypeRegistry, VariantInfo, }; use core::{fmt, fmt::Formatter}; use serde::de::{DeserializeSeed, EnumAccess, Error, MapAccess, SeqAccess, VariantAccess, Visitor}; diff --git a/crates/bevy_reflect/src/serde/de/helpers.rs b/crates/bevy_reflect/src/serde/de/helpers.rs index 3f8e9c7097a07..c48f8f83527a6 100644 --- a/crates/bevy_reflect/src/serde/de/helpers.rs +++ b/crates/bevy_reflect/src/serde/de/helpers.rs @@ -7,8 +7,8 @@ use core::{ fmt::{Debug, Display, Formatter}, }; use serde::{ - Deserialize, de::{Error, Visitor}, + Deserialize, }; /// A debug struct used for error messages that displays a list of expected values. diff --git a/crates/bevy_reflect/src/serde/de/lists.rs b/crates/bevy_reflect/src/serde/de/lists.rs index 1b8a5decb68bb..b85e46874a335 100644 --- a/crates/bevy_reflect/src/serde/de/lists.rs +++ b/crates/bevy_reflect/src/serde/de/lists.rs @@ -1,6 +1,6 @@ use crate::{ + serde::{de::registration_utils::try_get_registration, TypedReflectDeserializer}, DynamicList, ListInfo, TypeRegistry, - serde::{TypedReflectDeserializer, de::registration_utils::try_get_registration}, }; use core::{fmt, fmt::Formatter}; use serde::de::{SeqAccess, Visitor}; diff --git a/crates/bevy_reflect/src/serde/de/maps.rs b/crates/bevy_reflect/src/serde/de/maps.rs index b6c8664b82244..95b1c1f83e25b 100644 --- a/crates/bevy_reflect/src/serde/de/maps.rs +++ b/crates/bevy_reflect/src/serde/de/maps.rs @@ -1,6 +1,6 @@ use crate::{ + serde::{de::registration_utils::try_get_registration, TypedReflectDeserializer}, DynamicMap, Map, MapInfo, TypeRegistry, - serde::{TypedReflectDeserializer, de::registration_utils::try_get_registration}, }; use core::{fmt, fmt::Formatter}; use serde::de::{MapAccess, Visitor}; diff --git a/crates/bevy_reflect/src/serde/de/mod.rs b/crates/bevy_reflect/src/serde/de/mod.rs index 5dec21e5b503e..c6907b56ecbe3 100644 --- a/crates/bevy_reflect/src/serde/de/mod.rs +++ b/crates/bevy_reflect/src/serde/de/mod.rs @@ -32,18 +32,18 @@ mod tests { }; use bincode::Options; use core::{any::TypeId, f32::consts::PI, ops::RangeInclusive}; - use serde::{Deserialize, de::DeserializeSeed}; - use serde::{Deserializer, de::IgnoredAny}; + use serde::{de::DeserializeSeed, Deserialize}; + use serde::{de::IgnoredAny, Deserializer}; use bevy_platform_support::collections::{HashMap, HashSet}; use crate::{ - DynamicEnum, FromReflect, PartialReflect, Reflect, ReflectDeserialize, TypeRegistration, - TypeRegistry, serde::{ ReflectDeserializer, ReflectDeserializerProcessor, ReflectSerializer, TypedReflectDeserializer, }, + DynamicEnum, FromReflect, PartialReflect, Reflect, ReflectDeserialize, TypeRegistration, + TypeRegistry, }; #[derive(Reflect, Debug, PartialEq)] @@ -406,11 +406,9 @@ mod tests { let output = reflect_deserializer.deserialize(&mut deserializer).unwrap(); let expected = DynamicEnum::from(MyEnum::Tuple(1.23, 3.21)); - assert!( - expected - .reflect_partial_eq(output.as_partial_reflect()) - .unwrap() - ); + assert!(expected + .reflect_partial_eq(output.as_partial_reflect()) + .unwrap()); // === Struct Variant === // let input = r#"{ @@ -425,11 +423,9 @@ mod tests { let expected = DynamicEnum::from(MyEnum::Struct { value: String::from("I <3 Enums"), }); - assert!( - expected - .reflect_partial_eq(output.as_partial_reflect()) - .unwrap() - ); + assert!(expected + .reflect_partial_eq(output.as_partial_reflect()) + .unwrap()); } // Regression test for https://github.com/bevyengine/bevy/issues/12462 diff --git a/crates/bevy_reflect/src/serde/de/options.rs b/crates/bevy_reflect/src/serde/de/options.rs index e65175b006c1e..f347c4a67d8e3 100644 --- a/crates/bevy_reflect/src/serde/de/options.rs +++ b/crates/bevy_reflect/src/serde/de/options.rs @@ -1,9 +1,9 @@ use crate::{ - DynamicEnum, DynamicTuple, EnumInfo, TypeRegistry, VariantInfo, serde::{ - TypedReflectDeserializer, de::{error_utils::make_custom_error, registration_utils::try_get_registration}, + TypedReflectDeserializer, }, + DynamicEnum, DynamicTuple, EnumInfo, TypeRegistry, VariantInfo, }; use core::{fmt, fmt::Formatter}; use serde::de::{DeserializeSeed, Error, Visitor}; diff --git a/crates/bevy_reflect/src/serde/de/registration_utils.rs b/crates/bevy_reflect/src/serde/de/registration_utils.rs index 0004535eda807..0559af70afe55 100644 --- a/crates/bevy_reflect/src/serde/de/registration_utils.rs +++ b/crates/bevy_reflect/src/serde/de/registration_utils.rs @@ -1,4 +1,4 @@ -use crate::{Type, TypeRegistration, TypeRegistry, serde::de::error_utils::make_custom_error}; +use crate::{serde::de::error_utils::make_custom_error, Type, TypeRegistration, TypeRegistry}; use serde::de::Error; /// Attempts to find the [`TypeRegistration`] for a given [type]. diff --git a/crates/bevy_reflect/src/serde/de/registrations.rs b/crates/bevy_reflect/src/serde/de/registrations.rs index e44d754322713..adc0025c5489a 100644 --- a/crates/bevy_reflect/src/serde/de/registrations.rs +++ b/crates/bevy_reflect/src/serde/de/registrations.rs @@ -1,4 +1,4 @@ -use crate::{TypeRegistration, TypeRegistry, serde::de::error_utils::make_custom_error}; +use crate::{serde::de::error_utils::make_custom_error, TypeRegistration, TypeRegistry}; use core::{fmt, fmt::Formatter}; use serde::de::{DeserializeSeed, Error, Visitor}; diff --git a/crates/bevy_reflect/src/serde/de/sets.rs b/crates/bevy_reflect/src/serde/de/sets.rs index 0a1d2f7c092a1..ed1a469df3d7d 100644 --- a/crates/bevy_reflect/src/serde/de/sets.rs +++ b/crates/bevy_reflect/src/serde/de/sets.rs @@ -1,6 +1,6 @@ use crate::{ + serde::{de::registration_utils::try_get_registration, TypedReflectDeserializer}, DynamicSet, Set, SetInfo, TypeRegistry, - serde::{TypedReflectDeserializer, de::registration_utils::try_get_registration}, }; use core::{fmt, fmt::Formatter}; use serde::de::{SeqAccess, Visitor}; diff --git a/crates/bevy_reflect/src/serde/de/struct_utils.rs b/crates/bevy_reflect/src/serde/de/struct_utils.rs index 3fc38f2897768..9ac56d9a4a88b 100644 --- a/crates/bevy_reflect/src/serde/de/struct_utils.rs +++ b/crates/bevy_reflect/src/serde/de/struct_utils.rs @@ -1,13 +1,13 @@ use crate::{ - DynamicStruct, NamedField, StructInfo, StructVariantInfo, TypeRegistration, TypeRegistry, serde::{ - SerializationData, TypedReflectDeserializer, de::{ error_utils::make_custom_error, helpers::{ExpectedValues, Ident}, registration_utils::try_get_registration, }, + SerializationData, TypedReflectDeserializer, }, + DynamicStruct, NamedField, StructInfo, StructVariantInfo, TypeRegistration, TypeRegistry, }; use alloc::string::ToString; use core::slice::Iter; diff --git a/crates/bevy_reflect/src/serde/de/structs.rs b/crates/bevy_reflect/src/serde/de/structs.rs index 0f0d8489d877d..0135e96358580 100644 --- a/crates/bevy_reflect/src/serde/de/structs.rs +++ b/crates/bevy_reflect/src/serde/de/structs.rs @@ -1,6 +1,6 @@ use crate::{ - DynamicStruct, StructInfo, TypeRegistration, TypeRegistry, serde::de::struct_utils::{visit_struct, visit_struct_seq}, + DynamicStruct, StructInfo, TypeRegistration, TypeRegistry, }; use core::{fmt, fmt::Formatter}; use serde::de::{MapAccess, SeqAccess, Visitor}; diff --git a/crates/bevy_reflect/src/serde/de/tuple_structs.rs b/crates/bevy_reflect/src/serde/de/tuple_structs.rs index e51fb769d32ff..af33b8d0b3c33 100644 --- a/crates/bevy_reflect/src/serde/de/tuple_structs.rs +++ b/crates/bevy_reflect/src/serde/de/tuple_structs.rs @@ -1,11 +1,11 @@ use crate::{ + serde::{de::tuple_utils::visit_tuple, SerializationData}, DynamicTupleStruct, TupleStructInfo, TypeRegistration, TypeRegistry, - serde::{SerializationData, de::tuple_utils::visit_tuple}, }; use core::{fmt, fmt::Formatter}; use serde::de::{DeserializeSeed, SeqAccess, Visitor}; -use super::{TypedReflectDeserializer, registration_utils::try_get_registration}; +use super::{registration_utils::try_get_registration, TypedReflectDeserializer}; use super::ReflectDeserializerProcessor; diff --git a/crates/bevy_reflect/src/serde/de/tuple_utils.rs b/crates/bevy_reflect/src/serde/de/tuple_utils.rs index 1eeb1f1e87aac..13a65b4dd64ec 100644 --- a/crates/bevy_reflect/src/serde/de/tuple_utils.rs +++ b/crates/bevy_reflect/src/serde/de/tuple_utils.rs @@ -1,10 +1,10 @@ use crate::{ - DynamicTuple, TupleInfo, TupleStructInfo, TupleVariantInfo, TypeRegistration, TypeRegistry, - UnnamedField, serde::{ - SerializationData, TypedReflectDeserializer, de::{error_utils::make_custom_error, registration_utils::try_get_registration}, + SerializationData, TypedReflectDeserializer, }, + DynamicTuple, TupleInfo, TupleStructInfo, TupleVariantInfo, TypeRegistration, TypeRegistry, + UnnamedField, }; use alloc::string::ToString; use serde::de::{Error, SeqAccess}; diff --git a/crates/bevy_reflect/src/serde/de/tuples.rs b/crates/bevy_reflect/src/serde/de/tuples.rs index 2bb3190d23e0c..87b9fc81c9439 100644 --- a/crates/bevy_reflect/src/serde/de/tuples.rs +++ b/crates/bevy_reflect/src/serde/de/tuples.rs @@ -1,5 +1,5 @@ use crate::{ - DynamicTuple, TupleInfo, TypeRegistration, TypeRegistry, serde::de::tuple_utils::visit_tuple, + serde::de::tuple_utils::visit_tuple, DynamicTuple, TupleInfo, TypeRegistration, TypeRegistry, }; use core::{fmt, fmt::Formatter}; use serde::de::{SeqAccess, Visitor}; diff --git a/crates/bevy_reflect/src/serde/mod.rs b/crates/bevy_reflect/src/serde/mod.rs index 6b3fdeaaa23b1..c31d97456679f 100644 --- a/crates/bevy_reflect/src/serde/mod.rs +++ b/crates/bevy_reflect/src/serde/mod.rs @@ -10,8 +10,8 @@ pub use type_data::*; mod tests { use super::*; use crate::{ - DynamicStruct, DynamicTupleStruct, FromReflect, PartialReflect, Reflect, Struct, - type_registry::TypeRegistry, + type_registry::TypeRegistry, DynamicStruct, DynamicTupleStruct, FromReflect, + PartialReflect, Reflect, Struct, }; use serde::de::DeserializeSeed; @@ -178,11 +178,9 @@ mod tests { let expected = value.clone_value(); let result = reflect_deserializer.deserialize(&mut deserializer).unwrap(); - assert!( - expected - .reflect_partial_eq(result.as_partial_reflect()) - .unwrap() - ); + assert!(expected + .reflect_partial_eq(result.as_partial_reflect()) + .unwrap()); } mod type_data { diff --git a/crates/bevy_reflect/src/serde/ser/arrays.rs b/crates/bevy_reflect/src/serde/ser/arrays.rs index 563d0b4027deb..9d565344aeb44 100644 --- a/crates/bevy_reflect/src/serde/ser/arrays.rs +++ b/crates/bevy_reflect/src/serde/ser/arrays.rs @@ -1,5 +1,5 @@ -use crate::{Array, TypeRegistry, serde::TypedReflectSerializer}; -use serde::{Serialize, ser::SerializeTuple}; +use crate::{serde::TypedReflectSerializer, Array, TypeRegistry}; +use serde::{ser::SerializeTuple, Serialize}; use super::ReflectSerializerProcessor; diff --git a/crates/bevy_reflect/src/serde/ser/custom_serialization.rs b/crates/bevy_reflect/src/serde/ser/custom_serialization.rs index 0d7794d376a3f..18d2abed9c010 100644 --- a/crates/bevy_reflect/src/serde/ser/custom_serialization.rs +++ b/crates/bevy_reflect/src/serde/ser/custom_serialization.rs @@ -1,7 +1,7 @@ -use crate::serde::ReflectSerializeWithRegistry; +use crate::serde::ser::error_utils::make_custom_error; #[cfg(feature = "debug_stack")] use crate::serde::ser::error_utils::TYPE_INFO_STACK; -use crate::serde::ser::error_utils::make_custom_error; +use crate::serde::ReflectSerializeWithRegistry; use crate::{PartialReflect, ReflectSerialize, TypeRegistry}; use core::borrow::Borrow; use serde::{Serialize, Serializer}; @@ -54,12 +54,9 @@ pub(super) fn try_custom_serialize( Ok(reflect_serialize_with_registry.serialize(value, serializer, type_registry)) } else { - Err(( - serializer, - make_custom_error(format_args!( - "type `{}` did not register the `ReflectSerialize` or `ReflectSerializeWithRegistry` type data. For certain types, this may need to be registered manually using `register_type_data`", - info.type_path(), - )), - )) + Err((serializer, make_custom_error(format_args!( + "type `{}` did not register the `ReflectSerialize` or `ReflectSerializeWithRegistry` type data. For certain types, this may need to be registered manually using `register_type_data`", + info.type_path(), + )))) } } diff --git a/crates/bevy_reflect/src/serde/ser/enums.rs b/crates/bevy_reflect/src/serde/ser/enums.rs index 29d1c7466456f..86c4360ce037b 100644 --- a/crates/bevy_reflect/src/serde/ser/enums.rs +++ b/crates/bevy_reflect/src/serde/ser/enums.rs @@ -1,10 +1,10 @@ use crate::{ + serde::{ser::error_utils::make_custom_error, TypedReflectSerializer}, Enum, TypeInfo, TypeRegistry, VariantInfo, VariantType, - serde::{TypedReflectSerializer, ser::error_utils::make_custom_error}, }; use serde::{ - Serialize, ser::{SerializeStructVariant, SerializeTupleVariant}, + Serialize, }; use super::ReflectSerializerProcessor; diff --git a/crates/bevy_reflect/src/serde/ser/lists.rs b/crates/bevy_reflect/src/serde/ser/lists.rs index 42d8e87122e87..4c3fb6b33dd25 100644 --- a/crates/bevy_reflect/src/serde/ser/lists.rs +++ b/crates/bevy_reflect/src/serde/ser/lists.rs @@ -1,5 +1,5 @@ -use crate::{List, TypeRegistry, serde::TypedReflectSerializer}; -use serde::{Serialize, ser::SerializeSeq}; +use crate::{serde::TypedReflectSerializer, List, TypeRegistry}; +use serde::{ser::SerializeSeq, Serialize}; use super::ReflectSerializerProcessor; diff --git a/crates/bevy_reflect/src/serde/ser/maps.rs b/crates/bevy_reflect/src/serde/ser/maps.rs index 8ba1dd8cfedca..c1a8c287c1b3f 100644 --- a/crates/bevy_reflect/src/serde/ser/maps.rs +++ b/crates/bevy_reflect/src/serde/ser/maps.rs @@ -1,5 +1,5 @@ -use crate::{Map, TypeRegistry, serde::TypedReflectSerializer}; -use serde::{Serialize, ser::SerializeMap}; +use crate::{serde::TypedReflectSerializer, Map, TypeRegistry}; +use serde::{ser::SerializeMap, Serialize}; use super::ReflectSerializerProcessor; diff --git a/crates/bevy_reflect/src/serde/ser/mod.rs b/crates/bevy_reflect/src/serde/ser/mod.rs index 8f402ea2874c9..6cfebc747f285 100644 --- a/crates/bevy_reflect/src/serde/ser/mod.rs +++ b/crates/bevy_reflect/src/serde/ser/mod.rs @@ -21,8 +21,8 @@ mod tuples; #[cfg(test)] mod tests { use crate::{ - PartialReflect, Reflect, ReflectSerialize, Struct, TypeRegistry, serde::{ReflectSerializer, ReflectSerializerProcessor}, + PartialReflect, Reflect, ReflectSerialize, Struct, TypeRegistry, }; use alloc::{ boxed::Box, diff --git a/crates/bevy_reflect/src/serde/ser/serializer.rs b/crates/bevy_reflect/src/serde/ser/serializer.rs index f174660d89ade..afe6b56b1dfaf 100644 --- a/crates/bevy_reflect/src/serde/ser/serializer.rs +++ b/crates/bevy_reflect/src/serde/ser/serializer.rs @@ -1,15 +1,15 @@ #[cfg(feature = "debug_stack")] use crate::serde::ser::error_utils::TYPE_INFO_STACK; use crate::{ - PartialReflect, ReflectRef, TypeRegistry, serde::ser::{ arrays::ArraySerializer, custom_serialization::try_custom_serialize, enums::EnumSerializer, error_utils::make_custom_error, lists::ListSerializer, maps::MapSerializer, sets::SetSerializer, structs::StructSerializer, tuple_structs::TupleStructSerializer, tuples::TupleSerializer, }, + PartialReflect, ReflectRef, TypeRegistry, }; -use serde::{Serialize, Serializer, ser::SerializeMap}; +use serde::{ser::SerializeMap, Serialize, Serializer}; use super::ReflectSerializerProcessor; diff --git a/crates/bevy_reflect/src/serde/ser/sets.rs b/crates/bevy_reflect/src/serde/ser/sets.rs index 45f2949fe8491..34e8899d58c95 100644 --- a/crates/bevy_reflect/src/serde/ser/sets.rs +++ b/crates/bevy_reflect/src/serde/ser/sets.rs @@ -1,5 +1,5 @@ -use crate::{Set, TypeRegistry, serde::TypedReflectSerializer}; -use serde::{Serialize, ser::SerializeSeq}; +use crate::{serde::TypedReflectSerializer, Set, TypeRegistry}; +use serde::{ser::SerializeSeq, Serialize}; use super::ReflectSerializerProcessor; diff --git a/crates/bevy_reflect/src/serde/ser/structs.rs b/crates/bevy_reflect/src/serde/ser/structs.rs index 5d40f80095d2e..828eb3e6cb829 100644 --- a/crates/bevy_reflect/src/serde/ser/structs.rs +++ b/crates/bevy_reflect/src/serde/ser/structs.rs @@ -1,8 +1,8 @@ use crate::{ + serde::{ser::error_utils::make_custom_error, SerializationData, TypedReflectSerializer}, Struct, TypeInfo, TypeRegistry, - serde::{SerializationData, TypedReflectSerializer, ser::error_utils::make_custom_error}, }; -use serde::{Serialize, ser::SerializeStruct}; +use serde::{ser::SerializeStruct, Serialize}; use super::ReflectSerializerProcessor; diff --git a/crates/bevy_reflect/src/serde/ser/tuple_structs.rs b/crates/bevy_reflect/src/serde/ser/tuple_structs.rs index 73d6070f87692..00554c0a86694 100644 --- a/crates/bevy_reflect/src/serde/ser/tuple_structs.rs +++ b/crates/bevy_reflect/src/serde/ser/tuple_structs.rs @@ -1,8 +1,8 @@ use crate::{ + serde::{ser::error_utils::make_custom_error, SerializationData, TypedReflectSerializer}, TupleStruct, TypeInfo, TypeRegistry, - serde::{SerializationData, TypedReflectSerializer, ser::error_utils::make_custom_error}, }; -use serde::{Serialize, ser::SerializeTupleStruct}; +use serde::{ser::SerializeTupleStruct, Serialize}; use super::ReflectSerializerProcessor; diff --git a/crates/bevy_reflect/src/serde/ser/tuples.rs b/crates/bevy_reflect/src/serde/ser/tuples.rs index 5e1b02109af68..195d1e492d76b 100644 --- a/crates/bevy_reflect/src/serde/ser/tuples.rs +++ b/crates/bevy_reflect/src/serde/ser/tuples.rs @@ -1,5 +1,5 @@ -use crate::{Tuple, TypeRegistry, serde::TypedReflectSerializer}; -use serde::{Serialize, ser::SerializeTuple}; +use crate::{serde::TypedReflectSerializer, Tuple, TypeRegistry}; +use serde::{ser::SerializeTuple, Serialize}; use super::ReflectSerializerProcessor; diff --git a/crates/bevy_reflect/src/serde/type_data.rs b/crates/bevy_reflect/src/serde/type_data.rs index cc3c5ad881546..8df80c700f100 100644 --- a/crates/bevy_reflect/src/serde/type_data.rs +++ b/crates/bevy_reflect/src/serde/type_data.rs @@ -1,6 +1,6 @@ use crate::Reflect; use alloc::boxed::Box; -use bevy_platform_support::collections::{HashMap, hash_map::Iter}; +use bevy_platform_support::collections::{hash_map::Iter, HashMap}; /// Contains data relevant to the automatic reflect powered (de)serialization of a type. #[derive(Debug, Clone)] diff --git a/crates/bevy_reflect/src/set.rs b/crates/bevy_reflect/src/set.rs index 98db4a775d43e..799499a8adcd7 100644 --- a/crates/bevy_reflect/src/set.rs +++ b/crates/bevy_reflect/src/set.rs @@ -2,14 +2,14 @@ use alloc::{boxed::Box, format, vec::Vec}; use core::fmt::{Debug, Formatter}; use bevy_platform_support::collections::{ - HashTable, hash_table::OccupiedEntry as HashTableOccupiedEntry, + hash_table::OccupiedEntry as HashTableOccupiedEntry, HashTable, }; use bevy_reflect_derive::impl_type_path; use crate::{ - ApplyError, Generics, PartialReflect, Reflect, ReflectKind, ReflectMut, ReflectOwned, - ReflectRef, Type, TypeInfo, TypePath, generics::impl_generic_info_methods, hash_error, - type_info::impl_type_methods, + generics::impl_generic_info_methods, hash_error, type_info::impl_type_methods, ApplyError, + Generics, PartialReflect, Reflect, ReflectKind, ReflectMut, ReflectOwned, ReflectRef, Type, + TypeInfo, TypePath, }; /// A trait used to power [set-like] operations via [reflection]. diff --git a/crates/bevy_reflect/src/struct_trait.rs b/crates/bevy_reflect/src/struct_trait.rs index 71ab1be571862..dc7ed55cefef3 100644 --- a/crates/bevy_reflect/src/struct_trait.rs +++ b/crates/bevy_reflect/src/struct_trait.rs @@ -1,9 +1,9 @@ use crate::generics::impl_generic_info_methods; use crate::{ + attributes::{impl_custom_attribute_methods, CustomAttributes}, + type_info::impl_type_methods, ApplyError, Generics, NamedField, PartialReflect, Reflect, ReflectKind, ReflectMut, ReflectOwned, ReflectRef, Type, TypeInfo, TypePath, - attributes::{CustomAttributes, impl_custom_attribute_methods}, - type_info::impl_type_methods, }; use alloc::{borrow::Cow, boxed::Box, vec::Vec}; use bevy_platform_support::collections::HashMap; diff --git a/crates/bevy_reflect/src/tuple.rs b/crates/bevy_reflect/src/tuple.rs index ce535a43bcef3..28f95b6886cd8 100644 --- a/crates/bevy_reflect/src/tuple.rs +++ b/crates/bevy_reflect/src/tuple.rs @@ -3,9 +3,10 @@ use variadics_please::all_tuples; use crate::generics::impl_generic_info_methods; use crate::{ - ApplyError, FromReflect, Generics, GetTypeRegistration, MaybeTyped, PartialReflect, Reflect, - ReflectKind, ReflectMut, ReflectOwned, ReflectRef, Type, TypeInfo, TypePath, TypeRegistration, - TypeRegistry, Typed, UnnamedField, type_info::impl_type_methods, utility::GenericTypePathCell, + type_info::impl_type_methods, utility::GenericTypePathCell, ApplyError, FromReflect, Generics, + GetTypeRegistration, MaybeTyped, PartialReflect, Reflect, ReflectKind, ReflectMut, + ReflectOwned, ReflectRef, Type, TypeInfo, TypePath, TypeRegistration, TypeRegistry, Typed, + UnnamedField, }; use alloc::{boxed::Box, vec, vec::Vec}; use core::{ diff --git a/crates/bevy_reflect/src/tuple_struct.rs b/crates/bevy_reflect/src/tuple_struct.rs index cd58f0f38a795..8348ca7740861 100644 --- a/crates/bevy_reflect/src/tuple_struct.rs +++ b/crates/bevy_reflect/src/tuple_struct.rs @@ -2,10 +2,10 @@ use bevy_reflect_derive::impl_type_path; use crate::generics::impl_generic_info_methods; use crate::{ + attributes::{impl_custom_attribute_methods, CustomAttributes}, + type_info::impl_type_methods, ApplyError, DynamicTuple, Generics, PartialReflect, Reflect, ReflectKind, ReflectMut, ReflectOwned, ReflectRef, Tuple, Type, TypeInfo, TypePath, UnnamedField, - attributes::{CustomAttributes, impl_custom_attribute_methods}, - type_info::impl_type_methods, }; use alloc::{boxed::Box, vec::Vec}; use bevy_platform_support::sync::Arc; diff --git a/crates/bevy_reflect/src/type_registry.rs b/crates/bevy_reflect/src/type_registry.rs index e6bd3c2082947..cf80749edebbb 100644 --- a/crates/bevy_reflect/src/type_registry.rs +++ b/crates/bevy_reflect/src/type_registry.rs @@ -1,4 +1,4 @@ -use crate::{FromReflect, Reflect, TypeInfo, TypePath, Typed, serde::Serializable}; +use crate::{serde::Serializable, FromReflect, Reflect, TypeInfo, TypePath, Typed}; use alloc::{boxed::Box, string::String}; use bevy_platform_support::{ collections::{HashMap, HashSet}, @@ -11,7 +11,7 @@ use core::{ fmt::Debug, ops::{Deref, DerefMut}, }; -use downcast_rs::{Downcast, impl_downcast}; +use downcast_rs::{impl_downcast, Downcast}; use serde::Deserialize; /// A registry of [reflected] types. diff --git a/crates/bevy_remote/src/builtin_methods.rs b/crates/bevy_remote/src/builtin_methods.rs index 44366af25e9ff..80dc592d9a525 100644 --- a/crates/bevy_remote/src/builtin_methods.rs +++ b/crates/bevy_remote/src/builtin_methods.rs @@ -2,7 +2,7 @@ use core::any::TypeId; -use anyhow::{Result as AnyhowResult, anyhow}; +use anyhow::{anyhow, Result as AnyhowResult}; use bevy_ecs::{ component::ComponentId, entity::Entity, @@ -16,15 +16,15 @@ use bevy_ecs::{ }; use bevy_platform_support::collections::HashMap; use bevy_reflect::{ - GetPath as _, NamedField, OpaqueInfo, PartialReflect, ReflectDeserialize, ReflectSerialize, - TypeInfo, TypeRegistration, TypeRegistry, VariantInfo, prelude::ReflectDefault, serde::{ReflectSerializer, TypedReflectDeserializer}, + GetPath as _, NamedField, OpaqueInfo, PartialReflect, ReflectDeserialize, ReflectSerialize, + TypeInfo, TypeRegistration, TypeRegistry, VariantInfo, }; -use serde::{Deserialize, Serialize, de::DeserializeSeed as _}; -use serde_json::{Map, Value, json}; +use serde::{de::DeserializeSeed as _, Deserialize, Serialize}; +use serde_json::{json, Map, Value}; -use crate::{BrpError, BrpResult, error_codes}; +use crate::{error_codes, BrpError, BrpResult}; /// The method path for a `bevy/get` request. pub const BRP_GET_METHOD: &str = "bevy/get"; diff --git a/crates/bevy_remote/src/http.rs b/crates/bevy_remote/src/http.rs index c4aa8f945ee62..4e36e4a0bfe94 100644 --- a/crates/bevy_remote/src/http.rs +++ b/crates/bevy_remote/src/http.rs @@ -9,7 +9,7 @@ #![cfg(not(target_family = "wasm"))] use crate::{ - BrpBatch, BrpError, BrpMessage, BrpRequest, BrpResponse, BrpResult, BrpSender, error_codes, + error_codes, BrpBatch, BrpError, BrpMessage, BrpRequest, BrpResponse, BrpResult, BrpSender, }; use anyhow::Result as AnyhowResult; use async_channel::{Receiver, Sender}; @@ -17,7 +17,7 @@ use async_io::Async; use bevy_app::{App, Plugin, Startup}; use bevy_ecs::resource::Resource; use bevy_ecs::system::Res; -use bevy_tasks::{IoTaskPool, futures_lite::StreamExt}; +use bevy_tasks::{futures_lite::StreamExt, IoTaskPool}; use core::{ convert::Infallible, net::{IpAddr, Ipv4Addr}, @@ -26,11 +26,10 @@ use core::{ }; use http_body_util::{BodyExt as _, Full}; use hyper::{ - Request, Response, body::{Body, Bytes, Frame, Incoming}, header::{HeaderName, HeaderValue}, server::conn::http1, - service, + service, Request, Response, }; use serde_json::Value; use smol_hyper::rt::{FuturesIo, SmolTimer}; diff --git a/crates/bevy_remote/src/lib.rs b/crates/bevy_remote/src/lib.rs index 7959308fac40f..75ba79d58e8da 100644 --- a/crates/bevy_remote/src/lib.rs +++ b/crates/bevy_remote/src/lib.rs @@ -319,7 +319,7 @@ //! [fully-qualified type name]: bevy_reflect::TypePath::type_path use async_channel::{Receiver, Sender}; -use bevy_app::{MainScheduleOrder, prelude::*}; +use bevy_app::{prelude::*, MainScheduleOrder}; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::{ entity::Entity, diff --git a/crates/bevy_render/macros/src/as_bind_group.rs b/crates/bevy_render/macros/src/as_bind_group.rs index f470c324bbbca..47cf8b7ce8aef 100644 --- a/crates/bevy_render/macros/src/as_bind_group.rs +++ b/crates/bevy_render/macros/src/as_bind_group.rs @@ -1,12 +1,13 @@ -use bevy_macro_utils::{BevyManifest, Symbol, get_lit_bool, get_lit_str}; +use bevy_macro_utils::{get_lit_bool, get_lit_str, BevyManifest, Symbol}; use proc_macro::TokenStream; use proc_macro2::{Ident, Span}; -use quote::{ToTokens, quote}; +use quote::{quote, ToTokens}; use syn::{ - Data, DataStruct, Error, Fields, LitInt, LitStr, Meta, MetaList, Result, parenthesized, + parenthesized, parse::{Parse, ParseStream}, punctuated::Punctuated, token::Comma, + Data, DataStruct, Error, Fields, LitInt, LitStr, Meta, MetaList, Result, }; const UNIFORM_ATTRIBUTE_NAME: Symbol = Symbol("uniform"); @@ -308,17 +309,13 @@ pub fn derive_as_bind_group(ast: syn::DeriveInput) -> Result { } => { return Err(Error::new_spanned( attr, - format!( - "The '{field_name}' field cannot be assigned to binding {binding_index} because it is already occupied by the field '{occupied_ident}' of type {binding_type:?}." - ), + format!("The '{field_name}' field cannot be assigned to binding {binding_index} because it is already occupied by the field '{occupied_ident}' of type {binding_type:?}.") )); } BindingState::OccupiedConvertedUniform => { return Err(Error::new_spanned( attr, - format!( - "The '{field_name}' field cannot be assigned to binding {binding_index} because it is already occupied by a struct-level uniform binding at the same index." - ), + format!("The '{field_name}' field cannot be assigned to binding {binding_index} because it is already occupied by a struct-level uniform binding at the same index.") )); } BindingState::OccupiedMergeableUniform { uniform_fields } => match binding_type { @@ -327,12 +324,9 @@ pub fn derive_as_bind_group(ast: syn::DeriveInput) -> Result { } _ => { return Err(Error::new_spanned( - attr, - format!( - "The '{field_name}' field cannot be assigned to binding {binding_index} because it is already occupied by a {:?}.", - BindingType::Uniform - ), - )); + attr, + format!("The '{field_name}' field cannot be assigned to binding {binding_index} because it is already occupied by a {:?}.", BindingType::Uniform) + )); } }, } @@ -1189,7 +1183,7 @@ fn get_visibility_flag_value(meta_list: &MetaList) -> Result Result) -> Result { NameValue(m) => { return Err(Error::new_spanned( m.path, - "Not a valid name. Available attributes: `dimension`, `sample_type`, `multisampled`, or `filterable`.", + "Not a valid name. Available attributes: `dimension`, `sample_type`, `multisampled`, or `filterable`." )); } _ => { diff --git a/crates/bevy_render/macros/src/extract_component.rs b/crates/bevy_render/macros/src/extract_component.rs index 9033b5820f373..2bfd0e0e11133 100644 --- a/crates/bevy_render/macros/src/extract_component.rs +++ b/crates/bevy_render/macros/src/extract_component.rs @@ -1,6 +1,6 @@ use proc_macro::TokenStream; use quote::quote; -use syn::{DeriveInput, Path, parse_macro_input, parse_quote}; +use syn::{parse_macro_input, parse_quote, DeriveInput, Path}; pub fn derive_extract_component(input: TokenStream) -> TokenStream { let mut ast = parse_macro_input!(input as DeriveInput); diff --git a/crates/bevy_render/macros/src/extract_resource.rs b/crates/bevy_render/macros/src/extract_resource.rs index 45cd2447a2f1a..0a35eb4d5dd2b 100644 --- a/crates/bevy_render/macros/src/extract_resource.rs +++ b/crates/bevy_render/macros/src/extract_resource.rs @@ -1,6 +1,6 @@ use proc_macro::TokenStream; use quote::quote; -use syn::{DeriveInput, Path, parse_macro_input, parse_quote}; +use syn::{parse_macro_input, parse_quote, DeriveInput, Path}; pub fn derive_extract_resource(input: TokenStream) -> TokenStream { let mut ast = parse_macro_input!(input as DeriveInput); diff --git a/crates/bevy_render/macros/src/lib.rs b/crates/bevy_render/macros/src/lib.rs index 66a82d5c2cfd8..15b1add6b23b8 100644 --- a/crates/bevy_render/macros/src/lib.rs +++ b/crates/bevy_render/macros/src/lib.rs @@ -5,10 +5,10 @@ mod as_bind_group; mod extract_component; mod extract_resource; -use bevy_macro_utils::{BevyManifest, derive_label}; +use bevy_macro_utils::{derive_label, BevyManifest}; use proc_macro::TokenStream; use quote::format_ident; -use syn::{DeriveInput, parse_macro_input}; +use syn::{parse_macro_input, DeriveInput}; pub(crate) fn bevy_render_path() -> syn::Path { BevyManifest::shared().get_path("bevy_render") diff --git a/crates/bevy_render/src/alpha.rs b/crates/bevy_render/src/alpha.rs index cd08b1405fc4e..12e1377eabaab 100644 --- a/crates/bevy_render/src/alpha.rs +++ b/crates/bevy_render/src/alpha.rs @@ -1,4 +1,4 @@ -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; // TODO: add discussion about performance. /// Sets how a material's base color alpha channel is used for transparency. diff --git a/crates/bevy_render/src/batching/gpu_preprocessing.rs b/crates/bevy_render/src/batching/gpu_preprocessing.rs index c733170e21d20..3e29f72ba5840 100644 --- a/crates/bevy_render/src/batching/gpu_preprocessing.rs +++ b/crates/bevy_render/src/batching/gpu_preprocessing.rs @@ -14,17 +14,16 @@ use bevy_ecs::{ }; use bevy_encase_derive::ShaderType; use bevy_math::UVec4; -use bevy_platform_support::collections::{HashMap, HashSet, hash_map::Entry}; -use bevy_utils::{TypeIdMap, default}; +use bevy_platform_support::collections::{hash_map::Entry, HashMap, HashSet}; +use bevy_utils::{default, TypeIdMap}; use bytemuck::{Pod, Zeroable}; -use encase::{ShaderSize, internal::WriteInto}; +use encase::{internal::WriteInto, ShaderSize}; use indexmap::IndexMap; use nonmax::NonMaxU32; use tracing::error; use wgpu::{BindingResource, BufferUsages, DownlevelFlags, Features}; use crate::{ - Render, RenderApp, RenderDebugFlags, RenderSet, experimental::occlusion_culling::OcclusionCulling, render_phase::{ BinnedPhaseItem, BinnedRenderPhaseBatch, BinnedRenderPhaseBatchSet, @@ -37,6 +36,7 @@ use crate::{ renderer::{RenderAdapter, RenderDevice, RenderQueue}, sync_world::MainEntity, view::{ExtractedView, NoIndirectDrawing, RetainedViewEntity}, + Render, RenderApp, RenderDebugFlags, RenderSet, }; use super::{BatchMeta, GetBatchData, GetFullBatchData}; diff --git a/crates/bevy_render/src/batching/no_gpu_preprocessing.rs b/crates/bevy_render/src/batching/no_gpu_preprocessing.rs index 2af406967882c..8bbbff8dd9e46 100644 --- a/crates/bevy_render/src/batching/no_gpu_preprocessing.rs +++ b/crates/bevy_render/src/batching/no_gpu_preprocessing.rs @@ -4,7 +4,7 @@ use bevy_derive::{Deref, DerefMut}; use bevy_ecs::entity::Entity; use bevy_ecs::resource::Resource; use bevy_ecs::system::{Res, ResMut, StaticSystemParam}; -use smallvec::{SmallVec, smallvec}; +use smallvec::{smallvec, SmallVec}; use tracing::error; use wgpu::BindingResource; diff --git a/crates/bevy_render/src/camera/camera.rs b/crates/bevy_render/src/camera/camera.rs index 67f34b3a6d411..298be27c5fa9e 100644 --- a/crates/bevy_render/src/camera/camera.rs +++ b/crates/bevy_render/src/camera/camera.rs @@ -4,7 +4,6 @@ )] use super::{ClearColorConfig, Projection}; use crate::{ - Extract, batching::gpu_preprocessing::{GpuPreprocessingMode, GpuPreprocessingSupport}, camera::{CameraProjection, ManualTextureViewHandle, ManualTextureViews}, primitives::Frustum, @@ -17,6 +16,7 @@ use crate::{ ColorGrading, ExtractedView, ExtractedWindows, Msaa, NoIndirectDrawing, RenderLayers, RenderVisibleEntities, RetainedViewEntity, ViewUniformOffset, Visibility, VisibleEntities, }, + Extract, }; use bevy_asset::{AssetEvent, AssetId, Assets, Handle}; use bevy_derive::{Deref, DerefMut}; @@ -25,7 +25,7 @@ use bevy_ecs::{ component::{Component, HookContext}, entity::{Entity, EntityBorrow}, event::EventReader, - prelude::{With, require}, + prelude::{require, With}, query::Has, reflect::ReflectComponent, resource::Resource, @@ -33,7 +33,7 @@ use bevy_ecs::{ world::DeferredWorld, }; use bevy_image::Image; -use bevy_math::{Dir3, FloatOrd, Mat4, Ray3d, Rect, URect, UVec2, UVec4, Vec2, Vec3, ops, vec2}; +use bevy_math::{ops, vec2, Dir3, FloatOrd, Mat4, Ray3d, Rect, URect, UVec2, UVec4, Vec2, Vec3}; use bevy_platform_support::collections::{HashMap, HashSet}; use bevy_reflect::prelude::*; use bevy_render_macros::ExtractComponent; @@ -334,12 +334,7 @@ pub struct Camera { fn warn_on_no_render_graph(world: DeferredWorld, HookContext { entity, caller, .. }: HookContext) { if !world.entity(entity).contains::() { - warn!( - "{}Entity {entity} has a `Camera` component, but it doesn't have a render graph configured. Consider adding a `Camera2d` or `Camera3d` component, or manually adding a `CameraRenderGraph` component if you need a custom render graph.", - caller - .map(|location| format!("{location}: ")) - .unwrap_or_default() - ); + warn!("{}Entity {entity} has a `Camera` component, but it doesn't have a render graph configured. Consider adding a `Camera2d` or `Camera3d` component, or manually adding a `CameraRenderGraph` component if you need a custom render graph.", caller.map(|location|format!("{location}: ")).unwrap_or_default()); } } diff --git a/crates/bevy_render/src/camera/mod.rs b/crates/bevy_render/src/camera/mod.rs index db91f2a4f33c2..9b3c6907f60fc 100644 --- a/crates/bevy_render/src/camera/mod.rs +++ b/crates/bevy_render/src/camera/mod.rs @@ -11,8 +11,8 @@ pub use manual_texture_view::*; pub use projection::*; use crate::{ - ExtractSchedule, Render, RenderApp, RenderSet, extract_component::ExtractComponentPlugin, - extract_resource::ExtractResourcePlugin, render_graph::RenderGraph, + extract_component::ExtractComponentPlugin, extract_resource::ExtractResourcePlugin, + render_graph::RenderGraph, ExtractSchedule, Render, RenderApp, RenderSet, }; use bevy_app::{App, Plugin}; use bevy_ecs::schedule::IntoSystemConfigs; diff --git a/crates/bevy_render/src/camera/projection.rs b/crates/bevy_render/src/camera/projection.rs index 543bad15e4441..2b75dab047247 100644 --- a/crates/bevy_render/src/camera/projection.rs +++ b/crates/bevy_render/src/camera/projection.rs @@ -5,9 +5,9 @@ use bevy_app::{App, Plugin, PostStartup, PostUpdate}; use bevy_asset::AssetEvents; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::prelude::*; -use bevy_math::{AspectRatio, Mat4, Rect, Vec2, Vec3A, Vec4, ops}; -use bevy_reflect::{Reflect, ReflectDeserialize, ReflectSerialize, std_traits::ReflectDefault}; -use bevy_transform::{TransformSystem, components::GlobalTransform}; +use bevy_math::{ops, AspectRatio, Mat4, Rect, Vec2, Vec3A, Vec4}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect, ReflectDeserialize, ReflectSerialize}; +use bevy_transform::{components::GlobalTransform, TransformSystem}; use derive_more::derive::From; use serde::{Deserialize, Serialize}; diff --git a/crates/bevy_render/src/diagnostic/mod.rs b/crates/bevy_render/src/diagnostic/mod.rs index 353d32b15a43a..09b6052c10ebe 100644 --- a/crates/bevy_render/src/diagnostic/mod.rs +++ b/crates/bevy_render/src/diagnostic/mod.rs @@ -12,7 +12,7 @@ use bevy_app::{App, Plugin, PreUpdate}; use crate::RenderApp; use self::internal::{ - DiagnosticsRecorder, Pass, RenderDiagnosticsMutex, WriteTimestamp, sync_diagnostics, + sync_diagnostics, DiagnosticsRecorder, Pass, RenderDiagnosticsMutex, WriteTimestamp, }; use super::{RenderDevice, RenderQueue}; diff --git a/crates/bevy_render/src/experimental/occlusion_culling/mod.rs b/crates/bevy_render/src/experimental/occlusion_culling/mod.rs index 1bdbbf0ecd7a5..6bdfb4a102bf7 100644 --- a/crates/bevy_render/src/experimental/occlusion_culling/mod.rs +++ b/crates/bevy_render/src/experimental/occlusion_culling/mod.rs @@ -4,9 +4,9 @@ //! Bevy. use bevy_app::{App, Plugin}; -use bevy_asset::{Handle, load_internal_asset, weak_handle}; +use bevy_asset::{load_internal_asset, weak_handle, Handle}; use bevy_ecs::{component::Component, entity::Entity, prelude::ReflectComponent}; -use bevy_reflect::{Reflect, prelude::ReflectDefault}; +use bevy_reflect::{prelude::ReflectDefault, Reflect}; use crate::{ extract_component::ExtractComponent, diff --git a/crates/bevy_render/src/extract_component.rs b/crates/bevy_render/src/extract_component.rs index 75d9a4a24dd03..f77199842828c 100644 --- a/crates/bevy_render/src/extract_component.rs +++ b/crates/bevy_render/src/extract_component.rs @@ -1,10 +1,10 @@ use crate::{ - Extract, ExtractSchedule, Render, RenderApp, RenderSet, - render_resource::{DynamicUniformBuffer, ShaderType, encase::internal::WriteInto}, + render_resource::{encase::internal::WriteInto, DynamicUniformBuffer, ShaderType}, renderer::{RenderDevice, RenderQueue}, sync_component::SyncComponentPlugin, sync_world::RenderEntity, view::ViewVisibility, + Extract, ExtractSchedule, Render, RenderApp, RenderSet, }; use bevy_app::{App, Plugin}; use bevy_ecs::{ diff --git a/crates/bevy_render/src/extract_instances.rs b/crates/bevy_render/src/extract_instances.rs index fedcd3b3ed8a5..a8e5a9ecbdf92 100644 --- a/crates/bevy_render/src/extract_instances.rs +++ b/crates/bevy_render/src/extract_instances.rs @@ -16,7 +16,7 @@ use bevy_ecs::{ }; use crate::sync_world::MainEntityHashMap; -use crate::{Extract, ExtractSchedule, RenderApp, prelude::ViewVisibility}; +use crate::{prelude::ViewVisibility, Extract, ExtractSchedule, RenderApp}; /// Describes how to extract data needed for rendering from a component or /// components. diff --git a/crates/bevy_render/src/globals.rs b/crates/bevy_render/src/globals.rs index a209654ac3c82..b21b37ab8d963 100644 --- a/crates/bevy_render/src/globals.rs +++ b/crates/bevy_render/src/globals.rs @@ -1,12 +1,12 @@ use crate::{ - Extract, ExtractSchedule, Render, RenderApp, RenderSet, extract_resource::ExtractResource, prelude::Shader, render_resource::{ShaderType, UniformBuffer}, renderer::{RenderDevice, RenderQueue}, + Extract, ExtractSchedule, Render, RenderApp, RenderSet, }; use bevy_app::{App, Plugin}; -use bevy_asset::{Handle, load_internal_asset, weak_handle}; +use bevy_asset::{load_internal_asset, weak_handle, Handle}; use bevy_diagnostic::FrameCount; use bevy_ecs::prelude::*; use bevy_reflect::prelude::*; diff --git a/crates/bevy_render/src/gpu_component_array_buffer.rs b/crates/bevy_render/src/gpu_component_array_buffer.rs index c3edc5c38393d..ac0f471a4a235 100644 --- a/crates/bevy_render/src/gpu_component_array_buffer.rs +++ b/crates/bevy_render/src/gpu_component_array_buffer.rs @@ -1,7 +1,7 @@ use crate::{ - Render, RenderApp, RenderSet, render_resource::{GpuArrayBuffer, GpuArrayBufferable}, renderer::{RenderDevice, RenderQueue}, + Render, RenderApp, RenderSet, }; use bevy_app::{App, Plugin}; use bevy_ecs::{ diff --git a/crates/bevy_render/src/gpu_readback.rs b/crates/bevy_render/src/gpu_readback.rs index 875d5de143f6b..012ec1a6cb846 100644 --- a/crates/bevy_render/src/gpu_readback.rs +++ b/crates/bevy_render/src/gpu_readback.rs @@ -1,15 +1,15 @@ use crate::{ - ExtractSchedule, MainWorld, Render, RenderApp, RenderSet, extract_component::ExtractComponentPlugin, render_asset::RenderAssets, render_resource::{ Buffer, BufferUsages, CommandEncoder, Extent3d, TexelCopyBufferLayout, Texture, TextureFormat, }, - renderer::{RenderDevice, render_system}, + renderer::{render_system, RenderDevice}, storage::{GpuShaderStorageBuffer, ShaderStorageBuffer}, sync_world::MainEntity, texture::GpuImage, + ExtractSchedule, MainWorld, Render, RenderApp, RenderSet, }; use async_channel::{Receiver, Sender}; use bevy_app::{App, Plugin}; @@ -27,9 +27,9 @@ use bevy_image::{Image, TextureFormatPixelInfo}; use bevy_platform_support::collections::HashMap; use bevy_reflect::Reflect; use bevy_render_macros::ExtractComponent; -use encase::ShaderType; use encase::internal::ReadFrom; use encase::private::Reader; +use encase::ShaderType; use tracing::warn; /// A plugin that enables reading back gpu buffers and textures to the cpu. diff --git a/crates/bevy_render/src/lib.rs b/crates/bevy_render/src/lib.rs index 95c41fcf50ced..4a91686dfb243 100644 --- a/crates/bevy_render/src/lib.rs +++ b/crates/bevy_render/src/lib.rs @@ -56,19 +56,19 @@ pub mod view; pub mod prelude { #[doc(hidden)] pub use crate::{ - ExtractSchedule, alpha::AlphaMode, camera::{ Camera, ClearColor, ClearColorConfig, OrthographicProjection, PerspectiveProjection, Projection, }, mesh::{ - Mesh, Mesh2d, Mesh3d, morph::MorphWeights, primitives::MeshBuilder, - primitives::Meshable, + morph::MorphWeights, primitives::MeshBuilder, primitives::Meshable, Mesh, Mesh2d, + Mesh3d, }, render_resource::Shader, texture::ImagePlugin, view::{InheritedVisibility, Msaa, ViewVisibility, Visibility}, + ExtractSchedule, }; } use batching::gpu_preprocessing::BatchingPlugin; @@ -84,7 +84,7 @@ use render_asset::RenderAssetBytesPerFrame; use renderer::{RenderAdapter, RenderDevice, RenderQueue}; use settings::RenderResources; use sync_world::{ - SyncToRenderWorld, SyncWorldPlugin, despawn_temporary_render_entities, entity_sync_system, + despawn_temporary_render_entities, entity_sync_system, SyncToRenderWorld, SyncWorldPlugin, }; use crate::gpu_readback::GpuReadbackPlugin; @@ -93,14 +93,14 @@ use crate::{ mesh::{MeshPlugin, MorphPlugin, RenderMesh}, render_asset::prepare_assets, render_resource::{PipelineCache, Shader, ShaderLoader}, - renderer::{RenderInstance, WgpuWrapper, render_system}, + renderer::{render_system, RenderInstance, WgpuWrapper}, settings::RenderCreation, storage::StoragePlugin, view::{ViewPlugin, WindowRenderPlugin}, }; use alloc::sync::Arc; use bevy_app::{App, AppLabel, Plugin, SubApp}; -use bevy_asset::{AssetApp, AssetServer, Handle, load_internal_asset, weak_handle}; +use bevy_asset::{load_internal_asset, weak_handle, AssetApp, AssetServer, Handle}; use bevy_ecs::{prelude::*, schedule::ScheduleLabel}; use bitflags::bitflags; use core::ops::{Deref, DerefMut}; diff --git a/crates/bevy_render/src/mesh/allocator.rs b/crates/bevy_render/src/mesh/allocator.rs index 528e34e3359af..3af1ce1ea83fc 100644 --- a/crates/bevy_render/src/mesh/allocator.rs +++ b/crates/bevy_render/src/mesh/allocator.rs @@ -16,21 +16,21 @@ use bevy_ecs::{ system::{Res, ResMut}, world::{FromWorld, World}, }; -use bevy_platform_support::collections::{HashMap, HashSet, hash_map::Entry}; +use bevy_platform_support::collections::{hash_map::Entry, HashMap, HashSet}; use bevy_utils::default; use offset_allocator::{Allocation, Allocator}; use tracing::error; use wgpu::{ - BufferDescriptor, BufferSize, BufferUsages, COPY_BUFFER_ALIGNMENT, CommandEncoderDescriptor, - DownlevelFlags, + BufferDescriptor, BufferSize, BufferUsages, CommandEncoderDescriptor, DownlevelFlags, + COPY_BUFFER_ALIGNMENT, }; use crate::{ - Render, RenderApp, RenderSet, mesh::{Indices, Mesh, MeshVertexBufferLayouts, RenderMesh}, - render_asset::{ExtractedAssets, prepare_assets}, + render_asset::{prepare_assets, ExtractedAssets}, render_resource::Buffer, renderer::{RenderAdapter, RenderDevice, RenderQueue}, + Render, RenderApp, RenderSet, }; /// A plugin that manages GPU memory for mesh data. @@ -763,7 +763,9 @@ impl MeshAllocator { // Mark the allocation as pending. Don't copy it in just yet; further // meshes loaded this frame may result in its final allocation location // changing. - if let Some(Slab::General(general_slab)) = self.slabs.get_mut(&mesh_allocation.slab_id) { + if let Some(Slab::General(general_slab)) = + self.slabs.get_mut(&mesh_allocation.slab_id) + { general_slab .pending_allocations .insert(*mesh_id, mesh_allocation.slab_allocation); diff --git a/crates/bevy_render/src/mesh/components.rs b/crates/bevy_render/src/mesh/components.rs index c2dc3b0cf1038..b5b03ac2b8f27 100644 --- a/crates/bevy_render/src/mesh/components.rs +++ b/crates/bevy_render/src/mesh/components.rs @@ -9,7 +9,7 @@ use bevy_ecs::{ reflect::ReflectComponent, system::Query, }; use bevy_platform_support::{collections::HashSet, hash::FixedHasher}; -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_transform::components::Transform; use derive_more::derive::From; diff --git a/crates/bevy_render/src/mesh/mod.rs b/crates/bevy_render/src/mesh/mod.rs index 0d9d6b27115df..fbd530c14da42 100644 --- a/crates/bevy_render/src/mesh/mod.rs +++ b/crates/bevy_render/src/mesh/mod.rs @@ -4,12 +4,12 @@ use morph::{MeshMorphWeights, MorphWeights}; pub mod allocator; mod components; use crate::{ - RenderApp, primitives::Aabb, render_asset::{PrepareAssetError, RenderAsset, RenderAssetPlugin, RenderAssets}, render_resource::TextureView, texture::GpuImage, view::VisibilitySystems, + RenderApp, }; use allocator::MeshAllocatorPlugin; use bevy_app::{App, Plugin, PostUpdate}; @@ -17,11 +17,11 @@ use bevy_asset::{AssetApp, AssetEvents, AssetId, RenderAssetUsages}; use bevy_ecs::{ prelude::*, system::{ - SystemParamItem, lifetimeless::{SRes, SResMut}, + SystemParamItem, }, }; -pub use components::{Mesh2d, Mesh3d, MeshTag, mark_3d_meshes_as_changed_if_their_assets_changed}; +pub use components::{mark_3d_meshes_as_changed_if_their_assets_changed, Mesh2d, Mesh3d, MeshTag}; use wgpu::IndexFormat; /// Registers all [`MeshBuilder`] types. diff --git a/crates/bevy_render/src/primitives/mod.rs b/crates/bevy_render/src/primitives/mod.rs index 3ac5e4293dfd5..9123e95b5e946 100644 --- a/crates/bevy_render/src/primitives/mod.rs +++ b/crates/bevy_render/src/primitives/mod.rs @@ -353,7 +353,7 @@ pub struct CascadesFrusta { mod tests { use core::f32::consts::PI; - use bevy_math::{Quat, ops}; + use bevy_math::{ops, Quat}; use bevy_transform::components::GlobalTransform; use crate::camera::{CameraProjection, PerspectiveProjection}; diff --git a/crates/bevy_render/src/render_asset.rs b/crates/bevy_render/src/render_asset.rs index a0b377b210e0e..043b3554a148a 100644 --- a/crates/bevy_render/src/render_asset.rs +++ b/crates/bevy_render/src/render_asset.rs @@ -1,5 +1,5 @@ use crate::{ - ExtractSchedule, MainWorld, Render, RenderApp, RenderSet, render_resource::AsBindGroupError, + render_resource::AsBindGroupError, ExtractSchedule, MainWorld, Render, RenderApp, RenderSet, }; use bevy_app::{App, Plugin, SubApp}; pub use bevy_asset::RenderAssetUsages; diff --git a/crates/bevy_render/src/render_graph/context.rs b/crates/bevy_render/src/render_graph/context.rs index ccba753a6340d..4c6ecd30c1d67 100644 --- a/crates/bevy_render/src/render_graph/context.rs +++ b/crates/bevy_render/src/render_graph/context.rs @@ -242,9 +242,7 @@ pub enum RunSubGraphError { MissingSubGraph(InternedRenderSubGraph), #[error("attempted to pass inputs to sub-graph `{0:?}`, which has no input slots")] SubGraphHasNoInputs(InternedRenderSubGraph), - #[error( - "sub graph (name: `{graph_name:?}`) could not be run because slot `{slot_name}` at index {slot_index} has no value" - )] + #[error("sub graph (name: `{graph_name:?}`) could not be run because slot `{slot_name}` at index {slot_index} has no value")] MissingInput { slot_index: usize, slot_name: Cow<'static, str>, @@ -264,9 +262,7 @@ pub enum RunSubGraphError { pub enum OutputSlotError { #[error("output slot `{0:?}` does not exist")] InvalidSlot(SlotLabel), - #[error( - "attempted to output a value of type `{actual}` to output slot `{label:?}`, which has type `{expected}`" - )] + #[error("attempted to output a value of type `{actual}` to output slot `{label:?}`, which has type `{expected}`")] MismatchedSlotType { label: SlotLabel, expected: SlotType, @@ -278,9 +274,7 @@ pub enum OutputSlotError { pub enum InputSlotError { #[error("input slot `{0:?}` does not exist")] InvalidSlot(SlotLabel), - #[error( - "attempted to retrieve a value of type `{actual}` from input slot `{label:?}`, which has type `{expected}`" - )] + #[error("attempted to retrieve a value of type `{actual}` from input slot `{label:?}`, which has type `{expected}`")] MismatchedSlotType { label: SlotLabel, expected: SlotType, diff --git a/crates/bevy_render/src/render_graph/graph.rs b/crates/bevy_render/src/render_graph/graph.rs index 799797c57f557..78e6cbf324724 100644 --- a/crates/bevy_render/src/render_graph/graph.rs +++ b/crates/bevy_render/src/render_graph/graph.rs @@ -674,8 +674,8 @@ impl Node for GraphInputNode { mod tests { use crate::{ render_graph::{ - Edge, InternedRenderLabel, Node, NodeRunError, RenderGraph, RenderGraphContext, - RenderGraphError, RenderLabel, SlotInfo, SlotType, node::IntoRenderNodeArray, + node::IntoRenderNodeArray, Edge, InternedRenderLabel, Node, NodeRunError, RenderGraph, + RenderGraphContext, RenderGraphError, RenderLabel, SlotInfo, SlotType, }, renderer::RenderContext, }; diff --git a/crates/bevy_render/src/render_graph/mod.rs b/crates/bevy_render/src/render_graph/mod.rs index 1eead0a027cee..fbed33a23c6f4 100644 --- a/crates/bevy_render/src/render_graph/mod.rs +++ b/crates/bevy_render/src/render_graph/mod.rs @@ -24,9 +24,7 @@ pub enum RenderGraphError { InvalidInputNodeSlot(SlotLabel), #[error("node does not match the given type")] WrongNodeType, - #[error( - "attempted to connect output slot {output_slot} from node {output_node:?} to incompatible input slot {input_slot} from node {input_node:?}" - )] + #[error("attempted to connect output slot {output_slot} from node {output_node:?} to incompatible input slot {input_slot} from node {input_node:?}")] MismatchedNodeSlots { output_node: InternedRenderLabel, output_slot: usize, diff --git a/crates/bevy_render/src/render_graph/node.rs b/crates/bevy_render/src/render_graph/node.rs index 735856fbcc78e..0a634c2598461 100644 --- a/crates/bevy_render/src/render_graph/node.rs +++ b/crates/bevy_render/src/render_graph/node.rs @@ -14,7 +14,7 @@ use bevy_ecs::{ world::{FromWorld, World}, }; use core::fmt::Debug; -use downcast_rs::{Downcast, impl_downcast}; +use downcast_rs::{impl_downcast, Downcast}; use thiserror::Error; use variadics_please::all_tuples_with_size; diff --git a/crates/bevy_render/src/render_phase/draw.rs b/crates/bevy_render/src/render_phase/draw.rs index 9e23f57b14452..a12d336018508 100644 --- a/crates/bevy_render/src/render_phase/draw.rs +++ b/crates/bevy_render/src/render_phase/draw.rs @@ -333,11 +333,11 @@ where Ok(view) => view, Err(err) => match err { QueryEntityError::EntityDoesNotExist(_) => { - return Err(DrawError::ViewEntityNotFound); + return Err(DrawError::ViewEntityNotFound) } QueryEntityError::QueryDoesNotMatch(_, _) | QueryEntityError::AliasedMutability(_) => { - return Err(DrawError::InvalidViewQuery); + return Err(DrawError::InvalidViewQuery) } }, }; diff --git a/crates/bevy_render/src/render_phase/draw_state.rs b/crates/bevy_render/src/render_phase/draw_state.rs index 42a8477a11604..a7b8acdc00393 100644 --- a/crates/bevy_render/src/render_phase/draw_state.rs +++ b/crates/bevy_render/src/render_phase/draw_state.rs @@ -196,14 +196,18 @@ impl<'a> TrackedRenderPass<'a> { #[cfg(feature = "detailed_trace")] trace!( "set bind_group {} (already set): {:?} ({:?})", - index, bind_group, dynamic_uniform_indices + index, + bind_group, + dynamic_uniform_indices ); return; } #[cfg(feature = "detailed_trace")] trace!( "set bind_group {}: {:?} ({:?})", - index, bind_group, dynamic_uniform_indices + index, + bind_group, + dynamic_uniform_indices ); self.pass @@ -294,7 +298,9 @@ impl<'a> TrackedRenderPass<'a> { #[cfg(feature = "detailed_trace")] trace!( "draw indexed: {:?} {} {:?}", - indices, base_vertex, instances + indices, + base_vertex, + instances ); self.pass.draw_indexed(indices, base_vertex, instances); } @@ -345,7 +351,8 @@ impl<'a> TrackedRenderPass<'a> { #[cfg(feature = "detailed_trace")] trace!( "draw indexed indirect: {:?} {}", - indirect_buffer, indirect_offset + indirect_buffer, + indirect_offset ); self.pass .draw_indexed_indirect(indirect_buffer, indirect_offset); @@ -377,7 +384,9 @@ impl<'a> TrackedRenderPass<'a> { #[cfg(feature = "detailed_trace")] trace!( "multi draw indirect: {:?} {}, {}x", - indirect_buffer, indirect_offset, count + indirect_buffer, + indirect_offset, + count ); self.pass .multi_draw_indirect(indirect_buffer, indirect_offset, count); @@ -416,7 +425,11 @@ impl<'a> TrackedRenderPass<'a> { #[cfg(feature = "detailed_trace")] trace!( "multi draw indirect count: {:?} {}, ({:?} {})x, max {}x", - indirect_buffer, indirect_offset, count_buffer, count_offset, max_count + indirect_buffer, + indirect_offset, + count_buffer, + count_offset, + max_count ); self.pass.multi_draw_indirect_count( indirect_buffer, @@ -455,7 +468,9 @@ impl<'a> TrackedRenderPass<'a> { #[cfg(feature = "detailed_trace")] trace!( "multi draw indexed indirect: {:?} {}, {}x", - indirect_buffer, indirect_offset, count + indirect_buffer, + indirect_offset, + count ); self.pass .multi_draw_indexed_indirect(indirect_buffer, indirect_offset, count); @@ -496,7 +511,11 @@ impl<'a> TrackedRenderPass<'a> { #[cfg(feature = "detailed_trace")] trace!( "multi draw indexed indirect count: {:?} {}, ({:?} {})x, max {}x", - indirect_buffer, indirect_offset, count_buffer, count_offset, max_count + indirect_buffer, + indirect_offset, + count_buffer, + count_offset, + max_count ); self.pass.multi_draw_indexed_indirect_count( indirect_buffer, @@ -554,7 +573,12 @@ impl<'a> TrackedRenderPass<'a> { #[cfg(feature = "detailed_trace")] trace!( "set viewport: {} {} {} {} {} {}", - x, y, width, height, min_depth, max_depth + x, + y, + width, + height, + min_depth, + max_depth ); self.pass .set_viewport(x, y, width, height, min_depth, max_depth); diff --git a/crates/bevy_render/src/render_phase/mod.rs b/crates/bevy_render/src/render_phase/mod.rs index 617bbf61a2e97..9c538a1377c1a 100644 --- a/crates/bevy_render/src/render_phase/mod.rs +++ b/crates/bevy_render/src/render_phase/mod.rs @@ -32,18 +32,17 @@ use bevy_app::{App, Plugin}; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::component::Tick; use bevy_ecs::entity::EntityHash; -use bevy_platform_support::collections::{HashMap, hash_map::Entry}; +use bevy_platform_support::collections::{hash_map::Entry, HashMap}; use bevy_utils::default; pub use draw::*; pub use draw_state::*; -use encase::{ShaderSize, internal::WriteInto}; +use encase::{internal::WriteInto, ShaderSize}; use fixedbitset::{Block, FixedBitSet}; use indexmap::IndexMap; use nonmax::NonMaxU32; pub use rangefinder::*; use wgpu::Features; -use crate::RenderDebugFlags; use crate::batching::gpu_preprocessing::{ GpuPreprocessingMode, GpuPreprocessingSupport, PhaseBatchedInstanceBuffers, PhaseIndirectParametersBuffers, @@ -51,18 +50,20 @@ use crate::batching::gpu_preprocessing::{ use crate::renderer::RenderDevice; use crate::sync_world::{MainEntity, MainEntityHashMap}; use crate::view::RetainedViewEntity; +use crate::RenderDebugFlags; use crate::{ - Render, RenderApp, RenderSet, batching::{ - self, GetFullBatchData, + self, gpu_preprocessing::{self, BatchedInstanceBuffers}, no_gpu_preprocessing::{self, BatchedInstanceBuffer}, + GetFullBatchData, }, render_resource::{CachedRenderPipelineId, GpuArrayBufferIndex, PipelineCache}, + Render, RenderApp, RenderSet, }; use bevy_ecs::{ prelude::*, - system::{SystemParamItem, lifetimeless::SRes}, + system::{lifetimeless::SRes, SystemParamItem}, }; use core::{fmt::Debug, hash::Hash, iter, marker::PhantomData, ops::Range, slice::SliceIndex}; use smallvec::SmallVec; diff --git a/crates/bevy_render/src/render_resource/batched_uniform_buffer.rs b/crates/bevy_render/src/render_resource/batched_uniform_buffer.rs index 8b6cb5323ef9e..fecc90feac1a4 100644 --- a/crates/bevy_render/src/render_resource/batched_uniform_buffer.rs +++ b/crates/bevy_render/src/render_resource/batched_uniform_buffer.rs @@ -5,8 +5,8 @@ use crate::{ }; use core::{marker::PhantomData, num::NonZero}; use encase::{ - ShaderType, private::{ArrayMetadata, BufferMut, Metadata, RuntimeSizedArray, WriteInto, Writer}, + ShaderType, }; use nonmax::NonMaxU32; use wgpu::{BindingResource, Limits}; diff --git a/crates/bevy_render/src/render_resource/bind_group.rs b/crates/bevy_render/src/render_resource/bind_group.rs index 0b0b4ee2998aa..9fe835bb1b8ab 100644 --- a/crates/bevy_render/src/render_resource/bind_group.rs +++ b/crates/bevy_render/src/render_resource/bind_group.rs @@ -537,9 +537,7 @@ pub enum AsBindGroupError { RetryNextUpdate, #[error("Create the bind group via `as_bind_group()` instead")] CreateBindGroupDirectly, - #[error( - "At binding index {0}, the provided image sampler `{1}` does not match the required sampler type(s) `{2}`." - )] + #[error("At binding index {0}, the provided image sampler `{1}` does not match the required sampler type(s) `{2}`.")] InvalidSamplerType(u32, String, String), } diff --git a/crates/bevy_render/src/render_resource/bind_group_layout_entries.rs b/crates/bevy_render/src/render_resource/bind_group_layout_entries.rs index bfdacced5c114..bc4a7d306da4b 100644 --- a/crates/bevy_render/src/render_resource/bind_group_layout_entries.rs +++ b/crates/bevy_render/src/render_resource/bind_group_layout_entries.rs @@ -222,9 +222,7 @@ impl IntoBindGroupLayoutEntryBuilder for BindingType { impl IntoBindGroupLayoutEntryBuilder for BindGroupLayoutEntry { fn into_bind_group_layout_entry_builder(self) -> BindGroupLayoutEntryBuilder { if self.binding != u32::MAX { - tracing::warn!( - "The BindGroupLayoutEntries api ignores the binding index when converting a raw wgpu::BindGroupLayoutEntry. You can ignore this warning by setting it to u32::MAX." - ); + tracing::warn!("The BindGroupLayoutEntries api ignores the binding index when converting a raw wgpu::BindGroupLayoutEntry. You can ignore this warning by setting it to u32::MAX."); } BindGroupLayoutEntryBuilder { ty: self.ty, diff --git a/crates/bevy_render/src/render_resource/buffer_vec.rs b/crates/bevy_render/src/render_resource/buffer_vec.rs index 3d0e5131f4846..2077024215463 100644 --- a/crates/bevy_render/src/render_resource/buffer_vec.rs +++ b/crates/bevy_render/src/render_resource/buffer_vec.rs @@ -4,10 +4,10 @@ use crate::{ render_resource::Buffer, renderer::{RenderDevice, RenderQueue}, }; -use bytemuck::{NoUninit, must_cast_slice}; +use bytemuck::{must_cast_slice, NoUninit}; use encase::{ - ShaderType, internal::{WriteInto, Writer}, + ShaderType, }; use wgpu::{BindingResource, BufferAddress, BufferUsages}; diff --git a/crates/bevy_render/src/render_resource/gpu_array_buffer.rs b/crates/bevy_render/src/render_resource/gpu_array_buffer.rs index 05346fb89563c..195920ee0ceb7 100644 --- a/crates/bevy_render/src/render_resource/gpu_array_buffer.rs +++ b/crates/bevy_render/src/render_resource/gpu_array_buffer.rs @@ -1,6 +1,6 @@ use super::{ - BindGroupLayoutEntryBuilder, BufferVec, binding_types::{storage_buffer_read_only, uniform_buffer_sized}, + BindGroupLayoutEntryBuilder, BufferVec, }; use crate::{ render_resource::batched_uniform_buffer::BatchedUniformBuffer, @@ -8,7 +8,7 @@ use crate::{ }; use bevy_ecs::{prelude::Component, resource::Resource}; use core::marker::PhantomData; -use encase::{ShaderSize, ShaderType, private::WriteInto}; +use encase::{private::WriteInto, ShaderSize, ShaderType}; use nonmax::NonMaxU32; use wgpu::{BindingResource, BufferUsages}; diff --git a/crates/bevy_render/src/render_resource/mod.rs b/crates/bevy_render/src/render_resource/mod.rs index 81c5926c59bc5..aab2fe5b6a798 100644 --- a/crates/bevy_render/src/render_resource/mod.rs +++ b/crates/bevy_render/src/render_resource/mod.rs @@ -34,15 +34,18 @@ pub use uniform_buffer::*; // TODO: decide where re-exports should go pub use wgpu::{ + util::{ + BufferInitDescriptor, DispatchIndirectArgs, DrawIndexedIndirectArgs, DrawIndirectArgs, + TextureDataOrder, + }, AdapterInfo as WgpuAdapterInfo, AddressMode, AstcBlock, AstcChannel, BindGroupDescriptor, BindGroupEntry, BindGroupLayoutDescriptor, BindGroupLayoutEntry, BindingResource, BindingType, BlendComponent, BlendFactor, BlendOperation, BlendState, BufferAddress, BufferAsyncError, - BufferBinding, BufferBindingType, BufferDescriptor, BufferSize, BufferUsages, - COPY_BUFFER_ALIGNMENT, ColorTargetState, ColorWrites, CommandEncoder, CommandEncoderDescriptor, - CompareFunction, ComputePass, ComputePassDescriptor, - ComputePipelineDescriptor as RawComputePipelineDescriptor, DepthBiasState, DepthStencilState, - DownlevelFlags, Extent3d, Face, Features as WgpuFeatures, FilterMode, - FragmentState as RawFragmentState, FrontFace, ImageSubresourceRange, IndexFormat, + BufferBinding, BufferBindingType, BufferDescriptor, BufferSize, BufferUsages, ColorTargetState, + ColorWrites, CommandEncoder, CommandEncoderDescriptor, CompareFunction, ComputePass, + ComputePassDescriptor, ComputePipelineDescriptor as RawComputePipelineDescriptor, + DepthBiasState, DepthStencilState, DownlevelFlags, Extent3d, Face, Features as WgpuFeatures, + FilterMode, FragmentState as RawFragmentState, FrontFace, ImageSubresourceRange, IndexFormat, Limits as WgpuLimits, LoadOp, Maintain, MapMode, MultisampleState, Operations, Origin3d, PipelineCompilationOptions, PipelineLayout, PipelineLayoutDescriptor, PolygonMode, PrimitiveState, PrimitiveTopology, PushConstantRange, RenderPassColorAttachment, @@ -55,11 +58,7 @@ pub use wgpu::{ TextureDimension, TextureFormat, TextureSampleType, TextureUsages, TextureView as WgpuTextureView, TextureViewDescriptor, TextureViewDimension, VertexAttribute, VertexBufferLayout as RawVertexBufferLayout, VertexFormat, VertexState as RawVertexState, - VertexStepMode, - util::{ - BufferInitDescriptor, DispatchIndirectArgs, DrawIndexedIndirectArgs, DrawIndirectArgs, - TextureDataOrder, - }, + VertexStepMode, COPY_BUFFER_ALIGNMENT, }; pub use crate::mesh::VertexBufferLayout; diff --git a/crates/bevy_render/src/render_resource/pipeline_cache.rs b/crates/bevy_render/src/render_resource/pipeline_cache.rs index 83167a538e2a5..7be7d1f724c43 100644 --- a/crates/bevy_render/src/render_resource/pipeline_cache.rs +++ b/crates/bevy_render/src/render_resource/pipeline_cache.rs @@ -1,8 +1,8 @@ use crate::renderer::WgpuWrapper; use crate::{ - Extract, render_resource::*, renderer::{RenderAdapter, RenderDevice}, + Extract, }; use alloc::{borrow::Cow, sync::Arc}; use bevy_asset::{AssetEvent, AssetId, Assets}; @@ -11,7 +11,7 @@ use bevy_ecs::{ resource::Resource, system::{Res, ResMut}, }; -use bevy_platform_support::collections::{HashMap, HashSet, hash_map::EntryRef}; +use bevy_platform_support::collections::{hash_map::EntryRef, HashMap, HashSet}; use bevy_tasks::Task; use bevy_utils::default; use core::{future::Future, hash::Hash, mem, ops::Deref}; @@ -882,14 +882,16 @@ impl PipelineCache { }; } - CachedPipelineState::Creating(task) => match bevy_tasks::futures::check_ready(task) { - Some(Ok(pipeline)) => { - cached_pipeline.state = CachedPipelineState::Ok(pipeline); - return; + CachedPipelineState::Creating(task) => { + match bevy_tasks::futures::check_ready(task) { + Some(Ok(pipeline)) => { + cached_pipeline.state = CachedPipelineState::Ok(pipeline); + return; + } + Some(Err(err)) => cached_pipeline.state = CachedPipelineState::Err(err), + _ => (), } - Some(Err(err)) => cached_pipeline.state = CachedPipelineState::Err(err), - _ => (), - }, + } CachedPipelineState::Err(err) => match err { // Retry diff --git a/crates/bevy_render/src/render_resource/pipeline_specializer.rs b/crates/bevy_render/src/render_resource/pipeline_specializer.rs index ed4bbb2ddc8c4..67f737a6a4193 100644 --- a/crates/bevy_render/src/render_resource/pipeline_specializer.rs +++ b/crates/bevy_render/src/render_resource/pipeline_specializer.rs @@ -8,8 +8,8 @@ use crate::{ use bevy_ecs::resource::Resource; use bevy_platform_support::{ collections::{ - HashMap, hash_map::{Entry, RawEntryMut, VacantEntry}, + HashMap, }, hash::FixedHasher, }; diff --git a/crates/bevy_render/src/render_resource/shader.rs b/crates/bevy_render/src/render_resource/shader.rs index f4f927e94a82a..e1d00ec0d7f30 100644 --- a/crates/bevy_render/src/render_resource/shader.rs +++ b/crates/bevy_render/src/render_resource/shader.rs @@ -1,7 +1,7 @@ use super::ShaderDefVal; use crate::define_atomic_id; use alloc::borrow::Cow; -use bevy_asset::{Asset, AssetLoader, AssetPath, Handle, LoadContext, io::Reader}; +use bevy_asset::{io::Reader, Asset, AssetLoader, AssetPath, Handle, LoadContext}; use bevy_reflect::TypePath; use core::marker::Copy; use thiserror::Error; diff --git a/crates/bevy_render/src/render_resource/storage_buffer.rs b/crates/bevy_render/src/render_resource/storage_buffer.rs index 5f92a6fe719dd..b407e22d8f9e6 100644 --- a/crates/bevy_render/src/render_resource/storage_buffer.rs +++ b/crates/bevy_render/src/render_resource/storage_buffer.rs @@ -3,10 +3,10 @@ use core::marker::PhantomData; use super::Buffer; use crate::renderer::{RenderDevice, RenderQueue}; use encase::{ - DynamicStorageBuffer as DynamicStorageBufferWrapper, ShaderType, - StorageBuffer as StorageBufferWrapper, internal::WriteInto, + internal::WriteInto, DynamicStorageBuffer as DynamicStorageBufferWrapper, ShaderType, + StorageBuffer as StorageBufferWrapper, }; -use wgpu::{BindingResource, BufferBinding, BufferSize, BufferUsages, util::BufferInitDescriptor}; +use wgpu::{util::BufferInitDescriptor, BindingResource, BufferBinding, BufferSize, BufferUsages}; use super::IntoBinding; diff --git a/crates/bevy_render/src/render_resource/uniform_buffer.rs b/crates/bevy_render/src/render_resource/uniform_buffer.rs index f7cd03f594e64..b7d22972df469 100644 --- a/crates/bevy_render/src/render_resource/uniform_buffer.rs +++ b/crates/bevy_render/src/render_resource/uniform_buffer.rs @@ -5,12 +5,12 @@ use crate::{ renderer::{RenderDevice, RenderQueue}, }; use encase::{ + internal::{AlignmentValue, BufferMut, WriteInto}, DynamicUniformBuffer as DynamicUniformBufferWrapper, ShaderType, UniformBuffer as UniformBufferWrapper, - internal::{AlignmentValue, BufferMut, WriteInto}, }; use wgpu::{ - BindingResource, BufferBinding, BufferDescriptor, BufferUsages, util::BufferInitDescriptor, + util::BufferInitDescriptor, BindingResource, BufferBinding, BufferDescriptor, BufferUsages, }; use super::IntoBinding; diff --git a/crates/bevy_render/src/renderer/graph_runner.rs b/crates/bevy_render/src/renderer/graph_runner.rs index f0cd7fc6bc1e3..cc03374ea4316 100644 --- a/crates/bevy_render/src/renderer/graph_runner.rs +++ b/crates/bevy_render/src/renderer/graph_runner.rs @@ -4,7 +4,7 @@ use bevy_platform_support::collections::HashMap; use tracing::info_span; use alloc::{borrow::Cow, collections::VecDeque}; -use smallvec::{SmallVec, smallvec}; +use smallvec::{smallvec, SmallVec}; use thiserror::Error; use crate::{ @@ -39,9 +39,7 @@ pub enum RenderGraphRunnerError { slot_index: usize, slot_name: Cow<'static, str>, }, - #[error( - "graph '{sub_graph:?}' could not be run because slot '{slot_name}' at index {slot_index} has no value" - )] + #[error("graph '{sub_graph:?}' could not be run because slot '{slot_name}' at index {slot_index} has no value")] MissingInput { slot_index: usize, slot_name: Cow<'static, str>, diff --git a/crates/bevy_render/src/renderer/mod.rs b/crates/bevy_render/src/renderer/mod.rs index 02a4fdb193792..7d81db5a19402 100644 --- a/crates/bevy_render/src/renderer/mod.rs +++ b/crates/bevy_render/src/renderer/mod.rs @@ -9,7 +9,7 @@ pub use render_device::*; use tracing::{error, info, info_span, warn}; use crate::{ - diagnostic::{RecordDiagnostics, internal::DiagnosticsRecorder}, + diagnostic::{internal::DiagnosticsRecorder, RecordDiagnostics}, render_graph::RenderGraph, render_phase::TrackedRenderPass, render_resource::RenderPassDescriptor, @@ -111,9 +111,7 @@ pub fn render_system(world: &mut World, state: &mut SystemState { - panic!( - "The TimeSender channel should always be empty during render. You might need to add the bevy::core::time_system to your app.", - ); + panic!("The TimeSender channel should always be empty during render. You might need to add the bevy::core::time_system to your app.",); } bevy_time::TrySendError::Disconnected(_) => { // ignore disconnected errors, the main world probably just got dropped during shutdown diff --git a/crates/bevy_render/src/renderer/render_device.rs b/crates/bevy_render/src/renderer/render_device.rs index 9b6383fde4538..d33139745baf8 100644 --- a/crates/bevy_render/src/renderer/render_device.rs +++ b/crates/bevy_render/src/renderer/render_device.rs @@ -1,13 +1,13 @@ use super::RenderQueue; -use crate::WgpuWrapper; use crate::render_resource::{ BindGroup, BindGroupLayout, Buffer, ComputePipeline, RawRenderPipelineDescriptor, RenderPipeline, Sampler, Texture, }; +use crate::WgpuWrapper; use bevy_ecs::resource::Resource; use wgpu::{ - BindGroupDescriptor, BindGroupEntry, BindGroupLayoutDescriptor, BindGroupLayoutEntry, - BufferAsyncError, BufferBindingType, MaintainResult, util::DeviceExt, + util::DeviceExt, BindGroupDescriptor, BindGroupEntry, BindGroupLayoutDescriptor, + BindGroupLayoutEntry, BufferAsyncError, BufferBindingType, MaintainResult, }; /// This GPU device is responsible for the creation of most rendering and compute resources. @@ -101,9 +101,7 @@ impl RenderDevice { ) -> wgpu::ShaderModule { #[cfg(feature = "spirv_shader_passthrough")] match &desc.source { - wgpu::ShaderSource::SpirV(_source) => panic!( - "no safety checks are performed for spirv shaders. use `create_shader_module` instead" - ), + wgpu::ShaderSource::SpirV(_source) => panic!("no safety checks are performed for spirv shaders. use `create_shader_module` instead"), _ => self.device.create_shader_module(desc), } #[cfg(not(feature = "spirv_shader_passthrough"))] diff --git a/crates/bevy_render/src/storage.rs b/crates/bevy_render/src/storage.rs index 4a18d3bbe2902..7434f3999f3dc 100644 --- a/crates/bevy_render/src/storage.rs +++ b/crates/bevy_render/src/storage.rs @@ -5,10 +5,10 @@ use crate::{ }; use bevy_app::{App, Plugin}; use bevy_asset::{Asset, AssetApp, AssetId}; -use bevy_ecs::system::{SystemParamItem, lifetimeless::SRes}; -use bevy_reflect::{Reflect, prelude::ReflectDefault}; +use bevy_ecs::system::{lifetimeless::SRes, SystemParamItem}; +use bevy_reflect::{prelude::ReflectDefault, Reflect}; use bevy_utils::default; -use encase::{ShaderType, internal::WriteInto}; +use encase::{internal::WriteInto, ShaderType}; use wgpu::util::BufferInitDescriptor; /// Adds [`ShaderStorageBuffer`] as an asset that is extracted and uploaded to the GPU. diff --git a/crates/bevy_render/src/sync_world.rs b/crates/bevy_render/src/sync_world.rs index c092e52d075ca..3c9dc57ff8f40 100644 --- a/crates/bevy_render/src/sync_world.rs +++ b/crates/bevy_render/src/sync_world.rs @@ -279,7 +279,7 @@ mod render_entities_world_query_impls { entity::Entity, query::{FilteredAccess, QueryData, ReadOnlyQueryData, WorldQuery}, storage::{Table, TableRow}, - world::{World, unsafe_world_cell::UnsafeWorldCell}, + world::{unsafe_world_cell::UnsafeWorldCell, World}, }; /// SAFETY: defers completely to `&RenderEntity` implementation, @@ -492,8 +492,8 @@ mod tests { }; use super::{ - EntityRecord, MainEntity, PendingSyncEntity, RenderEntity, SyncToRenderWorld, - entity_sync_system, + entity_sync_system, EntityRecord, MainEntity, PendingSyncEntity, RenderEntity, + SyncToRenderWorld, }; #[derive(Component)] diff --git a/crates/bevy_render/src/texture/gpu_image.rs b/crates/bevy_render/src/texture/gpu_image.rs index 6ed90fcdedc07..551bd3ee02e09 100644 --- a/crates/bevy_render/src/texture/gpu_image.rs +++ b/crates/bevy_render/src/texture/gpu_image.rs @@ -4,7 +4,7 @@ use crate::{ renderer::{RenderDevice, RenderQueue}, }; use bevy_asset::AssetId; -use bevy_ecs::system::{SystemParamItem, lifetimeless::SRes}; +use bevy_ecs::system::{lifetimeless::SRes, SystemParamItem}; use bevy_image::{Image, ImageSampler}; use bevy_math::{AspectRatio, UVec2}; use wgpu::{Extent3d, TextureFormat, TextureViewDescriptor}; diff --git a/crates/bevy_render/src/texture/mod.rs b/crates/bevy_render/src/texture/mod.rs index 64402714cf815..6955de7ff4fc2 100644 --- a/crates/bevy_render/src/texture/mod.rs +++ b/crates/bevy_render/src/texture/mod.rs @@ -15,10 +15,10 @@ pub use texture_attachment::*; pub use texture_cache::*; use crate::{ - Render, RenderApp, RenderSet, render_asset::RenderAssetPlugin, renderer::RenderDevice, + render_asset::RenderAssetPlugin, renderer::RenderDevice, Render, RenderApp, RenderSet, }; use bevy_app::{App, Plugin}; -use bevy_asset::{AssetApp, Assets, Handle, weak_handle}; +use bevy_asset::{weak_handle, AssetApp, Assets, Handle}; use bevy_ecs::prelude::*; /// A handle to a 1 x 1 transparent white image. diff --git a/crates/bevy_render/src/texture/texture_cache.rs b/crates/bevy_render/src/texture/texture_cache.rs index 5e65ac8054efa..8a3fb010109d5 100644 --- a/crates/bevy_render/src/texture/texture_cache.rs +++ b/crates/bevy_render/src/texture/texture_cache.rs @@ -3,7 +3,7 @@ use crate::{ renderer::RenderDevice, }; use bevy_ecs::{prelude::ResMut, resource::Resource}; -use bevy_platform_support::collections::{HashMap, hash_map::Entry}; +use bevy_platform_support::collections::{hash_map::Entry, HashMap}; use wgpu::{TextureDescriptor, TextureViewDescriptor}; /// The internal representation of a [`CachedTexture`] used to track whether it was recently used diff --git a/crates/bevy_render/src/view/mod.rs b/crates/bevy_render/src/view/mod.rs index 4642f56248b4f..ba0f8cca62ced 100644 --- a/crates/bevy_render/src/view/mod.rs +++ b/crates/bevy_render/src/view/mod.rs @@ -1,13 +1,12 @@ pub mod visibility; pub mod window; -use bevy_asset::{Handle, load_internal_asset, weak_handle}; +use bevy_asset::{load_internal_asset, weak_handle, Handle}; use bevy_diagnostic::FrameCount; pub use visibility::*; pub use window::*; use crate::{ - Render, RenderApp, RenderSet, camera::{ CameraMainTextureUsages, ClearColor, ClearColorConfig, Exposure, ExtractedCamera, ManualTextureViews, MipBias, NormalizedRenderTarget, TemporalJitter, @@ -25,6 +24,7 @@ use crate::{ CachedTexture, ColorAttachment, DepthAttachment, GpuImage, OutputColorAttachment, TextureCache, }, + Render, RenderApp, RenderSet, }; use alloc::sync::Arc; use bevy_app::{App, Plugin}; @@ -32,9 +32,9 @@ use bevy_color::LinearRgba; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::prelude::*; use bevy_image::BevyDefault as _; -use bevy_math::{Mat3, Mat4, UVec4, Vec2, Vec3, Vec4, Vec4Swizzles, mat3, vec2, vec3}; -use bevy_platform_support::collections::{HashMap, hash_map::Entry}; -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_math::{mat3, vec2, vec3, Mat3, Mat4, UVec4, Vec2, Vec3, Vec4, Vec4Swizzles}; +use bevy_platform_support::collections::{hash_map::Entry, HashMap}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render_macros::ExtractComponent; use bevy_transform::components::GlobalTransform; use core::{ diff --git a/crates/bevy_render/src/view/visibility/mod.rs b/crates/bevy_render/src/view/visibility/mod.rs index 7afa00e470d86..09dc516b6ea9b 100644 --- a/crates/bevy_render/src/view/visibility/mod.rs +++ b/crates/bevy_render/src/view/visibility/mod.rs @@ -13,8 +13,8 @@ pub use render_layers::*; use bevy_app::{Plugin, PostUpdate}; use bevy_asset::Assets; use bevy_ecs::{hierarchy::validate_parent_has_component, prelude::*}; -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; -use bevy_transform::{TransformSystem, components::GlobalTransform}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_transform::{components::GlobalTransform, TransformSystem}; use bevy_utils::{Parallel, TypeIdMap}; use smallvec::SmallVec; diff --git a/crates/bevy_render/src/view/visibility/range.rs b/crates/bevy_render/src/view/visibility/range.rs index a5f8ebb6ac0a4..fe0af5b08afb1 100644 --- a/crates/bevy_render/src/view/visibility/range.rs +++ b/crates/bevy_render/src/view/visibility/range.rs @@ -9,7 +9,7 @@ use core::{ use bevy_app::{App, Plugin, PostUpdate}; use bevy_ecs::{ component::Component, - entity::{Entity, hash_map::EntityHashMap}, + entity::{hash_map::EntityHashMap, Entity}, query::{Changed, With}, reflect::ReflectComponent, removal_detection::RemovedComponents, @@ -17,7 +17,7 @@ use bevy_ecs::{ schedule::IntoSystemConfigs as _, system::{Query, Res, ResMut}, }; -use bevy_math::{FloatOrd, Vec4, vec4}; +use bevy_math::{vec4, FloatOrd, Vec4}; use bevy_platform_support::collections::HashMap; use bevy_reflect::Reflect; use bevy_transform::components::GlobalTransform; @@ -25,14 +25,14 @@ use bevy_utils::prelude::default; use nonmax::NonMaxU16; use wgpu::{BufferBindingType, BufferUsages}; -use super::{VisibilitySystems, check_visibility}; +use super::{check_visibility, VisibilitySystems}; use crate::sync_world::{MainEntity, MainEntityHashMap}; use crate::{ - Extract, ExtractSchedule, Render, RenderApp, RenderSet, camera::Camera, primitives::Aabb, render_resource::BufferVec, renderer::{RenderDevice, RenderQueue}, + Extract, ExtractSchedule, Render, RenderApp, RenderSet, }; /// We need at least 4 storage buffer bindings available to enable the diff --git a/crates/bevy_render/src/view/visibility/render_layers.rs b/crates/bevy_render/src/view/visibility/render_layers.rs index 29cf6ff59f3eb..1932abdf71fba 100644 --- a/crates/bevy_render/src/view/visibility/render_layers.rs +++ b/crates/bevy_render/src/view/visibility/render_layers.rs @@ -1,5 +1,5 @@ use bevy_ecs::prelude::{Component, ReflectComponent}; -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use smallvec::SmallVec; pub const DEFAULT_LAYERS: &RenderLayers = &RenderLayers::layer(0); diff --git a/crates/bevy_render/src/view/window/mod.rs b/crates/bevy_render/src/view/window/mod.rs index 5b1714a8814f8..14a984ff3921e 100644 --- a/crates/bevy_render/src/view/window/mod.rs +++ b/crates/bevy_render/src/view/window/mod.rs @@ -1,7 +1,7 @@ use crate::{ - Extract, ExtractSchedule, Render, RenderApp, RenderSet, WgpuWrapper, render_resource::{SurfaceTexture, TextureView}, renderer::{RenderAdapter, RenderDevice, RenderInstance}, + Extract, ExtractSchedule, Render, RenderApp, RenderSet, WgpuWrapper, }; use bevy_app::{App, Plugin}; use bevy_ecs::{entity::hash_map::EntityHashMap, prelude::*}; diff --git a/crates/bevy_render/src/view/window/screenshot.rs b/crates/bevy_render/src/view/window/screenshot.rs index e9c5bd513ba16..d8a309036edb4 100644 --- a/crates/bevy_render/src/view/window/screenshot.rs +++ b/crates/bevy_render/src/view/window/screenshot.rs @@ -1,23 +1,23 @@ use super::ExtractedWindows; use crate::{ - ExtractSchedule, MainWorld, Render, RenderApp, RenderSet, camera::{ManualTextureViewHandle, ManualTextureViews, NormalizedRenderTarget, RenderTarget}, gpu_readback, prelude::Shader, render_asset::{RenderAssetUsages, RenderAssets}, render_resource::{ - BindGroup, BindGroupEntries, BindGroupLayout, BindGroupLayoutEntries, Buffer, BufferUsages, - CachedRenderPipelineId, FragmentState, PipelineCache, RenderPipelineDescriptor, - SpecializedRenderPipeline, SpecializedRenderPipelines, Texture, TextureUsages, TextureView, - VertexState, binding_types::texture_2d, + binding_types::texture_2d, BindGroup, BindGroupEntries, BindGroupLayout, + BindGroupLayoutEntries, Buffer, BufferUsages, CachedRenderPipelineId, FragmentState, + PipelineCache, RenderPipelineDescriptor, SpecializedRenderPipeline, + SpecializedRenderPipelines, Texture, TextureUsages, TextureView, VertexState, }, renderer::RenderDevice, texture::{GpuImage, OutputColorAttachment}, - view::{ViewTargetAttachments, WindowSurfaces, prepare_view_attachments, prepare_view_targets}, + view::{prepare_view_attachments, prepare_view_targets, ViewTargetAttachments, WindowSurfaces}, + ExtractSchedule, MainWorld, Render, RenderApp, RenderSet, }; use alloc::{borrow::Cow, sync::Arc}; use bevy_app::{First, Plugin, Update}; -use bevy_asset::{Handle, load_internal_asset, weak_handle}; +use bevy_asset::{load_internal_asset, weak_handle, Handle}; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::{ entity::hash_map::EntityHashMap, event::event_update_system, prelude::*, system::SystemState, @@ -32,8 +32,8 @@ use core::ops::Deref; use std::{ path::Path, sync::{ - Mutex, mpsc::{Receiver, Sender}, + Mutex, }, }; use tracing::{error, info, warn}; diff --git a/crates/bevy_scene/src/components.rs b/crates/bevy_scene/src/components.rs index ba1d6134e7fbc..8709c7990fd50 100644 --- a/crates/bevy_scene/src/components.rs +++ b/crates/bevy_scene/src/components.rs @@ -1,10 +1,10 @@ use bevy_asset::Handle; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::{ - component::{Component, require}, + component::{require, Component}, prelude::ReflectComponent, }; -use bevy_reflect::{Reflect, prelude::ReflectDefault}; +use bevy_reflect::{prelude::ReflectDefault, Reflect}; use bevy_transform::components::Transform; use derive_more::derive::From; diff --git a/crates/bevy_scene/src/dynamic_scene.rs b/crates/bevy_scene/src/dynamic_scene.rs index c05ddf7119c92..be45b54a811a9 100644 --- a/crates/bevy_scene/src/dynamic_scene.rs +++ b/crates/bevy_scene/src/dynamic_scene.rs @@ -1,8 +1,8 @@ -use crate::{DynamicSceneBuilder, Scene, SceneSpawnError, ron}; +use crate::{ron, DynamicSceneBuilder, Scene, SceneSpawnError}; use bevy_asset::Asset; use bevy_ecs::reflect::{ReflectMapEntities, ReflectResource}; use bevy_ecs::{ - entity::{Entity, SceneEntityMapper, hash_map::EntityHashMap}, + entity::{hash_map::EntityHashMap, Entity, SceneEntityMapper}, reflect::{AppTypeRegistry, ReflectComponent}, world::World, }; @@ -209,8 +209,8 @@ mod tests { use bevy_ecs::{ component::Component, entity::{ - Entity, EntityMapper, MapEntities, VisitEntities, VisitEntitiesMut, - hash_map::EntityHashMap, + hash_map::EntityHashMap, Entity, EntityMapper, MapEntities, VisitEntities, + VisitEntitiesMut, }, hierarchy::ChildOf, reflect::{AppTypeRegistry, ReflectComponent, ReflectMapEntities, ReflectResource}, diff --git a/crates/bevy_scene/src/dynamic_scene_builder.rs b/crates/bevy_scene/src/dynamic_scene_builder.rs index 86e07d7ac206c..c33346373bcc7 100644 --- a/crates/bevy_scene/src/dynamic_scene_builder.rs +++ b/crates/bevy_scene/src/dynamic_scene_builder.rs @@ -731,19 +731,15 @@ mod tests { .build(); let component = &scene.entities[0].components[0]; - assert!( - component - .try_as_reflect() - .expect("component should be concrete due to `FromReflect`") - .is::() - ); + assert!(component + .try_as_reflect() + .expect("component should be concrete due to `FromReflect`") + .is::()); let resource = &scene.resources[0]; - assert!( - resource - .try_as_reflect() - .expect("resource should be concrete due to `FromReflect`") - .is::() - ); + assert!(resource + .try_as_reflect() + .expect("resource should be concrete due to `FromReflect`") + .is::()); } } diff --git a/crates/bevy_scene/src/scene.rs b/crates/bevy_scene/src/scene.rs index 27ac065d4f3de..9040b15e85f7c 100644 --- a/crates/bevy_scene/src/scene.rs +++ b/crates/bevy_scene/src/scene.rs @@ -4,7 +4,7 @@ use crate::{DynamicScene, SceneSpawnError}; use bevy_asset::Asset; use bevy_ecs::{ component::ComponentCloneBehavior, - entity::{Entity, SceneEntityMapper, hash_map::EntityHashMap}, + entity::{hash_map::EntityHashMap, Entity, SceneEntityMapper}, entity_disabling::DefaultQueryFilters, reflect::{AppTypeRegistry, ReflectComponent, ReflectResource}, world::World, diff --git a/crates/bevy_scene/src/scene_filter.rs b/crates/bevy_scene/src/scene_filter.rs index 9f94f2b8bc11b..732a1e5f15490 100644 --- a/crates/bevy_scene/src/scene_filter.rs +++ b/crates/bevy_scene/src/scene_filter.rs @@ -1,4 +1,4 @@ -use bevy_platform_support::collections::{HashSet, hash_set::IntoIter}; +use bevy_platform_support::collections::{hash_set::IntoIter, HashSet}; use core::any::{Any, TypeId}; /// A filter used to control which types can be added to a [`DynamicScene`]. diff --git a/crates/bevy_scene/src/scene_loader.rs b/crates/bevy_scene/src/scene_loader.rs index bf3b3ab30a5aa..481b7ebc04124 100644 --- a/crates/bevy_scene/src/scene_loader.rs +++ b/crates/bevy_scene/src/scene_loader.rs @@ -1,7 +1,7 @@ #[cfg(feature = "serialize")] use crate::serde::SceneDeserializer; -use crate::{DynamicScene, ron}; -use bevy_asset::{AssetLoader, LoadContext, io::Reader}; +use crate::{ron, DynamicScene}; +use bevy_asset::{io::Reader, AssetLoader, LoadContext}; use bevy_ecs::{ reflect::AppTypeRegistry, world::{FromWorld, World}, diff --git a/crates/bevy_scene/src/scene_spawner.rs b/crates/bevy_scene/src/scene_spawner.rs index c5fb7f7c7d019..3d4014f123534 100644 --- a/crates/bevy_scene/src/scene_spawner.rs +++ b/crates/bevy_scene/src/scene_spawner.rs @@ -1,7 +1,7 @@ use crate::{DynamicScene, Scene}; use bevy_asset::{AssetEvent, AssetId, Assets, Handle}; use bevy_ecs::{ - entity::{Entity, hash_map::EntityHashMap}, + entity::{hash_map::EntityHashMap, Entity}, event::{Event, EventCursor, Events}, hierarchy::ChildOf, reflect::AppTypeRegistry, @@ -85,17 +85,13 @@ pub struct SceneSpawner { #[derive(Error, Debug)] pub enum SceneSpawnError { /// Scene contains an unregistered component type. - #[error( - "scene contains the unregistered component `{type_path}`. consider adding `#[reflect(Component)]` to your type" - )] + #[error("scene contains the unregistered component `{type_path}`. consider adding `#[reflect(Component)]` to your type")] UnregisteredComponent { /// Type of the unregistered component. type_path: String, }, /// Scene contains an unregistered resource type. - #[error( - "scene contains the unregistered resource `{type_path}`. consider adding `#[reflect(Resource)]` to your type" - )] + #[error("scene contains the unregistered resource `{type_path}`. consider adding `#[reflect(Resource)]` to your type")] UnregisteredResource { /// Type of the unregistered resource. type_path: String, @@ -120,9 +116,7 @@ pub enum SceneSpawnError { type_path: String, }, /// Scene contains a proxy without a represented type. - #[error( - "scene contains dynamic type `{type_path}` without a represented type. consider changing this using `set_represented_type`." - )] + #[error("scene contains dynamic type `{type_path}` without a represented type. consider changing this using `set_represented_type`.")] NoRepresentedType { /// The dynamic instance type. type_path: String, diff --git a/crates/bevy_scene/src/serde.rs b/crates/bevy_scene/src/serde.rs index 726745846193c..8e26863e792ee 100644 --- a/crates/bevy_scene/src/serde.rs +++ b/crates/bevy_scene/src/serde.rs @@ -4,17 +4,17 @@ use crate::{DynamicEntity, DynamicScene}; use bevy_ecs::entity::Entity; use bevy_platform_support::collections::HashSet; use bevy_reflect::{ - PartialReflect, ReflectFromReflect, TypeRegistry, serde::{ ReflectDeserializer, TypeRegistrationDeserializer, TypedReflectDeserializer, TypedReflectSerializer, }, + PartialReflect, ReflectFromReflect, TypeRegistry, }; use core::fmt::Formatter; use serde::{ - Deserialize, Deserializer, Serialize, Serializer, de::{DeserializeSeed, Error, MapAccess, SeqAccess, Visitor}, ser::{SerializeMap, SerializeStruct}, + Deserialize, Deserializer, Serialize, Serializer, }; /// Name of the serialized scene struct type. @@ -510,11 +510,12 @@ impl<'a, 'de> Visitor<'de> for SceneMapVisitor<'a> { #[cfg(test)] mod tests { use crate::{ - DynamicScene, DynamicSceneBuilder, ron, + ron, serde::{SceneDeserializer, SceneSerializer}, + DynamicScene, DynamicSceneBuilder, }; use bevy_ecs::{ - entity::{Entity, hash_map::EntityHashMap}, + entity::{hash_map::EntityHashMap, Entity}, prelude::{Component, ReflectComponent, ReflectResource, Resource, World}, query::{With, Without}, reflect::AppTypeRegistry, @@ -522,7 +523,7 @@ mod tests { }; use bevy_reflect::{Reflect, ReflectDeserialize, ReflectSerialize}; use bincode::Options; - use serde::{Deserialize, Serialize, de::DeserializeSeed}; + use serde::{de::DeserializeSeed, Deserialize, Serialize}; use std::io::BufReader; #[derive(Component, Reflect, Default)] @@ -537,7 +538,7 @@ mod tests { // De/serialize as hex. mod qux { - use serde::{Deserialize, Deserializer, Serializer, de::Error}; + use serde::{de::Error, Deserialize, Deserializer, Serializer}; pub fn serialize(value: &u32, serializer: S) -> Result where @@ -771,12 +772,10 @@ mod tests { .unwrap(); assert_eq!(foo, bar_to_foo.0); - assert!( - dst_world - .query_filtered::<&MyEntityRef, With>() - .iter(&dst_world) - .all(|r| world.get_entity(r.0).is_err()) - ); + assert!(dst_world + .query_filtered::<&MyEntityRef, With>() + .iter(&dst_world) + .all(|r| world.get_entity(r.0).is_err())); } #[test] diff --git a/crates/bevy_sprite/src/lib.rs b/crates/bevy_sprite/src/lib.rs index cac9864fa264a..568701725d605 100644 --- a/crates/bevy_sprite/src/lib.rs +++ b/crates/bevy_sprite/src/lib.rs @@ -23,9 +23,9 @@ mod texture_slice; pub mod prelude { #[doc(hidden)] pub use crate::{ - ColorMaterial, MeshMaterial2d, ScalingMode, sprite::{Sprite, SpriteImageMode}, texture_slice::{BorderRect, SliceScaleMode, TextureSlice, TextureSlicer}, + ColorMaterial, MeshMaterial2d, ScalingMode, }; } @@ -37,18 +37,18 @@ pub use sprite::*; pub use texture_slice::*; use bevy_app::prelude::*; -use bevy_asset::{AssetEvents, Assets, Handle, load_internal_asset, weak_handle}; +use bevy_asset::{load_internal_asset, weak_handle, AssetEvents, Assets, Handle}; use bevy_core_pipeline::core_2d::{AlphaMask2d, Opaque2d, Transparent2d}; use bevy_ecs::prelude::*; -use bevy_image::{TextureAtlasPlugin, prelude::*}; +use bevy_image::{prelude::*, TextureAtlasPlugin}; use bevy_render::{ - ExtractSchedule, Render, RenderApp, RenderSet, batching::sort_binned_render_phase, mesh::{Mesh, Mesh2d, MeshAabb}, primitives::Aabb, render_phase::AddRenderCommand, render_resource::{Shader, SpecializedRenderPipelines}, view::{NoFrustumCulling, VisibilitySystems}, + ExtractSchedule, Render, RenderApp, RenderSet, }; /// Adds support for 2D sprite rendering. @@ -246,23 +246,21 @@ mod test { let entity = app.world_mut().spawn(Sprite::from_image(image_handle)).id(); // Verify that the entity does not have an AABB - assert!( - !app.world() - .get_entity(entity) - .expect("Could not find entity") - .contains::() - ); + assert!(!app + .world() + .get_entity(entity) + .expect("Could not find entity") + .contains::()); // Run system app.update(); // Verify the AABB exists - assert!( - app.world() - .get_entity(entity) - .expect("Could not find entity") - .contains::() - ); + assert!(app + .world() + .get_entity(entity) + .expect("Could not find entity") + .contains::()); } #[test] diff --git a/crates/bevy_sprite/src/mesh2d/color_material.rs b/crates/bevy_sprite/src/mesh2d/color_material.rs index b4aca40a3eb86..15c965b7a788d 100644 --- a/crates/bevy_sprite/src/mesh2d/color_material.rs +++ b/crates/bevy_sprite/src/mesh2d/color_material.rs @@ -1,6 +1,6 @@ use crate::{AlphaMode2d, Material2d, Material2dPlugin}; use bevy_app::{App, Plugin}; -use bevy_asset::{Asset, AssetApp, Assets, Handle, load_internal_asset, weak_handle}; +use bevy_asset::{load_internal_asset, weak_handle, Asset, AssetApp, Assets, Handle}; use bevy_color::{Alpha, Color, ColorToComponents, LinearRgba}; use bevy_image::Image; use bevy_math::Vec4; diff --git a/crates/bevy_sprite/src/mesh2d/material.rs b/crates/bevy_sprite/src/mesh2d/material.rs index cde64361f68f9..fbe2c2132cdb6 100644 --- a/crates/bevy_sprite/src/mesh2d/material.rs +++ b/crates/bevy_sprite/src/mesh2d/material.rs @@ -16,19 +16,18 @@ use bevy_ecs::component::Tick; use bevy_ecs::system::SystemChangeTick; use bevy_ecs::{ prelude::*, - system::{SystemParamItem, lifetimeless::SRes}, + system::{lifetimeless::SRes, SystemParamItem}, }; use bevy_math::FloatOrd; use bevy_platform_support::collections::HashMap; -use bevy_reflect::{Reflect, prelude::ReflectDefault}; +use bevy_reflect::{prelude::ReflectDefault, Reflect}; use bevy_render::render_phase::{DrawFunctionId, InputUniformIndex}; use bevy_render::render_resource::CachedRenderPipelineId; use bevy_render::view::RenderVisibleEntities; use bevy_render::{ - Extract, ExtractSchedule, Render, RenderApp, RenderSet, mesh::{MeshVertexBufferLayoutRef, RenderMesh}, render_asset::{ - PrepareAssetError, RenderAsset, RenderAssetPlugin, RenderAssets, prepare_assets, + prepare_assets, PrepareAssetError, RenderAsset, RenderAssetPlugin, RenderAssets, }, render_phase::{ AddRenderCommand, BinnedRenderPhaseType, DrawFunctions, PhaseItem, PhaseItemExtraIndex, @@ -43,6 +42,7 @@ use bevy_render::{ renderer::RenderDevice, sync_world::{MainEntity, MainEntityHashMap}, view::{ExtractedView, ViewVisibility}, + Extract, ExtractSchedule, Render, RenderApp, RenderSet, }; use core::{hash::Hash, marker::PhantomData}; use derive_more::derive::From; diff --git a/crates/bevy_sprite/src/mesh2d/mesh.rs b/crates/bevy_sprite/src/mesh2d/mesh.rs index 8a9908d32d869..5822d47ed6231 100644 --- a/crates/bevy_sprite/src/mesh2d/mesh.rs +++ b/crates/bevy_sprite/src/mesh2d/mesh.rs @@ -1,12 +1,12 @@ use bevy_app::Plugin; -use bevy_asset::{AssetId, Handle, load_internal_asset, weak_handle}; +use bevy_asset::{load_internal_asset, weak_handle, AssetId, Handle}; -use crate::{Material2dBindGroupId, tonemapping_pipeline_key}; +use crate::{tonemapping_pipeline_key, Material2dBindGroupId}; use bevy_core_pipeline::tonemapping::DebandDither; use bevy_core_pipeline::{ - core_2d::{AlphaMask2d, CORE_2D_DEPTH_FORMAT, Camera2d, Opaque2d, Transparent2d}, + core_2d::{AlphaMask2d, Camera2d, Opaque2d, Transparent2d, CORE_2D_DEPTH_FORMAT}, tonemapping::{ - Tonemapping, TonemappingLuts, get_lut_bind_group_layout_entries, get_lut_bindings, + get_lut_bind_group_layout_entries, get_lut_bindings, Tonemapping, TonemappingLuts, }, }; use bevy_derive::{Deref, DerefMut}; @@ -15,32 +15,31 @@ use bevy_ecs::system::SystemChangeTick; use bevy_ecs::{ prelude::*, query::ROQueryItem, - system::{SystemParamItem, SystemState, lifetimeless::*}, + system::{lifetimeless::*, SystemParamItem, SystemState}, }; use bevy_image::{BevyDefault, Image, ImageSampler, TextureFormatPixelInfo}; use bevy_math::{Affine3, Vec4}; -use bevy_render::RenderSet::PrepareAssets; use bevy_render::mesh::MeshTag; use bevy_render::prelude::Msaa; +use bevy_render::RenderSet::PrepareAssets; use bevy_render::{ - Extract, ExtractSchedule, Render, RenderApp, RenderSet, batching::{ - GetBatchData, GetFullBatchData, NoAutomaticBatching, gpu_preprocessing::IndirectParametersCpuMetadata, no_gpu_preprocessing::{ - self, BatchedInstanceBuffer, batch_and_prepare_binned_render_phase, - batch_and_prepare_sorted_render_phase, write_batched_instance_buffer, + self, batch_and_prepare_binned_render_phase, batch_and_prepare_sorted_render_phase, + write_batched_instance_buffer, BatchedInstanceBuffer, }, + GetBatchData, GetFullBatchData, NoAutomaticBatching, }, globals::{GlobalsBuffer, GlobalsUniform}, mesh::{ - Mesh, Mesh2d, MeshVertexBufferLayoutRef, RenderMesh, RenderMeshBufferInfo, - allocator::MeshAllocator, + allocator::MeshAllocator, Mesh, Mesh2d, MeshVertexBufferLayoutRef, RenderMesh, + RenderMeshBufferInfo, }, render_asset::RenderAssets, render_phase::{ - PhaseItem, PhaseItemExtraIndex, RenderCommand, RenderCommandResult, TrackedRenderPass, - sweep_old_entities, + sweep_old_entities, PhaseItem, PhaseItemExtraIndex, RenderCommand, RenderCommandResult, + TrackedRenderPass, }, render_resource::{binding_types::uniform_buffer, *}, renderer::{RenderDevice, RenderQueue}, @@ -49,6 +48,7 @@ use bevy_render::{ view::{ ExtractedView, ViewTarget, ViewUniform, ViewUniformOffset, ViewUniforms, ViewVisibility, }, + Extract, ExtractSchedule, Render, RenderApp, RenderSet, }; use bevy_transform::components::GlobalTransform; use nonmax::NonMaxU32; diff --git a/crates/bevy_sprite/src/mesh2d/wireframe2d.rs b/crates/bevy_sprite/src/mesh2d/wireframe2d.rs index bea60e8b13b5d..4547f83d9b6af 100644 --- a/crates/bevy_sprite/src/mesh2d/wireframe2d.rs +++ b/crates/bevy_sprite/src/mesh2d/wireframe2d.rs @@ -1,9 +1,9 @@ use crate::{Material2d, Material2dKey, Material2dPlugin, Mesh2d}; use bevy_app::{Plugin, Startup, Update}; -use bevy_asset::{Asset, AssetApp, Assets, Handle, load_internal_asset, weak_handle}; +use bevy_asset::{load_internal_asset, weak_handle, Asset, AssetApp, Assets, Handle}; use bevy_color::{Color, LinearRgba}; use bevy_ecs::prelude::*; -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::{ extract_resource::ExtractResource, mesh::MeshVertexBufferLayoutRef, prelude::*, render_resource::*, diff --git a/crates/bevy_sprite/src/picking_backend.rs b/crates/bevy_sprite/src/picking_backend.rs index 56a779526781e..18fe21891ede3 100644 --- a/crates/bevy_sprite/src/picking_backend.rs +++ b/crates/bevy_sprite/src/picking_backend.rs @@ -13,7 +13,7 @@ use bevy_asset::prelude::*; use bevy_color::Alpha; use bevy_ecs::prelude::*; use bevy_image::prelude::*; -use bevy_math::{FloatExt, prelude::*}; +use bevy_math::{prelude::*, FloatExt}; use bevy_picking::backend::prelude::*; use bevy_reflect::prelude::*; use bevy_render::prelude::*; diff --git a/crates/bevy_sprite/src/render/mod.rs b/crates/bevy_sprite/src/render/mod.rs index 480152329dc63..b188ebbc1aa47 100644 --- a/crates/bevy_sprite/src/render/mod.rs +++ b/crates/bevy_sprite/src/render/mod.rs @@ -1,20 +1,20 @@ use core::ops::Range; -use crate::{ComputedTextureSlices, SPRITE_SHADER_HANDLE, ScalingMode, Sprite}; +use crate::{ComputedTextureSlices, ScalingMode, Sprite, SPRITE_SHADER_HANDLE}; use bevy_asset::{AssetEvent, AssetId, Assets}; use bevy_color::{ColorToComponents, LinearRgba}; use bevy_core_pipeline::{ - core_2d::{CORE_2D_DEPTH_FORMAT, Transparent2d}, + core_2d::{Transparent2d, CORE_2D_DEPTH_FORMAT}, tonemapping::{ - DebandDither, Tonemapping, TonemappingLuts, get_lut_bind_group_layout_entries, - get_lut_bindings, + get_lut_bind_group_layout_entries, get_lut_bindings, DebandDither, Tonemapping, + TonemappingLuts, }, }; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::{ prelude::*, query::ROQueryItem, - system::{SystemParamItem, SystemState, lifetimeless::*}, + system::{lifetimeless::*, SystemParamItem, SystemState}, }; use bevy_image::{BevyDefault, Image, ImageSampler, TextureAtlasLayout, TextureFormatPixelInfo}; use bevy_math::{Affine3A, FloatOrd, Quat, Rect, Vec2, Vec4}; @@ -22,7 +22,6 @@ use bevy_platform_support::collections::HashMap; use bevy_render::sync_world::MainEntity; use bevy_render::view::{RenderVisibleEntities, RetainedViewEntity}; use bevy_render::{ - Extract, render_asset::RenderAssets, render_phase::{ DrawFunctions, PhaseItem, PhaseItemExtraIndex, RenderCommand, RenderCommandResult, @@ -39,6 +38,7 @@ use bevy_render::{ ExtractedView, Msaa, ViewTarget, ViewUniform, ViewUniformOffset, ViewUniforms, ViewVisibility, }, + Extract, }; use bevy_transform::components::GlobalTransform; use bytemuck::{Pod, Zeroable}; diff --git a/crates/bevy_sprite/src/sprite.rs b/crates/bevy_sprite/src/sprite.rs index 5bf6c0693779e..59c60071a0293 100644 --- a/crates/bevy_sprite/src/sprite.rs +++ b/crates/bevy_sprite/src/sprite.rs @@ -1,12 +1,12 @@ use bevy_asset::{Assets, Handle}; use bevy_color::Color; use bevy_ecs::{ - component::{Component, require}, + component::{require, Component}, reflect::ReflectComponent, }; use bevy_image::{Image, TextureAtlas, TextureAtlasLayout}; use bevy_math::{Rect, UVec2, Vec2}; -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::{ sync_world::SyncToRenderWorld, view::{self, Visibility, VisibilityClass}, diff --git a/crates/bevy_sprite/src/texture_slice/mod.rs b/crates/bevy_sprite/src/texture_slice/mod.rs index bbbf4221ed7ff..7ea01d5839dc2 100644 --- a/crates/bevy_sprite/src/texture_slice/mod.rs +++ b/crates/bevy_sprite/src/texture_slice/mod.rs @@ -7,7 +7,7 @@ pub use border_rect::BorderRect; pub use slicer::{SliceScaleMode, TextureSlicer}; pub(crate) use computed_slices::{ - ComputedTextureSlices, compute_slices_on_asset_event, compute_slices_on_sprite_change, + compute_slices_on_asset_event, compute_slices_on_sprite_change, ComputedTextureSlices, }; /// Single texture slice, representing a texture rect to draw in a given area @@ -86,10 +86,7 @@ impl TextureSlice { remaining_columns -= size_y; } if slices.len() > 1_000 { - tracing::warn!( - "One of your tiled textures has generated {} slices. You might want to use higher stretch values to avoid a great performance cost", - slices.len() - ); + tracing::warn!("One of your tiled textures has generated {} slices. You might want to use higher stretch values to avoid a great performance cost", slices.len()); } slices } diff --git a/crates/bevy_sprite/src/texture_slice/slicer.rs b/crates/bevy_sprite/src/texture_slice/slicer.rs index 07cd97162f4e7..7250533550dff 100644 --- a/crates/bevy_sprite/src/texture_slice/slicer.rs +++ b/crates/bevy_sprite/src/texture_slice/slicer.rs @@ -1,5 +1,5 @@ use super::{BorderRect, TextureSlice}; -use bevy_math::{Rect, Vec2, vec2}; +use bevy_math::{vec2, Rect, Vec2}; use bevy_reflect::Reflect; /// Slices a texture using the **9-slicing** technique. This allows to reuse an image at various sizes diff --git a/crates/bevy_state/macros/src/states.rs b/crates/bevy_state/macros/src/states.rs index 7cc0087370463..52c133f6ee204 100644 --- a/crates/bevy_state/macros/src/states.rs +++ b/crates/bevy_state/macros/src/states.rs @@ -1,6 +1,6 @@ use proc_macro::TokenStream; use quote::{format_ident, quote}; -use syn::{DeriveInput, Pat, Path, Result, parse_macro_input, spanned::Spanned}; +use syn::{parse_macro_input, spanned::Spanned, DeriveInput, Pat, Path, Result}; use crate::bevy_state_path; diff --git a/crates/bevy_state/src/app.rs b/crates/bevy_state/src/app.rs index 3f3ee06c2aaba..2419efd4d8a99 100644 --- a/crates/bevy_state/src/app.rs +++ b/crates/bevy_state/src/app.rs @@ -5,9 +5,8 @@ use log::warn; use crate::{ state::{ - ComputedStates, FreelyMutableState, NextState, State, StateTransition, - StateTransitionEvent, StateTransitionSteps, States, SubStates, - setup_state_transitions_in_world, + setup_state_transitions_in_world, ComputedStates, FreelyMutableState, NextState, State, + StateTransition, StateTransitionEvent, StateTransitionSteps, States, SubStates, }, state_scoped::clear_state_scoped_entities, }; @@ -221,10 +220,7 @@ impl AppExtStates for SubApp { .contains_resource::>>() { let name = core::any::type_name::(); - warn!( - "State scoped entities are enabled for state `{}`, but the state isn't installed in the app!", - name - ); + warn!("State scoped entities are enabled for state `{}`, but the state isn't installed in the app!", name); } // We work with [`StateTransition`] in set [`StateTransitionSteps::ExitSchedules`] as opposed to [`OnExit`], // because [`OnExit`] only runs for one specific variant of the state. diff --git a/crates/bevy_state/src/lib.rs b/crates/bevy_state/src/lib.rs index bf1dc541d99b4..b2714b50c5025 100644 --- a/crates/bevy_state/src/lib.rs +++ b/crates/bevy_state/src/lib.rs @@ -85,9 +85,9 @@ pub mod prelude { commands::CommandsStatesExt, condition::*, state::{ - ComputedStates, EnterSchedules, ExitSchedules, NextState, OnEnter, OnExit, - OnTransition, State, StateSet, StateTransition, StateTransitionEvent, States, - SubStates, TransitionSchedules, last_transition, + last_transition, ComputedStates, EnterSchedules, ExitSchedules, NextState, OnEnter, + OnExit, OnTransition, State, StateSet, StateTransition, StateTransitionEvent, States, + SubStates, TransitionSchedules, }, state_scoped::StateScoped, }; diff --git a/crates/bevy_state/src/state/freely_mutable_state.rs b/crates/bevy_state/src/state/freely_mutable_state.rs index 55983d5a0d632..2bc186ebe0fb2 100644 --- a/crates/bevy_state/src/state/freely_mutable_state.rs +++ b/crates/bevy_state/src/state/freely_mutable_state.rs @@ -5,7 +5,7 @@ use bevy_ecs::{ system::{Commands, IntoSystem, ResMut}, }; -use super::{NextState, State, states::States, take_next_state, transitions::*}; +use super::{states::States, take_next_state, transitions::*, NextState, State}; /// This trait allows a state to be mutated directly using the [`NextState`](crate::state::NextState) resource. /// diff --git a/crates/bevy_state/src/state/mod.rs b/crates/bevy_state/src/state/mod.rs index 867c964ec6a21..9267478281575 100644 --- a/crates/bevy_state/src/state/mod.rs +++ b/crates/bevy_state/src/state/mod.rs @@ -525,11 +525,9 @@ mod tests { world.run_schedule(StateTransition); assert_eq!(world.resource::>().0, SimpleState::A); - assert!( - world - .resource::>>() - .is_empty() - ); + assert!(world + .resource::>>() + .is_empty()); world.insert_resource(TransitionCounter::default()); world.insert_resource(NextState::Pending(SimpleState::A)); diff --git a/crates/bevy_state/src/state/state_set.rs b/crates/bevy_state/src/state/state_set.rs index 4d6f42afbdb58..ca167d4970596 100644 --- a/crates/bevy_state/src/state/state_set.rs +++ b/crates/bevy_state/src/state/state_set.rs @@ -8,10 +8,10 @@ use variadics_please::all_tuples; use self::sealed::StateSetSealed; use super::{ - ApplyStateTransition, EnterSchedules, ExitSchedules, NextState, State, StateTransitionEvent, - StateTransitionSteps, States, TransitionSchedules, computed_states::ComputedStates, - internal_apply_state_transition, last_transition, run_enter, run_exit, run_transition, - sub_states::SubStates, take_next_state, + computed_states::ComputedStates, internal_apply_state_transition, last_transition, run_enter, + run_exit, run_transition, sub_states::SubStates, take_next_state, ApplyStateTransition, + EnterSchedules, ExitSchedules, NextState, State, StateTransitionEvent, StateTransitionSteps, + States, TransitionSchedules, }; mod sealed { diff --git a/crates/bevy_tasks/src/task_pool.rs b/crates/bevy_tasks/src/task_pool.rs index 891c971b356b4..b9c0e9f98261a 100644 --- a/crates/bevy_tasks/src/task_pool.rs +++ b/crates/bevy_tasks/src/task_pool.rs @@ -11,8 +11,9 @@ use concurrent_queue::ConcurrentQueue; use futures_lite::FutureExt; use crate::{ - Task, block_on, + block_on, thread_executor::{ThreadExecutor, ThreadExecutorTicker}, + Task, }; struct CallOnDrop(Option>); diff --git a/crates/bevy_text/src/bounds.rs b/crates/bevy_text/src/bounds.rs index ce7193c5fdd02..98d42e3a34b28 100644 --- a/crates/bevy_text/src/bounds.rs +++ b/crates/bevy_text/src/bounds.rs @@ -1,6 +1,6 @@ use bevy_ecs::{component::Component, reflect::ReflectComponent}; use bevy_math::Vec2; -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; /// The maximum width and height of text. The text will wrap according to the specified size. /// diff --git a/crates/bevy_text/src/font_atlas.rs b/crates/bevy_text/src/font_atlas.rs index 1bf4c021208e0..e14157cb38f8a 100644 --- a/crates/bevy_text/src/font_atlas.rs +++ b/crates/bevy_text/src/font_atlas.rs @@ -1,5 +1,5 @@ use bevy_asset::{Assets, Handle}; -use bevy_image::{ImageSampler, prelude::*}; +use bevy_image::{prelude::*, ImageSampler}; use bevy_math::{IVec2, UVec2}; use bevy_platform_support::collections::HashMap; use bevy_render::{ diff --git a/crates/bevy_text/src/font_atlas_set.rs b/crates/bevy_text/src/font_atlas_set.rs index 144b15fd5f6c2..92b71ef535842 100644 --- a/crates/bevy_text/src/font_atlas_set.rs +++ b/crates/bevy_text/src/font_atlas_set.rs @@ -9,7 +9,7 @@ use bevy_render::{ render_resource::{Extent3d, TextureDimension, TextureFormat}, }; -use crate::{Font, FontAtlas, FontSmoothing, GlyphAtlasInfo, error::TextError}; +use crate::{error::TextError, Font, FontAtlas, FontSmoothing, GlyphAtlasInfo}; /// A map of font faces to their corresponding [`FontAtlasSet`]s. #[derive(Debug, Default, Resource)] diff --git a/crates/bevy_text/src/font_loader.rs b/crates/bevy_text/src/font_loader.rs index 12a1be8ba4d88..9e0f2185a234e 100644 --- a/crates/bevy_text/src/font_loader.rs +++ b/crates/bevy_text/src/font_loader.rs @@ -1,5 +1,5 @@ use crate::Font; -use bevy_asset::{AssetLoader, LoadContext, io::Reader}; +use bevy_asset::{io::Reader, AssetLoader, LoadContext}; use thiserror::Error; #[derive(Default)] diff --git a/crates/bevy_text/src/lib.rs b/crates/bevy_text/src/lib.rs index 0542c17d46c92..670f793c31c15 100644 --- a/crates/bevy_text/src/lib.rs +++ b/crates/bevy_text/src/lib.rs @@ -52,8 +52,8 @@ pub use font_loader::*; pub use glyph::*; pub use pipeline::*; pub use text::*; -pub use text_access::*; pub use text2d::*; +pub use text_access::*; /// The text prelude. /// @@ -66,13 +66,13 @@ pub mod prelude { }; } -use bevy_app::{Animation, prelude::*}; -use bevy_asset::{AssetApp, AssetEvents}; +use bevy_app::{prelude::*, Animation}; #[cfg(feature = "default_font")] -use bevy_asset::{Handle, load_internal_binary_asset}; +use bevy_asset::{load_internal_binary_asset, Handle}; +use bevy_asset::{AssetApp, AssetEvents}; use bevy_ecs::prelude::*; use bevy_render::{ - ExtractSchedule, RenderApp, camera::CameraUpdateSystem, view::VisibilitySystems, + camera::CameraUpdateSystem, view::VisibilitySystems, ExtractSchedule, RenderApp, }; use bevy_sprite::SpriteSystem; diff --git a/crates/bevy_text/src/pipeline.rs b/crates/bevy_text/src/pipeline.rs index a742e52b178ce..e7774569cfb25 100644 --- a/crates/bevy_text/src/pipeline.rs +++ b/crates/bevy_text/src/pipeline.rs @@ -11,13 +11,13 @@ use bevy_image::prelude::*; use bevy_log::{once, warn}; use bevy_math::{UVec2, Vec2}; use bevy_platform_support::collections::HashMap; -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use cosmic_text::{Attrs, Buffer, Family, Metrics, Shaping, Wrap}; use crate::{ - ComputedTextBlock, Font, FontAtlasSets, FontSmoothing, JustifyText, LineBreak, PositionedGlyph, - TextBounds, TextEntity, TextFont, TextLayout, YAxisOrientation, error::TextError, + error::TextError, ComputedTextBlock, Font, FontAtlasSets, FontSmoothing, JustifyText, + LineBreak, PositionedGlyph, TextBounds, TextEntity, TextFont, TextLayout, YAxisOrientation, }; /// A wrapper resource around a [`cosmic_text::FontSystem`] diff --git a/crates/bevy_text/src/text.rs b/crates/bevy_text/src/text.rs index 7314ec9b3b8bb..7c88010de9118 100644 --- a/crates/bevy_text/src/text.rs +++ b/crates/bevy_text/src/text.rs @@ -497,12 +497,8 @@ pub fn detect_text_needs_rerender( // - Root children changed (can include additions and removals). for root in changed_roots.iter() { let Ok((_, Some(mut computed), _)) = computed.get_mut(root) else { - once!(warn!( - "found entity {} with a root text component ({}) but no ComputedTextBlock; this warning only \ - prints once", - root, - core::any::type_name::() - )); + once!(warn!("found entity {} with a root text component ({}) but no ComputedTextBlock; this warning only \ + prints once", root, core::any::type_name::())); continue; }; computed.needs_rerender = true; @@ -514,12 +510,9 @@ pub fn detect_text_needs_rerender( // - Span children changed (can include additions and removals). for (entity, maybe_span_parent, has_text_block) in changed_spans.iter() { if has_text_block { - once!(warn!( - "found entity {} with a TextSpan that has a TextLayout, which should only be on root \ + once!(warn!("found entity {} with a TextSpan that has a TextLayout, which should only be on root \ text entities (that have {}); this warning only prints once", - entity, - core::any::type_name::() - )); + entity, core::any::type_name::())); } let Some(span_parent) = maybe_span_parent else { @@ -538,11 +531,9 @@ pub fn detect_text_needs_rerender( // is outweighed by the expense of tracking visited spans. loop { let Ok((maybe_parent, maybe_computed, has_span)) = computed.get_mut(parent) else { - once!(warn!( - "found entity {} with a TextSpan that is part of a broken hierarchy with a ChildOf \ + once!(warn!("found entity {} with a TextSpan that is part of a broken hierarchy with a ChildOf \ component that points at non-existent entity {}; this warning only prints once", - entity, parent - )); + entity, parent)); break; }; if let Some(mut computed) = maybe_computed { @@ -550,11 +541,9 @@ pub fn detect_text_needs_rerender( break; } if !has_span { - once!(warn!( - "found entity {} with a TextSpan that has an ancestor ({}) that does not have a text \ + once!(warn!("found entity {} with a TextSpan that has an ancestor ({}) that does not have a text \ span component or a ComputedTextBlock component; this warning only prints once", - entity, parent - )); + entity, parent)); break; } let Some(next_parent) = maybe_parent else { diff --git a/crates/bevy_text/src/text2d.rs b/crates/bevy_text/src/text2d.rs index 0e475881c71c5..952627a6b785c 100644 --- a/crates/bevy_text/src/text2d.rs +++ b/crates/bevy_text/src/text2d.rs @@ -10,7 +10,7 @@ use bevy_derive::{Deref, DerefMut}; use bevy_ecs::entity::hash_set::EntityHashSet; use bevy_ecs::{ change_detection::{DetectChanges, Ref}, - component::{Component, require}, + component::{require, Component}, entity::Entity, prelude::{ReflectComponent, With}, query::{Changed, Without}, @@ -18,13 +18,13 @@ use bevy_ecs::{ }; use bevy_image::prelude::*; use bevy_math::Vec2; -use bevy_reflect::{Reflect, prelude::ReflectDefault}; +use bevy_reflect::{prelude::ReflectDefault, Reflect}; use bevy_render::sync_world::TemporaryRenderEntity; use bevy_render::view::{self, Visibility, VisibilityClass}; use bevy_render::{ - Extract, primitives::Aabb, view::{NoFrustumCulling, ViewVisibility}, + Extract, }; use bevy_sprite::{Anchor, ExtractedSprite, ExtractedSprites, Sprite}; use bevy_transform::components::Transform; @@ -370,10 +370,10 @@ pub fn calculate_bounds_text2d( mod tests { use bevy_app::{App, Update}; - use bevy_asset::{Handle, load_internal_binary_asset}; + use bevy_asset::{load_internal_binary_asset, Handle}; use bevy_ecs::schedule::IntoSystemConfigs; - use crate::{TextIterScratch, detect_text_needs_rerender}; + use crate::{detect_text_needs_rerender, TextIterScratch}; use super::*; @@ -417,12 +417,11 @@ mod tests { fn calculate_bounds_text2d_create_aabb() { let (mut app, entity) = setup(); - assert!( - !app.world() - .get_entity(entity) - .expect("Could not find entity") - .contains::() - ); + assert!(!app + .world() + .get_entity(entity) + .expect("Could not find entity") + .contains::()); // Creates the AABB after text layouting. app.update(); diff --git a/crates/bevy_time/src/lib.rs b/crates/bevy_time/src/lib.rs index ca4821e78698f..334ff549a958c 100644 --- a/crates/bevy_time/src/lib.rs +++ b/crates/bevy_time/src/lib.rs @@ -36,9 +36,9 @@ pub mod prelude { pub use crate::{Fixed, Real, Time, Timer, TimerMode, Virtual}; } -use bevy_app::{RunFixedMainLoop, prelude::*}; +use bevy_app::{prelude::*, RunFixedMainLoop}; use bevy_ecs::{ - event::{EventRegistry, ShouldUpdateEvents, event_update_system, signal_event_update_system}, + event::{event_update_system, signal_event_update_system, EventRegistry, ShouldUpdateEvents}, prelude::*, }; use bevy_platform_support::time::Instant; @@ -153,9 +153,7 @@ pub fn time_system( } Some(Err(_)) => { if *has_received_time { - log::warn!( - "time_system did not receive the time from the render world! Calculations depending on the time may be incorrect." - ); + log::warn!("time_system did not receive the time from the render world! Calculations depending on the time may be incorrect."); } None } @@ -357,9 +355,7 @@ mod tests { let event_registry = app.world().resource::(); let should_update = event_registry.should_update; - println!( - "Frame {frame}, {fixed_updates_seen} fixed updates seen. Should update: {should_update:?}" - ); + println!("Frame {frame}, {fixed_updates_seen} fixed updates seen. Should update: {should_update:?}"); println!("Total events: {n_total_events} | Current events: {n_current_events}",); match frame { diff --git a/crates/bevy_time/src/stopwatch.rs b/crates/bevy_time/src/stopwatch.rs index 6bc95c4918d76..f90503ee24b6f 100644 --- a/crates/bevy_time/src/stopwatch.rs +++ b/crates/bevy_time/src/stopwatch.rs @@ -1,5 +1,5 @@ #[cfg(feature = "bevy_reflect")] -use bevy_reflect::{Reflect, prelude::*}; +use bevy_reflect::{prelude::*, Reflect}; use core::time::Duration; /// A Stopwatch is a struct that tracks elapsed time when started. diff --git a/crates/bevy_time/src/time.rs b/crates/bevy_time/src/time.rs index bcc54b1fc49a2..3b5dbc8e26633 100644 --- a/crates/bevy_time/src/time.rs +++ b/crates/bevy_time/src/time.rs @@ -3,7 +3,7 @@ use core::time::Duration; #[cfg(feature = "bevy_reflect")] use { bevy_ecs::reflect::ReflectResource, - bevy_reflect::{Reflect, std_traits::ReflectDefault}, + bevy_reflect::{std_traits::ReflectDefault, Reflect}, }; /// A generic clock resource that tracks how much it has advanced since its diff --git a/crates/bevy_transform/src/components/global_transform.rs b/crates/bevy_transform/src/components/global_transform.rs index 601af69c40088..ecd59fac9d7da 100644 --- a/crates/bevy_transform/src/components/global_transform.rs +++ b/crates/bevy_transform/src/components/global_transform.rs @@ -1,7 +1,7 @@ use core::ops::Mul; use super::Transform; -use bevy_math::{Affine3A, Dir3, Isometry3d, Mat4, Quat, Vec3, Vec3A, ops}; +use bevy_math::{ops, Affine3A, Dir3, Isometry3d, Mat4, Quat, Vec3, Vec3A}; use derive_more::derive::From; #[cfg(all(feature = "bevy_reflect", feature = "serialize"))] @@ -13,7 +13,7 @@ use bevy_ecs::{component::Component, hierarchy::validate_parent_has_component}; #[cfg(feature = "bevy_reflect")] use { bevy_ecs::reflect::ReflectComponent, - bevy_reflect::{Reflect, std_traits::ReflectDefault}, + bevy_reflect::{std_traits::ReflectDefault, Reflect}, }; /// [`GlobalTransform`] is an affine transformation from entity-local coordinates to worldspace coordinates. diff --git a/crates/bevy_transform/src/helper.rs b/crates/bevy_transform/src/helper.rs index a4f28cbf9d8ae..777ca81a9dbd5 100644 --- a/crates/bevy_transform/src/helper.rs +++ b/crates/bevy_transform/src/helper.rs @@ -96,11 +96,9 @@ mod tests { #[test] fn match_transform_propagation_systems() { // Single transform - match_transform_propagation_systems_inner(vec![ - Transform::from_translation(Vec3::X) - .with_rotation(Quat::from_rotation_y(TAU / 4.)) - .with_scale(Vec3::splat(2.)), - ]); + match_transform_propagation_systems_inner(vec![Transform::from_translation(Vec3::X) + .with_rotation(Quat::from_rotation_y(TAU / 4.)) + .with_scale(Vec3::splat(2.))]); // Transform hierarchy match_transform_propagation_systems_inner(vec![ diff --git a/crates/bevy_transform/src/systems.rs b/crates/bevy_transform/src/systems.rs index 2a2764bc095e9..5f070c2ed65d3 100644 --- a/crates/bevy_transform/src/systems.rs +++ b/crates/bevy_transform/src/systems.rs @@ -160,8 +160,7 @@ unsafe fn propagate_recursive( let Some(children) = children else { return }; for (child, actual_parent) in parent_query.iter_many(children) { assert_eq!( - actual_parent.get(), - entity, + actual_parent.get(), entity, "Malformed hierarchy. This probably means that your hierarchy has been improperly maintained, or contains a cycle" ); // SAFETY: The caller guarantees that `transform_query` will not be fetched @@ -186,7 +185,7 @@ mod test { use alloc::vec; use bevy_app::prelude::*; use bevy_ecs::{prelude::*, world::CommandQueue}; - use bevy_math::{Vec3, vec3}; + use bevy_math::{vec3, Vec3}; use bevy_tasks::{ComputeTaskPool, TaskPool}; use crate::systems::*; @@ -454,16 +453,23 @@ mod test { .spawn(Transform::IDENTITY) .add_children(&[child]); - let mut child_entity = app.world_mut().entity_mut(child); + let mut child_entity = app + .world_mut() + .entity_mut(child); - let mut grandchild_entity = temp.entity_mut(grandchild); + let mut grandchild_entity = temp + .entity_mut(grandchild); #[expect( unsafe_code, reason = "ChildOf is not mutable but this is for a test to produce a scenario that cannot happen" )] // SAFETY: ChildOf is not mutable but this is for a test to produce a scenario that cannot happen - let mut a = unsafe { child_entity.get_mut_assume_mutable::().unwrap() }; + let mut a = unsafe { + child_entity + .get_mut_assume_mutable::() + .unwrap() + }; // SAFETY: ChildOf is not mutable but this is for a test to produce a scenario that cannot happen #[expect( @@ -476,7 +482,10 @@ mod test { .unwrap() }; - core::mem::swap(a.as_mut(), b.as_mut()); + core::mem::swap( + a.as_mut(), + b.as_mut(), + ); app.update(); } @@ -505,16 +514,12 @@ mod test { // Child should be positioned relative to its parent let parent_global_transform = *world.entity(parent).get::().unwrap(); let child_global_transform = *world.entity(child).get::().unwrap(); - assert!( - parent_global_transform - .translation() - .abs_diff_eq(translation, 0.1) - ); - assert!( - child_global_transform - .translation() - .abs_diff_eq(2. * translation, 0.1) - ); + assert!(parent_global_transform + .translation() + .abs_diff_eq(translation, 0.1)); + assert!(child_global_transform + .translation() + .abs_diff_eq(2. * translation, 0.1)); // Reparent child world.entity_mut(child).remove::(); diff --git a/crates/bevy_ui/src/accessibility.rs b/crates/bevy_ui/src/accessibility.rs index 5e8ffc217df3d..95686530ce37e 100644 --- a/crates/bevy_ui/src/accessibility.rs +++ b/crates/bevy_ui/src/accessibility.rs @@ -1,8 +1,8 @@ use crate::{ - ComputedNode, experimental::UiChildren, prelude::{Button, Label}, widget::{ImageNode, TextUiReader}, + ComputedNode, }; use bevy_a11y::AccessibilityNode; use bevy_app::{App, Plugin, PostUpdate}; diff --git a/crates/bevy_ui/src/experimental/ghost_hierarchy.rs b/crates/bevy_ui/src/experimental/ghost_hierarchy.rs index ecc0ef4be24a7..8e663964f7eb9 100644 --- a/crates/bevy_ui/src/experimental/ghost_hierarchy.rs +++ b/crates/bevy_ui/src/experimental/ghost_hierarchy.rs @@ -1,8 +1,8 @@ //! This module contains [`GhostNode`] and utilities to flatten the UI hierarchy, traversing past ghost nodes. -use crate::Node; #[cfg(feature = "ghost_nodes")] use crate::ui_node::ComputedNodeTarget; +use crate::Node; use bevy_ecs::{prelude::*, system::SystemParam}; #[cfg(feature = "ghost_nodes")] use bevy_reflect::prelude::*; diff --git a/crates/bevy_ui/src/focus.rs b/crates/bevy_ui/src/focus.rs index 78b55c37832e4..4093b81d55347 100644 --- a/crates/bevy_ui/src/focus.rs +++ b/crates/bevy_ui/src/focus.rs @@ -7,10 +7,10 @@ use bevy_ecs::{ reflect::ReflectComponent, system::{Local, Query, Res}, }; -use bevy_input::{ButtonInput, mouse::MouseButton, touch::Touches}; +use bevy_input::{mouse::MouseButton, touch::Touches, ButtonInput}; use bevy_math::{Rect, Vec2}; use bevy_platform_support::collections::HashMap; -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::{camera::NormalizedRenderTarget, prelude::Camera, view::InheritedVisibility}; use bevy_transform::components::GlobalTransform; use bevy_window::{PrimaryWindow, Window}; diff --git a/crates/bevy_ui/src/geometry.rs b/crates/bevy_ui/src/geometry.rs index 755868f311358..a8b523d696fa1 100644 --- a/crates/bevy_ui/src/geometry.rs +++ b/crates/bevy_ui/src/geometry.rs @@ -1,5 +1,5 @@ use bevy_math::Vec2; -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use core::ops::{Div, DivAssign, Mul, MulAssign, Neg}; use thiserror::Error; diff --git a/crates/bevy_ui/src/layout/mod.rs b/crates/bevy_ui/src/layout/mod.rs index d8833649b0bd1..912079fdaeac8 100644 --- a/crates/bevy_ui/src/layout/mod.rs +++ b/crates/bevy_ui/src/layout/mod.rs @@ -1,7 +1,7 @@ use crate::{ + experimental::{UiChildren, UiRootNodes}, BorderRadius, ComputedNode, ComputedNodeTarget, ContentSize, Display, LayoutConfig, Node, Outline, OverflowAxis, ScrollPosition, Val, - experimental::{UiChildren, UiRootNodes}, }; use bevy_ecs::{ change_detection::{DetectChanges, DetectChangesMut}, @@ -364,8 +364,8 @@ mod tests { }; use crate::{ - ContentSize, LayoutContext, layout::ui_surface::UiSurface, prelude::*, ui_layout_system, - update::update_ui_context_system, + layout::ui_surface::UiSurface, prelude::*, ui_layout_system, + update::update_ui_context_system, ContentSize, LayoutContext, }; // these window dimensions are easy to convert to and from percentage values @@ -580,30 +580,24 @@ mod tests { ui_surface.taffy.parent(child_node.id), Some(ui_parent_node.id) ); - assert!( - ui_surface - .taffy - .children(ui_parent_node.id) - .unwrap() - .contains(&child_node.id) - ); + assert!(ui_surface + .taffy + .children(ui_parent_node.id) + .unwrap() + .contains(&child_node.id)); } // the nodes of the deleted children should have been removed from the layout tree for deleted_child_entity in &deleted_children { - assert!( - !ui_surface - .entity_to_taffy - .contains_key(deleted_child_entity) - ); + assert!(!ui_surface + .entity_to_taffy + .contains_key(deleted_child_entity)); let deleted_child_node = child_node_map[deleted_child_entity]; - assert!( - !ui_surface - .taffy - .children(ui_parent_node.id) - .unwrap() - .contains(&deleted_child_node.id) - ); + assert!(!ui_surface + .taffy + .children(ui_parent_node.id) + .unwrap() + .contains(&deleted_child_node.id)); } // despawn the parent entity and its descendants @@ -718,10 +712,7 @@ mod tests { let Some((_rect, is_overlapping)) = overlap_check else { unreachable!("test not setup properly"); }; - assert!( - is_overlapping, - "root ui nodes are expected to behave like they have absolute position and be independent from each other" - ); + assert!(is_overlapping, "root ui nodes are expected to behave like they have absolute position and be independent from each other"); } #[test] @@ -861,9 +852,7 @@ mod tests { let current_taffy_node_count = get_taffy_node_count(&world); if current_taffy_node_count > expected_max_taffy_node_count { - panic!( - "extra taffy nodes detected: current: {current_taffy_node_count} max expected: {expected_max_taffy_node_count}" - ); + panic!("extra taffy nodes detected: current: {current_taffy_node_count} max expected: {expected_max_taffy_node_count}"); } } diff --git a/crates/bevy_ui/src/layout/ui_surface.rs b/crates/bevy_ui/src/layout/ui_surface.rs index bdb52fe753859..e0333763b83d2 100644 --- a/crates/bevy_ui/src/layout/ui_surface.rs +++ b/crates/bevy_ui/src/layout/ui_surface.rs @@ -4,13 +4,13 @@ use bevy_platform_support::collections::hash_map::Entry; use taffy::TaffyTree; use bevy_ecs::{ - entity::{Entity, hash_map::EntityHashMap}, + entity::{hash_map::EntityHashMap, Entity}, prelude::Resource, }; use bevy_math::{UVec2, Vec2}; use bevy_utils::default; -use crate::{LayoutContext, LayoutError, Measure, MeasureArgs, Node, NodeMeasure, layout::convert}; +use crate::{layout::convert, LayoutContext, LayoutError, Measure, MeasureArgs, Node, NodeMeasure}; use bevy_text::CosmicFontSystem; #[derive(Debug, Copy, Clone, PartialEq, Eq)] @@ -373,11 +373,9 @@ mod tests { let mut content_size = ContentSize::default(); content_size.set(NodeMeasure::Fixed(FixedMeasure { size: Vec2::ONE })); let measure_func = content_size.measure.take().unwrap(); - assert!( - ui_surface - .update_node_context(root_node_entity, measure_func) - .is_some() - ); + assert!(ui_surface + .update_node_context(root_node_entity, measure_func) + .is_some()); } #[test] diff --git a/crates/bevy_ui/src/lib.rs b/crates/bevy_ui/src/lib.rs index c92744bc6f895..5dfb4feeebaf1 100644 --- a/crates/bevy_ui/src/lib.rs +++ b/crates/bevy_ui/src/lib.rs @@ -19,7 +19,7 @@ pub mod widget; pub mod picking_backend; use bevy_derive::{Deref, DerefMut}; -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; mod accessibility; // This module is not re-exported, but is instead made public. // This is intended to discourage accidental use of the experimental API. @@ -53,25 +53,25 @@ pub mod prelude { #[doc(hidden)] pub use { crate::{ - Interaction, MaterialNode, UiMaterialPlugin, UiScale, geometry::*, ui_material::*, ui_node::*, widget::{Button, ImageNode, Label, NodeImageMode}, + Interaction, MaterialNode, UiMaterialPlugin, UiScale, }, // `bevy_sprite` re-exports for texture slicing bevy_sprite::{BorderRect, SliceScaleMode, SpriteImageMode, TextureSlicer}, }; } -use bevy_app::{Animation, prelude::*}; +use bevy_app::{prelude::*, Animation}; use bevy_ecs::prelude::*; use bevy_input::InputSystem; -use bevy_render::{RenderApp, camera::CameraUpdateSystem}; +use bevy_render::{camera::CameraUpdateSystem, RenderApp}; use bevy_transform::TransformSystem; use layout::ui_surface::UiSurface; -pub use stack::UiStack; use stack::ui_stack_system; +pub use stack::UiStack; use update::{update_clipping_system, update_ui_context_system}; /// The basic plugin for Bevy UI diff --git a/crates/bevy_ui/src/measurement.rs b/crates/bevy_ui/src/measurement.rs index 5cd51ffa89a0c..029498ab8de9d 100644 --- a/crates/bevy_ui/src/measurement.rs +++ b/crates/bevy_ui/src/measurement.rs @@ -1,6 +1,6 @@ use bevy_ecs::{prelude::Component, reflect::ReflectComponent}; use bevy_math::Vec2; -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_text::CosmicFontSystem; use core::fmt::Formatter; pub use taffy::style::AvailableSpace; diff --git a/crates/bevy_ui/src/picking_backend.rs b/crates/bevy_ui/src/picking_backend.rs index 8460a7fd7585e..afb2aecae3b32 100644 --- a/crates/bevy_ui/src/picking_backend.rs +++ b/crates/bevy_ui/src/picking_backend.rs @@ -24,7 +24,7 @@ #![deny(missing_docs)] -use crate::{UiStack, focus::pick_rounded_rect, prelude::*}; +use crate::{focus::pick_rounded_rect, prelude::*, UiStack}; use bevy_app::prelude::*; use bevy_ecs::{prelude::*, query::QueryData}; use bevy_math::{Rect, Vec2}; diff --git a/crates/bevy_ui/src/render/box_shadow.rs b/crates/bevy_ui/src/render/box_shadow.rs index 30ca38f290b45..0e501783564a4 100644 --- a/crates/bevy_ui/src/render/box_shadow.rs +++ b/crates/bevy_ui/src/render/box_shadow.rs @@ -18,21 +18,21 @@ use bevy_ecs::{ }, }; use bevy_image::BevyDefault as _; -use bevy_math::{FloatOrd, Mat4, Rect, Vec2, Vec3Swizzles, Vec4Swizzles, vec2}; -use bevy_render::RenderApp; +use bevy_math::{vec2, FloatOrd, Mat4, Rect, Vec2, Vec3Swizzles, Vec4Swizzles}; use bevy_render::sync_world::MainEntity; +use bevy_render::RenderApp; use bevy_render::{ - Extract, ExtractSchedule, Render, RenderSet, render_phase::*, render_resource::{binding_types::uniform_buffer, *}, renderer::{RenderDevice, RenderQueue}, sync_world::TemporaryRenderEntity, view::*, + Extract, ExtractSchedule, Render, RenderSet, }; use bevy_transform::prelude::GlobalTransform; use bytemuck::{Pod, Zeroable}; -use super::{QUAD_INDICES, QUAD_VERTEX_POSITIONS, UiCameraMap, UiCameraView, stack_z_offsets}; +use super::{stack_z_offsets, UiCameraMap, UiCameraView, QUAD_INDICES, QUAD_VERTEX_POSITIONS}; pub const BOX_SHADOW_SHADER_HANDLE: Handle = weak_handle!("d2991ecd-134f-4f82-adf5-0fcc86f02227"); diff --git a/crates/bevy_ui/src/render/debug_overlay.rs b/crates/bevy_ui/src/render/debug_overlay.rs index ab2eaf4ee9e08..79001f3ba1982 100644 --- a/crates/bevy_ui/src/render/debug_overlay.rs +++ b/crates/bevy_ui/src/render/debug_overlay.rs @@ -1,6 +1,6 @@ +use crate::ui_node::ComputedNodeTarget; use crate::CalculatedClip; use crate::ComputedNode; -use crate::ui_node::ComputedNodeTarget; use bevy_asset::AssetId; use bevy_color::Hsla; use bevy_ecs::entity::Entity; @@ -11,9 +11,9 @@ use bevy_ecs::system::Res; use bevy_ecs::system::ResMut; use bevy_math::Rect; use bevy_math::Vec2; -use bevy_render::Extract; use bevy_render::sync_world::TemporaryRenderEntity; use bevy_render::view::InheritedVisibility; +use bevy_render::Extract; use bevy_sprite::BorderRect; use bevy_transform::components::GlobalTransform; diff --git a/crates/bevy_ui/src/render/mod.rs b/crates/bevy_ui/src/render/mod.rs index 67b77583d0bf7..f41c8f2b81620 100644 --- a/crates/bevy_ui/src/render/mod.rs +++ b/crates/bevy_ui/src/render/mod.rs @@ -14,7 +14,7 @@ use crate::{ UiTargetCamera, }; use bevy_app::prelude::*; -use bevy_asset::{AssetEvent, AssetId, Assets, Handle, load_internal_asset, weak_handle}; +use bevy_asset::{load_internal_asset, weak_handle, AssetEvent, AssetId, Assets, Handle}; use bevy_color::{Alpha, ColorToComponents, LinearRgba}; use bevy_core_pipeline::core_2d::graph::{Core2d, Node2d}; use bevy_core_pipeline::core_3d::graph::{Core3d, Node3d}; @@ -30,21 +30,21 @@ use bevy_render::sync_world::MainEntity; use bevy_render::texture::TRANSPARENT_IMAGE_HANDLE; use bevy_render::view::RetainedViewEntity; use bevy_render::{ - Extract, RenderApp, RenderSet, camera::Camera, render_asset::RenderAssets, render_graph::{Node as RenderGraphNode, RenderGraph}, - render_phase::{AddRenderCommand, DrawFunctions, sort_phase_system}, + render_phase::{sort_phase_system, AddRenderCommand, DrawFunctions}, render_resource::*, renderer::{RenderDevice, RenderQueue}, view::{ExtractedView, ViewUniforms}, + Extract, RenderApp, RenderSet, }; use bevy_render::{ - ExtractSchedule, Render, render_phase::{PhaseItem, PhaseItemExtraIndex}, sync_world::{RenderEntity, TemporaryRenderEntity}, texture::GpuImage, view::InheritedVisibility, + ExtractSchedule, Render, }; use bevy_sprite::{BorderRect, SpriteAssetEvents}; #[cfg(feature = "bevy_ui_debug")] diff --git a/crates/bevy_ui/src/render/render_pass.rs b/crates/bevy_ui/src/render/render_pass.rs index b13ab6b72c7e6..f89133e31e3c4 100644 --- a/crates/bevy_ui/src/render/render_pass.rs +++ b/crates/bevy_ui/src/render/render_pass.rs @@ -4,7 +4,7 @@ use super::{ImageNodeBindGroups, UiBatch, UiMeta, UiViewTarget}; use crate::UiCameraView; use bevy_ecs::{ prelude::*, - system::{SystemParamItem, lifetimeless::*}, + system::{lifetimeless::*, SystemParamItem}, }; use bevy_math::FloatOrd; use bevy_render::sync_world::MainEntity; diff --git a/crates/bevy_ui/src/render/ui_material_pipeline.rs b/crates/bevy_ui/src/render/ui_material_pipeline.rs index d0544aecc1d18..8267668c0b297 100644 --- a/crates/bevy_ui/src/render/ui_material_pipeline.rs +++ b/crates/bevy_ui/src/render/ui_material_pipeline.rs @@ -14,7 +14,6 @@ use bevy_image::BevyDefault as _; use bevy_math::{FloatOrd, Mat4, Rect, Vec2, Vec4Swizzles}; use bevy_render::sync_world::{MainEntity, TemporaryRenderEntity}; use bevy_render::{ - Extract, ExtractSchedule, Render, RenderSet, extract_component::ExtractComponentPlugin, globals::{GlobalsBuffer, GlobalsUniform}, render_asset::{PrepareAssetError, RenderAsset, RenderAssetPlugin, RenderAssets}, @@ -22,6 +21,7 @@ use bevy_render::{ render_resource::{binding_types::uniform_buffer, *}, renderer::{RenderDevice, RenderQueue}, view::*, + Extract, ExtractSchedule, Render, RenderSet, }; use bevy_sprite::BorderRect; use bevy_transform::prelude::GlobalTransform; diff --git a/crates/bevy_ui/src/render/ui_texture_slice_pipeline.rs b/crates/bevy_ui/src/render/ui_texture_slice_pipeline.rs index a682a3a414a89..fd9799b679149 100644 --- a/crates/bevy_ui/src/render/ui_texture_slice_pipeline.rs +++ b/crates/bevy_ui/src/render/ui_texture_slice_pipeline.rs @@ -15,7 +15,6 @@ use bevy_math::{FloatOrd, Mat4, Rect, Vec2, Vec4Swizzles}; use bevy_platform_support::collections::HashMap; use bevy_render::sync_world::MainEntity; use bevy_render::{ - Extract, ExtractSchedule, Render, RenderSet, render_asset::RenderAssets, render_phase::*, render_resource::{binding_types::uniform_buffer, *}, @@ -23,6 +22,7 @@ use bevy_render::{ sync_world::TemporaryRenderEntity, texture::{GpuImage, TRANSPARENT_IMAGE_HANDLE}, view::*, + Extract, ExtractSchedule, Render, RenderSet, }; use bevy_sprite::{SliceScaleMode, SpriteAssetEvents, SpriteImageMode, TextureSlicer}; use bevy_transform::prelude::GlobalTransform; diff --git a/crates/bevy_ui/src/stack.rs b/crates/bevy_ui/src/stack.rs index fbf8ff2b0eda5..c8dfde318d5d2 100644 --- a/crates/bevy_ui/src/stack.rs +++ b/crates/bevy_ui/src/stack.rs @@ -4,8 +4,8 @@ use bevy_ecs::prelude::*; use bevy_platform_support::collections::HashSet; use crate::{ - ComputedNode, GlobalZIndex, ZIndex, experimental::{UiChildren, UiRootNodes}, + ComputedNode, GlobalZIndex, ZIndex, }; /// The current UI stack, which contains all UI nodes ordered by their depth (back-to-front). diff --git a/crates/bevy_ui/src/ui_material.rs b/crates/bevy_ui/src/ui_material.rs index 4e812a1fd91b2..a9d712d5be548 100644 --- a/crates/bevy_ui/src/ui_material.rs +++ b/crates/bevy_ui/src/ui_material.rs @@ -2,10 +2,10 @@ use crate::Node; use bevy_asset::{Asset, AssetId, Handle}; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::{ - component::{Component, require}, + component::{require, Component}, reflect::ReflectComponent, }; -use bevy_reflect::{Reflect, prelude::ReflectDefault}; +use bevy_reflect::{prelude::ReflectDefault, Reflect}; use bevy_render::{ extract_component::ExtractComponent, render_resource::{AsBindGroup, RenderPipelineDescriptor, ShaderRef}, diff --git a/crates/bevy_ui/src/ui_node.rs b/crates/bevy_ui/src/ui_node.rs index 6175a9aee38cc..96d9d2aeb2410 100644 --- a/crates/bevy_ui/src/ui_node.rs +++ b/crates/bevy_ui/src/ui_node.rs @@ -2,7 +2,7 @@ use crate::{FocusPolicy, UiRect, Val}; use bevy_color::Color; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::{prelude::*, system::SystemParam}; -use bevy_math::{Rect, UVec2, Vec2, Vec4Swizzles, vec4}; +use bevy_math::{vec4, Rect, UVec2, Vec2, Vec4Swizzles}; use bevy_reflect::prelude::*; use bevy_render::{ camera::{Camera, RenderTarget}, diff --git a/crates/bevy_ui/src/update.rs b/crates/bevy_ui/src/update.rs index 2a38ba4b02cf3..4c3b28a6923f9 100644 --- a/crates/bevy_ui/src/update.rs +++ b/crates/bevy_ui/src/update.rs @@ -1,15 +1,15 @@ //! This module contains systems that update the UI when something changes use crate::{ + experimental::{UiChildren, UiRootNodes}, CalculatedClip, ComputedNodeTarget, DefaultUiCamera, Display, Node, OverflowAxis, UiScale, UiTargetCamera, - experimental::{UiChildren, UiRootNodes}, }; use super::ComputedNode; use bevy_ecs::{ change_detection::DetectChangesMut, - entity::{Entity, hash_set::EntityHashSet}, + entity::{hash_set::EntityHashSet, Entity}, hierarchy::ChildOf, query::{Changed, With}, system::{Commands, Local, Query, Res}, diff --git a/crates/bevy_ui/src/widget/button.rs b/crates/bevy_ui/src/widget/button.rs index 0f8cd15773bdf..8445a4ad6266b 100644 --- a/crates/bevy_ui/src/widget/button.rs +++ b/crates/bevy_ui/src/widget/button.rs @@ -1,9 +1,9 @@ use crate::{FocusPolicy, Interaction, Node}; use bevy_ecs::{ - prelude::{Component, require}, + prelude::{require, Component}, reflect::ReflectComponent, }; -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; /// Marker struct for buttons #[derive(Component, Debug, Default, Clone, Copy, PartialEq, Eq, Reflect)] diff --git a/crates/bevy_ui/src/widget/image.rs b/crates/bevy_ui/src/widget/image.rs index d64b3efcf6c54..9c6abbbf82809 100644 --- a/crates/bevy_ui/src/widget/image.rs +++ b/crates/bevy_ui/src/widget/image.rs @@ -4,7 +4,7 @@ use bevy_color::Color; use bevy_ecs::prelude::*; use bevy_image::prelude::*; use bevy_math::{Rect, UVec2, Vec2}; -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::texture::TRANSPARENT_IMAGE_HANDLE; use bevy_sprite::TextureSlicer; use taffy::{MaybeMath, MaybeResolve}; diff --git a/crates/bevy_ui/src/widget/label.rs b/crates/bevy_ui/src/widget/label.rs index efacb2ec38866..f464fea527fc4 100644 --- a/crates/bevy_ui/src/widget/label.rs +++ b/crates/bevy_ui/src/widget/label.rs @@ -1,5 +1,5 @@ use bevy_ecs::{prelude::Component, reflect::ReflectComponent}; -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; /// Marker struct for labels #[derive(Component, Debug, Default, Clone, Copy, Reflect)] diff --git a/crates/bevy_ui/src/widget/text.rs b/crates/bevy_ui/src/widget/text.rs index 8bbba52810cdd..e1be210950a0b 100644 --- a/crates/bevy_ui/src/widget/text.rs +++ b/crates/bevy_ui/src/widget/text.rs @@ -8,7 +8,7 @@ use bevy_derive::{Deref, DerefMut}; use bevy_ecs::{ change_detection::DetectChanges, entity::Entity, - prelude::{Component, require}, + prelude::{require, Component}, query::With, reflect::ReflectComponent, system::{Query, Res, ResMut}, @@ -16,11 +16,11 @@ use bevy_ecs::{ }; use bevy_image::prelude::*; use bevy_math::Vec2; -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_text::{ - ComputedTextBlock, CosmicFontSystem, Font, FontAtlasSets, LineBreak, SwashCache, TextBounds, - TextColor, TextError, TextFont, TextLayout, TextLayoutInfo, TextMeasureInfo, TextPipeline, - TextReader, TextRoot, TextSpanAccess, TextWriter, YAxisOrientation, scale_value, + scale_value, ComputedTextBlock, CosmicFontSystem, Font, FontAtlasSets, LineBreak, SwashCache, + TextBounds, TextColor, TextError, TextFont, TextLayout, TextLayoutInfo, TextMeasureInfo, + TextPipeline, TextReader, TextRoot, TextSpanAccess, TextWriter, YAxisOrientation, }; use taffy::style::AvailableSpace; use tracing::error; diff --git a/crates/bevy_window/src/system_cursor.rs b/crates/bevy_window/src/system_cursor.rs index 08aa3791f009e..8db274ae9a807 100644 --- a/crates/bevy_window/src/system_cursor.rs +++ b/crates/bevy_window/src/system_cursor.rs @@ -69,7 +69,7 @@ // -------------------------------------------------------------- #[cfg(feature = "bevy_reflect")] -use bevy_reflect::{Reflect, prelude::ReflectDefault}; +use bevy_reflect::{prelude::ReflectDefault, Reflect}; #[cfg(feature = "serialize")] use bevy_reflect::{ReflectDeserialize, ReflectSerialize}; diff --git a/crates/bevy_window/src/window.rs b/crates/bevy_window/src/window.rs index 8a4deba68cf62..92455a908b2eb 100644 --- a/crates/bevy_window/src/window.rs +++ b/crates/bevy_window/src/window.rs @@ -11,7 +11,7 @@ use log::warn; #[cfg(feature = "bevy_reflect")] use { bevy_ecs::prelude::ReflectComponent, - bevy_reflect::{Reflect, std_traits::ReflectDefault}, + bevy_reflect::{std_traits::ReflectDefault, Reflect}, }; #[cfg(all(feature = "serialize", feature = "bevy_reflect"))] diff --git a/crates/bevy_winit/src/converters.rs b/crates/bevy_winit/src/converters.rs index effdd444301ca..ba41c6253474d 100644 --- a/crates/bevy_winit/src/converters.rs +++ b/crates/bevy_winit/src/converters.rs @@ -1,9 +1,9 @@ use bevy_ecs::entity::Entity; use bevy_input::{ - ButtonState, keyboard::{KeyCode, KeyboardInput, NativeKeyCode}, mouse::MouseButton, touch::{ForceTouch, TouchInput, TouchPhase}, + ButtonState, }; use bevy_math::{CompassOctant, Vec2}; use bevy_window::SystemCursorIcon; diff --git a/crates/bevy_winit/src/cursor.rs b/crates/bevy_winit/src/cursor.rs index 022fd7f2fcdd1..6e601f24294d8 100644 --- a/crates/bevy_winit/src/cursor.rs +++ b/crates/bevy_winit/src/cursor.rs @@ -1,17 +1,17 @@ //! Components to customize winit cursor +use crate::{ + converters::convert_system_cursor_icon, + state::{CursorSource, PendingCursor}, +}; #[cfg(feature = "custom_cursor")] use crate::{ - WinitCustomCursor, custom_cursor::{ - CustomCursorPlugin, calculate_effective_rect, extract_and_transform_rgba_pixels, - extract_rgba_pixels, transform_hotspot, + calculate_effective_rect, extract_and_transform_rgba_pixels, extract_rgba_pixels, + transform_hotspot, CustomCursorPlugin, }, state::{CustomCursorCache, CustomCursorCacheKey}, -}; -use crate::{ - converters::convert_system_cursor_icon, - state::{CursorSource, PendingCursor}, + WinitCustomCursor, }; use bevy_app::{App, Last, Plugin}; #[cfg(feature = "custom_cursor")] @@ -31,7 +31,7 @@ use bevy_ecs::{ #[cfg(feature = "custom_cursor")] use bevy_image::{Image, TextureAtlasLayout}; use bevy_platform_support::collections::HashSet; -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_window::{SystemCursorIcon, Window}; #[cfg(feature = "custom_cursor")] use tracing::warn; @@ -134,9 +134,7 @@ fn update_cursors( }; let Some(rgba) = maybe_rgba else { - warn!( - "Cursor image {handle:?} not accepted because it's not rgba8 or rgba32float format" - ); + warn!("Cursor image {handle:?} not accepted because it's not rgba8 or rgba32float format"); continue; }; diff --git a/crates/bevy_winit/src/custom_cursor.rs b/crates/bevy_winit/src/custom_cursor.rs index d51f6c855b9d8..f6c90da6e20b8 100644 --- a/crates/bevy_winit/src/custom_cursor.rs +++ b/crates/bevy_winit/src/custom_cursor.rs @@ -1,8 +1,8 @@ use bevy_app::{App, Plugin}; use bevy_asset::{Assets, Handle}; use bevy_image::{Image, TextureAtlas, TextureAtlasLayout, TextureAtlasPlugin}; -use bevy_math::{Rect, URect, UVec2, Vec2, ops}; -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_math::{ops, Rect, URect, UVec2, Vec2}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use wgpu_types::TextureFormat; use crate::{cursor::CursorIcon, state::CustomCursorCache}; diff --git a/crates/bevy_winit/src/lib.rs b/crates/bevy_winit/src/lib.rs index 85fb69c8e963c..c2a3eddc52f04 100644 --- a/crates/bevy_winit/src/lib.rs +++ b/crates/bevy_winit/src/lib.rs @@ -15,8 +15,8 @@ extern crate alloc; use bevy_derive::Deref; -use bevy_reflect::Reflect; use bevy_reflect::prelude::ReflectDefault; +use bevy_reflect::Reflect; use bevy_window::{RawHandleWrapperHolder, WindowEvent}; use core::marker::PhantomData; use winit::{event_loop::EventLoop, window::WindowId}; @@ -24,7 +24,7 @@ use winit::{event_loop::EventLoop, window::WindowId}; use bevy_a11y::AccessibilityRequested; use bevy_app::{App, Last, Plugin}; use bevy_ecs::prelude::*; -use bevy_window::{Window, WindowCreated, exit_on_all_closed}; +use bevy_window::{exit_on_all_closed, Window, WindowCreated}; use system::{changed_windows, check_keyboard_focus_lost, despawn_windows}; pub use system::{create_monitors, create_windows}; #[cfg(all(target_family = "wasm", target_os = "unknown"))] diff --git a/crates/bevy_winit/src/state.rs b/crates/bevy_winit/src/state.rs index fdaf8f2e652eb..0c1a02e0ce0b4 100644 --- a/crates/bevy_winit/src/state.rs +++ b/crates/bevy_winit/src/state.rs @@ -19,7 +19,7 @@ use bevy_input::{ use bevy_log::{error, trace, warn}; #[cfg(feature = "custom_cursor")] use bevy_math::URect; -use bevy_math::{DVec2, Vec2, ivec2}; +use bevy_math::{ivec2, DVec2, Vec2}; #[cfg(feature = "custom_cursor")] use bevy_platform_support::collections::HashMap; use bevy_platform_support::time::Instant; @@ -47,11 +47,11 @@ use bevy_window::{ use bevy_window::{PrimaryWindow, RawHandleWrapper}; use crate::{ - AppSendEvent, CreateMonitorParams, CreateWindowParams, EventLoopProxyWrapper, - RawWinitWindowEvent, UpdateMode, WinitSettings, WinitWindows, accessibility::AccessKitAdapters, converters, create_windows, - system::{CachedWindow, create_monitors}, + system::{create_monitors, CachedWindow}, + AppSendEvent, CreateMonitorParams, CreateWindowParams, EventLoopProxyWrapper, + RawWinitWindowEvent, UpdateMode, WinitSettings, WinitWindows, }; /// Persistent state that is used to run the [`App`] according to the current diff --git a/crates/bevy_winit/src/system.rs b/crates/bevy_winit/src/system.rs index b71df7432a6f3..2c481f960878c 100644 --- a/crates/bevy_winit/src/system.rs +++ b/crates/bevy_winit/src/system.rs @@ -27,7 +27,6 @@ use winit::platform::ios::WindowExtIOS; use winit::platform::web::WindowExtWebSys; use crate::{ - CreateMonitorParams, CreateWindowParams, WinitWindows, converters::{ convert_enabled_buttons, convert_resize_direction, convert_window_level, convert_window_theme, convert_winit_theme, @@ -35,6 +34,7 @@ use crate::{ get_best_videomode, get_fitting_videomode, select_monitor, state::react_to_resize, winit_monitors::WinitMonitors, + CreateMonitorParams, CreateWindowParams, WinitWindows, }; /// Creates new windows on the [`winit`] backend for each entity with a newly-added @@ -532,9 +532,7 @@ pub(crate) fn changed_windows( cache.window.recognize_pan_gesture, ) { (Some(_), Some(_)) => { - warn!( - "Bevy currently doesn't support modifying PanGesture number of fingers recognition. Please disable it before re-enabling it with the new number of fingers" - ); + warn!("Bevy currently doesn't support modifying PanGesture number of fingers recognition. Please disable it before re-enabling it with the new number of fingers"); } (Some((min, max)), _) => winit_window.recognize_pan_gesture(true, min, max), _ => winit_window.recognize_pan_gesture(false, 0, 0), diff --git a/crates/bevy_winit/src/winit_windows.rs b/crates/bevy_winit/src/winit_windows.rs index c36d989ef224c..cae20f15afc84 100644 --- a/crates/bevy_winit/src/winit_windows.rs +++ b/crates/bevy_winit/src/winit_windows.rs @@ -19,7 +19,7 @@ use winit::{ use crate::{ accessibility::{ - AccessKitAdapters, WinitActionRequestHandlers, prepare_accessibility_for_window, + prepare_accessibility_for_window, AccessKitAdapters, WinitActionRequestHandlers, }, converters::{convert_enabled_buttons, convert_window_level, convert_window_theme}, winit_monitors::WinitMonitors, @@ -460,9 +460,7 @@ pub fn select_monitor( match monitor_selection { Current => { if current_monitor.is_none() { - warn!( - "Can't select current monitor on window creation or cannot find current monitor!" - ); + warn!("Can't select current monitor on window creation or cannot find current monitor!"); } current_monitor } diff --git a/examples/2d/cpu_draw.rs b/examples/2d/cpu_draw.rs index ba98e1051e8f7..f142f50d1d214 100644 --- a/examples/2d/cpu_draw.rs +++ b/examples/2d/cpu_draw.rs @@ -101,11 +101,7 @@ fn draw( ) { if *i == 0 { // Generate a random color on first run. - *draw_color = Color::linear_rgb( - seeded_rng.0.r#gen(), - seeded_rng.0.r#gen(), - seeded_rng.0.r#gen(), - ); + *draw_color = Color::linear_rgb(seeded_rng.0.r#gen(), seeded_rng.0.r#gen(), seeded_rng.0.r#gen()); } // Get the image from Bevy's asset storage. @@ -128,11 +124,7 @@ fn draw( // If the old color is our current color, change our drawing color. let tolerance = 1.0 / 255.0; if old_color.distance(&draw_color) <= tolerance { - *draw_color = Color::linear_rgb( - seeded_rng.0.r#gen(), - seeded_rng.0.r#gen(), - seeded_rng.0.r#gen(), - ); + *draw_color = Color::linear_rgb(seeded_rng.0.r#gen(), seeded_rng.0.r#gen(), seeded_rng.0.r#gen()); } // Set the new color, but keep old alpha value from image. diff --git a/examples/2d/mesh2d_arcs.rs b/examples/2d/mesh2d_arcs.rs index a39253d459deb..db66b784acd54 100644 --- a/examples/2d/mesh2d_arcs.rs +++ b/examples/2d/mesh2d_arcs.rs @@ -7,8 +7,8 @@ use std::f32::consts::FRAC_PI_2; use bevy::{ color::palettes::css::{BLUE, GRAY, RED}, math::{ - Isometry2d, bounding::{Bounded2d, BoundingVolume}, + Isometry2d, }, prelude::*, render::mesh::{CircularMeshUvMode, CircularSectorMeshBuilder, CircularSegmentMeshBuilder}, diff --git a/examples/2d/mesh2d_manual.rs b/examples/2d/mesh2d_manual.rs index aaf54606df380..ca99a71ba034c 100644 --- a/examples/2d/mesh2d_manual.rs +++ b/examples/2d/mesh2d_manual.rs @@ -8,11 +8,10 @@ use bevy::{ asset::weak_handle, color::palettes::basic::YELLOW, - core_pipeline::core_2d::{CORE_2D_DEPTH_FORMAT, Transparent2d}, - math::{FloatOrd, ops}, + core_pipeline::core_2d::{Transparent2d, CORE_2D_DEPTH_FORMAT}, + math::{ops, FloatOrd}, prelude::*, render::{ - Extract, Render, RenderApp, RenderSet, mesh::{Indices, MeshVertexAttribute, RenderMesh}, render_asset::{RenderAssetUsages, RenderAssets}, render_phase::{ @@ -28,11 +27,12 @@ use bevy::{ }, sync_world::MainEntityHashMap, view::{ExtractedView, RenderVisibleEntities, ViewTarget}, + Extract, Render, RenderApp, RenderSet, }, sprite::{ - DrawMesh2d, Material2dBindGroupId, Mesh2dPipeline, Mesh2dPipelineKey, Mesh2dTransforms, - MeshFlags, RenderMesh2dInstance, SetMesh2dBindGroup, SetMesh2dViewBindGroup, - extract_mesh2d, + extract_mesh2d, DrawMesh2d, Material2dBindGroupId, Mesh2dPipeline, Mesh2dPipelineKey, + Mesh2dTransforms, MeshFlags, RenderMesh2dInstance, SetMesh2dBindGroup, + SetMesh2dViewBindGroup, }, }; use std::f32::consts::PI; diff --git a/examples/2d/wireframe_2d.rs b/examples/2d/wireframe_2d.rs index b6cd2a3cc4c83..fe4cc261870dd 100644 --- a/examples/2d/wireframe_2d.rs +++ b/examples/2d/wireframe_2d.rs @@ -12,9 +12,9 @@ use bevy::{ color::palettes::basic::{GREEN, RED, WHITE}, prelude::*, render::{ - RenderPlugin, render_resource::WgpuFeatures, settings::{RenderCreation, WgpuSettings}, + RenderPlugin, }, sprite::{NoWireframe2d, Wireframe2d, Wireframe2dColor, Wireframe2dConfig, Wireframe2dPlugin}, }; diff --git a/examples/3d/atmosphere.rs b/examples/3d/atmosphere.rs index 02a05e100aa98..53c5c91dfa687 100644 --- a/examples/3d/atmosphere.rs +++ b/examples/3d/atmosphere.rs @@ -4,7 +4,7 @@ use std::f32::consts::PI; use bevy::{ core_pipeline::{bloom::Bloom, tonemapping::Tonemapping}, - pbr::{Atmosphere, AtmosphereSettings, CascadeShadowConfigBuilder, light_consts::lux}, + pbr::{light_consts::lux, Atmosphere, AtmosphereSettings, CascadeShadowConfigBuilder}, prelude::*, render::camera::Exposure, }; diff --git a/examples/3d/auto_exposure.rs b/examples/3d/auto_exposure.rs index 0b2b8ef644e34..79fece61c8e36 100644 --- a/examples/3d/auto_exposure.rs +++ b/examples/3d/auto_exposure.rs @@ -13,8 +13,8 @@ use bevy::{ core_pipeline::{ - Skybox, auto_exposure::{AutoExposure, AutoExposureCompensationCurve, AutoExposurePlugin}, + Skybox, }, math::{cubic_splines::LinearSpline, primitives::Plane3d, vec2}, prelude::*, diff --git a/examples/3d/clearcoat.rs b/examples/3d/clearcoat.rs index 2c092ffbfc721..c04b12d5814ed 100644 --- a/examples/3d/clearcoat.rs +++ b/examples/3d/clearcoat.rs @@ -21,7 +21,7 @@ use std::f32::consts::PI; use bevy::{ color::palettes::css::{BLUE, GOLD, WHITE}, - core_pipeline::{Skybox, tonemapping::Tonemapping::AcesFitted}, + core_pipeline::{tonemapping::Tonemapping::AcesFitted, Skybox}, image::ImageLoaderSettings, math::vec3, prelude::*, diff --git a/examples/3d/clustered_decals.rs b/examples/3d/clustered_decals.rs index 4031a7627bca6..108efe586ef1e 100644 --- a/examples/3d/clustered_decals.rs +++ b/examples/3d/clustered_decals.rs @@ -8,8 +8,8 @@ use bevy::{ color::palettes::css::{LIME, ORANGE_RED, SILVER}, input::mouse::AccumulatedMouseMotion, pbr::{ - ExtendedMaterial, MaterialExtension, decal::{self, clustered::ClusteredDecal}, + ExtendedMaterial, MaterialExtension, }, prelude::*, render::{ @@ -21,8 +21,8 @@ use bevy::{ }; use ops::{acos, cos, sin}; use widgets::{ - BUTTON_BORDER, BUTTON_BORDER_COLOR, BUTTON_BORDER_RADIUS_SIZE, BUTTON_PADDING, - WidgetClickEvent, WidgetClickSender, + WidgetClickEvent, WidgetClickSender, BUTTON_BORDER, BUTTON_BORDER_COLOR, + BUTTON_BORDER_RADIUS_SIZE, BUTTON_PADDING, }; #[path = "../helpers/widgets.rs"] diff --git a/examples/3d/edit_material_on_gltf.rs b/examples/3d/edit_material_on_gltf.rs index 73fc0c8648b06..f9de5842a92fe 100644 --- a/examples/3d/edit_material_on_gltf.rs +++ b/examples/3d/edit_material_on_gltf.rs @@ -1,16 +1,16 @@ //! Showcases how to change the material of a `Scene` spawned from a Gltf use bevy::{ - DefaultPlugins, app::{App, PluginGroup, Startup}, asset::{AssetServer, Assets}, audio::AudioPlugin, - color::{Color, palettes}, + color::{palettes, Color}, gltf::GltfAssetLabel, math::{Dir3, Vec3}, pbr::{DirectionalLight, MeshMaterial3d, StandardMaterial}, prelude::{Camera3d, Children, Commands, Component, Query, Res, ResMut, Transform, Trigger}, scene::{SceneInstanceReady, SceneRoot}, + DefaultPlugins, }; fn main() { diff --git a/examples/3d/fog.rs b/examples/3d/fog.rs index 9793ae0ad356a..ed2a2a0dd6867 100644 --- a/examples/3d/fog.rs +++ b/examples/3d/fog.rs @@ -185,7 +185,11 @@ fn update_system( } // Linear Fog Controls - if let FogFalloff::Linear { start, end } = &mut fog.falloff { + if let FogFalloff::Linear { + start, + end, + } = &mut fog.falloff + { text.push_str("\nA / S - Move Start Distance\nZ / X - Move End Distance"); if keycode.pressed(KeyCode::KeyA) { diff --git a/examples/3d/irradiance_volumes.rs b/examples/3d/irradiance_volumes.rs index dcb03396847e1..31529c421986d 100644 --- a/examples/3d/irradiance_volumes.rs +++ b/examples/3d/irradiance_volumes.rs @@ -18,7 +18,7 @@ use bevy::{ core_pipeline::Skybox, math::{uvec3, vec3}, pbr::{ - ExtendedMaterial, MaterialExtension, NotShadowCaster, irradiance_volume::IrradianceVolume, + irradiance_volume::IrradianceVolume, ExtendedMaterial, MaterialExtension, NotShadowCaster, }, prelude::*, render::render_resource::{AsBindGroup, ShaderRef, ShaderType}, diff --git a/examples/3d/meshlet.rs b/examples/3d/meshlet.rs index 3fdb144bf63e9..0bab7d750198c 100644 --- a/examples/3d/meshlet.rs +++ b/examples/3d/meshlet.rs @@ -7,8 +7,8 @@ mod camera_controller; use bevy::{ pbr::{ - CascadeShadowConfigBuilder, DirectionalLightShadowMap, experimental::meshlet::{MeshletMesh3d, MeshletPlugin}, + CascadeShadowConfigBuilder, DirectionalLightShadowMap, }, prelude::*, render::render_resource::AsBindGroup, @@ -16,13 +16,12 @@ use bevy::{ use camera_controller::{CameraController, CameraControllerPlugin}; use std::{f32::consts::PI, path::Path, process::ExitCode}; -const ASSET_URL: &str = "https://raw.githubusercontent.com/JMS55/bevy_meshlet_asset/7a7c14138021f63904b584d5f7b73b695c7f4bbf/bunny.meshlet_mesh"; +const ASSET_URL: &str = + "https://raw.githubusercontent.com/JMS55/bevy_meshlet_asset/7a7c14138021f63904b584d5f7b73b695c7f4bbf/bunny.meshlet_mesh"; fn main() -> ExitCode { if !Path::new("./assets/external/models/bunny.meshlet_mesh").exists() { - eprintln!( - "ERROR: Asset at path /assets/external/models/bunny.meshlet_mesh is missing. Please download it from {ASSET_URL}" - ); + eprintln!("ERROR: Asset at path /assets/external/models/bunny.meshlet_mesh is missing. Please download it from {ASSET_URL}"); return ExitCode::FAILURE; } diff --git a/examples/3d/occlusion_culling.rs b/examples/3d/occlusion_culling.rs index 5ffa5ef4c5af8..4c69db0a4a101 100644 --- a/examples/3d/occlusion_culling.rs +++ b/examples/3d/occlusion_culling.rs @@ -17,15 +17,14 @@ use bevy::{ color::palettes::css::{SILVER, WHITE}, core_pipeline::{ core_3d::{ - Opaque3d, graph::{Core3d, Node3d}, + Opaque3d, }, prepass::DepthPrepass, }, pbr::PbrPlugin, prelude::*, render::{ - Render, RenderApp, RenderDebugFlags, RenderPlugin, RenderSet, batching::gpu_preprocessing::{ GpuPreprocessingMode, GpuPreprocessingSupport, IndirectParametersBuffers, IndirectParametersIndexed, @@ -35,6 +34,7 @@ use bevy::{ render_resource::{Buffer, BufferDescriptor, BufferUsages, MapMode}, renderer::{RenderAdapter, RenderContext, RenderDevice}, settings::WgpuFeatures, + Render, RenderApp, RenderDebugFlags, RenderPlugin, RenderSet, }, }; use bytemuck::Pod; diff --git a/examples/3d/pcss.rs b/examples/3d/pcss.rs index 8d3965c20c63e..0f96396cb0e9c 100644 --- a/examples/3d/pcss.rs +++ b/examples/3d/pcss.rs @@ -4,9 +4,9 @@ use std::f32::consts::PI; use bevy::{ core_pipeline::{ - Skybox, experimental::taa::{TemporalAntiAliasPlugin, TemporalAntiAliasing}, prepass::{DepthPrepass, MotionVectorPrepass}, + Skybox, }, math::vec3, pbr::{CubemapVisibleEntities, ShadowFilteringMethod, VisibleMeshEntities}, diff --git a/examples/3d/rotate_environment_map.rs b/examples/3d/rotate_environment_map.rs index 59f8c3ba7dcd0..68ecceeccf7de 100644 --- a/examples/3d/rotate_environment_map.rs +++ b/examples/3d/rotate_environment_map.rs @@ -4,7 +4,7 @@ use std::f32::consts::PI; use bevy::{ color::palettes::css::{GOLD, WHITE}, - core_pipeline::{Skybox, tonemapping::Tonemapping::AcesFitted}, + core_pipeline::{tonemapping::Tonemapping::AcesFitted, Skybox}, image::ImageLoaderSettings, prelude::*, }; diff --git a/examples/3d/ssr.rs b/examples/3d/ssr.rs index bef631b0abdea..9d0026fbbcf98 100644 --- a/examples/3d/ssr.rs +++ b/examples/3d/ssr.rs @@ -4,7 +4,7 @@ use std::ops::Range; use bevy::{ color::palettes::css::{BLACK, WHITE}, - core_pipeline::{Skybox, fxaa::Fxaa}, + core_pipeline::{fxaa::Fxaa, Skybox}, image::{ ImageAddressMode, ImageFilterMode, ImageLoaderSettings, ImageSampler, ImageSamplerDescriptor, diff --git a/examples/3d/visibility_range.rs b/examples/3d/visibility_range.rs index 0765a1156a558..013b39d8d1e2c 100644 --- a/examples/3d/visibility_range.rs +++ b/examples/3d/visibility_range.rs @@ -6,7 +6,7 @@ use bevy::{ core_pipeline::prepass::{DepthPrepass, NormalPrepass}, input::mouse::MouseWheel, math::vec3, - pbr::{CascadeShadowConfigBuilder, light_consts::lux::FULL_DAYLIGHT}, + pbr::{light_consts::lux::FULL_DAYLIGHT, CascadeShadowConfigBuilder}, prelude::*, render::view::VisibilityRange, }; diff --git a/examples/3d/volumetric_fog.rs b/examples/3d/volumetric_fog.rs index 6e8a3445f9913..9cfef624c6594 100644 --- a/examples/3d/volumetric_fog.rs +++ b/examples/3d/volumetric_fog.rs @@ -2,7 +2,7 @@ use bevy::{ color::palettes::css::RED, - core_pipeline::{Skybox, bloom::Bloom, tonemapping::Tonemapping}, + core_pipeline::{bloom::Bloom, tonemapping::Tonemapping, Skybox}, math::vec3, pbr::{FogVolume, VolumetricFog, VolumetricLight}, prelude::*, diff --git a/examples/3d/wireframe.rs b/examples/3d/wireframe.rs index babee4bd2becb..e62e9f0029537 100644 --- a/examples/3d/wireframe.rs +++ b/examples/3d/wireframe.rs @@ -13,9 +13,9 @@ use bevy::{ pbr::wireframe::{NoWireframe, Wireframe, WireframeColor, WireframeConfig, WireframePlugin}, prelude::*, render::{ - RenderPlugin, render_resource::WgpuFeatures, settings::{RenderCreation, WgpuSettings}, + RenderPlugin, }, }; diff --git a/examples/animation/animated_transform.rs b/examples/animation/animated_transform.rs index caa0717ce7ac2..decb3d34a69df 100644 --- a/examples/animation/animated_transform.rs +++ b/examples/animation/animated_transform.rs @@ -3,7 +3,7 @@ use std::f32::consts::PI; use bevy::{ - animation::{AnimationTarget, AnimationTargetId, animated_field}, + animation::{animated_field, AnimationTarget, AnimationTargetId}, prelude::*, }; diff --git a/examples/animation/animated_ui.rs b/examples/animation/animated_ui.rs index 349d24899a510..f31b2ccd5eb4b 100644 --- a/examples/animation/animated_ui.rs +++ b/examples/animation/animated_ui.rs @@ -2,8 +2,8 @@ use bevy::{ animation::{ - AnimationEntityMut, AnimationEvaluationError, AnimationTarget, AnimationTargetId, - animated_field, + animated_field, AnimationEntityMut, AnimationEvaluationError, AnimationTarget, + AnimationTargetId, }, prelude::*, }; diff --git a/examples/animation/custom_skinned_mesh.rs b/examples/animation/custom_skinned_mesh.rs index 356fbbb2a5b88..b091f2dd4254c 100644 --- a/examples/animation/custom_skinned_mesh.rs +++ b/examples/animation/custom_skinned_mesh.rs @@ -8,8 +8,8 @@ use bevy::{ prelude::*, render::{ mesh::{ - Indices, PrimitiveTopology, VertexAttributeValues, skinning::{SkinnedMesh, SkinnedMeshInverseBindposes}, + Indices, PrimitiveTopology, VertexAttributeValues, }, render_asset::RenderAssetUsages, }, diff --git a/examples/animation/eased_motion.rs b/examples/animation/eased_motion.rs index 53f9aa876bae9..f6254cd65de35 100644 --- a/examples/animation/eased_motion.rs +++ b/examples/animation/eased_motion.rs @@ -3,7 +3,7 @@ use std::f32::consts::FRAC_PI_2; use bevy::{ - animation::{AnimationTarget, AnimationTargetId, animated_field}, + animation::{animated_field, AnimationTarget, AnimationTargetId}, color::palettes::css::{ORANGE, SILVER}, math::vec3, prelude::*, diff --git a/examples/app/headless.rs b/examples/app/headless.rs index 316a2892ae7f4..536da8c26e0a9 100644 --- a/examples/app/headless.rs +++ b/examples/app/headless.rs @@ -15,9 +15,7 @@ use core::time::Duration; fn main() { if cfg!(feature = "bevy_window") { - println!( - "This example is running with the bevy_window feature enabled and will not run headless." - ); + println!("This example is running with the bevy_window feature enabled and will not run headless."); println!("Disable the default features and rerun the example to run headless."); println!("To do so, run:"); println!(); diff --git a/examples/app/headless_renderer.rs b/examples/app/headless_renderer.rs index 8dab39236bed5..619404dc901c5 100644 --- a/examples/app/headless_renderer.rs +++ b/examples/app/headless_renderer.rs @@ -13,7 +13,6 @@ use bevy::{ image::TextureFormatPixelInfo, prelude::*, render::{ - Extract, Render, RenderApp, RenderSet, camera::RenderTarget, render_asset::{RenderAssetUsages, RenderAssets}, render_graph::{self, NodeRunError, RenderGraph, RenderGraphContext, RenderLabel}, @@ -23,6 +22,7 @@ use bevy::{ TextureUsages, }, renderer::{RenderContext, RenderDevice, RenderQueue}, + Extract, Render, RenderApp, RenderSet, }, winit::WinitPlugin, }; @@ -31,8 +31,8 @@ use std::{ ops::{Deref, DerefMut}, path::PathBuf, sync::{ - Arc, atomic::{AtomicBool, Ordering}, + Arc, }, time::Duration, }; diff --git a/examples/app/log_layers.rs b/examples/app/log_layers.rs index 7c710336b3f74..558d5b2ba5a48 100644 --- a/examples/app/log_layers.rs +++ b/examples/app/log_layers.rs @@ -2,9 +2,9 @@ use bevy::{ log::{ - BoxedLayer, tracing::{self, Subscriber}, tracing_subscriber::Layer, + BoxedLayer, }, prelude::*, }; diff --git a/examples/app/log_layers_ecs.rs b/examples/app/log_layers_ecs.rs index d69ee9fca3cdb..30cba02b8ddb8 100644 --- a/examples/app/log_layers_ecs.rs +++ b/examples/app/log_layers_ecs.rs @@ -15,9 +15,9 @@ use std::sync::mpsc; use bevy::{ log::{ - BoxedLayer, Level, tracing::{self, Subscriber}, tracing_subscriber::{self, Layer}, + BoxedLayer, Level, }, prelude::*, }; diff --git a/examples/app/no_renderer.rs b/examples/app/no_renderer.rs index 8b0059b924b9c..5109bba128c8f 100644 --- a/examples/app/no_renderer.rs +++ b/examples/app/no_renderer.rs @@ -6,7 +6,7 @@ use bevy::{ prelude::*, - render::{RenderPlugin, settings::WgpuSettings}, + render::{settings::WgpuSettings, RenderPlugin}, }; fn main() { diff --git a/examples/asset/asset_decompression.rs b/examples/asset/asset_decompression.rs index 1eb3afe2f3b8e..edc42ab853fb3 100644 --- a/examples/asset/asset_decompression.rs +++ b/examples/asset/asset_decompression.rs @@ -2,8 +2,8 @@ use bevy::{ asset::{ - AssetLoader, CompleteErasedLoadedAsset, LoadContext, LoadDirectError, io::{Reader, VecReader}, + AssetLoader, CompleteErasedLoadedAsset, LoadContext, LoadDirectError, }, prelude::*, reflect::TypePath, diff --git a/examples/asset/asset_loading.rs b/examples/asset/asset_loading.rs index 28ab31fe98bdc..88867ea458b8b 100644 --- a/examples/asset/asset_loading.rs +++ b/examples/asset/asset_loading.rs @@ -36,17 +36,14 @@ fn setup( ); // All assets end up in their Assets collection once they are done loading: - match meshes.get(&sphere_handle) { - Some(sphere) => { - // You might notice that this doesn't run! This is because assets load in parallel without - // blocking. When an asset has loaded, it will appear in relevant Assets - // collection. - info!("{:?}", sphere.primitive_topology()); - } - _ => { - info!("sphere hasn't loaded yet"); - } - } + match meshes.get(&sphere_handle) { Some(sphere) => { + // You might notice that this doesn't run! This is because assets load in parallel without + // blocking. When an asset has loaded, it will appear in relevant Assets + // collection. + info!("{:?}", sphere.primitive_topology()); + } _ => { + info!("sphere hasn't loaded yet"); + }} // You can load all assets in a folder like this. They will be loaded in parallel without // blocking. The LoadedFolder asset holds handles to each asset in the folder. These are all diff --git a/examples/asset/custom_asset.rs b/examples/asset/custom_asset.rs index fdfd010cc463b..8d4ac958ecdd1 100644 --- a/examples/asset/custom_asset.rs +++ b/examples/asset/custom_asset.rs @@ -1,7 +1,7 @@ //! Implements loader for a custom asset type. use bevy::{ - asset::{AssetLoader, LoadContext, io::Reader}, + asset::{io::Reader, AssetLoader, LoadContext}, prelude::*, reflect::TypePath, }; diff --git a/examples/asset/embedded_asset.rs b/examples/asset/embedded_asset.rs index 689969aedca5f..66349cfc5aef8 100644 --- a/examples/asset/embedded_asset.rs +++ b/examples/asset/embedded_asset.rs @@ -1,7 +1,7 @@ //! Example of loading an embedded asset. use bevy::{ - asset::{AssetPath, embedded_asset, io::AssetSourceId}, + asset::{embedded_asset, io::AssetSourceId, AssetPath}, prelude::*, }; use std::path::Path; diff --git a/examples/asset/extra_source.rs b/examples/asset/extra_source.rs index cf6e07bf267f4..298b9d4aa85c7 100644 --- a/examples/asset/extra_source.rs +++ b/examples/asset/extra_source.rs @@ -3,8 +3,8 @@ use bevy::{ asset::{ - AssetPath, io::{AssetSourceBuilder, AssetSourceId}, + AssetPath, }, prelude::*, }; diff --git a/examples/asset/multi_asset_sync.rs b/examples/asset/multi_asset_sync.rs index af84dea08b30f..758bb4a06d01c 100644 --- a/examples/asset/multi_asset_sync.rs +++ b/examples/asset/multi_asset_sync.rs @@ -4,8 +4,8 @@ use std::{ f32::consts::PI, ops::Drop, sync::{ - Arc, atomic::{AtomicBool, AtomicU32, Ordering}, + Arc, }, }; diff --git a/examples/asset/processing/asset_processing.rs b/examples/asset/processing/asset_processing.rs index c3948c4a9412f..b24f7afb14bc1 100644 --- a/examples/asset/processing/asset_processing.rs +++ b/examples/asset/processing/asset_processing.rs @@ -2,11 +2,12 @@ use bevy::{ asset::{ - AssetLoader, AsyncWriteExt, LoadContext, embedded_asset, + embedded_asset, io::{Reader, Writer}, processor::LoadTransformAndSave, saver::{AssetSaver, SavedAsset}, transformer::{AssetTransformer, TransformedAsset}, + AssetLoader, AsyncWriteExt, LoadContext, }, prelude::*, reflect::TypePath, diff --git a/examples/async_tasks/async_compute.rs b/examples/async_tasks/async_compute.rs index af9a0bb1cf3ce..0b5a044563528 100644 --- a/examples/async_tasks/async_compute.rs +++ b/examples/async_tasks/async_compute.rs @@ -4,7 +4,7 @@ use bevy::{ ecs::{system::SystemState, world::CommandQueue}, prelude::*, - tasks::{AsyncComputeTaskPool, Task, block_on, futures_lite::future}, + tasks::{block_on, futures_lite::future, AsyncComputeTaskPool, Task}, }; use rand::Rng; use std::time::Duration; diff --git a/examples/async_tasks/external_source_external_thread.rs b/examples/async_tasks/external_source_external_thread.rs index 94ba29a6ee98f..92c7c60a82968 100644 --- a/examples/async_tasks/external_source_external_thread.rs +++ b/examples/async_tasks/external_source_external_thread.rs @@ -2,7 +2,7 @@ use bevy::prelude::*; // Using crossbeam_channel instead of std as std `Receiver` is `!Sync` -use crossbeam_channel::{Receiver, bounded}; +use crossbeam_channel::{bounded, Receiver}; use rand::{Rng, SeedableRng}; use rand_chacha::ChaCha8Rng; diff --git a/examples/ecs/fallible_systems.rs b/examples/ecs/fallible_systems.rs index 42f4a425da554..59e82371a353a 100644 --- a/examples/ecs/fallible_systems.rs +++ b/examples/ecs/fallible_systems.rs @@ -5,8 +5,8 @@ use bevy::ecs::world::DeferredWorld; use bevy::math::sampling::UniformMeshSampler; use bevy::prelude::*; -use rand::SeedableRng; use rand::distributions::Distribution; +use rand::SeedableRng; use rand_chacha::ChaCha8Rng; fn main() { diff --git a/examples/ecs/iter_combinations.rs b/examples/ecs/iter_combinations.rs index 08b827ff80062..b112a0a698a24 100644 --- a/examples/ecs/iter_combinations.rs +++ b/examples/ecs/iter_combinations.rs @@ -121,12 +121,8 @@ fn generate_bodies( fn interact_bodies(mut query: Query<(&Mass, &GlobalTransform, &mut Acceleration)>) { let mut iter = query.iter_combinations_mut(); - while let Some( - [ - (Mass(m1), transform1, mut acc1), - (Mass(m2), transform2, mut acc2), - ], - ) = iter.fetch_next() + while let Some([(Mass(m1), transform1, mut acc1), (Mass(m2), transform2, mut acc2)]) = + iter.fetch_next() { let delta = transform2.translation() - transform1.translation(); let distance_sq: f32 = delta.length_squared(); diff --git a/examples/ecs/observer_propagation.rs b/examples/ecs/observer_propagation.rs index 97129876ea85d..0ca64686d0156 100644 --- a/examples/ecs/observer_propagation.rs +++ b/examples/ecs/observer_propagation.rs @@ -3,7 +3,7 @@ use std::time::Duration; use bevy::{log::LogPlugin, prelude::*, time::common_conditions::on_timer}; -use rand::{Rng, seq::IteratorRandom, thread_rng}; +use rand::{seq::IteratorRandom, thread_rng, Rng}; fn main() { App::new() diff --git a/examples/ecs/run_conditions.rs b/examples/ecs/run_conditions.rs index 3c3d8629c1b4b..47c4c76d818e1 100644 --- a/examples/ecs/run_conditions.rs +++ b/examples/ecs/run_conditions.rs @@ -5,9 +5,7 @@ use bevy::prelude::*; fn main() { println!(); println!("For the first 2 seconds you will not be able to increment the counter"); - println!( - "Once that time has passed you can press space, enter, left mouse, right mouse or touch the screen to increment the counter" - ); + println!("Once that time has passed you can press space, enter, left mouse, right mouse or touch the screen to increment the counter"); println!(); App::new() diff --git a/examples/ecs/system_piping.rs b/examples/ecs/system_piping.rs index 9436aca6c2530..a3607c085de6d 100644 --- a/examples/ecs/system_piping.rs +++ b/examples/ecs/system_piping.rs @@ -4,7 +4,7 @@ use bevy::prelude::*; use std::num::ParseIntError; -use bevy::log::{Level, LogPlugin, debug, error, info}; +use bevy::log::{debug, error, info, Level, LogPlugin}; fn main() { App::new() diff --git a/examples/games/alien_cake_addict.rs b/examples/games/alien_cake_addict.rs index da603a39dc25f..67267a8b6fac2 100644 --- a/examples/games/alien_cake_addict.rs +++ b/examples/games/alien_cake_addict.rs @@ -271,30 +271,25 @@ fn focus_camera( ) { const SPEED: f32 = 2.0; // if there is both a player and a bonus, target the mid-point of them - match (game.player.entity, game.bonus.entity) { - (Some(player_entity), Some(bonus_entity)) => { - let transform_query = transforms.p1(); - if let (Ok(player_transform), Ok(bonus_transform)) = ( - transform_query.get(player_entity), - transform_query.get(bonus_entity), - ) { - game.camera_should_focus = player_transform - .translation - .lerp(bonus_transform.translation, 0.5); - } - // otherwise, if there is only a player, target the player + match (game.player.entity, game.bonus.entity) { (Some(player_entity), Some(bonus_entity)) => { + let transform_query = transforms.p1(); + if let (Ok(player_transform), Ok(bonus_transform)) = ( + transform_query.get(player_entity), + transform_query.get(bonus_entity), + ) { + game.camera_should_focus = player_transform + .translation + .lerp(bonus_transform.translation, 0.5); } - _ => { - if let Some(player_entity) = game.player.entity { - if let Ok(player_transform) = transforms.p1().get(player_entity) { - game.camera_should_focus = player_transform.translation; - } - // otherwise, target the middle - } else { - game.camera_should_focus = Vec3::from(RESET_FOCUS); - } + // otherwise, if there is only a player, target the player + } _ => if let Some(player_entity) = game.player.entity { + if let Ok(player_transform) = transforms.p1().get(player_entity) { + game.camera_should_focus = player_transform.translation; } - } + // otherwise, target the middle + } else { + game.camera_should_focus = Vec3::from(RESET_FOCUS); + }} // calculate the camera motion based on the difference between where the camera is looking // and where it should be looking; the greater the distance, the faster the motion; // smooth out the camera movement using the frame time diff --git a/examples/games/game_menu.rs b/examples/games/game_menu.rs index fdc9dac508fa8..03056cbe30151 100644 --- a/examples/games/game_menu.rs +++ b/examples/games/game_menu.rs @@ -48,7 +48,7 @@ fn setup(mut commands: Commands) { mod splash { use bevy::prelude::*; - use super::{GameState, despawn_screen}; + use super::{despawn_screen, GameState}; // This plugin will display a splash screen with Bevy logo for 1 second before switching to the menu pub fn splash_plugin(app: &mut App) { @@ -113,7 +113,7 @@ mod game { prelude::*, }; - use super::{DisplayQuality, GameState, TEXT_COLOR, Volume, despawn_screen}; + use super::{despawn_screen, DisplayQuality, GameState, Volume, TEXT_COLOR}; // This plugin will contain the game. In this case, it's just be a screen that will // display the current settings for 5 seconds before returning to the menu @@ -229,7 +229,7 @@ mod menu { prelude::*, }; - use super::{DisplayQuality, GameState, TEXT_COLOR, Volume, despawn_screen}; + use super::{despawn_screen, DisplayQuality, GameState, Volume, TEXT_COLOR}; // This plugin manages the menu, with 5 different screens: // - a main menu with "New Game", "Settings", "Quit" diff --git a/examples/math/bounding_2d.rs b/examples/math/bounding_2d.rs index 9b6539c875689..8fbb41d784456 100644 --- a/examples/math/bounding_2d.rs +++ b/examples/math/bounding_2d.rs @@ -2,7 +2,7 @@ use bevy::{ color::palettes::css::*, - math::{Isometry2d, bounding::*, ops}, + math::{bounding::*, ops, Isometry2d}, prelude::*, }; diff --git a/examples/math/cubic_splines.rs b/examples/math/cubic_splines.rs index ec5a266936b18..d4c74c7c73bc3 100644 --- a/examples/math/cubic_splines.rs +++ b/examples/math/cubic_splines.rs @@ -5,7 +5,7 @@ use bevy::{ color::*, ecs::system::Commands, gizmos::gizmos::Gizmos, - input::{ButtonState, mouse::MouseButtonInput}, + input::{mouse::MouseButtonInput, ButtonState}, math::{cubic_splines::*, vec2}, prelude::*, }; diff --git a/examples/math/custom_primitives.rs b/examples/math/custom_primitives.rs index 3a7c880691e02..a072b4476412c 100644 --- a/examples/math/custom_primitives.rs +++ b/examples/math/custom_primitives.rs @@ -7,10 +7,10 @@ use bevy::{ color::palettes::css::{RED, WHITE}, input::common_conditions::input_just_pressed, math::{ - Isometry2d, bounding::{ Aabb2d, Bounded2d, Bounded3d, BoundedExtrusion, BoundingCircle, BoundingVolume, }, + Isometry2d, }, prelude::*, render::{ diff --git a/examples/math/random_sampling.rs b/examples/math/random_sampling.rs index 8696fcf8f31de..33018c7734c8e 100644 --- a/examples/math/random_sampling.rs +++ b/examples/math/random_sampling.rs @@ -6,7 +6,7 @@ use bevy::{ prelude::*, render::mesh::SphereKind, }; -use rand::{SeedableRng, distributions::Distribution}; +use rand::{distributions::Distribution, SeedableRng}; use rand_chacha::ChaCha8Rng; fn main() { diff --git a/examples/math/sampling_primitives.rs b/examples/math/sampling_primitives.rs index 082edd679d393..446f6c911fe06 100644 --- a/examples/math/sampling_primitives.rs +++ b/examples/math/sampling_primitives.rs @@ -8,7 +8,7 @@ use bevy::{ math::prelude::*, prelude::*, }; -use rand::{Rng, SeedableRng, seq::SliceRandom}; +use rand::{seq::SliceRandom, Rng, SeedableRng}; use rand_chacha::ChaCha8Rng; fn main() { diff --git a/examples/movement/smooth_follow.rs b/examples/movement/smooth_follow.rs index b74f57b3cce99..ccf31e7cf66ee 100644 --- a/examples/movement/smooth_follow.rs +++ b/examples/movement/smooth_follow.rs @@ -1,7 +1,7 @@ //! This example demonstrates how to use interpolation to make one entity smoothly follow another. use bevy::{ - math::{NormedVectorSpace, prelude::*, vec3}, + math::{prelude::*, vec3, NormedVectorSpace}, prelude::*, }; use rand::SeedableRng; diff --git a/examples/reflection/dynamic_types.rs b/examples/reflection/dynamic_types.rs index 88306d1d60ff7..387fe7d0ed34d 100644 --- a/examples/reflection/dynamic_types.rs +++ b/examples/reflection/dynamic_types.rs @@ -1,10 +1,10 @@ //! This example demonstrates the use of dynamic types in Bevy's reflection system. use bevy::reflect::{ - DynamicArray, DynamicEnum, DynamicList, DynamicMap, DynamicSet, DynamicStruct, DynamicTuple, + reflect_trait, serde::TypedReflectDeserializer, std_traits::ReflectDefault, DynamicArray, + DynamicEnum, DynamicList, DynamicMap, DynamicSet, DynamicStruct, DynamicTuple, DynamicTupleStruct, DynamicVariant, FromReflect, PartialReflect, Reflect, ReflectFromReflect, - Set, TypeRegistry, Typed, reflect_trait, serde::TypedReflectDeserializer, - std_traits::ReflectDefault, + Set, TypeRegistry, Typed, }; use serde::de::DeserializeSeed; use std::collections::{HashMap, HashSet}; @@ -87,12 +87,10 @@ fn main() { // since it doesn't implement `Reflect`, only `PartialReflect`. // Similarly, trying to force the operation will fail. // This fails since the underlying type of `deserialized` is `DynamicStruct` and not `Player`. - assert!( - deserialized - .try_as_reflect() - .and_then(|reflect_trait_obj| reflect_identifiable.get(reflect_trait_obj)) - .is_none() - ); + assert!(deserialized + .try_as_reflect() + .and_then(|reflect_trait_obj| reflect_identifiable.get(reflect_trait_obj)) + .is_none()); // So how can we go from a dynamic type to a concrete type? // There are two ways: @@ -149,17 +147,13 @@ fn main() { assert_eq!(my_list, vec![1, 2, 3]); // And if you want it to actually proxy a type, you can configure it to do that as well: - assert!( - !my_dynamic_list - .as_partial_reflect() - .represents::>() - ); + assert!(!my_dynamic_list + .as_partial_reflect() + .represents::>()); my_dynamic_list.set_represented_type(Some(>::type_info())); - assert!( - my_dynamic_list - .as_partial_reflect() - .represents::>() - ); + assert!(my_dynamic_list + .as_partial_reflect() + .represents::>()); // ============================= REFERENCE ============================= // // For reference, here are all the available dynamic types: diff --git a/examples/reflection/function_reflection.rs b/examples/reflection/function_reflection.rs index 578603dc4ead2..4a4f97497ec67 100644 --- a/examples/reflection/function_reflection.rs +++ b/examples/reflection/function_reflection.rs @@ -7,11 +7,11 @@ //! processing deserialized reflection data, or even just storing type-erased versions of your functions. use bevy::reflect::{ - PartialReflect, Reflect, func::{ ArgList, DynamicFunction, DynamicFunctionMut, FunctionResult, IntoFunction, IntoFunctionMut, Return, SignatureInfo, }, + PartialReflect, Reflect, }; // Note that the `dbg!` invocations are used purely for demonstration purposes diff --git a/examples/reflection/reflection.rs b/examples/reflection/reflection.rs index 369cebf0dd1a7..f2130c35de37f 100644 --- a/examples/reflection/reflection.rs +++ b/examples/reflection/reflection.rs @@ -7,8 +7,8 @@ use bevy::{ prelude::*, reflect::{ - DynamicStruct, PartialReflect, serde::{ReflectDeserializer, ReflectSerializer}, + DynamicStruct, PartialReflect, }, }; use serde::de::DeserializeSeed; diff --git a/examples/remote/client.rs b/examples/remote/client.rs index 8a65de55a0c95..1188dd0876634 100644 --- a/examples/remote/client.rs +++ b/examples/remote/client.rs @@ -4,10 +4,10 @@ use anyhow::Result as AnyhowResult; use argh::FromArgs; use bevy::remote::{ - BrpRequest, - builtin_methods::{BRP_QUERY_METHOD, BrpQuery, BrpQueryFilter, BrpQueryParams}, + builtin_methods::{BrpQuery, BrpQueryFilter, BrpQueryParams, BRP_QUERY_METHOD}, http::DEFAULT_ADDR, http::DEFAULT_PORT, + BrpRequest, }; /// Struct containing the command-line arguments that can be passed to this example. diff --git a/examples/remote/server.rs b/examples/remote/server.rs index f6f91c18c709b..39033218a7379 100644 --- a/examples/remote/server.rs +++ b/examples/remote/server.rs @@ -4,7 +4,7 @@ use bevy::math::ops::cos; use bevy::{ input::common_conditions::input_just_pressed, prelude::*, - remote::{RemotePlugin, http::RemoteHttpPlugin}, + remote::{http::RemoteHttpPlugin, RemotePlugin}, }; use serde::{Deserialize, Serialize}; diff --git a/examples/shader/compute_shader_game_of_life.rs b/examples/shader/compute_shader_game_of_life.rs index 7118588fb6ee9..af9fe3b2928b2 100644 --- a/examples/shader/compute_shader_game_of_life.rs +++ b/examples/shader/compute_shader_game_of_life.rs @@ -6,13 +6,13 @@ use bevy::{ prelude::*, render::{ - Render, RenderApp, RenderSet, extract_resource::{ExtractResource, ExtractResourcePlugin}, render_asset::{RenderAssetUsages, RenderAssets}, render_graph::{self, RenderGraph, RenderLabel}, render_resource::{binding_types::texture_storage_2d, *}, renderer::{RenderContext, RenderDevice}, texture::GpuImage, + Render, RenderApp, RenderSet, }, }; use std::borrow::Cow; diff --git a/examples/shader/custom_phase_item.rs b/examples/shader/custom_phase_item.rs index 5728ba509d09a..fe69c5b8125ac 100644 --- a/examples/shader/custom_phase_item.rs +++ b/examples/shader/custom_phase_item.rs @@ -8,15 +8,14 @@ //! for better reuse of parts of Bevy's built-in mesh rendering logic. use bevy::{ - core_pipeline::core_3d::{CORE_3D_DEPTH_FORMAT, Opaque3d, Opaque3dBatchSetKey, Opaque3dBinKey}, + core_pipeline::core_3d::{Opaque3d, Opaque3dBatchSetKey, Opaque3dBinKey, CORE_3D_DEPTH_FORMAT}, ecs::{ component::Tick, query::ROQueryItem, - system::{SystemParamItem, lifetimeless::SRes}, + system::{lifetimeless::SRes, SystemParamItem}, }, prelude::*, render::{ - Render, RenderApp, RenderSet, extract_component::{ExtractComponent, ExtractComponentPlugin}, primitives::Aabb, render_phase::{ @@ -33,6 +32,7 @@ use bevy::{ }, renderer::{RenderDevice, RenderQueue}, view::{self, ExtractedView, RenderVisibleEntities, VisibilityClass}, + Render, RenderApp, RenderSet, }, }; use bytemuck::{Pod, Zeroable}; diff --git a/examples/shader/custom_post_processing.rs b/examples/shader/custom_post_processing.rs index 9ccf79083ab64..ec532071bf2b8 100644 --- a/examples/shader/custom_post_processing.rs +++ b/examples/shader/custom_post_processing.rs @@ -14,7 +14,6 @@ use bevy::{ ecs::query::QueryItem, prelude::*, render::{ - RenderApp, extract_component::{ ComponentUniforms, DynamicUniformIndex, ExtractComponent, ExtractComponentPlugin, UniformComponentPlugin, @@ -28,6 +27,7 @@ use bevy::{ }, renderer::{RenderContext, RenderDevice}, view::ViewTarget, + RenderApp, }, }; diff --git a/examples/shader/custom_render_phase.rs b/examples/shader/custom_render_phase.rs index 84c24fcabb65d..47aad1b88faef 100644 --- a/examples/shader/custom_render_phase.rs +++ b/examples/shader/custom_render_phase.rs @@ -16,7 +16,7 @@ use bevy::{ core_pipeline::core_3d::graph::{Core3d, Node3d}, ecs::{ query::QueryItem, - system::{SystemParamItem, lifetimeless::SRes}, + system::{lifetimeless::SRes, SystemParamItem}, }, math::FloatOrd, pbr::{ @@ -26,25 +26,24 @@ use bevy::{ platform_support::collections::HashSet, prelude::*, render::{ - Extract, Render, RenderApp, RenderDebugFlags, RenderSet, batching::{ - GetBatchData, GetFullBatchData, gpu_preprocessing::{ - IndirectParametersCpuMetadata, UntypedPhaseIndirectParametersBuffers, - batch_and_prepare_sorted_render_phase, + batch_and_prepare_sorted_render_phase, IndirectParametersCpuMetadata, + UntypedPhaseIndirectParametersBuffers, }, + GetBatchData, GetFullBatchData, }, camera::ExtractedCamera, extract_component::{ExtractComponent, ExtractComponentPlugin}, - mesh::{MeshVertexBufferLayoutRef, RenderMesh, allocator::MeshAllocator}, + mesh::{allocator::MeshAllocator, MeshVertexBufferLayoutRef, RenderMesh}, render_asset::RenderAssets, render_graph::{ NodeRunError, RenderGraphApp, RenderGraphContext, RenderLabel, ViewNode, ViewNodeRunner, }, render_phase::{ - AddRenderCommand, CachedRenderPipelinePhaseItem, DrawFunctionId, DrawFunctions, - PhaseItem, PhaseItemExtraIndex, SetItemPipeline, SortedPhaseItem, - SortedRenderPhasePlugin, ViewSortedRenderPhases, sort_phase_system, + sort_phase_system, AddRenderCommand, CachedRenderPipelinePhaseItem, DrawFunctionId, + DrawFunctions, PhaseItem, PhaseItemExtraIndex, SetItemPipeline, SortedPhaseItem, + SortedRenderPhasePlugin, ViewSortedRenderPhases, }, render_resource::{ CachedRenderPipelineId, ColorTargetState, ColorWrites, Face, FragmentState, FrontFace, @@ -55,6 +54,7 @@ use bevy::{ renderer::RenderContext, sync_world::MainEntity, view::{ExtractedView, RenderVisibleEntities, RetainedViewEntity, ViewTarget}, + Extract, Render, RenderApp, RenderDebugFlags, RenderSet, }, }; use nonmax::NonMaxU32; diff --git a/examples/shader/custom_shader_instancing.rs b/examples/shader/custom_shader_instancing.rs index f4d7a359d8b90..cd5909c36fff1 100644 --- a/examples/shader/custom_shader_instancing.rs +++ b/examples/shader/custom_shader_instancing.rs @@ -11,17 +11,16 @@ use bevy::{ core_pipeline::core_3d::Transparent3d, ecs::{ query::QueryItem, - system::{SystemParamItem, lifetimeless::*}, + system::{lifetimeless::*, SystemParamItem}, }, pbr::{ MeshPipeline, MeshPipelineKey, RenderMeshInstances, SetMeshBindGroup, SetMeshViewBindGroup, }, prelude::*, render::{ - Render, RenderApp, RenderSet, extract_component::{ExtractComponent, ExtractComponentPlugin}, mesh::{ - MeshVertexBufferLayoutRef, RenderMesh, RenderMeshBufferInfo, allocator::MeshAllocator, + allocator::MeshAllocator, MeshVertexBufferLayoutRef, RenderMesh, RenderMeshBufferInfo, }, render_asset::RenderAssets, render_phase::{ @@ -32,6 +31,7 @@ use bevy::{ renderer::RenderDevice, sync_world::MainEntity, view::{ExtractedView, NoFrustumCulling, NoIndirectDrawing}, + Render, RenderApp, RenderSet, }, }; use bytemuck::{Pod, Zeroable}; diff --git a/examples/shader/gpu_readback.rs b/examples/shader/gpu_readback.rs index 228a2c62783f7..55a752b315915 100644 --- a/examples/shader/gpu_readback.rs +++ b/examples/shader/gpu_readback.rs @@ -4,7 +4,6 @@ use bevy::{ prelude::*, render::{ - Render, RenderApp, RenderSet, extract_resource::{ExtractResource, ExtractResourcePlugin}, gpu_readback::{Readback, ReadbackComplete}, render_asset::{RenderAssetUsages, RenderAssets}, @@ -16,6 +15,7 @@ use bevy::{ renderer::{RenderContext, RenderDevice}, storage::{GpuShaderStorageBuffer, ShaderStorageBuffer}, texture::GpuImage, + Render, RenderApp, RenderSet, }, }; diff --git a/examples/shader/specialized_mesh_pipeline.rs b/examples/shader/specialized_mesh_pipeline.rs index f1e3626c1482e..66f42f5872ecc 100644 --- a/examples/shader/specialized_mesh_pipeline.rs +++ b/examples/shader/specialized_mesh_pipeline.rs @@ -7,7 +7,7 @@ //! [`SpecializedMeshPipeline`] let's you customize the entire pipeline used when rendering a mesh. use bevy::{ - core_pipeline::core_3d::{CORE_3D_DEPTH_FORMAT, Opaque3d, Opaque3dBatchSetKey, Opaque3dBinKey}, + core_pipeline::core_3d::{Opaque3d, Opaque3dBatchSetKey, Opaque3dBinKey, CORE_3D_DEPTH_FORMAT}, ecs::{component::Tick, system::StaticSystemParam}, math::{vec3, vec4}, pbr::{ @@ -16,13 +16,12 @@ use bevy::{ }, prelude::*, render::{ - Render, RenderApp, RenderSet, batching::{ - GetBatchData, GetFullBatchData, gpu_preprocessing::{ self, PhaseBatchedInstanceBuffers, PhaseIndirectParametersBuffers, PreprocessWorkItem, UntypedPhaseBatchedInstanceBuffers, }, + GetBatchData, GetFullBatchData, }, experimental::occlusion_culling::OcclusionCulling, extract_component::{ExtractComponent, ExtractComponentPlugin}, @@ -40,6 +39,7 @@ use bevy::{ }, view::NoIndirectDrawing, view::{self, ExtractedView, RenderVisibleEntities, ViewTarget, VisibilityClass}, + Render, RenderApp, RenderSet, }, }; diff --git a/examples/shader/texture_binding_array.rs b/examples/shader/texture_binding_array.rs index ff7fd3739ac6f..bf5dc3da9debe 100644 --- a/examples/shader/texture_binding_array.rs +++ b/examples/shader/texture_binding_array.rs @@ -2,11 +2,10 @@ //! `binding_array>` shader binding slot and sample non-uniformly. use bevy::{ - ecs::system::{SystemParamItem, lifetimeless::SRes}, + ecs::system::{lifetimeless::SRes, SystemParamItem}, prelude::*, reflect::TypePath, render::{ - RenderApp, render_asset::RenderAssets, render_resource::{ binding_types::{sampler, texture_2d}, @@ -14,6 +13,7 @@ use bevy::{ }, renderer::RenderDevice, texture::{FallbackImage, GpuImage}, + RenderApp, }, }; use std::{num::NonZero, process::exit}; diff --git a/examples/stress_tests/bevymark.rs b/examples/stress_tests/bevymark.rs index 116c82e54d149..1ee719d93f85c 100644 --- a/examples/stress_tests/bevymark.rs +++ b/examples/stress_tests/bevymark.rs @@ -18,7 +18,7 @@ use bevy::{ window::{PresentMode, WindowResolution}, winit::{UpdateMode, WinitSettings}, }; -use rand::{Rng, SeedableRng, seq::SliceRandom}; +use rand::{seq::SliceRandom, Rng, SeedableRng}; use rand_chacha::ChaCha8Rng; const BIRDS_PER_SECOND: u32 = 10000; diff --git a/examples/stress_tests/many_components.rs b/examples/stress_tests/many_components.rs index 36ad4e8d44fc3..f047445f94bbe 100644 --- a/examples/stress_tests/many_components.rs +++ b/examples/stress_tests/many_components.rs @@ -13,7 +13,6 @@ //! If no valid number is provided, for each argument there's a reasonable default. use bevy::{ - MinimalPlugins, diagnostic::{ DiagnosticPath, DiagnosticsPlugin, FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin, }, @@ -25,6 +24,7 @@ use bevy::{ log::LogPlugin, prelude::{App, In, IntoSystem, Query, Schedule, SystemParamBuilder, Update}, ptr::{OwningPtr, PtrMut}, + MinimalPlugins, }; use rand::prelude::{Rng, SeedableRng, SliceRandom}; diff --git a/examples/stress_tests/many_cubes.rs b/examples/stress_tests/many_cubes.rs index 98e377ac567de..1d8a50313152f 100644 --- a/examples/stress_tests/many_cubes.rs +++ b/examples/stress_tests/many_cubes.rs @@ -25,7 +25,7 @@ use bevy::{ window::{PresentMode, WindowResolution}, winit::{UpdateMode, WinitSettings}, }; -use rand::{Rng, SeedableRng, seq::SliceRandom}; +use rand::{seq::SliceRandom, Rng, SeedableRng}; use rand_chacha::ChaCha8Rng; #[derive(FromArgs, Resource)] diff --git a/examples/stress_tests/many_lights.rs b/examples/stress_tests/many_lights.rs index 74acd59ed4574..a19f02d156725 100644 --- a/examples/stress_tests/many_lights.rs +++ b/examples/stress_tests/many_lights.rs @@ -9,11 +9,11 @@ use bevy::{ math::{DVec2, DVec3}, pbr::{ExtractedPointLight, GlobalClusterableObjectMeta}, prelude::*, - render::{Render, RenderApp, RenderSet, camera::ScalingMode}, + render::{camera::ScalingMode, Render, RenderApp, RenderSet}, window::{PresentMode, WindowResolution}, winit::{UpdateMode, WinitSettings}, }; -use rand::{Rng, thread_rng}; +use rand::{thread_rng, Rng}; fn main() { App::new() diff --git a/examples/stress_tests/many_text2d.rs b/examples/stress_tests/many_text2d.rs index 08472046ee100..65c133a813c77 100644 --- a/examples/stress_tests/many_text2d.rs +++ b/examples/stress_tests/many_text2d.rs @@ -12,8 +12,8 @@ use bevy::{ use argh::FromArgs; use rand::{ - Rng, SeedableRng, seq::{IteratorRandom, SliceRandom}, + Rng, SeedableRng, }; use rand_chacha::ChaCha8Rng; diff --git a/examples/tools/scene_viewer/scene_viewer_plugin.rs b/examples/tools/scene_viewer/scene_viewer_plugin.rs index 2e2990b3fc8d1..49f4805d06eb7 100644 --- a/examples/tools/scene_viewer/scene_viewer_plugin.rs +++ b/examples/tools/scene_viewer/scene_viewer_plugin.rs @@ -101,9 +101,7 @@ fn scene_load_check( scene_handle.scene_index, gltf.scenes.len() ); - info!( - "You can select the scene by adding '#Scene' followed by a number to the end of the file path (e.g '#Scene1' to load the second scene)." - ); + info!("You can select the scene by adding '#Scene' followed by a number to the end of the file path (e.g '#Scene1' to load the second scene)."); } let gltf_scene_handle = diff --git a/examples/ui/directional_navigation.rs b/examples/ui/directional_navigation.rs index d3e918e790e9b..0512c7498db54 100644 --- a/examples/ui/directional_navigation.rs +++ b/examples/ui/directional_navigation.rs @@ -9,10 +9,10 @@ use std::time::Duration; use bevy::{ input_focus::{ - InputDispatchPlugin, InputFocus, InputFocusVisible, directional_navigation::{ DirectionalNavigation, DirectionalNavigationMap, DirectionalNavigationPlugin, }, + InputDispatchPlugin, InputFocus, InputFocusVisible, }, math::{CompassOctant, FloatOrd}, picking::{ diff --git a/examples/ui/tab_navigation.rs b/examples/ui/tab_navigation.rs index 60d57568559df..c6060bd848e07 100644 --- a/examples/ui/tab_navigation.rs +++ b/examples/ui/tab_navigation.rs @@ -3,8 +3,8 @@ use bevy::{ color::palettes::basic::*, input_focus::{ - InputDispatchPlugin, InputFocus, tab_navigation::{TabGroup, TabIndex, TabNavigationPlugin}, + InputDispatchPlugin, InputFocus, }, prelude::*, winit::WinitSettings, diff --git a/examples/window/custom_user_event.rs b/examples/window/custom_user_event.rs index 68376482e88ad..c01df5fa6d549 100644 --- a/examples/window/custom_user_event.rs +++ b/examples/window/custom_user_event.rs @@ -83,7 +83,7 @@ fn handle_event(mut events: EventReader) { pub(crate) mod wasm { use super::*; use bevy::winit::EventLoopProxy; - use wasm_bindgen::{JsCast, prelude::*}; + use wasm_bindgen::{prelude::*, JsCast}; use web_sys::KeyboardEvent; pub(crate) fn setup_js_closure(event_loop: Res>) { diff --git a/examples/window/screenshot.rs b/examples/window/screenshot.rs index 854b6dea6d01c..84c15a6837349 100644 --- a/examples/window/screenshot.rs +++ b/examples/window/screenshot.rs @@ -2,7 +2,7 @@ use bevy::{ prelude::*, - render::view::screenshot::{Capturing, Screenshot, save_to_disk}, + render::view::screenshot::{save_to_disk, Capturing, Screenshot}, window::SystemCursorIcon, winit::cursor::CursorIcon, }; diff --git a/tools/build-easefunction-graphs/src/main.rs b/tools/build-easefunction-graphs/src/main.rs index caf9f74eb241a..5034251ab2a47 100644 --- a/tools/build-easefunction-graphs/src/main.rs +++ b/tools/build-easefunction-graphs/src/main.rs @@ -3,8 +3,8 @@ use std::path::PathBuf; use bevy_math::curve::{CurveExt, EaseFunction, EasingCurve, JumpAt}; use svg::{ - Document, node::element::{self, path::Data}, + Document, }; fn main() { diff --git a/tools/build-wasm-example/src/main.rs b/tools/build-wasm-example/src/main.rs index 9e3e79a46b8ec..1162aaece7449 100644 --- a/tools/build-wasm-example/src/main.rs +++ b/tools/build-wasm-example/src/main.rs @@ -3,7 +3,7 @@ use std::{fs::File, io::Write}; use clap::{Parser, ValueEnum}; -use xshell::{Shell, cmd}; +use xshell::{cmd, Shell}; #[derive(Debug, Copy, Clone, ValueEnum)] enum WebApi { diff --git a/tools/ci/src/commands/compile.rs b/tools/ci/src/commands/compile.rs index 58bd1f9006fcd..f445aaca57331 100644 --- a/tools/ci/src/commands/compile.rs +++ b/tools/ci/src/commands/compile.rs @@ -1,9 +1,9 @@ use crate::{ - Flag, Prepare, PreparedCommand, commands::{ BenchCheckCommand, CompileCheckCommand, CompileFailCommand, ExampleCheckCommand, IntegrationTestCheckCommand, TestCheckCommand, }, + Flag, Prepare, PreparedCommand, }; use argh::FromArgs; diff --git a/tools/ci/src/commands/doc.rs b/tools/ci/src/commands/doc.rs index f62eea7691f67..fb8074ca8cf48 100644 --- a/tools/ci/src/commands/doc.rs +++ b/tools/ci/src/commands/doc.rs @@ -1,6 +1,6 @@ use crate::{ - Flag, Prepare, PreparedCommand, commands::{DocCheckCommand, DocTestCommand}, + Flag, Prepare, PreparedCommand, }; use argh::FromArgs; diff --git a/tools/ci/src/commands/integration_test.rs b/tools/ci/src/commands/integration_test.rs index ba4adbcd9d34a..b86a027a56026 100644 --- a/tools/ci/src/commands/integration_test.rs +++ b/tools/ci/src/commands/integration_test.rs @@ -1,4 +1,4 @@ -use crate::{Flag, Prepare, PreparedCommand, commands::get_integration_tests}; +use crate::{commands::get_integration_tests, Flag, Prepare, PreparedCommand}; use argh::FromArgs; use xshell::cmd; diff --git a/tools/ci/src/commands/lints.rs b/tools/ci/src/commands/lints.rs index 28cd047c5f1c4..befdaf5fc5d48 100644 --- a/tools/ci/src/commands/lints.rs +++ b/tools/ci/src/commands/lints.rs @@ -1,6 +1,6 @@ use crate::{ - Flag, Prepare, PreparedCommand, commands::{ClippyCommand, FormatCommand}, + Flag, Prepare, PreparedCommand, }; use argh::FromArgs; diff --git a/tools/compile_fail_utils/src/lib.rs b/tools/compile_fail_utils/src/lib.rs index dedfb56dc2882..816e81d062865 100644 --- a/tools/compile_fail_utils/src/lib.rs +++ b/tools/compile_fail_utils/src/lib.rs @@ -7,13 +7,13 @@ use std::{ pub use ui_test; use ui_test::{ - Args, Config, OutputConflictHandling, color_eyre::eyre::eyre, default_file_filter, default_per_file_config, dependencies::DependencyBuilder, run_tests_generic, spanned::Spanned, status_emitter::{Gha, StatusEmitter, Text}, + Args, Config, OutputConflictHandling, }; /// Use this instead of hand rolling configs. diff --git a/tools/example-showcase/src/main.rs b/tools/example-showcase/src/main.rs index ee810dde50211..49afb15c2048c 100644 --- a/tools/example-showcase/src/main.rs +++ b/tools/example-showcase/src/main.rs @@ -6,7 +6,7 @@ use core::{ time::Duration, }; use std::{ - collections::{HashMap, hash_map::DefaultHasher}, + collections::{hash_map::DefaultHasher, HashMap}, fs::{self, File}, io::Write, path::{Path, PathBuf}, @@ -15,11 +15,11 @@ use std::{ time::Instant, }; -use clap::{CommandFactory, Parser, ValueEnum, error::ErrorKind}; +use clap::{error::ErrorKind, CommandFactory, Parser, ValueEnum}; use pbr::ProgressBar; use regex::Regex; use toml_edit::{DocumentMut, Item}; -use xshell::{Shell, cmd}; +use xshell::{cmd, Shell}; #[derive(Parser, Debug)] struct Args { From 32a0ad28cad53a889b2c8b8732b47df272d4bded Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Fri, 21 Feb 2025 22:49:41 +1100 Subject: [PATCH 21/34] Use 2021 formatting style explicitly --- crates/bevy_ecs/src/observer/mod.rs | 16 +++----- crates/bevy_ecs/src/schedule/schedule.rs | 8 ++-- crates/bevy_ecs/src/system/mod.rs | 4 +- crates/bevy_pbr/src/material.rs | 11 ++---- crates/bevy_render/src/mesh/allocator.rs | 4 +- .../src/render_resource/pipeline_cache.rs | 16 ++++---- crates/bevy_transform/src/systems.rs | 18 ++------- examples/2d/cpu_draw.rs | 12 +++++- examples/3d/fog.rs | 6 +-- examples/asset/asset_loading.rs | 19 +++++---- examples/games/alien_cake_addict.rs | 39 +++++++++++-------- rustfmt.toml | 1 + 12 files changed, 74 insertions(+), 80 deletions(-) diff --git a/crates/bevy_ecs/src/observer/mod.rs b/crates/bevy_ecs/src/observer/mod.rs index 525e9751a684e..ca715db051d9c 100644 --- a/crates/bevy_ecs/src/observer/mod.rs +++ b/crates/bevy_ecs/src/observer/mod.rs @@ -1166,11 +1166,9 @@ mod tests { let mut world = World::new(); world.init_resource::(); - world - .spawn_empty() - .observe(|_: Trigger| -> () { - panic!("Trigger routed to non-targeted entity."); - }); + world.spawn_empty().observe(|_: Trigger| -> () { + panic!("Trigger routed to non-targeted entity."); + }); world.add_observer(move |obs: Trigger, mut res: ResMut| { assert_eq!(obs.target(), Entity::PLACEHOLDER); res.observed("event_a"); @@ -1189,11 +1187,9 @@ mod tests { let mut world = World::new(); world.init_resource::(); - world - .spawn_empty() - .observe(|_: Trigger| -> () { - panic!("Trigger routed to non-targeted entity."); - }); + world.spawn_empty().observe(|_: Trigger| -> () { + panic!("Trigger routed to non-targeted entity."); + }); let entity = world .spawn_empty() .observe(|_: Trigger, mut res: ResMut| res.observed("a_1")) diff --git a/crates/bevy_ecs/src/schedule/schedule.rs b/crates/bevy_ecs/src/schedule/schedule.rs index ef6c457332916..b121bf6ac21cf 100644 --- a/crates/bevy_ecs/src/schedule/schedule.rs +++ b/crates/bevy_ecs/src/schedule/schedule.rs @@ -2064,9 +2064,11 @@ mod tests { schedule.configure_sets(Set.run_if(|| false)); schedule.add_systems( - (|| -> () { panic!("This system must not run"); }) - .ambiguous_with(|| ()) - .in_set(Set), + (|| -> () { + panic!("This system must not run"); + }) + .ambiguous_with(|| ()) + .in_set(Set), ); schedule.run(&mut world); } diff --git a/crates/bevy_ecs/src/system/mod.rs b/crates/bevy_ecs/src/system/mod.rs index 43f9c612d13c3..9a5523174150b 100644 --- a/crates/bevy_ecs/src/system/mod.rs +++ b/crates/bevy_ecs/src/system/mod.rs @@ -1648,7 +1648,9 @@ mod tests { #[should_panic] fn panic_inside_system() { let mut world = World::new(); - run_system(&mut world, || -> () { panic!("this system panics"); }); + run_system(&mut world, || -> () { + panic!("this system panics"); + }); } #[test] diff --git a/crates/bevy_pbr/src/material.rs b/crates/bevy_pbr/src/material.rs index d91ff14633af9..cb30b1dc381ab 100644 --- a/crates/bevy_pbr/src/material.rs +++ b/crates/bevy_pbr/src/material.rs @@ -1381,14 +1381,9 @@ impl RenderAsset for PreparedMaterial { fn unload_asset( source_asset: AssetId, - ( - _, - _, - _, - bind_group_allocator, - render_material_bindings, - .., - ): &mut SystemParamItem, + (_, _, _, bind_group_allocator, render_material_bindings, ..): &mut SystemParamItem< + Self::Param, + >, ) { let Some(material_binding_id) = render_material_bindings.remove(&source_asset.untyped()) else { diff --git a/crates/bevy_render/src/mesh/allocator.rs b/crates/bevy_render/src/mesh/allocator.rs index 3af1ce1ea83fc..cb023f1a9d9e6 100644 --- a/crates/bevy_render/src/mesh/allocator.rs +++ b/crates/bevy_render/src/mesh/allocator.rs @@ -763,9 +763,7 @@ impl MeshAllocator { // Mark the allocation as pending. Don't copy it in just yet; further // meshes loaded this frame may result in its final allocation location // changing. - if let Some(Slab::General(general_slab)) = - self.slabs.get_mut(&mesh_allocation.slab_id) - { + if let Some(Slab::General(general_slab)) = self.slabs.get_mut(&mesh_allocation.slab_id) { general_slab .pending_allocations .insert(*mesh_id, mesh_allocation.slab_allocation); diff --git a/crates/bevy_render/src/render_resource/pipeline_cache.rs b/crates/bevy_render/src/render_resource/pipeline_cache.rs index 7be7d1f724c43..37211edb04c3d 100644 --- a/crates/bevy_render/src/render_resource/pipeline_cache.rs +++ b/crates/bevy_render/src/render_resource/pipeline_cache.rs @@ -882,16 +882,14 @@ impl PipelineCache { }; } - CachedPipelineState::Creating(task) => { - match bevy_tasks::futures::check_ready(task) { - Some(Ok(pipeline)) => { - cached_pipeline.state = CachedPipelineState::Ok(pipeline); - return; - } - Some(Err(err)) => cached_pipeline.state = CachedPipelineState::Err(err), - _ => (), + CachedPipelineState::Creating(task) => match bevy_tasks::futures::check_ready(task) { + Some(Ok(pipeline)) => { + cached_pipeline.state = CachedPipelineState::Ok(pipeline); + return; } - } + Some(Err(err)) => cached_pipeline.state = CachedPipelineState::Err(err), + _ => (), + }, CachedPipelineState::Err(err) => match err { // Retry diff --git a/crates/bevy_transform/src/systems.rs b/crates/bevy_transform/src/systems.rs index 5f070c2ed65d3..302d18ee1bf02 100644 --- a/crates/bevy_transform/src/systems.rs +++ b/crates/bevy_transform/src/systems.rs @@ -453,23 +453,16 @@ mod test { .spawn(Transform::IDENTITY) .add_children(&[child]); - let mut child_entity = app - .world_mut() - .entity_mut(child); + let mut child_entity = app.world_mut().entity_mut(child); - let mut grandchild_entity = temp - .entity_mut(grandchild); + let mut grandchild_entity = temp.entity_mut(grandchild); #[expect( unsafe_code, reason = "ChildOf is not mutable but this is for a test to produce a scenario that cannot happen" )] // SAFETY: ChildOf is not mutable but this is for a test to produce a scenario that cannot happen - let mut a = unsafe { - child_entity - .get_mut_assume_mutable::() - .unwrap() - }; + let mut a = unsafe { child_entity.get_mut_assume_mutable::().unwrap() }; // SAFETY: ChildOf is not mutable but this is for a test to produce a scenario that cannot happen #[expect( @@ -482,10 +475,7 @@ mod test { .unwrap() }; - core::mem::swap( - a.as_mut(), - b.as_mut(), - ); + core::mem::swap(a.as_mut(), b.as_mut()); app.update(); } diff --git a/examples/2d/cpu_draw.rs b/examples/2d/cpu_draw.rs index f142f50d1d214..ba98e1051e8f7 100644 --- a/examples/2d/cpu_draw.rs +++ b/examples/2d/cpu_draw.rs @@ -101,7 +101,11 @@ fn draw( ) { if *i == 0 { // Generate a random color on first run. - *draw_color = Color::linear_rgb(seeded_rng.0.r#gen(), seeded_rng.0.r#gen(), seeded_rng.0.r#gen()); + *draw_color = Color::linear_rgb( + seeded_rng.0.r#gen(), + seeded_rng.0.r#gen(), + seeded_rng.0.r#gen(), + ); } // Get the image from Bevy's asset storage. @@ -124,7 +128,11 @@ fn draw( // If the old color is our current color, change our drawing color. let tolerance = 1.0 / 255.0; if old_color.distance(&draw_color) <= tolerance { - *draw_color = Color::linear_rgb(seeded_rng.0.r#gen(), seeded_rng.0.r#gen(), seeded_rng.0.r#gen()); + *draw_color = Color::linear_rgb( + seeded_rng.0.r#gen(), + seeded_rng.0.r#gen(), + seeded_rng.0.r#gen(), + ); } // Set the new color, but keep old alpha value from image. diff --git a/examples/3d/fog.rs b/examples/3d/fog.rs index ed2a2a0dd6867..9793ae0ad356a 100644 --- a/examples/3d/fog.rs +++ b/examples/3d/fog.rs @@ -185,11 +185,7 @@ fn update_system( } // Linear Fog Controls - if let FogFalloff::Linear { - start, - end, - } = &mut fog.falloff - { + if let FogFalloff::Linear { start, end } = &mut fog.falloff { text.push_str("\nA / S - Move Start Distance\nZ / X - Move End Distance"); if keycode.pressed(KeyCode::KeyA) { diff --git a/examples/asset/asset_loading.rs b/examples/asset/asset_loading.rs index 88867ea458b8b..28ab31fe98bdc 100644 --- a/examples/asset/asset_loading.rs +++ b/examples/asset/asset_loading.rs @@ -36,14 +36,17 @@ fn setup( ); // All assets end up in their Assets collection once they are done loading: - match meshes.get(&sphere_handle) { Some(sphere) => { - // You might notice that this doesn't run! This is because assets load in parallel without - // blocking. When an asset has loaded, it will appear in relevant Assets - // collection. - info!("{:?}", sphere.primitive_topology()); - } _ => { - info!("sphere hasn't loaded yet"); - }} + match meshes.get(&sphere_handle) { + Some(sphere) => { + // You might notice that this doesn't run! This is because assets load in parallel without + // blocking. When an asset has loaded, it will appear in relevant Assets + // collection. + info!("{:?}", sphere.primitive_topology()); + } + _ => { + info!("sphere hasn't loaded yet"); + } + } // You can load all assets in a folder like this. They will be loaded in parallel without // blocking. The LoadedFolder asset holds handles to each asset in the folder. These are all diff --git a/examples/games/alien_cake_addict.rs b/examples/games/alien_cake_addict.rs index 67267a8b6fac2..da603a39dc25f 100644 --- a/examples/games/alien_cake_addict.rs +++ b/examples/games/alien_cake_addict.rs @@ -271,25 +271,30 @@ fn focus_camera( ) { const SPEED: f32 = 2.0; // if there is both a player and a bonus, target the mid-point of them - match (game.player.entity, game.bonus.entity) { (Some(player_entity), Some(bonus_entity)) => { - let transform_query = transforms.p1(); - if let (Ok(player_transform), Ok(bonus_transform)) = ( - transform_query.get(player_entity), - transform_query.get(bonus_entity), - ) { - game.camera_should_focus = player_transform - .translation - .lerp(bonus_transform.translation, 0.5); + match (game.player.entity, game.bonus.entity) { + (Some(player_entity), Some(bonus_entity)) => { + let transform_query = transforms.p1(); + if let (Ok(player_transform), Ok(bonus_transform)) = ( + transform_query.get(player_entity), + transform_query.get(bonus_entity), + ) { + game.camera_should_focus = player_transform + .translation + .lerp(bonus_transform.translation, 0.5); + } + // otherwise, if there is only a player, target the player } - // otherwise, if there is only a player, target the player - } _ => if let Some(player_entity) = game.player.entity { - if let Ok(player_transform) = transforms.p1().get(player_entity) { - game.camera_should_focus = player_transform.translation; + _ => { + if let Some(player_entity) = game.player.entity { + if let Ok(player_transform) = transforms.p1().get(player_entity) { + game.camera_should_focus = player_transform.translation; + } + // otherwise, target the middle + } else { + game.camera_should_focus = Vec3::from(RESET_FOCUS); + } } - // otherwise, target the middle - } else { - game.camera_should_focus = Vec3::from(RESET_FOCUS); - }} + } // calculate the camera motion based on the difference between where the camera is looking // and where it should be looking; the greater the distance, the faster the motion; // smooth out the camera movement using the frame time diff --git a/rustfmt.toml b/rustfmt.toml index 467c4533c832c..8769775ec91b5 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,5 +1,6 @@ use_field_init_shorthand = true newline_style = "Unix" +style_edition = "2021" # The following lines may be uncommented on nightly Rust. # Once these features have stabilized, they should be added to the always-enabled options above. From 3a3d98af74e8406aa8e37d424ab1c0add5a2f44e Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Fri, 21 Feb 2025 22:50:05 +1100 Subject: [PATCH 22/34] Fix Rust version for templated pages CI --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b0704a2395528..2f3a25179fcfe 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -335,6 +335,7 @@ jobs: timeout-minutes: 30 steps: - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable - name: check for missing metadata id: missing-metadata run: cargo run -p build-templated-pages -- check-missing examples From 7da43d1393974e0c3a91879b97988e30fca82bdc Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Fri, 21 Feb 2025 22:53:07 +1100 Subject: [PATCH 23/34] Fix check-missing-features-in-docs --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2f3a25179fcfe..4e50d713b1c29 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -370,6 +370,7 @@ jobs: needs: check-missing-examples-in-docs steps: - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable - name: check for missing features id: missing-features run: cargo run -p build-templated-pages -- check-missing features From 069108e72b8ee44d6333fb5360645a85fd8cb120 Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Fri, 21 Feb 2025 23:02:29 +1100 Subject: [PATCH 24/34] Fix docs --- crates/bevy_ecs/src/system/commands/mod.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/bevy_ecs/src/system/commands/mod.rs b/crates/bevy_ecs/src/system/commands/mod.rs index 04d0940a44c65..720512e1f2e9d 100644 --- a/crates/bevy_ecs/src/system/commands/mod.rs +++ b/crates/bevy_ecs/src/system/commands/mod.rs @@ -82,7 +82,6 @@ use crate::{ /// // NOTE: type inference fails here, so annotations are required on the closure. /// commands.queue(|w: &mut World| { /// // Mutate the world however you want... -/// # todo!(); /// }); /// # } /// ``` From 1de39167aa4e45996a4c44f5986fd60b8d68c11c Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Fri, 21 Feb 2025 23:12:54 +1100 Subject: [PATCH 25/34] Fix bevy_log doc tests --- crates/bevy_log/src/lib.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/bevy_log/src/lib.rs b/crates/bevy_log/src/lib.rs index f0743f022de0f..0f4f9a5c6d6f3 100644 --- a/crates/bevy_log/src/lib.rs +++ b/crates/bevy_log/src/lib.rs @@ -117,7 +117,10 @@ pub(crate) struct FlushGuard(SyncCell); /// # use bevy_app::{App, NoopPluginGroup as DefaultPlugins, PluginGroup}; /// # use bevy_log::LogPlugin; /// fn main() { +/// # // SAFETY: Single-threaded +/// # unsafe { /// std::env::set_var("NO_COLOR", "1"); +/// # } /// App::new() /// .add_plugins(DefaultPlugins) /// .run(); From d4ed647f912301d6c3f2dd0a56dec900b2e26b6b Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Sat, 22 Feb 2025 17:32:38 +1100 Subject: [PATCH 26/34] Fix all doc tests --- crates/bevy_ecs/src/entity/unique_slice.rs | 1 - crates/bevy_ecs/src/query/filter.rs | 2 -- crates/bevy_math/src/sampling/standard.rs | 2 +- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/crates/bevy_ecs/src/entity/unique_slice.rs b/crates/bevy_ecs/src/entity/unique_slice.rs index f3a6f66de7e87..507d98b09be88 100644 --- a/crates/bevy_ecs/src/entity/unique_slice.rs +++ b/crates/bevy_ecs/src/entity/unique_slice.rs @@ -1280,7 +1280,6 @@ impl IndexMut> for UniqueEntityS /// the [`IntoIterator`] impls on it and [`UniqueEntityVec`]. /// /// [`iter`]: `UniqueEntitySlice::iter` -/// [`into_iter`]: UniqueEntitySlice::into_iter pub type Iter<'a, T> = UniqueEntityIter>; impl<'a, T: TrustedEntityBorrow> UniqueEntityIter> { diff --git a/crates/bevy_ecs/src/query/filter.rs b/crates/bevy_ecs/src/query/filter.rs index 9e4f36a9655f6..e4e1f0fd668d3 100644 --- a/crates/bevy_ecs/src/query/filter.rs +++ b/crates/bevy_ecs/src/query/filter.rs @@ -66,9 +66,7 @@ use variadics_please::all_tuples; /// # bevy_ecs::system::assert_is_system(my_system); /// ``` /// -/// [`matches_component_set`]: Self::matches_component_set /// [`Query`]: crate::system::Query -/// [`State`]: Self::State /// /// # Safety /// diff --git a/crates/bevy_math/src/sampling/standard.rs b/crates/bevy_math/src/sampling/standard.rs index 7de8270e30ea1..d4e82fdc81c14 100644 --- a/crates/bevy_math/src/sampling/standard.rs +++ b/crates/bevy_math/src/sampling/standard.rs @@ -12,7 +12,7 @@ //! let random_direction1: Dir3 = random(); //! //! // Random direction using the rng constructed above -//! let random_direction2: Dir3 = rng.gen(); +//! let random_direction2: Dir3 = rng.r#gen(); //! //! // The same as the previous but with different syntax //! let random_direction3 = Dir3::from_rng(&mut rng); From d2da9fe13de1cb9ea91f2e5e93c74989b12299b1 Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Sat, 22 Feb 2025 20:09:10 +1100 Subject: [PATCH 27/34] Clippy has hands --- .../benches/bevy_ecs/components/add_remove.rs | 2 +- .../benches/bevy_ecs/iteration/iter_simple.rs | 10 +++--- .../bevy_ecs/iteration/iter_simple_foreach.rs | 10 +++--- .../iter_simple_foreach_sparse_set.rs | 10 +++--- .../iteration/iter_simple_foreach_wide.rs | 10 +++--- .../iter_simple_foreach_wide_sparse_set.rs | 10 +++--- .../iteration/iter_simple_sparse_set.rs | 10 +++--- .../bevy_ecs/iteration/iter_simple_system.rs | 10 +++--- .../bevy_ecs/iteration/iter_simple_wide.rs | 10 +++--- .../iteration/iter_simple_wide_sparse_set.rs | 10 +++--- .../bevy_ecs/iteration/par_iter_simple.rs | 10 +++--- benches/benches/bevy_reflect/list.rs | 12 +++---- benches/benches/bevy_reflect/map.rs | 2 +- crates/bevy_animation/src/graph.rs | 4 +-- crates/bevy_app/src/app.rs | 4 +-- crates/bevy_app/src/panic_handler.rs | 2 +- crates/bevy_asset/src/lib.rs | 4 +-- crates/bevy_asset/src/loader.rs | 4 +-- crates/bevy_asset/src/path.rs | 4 +-- crates/bevy_asset/src/processor/mod.rs | 11 ++++--- crates/bevy_asset/src/server/mod.rs | 21 ++++++------ crates/bevy_dev_tools/src/lib.rs | 2 +- crates/bevy_ecs/src/change_detection.rs | 2 +- crates/bevy_ecs/src/entity/unique_vec.rs | 4 +-- crates/bevy_ecs/src/event/collections.rs | 2 +- crates/bevy_ecs/src/observer/mod.rs | 30 +++++++++-------- crates/bevy_ecs/src/query/access.rs | 2 +- crates/bevy_ecs/src/query/state.rs | 4 +-- .../bevy_ecs/src/reflect/entity_commands.rs | 6 ++-- crates/bevy_ecs/src/schedule/schedule.rs | 12 +++---- crates/bevy_ecs/src/schedule/stepping.rs | 2 +- crates/bevy_ecs/src/storage/blob_array.rs | 10 +++--- crates/bevy_ecs/src/storage/blob_vec.rs | 8 ++--- crates/bevy_ecs/src/system/mod.rs | 5 +-- crates/bevy_ecs/src/world/entity_ref.rs | 22 ++++++------- .../bevy_ecs/src/world/unsafe_world_cell.rs | 6 ++-- crates/bevy_gizmos/src/arcs.rs | 30 ++++++++--------- crates/bevy_gizmos/src/gizmos.rs | 3 +- crates/bevy_gizmos/src/grid.rs | 17 ++++------ crates/bevy_gizmos/src/rounded_box.rs | 23 ++++++------- crates/bevy_log/src/lib.rs | 6 ++-- crates/bevy_math/src/cubic_splines/mod.rs | 5 ++- crates/bevy_mesh/src/mesh.rs | 20 ++++++------ crates/bevy_mesh/src/morph.rs | 3 +- crates/bevy_mikktspace/examples/generate.rs | 6 +++- .../bevy_mikktspace/tests/regression_test.rs | 3 +- crates/bevy_pbr/src/cluster/assign.rs | 4 +-- crates/bevy_pbr/src/fog.rs | 14 ++++---- .../src/light_probe/irradiance_volume.rs | 18 +++++------ crates/bevy_pbr/src/light_probe/mod.rs | 16 +++++----- crates/bevy_pbr/src/meshlet/from_mesh.rs | 22 +++++++------ .../bevy_pbr/src/meshlet/resource_manager.rs | 2 +- crates/bevy_pbr/src/pbr_material.rs | 10 +++--- crates/bevy_reflect/src/lib.rs | 2 +- crates/bevy_reflect/src/serde/type_data.rs | 6 ++-- crates/bevy_remote/src/lib.rs | 2 +- crates/bevy_render/src/pipelined_rendering.rs | 8 ++--- crates/bevy_render/src/primitives/mod.rs | 4 +-- crates/bevy_render/src/render_phase/mod.rs | 22 ++++++------- .../src/render_resource/bind_group.rs | 32 +++++++++---------- .../src/render_resource/buffer_vec.rs | 2 +- crates/bevy_render/src/view/visibility/mod.rs | 2 +- crates/bevy_sprite/src/lib.rs | 2 +- crates/bevy_sprite/src/texture_slice/mod.rs | 2 +- .../src/components/global_transform.rs | 2 +- .../src/components/transform.rs | 10 +++--- crates/bevy_transform/src/systems.rs | 4 +-- crates/bevy_ui/src/widget/text.rs | 6 ++-- crates/bevy_window/src/window.rs | 14 ++++---- crates/bevy_winit/src/winit_config.rs | 2 +- examples/3d/transparency_3d.rs | 2 +- examples/camera/first_person_view_model.rs | 12 +++---- examples/ecs/component_hooks.rs | 4 +-- .../movement/physics_in_fixed_timestep.rs | 20 ++++++------ examples/stress_tests/transform_hierarchy.rs | 2 +- 75 files changed, 327 insertions(+), 324 deletions(-) diff --git a/benches/benches/bevy_ecs/components/add_remove.rs b/benches/benches/bevy_ecs/components/add_remove.rs index b381ccb434fe5..9b654e7a82ec1 100644 --- a/benches/benches/bevy_ecs/components/add_remove.rs +++ b/benches/benches/bevy_ecs/components/add_remove.rs @@ -12,7 +12,7 @@ impl Benchmark { let mut world = World::default(); let entities = world - .spawn_batch(core::iter::repeat(A(0.)).take(10000)) + .spawn_batch(core::iter::repeat_n(A(0.), 10_000)) .collect(); Self(world, entities) } diff --git a/benches/benches/bevy_ecs/iteration/iter_simple.rs b/benches/benches/bevy_ecs/iteration/iter_simple.rs index 1fc86f5087679..14cca69082752 100644 --- a/benches/benches/bevy_ecs/iteration/iter_simple.rs +++ b/benches/benches/bevy_ecs/iteration/iter_simple.rs @@ -19,15 +19,15 @@ impl<'w> Benchmark<'w> { pub fn new() -> Self { let mut world = World::new(); - world.spawn_batch( - core::iter::repeat(( + world.spawn_batch(core::iter::repeat_n( + ( Transform(Mat4::from_scale(Vec3::ONE)), Position(Vec3::X), Rotation(Vec3::X), Velocity(Vec3::X), - )) - .take(10_000), - ); + ), + 10_000, + )); let query = world.query::<(&Velocity, &mut Position)>(); Self(world, query) diff --git a/benches/benches/bevy_ecs/iteration/iter_simple_foreach.rs b/benches/benches/bevy_ecs/iteration/iter_simple_foreach.rs index f0a41d18be53b..19396e95b0820 100644 --- a/benches/benches/bevy_ecs/iteration/iter_simple_foreach.rs +++ b/benches/benches/bevy_ecs/iteration/iter_simple_foreach.rs @@ -19,15 +19,15 @@ impl<'w> Benchmark<'w> { pub fn new() -> Self { let mut world = World::new(); - world.spawn_batch( - core::iter::repeat(( + world.spawn_batch(core::iter::repeat_n( + ( Transform(Mat4::from_scale(Vec3::ONE)), Position(Vec3::X), Rotation(Vec3::X), Velocity(Vec3::X), - )) - .take(10_000), - ); + ), + 10_000, + )); let query = world.query::<(&Velocity, &mut Position)>(); Self(world, query) diff --git a/benches/benches/bevy_ecs/iteration/iter_simple_foreach_sparse_set.rs b/benches/benches/bevy_ecs/iteration/iter_simple_foreach_sparse_set.rs index 0075c2706ba20..1e0db505c1667 100644 --- a/benches/benches/bevy_ecs/iteration/iter_simple_foreach_sparse_set.rs +++ b/benches/benches/bevy_ecs/iteration/iter_simple_foreach_sparse_set.rs @@ -21,15 +21,15 @@ impl<'w> Benchmark<'w> { pub fn new() -> Self { let mut world = World::new(); - world.spawn_batch( - core::iter::repeat(( + world.spawn_batch(core::iter::repeat_n( + ( Transform(Mat4::from_scale(Vec3::ONE)), Position(Vec3::X), Rotation(Vec3::X), Velocity(Vec3::X), - )) - .take(10_000), - ); + ), + 10_000, + )); let query = world.query::<(&Velocity, &mut Position)>(); Self(world, query) diff --git a/benches/benches/bevy_ecs/iteration/iter_simple_foreach_wide.rs b/benches/benches/bevy_ecs/iteration/iter_simple_foreach_wide.rs index 7dbd11d1e0499..505d624eb8164 100644 --- a/benches/benches/bevy_ecs/iteration/iter_simple_foreach_wide.rs +++ b/benches/benches/bevy_ecs/iteration/iter_simple_foreach_wide.rs @@ -33,8 +33,8 @@ impl<'w> Benchmark<'w> { pub fn new() -> Self { let mut world = World::new(); - world.spawn_batch( - core::iter::repeat(( + world.spawn_batch(core::iter::repeat_n( + ( Transform(Mat4::from_scale(Vec3::ONE)), Rotation(Vec3::X), Position::<0>(Vec3::X), @@ -47,9 +47,9 @@ impl<'w> Benchmark<'w> { Velocity::<3>(Vec3::X), Position::<4>(Vec3::X), Velocity::<4>(Vec3::X), - )) - .take(10_000), - ); + ), + 10_000, + )); let query = world.query(); Self(world, query) diff --git a/benches/benches/bevy_ecs/iteration/iter_simple_foreach_wide_sparse_set.rs b/benches/benches/bevy_ecs/iteration/iter_simple_foreach_wide_sparse_set.rs index f520ffde42662..88b58be0f250a 100644 --- a/benches/benches/bevy_ecs/iteration/iter_simple_foreach_wide_sparse_set.rs +++ b/benches/benches/bevy_ecs/iteration/iter_simple_foreach_wide_sparse_set.rs @@ -35,8 +35,8 @@ impl<'w> Benchmark<'w> { pub fn new() -> Self { let mut world = World::new(); - world.spawn_batch( - core::iter::repeat(( + world.spawn_batch(core::iter::repeat_n( + ( Transform(Mat4::from_scale(Vec3::ONE)), Rotation(Vec3::X), Position::<0>(Vec3::X), @@ -49,9 +49,9 @@ impl<'w> Benchmark<'w> { Velocity::<3>(Vec3::X), Position::<4>(Vec3::X), Velocity::<4>(Vec3::X), - )) - .take(10_000), - ); + ), + 10_000, + )); let query = world.query(); Self(world, query) diff --git a/benches/benches/bevy_ecs/iteration/iter_simple_sparse_set.rs b/benches/benches/bevy_ecs/iteration/iter_simple_sparse_set.rs index e4ba3759412c7..ed1c531c1ded8 100644 --- a/benches/benches/bevy_ecs/iteration/iter_simple_sparse_set.rs +++ b/benches/benches/bevy_ecs/iteration/iter_simple_sparse_set.rs @@ -21,15 +21,15 @@ impl<'w> Benchmark<'w> { pub fn new() -> Self { let mut world = World::new(); - world.spawn_batch( - core::iter::repeat(( + world.spawn_batch(core::iter::repeat_n( + ( Transform(Mat4::from_scale(Vec3::ONE)), Position(Vec3::X), Rotation(Vec3::X), Velocity(Vec3::X), - )) - .take(10_000), - ); + ), + 10_000, + )); let query = world.query::<(&Velocity, &mut Position)>(); Self(world, query) diff --git a/benches/benches/bevy_ecs/iteration/iter_simple_system.rs b/benches/benches/bevy_ecs/iteration/iter_simple_system.rs index 18918ee234f9f..2b6e8287218c2 100644 --- a/benches/benches/bevy_ecs/iteration/iter_simple_system.rs +++ b/benches/benches/bevy_ecs/iteration/iter_simple_system.rs @@ -19,15 +19,15 @@ impl Benchmark { pub fn new() -> Self { let mut world = World::new(); - world.spawn_batch( - core::iter::repeat(( + world.spawn_batch(core::iter::repeat_n( + ( Transform(Mat4::from_scale(Vec3::ONE)), Position(Vec3::X), Rotation(Vec3::X), Velocity(Vec3::X), - )) - .take(10_000), - ); + ), + 10_000, + )); fn query_system(mut query: Query<(&Velocity, &mut Position)>) { for (velocity, mut position) in &mut query { diff --git a/benches/benches/bevy_ecs/iteration/iter_simple_wide.rs b/benches/benches/bevy_ecs/iteration/iter_simple_wide.rs index 7d013b3bf6003..dccd1fe8b362b 100644 --- a/benches/benches/bevy_ecs/iteration/iter_simple_wide.rs +++ b/benches/benches/bevy_ecs/iteration/iter_simple_wide.rs @@ -33,8 +33,8 @@ impl<'w> Benchmark<'w> { pub fn new() -> Self { let mut world = World::new(); - world.spawn_batch( - core::iter::repeat(( + world.spawn_batch(core::iter::repeat_n( + ( Transform(Mat4::from_scale(Vec3::ONE)), Rotation(Vec3::X), Position::<0>(Vec3::X), @@ -47,9 +47,9 @@ impl<'w> Benchmark<'w> { Velocity::<3>(Vec3::X), Position::<4>(Vec3::X), Velocity::<4>(Vec3::X), - )) - .take(10_000), - ); + ), + 10_000, + )); let query = world.query(); Self(world, query) diff --git a/benches/benches/bevy_ecs/iteration/iter_simple_wide_sparse_set.rs b/benches/benches/bevy_ecs/iteration/iter_simple_wide_sparse_set.rs index 28a6dbd85dc28..49677dc1b9ac8 100644 --- a/benches/benches/bevy_ecs/iteration/iter_simple_wide_sparse_set.rs +++ b/benches/benches/bevy_ecs/iteration/iter_simple_wide_sparse_set.rs @@ -35,8 +35,8 @@ impl<'w> Benchmark<'w> { pub fn new() -> Self { let mut world = World::new(); - world.spawn_batch( - core::iter::repeat(( + world.spawn_batch(core::iter::repeat_n( + ( Transform(Mat4::from_scale(Vec3::ONE)), Rotation(Vec3::X), Position::<0>(Vec3::X), @@ -49,9 +49,9 @@ impl<'w> Benchmark<'w> { Velocity::<3>(Vec3::X), Position::<4>(Vec3::X), Velocity::<4>(Vec3::X), - )) - .take(10_000), - ); + ), + 10_000, + )); let query = world.query(); Self(world, query) diff --git a/benches/benches/bevy_ecs/iteration/par_iter_simple.rs b/benches/benches/bevy_ecs/iteration/par_iter_simple.rs index 971598005ab1b..92259cb98fecf 100644 --- a/benches/benches/bevy_ecs/iteration/par_iter_simple.rs +++ b/benches/benches/bevy_ecs/iteration/par_iter_simple.rs @@ -30,15 +30,15 @@ impl<'w> Benchmark<'w> { let mut world = World::new(); - let iter = world.spawn_batch( - core::iter::repeat(( + let iter = world.spawn_batch(core::iter::repeat_n( + ( Transform(Mat4::from_scale(Vec3::ONE)), Position(Vec3::X), Rotation(Vec3::X), Velocity(Vec3::X), - )) - .take(100_000), - ); + ), + 100_000, + )); let entities = iter.into_iter().collect::>(); for i in 0..fragment { let mut e = world.entity_mut(entities[i as usize]); diff --git a/benches/benches/bevy_reflect/list.rs b/benches/benches/bevy_reflect/list.rs index 872c2dd0cb898..c6c94ac2f7c47 100644 --- a/benches/benches/bevy_reflect/list.rs +++ b/benches/benches/bevy_reflect/list.rs @@ -75,8 +75,8 @@ fn concrete_list_apply(criterion: &mut Criterion) { let mut group = create_group(criterion, bench!("concrete_list_apply")); let empty_base = |_: usize| Vec::::new; - let full_base = |size: usize| move || iter::repeat(0).take(size).collect::>(); - let patch = |size: usize| iter::repeat(1).take(size).collect::>(); + let full_base = |size: usize| move || iter::repeat_n(0, size).collect::>(); + let patch = |size: usize| iter::repeat_n(1, size).collect::>(); list_apply(&mut group, "empty_base_concrete_patch", empty_base, patch); @@ -103,7 +103,7 @@ fn concrete_list_clone_dynamic(criterion: &mut Criterion) { BenchmarkId::from_parameter(size), &size, |bencher, &size| { - let v = iter::repeat(0).take(size).collect::>(); + let v = iter::repeat_n(0, size).collect::>(); bencher.iter(|| black_box(&v).clone_dynamic()); }, @@ -123,7 +123,7 @@ fn dynamic_list_push(criterion: &mut Criterion) { BenchmarkId::from_parameter(size), &size, |bencher, &size| { - let src = iter::repeat(()).take(size).collect::>(); + let src = iter::repeat_n((), size).collect::>(); let dst = DynamicList::default(); bencher.iter_batched( @@ -146,8 +146,8 @@ fn dynamic_list_apply(criterion: &mut Criterion) { let mut group = create_group(criterion, bench!("dynamic_list_apply")); let empty_base = |_: usize| || Vec::::new().clone_dynamic(); - let full_base = |size: usize| move || iter::repeat(0).take(size).collect::>(); - let patch = |size: usize| iter::repeat(1).take(size).collect::>(); + let full_base = |size: usize| move || iter::repeat_n(0, size).collect::>(); + let patch = |size: usize| iter::repeat_n(1, size).collect::>(); list_apply(&mut group, "empty_base_concrete_patch", empty_base, patch); diff --git a/benches/benches/bevy_reflect/map.rs b/benches/benches/bevy_reflect/map.rs index 4525ed8598926..cd0ed188474e7 100644 --- a/benches/benches/bevy_reflect/map.rs +++ b/benches/benches/bevy_reflect/map.rs @@ -145,7 +145,7 @@ fn u64_to_n_byte_key(k: u64, n: usize) -> String { write!(&mut key, "{}", k).unwrap(); // Pad key to n bytes. - key.extend(iter::repeat('\0').take(n - key.len())); + key.extend(iter::repeat_n('\0', n - key.len())); key } diff --git a/crates/bevy_animation/src/graph.rs b/crates/bevy_animation/src/graph.rs index 1729841f02641..146bd8da3e45b 100644 --- a/crates/bevy_animation/src/graph.rs +++ b/crates/bevy_animation/src/graph.rs @@ -884,10 +884,10 @@ impl ThreadedAnimationGraph { self.sorted_edge_ranges.clear(); self.sorted_edge_ranges - .extend(iter::repeat(0..0).take(node_count)); + .extend(iter::repeat_n(0..0, node_count)); self.computed_masks.clear(); - self.computed_masks.extend(iter::repeat(0).take(node_count)); + self.computed_masks.extend(iter::repeat_n(0, node_count)); } /// Recursively constructs the [`ThreadedAnimationGraph`] for the subtree diff --git a/crates/bevy_app/src/app.rs b/crates/bevy_app/src/app.rs index cee160f0e7049..a82bf6610912a 100644 --- a/crates/bevy_app/src/app.rs +++ b/crates/bevy_app/src/app.rs @@ -1435,7 +1435,7 @@ impl Termination for AppExit { #[cfg(test)] mod tests { - use core::{iter, marker::PhantomData}; + use core::marker::PhantomData; use std::sync::Mutex; use bevy_ecs::{ @@ -1659,7 +1659,7 @@ mod tests { struct Foo; let mut app = App::new(); - app.world_mut().spawn_batch(iter::repeat(Foo).take(5)); + app.world_mut().spawn_batch(core::iter::repeat_n(Foo, 5)); fn despawn_one_foo(mut commands: Commands, foos: Query>) { if let Some(e) = foos.iter().next() { diff --git a/crates/bevy_app/src/panic_handler.rs b/crates/bevy_app/src/panic_handler.rs index 56d66da7281b2..5a2ae097ff053 100644 --- a/crates/bevy_app/src/panic_handler.rs +++ b/crates/bevy_app/src/panic_handler.rs @@ -11,7 +11,7 @@ use crate::{App, Plugin}; /// Adds sensible panic handlers to Apps. This plugin is part of the `DefaultPlugins`. Adding /// this plugin will setup a panic hook appropriate to your target platform: /// * On Wasm, uses [`console_error_panic_hook`](https://crates.io/crates/console_error_panic_hook), logging -/// to the browser console. +/// to the browser console. /// * Other platforms are currently not setup. /// /// ```no_run diff --git a/crates/bevy_asset/src/lib.rs b/crates/bevy_asset/src/lib.rs index f0b8e92a9320d..7d1d6dc32778f 100644 --- a/crates/bevy_asset/src/lib.rs +++ b/crates/bevy_asset/src/lib.rs @@ -499,8 +499,8 @@ pub trait AssetApp { /// * Initializing the [`AssetEvent`] resource for the [`Asset`] /// * Adding other relevant systems and resources for the [`Asset`] /// * Ignoring schedule ambiguities in [`Assets`] resource. Any time a system takes - /// mutable access to this resource this causes a conflict, but they rarely actually - /// modify the same underlying asset. + /// mutable access to this resource this causes a conflict, but they rarely actually + /// modify the same underlying asset. fn init_asset(&mut self) -> &mut Self; /// Registers the asset type `T` using `[App::register]`, /// and adds [`ReflectAsset`] type data to `T` and [`ReflectHandle`] type data to [`Handle`] in the type registry. diff --git a/crates/bevy_asset/src/loader.rs b/crates/bevy_asset/src/loader.rs index 3be672e0c194d..caccaa1b0ea2c 100644 --- a/crates/bevy_asset/src/loader.rs +++ b/crates/bevy_asset/src/loader.rs @@ -552,8 +552,8 @@ impl<'a> LoadContext<'a> { let path = path.into(); let source = self.asset_server.get_source(path.source())?; let asset_reader = match self.asset_server.mode() { - AssetServerMode::Unprocessed { .. } => source.reader(), - AssetServerMode::Processed { .. } => source.processed_reader()?, + AssetServerMode::Unprocessed => source.reader(), + AssetServerMode::Processed => source.processed_reader()?, }; let mut reader = asset_reader.read(path.path()).await?; let hash = if self.populate_hashes { diff --git a/crates/bevy_asset/src/path.rs b/crates/bevy_asset/src/path.rs index 3038c52fbadbe..f21bb96db97d7 100644 --- a/crates/bevy_asset/src/path.rs +++ b/crates/bevy_asset/src/path.rs @@ -18,10 +18,10 @@ use thiserror::Error; /// /// Asset paths consist of three main parts: /// * [`AssetPath::source`]: The name of the [`AssetSource`](crate::io::AssetSource) to load the asset from. -/// This is optional. If one is not set the default source will be used (which is the `assets` folder by default). +/// This is optional. If one is not set the default source will be used (which is the `assets` folder by default). /// * [`AssetPath::path`]: The "virtual filesystem path" pointing to an asset source file. /// * [`AssetPath::label`]: An optional "named sub asset". When assets are loaded, they are -/// allowed to load "sub assets" of any type, which are identified by a named "label". +/// allowed to load "sub assets" of any type, which are identified by a named "label". /// /// Asset paths are generally constructed (and visualized) as strings: /// diff --git a/crates/bevy_asset/src/processor/mod.rs b/crates/bevy_asset/src/processor/mod.rs index bfc9a295d86d3..d0db3dc90f718 100644 --- a/crates/bevy_asset/src/processor/mod.rs +++ b/crates/bevy_asset/src/processor/mod.rs @@ -207,10 +207,13 @@ impl AssetProcessor { /// Processes all assets. This will: /// * For each "processed [`AssetSource`]: /// * Scan the [`ProcessorTransactionLog`] and recover from any failures detected - /// * Scan the processed [`AssetReader`](crate::io::AssetReader) to build the current view of already processed assets. - /// * Scan the unprocessed [`AssetReader`](crate::io::AssetReader) and remove any final processed assets that are invalid or no longer exist. - /// * For each asset in the unprocessed [`AssetReader`](crate::io::AssetReader), kick off a new "process job", which will process the asset - /// (if the latest version of the asset has not been processed). + /// * Scan the processed [`AssetReader`](crate::io::AssetReader) to build the current view of + /// already processed assets. + /// * Scan the unprocessed [`AssetReader`](crate::io::AssetReader) and remove any final + /// processed assets that are invalid or no longer exist. + /// * For each asset in the unprocessed [`AssetReader`](crate::io::AssetReader), kick off a new + /// "process job", which will process the asset + /// (if the latest version of the asset has not been processed). #[cfg(all(not(target_arch = "wasm32"), feature = "multi_threaded"))] pub fn process_assets(&self) { let start_time = std::time::Instant::now(); diff --git a/crates/bevy_asset/src/server/mod.rs b/crates/bevy_asset/src/server/mod.rs index e65bbd2b6acb7..fec52f78d0967 100644 --- a/crates/bevy_asset/src/server/mod.rs +++ b/crates/bevy_asset/src/server/mod.rs @@ -38,12 +38,13 @@ use std::path::{Path, PathBuf}; use thiserror::Error; use tracing::{error, info}; -/// Loads and tracks the state of [`Asset`] values from a configured [`AssetReader`](crate::io::AssetReader). This can be used to kick off new asset loads and -/// retrieve their current load states. +/// Loads and tracks the state of [`Asset`] values from a configured [`AssetReader`](crate::io::AssetReader). +/// This can be used to kick off new asset loads and retrieve their current load states. /// /// The general process to load an asset is: -/// 1. Initialize a new [`Asset`] type with the [`AssetServer`] via [`AssetApp::init_asset`], which will internally call [`AssetServer::register_asset`] -/// and set up related ECS [`Assets`] storage and systems. +/// 1. Initialize a new [`Asset`] type with the [`AssetServer`] via [`AssetApp::init_asset`], which +/// will internally call [`AssetServer::register_asset`] and set up related ECS [`Assets`] +/// storage and systems. /// 2. Register one or more [`AssetLoader`]s for that asset with [`AssetApp::init_asset_loader`] /// 3. Add the asset to your asset folder (defaults to `assets`). /// 4. Call [`AssetServer::load`] with a path to your asset. @@ -923,8 +924,8 @@ impl AssetServer { }; let asset_reader = match server.data.mode { - AssetServerMode::Unprocessed { .. } => source.reader(), - AssetServerMode::Processed { .. } => match source.processed_reader() { + AssetServerMode::Unprocessed => source.reader(), + AssetServerMode::Processed => match source.processed_reader() { Ok(reader) => reader, Err(_) => { error!( @@ -1235,8 +1236,8 @@ impl AssetServer { // Then the meta reader, if meta exists, will correspond to the meta for the current "version" of the asset. // See ProcessedAssetInfo::file_transaction_lock for more context let asset_reader = match self.data.mode { - AssetServerMode::Unprocessed { .. } => source.reader(), - AssetServerMode::Processed { .. } => source.processed_reader()?, + AssetServerMode::Unprocessed => source.reader(), + AssetServerMode::Processed => source.processed_reader()?, }; let reader = asset_reader.read(asset_path.path()).await?; let read_meta = match &self.data.meta_check { @@ -1584,14 +1585,14 @@ pub fn handle_internal_asset_events(world: &mut World) { for source in server.data.sources.iter() { match server.data.mode { - AssetServerMode::Unprocessed { .. } => { + AssetServerMode::Unprocessed => { if let Some(receiver) = source.event_receiver() { for event in receiver.try_iter() { handle_event(source.id(), event); } } } - AssetServerMode::Processed { .. } => { + AssetServerMode::Processed => { if let Some(receiver) = source.processed_event_receiver() { for event in receiver.try_iter() { handle_event(source.id(), event); diff --git a/crates/bevy_dev_tools/src/lib.rs b/crates/bevy_dev_tools/src/lib.rs index 0f9dc75611326..1dfd4734090cc 100644 --- a/crates/bevy_dev_tools/src/lib.rs +++ b/crates/bevy_dev_tools/src/lib.rs @@ -29,7 +29,7 @@ pub mod states; /// To enable developer tools, you can either: /// /// - Create a custom crate feature (e.g "`dev_mode`"), which enables the `bevy_dev_tools` feature -/// along with any other development tools you might be using: +/// along with any other development tools you might be using: /// /// ```toml /// [feature] diff --git a/crates/bevy_ecs/src/change_detection.rs b/crates/bevy_ecs/src/change_detection.rs index 8731fb8eb7863..d173d686c6778 100644 --- a/crates/bevy_ecs/src/change_detection.rs +++ b/crates/bevy_ecs/src/change_detection.rs @@ -811,7 +811,7 @@ impl<'w, T: ?Sized> Ref<'w, T> { /// - `added` - A [`Tick`] that stores the tick when the wrapped value was created. /// - `changed` - A [`Tick`] that stores the last time the wrapped value was changed. /// - `last_run` - A [`Tick`], occurring before `this_run`, which is used - /// as a reference to determine whether the wrapped value is newly added or changed. + /// as a reference to determine whether the wrapped value is newly added or changed. /// - `this_run` - A [`Tick`] corresponding to the current point in time -- "now". pub fn new( value: &'w T, diff --git a/crates/bevy_ecs/src/entity/unique_vec.rs b/crates/bevy_ecs/src/entity/unique_vec.rs index 9ea1f9c7a6b39..785d4fd7c292b 100644 --- a/crates/bevy_ecs/src/entity/unique_vec.rs +++ b/crates/bevy_ecs/src/entity/unique_vec.rs @@ -809,7 +809,7 @@ impl Extend for UniqueEntityVec { let reserve = if self.is_empty() { iter.size_hint().0 } else { - (iter.size_hint().0 + 1) / 2 + iter.size_hint().0.div_ceil(2) }; self.reserve(reserve); // Internal iteration (fold/for_each) is known to result in better code generation @@ -836,7 +836,7 @@ impl<'a, T: TrustedEntityBorrow + Copy + 'a> Extend<&'a T> for UniqueEntityVec| -> () { - panic!("Observer triggered after being despawned.") - }) - .id(); + let system: fn(Trigger) = |_| { + panic!("Observer triggered after being despawned."); + }; + let observer = world.add_observer(system).id(); world.despawn(observer); world.spawn(A).flush(); } @@ -1136,11 +1135,11 @@ mod tests { res.observed("remove_a"); }); - let observer = world - .add_observer(|_: Trigger| -> () { - panic!("Observer triggered after being despawned."); - }) - .flush(); + let system: fn(Trigger) = |_: Trigger| { + panic!("Observer triggered after being despawned."); + }; + + let observer = world.add_observer(system).flush(); world.despawn(observer); world.despawn(entity); @@ -1166,9 +1165,10 @@ mod tests { let mut world = World::new(); world.init_resource::(); - world.spawn_empty().observe(|_: Trigger| -> () { + let system: fn(Trigger) = |_| { panic!("Trigger routed to non-targeted entity."); - }); + }; + world.spawn_empty().observe(system); world.add_observer(move |obs: Trigger, mut res: ResMut| { assert_eq!(obs.target(), Entity::PLACEHOLDER); res.observed("event_a"); @@ -1187,9 +1187,11 @@ mod tests { let mut world = World::new(); world.init_resource::(); - world.spawn_empty().observe(|_: Trigger| -> () { + let system: fn(Trigger) = |_| { panic!("Trigger routed to non-targeted entity."); - }); + }; + + world.spawn_empty().observe(system); let entity = world .spawn_empty() .observe(|_: Trigger, mut res: ResMut| res.observed("a_1")) diff --git a/crates/bevy_ecs/src/query/access.rs b/crates/bevy_ecs/src/query/access.rs index 089d6914c6358..da8c2ef68035a 100644 --- a/crates/bevy_ecs/src/query/access.rs +++ b/crates/bevy_ecs/src/query/access.rs @@ -819,7 +819,7 @@ impl Access { /// otherwise would allow for queries to be considered disjoint when they shouldn't: /// - `Query<(&mut T, Option<&U>)>` read/write `T`, read `U`, with `U` /// - `Query<&mut T, Without>` read/write `T`, without `U` -/// from this we could reasonably conclude that the queries are disjoint but they aren't. +/// from this we could reasonably conclude that the queries are disjoint but they aren't. /// /// In order to solve this the actual access that `Query<(&mut T, Option<&U>)>` has /// is read/write `T`, read `U`. It must still have a read `U` access otherwise the following diff --git a/crates/bevy_ecs/src/query/state.rs b/crates/bevy_ecs/src/query/state.rs index 1e851285dcb03..1dfcb922d3de1 100644 --- a/crates/bevy_ecs/src/query/state.rs +++ b/crates/bevy_ecs/src/query/state.rs @@ -51,9 +51,9 @@ pub(super) union StorageId { /// /// This data is cached between system runs, and is used to: /// - store metadata about which [`Table`] or [`Archetype`] are matched by the query. "Matched" means -/// that the query will iterate over the data in the matched table/archetype. +/// that the query will iterate over the data in the matched table/archetype. /// - cache the [`State`] needed to compute the [`Fetch`] struct used to retrieve data -/// from a specific [`Table`] or [`Archetype`] +/// from a specific [`Table`] or [`Archetype`] /// - build iterators that can iterate over the query results /// /// [`State`]: crate::query::world_query::WorldQuery::State diff --git a/crates/bevy_ecs/src/reflect/entity_commands.rs b/crates/bevy_ecs/src/reflect/entity_commands.rs index 9aef8105a53ca..725c61265f865 100644 --- a/crates/bevy_ecs/src/reflect/entity_commands.rs +++ b/crates/bevy_ecs/src/reflect/entity_commands.rs @@ -20,7 +20,7 @@ pub trait ReflectCommandExt { /// /// - If the entity doesn't exist. /// - If [`AppTypeRegistry`] does not have the reflection data for the given - /// [`Component`](crate::component::Component) or [`Bundle`](crate::bundle::Bundle). + /// [`Component`](crate::component::Component) or [`Bundle`](crate::bundle::Bundle). /// - If the component or bundle data is invalid. See [`PartialReflect::apply`] for further details. /// - If [`AppTypeRegistry`] is not present in the [`World`]. /// @@ -212,7 +212,7 @@ impl<'w> EntityWorldMut<'w> { /// /// - If the entity has been despawned while this `EntityWorldMut` is still alive. /// - If [`AppTypeRegistry`] does not have the reflection data for the given - /// [`Component`](crate::component::Component) or [`Bundle`](crate::bundle::Bundle). + /// [`Component`](crate::component::Component) or [`Bundle`](crate::bundle::Bundle). /// - If the component or bundle data is invalid. See [`PartialReflect::apply`] for further details. /// - If [`AppTypeRegistry`] is not present in the [`World`]. /// @@ -243,7 +243,7 @@ impl<'w> EntityWorldMut<'w> { /// /// - If the entity has been despawned while this `EntityWorldMut` is still alive. /// - If the given [`Resource`] does not have the reflection data for the given - /// [`Component`](crate::component::Component) or [`Bundle`](crate::bundle::Bundle). + /// [`Component`](crate::component::Component) or [`Bundle`](crate::bundle::Bundle). /// - If the component or bundle data is invalid. See [`PartialReflect::apply`] for further details. /// - If the given [`Resource`] is not present in the [`World`]. pub fn insert_reflect_with_registry>( diff --git a/crates/bevy_ecs/src/schedule/schedule.rs b/crates/bevy_ecs/src/schedule/schedule.rs index b121bf6ac21cf..18f3fadd698b7 100644 --- a/crates/bevy_ecs/src/schedule/schedule.rs +++ b/crates/bevy_ecs/src/schedule/schedule.rs @@ -2062,14 +2062,12 @@ mod tests { let mut world = World::new(); let mut schedule = Schedule::default(); + let system: fn() = || { + panic!("This system must not run"); + }; + schedule.configure_sets(Set.run_if(|| false)); - schedule.add_systems( - (|| -> () { - panic!("This system must not run"); - }) - .ambiguous_with(|| ()) - .in_set(Set), - ); + schedule.add_systems(system.ambiguous_with(|| ()).in_set(Set)); schedule.run(&mut world); } diff --git a/crates/bevy_ecs/src/schedule/stepping.rs b/crates/bevy_ecs/src/schedule/stepping.rs index 9b23fe9313841..7902460da34db 100644 --- a/crates/bevy_ecs/src/schedule/stepping.rs +++ b/crates/bevy_ecs/src/schedule/stepping.rs @@ -1348,7 +1348,7 @@ mod tests { // // first system will be configured as `run_if(|| false)`, so it can // just panic if called - let first_system = move || -> () { + let first_system: fn() = move || { panic!("first_system should not be run"); }; diff --git a/crates/bevy_ecs/src/storage/blob_array.rs b/crates/bevy_ecs/src/storage/blob_array.rs index 911efde621b36..f5f58c4af8fa6 100644 --- a/crates/bevy_ecs/src/storage/blob_array.rs +++ b/crates/bevy_ecs/src/storage/blob_array.rs @@ -76,7 +76,7 @@ impl BlobArray { /// /// # Safety /// - The element at index `index` is safe to access. - /// (If the safety requirements of every method that has been used on `Self` have been fulfilled, the caller just needs to ensure that `index` < `len`) + /// (If the safety requirements of every method that has been used on `Self` have been fulfilled, the caller just needs to ensure that `index` < `len`) /// /// [`Vec::len`]: alloc::vec::Vec::len #[inline] @@ -99,7 +99,7 @@ impl BlobArray { /// /// # Safety /// - The element with at index `index` is safe to access. - /// (If the safety requirements of every method that has been used on `Self` have been fulfilled, the caller just needs to ensure that `index` < `len`) + /// (If the safety requirements of every method that has been used on `Self` have been fulfilled, the caller just needs to ensure that `index` < `len`) /// /// [`Vec::len`]: alloc::vec::Vec::len #[inline] @@ -156,7 +156,7 @@ impl BlobArray { /// /// # Safety /// - For every element with index `i`, if `i` < `len`: It must be safe to call [`Self::get_unchecked_mut`] with `i`. - /// (If the safety requirements of every method that has been used on `Self` have been fulfilled, the caller just needs to ensure that `len` is correct.) + /// (If the safety requirements of every method that has been used on `Self` have been fulfilled, the caller just needs to ensure that `len` is correct.) /// /// [`Vec::clear`]: alloc::vec::Vec::clear pub unsafe fn clear(&mut self, len: usize) { @@ -289,7 +289,7 @@ impl BlobArray { /// # Safety /// - `index` must be in bounds (`index` < capacity) /// - The [`Layout`] of the value must match the layout of the blobs stored in this array, - /// and it must be safe to use the `drop` function of this [`BlobArray`] to drop `value`. + /// and it must be safe to use the `drop` function of this [`BlobArray`] to drop `value`. /// - `value` must not point to the same value that is being initialized. #[inline] pub unsafe fn initialize_unchecked(&mut self, index: usize, value: OwningPtr<'_>) { @@ -305,7 +305,7 @@ impl BlobArray { /// # Safety /// - Index must be in-bounds (`index` < `len`) /// - `value`'s [`Layout`] must match this [`BlobArray`]'s `item_layout`, - /// and it must be safe to use the `drop` function of this [`BlobArray`] to drop `value`. + /// and it must be safe to use the `drop` function of this [`BlobArray`] to drop `value`. /// - `value` must not point to the same value that is being replaced. pub unsafe fn replace_unchecked(&mut self, index: usize, value: OwningPtr<'_>) { #[cfg(debug_assertions)] diff --git a/crates/bevy_ecs/src/storage/blob_vec.rs b/crates/bevy_ecs/src/storage/blob_vec.rs index 971cf80fa7820..2451fccb140f8 100644 --- a/crates/bevy_ecs/src/storage/blob_vec.rs +++ b/crates/bevy_ecs/src/storage/blob_vec.rs @@ -176,7 +176,7 @@ impl BlobVec { /// # Safety /// - index must be in bounds /// - the memory in the [`BlobVec`] starting at index `index`, of a size matching this [`BlobVec`]'s - /// `item_layout`, must have been previously allocated. + /// `item_layout`, must have been previously allocated. #[inline] pub unsafe fn initialize_unchecked(&mut self, index: usize, value: OwningPtr<'_>) { debug_assert!(index < self.len()); @@ -189,10 +189,10 @@ impl BlobVec { /// # Safety /// - index must be in-bounds /// - the memory in the [`BlobVec`] starting at index `index`, of a size matching this - /// [`BlobVec`]'s `item_layout`, must have been previously initialized with an item matching - /// this [`BlobVec`]'s `item_layout` + /// [`BlobVec`]'s `item_layout`, must have been previously initialized with an item matching + /// this [`BlobVec`]'s `item_layout` /// - the memory at `*value` must also be previously initialized with an item matching this - /// [`BlobVec`]'s `item_layout` + /// [`BlobVec`]'s `item_layout` pub unsafe fn replace_unchecked(&mut self, index: usize, value: OwningPtr<'_>) { debug_assert!(index < self.len()); diff --git a/crates/bevy_ecs/src/system/mod.rs b/crates/bevy_ecs/src/system/mod.rs index 9a5523174150b..a8a3404537671 100644 --- a/crates/bevy_ecs/src/system/mod.rs +++ b/crates/bevy_ecs/src/system/mod.rs @@ -1648,9 +1648,10 @@ mod tests { #[should_panic] fn panic_inside_system() { let mut world = World::new(); - run_system(&mut world, || -> () { + let system: fn() = || { panic!("this system panics"); - }); + }; + run_system(&mut world, system); } #[test] diff --git a/crates/bevy_ecs/src/world/entity_ref.rs b/crates/bevy_ecs/src/world/entity_ref.rs index 17367e56df70f..4feb96bccf82a 100644 --- a/crates/bevy_ecs/src/world/entity_ref.rs +++ b/crates/bevy_ecs/src/world/entity_ref.rs @@ -105,7 +105,7 @@ impl<'w> EntityRef<'w> { /// /// - If you know the concrete type of the component, you should prefer [`Self::contains`]. /// - If you know the component's [`TypeId`] but not its [`ComponentId`], consider using - /// [`Self::contains_type_id`]. + /// [`Self::contains_type_id`]. #[inline] pub fn contains_id(&self, component_id: ComponentId) -> bool { self.cell.contains_id(component_id) @@ -510,7 +510,7 @@ impl<'w> EntityMut<'w> { /// /// - If you know the concrete type of the component, you should prefer [`Self::contains`]. /// - If you know the component's [`TypeId`] but not its [`ComponentId`], consider using - /// [`Self::contains_type_id`]. + /// [`Self::contains_type_id`]. #[inline] pub fn contains_id(&self, component_id: ComponentId) -> bool { self.cell.contains_id(component_id) @@ -1134,7 +1134,7 @@ impl<'w> EntityWorldMut<'w> { /// /// - If you know the concrete type of the component, you should prefer [`Self::contains`]. /// - If you know the component's [`TypeId`] but not its [`ComponentId`], consider using - /// [`Self::contains_type_id`]. + /// [`Self::contains_type_id`]. /// /// # Panics /// @@ -3052,7 +3052,7 @@ impl<'w> FilteredEntityRef<'w> { /// # Safety /// - No `&mut World` can exist from the underlying `UnsafeWorldCell` /// - If `access` takes read access to a component no mutable reference to that - /// component can exist at the same time as the returned [`FilteredEntityMut`] + /// component can exist at the same time as the returned [`FilteredEntityMut`] /// - If `access` takes any access for a component `entity` must have that component. #[inline] pub(crate) unsafe fn new(entity: UnsafeEntityCell<'w>, access: Access) -> Self { @@ -3103,7 +3103,7 @@ impl<'w> FilteredEntityRef<'w> { /// /// - If you know the concrete type of the component, you should prefer [`Self::contains`]. /// - If you know the component's [`TypeId`] but not its [`ComponentId`], consider using - /// [`Self::contains_type_id`]. + /// [`Self::contains_type_id`]. #[inline] pub fn contains_id(&self, component_id: ComponentId) -> bool { self.entity.contains_id(component_id) @@ -3382,9 +3382,9 @@ impl<'w> FilteredEntityMut<'w> { /// # Safety /// - No `&mut World` can exist from the underlying `UnsafeWorldCell` /// - If `access` takes read access to a component no mutable reference to that - /// component can exist at the same time as the returned [`FilteredEntityMut`] + /// component can exist at the same time as the returned [`FilteredEntityMut`] /// - If `access` takes write access to a component, no reference to that component - /// may exist at the same time as the returned [`FilteredEntityMut`] + /// may exist at the same time as the returned [`FilteredEntityMut`] /// - If `access` takes any access for a component `entity` must have that component. #[inline] pub(crate) unsafe fn new(entity: UnsafeEntityCell<'w>, access: Access) -> Self { @@ -3448,7 +3448,7 @@ impl<'w> FilteredEntityMut<'w> { /// /// - If you know the concrete type of the component, you should prefer [`Self::contains`]. /// - If you know the component's [`TypeId`] but not its [`ComponentId`], consider using - /// [`Self::contains_type_id`]. + /// [`Self::contains_type_id`]. #[inline] pub fn contains_id(&self, component_id: ComponentId) -> bool { self.entity.contains_id(component_id) @@ -3812,7 +3812,7 @@ where /// /// - If you know the concrete type of the component, you should prefer [`Self::contains`]. /// - If you know the component's [`TypeId`] but not its [`ComponentId`], consider using - /// [`Self::contains_type_id`]. + /// [`Self::contains_type_id`]. #[inline] pub fn contains_id(&self, component_id: ComponentId) -> bool { self.entity.contains_id(component_id) @@ -4037,7 +4037,7 @@ where /// /// - If you know the concrete type of the component, you should prefer [`Self::contains`]. /// - If you know the component's [`TypeId`] but not its [`ComponentId`], consider using - /// [`Self::contains_type_id`]. + /// [`Self::contains_type_id`]. #[inline] pub fn contains_id(&self, component_id: ComponentId) -> bool { self.entity.contains_id(component_id) @@ -4146,7 +4146,7 @@ where /// # Safety /// /// - [`OwningPtr`] and [`StorageType`] iterators must correspond to the -/// [`BundleInfo`] used to construct [`BundleInserter`] +/// [`BundleInfo`] used to construct [`BundleInserter`] /// - [`Entity`] must correspond to [`EntityLocation`] unsafe fn insert_dynamic_bundle< 'a, diff --git a/crates/bevy_ecs/src/world/unsafe_world_cell.rs b/crates/bevy_ecs/src/world/unsafe_world_cell.rs index cbaffb299192c..b2afb67359daf 100644 --- a/crates/bevy_ecs/src/world/unsafe_world_cell.rs +++ b/crates/bevy_ecs/src/world/unsafe_world_cell.rs @@ -748,7 +748,7 @@ impl<'w> UnsafeEntityCell<'w> { /// /// - If you know the concrete type of the component, you should prefer [`Self::contains`]. /// - If you know the component's [`TypeId`] but not its [`ComponentId`], consider using - /// [`Self::contains_type_id`]. + /// [`Self::contains_type_id`]. #[inline] pub fn contains_id(self, component_id: ComponentId) -> bool { self.archetype().contains(component_id) @@ -1125,7 +1125,7 @@ impl<'w> UnsafeWorldCell<'w> { /// /// # Safety /// - `location` must refer to an archetype that contains `entity` -/// the archetype +/// the archetype /// - `component_id` must be valid /// - `storage_type` must accurately reflect where the components for `component_id` are stored. /// - the caller must ensure that no aliasing rules are violated @@ -1195,7 +1195,7 @@ unsafe fn get_component_and_ticks( /// /// # Safety /// - `location` must refer to an archetype that contains `entity` -/// the archetype +/// the archetype /// - `component_id` must be valid /// - `storage_type` must accurately reflect where the components for `component_id` are stored. /// - the caller must ensure that no aliasing rules are violated diff --git a/crates/bevy_gizmos/src/arcs.rs b/crates/bevy_gizmos/src/arcs.rs index 65f5f67ee7e4f..41647f9fe21a2 100644 --- a/crates/bevy_gizmos/src/arcs.rs +++ b/crates/bevy_gizmos/src/arcs.rs @@ -136,11 +136,11 @@ where /// /// # Arguments /// - `angle`: sets how much of a circle circumference is passed, e.g. PI is half a circle. This - /// value should be in the range (-2 * PI..=2 * PI) + /// value should be in the range (-2 * PI..=2 * PI) /// - `radius`: distance between the arc and its center point /// - `isometry` defines the translation and rotation of the arc. - /// - the translation specifies the center of the arc - /// - the rotation is counter-clockwise starting from `Vec3::Y` + /// - the translation specifies the center of the arc + /// - the rotation is counter-clockwise starting from `Vec3::Y` /// - `color`: color of the arc /// /// # Builder methods @@ -219,10 +219,10 @@ where /// /// # Notes /// - This method assumes that the points `from` and `to` are distinct from `center`. If one of - /// the points is coincident with `center`, nothing is rendered. + /// the points is coincident with `center`, nothing is rendered. /// - The arc is drawn as a portion of a circle with a radius equal to the distance from the - /// `center` to `from`. If the distance from `center` to `to` is not equal to the radius, then - /// the results will behave as if this were the case + /// `center` to `from`. If the distance from `center` to `to` is not equal to the radius, then + /// the results will behave as if this were the case #[inline] pub fn short_arc_3d_between( &mut self, @@ -265,10 +265,10 @@ where /// /// # Notes /// - This method assumes that the points `from` and `to` are distinct from `center`. If one of - /// the points is coincident with `center`, nothing is rendered. + /// the points is coincident with `center`, nothing is rendered. /// - The arc is drawn as a portion of a circle with a radius equal to the distance from the - /// `center` to `from`. If the distance from `center` to `to` is not equal to the radius, then - /// the results will behave as if this were the case. + /// `center` to `from`. If the distance from `center` to `to` is not equal to the radius, then + /// the results will behave as if this were the case. #[inline] pub fn long_arc_3d_between( &mut self, @@ -352,10 +352,10 @@ where /// /// # Notes /// - This method assumes that the points `from` and `to` are distinct from `center`. If one of - /// the points is coincident with `center`, nothing is rendered. + /// the points is coincident with `center`, nothing is rendered. /// - The arc is drawn as a portion of a circle with a radius equal to the distance from the - /// `center` to `from`. If the distance from `center` to `to` is not equal to the radius, then - /// the results will behave as if this were the case + /// `center` to `from`. If the distance from `center` to `to` is not equal to the radius, then + /// the results will behave as if this were the case #[inline] pub fn short_arc_2d_between( &mut self, @@ -398,10 +398,10 @@ where /// /// # Notes /// - This method assumes that the points `from` and `to` are distinct from `center`. If one of - /// the points is coincident with `center`, nothing is rendered. + /// the points is coincident with `center`, nothing is rendered. /// - The arc is drawn as a portion of a circle with a radius equal to the distance from the - /// `center` to `from`. If the distance from `center` to `to` is not equal to the radius, then - /// the results will behave as if this were the case. + /// `center` to `from`. If the distance from `center` to `to` is not equal to the radius, then + /// the results will behave as if this were the case. #[inline] pub fn long_arc_2d_between( &mut self, diff --git a/crates/bevy_gizmos/src/gizmos.rs b/crates/bevy_gizmos/src/gizmos.rs index b1fe363f510cb..2d8c523e0742a 100644 --- a/crates/bevy_gizmos/src/gizmos.rs +++ b/crates/bevy_gizmos/src/gizmos.rs @@ -820,8 +820,7 @@ where let polymorphic_color: Color = color.into(); let linear_color = LinearRgba::from(polymorphic_color); - self.list_colors - .extend(iter::repeat(linear_color).take(count)); + self.list_colors.extend(iter::repeat_n(linear_color, count)); } #[inline] diff --git a/crates/bevy_gizmos/src/grid.rs b/crates/bevy_gizmos/src/grid.rs index 42742e196c77c..cdcfc41236fd5 100644 --- a/crates/bevy_gizmos/src/grid.rs +++ b/crates/bevy_gizmos/src/grid.rs @@ -186,10 +186,9 @@ where /// # Arguments /// /// - `isometry` defines the translation and rotation of the grid. - /// - the translation specifies the center of the grid - /// - defines the orientation of the grid, by default - /// we assume the grid is contained in a plane parallel - /// to the XY plane + /// - the translation specifies the center of the grid + /// - defines the orientation of the grid, by default we assume the grid is contained in a + /// plane parallel to the XY plane /// - `cell_count`: defines the amount of cells in the x and y axes /// - `spacing`: defines the distance between cells along the x and y axes /// - `color`: color of the grid @@ -241,9 +240,8 @@ where /// # Arguments /// /// - `isometry` defines the translation and rotation of the grid. - /// - the translation specifies the center of the grid - /// - defines the orientation of the grid, by default - /// we assume the grid is aligned with all axes + /// - the translation specifies the center of the grid + /// - defines the orientation of the grid, by default we assume the grid is aligned with all axes /// - `cell_count`: defines the amount of cells in the x, y and z axes /// - `spacing`: defines the distance between cells along the x, y and z axes /// - `color`: color of the grid @@ -295,9 +293,8 @@ where /// # Arguments /// /// - `isometry` defines the translation and rotation of the grid. - /// - the translation specifies the center of the grid - /// - defines the orientation of the grid, by default - /// we assume the grid is aligned with all axes + /// - the translation specifies the center of the grid + /// - defines the orientation of the grid, by default we assume the grid is aligned with all axes /// - `cell_count`: defines the amount of cells in the x and y axes /// - `spacing`: defines the distance between cells along the x and y axes /// - `color`: color of the grid diff --git a/crates/bevy_gizmos/src/rounded_box.rs b/crates/bevy_gizmos/src/rounded_box.rs index 6f0df7ac0ec5e..530d4f8617a54 100644 --- a/crates/bevy_gizmos/src/rounded_box.rs +++ b/crates/bevy_gizmos/src/rounded_box.rs @@ -238,10 +238,9 @@ where /// # Arguments /// /// - `isometry` defines the translation and rotation of the rectangle. - /// - the translation specifies the center of the rectangle - /// - defines orientation of the rectangle, by default we - /// assume the rectangle is contained in a plane parallel - /// to the XY plane. + /// - the translation specifies the center of the rectangle + /// - defines orientation of the rectangle, by default we assume the rectangle is contained in + /// a plane parallel to the XY plane. /// - `size`: defines the size of the rectangle. This refers to the 'outer size', similar to a bounding box. /// - `color`: color of the rectangle /// @@ -249,7 +248,7 @@ where /// /// - The corner radius can be adjusted with the `.corner_radius(...)` method. /// - The resolution of the arcs at each corner (i.e. the level of detail) can be adjusted with the - /// `.arc_resolution(...)` method. + /// `.arc_resolution(...)` method. /// /// # Example /// ``` @@ -293,9 +292,8 @@ where /// # Arguments /// /// - `isometry` defines the translation and rotation of the rectangle. - /// - the translation specifies the center of the rectangle - /// - defines orientation of the rectangle, by default we - /// assume the rectangle aligned with all axes. + /// - the translation specifies the center of the rectangle + /// - defines orientation of the rectangle, by default we assume the rectangle aligned with all axes. /// - `size`: defines the size of the rectangle. This refers to the 'outer size', similar to a bounding box. /// - `color`: color of the rectangle /// @@ -303,7 +301,7 @@ where /// /// - The corner radius can be adjusted with the `.corner_radius(...)` method. /// - The resolution of the arcs at each corner (i.e. the level of detail) can be adjusted with the - /// `.arc_resolution(...)` method. + /// `.arc_resolution(...)` method. /// /// # Example /// ``` @@ -351,9 +349,8 @@ where /// # Arguments /// /// - `isometry` defines the translation and rotation of the cuboid. - /// - the translation specifies the center of the cuboid - /// - defines orientation of the cuboid, by default we - /// assume the cuboid aligned with all axes. + /// - the translation specifies the center of the cuboid + /// - defines orientation of the cuboid, by default we assume the cuboid aligned with all axes. /// - `size`: defines the size of the cuboid. This refers to the 'outer size', similar to a bounding box. /// - `color`: color of the cuboid /// @@ -361,7 +358,7 @@ where /// /// - The edge radius can be adjusted with the `.edge_radius(...)` method. /// - The resolution of the arcs at each edge (i.e. the level of detail) can be adjusted with the - /// `.arc_resolution(...)` method. + /// `.arc_resolution(...)` method. /// /// # Example /// ``` diff --git a/crates/bevy_log/src/lib.rs b/crates/bevy_log/src/lib.rs index 0f4f9a5c6d6f3..0a4db7fb8b6d7 100644 --- a/crates/bevy_log/src/lib.rs +++ b/crates/bevy_log/src/lib.rs @@ -80,11 +80,11 @@ pub(crate) struct FlushGuard(SyncCell); /// Adds logging to Apps. This plugin is part of the `DefaultPlugins`. Adding /// this plugin will setup a collector appropriate to your target platform: /// * Using [`tracing-subscriber`](https://crates.io/crates/tracing-subscriber) by default, -/// logging to `stdout`. +/// logging to `stdout`. /// * Using [`android_log-sys`](https://crates.io/crates/android_log-sys) on Android, -/// logging to Android logs. +/// logging to Android logs. /// * Using [`tracing-wasm`](https://crates.io/crates/tracing-wasm) in Wasm, logging -/// to the browser console. +/// to the browser console. /// /// You can configure this plugin. /// ```no_run diff --git a/crates/bevy_math/src/cubic_splines/mod.rs b/crates/bevy_math/src/cubic_splines/mod.rs index 32e13f6720a92..9feedd31705a5 100644 --- a/crates/bevy_math/src/cubic_splines/mod.rs +++ b/crates/bevy_math/src/cubic_splines/mod.rs @@ -746,10 +746,9 @@ impl CubicNurbs

{ } let last_knots_value = control_points - 3; Some( - core::iter::repeat(0.0) - .take(4) + core::iter::repeat_n(0.0, 4) .chain((1..last_knots_value).map(|v| v as f32)) - .chain(core::iter::repeat(last_knots_value as f32).take(4)) + .chain(core::iter::repeat_n(last_knots_value as f32, 4)) .collect(), ) } diff --git a/crates/bevy_mesh/src/mesh.rs b/crates/bevy_mesh/src/mesh.rs index 44b313434e299..26363d50ed8a3 100644 --- a/crates/bevy_mesh/src/mesh.rs +++ b/crates/bevy_mesh/src/mesh.rs @@ -85,25 +85,25 @@ pub const VERTEX_ATTRIBUTE_BUFFER_ID: u64 = 10; /// ## Common points of confusion /// /// - UV maps in Bevy start at the top-left, see [`ATTRIBUTE_UV_0`](Mesh::ATTRIBUTE_UV_0), -/// other APIs can have other conventions, `OpenGL` starts at bottom-left. +/// other APIs can have other conventions, `OpenGL` starts at bottom-left. /// - It is possible and sometimes useful for multiple vertices to have the same -/// [position attribute](Mesh::ATTRIBUTE_POSITION) value, -/// it's a common technique in 3D modeling for complex UV mapping or other calculations. +/// [position attribute](Mesh::ATTRIBUTE_POSITION) value, +/// it's a common technique in 3D modeling for complex UV mapping or other calculations. /// - Bevy performs frustum culling based on the `Aabb` of meshes, which is calculated -/// and added automatically for new meshes only. If a mesh is modified, the entity's `Aabb` -/// needs to be updated manually or deleted so that it is re-calculated. +/// and added automatically for new meshes only. If a mesh is modified, the entity's `Aabb` +/// needs to be updated manually or deleted so that it is re-calculated. /// /// ## Use with `StandardMaterial` /// /// To render correctly with `StandardMaterial`, a mesh needs to have properly defined: /// - [`UVs`](Mesh::ATTRIBUTE_UV_0): Bevy needs to know how to map a texture onto the mesh -/// (also true for `ColorMaterial`). +/// (also true for `ColorMaterial`). /// - [`Normals`](Mesh::ATTRIBUTE_NORMAL): Bevy needs to know how light interacts with your mesh. -/// [0.0, 0.0, 1.0] is very common for simple flat meshes on the XY plane, -/// because simple meshes are smooth and they don't require complex light calculations. +/// [0.0, 0.0, 1.0] is very common for simple flat meshes on the XY plane, +/// because simple meshes are smooth and they don't require complex light calculations. /// - Vertex winding order: by default, `StandardMaterial.cull_mode` is `Some(Face::Back)`, -/// which means that Bevy would *only* render the "front" of each triangle, which -/// is the side of the triangle from where the vertices appear in a *counter-clockwise* order. +/// which means that Bevy would *only* render the "front" of each triangle, which +/// is the side of the triangle from where the vertices appear in a *counter-clockwise* order. #[derive(Asset, Debug, Clone, Reflect)] pub struct Mesh { #[reflect(ignore)] diff --git a/crates/bevy_mesh/src/morph.rs b/crates/bevy_mesh/src/morph.rs index 0c2c2c948cdde..b2a46305aa438 100644 --- a/crates/bevy_mesh/src/morph.rs +++ b/crates/bevy_mesh/src/morph.rs @@ -5,7 +5,6 @@ use bevy_image::Image; use bevy_math::Vec3; use bevy_reflect::prelude::*; use bytemuck::{Pod, Zeroable}; -use core::iter; use thiserror::Error; use wgpu_types::{Extent3d, TextureDimension, TextureFormat}; @@ -77,7 +76,7 @@ impl MorphTargetImage { buffer.extend_from_slice(bytemuck::bytes_of(&to_add)); } // Pad each layer so that they fit width * height - buffer.extend(iter::repeat(0).take(padding as usize * size_of::())); + buffer.extend(core::iter::repeat_n(0, padding as usize * size_of::())); debug_assert_eq!(buffer.len(), layer_byte_count); buffer }) diff --git a/crates/bevy_mikktspace/examples/generate.rs b/crates/bevy_mikktspace/examples/generate.rs index 6ca3fa36df06e..764d0708501a0 100644 --- a/crates/bevy_mikktspace/examples/generate.rs +++ b/crates/bevy_mikktspace/examples/generate.rs @@ -1,6 +1,10 @@ //! This example demonstrates how to generate a mesh. -#![allow(clippy::bool_assert_comparison, clippy::useless_conversion)] +#![allow( + clippy::bool_assert_comparison, + clippy::useless_conversion, + reason = "Crate auto-generated with many non-idiomatic decisions. See #7372 for details." +)] use glam::{Vec2, Vec3}; diff --git a/crates/bevy_mikktspace/tests/regression_test.rs b/crates/bevy_mikktspace/tests/regression_test.rs index a0632b76e29b5..bd6718ad39f20 100644 --- a/crates/bevy_mikktspace/tests/regression_test.rs +++ b/crates/bevy_mikktspace/tests/regression_test.rs @@ -2,7 +2,8 @@ #![expect( clippy::bool_assert_comparison, clippy::semicolon_if_nothing_returned, - clippy::useless_conversion + clippy::useless_conversion, + reason = "Crate auto-generated with many non-idiomatic decisions. See #7372 for details." )] use bevy_mikktspace::{generate_tangents, Geometry}; diff --git a/crates/bevy_pbr/src/cluster/assign.rs b/crates/bevy_pbr/src/cluster/assign.rs index 36a4aadfb31d6..1b7b3563d75c8 100644 --- a/crates/bevy_pbr/src/cluster/assign.rs +++ b/crates/bevy_pbr/src/cluster/assign.rs @@ -496,7 +496,7 @@ pub(crate) fn assign_objects_to_clusters( // initialize empty cluster bounding spheres cluster_aabb_spheres.clear(); - cluster_aabb_spheres.extend(core::iter::repeat(None).take(cluster_count)); + cluster_aabb_spheres.extend(core::iter::repeat_n(None, cluster_count)); // Calculate the x/y/z cluster frustum planes in view space let mut x_planes = Vec::with_capacity(clusters.dimensions.x as usize + 1); @@ -845,7 +845,7 @@ pub(crate) fn assign_objects_to_clusters( } } - ClusterableObjectType::Decal { .. } => { + ClusterableObjectType::Decal => { // Decals currently affect all clusters in their // bounding sphere. // diff --git a/crates/bevy_pbr/src/fog.rs b/crates/bevy_pbr/src/fog.rs index 831ec6928c424..6d2b6bdfdfbd4 100644 --- a/crates/bevy_pbr/src/fog.rs +++ b/crates/bevy_pbr/src/fog.rs @@ -141,11 +141,11 @@ pub enum FogFalloff { /// ## Tips /// /// - Use the [`FogFalloff::from_visibility()`] convenience method to create an exponential falloff with the proper - /// density for a desired visibility distance in world units; + /// density for a desired visibility distance in world units; /// - It's not _unusual_ to have very large or very small values for the density, depending on the scene - /// scale. Typically, for scenes with objects in the scale of thousands of units, you might want density values - /// in the ballpark of `0.001`. Conversely, for really small scale scenes you might want really high values of - /// density; + /// scale. Typically, for scenes with objects in the scale of thousands of units, you might want density values + /// in the ballpark of `0.001`. Conversely, for really small scale scenes you might want really high values of + /// density; /// - Combine the `density` parameter with the [`DistanceFog`] `color`'s alpha channel for easier artistic control. /// /// ## Formula @@ -193,7 +193,7 @@ pub enum FogFalloff { /// ## Tips /// /// - Use the [`FogFalloff::from_visibility_squared()`] convenience method to create an exponential squared falloff - /// with the proper density for a desired visibility distance in world units; + /// with the proper density for a desired visibility distance in world units; /// - Combine the `density` parameter with the [`DistanceFog`] `color`'s alpha channel for easier artistic control. /// /// ## Formula @@ -239,8 +239,8 @@ pub enum FogFalloff { /// ## Tips /// /// - Use the [`FogFalloff::from_visibility_colors()`] or [`FogFalloff::from_visibility_color()`] convenience methods - /// to create an atmospheric falloff with the proper densities for a desired visibility distance in world units and - /// extinction and inscattering colors; + /// to create an atmospheric falloff with the proper densities for a desired visibility distance in world units and + /// extinction and inscattering colors; /// - Combine the atmospheric fog parameters with the [`DistanceFog`] `color`'s alpha channel for easier artistic control. /// /// ## Formula diff --git a/crates/bevy_pbr/src/light_probe/irradiance_volume.rs b/crates/bevy_pbr/src/light_probe/irradiance_volume.rs index 799329e98284b..246321ff84407 100644 --- a/crates/bevy_pbr/src/light_probe/irradiance_volume.rs +++ b/crates/bevy_pbr/src/light_probe/irradiance_volume.rs @@ -81,17 +81,17 @@ //! less ideal for this use case: //! //! 1. The level 1 spherical harmonic coefficients can be negative. That -//! prevents the use of the efficient [RGB9E5 texture format], which only -//! encodes unsigned floating point numbers, and forces the use of the -//! less-efficient [RGBA16F format] if hardware interpolation is desired. +//! prevents the use of the efficient [RGB9E5 texture format], which only +//! encodes unsigned floating point numbers, and forces the use of the +//! less-efficient [RGBA16F format] if hardware interpolation is desired. //! //! 2. As an alternative to RGBA16F, level 1 spherical harmonics can be -//! normalized and scaled to the SH0 base color, as [Frostbite] does. This -//! allows them to be packed in standard LDR RGBA8 textures. However, this -//! prevents the use of hardware trilinear filtering, as the nonuniform scale -//! factor means that hardware interpolation no longer produces correct results. -//! The 8 texture fetches needed to interpolate between voxels can be upwards of -//! twice as slow as the hardware interpolation. +//! normalized and scaled to the SH0 base color, as [Frostbite] does. This +//! allows them to be packed in standard LDR RGBA8 textures. However, this +//! prevents the use of hardware trilinear filtering, as the nonuniform scale +//! factor means that hardware interpolation no longer produces correct results. +//! The 8 texture fetches needed to interpolate between voxels can be upwards of +//! twice as slow as the hardware interpolation. //! //! The following chart summarizes the costs and benefits of ambient cubes, //! level 1 spherical harmonics, and level 2 spherical harmonics: diff --git a/crates/bevy_pbr/src/light_probe/mod.rs b/crates/bevy_pbr/src/light_probe/mod.rs index 3ef3e78db85f4..c728a1cc6b863 100644 --- a/crates/bevy_pbr/src/light_probe/mod.rs +++ b/crates/bevy_pbr/src/light_probe/mod.rs @@ -769,22 +769,22 @@ pub(crate) fn add_cubemap_texture_view<'a>( /// (a.k.a. bindless textures). This function checks for these pitfalls: /// /// 1. If GLSL support is enabled at the feature level, then in debug mode -/// `naga_oil` will attempt to compile all shader modules under GLSL to check -/// validity of names, even if GLSL isn't actually used. This will cause a crash -/// if binding arrays are enabled, because binding arrays are currently -/// unimplemented in the GLSL backend of Naga. Therefore, we disable binding -/// arrays if the `shader_format_glsl` feature is present. +/// `naga_oil` will attempt to compile all shader modules under GLSL to check +/// validity of names, even if GLSL isn't actually used. This will cause a crash +/// if binding arrays are enabled, because binding arrays are currently +/// unimplemented in the GLSL backend of Naga. Therefore, we disable binding +/// arrays if the `shader_format_glsl` feature is present. /// /// 2. If there aren't enough texture bindings available to accommodate all the -/// binding arrays, the driver will panic. So we also bail out if there aren't -/// enough texture bindings available in the fragment shader. +/// binding arrays, the driver will panic. So we also bail out if there aren't +/// enough texture bindings available in the fragment shader. /// /// 3. If binding arrays aren't supported on the hardware, then we obviously /// can't use them. Adreno <= 610 claims to support bindless, but seems to be /// too buggy to be usable. /// /// 4. If binding arrays are supported on the hardware, but they can only be -/// accessed by uniform indices, that's not good enough, and we bail out. +/// accessed by uniform indices, that's not good enough, and we bail out. /// /// If binding arrays aren't usable, we disable reflection probes and limit the /// number of irradiance volumes in the scene to 1. diff --git a/crates/bevy_pbr/src/meshlet/from_mesh.rs b/crates/bevy_pbr/src/meshlet/from_mesh.rs index 7b959eef46887..016722b0960ab 100644 --- a/crates/bevy_pbr/src/meshlet/from_mesh.rs +++ b/crates/bevy_pbr/src/meshlet/from_mesh.rs @@ -102,11 +102,13 @@ impl MeshletMesh { }, }) .collect::>(); - let mut simplification_errors = iter::repeat(MeshletSimplificationError { - group_error: f16::ZERO, - parent_group_error: f16::MAX, - }) - .take(meshlets.len()) + let mut simplification_errors = iter::repeat_n( + MeshletSimplificationError { + group_error: f16::ZERO, + parent_group_error: f16::MAX, + }, + meshlets.len(), + ) .collect::>(); let mut vertex_locks = vec![false; vertices.vertex_count]; @@ -187,13 +189,13 @@ impl MeshletMesh { }, } })); - simplification_errors.extend( - iter::repeat(MeshletSimplificationError { + simplification_errors.extend(iter::repeat_n( + MeshletSimplificationError { group_error, parent_group_error: f16::MAX, - }) - .take(new_meshlet_ids.len()), - ); + }, + new_meshlet_ids.len(), + )); } // Set simplification queue to the list of newly created meshlets diff --git a/crates/bevy_pbr/src/meshlet/resource_manager.rs b/crates/bevy_pbr/src/meshlet/resource_manager.rs index 1d3828b95e184..9fb1387aec055 100644 --- a/crates/bevy_pbr/src/meshlet/resource_manager.rs +++ b/crates/bevy_pbr/src/meshlet/resource_manager.rs @@ -455,7 +455,7 @@ pub fn prepare_meshlet_per_frame_resources( let index = instance_index / 32; let bit = instance_index - index * 32; if vec.len() <= index { - vec.extend(iter::repeat(0).take(index - vec.len() + 1)); + vec.extend(iter::repeat_n(0, index - vec.len() + 1)); } vec[index] |= 1 << bit; } diff --git a/crates/bevy_pbr/src/pbr_material.rs b/crates/bevy_pbr/src/pbr_material.rs index 44d1b960dff52..0eee3cfd869d8 100644 --- a/crates/bevy_pbr/src/pbr_material.rs +++ b/crates/bevy_pbr/src/pbr_material.rs @@ -249,13 +249,13 @@ pub struct StandardMaterial { /// with distortion and blur effects. /// /// - [`Camera3d::screen_space_specular_transmission_steps`](bevy_core_pipeline::core_3d::Camera3d::screen_space_specular_transmission_steps) can be used to enable transmissive objects - /// to be seen through other transmissive objects, at the cost of additional draw calls and texture copies; (Use with caution!) - /// - If a simplified approximation of specular transmission using only environment map lighting is sufficient, consider setting - /// [`Camera3d::screen_space_specular_transmission_steps`](bevy_core_pipeline::core_3d::Camera3d::screen_space_specular_transmission_steps) to `0`. + /// to be seen through other transmissive objects, at the cost of additional draw calls and texture copies; (Use with caution!) + /// - If a simplified approximation of specular transmission using only environment map lighting is sufficient, consider setting + /// [`Camera3d::screen_space_specular_transmission_steps`](bevy_core_pipeline::core_3d::Camera3d::screen_space_specular_transmission_steps) to `0`. /// - If purely diffuse light transmission is needed, (i.e. “translucency”) consider using [`StandardMaterial::diffuse_transmission`] instead, - /// for a much less expensive effect. + /// for a much less expensive effect. /// - Specular transmission is rendered before alpha blending, so any material with [`AlphaMode::Blend`], [`AlphaMode::Premultiplied`], [`AlphaMode::Add`] or [`AlphaMode::Multiply`] - /// won't be visible through specular transmissive materials. + /// won't be visible through specular transmissive materials. #[doc(alias = "refraction")] pub specular_transmission: f32, diff --git a/crates/bevy_reflect/src/lib.rs b/crates/bevy_reflect/src/lib.rs index 2845c716c5d54..cf38c1da5086f 100644 --- a/crates/bevy_reflect/src/lib.rs +++ b/crates/bevy_reflect/src/lib.rs @@ -112,7 +112,7 @@ //! //! Additionally, using the derive macro on enums requires a third condition to be met: //! * All fields and sub-elements must implement [`FromReflect`]— -//! another important reflection trait discussed in a later section. +//! another important reflection trait discussed in a later section. //! //! # The Reflection Subtraits //! diff --git a/crates/bevy_reflect/src/serde/type_data.rs b/crates/bevy_reflect/src/serde/type_data.rs index 8df80c700f100..f1b0129a3c468 100644 --- a/crates/bevy_reflect/src/serde/type_data.rs +++ b/crates/bevy_reflect/src/serde/type_data.rs @@ -14,9 +14,9 @@ impl SerializationData { /// # Arguments /// /// * `skipped_iter`: The iterator of field indices to be skipped during (de)serialization. - /// Indices are assigned only to reflected fields. - /// Ignored fields (i.e. those marked `#[reflect(ignore)]`) are implicitly skipped - /// and do not need to be included in this iterator. + /// Indices are assigned only to reflected fields. + /// Ignored fields (i.e. those marked `#[reflect(ignore)]`) are implicitly skipped + /// and do not need to be included in this iterator. pub fn new>(skipped_iter: I) -> Self { Self { skipped_fields: skipped_iter.collect(), diff --git a/crates/bevy_remote/src/lib.rs b/crates/bevy_remote/src/lib.rs index 75ba79d58e8da..ca3792b7ea75c 100644 --- a/crates/bevy_remote/src/lib.rs +++ b/crates/bevy_remote/src/lib.rs @@ -137,7 +137,7 @@ //! see _below_ example for a query to list all the type names in **your** project. //! - `option` (optional): An array of fully-qualified type names of components to fetch optionally. //! - `has` (optional): An array of fully-qualified type names of components whose presence will be -//! reported as boolean values. +//! reported as boolean values. //! - `filter` (optional): //! - `with` (optional): An array of fully-qualified type names of components that must be present //! on entities in order for them to be included in results. diff --git a/crates/bevy_render/src/pipelined_rendering.rs b/crates/bevy_render/src/pipelined_rendering.rs index ed54a6301a4b7..fb665e469d559 100644 --- a/crates/bevy_render/src/pipelined_rendering.rs +++ b/crates/bevy_render/src/pipelined_rendering.rs @@ -92,14 +92,14 @@ impl Drop for RenderAppChannels { /// ``` /// /// - `sync` is the step where the entity-entity mapping between the main and render world is updated. -/// This is run on the main app's thread. For more information checkout [`SyncWorldPlugin`]. +/// This is run on the main app's thread. For more information checkout [`SyncWorldPlugin`]. /// - `extract` is the step where data is copied from the main world to the render world. -/// This is run on the main app's thread. +/// This is run on the main app's thread. /// - On the render thread, we first apply the `extract commands`. This is not run during extract, so the -/// main schedule can start sooner. +/// main schedule can start sooner. /// - Then the `rendering schedule` is run. See [`RenderSet`](crate::RenderSet) for the standard steps in this process. /// - In parallel to the rendering thread the [`RenderExtractApp`] schedule runs. By -/// default, this schedule is empty. But it is useful if you need something to run before I/O processing. +/// default, this schedule is empty. But it is useful if you need something to run before I/O processing. /// - Next all the `winit events` are processed. /// - And finally the `main app schedule` is run. /// - Once both the `main app schedule` and the `render schedule` are finished running, `extract` is run again. diff --git a/crates/bevy_render/src/primitives/mod.rs b/crates/bevy_render/src/primitives/mod.rs index 9123e95b5e946..10cbe4bd980c1 100644 --- a/crates/bevy_render/src/primitives/mod.rs +++ b/crates/bevy_render/src/primitives/mod.rs @@ -7,7 +7,7 @@ use bevy_reflect::prelude::*; /// An axis-aligned bounding box, defined by: /// - a center, /// - the distances from the center to each faces along the axis, -/// the faces are orthogonal to the axis. +/// the faces are orthogonal to the axis. /// /// It is typically used as a component on an entity to represent the local space /// occupied by this entity, with faces orthogonal to its local axis. @@ -18,7 +18,7 @@ use bevy_reflect::prelude::*; /// /// It will be added automatically by the systems in [`CalculateBounds`] to entities that: /// - could be subject to frustum culling, for example with a [`Mesh3d`] -/// or `Sprite` component, +/// or `Sprite` component, /// - don't have the [`NoFrustumCulling`] component. /// /// It won't be updated automatically if the space occupied by the entity changes, diff --git a/crates/bevy_render/src/render_phase/mod.rs b/crates/bevy_render/src/render_phase/mod.rs index 9c538a1377c1a..24a7bc4b622bb 100644 --- a/crates/bevy_render/src/render_phase/mod.rs +++ b/crates/bevy_render/src/render_phase/mod.rs @@ -1383,15 +1383,15 @@ where /// [`SortedPhaseItem`]s. /// /// * Binned phase items have a `BinKey` which specifies what bin they're to be -/// placed in. All items in the same bin are eligible to be batched together. -/// The `BinKey`s are sorted, but the individual bin items aren't. Binned phase -/// items are good for opaque meshes, in which the order of rendering isn't -/// important. Generally, binned phase items are faster than sorted phase items. +/// placed in. All items in the same bin are eligible to be batched together. +/// The `BinKey`s are sorted, but the individual bin items aren't. Binned phase +/// items are good for opaque meshes, in which the order of rendering isn't +/// important. Generally, binned phase items are faster than sorted phase items. /// /// * Sorted phase items, on the other hand, are placed into one large buffer -/// and then sorted all at once. This is needed for transparent meshes, which -/// have to be sorted back-to-front to render with the painter's algorithm. -/// These types of phase items are generally slower than binned phase items. +/// and then sorted all at once. This is needed for transparent meshes, which +/// have to be sorted back-to-front to render with the painter's algorithm. +/// These types of phase items are generally slower than binned phase items. pub trait PhaseItem: Sized + Send + Sync + 'static { /// Whether or not this `PhaseItem` should be subjected to automatic batching. (Default: `true`) const AUTOMATIC_BATCHING: bool = true; @@ -1432,12 +1432,12 @@ pub trait PhaseItem: Sized + Send + Sync + 'static { /// instances they already have. These can be: /// /// * The *dynamic offset*: a `wgpu` dynamic offset into the uniform buffer of -/// instance data. This is used on platforms that don't support storage -/// buffers, to work around uniform buffer size limitations. +/// instance data. This is used on platforms that don't support storage +/// buffers, to work around uniform buffer size limitations. /// /// * The *indirect parameters index*: an index into the buffer that specifies -/// the indirect parameters for this [`PhaseItem`]'s drawcall. This is used when -/// indirect mode is on (as used for GPU culling). +/// the indirect parameters for this [`PhaseItem`]'s drawcall. This is used when +/// indirect mode is on (as used for GPU culling). /// /// Note that our indirect draw functionality requires storage buffers, so it's /// impossible to have both a dynamic offset and an indirect parameters index. diff --git a/crates/bevy_render/src/render_resource/bind_group.rs b/crates/bevy_render/src/render_resource/bind_group.rs index 9fe835bb1b8ab..6db28ec55a35b 100644 --- a/crates/bevy_render/src/render_resource/bind_group.rs +++ b/crates/bevy_render/src/render_resource/bind_group.rs @@ -148,16 +148,16 @@ impl Deref for BindGroup { /// ## `uniform(BINDING_INDEX)` /// /// * The field will be converted to a shader-compatible type using the [`ShaderType`] trait, written to a [`Buffer`], and bound as a uniform. -/// [`ShaderType`] is implemented for most math types already, such as [`f32`], [`Vec4`](bevy_math::Vec4), and -/// [`LinearRgba`](bevy_color::LinearRgba). It can also be derived for custom structs. +/// [`ShaderType`] is implemented for most math types already, such as [`f32`], [`Vec4`](bevy_math::Vec4), and +/// [`LinearRgba`](bevy_color::LinearRgba). It can also be derived for custom structs. /// /// ## `texture(BINDING_INDEX, arguments)` /// /// * This field's [`Handle`](bevy_asset::Handle) will be used to look up the matching [`Texture`](crate::render_resource::Texture) -/// GPU resource, which will be bound as a texture in shaders. The field will be assumed to implement [`Into>>`]. In practice, -/// most fields should be a [`Handle`](bevy_asset::Handle) or [`Option>`]. If the value of an [`Option>`] is -/// [`None`], the [`crate::texture::FallbackImage`] resource will be used instead. This attribute can be used in conjunction with a `sampler` binding attribute -/// (with a different binding index) if a binding of the sampler for the [`Image`](bevy_image::Image) is also required. +/// GPU resource, which will be bound as a texture in shaders. The field will be assumed to implement [`Into>>`]. In practice, +/// most fields should be a [`Handle`](bevy_asset::Handle) or [`Option>`]. If the value of an [`Option>`] is +/// [`None`], the [`crate::texture::FallbackImage`] resource will be used instead. This attribute can be used in conjunction with a `sampler` binding attribute +/// (with a different binding index) if a binding of the sampler for the [`Image`](bevy_image::Image) is also required. /// /// | Arguments | Values | Default | /// |-----------------------|-------------------------------------------------------------------------|----------------------| @@ -170,9 +170,9 @@ impl Deref for BindGroup { /// ## `storage_texture(BINDING_INDEX, arguments)` /// /// * This field's [`Handle`](bevy_asset::Handle) will be used to look up the matching [`Texture`](crate::render_resource::Texture) -/// GPU resource, which will be bound as a storage texture in shaders. The field will be assumed to implement [`Into>>`]. In practice, -/// most fields should be a [`Handle`](bevy_asset::Handle) or [`Option>`]. If the value of an [`Option>`] is -/// [`None`], the [`crate::texture::FallbackImage`] resource will be used instead. +/// GPU resource, which will be bound as a storage texture in shaders. The field will be assumed to implement [`Into>>`]. In practice, +/// most fields should be a [`Handle`](bevy_asset::Handle) or [`Option>`]. If the value of an [`Option>`] is +/// [`None`], the [`crate::texture::FallbackImage`] resource will be used instead. /// /// | Arguments | Values | Default | /// |------------------------|--------------------------------------------------------------------------------------------|---------------| @@ -184,10 +184,10 @@ impl Deref for BindGroup { /// ## `sampler(BINDING_INDEX, arguments)` /// /// * This field's [`Handle`](bevy_asset::Handle) will be used to look up the matching [`Sampler`] GPU -/// resource, which will be bound as a sampler in shaders. The field will be assumed to implement [`Into>>`]. In practice, -/// most fields should be a [`Handle`](bevy_asset::Handle) or [`Option>`]. If the value of an [`Option>`] is -/// [`None`], the [`crate::texture::FallbackImage`] resource will be used instead. This attribute can be used in conjunction with a `texture` binding attribute -/// (with a different binding index) if a binding of the texture for the [`Image`](bevy_image::Image) is also required. +/// resource, which will be bound as a sampler in shaders. The field will be assumed to implement [`Into>>`]. In practice, +/// most fields should be a [`Handle`](bevy_asset::Handle) or [`Option>`]. If the value of an [`Option>`] is +/// [`None`], the [`crate::texture::FallbackImage`] resource will be used instead. This attribute can be used in conjunction with a `texture` binding attribute +/// (with a different binding index) if a binding of the texture for the [`Image`](bevy_image::Image) is also required. /// /// | Arguments | Values | Default | /// |------------------------|-------------------------------------------------------------------------|------------------------| @@ -294,9 +294,9 @@ impl Deref for BindGroup { /// ## `bind_group_data(DataType)` /// /// * The [`AsBindGroup`] type will be converted to some `DataType` using [`Into`] and stored -/// as [`AsBindGroup::Data`] as part of the [`AsBindGroup::as_bind_group`] call. This is useful if data needs to be stored alongside -/// the generated bind group, such as a unique identifier for a material's bind group. The most common use case for this attribute -/// is "shader pipeline specialization". See [`SpecializedRenderPipeline`](crate::render_resource::SpecializedRenderPipeline). +/// as [`AsBindGroup::Data`] as part of the [`AsBindGroup::as_bind_group`] call. This is useful if data needs to be stored alongside +/// the generated bind group, such as a unique identifier for a material's bind group. The most common use case for this attribute +/// is "shader pipeline specialization". See [`SpecializedRenderPipeline`](crate::render_resource::SpecializedRenderPipeline). /// /// ## `bindless` /// diff --git a/crates/bevy_render/src/render_resource/buffer_vec.rs b/crates/bevy_render/src/render_resource/buffer_vec.rs index 2077024215463..4e6c787fba299 100644 --- a/crates/bevy_render/src/render_resource/buffer_vec.rs +++ b/crates/bevy_render/src/render_resource/buffer_vec.rs @@ -316,7 +316,7 @@ where // TODO: Consider using unsafe code to push uninitialized, to prevent // the zeroing. It shows up in profiles. - self.data.extend(iter::repeat(0).take(element_size)); + self.data.extend(iter::repeat_n(0, element_size)); // Take a slice of the new data for `write_into` to use. This is // important: it hoists the bounds check up here so that the compiler diff --git a/crates/bevy_render/src/view/visibility/mod.rs b/crates/bevy_render/src/view/visibility/mod.rs index 09dc516b6ea9b..ce84285853045 100644 --- a/crates/bevy_render/src/view/visibility/mod.rs +++ b/crates/bevy_render/src/view/visibility/mod.rs @@ -204,7 +204,7 @@ impl ViewVisibility { /// It can be used for example: /// - when a [`Mesh`] is updated but its [`Aabb`] is not, which might happen with animations, /// - when using some light effects, like wanting a [`Mesh`] out of the [`Frustum`] -/// to appear in the reflection of a [`Mesh`] within. +/// to appear in the reflection of a [`Mesh`] within. #[derive(Debug, Component, Default, Reflect)] #[reflect(Component, Default, Debug)] pub struct NoFrustumCulling; diff --git a/crates/bevy_sprite/src/lib.rs b/crates/bevy_sprite/src/lib.rs index 568701725d605..1107e6c38eb96 100644 --- a/crates/bevy_sprite/src/lib.rs +++ b/crates/bevy_sprite/src/lib.rs @@ -171,7 +171,7 @@ impl Plugin for SpritePlugin { /// System calculating and inserting an [`Aabb`] component to entities with either: /// - a `Mesh2d` component, /// - a `Sprite` and `Handle` components, -/// and without a [`NoFrustumCulling`] component. +/// and without a [`NoFrustumCulling`] component. /// /// Used in system set [`VisibilitySystems::CalculateBounds`]. pub fn calculate_bounds_2d( diff --git a/crates/bevy_sprite/src/texture_slice/mod.rs b/crates/bevy_sprite/src/texture_slice/mod.rs index 7ea01d5839dc2..7b1a1e33e2168 100644 --- a/crates/bevy_sprite/src/texture_slice/mod.rs +++ b/crates/bevy_sprite/src/texture_slice/mod.rs @@ -27,7 +27,7 @@ impl TextureSlice { /// # Arguments /// /// * `stretch_value` - The slice will repeat when the ratio between the *drawing dimensions* of texture and the - /// *original texture size* (rect) are above `stretch_value`. + /// *original texture size* (rect) are above `stretch_value`. /// * `tile_x` - should the slice be tiled horizontally /// * `tile_y` - should the slice be tiled vertically #[must_use] diff --git a/crates/bevy_transform/src/components/global_transform.rs b/crates/bevy_transform/src/components/global_transform.rs index ecd59fac9d7da..557c1dd6f631c 100644 --- a/crates/bevy_transform/src/components/global_transform.rs +++ b/crates/bevy_transform/src/components/global_transform.rs @@ -23,7 +23,7 @@ use { /// /// * To get the global transform of an entity, you should get its [`GlobalTransform`]. /// * For transform hierarchies to work correctly, you must have both a [`Transform`] and a [`GlobalTransform`]. -/// [`GlobalTransform`] is automatically inserted whenever [`Transform`] is inserted. +/// [`GlobalTransform`] is automatically inserted whenever [`Transform`] is inserted. /// /// ## [`Transform`] and [`GlobalTransform`] /// diff --git a/crates/bevy_transform/src/components/transform.rs b/crates/bevy_transform/src/components/transform.rs index baa3a66196742..2949015848470 100644 --- a/crates/bevy_transform/src/components/transform.rs +++ b/crates/bevy_transform/src/components/transform.rs @@ -201,8 +201,8 @@ impl Transform { /// * if `main_axis` or `main_direction` fail converting to `Dir3` (e.g are zero), `Dir3::X` takes their place /// * if `secondary_axis` or `secondary_direction` fail converting, `Dir3::Y` takes their place /// * if `main_axis` is parallel with `secondary_axis` or `main_direction` is parallel with `secondary_direction`, - /// a rotation is constructed which takes `main_axis` to `main_direction` along a great circle, ignoring the secondary - /// counterparts + /// a rotation is constructed which takes `main_axis` to `main_direction` along a great circle, ignoring the secondary + /// counterparts /// /// See [`Transform::align`] for additional details. #[inline] @@ -480,7 +480,7 @@ impl Transform { /// More precisely, the [`Transform::rotation`] produced will be such that: /// * applying it to `main_axis` results in `main_direction` /// * applying it to `secondary_axis` produces a vector that lies in the half-plane generated by `main_direction` and - /// `secondary_direction` (with positive contribution by `secondary_direction`) + /// `secondary_direction` (with positive contribution by `secondary_direction`) /// /// [`Transform::look_to`] is recovered, for instance, when `main_axis` is `Dir3::NEG_Z` (the [`Transform::forward`] /// direction in the default orientation) and `secondary_axis` is `Dir3::Y` (the [`Transform::up`] direction in the default @@ -490,8 +490,8 @@ impl Transform { /// * if `main_axis` or `main_direction` fail converting to `Dir3` (e.g are zero), `Dir3::X` takes their place /// * if `secondary_axis` or `secondary_direction` fail converting, `Dir3::Y` takes their place /// * if `main_axis` is parallel with `secondary_axis` or `main_direction` is parallel with `secondary_direction`, - /// a rotation is constructed which takes `main_axis` to `main_direction` along a great circle, ignoring the secondary - /// counterparts + /// a rotation is constructed which takes `main_axis` to `main_direction` along a great circle, ignoring the secondary + /// counterparts /// /// Example /// ``` diff --git a/crates/bevy_transform/src/systems.rs b/crates/bevy_transform/src/systems.rs index 302d18ee1bf02..f42c6b93e66b5 100644 --- a/crates/bevy_transform/src/systems.rs +++ b/crates/bevy_transform/src/systems.rs @@ -101,9 +101,9 @@ pub fn propagate_transforms( /// # Safety /// /// - While this function is running, `transform_query` must not have any fetches for `entity`, -/// nor any of its descendants. +/// nor any of its descendants. /// - The caller must ensure that the hierarchy leading to `entity` -/// is well-formed and must remain as a tree or a forest. Each entity must have at most one parent. +/// is well-formed and must remain as a tree or a forest. Each entity must have at most one parent. #[expect( unsafe_code, reason = "This function uses `Query::get_unchecked()`, which can result in multiple mutable references if the preconditions are not met." diff --git a/crates/bevy_ui/src/widget/text.rs b/crates/bevy_ui/src/widget/text.rs index e1be210950a0b..42c91fd833415 100644 --- a/crates/bevy_ui/src/widget/text.rs +++ b/crates/bevy_ui/src/widget/text.rs @@ -242,9 +242,9 @@ fn create_text_measure<'a>( /// /// * Measures are regenerated on changes to either [`ComputedTextBlock`] or [`ComputedNodeTarget`]. /// * Changes that only modify the colors of a `Text` do not require a new `Measure`. This system -/// is only able to detect that a `Text` component has changed and will regenerate the `Measure` on -/// color changes. This can be expensive, particularly for large blocks of text, and the [`bypass_change_detection`](bevy_ecs::change_detection::DetectChangesMut::bypass_change_detection) -/// method should be called when only changing the `Text`'s colors. +/// is only able to detect that a `Text` component has changed and will regenerate the `Measure` on +/// color changes. This can be expensive, particularly for large blocks of text, and the [`bypass_change_detection`](bevy_ecs::change_detection::DetectChangesMut::bypass_change_detection) +/// method should be called when only changing the `Text`'s colors. pub fn measure_text_system( fonts: Res>, mut text_query: Query< diff --git a/crates/bevy_window/src/window.rs b/crates/bevy_window/src/window.rs index 92455a908b2eb..bc4ca5f23d734 100644 --- a/crates/bevy_window/src/window.rs +++ b/crates/bevy_window/src/window.rs @@ -708,7 +708,7 @@ pub struct CursorOptions { /// ## Platform-specific /// /// - **`Windows`**, **`X11`**, and **`Wayland`**: The cursor is hidden only when inside the window. - /// To stop the cursor from leaving the window, change [`CursorOptions::grab_mode`] to [`CursorGrabMode::Locked`] or [`CursorGrabMode::Confined`] + /// To stop the cursor from leaving the window, change [`CursorOptions::grab_mode`] to [`CursorGrabMode::Locked`] or [`CursorGrabMode::Confined`] /// - **`macOS`**: The cursor is hidden only when the window is focused. /// - **`iOS`** and **`Android`** do not have cursors pub visible: bool, @@ -792,14 +792,14 @@ impl WindowPosition { /// /// There are three sizes associated with a window: /// - the physical size, -/// which represents the actual height and width in physical pixels -/// the window occupies on the monitor, +/// which represents the actual height and width in physical pixels +/// the window occupies on the monitor, /// - the logical size, -/// which represents the size that should be used to scale elements -/// inside the window, measured in logical pixels, +/// which represents the size that should be used to scale elements +/// inside the window, measured in logical pixels, /// - the requested size, -/// measured in logical pixels, which is the value submitted -/// to the API when creating the window, or requesting that it be resized. +/// measured in logical pixels, which is the value submitted +/// to the API when creating the window, or requesting that it be resized. /// /// ## Scale factor /// diff --git a/crates/bevy_winit/src/winit_config.rs b/crates/bevy_winit/src/winit_config.rs index feeeb8d3bb15e..1b2cf8ad4f84e 100644 --- a/crates/bevy_winit/src/winit_config.rs +++ b/crates/bevy_winit/src/winit_config.rs @@ -80,7 +80,7 @@ pub enum UpdateMode { /// - `wait` time has elapsed since the previous update /// - a redraw has been requested by [`RequestRedraw`](bevy_window::RequestRedraw) /// - new [window](`winit::event::WindowEvent`), [raw input](`winit::event::DeviceEvent`), or custom - /// events have appeared + /// events have appeared /// - a redraw has been requested with the [`EventLoopProxy`](crate::EventLoopProxy) Reactive { /// The approximate time from the start of one update to the next. diff --git a/examples/3d/transparency_3d.rs b/examples/3d/transparency_3d.rs index 35cb7c1d14f25..37fa25b529c74 100644 --- a/examples/3d/transparency_3d.rs +++ b/examples/3d/transparency_3d.rs @@ -100,7 +100,7 @@ fn setup( /// Each blend mode responds differently to this: /// - [`Opaque`](AlphaMode::Opaque): Ignores alpha channel altogether, these materials stay completely opaque. /// - [`Mask(f32)`](AlphaMode::Mask): Object appears when the alpha value goes above the mask's threshold, disappears -/// when the alpha value goes back below the threshold. +/// when the alpha value goes back below the threshold. /// - [`Blend`](AlphaMode::Blend): Object fades in and out smoothly. /// - [`AlphaToCoverage`](AlphaMode::AlphaToCoverage): Object fades in and out /// in steps corresponding to the number of multisample antialiasing (MSAA) diff --git a/examples/camera/first_person_view_model.rs b/examples/camera/first_person_view_model.rs index c23e745c4cb03..56a24e9119330 100644 --- a/examples/camera/first_person_view_model.rs +++ b/examples/camera/first_person_view_model.rs @@ -15,9 +15,9 @@ //! be able to change its FOV to accommodate the player's preferences for the following reasons: //! - *Accessibility*: How prone is the player to motion sickness? A wider FOV can help. //! - *Tactical preference*: Does the player want to see more of the battlefield? -//! Or have a more zoomed-in view for precision aiming? +//! Or have a more zoomed-in view for precision aiming? //! - *Physical considerations*: How well does the in-game FOV match the player's real-world FOV? -//! Are they sitting in front of a monitor or playing on a TV in the living room? How big is the screen? +//! Are they sitting in front of a monitor or playing on a TV in the living room? How big is the screen? //! //! ## Implementation //! @@ -27,12 +27,12 @@ //! We use different `RenderLayers` to select what to render. //! //! - The world model camera has no explicit `RenderLayers` component, so it uses the layer 0. -//! All static objects in the scene are also on layer 0 for the same reason. +//! All static objects in the scene are also on layer 0 for the same reason. //! - The view model camera has a `RenderLayers` component with layer 1, so it only renders objects -//! explicitly assigned to layer 1. The arm of the player is one such object. -//! The order of the view model camera is additionally bumped to 1 to ensure it renders on top of the world model. +//! explicitly assigned to layer 1. The arm of the player is one such object. +//! The order of the view model camera is additionally bumped to 1 to ensure it renders on top of the world model. //! - The light source in the scene must illuminate both the view model and the world model, so it is -//! assigned to both layers 0 and 1. +//! assigned to both layers 0 and 1. //! //! ## Controls //! diff --git a/examples/ecs/component_hooks.rs b/examples/ecs/component_hooks.rs index 836779c4e6055..ba9606fe57dc6 100644 --- a/examples/ecs/component_hooks.rs +++ b/examples/ecs/component_hooks.rs @@ -8,10 +8,10 @@ //! Here are some cases where components hooks might be necessary: //! //! - Maintaining indexes: If you need to keep custom data structures (like a spatial index) in -//! sync with the addition/removal of components. +//! sync with the addition/removal of components. //! //! - Enforcing structural rules: When you have systems that depend on specific relationships -//! between components (like hierarchies or parent-child links) and need to maintain correctness. +//! between components (like hierarchies or parent-child links) and need to maintain correctness. use bevy::{ ecs::component::{ComponentHook, HookContext, Mutable, StorageType}, diff --git a/examples/movement/physics_in_fixed_timestep.rs b/examples/movement/physics_in_fixed_timestep.rs index b477c3c867178..2e105f9a006c4 100644 --- a/examples/movement/physics_in_fixed_timestep.rs +++ b/examples/movement/physics_in_fixed_timestep.rs @@ -59,16 +59,16 @@ //! - The player's previous position in the physics simulation is stored in a `PreviousPhysicalTranslation` component. //! - The player's visual representation is stored in Bevy's regular `Transform` component. //! - Every frame, we go through the following steps: -//! - Accumulate the player's input and set the current speed in the `handle_input` system. -//! This is run in the `RunFixedMainLoop` schedule, ordered in `RunFixedMainLoopSystem::BeforeFixedMainLoop`, -//! which runs before the fixed timestep loop. This is run every frame. -//! - Advance the physics simulation by one fixed timestep in the `advance_physics` system. -//! Accumulated input is consumed here. -//! This is run in the `FixedUpdate` schedule, which runs zero or multiple times per frame. -//! - Update the player's visual representation in the `interpolate_rendered_transform` system. -//! This interpolates between the player's previous and current position in the physics simulation. -//! It is run in the `RunFixedMainLoop` schedule, ordered in `RunFixedMainLoopSystem::AfterFixedMainLoop`, -//! which runs after the fixed timestep loop. This is run every frame. +//! - Accumulate the player's input and set the current speed in the `handle_input` system. +//! This is run in the `RunFixedMainLoop` schedule, ordered in `RunFixedMainLoopSystem::BeforeFixedMainLoop`, +//! which runs before the fixed timestep loop. This is run every frame. +//! - Advance the physics simulation by one fixed timestep in the `advance_physics` system. +//! Accumulated input is consumed here. +//! This is run in the `FixedUpdate` schedule, which runs zero or multiple times per frame. +//! - Update the player's visual representation in the `interpolate_rendered_transform` system. +//! This interpolates between the player's previous and current position in the physics simulation. +//! It is run in the `RunFixedMainLoop` schedule, ordered in `RunFixedMainLoopSystem::AfterFixedMainLoop`, +//! which runs after the fixed timestep loop. This is run every frame. //! //! //! ## Controls diff --git a/examples/stress_tests/transform_hierarchy.rs b/examples/stress_tests/transform_hierarchy.rs index 5f717fe9d2d7e..49ff27b4ee9e0 100644 --- a/examples/stress_tests/transform_hierarchy.rs +++ b/examples/stress_tests/transform_hierarchy.rs @@ -447,7 +447,7 @@ fn gen_tree(depth: u32, branch_width: u32) -> Vec { // the tree is built using this pattern: // 0, 0, 0, ... 1, 1, 1, ... 2, 2, 2, ... (count - 1) (0..count) - .flat_map(|i| std::iter::repeat(i).take(branch_width.try_into().unwrap())) + .flat_map(|i| std::iter::repeat_n(i, branch_width.try_into().unwrap())) .collect() } From 4ff84aa8dd0c3833e6d3dc907561d689c0606cae Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Sat, 22 Feb 2025 20:35:34 +1100 Subject: [PATCH 28/34] Attempt to resolve `msrv` CI issue --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4e50d713b1c29..cb85b514c4fed 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -419,7 +419,7 @@ jobs: run: | msrv=`cargo metadata --no-deps --format-version 1 | jq --raw-output '.packages[] | select(.name=="bevy") | .rust_version'` echo "msrv=$msrv" >> $GITHUB_OUTPUT - - uses: dtolnay/rust-toolchain@master + - uses: dtolnay/rust-toolchain@stable with: toolchain: ${{ steps.msrv.outputs.msrv }} - name: Install Linux dependencies From 6403379dfe0c0ecb0af0fdc3a1e60cbf86509ace Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Sat, 22 Feb 2025 20:47:40 +1100 Subject: [PATCH 29/34] Revert "Attempt to resolve `msrv` CI issue" This reverts commit 4ff84aa8dd0c3833e6d3dc907561d689c0606cae. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cb85b514c4fed..4e50d713b1c29 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -419,7 +419,7 @@ jobs: run: | msrv=`cargo metadata --no-deps --format-version 1 | jq --raw-output '.packages[] | select(.name=="bevy") | .rust_version'` echo "msrv=$msrv" >> $GITHUB_OUTPUT - - uses: dtolnay/rust-toolchain@stable + - uses: dtolnay/rust-toolchain@master with: toolchain: ${{ steps.msrv.outputs.msrv }} - name: Install Linux dependencies From 501909a52d0381b6ce8eb90c78ad302f524c183e Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Sat, 22 Feb 2025 22:28:12 +1100 Subject: [PATCH 30/34] Use `generation` instead of `r#gen` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: François Mockers --- benches/benches/bevy_ecs/world/entity_hash.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/benches/benches/bevy_ecs/world/entity_hash.rs b/benches/benches/bevy_ecs/world/entity_hash.rs index 008b2cbbaa358..af7987bb021f4 100644 --- a/benches/benches/bevy_ecs/world/entity_hash.rs +++ b/benches/benches/bevy_ecs/world/entity_hash.rs @@ -14,13 +14,13 @@ fn make_entity(rng: &mut impl Rng, size: usize) -> Entity { let x: f64 = rng.r#gen(); let id = -(1.0 - x).log2() * (size as f64); let x: f64 = rng.r#gen(); - let r#gen = 1.0 + -(1.0 - x).log2() * 2.0; + let generation = 1.0 + -(1.0 - x).log2() * 2.0; // this is not reliable, but we're internal so a hack is ok - let bits = ((r#gen as u64) << 32) | (id as u64); + let bits = ((generation as u64) << 32) | (id as u64); let e = Entity::from_bits(bits); assert_eq!(e.index(), id as u32); - assert_eq!(e.generation(), r#gen as u32); + assert_eq!(e.generation(), generation as u32); e } From d1ab4433d762605ef864180c80cb480cd63d68d2 Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Sat, 22 Feb 2025 22:45:38 +1100 Subject: [PATCH 31/34] Revert changes to `asset_loading` example --- examples/asset/asset_loading.rs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/examples/asset/asset_loading.rs b/examples/asset/asset_loading.rs index 28ab31fe98bdc..49d2dca279025 100644 --- a/examples/asset/asset_loading.rs +++ b/examples/asset/asset_loading.rs @@ -36,16 +36,13 @@ fn setup( ); // All assets end up in their Assets collection once they are done loading: - match meshes.get(&sphere_handle) { - Some(sphere) => { - // You might notice that this doesn't run! This is because assets load in parallel without - // blocking. When an asset has loaded, it will appear in relevant Assets - // collection. - info!("{:?}", sphere.primitive_topology()); - } - _ => { - info!("sphere hasn't loaded yet"); - } + if let Some(sphere) = meshes.get(&sphere_handle) { + // You might notice that this doesn't run! This is because assets load in parallel without + // blocking. When an asset has loaded, it will appear in relevant Assets + // collection. + info!("{:?}", sphere.primitive_topology()); + } else { + info!("sphere hasn't loaded yet"); } // You can load all assets in a folder like this. They will be loaded in parallel without From 011ae5e23cfe3fa81276429bfd54ed81aa254ebc Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Sat, 22 Feb 2025 22:46:43 +1100 Subject: [PATCH 32/34] Revert `alien_cake_addict` --- examples/games/alien_cake_addict.rs | 37 +++++++++++++---------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/examples/games/alien_cake_addict.rs b/examples/games/alien_cake_addict.rs index da603a39dc25f..06a2b9891d5d8 100644 --- a/examples/games/alien_cake_addict.rs +++ b/examples/games/alien_cake_addict.rs @@ -271,29 +271,24 @@ fn focus_camera( ) { const SPEED: f32 = 2.0; // if there is both a player and a bonus, target the mid-point of them - match (game.player.entity, game.bonus.entity) { - (Some(player_entity), Some(bonus_entity)) => { - let transform_query = transforms.p1(); - if let (Ok(player_transform), Ok(bonus_transform)) = ( - transform_query.get(player_entity), - transform_query.get(bonus_entity), - ) { - game.camera_should_focus = player_transform - .translation - .lerp(bonus_transform.translation, 0.5); - } - // otherwise, if there is only a player, target the player + if let (Some(player_entity), Some(bonus_entity)) = (game.player.entity, game.bonus.entity) { + let transform_query = transforms.p1(); + if let (Ok(player_transform), Ok(bonus_transform)) = ( + transform_query.get(player_entity), + transform_query.get(bonus_entity), + ) { + game.camera_should_focus = player_transform + .translation + .lerp(bonus_transform.translation, 0.5); } - _ => { - if let Some(player_entity) = game.player.entity { - if let Ok(player_transform) = transforms.p1().get(player_entity) { - game.camera_should_focus = player_transform.translation; - } - // otherwise, target the middle - } else { - game.camera_should_focus = Vec3::from(RESET_FOCUS); - } + // otherwise, if there is only a player, target the player + } else if let Some(player_entity) = game.player.entity { + if let Ok(player_transform) = transforms.p1().get(player_entity) { + game.camera_should_focus = player_transform.translation; } + // otherwise, target the middle + } else { + game.camera_should_focus = Vec3::from(RESET_FOCUS); } // calculate the camera motion based on the difference between where the camera is looking // and where it should be looking; the greater the distance, the faster the motion; From d2a6de3ecce172bc792d25fb8e8fb3b842fe859b Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Sat, 22 Feb 2025 22:56:48 +1100 Subject: [PATCH 33/34] Possible fix for `msrv` CI task MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: François Mockers --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4e50d713b1c29..99e3edc98691f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -414,6 +414,7 @@ jobs: ~/.cargo/git/db/ target/ key: ${{ runner.os }}-cargo-msrv-${{ hashFiles('**/Cargo.toml') }} + - uses: dtolnay/rust-toolchain@stable - name: get MSRV id: msrv run: | From bb802702495c7cdffca1ae93ff7843b3d046008e Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Mon, 24 Feb 2025 10:47:48 +1100 Subject: [PATCH 34/34] Wrap `no_mangle` in `unsafe` --- crates/bevy_derive/src/bevy_main.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/bevy_derive/src/bevy_main.rs b/crates/bevy_derive/src/bevy_main.rs index 8111a31338b56..a9339b1395d13 100644 --- a/crates/bevy_derive/src/bevy_main.rs +++ b/crates/bevy_derive/src/bevy_main.rs @@ -10,14 +10,20 @@ pub fn bevy_main(_attr: TokenStream, item: TokenStream) -> TokenStream { ); TokenStream::from(quote! { - #[no_mangle] + // SAFETY: `#[bevy_main]` should only be placed on a single `main` function + // TODO: Potentially make `bevy_main` and unsafe attribute as there is a safety + // guarantee required from the caller. + #[unsafe(no_mangle)] #[cfg(target_os = "android")] fn android_main(android_app: bevy::window::android_activity::AndroidApp) { let _ = bevy::window::ANDROID_APP.set(android_app); main(); } - #[no_mangle] + // SAFETY: `#[bevy_main]` should only be placed on a single `main` function + // TODO: Potentially make `bevy_main` and unsafe attribute as there is a safety + // guarantee required from the caller. + #[unsafe(no_mangle)] #[cfg(target_os = "ios")] extern "C" fn main_rs() { main();

{ /// An error indicating that a spline construction didn't have enough control points to generate a curve. #[derive(Clone, Debug, Error)] -#[error("Not enough data to build curve: needed at least {expected} control points but was only given {given}")] +#[error( + "Not enough data to build curve: needed at least {expected} control points but was only given {given}" +)] pub struct InsufficientDataError { expected: usize, given: usize, @@ -1622,7 +1624,7 @@ mod tests { ops::{self, FloatPow}, }; use alloc::vec::Vec; - use glam::{vec2, Vec2}; + use glam::{Vec2, vec2}; /// How close two floats can be and still be considered equal const FLOAT_EQ: f32 = 1e-5; @@ -1705,18 +1707,26 @@ mod tests { assert!(curve.position(3.).abs_diff_eq(p3, FLOAT_EQ)); // Tangents at segment endpoints - assert!(curve - .velocity(0.) - .abs_diff_eq((p1 - p0) * tension * 2., FLOAT_EQ)); - assert!(curve - .velocity(1.) - .abs_diff_eq((p2 - p0) * tension, FLOAT_EQ)); - assert!(curve - .velocity(2.) - .abs_diff_eq((p3 - p1) * tension, FLOAT_EQ)); - assert!(curve - .velocity(3.) - .abs_diff_eq((p3 - p2) * tension * 2., FLOAT_EQ)); + assert!( + curve + .velocity(0.) + .abs_diff_eq((p1 - p0) * tension * 2., FLOAT_EQ) + ); + assert!( + curve + .velocity(1.) + .abs_diff_eq((p2 - p0) * tension, FLOAT_EQ) + ); + assert!( + curve + .velocity(2.) + .abs_diff_eq((p3 - p1) * tension, FLOAT_EQ) + ); + assert!( + curve + .velocity(3.) + .abs_diff_eq((p3 - p2) * tension * 2., FLOAT_EQ) + ); } /// Test that [`RationalCurve`] properly generalizes [`CubicCurve`]. A Cubic upgraded to a rational diff --git a/crates/bevy_math/src/curve/adaptors.rs b/crates/bevy_math/src/curve/adaptors.rs index afc34837d3b13..a3b6c48781a0e 100644 --- a/crates/bevy_math/src/curve/adaptors.rs +++ b/crates/bevy_math/src/curve/adaptors.rs @@ -1,10 +1,10 @@ //! Adaptors used by the Curve API for transforming and combining curves together. -use super::interval::*; use super::Curve; +use super::interval::*; -use crate::ops; use crate::VectorSpace; +use crate::ops; use core::any::type_name; use core::fmt::{self, Debug}; use core::marker::PhantomData; @@ -12,7 +12,7 @@ use core::marker::PhantomData; #[cfg(feature = "bevy_reflect")] use { alloc::format, - bevy_reflect::{utility::GenericTypePathCell, FromReflect, Reflect, TypePath}, + bevy_reflect::{FromReflect, Reflect, TypePath, utility::GenericTypePathCell}, }; #[cfg(feature = "bevy_reflect")] diff --git a/crates/bevy_math/src/curve/cores.rs b/crates/bevy_math/src/curve/cores.rs index 838d0d116d440..ee154d61bcb31 100644 --- a/crates/bevy_math/src/curve/cores.rs +++ b/crates/bevy_math/src/curve/cores.rs @@ -507,7 +507,9 @@ pub enum ChunkedUnevenCoreError { }, /// Tried to infer the width, but the ratio of lengths wasn't an integer, so no such length exists. - #[error("The length of the list of values ({values_len}) was not divisible by that of the list of times ({times_len})")] + #[error( + "The length of the list of values ({values_len}) was not divisible by that of the list of times ({times_len})" + )] NonDivisibleLengths { /// The length of the value buffer. values_len: usize, @@ -698,7 +700,7 @@ mod tests { use super::{ChunkedUnevenCore, EvenCore, UnevenCore}; use crate::curve::{cores::InterpolationDatum, interval}; use alloc::vec; - use approx::{assert_abs_diff_eq, AbsDiffEq}; + use approx::{AbsDiffEq, assert_abs_diff_eq}; fn approx_between(datum: InterpolationDatum, start: T, end: T, p: f32) -> bool where diff --git a/crates/bevy_math/src/curve/derivatives/adaptor_impls.rs b/crates/bevy_math/src/curve/derivatives/adaptor_impls.rs index a499526b78338..1d59959a23321 100644 --- a/crates/bevy_math/src/curve/derivatives/adaptor_impls.rs +++ b/crates/bevy_math/src/curve/derivatives/adaptor_impls.rs @@ -4,11 +4,11 @@ use super::{SampleDerivative, SampleTwoDerivatives}; use crate::common_traits::{HasTangent, Sum, VectorSpace, WithDerivative, WithTwoDerivatives}; use crate::curve::{ + Curve, adaptors::{ ChainCurve, ConstantCurve, ContinuationCurve, CurveReparamCurve, ForeverCurve, GraphCurve, LinearReparamCurve, PingPongCurve, RepeatCurve, ReverseCurve, ZipCurve, }, - Curve, }; // -- ConstantCurve @@ -454,7 +454,7 @@ mod tests { use super::*; use crate::cubic_splines::{CubicBezier, CubicCardinalSpline, CubicCurve, CubicGenerator}; use crate::curve::{Curve, CurveExt, Interval}; - use crate::{vec2, Vec2, Vec3}; + use crate::{Vec2, Vec3, vec2}; fn test_curve() -> CubicCurve { let control_pts = [[ diff --git a/crates/bevy_math/src/curve/easing.rs b/crates/bevy_math/src/curve/easing.rs index 18f42d3f13f24..b6612576f2e9c 100644 --- a/crates/bevy_math/src/curve/easing.rs +++ b/crates/bevy_math/src/curve/easing.rs @@ -4,8 +4,8 @@ //! [easing functions]: EaseFunction use crate::{ - curve::{Curve, CurveExt, FunctionCurve, Interval}, Dir2, Dir3, Dir3A, Isometry2d, Isometry3d, Quat, Rot2, VectorSpace, + curve::{Curve, CurveExt, FunctionCurve, Interval}, }; use variadics_please::all_tuples_enumerated; @@ -597,7 +597,7 @@ pub enum EaseFunction { mod easing_functions { use core::f32::consts::{FRAC_PI_2, FRAC_PI_3, PI}; - use crate::{ops, FloatPow}; + use crate::{FloatPow, ops}; #[inline] pub(crate) fn linear(t: f32) -> f32 { diff --git a/crates/bevy_math/src/curve/interval.rs b/crates/bevy_math/src/curve/interval.rs index 007e523c95be6..31b159b707b98 100644 --- a/crates/bevy_math/src/curve/interval.rs +++ b/crates/bevy_math/src/curve/interval.rs @@ -202,7 +202,7 @@ mod tests { use super::*; use alloc::vec::Vec; - use approx::{assert_abs_diff_eq, AbsDiffEq}; + use approx::{AbsDiffEq, assert_abs_diff_eq}; #[test] fn make_intervals() { @@ -265,14 +265,16 @@ mod tests { let ivl6 = Interval::EVERYWHERE; assert!(ivl1.intersect(ivl2).is_ok_and(|ivl| ivl == Interval::UNIT)); - assert!(ivl1 - .intersect(ivl3) - .is_ok_and(|ivl| ivl == interval(-1.0, 0.0).unwrap())); + assert!( + ivl1.intersect(ivl3) + .is_ok_and(|ivl| ivl == interval(-1.0, 0.0).unwrap()) + ); assert!(ivl2.intersect(ivl3).is_err()); assert!(ivl1.intersect(ivl4).is_ok_and(|ivl| ivl == Interval::UNIT)); - assert!(ivl1 - .intersect(ivl5) - .is_ok_and(|ivl| ivl == interval(-1.0, 0.0).unwrap())); + assert!( + ivl1.intersect(ivl5) + .is_ok_and(|ivl| ivl == interval(-1.0, 0.0).unwrap()) + ); assert!(ivl4.intersect(ivl5).is_err()); assert_eq!(ivl1.intersect(ivl6).unwrap(), ivl1); assert_eq!(ivl4.intersect(ivl6).unwrap(), ivl4); diff --git a/crates/bevy_math/src/curve/mod.rs b/crates/bevy_math/src/curve/mod.rs index 94e7b0151e226..51246de724461 100644 --- a/crates/bevy_math/src/curve/mod.rs +++ b/crates/bevy_math/src/curve/mod.rs @@ -298,7 +298,7 @@ pub mod sample_curves; // bevy_math::curve re-exports all commonly-needed curve-related items. pub use adaptors::*; pub use easing::*; -pub use interval::{interval, Interval}; +pub use interval::{Interval, interval}; #[cfg(feature = "alloc")] pub use { @@ -1004,9 +1004,9 @@ pub enum ResamplingError { #[cfg(test)] mod tests { use super::*; - use crate::{ops, Quat}; + use crate::{Quat, ops}; use alloc::vec::Vec; - use approx::{assert_abs_diff_eq, AbsDiffEq}; + use approx::{AbsDiffEq, assert_abs_diff_eq}; use core::f32::consts::TAU; use glam::*; diff --git a/crates/bevy_math/src/curve/sample_curves.rs b/crates/bevy_math/src/curve/sample_curves.rs index f0fa928abba57..d43cc016a32c5 100644 --- a/crates/bevy_math/src/curve/sample_curves.rs +++ b/crates/bevy_math/src/curve/sample_curves.rs @@ -10,7 +10,7 @@ use core::any::type_name; use core::fmt::{self, Debug}; #[cfg(feature = "bevy_reflect")] -use bevy_reflect::{utility::GenericTypePathCell, Reflect, TypePath}; +use bevy_reflect::{Reflect, TypePath, utility::GenericTypePathCell}; #[cfg(feature = "bevy_reflect")] mod paths { @@ -370,7 +370,7 @@ mod tests { //! - 'static closures //! - function pointers use super::{SampleCurve, UnevenSampleCurve}; - use crate::{curve::Interval, VectorSpace}; + use crate::{VectorSpace, curve::Interval}; use alloc::boxed::Box; use bevy_reflect::Reflect; diff --git a/crates/bevy_math/src/direction.rs b/crates/bevy_math/src/direction.rs index e61e84ee1a129..8b99d1fa30e48 100644 --- a/crates/bevy_math/src/direction.rs +++ b/crates/bevy_math/src/direction.rs @@ -1,6 +1,6 @@ use crate::{ - primitives::{Primitive2d, Primitive3d}, Quat, Rot2, Vec2, Vec3, Vec3A, + primitives::{Primitive2d, Primitive3d}, }; use core::f32::consts::FRAC_1_SQRT_2; diff --git a/crates/bevy_math/src/isometry.rs b/crates/bevy_math/src/isometry.rs index 1d88736d3bd2e..59764587b10e0 100644 --- a/crates/bevy_math/src/isometry.rs +++ b/crates/bevy_math/src/isometry.rs @@ -7,7 +7,7 @@ use core::ops::Mul; use approx::{AbsDiffEq, RelativeEq, UlpsEq}; #[cfg(feature = "bevy_reflect")] -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; #[cfg(all(feature = "bevy_reflect", feature = "serialize"))] use bevy_reflect::{ReflectDeserialize, ReflectSerialize}; diff --git a/crates/bevy_math/src/lib.rs b/crates/bevy_math/src/lib.rs index 20d458db72d23..9c7a8b4adc27a 100644 --- a/crates/bevy_math/src/lib.rs +++ b/crates/bevy_math/src/lib.rs @@ -71,15 +71,15 @@ pub use sampling::{FromRng, ShapeSample}; pub mod prelude { #[doc(hidden)] pub use crate::{ - bvec2, bvec3, bvec3a, bvec4, bvec4a, + BVec2, BVec3, BVec3A, BVec4, BVec4A, EulerRot, FloatExt, IRect, IVec2, IVec3, IVec4, + Isometry2d, Isometry3d, Mat2, Mat3, Mat3A, Mat4, Quat, Ray2d, Ray3d, Rect, Rot2, + StableInterpolate, URect, UVec2, UVec3, UVec4, Vec2, Vec2Swizzles, Vec3, Vec3A, + Vec3Swizzles, Vec4, Vec4Swizzles, bvec2, bvec3, bvec3a, bvec4, bvec4a, cubic_splines::{CubicNurbsError, CubicSegment, RationalSegment}, direction::{Dir2, Dir3, Dir3A}, ivec2, ivec3, ivec4, mat2, mat3, mat3a, mat4, ops, primitives::*, - quat, uvec2, uvec3, uvec4, vec2, vec3, vec3a, vec4, BVec2, BVec3, BVec3A, BVec4, BVec4A, - EulerRot, FloatExt, IRect, IVec2, IVec3, IVec4, Isometry2d, Isometry3d, Mat2, Mat3, Mat3A, - Mat4, Quat, Ray2d, Ray3d, Rect, Rot2, StableInterpolate, URect, UVec2, UVec3, UVec4, Vec2, - Vec2Swizzles, Vec3, Vec3A, Vec3Swizzles, Vec4, Vec4Swizzles, + quat, uvec2, uvec3, uvec4, vec2, vec3, vec3a, vec4, }; #[doc(hidden)] diff --git a/crates/bevy_math/src/ops.rs b/crates/bevy_math/src/ops.rs index e9d27ac54a83a..2bcceb43a6759 100644 --- a/crates/bevy_math/src/ops.rs +++ b/crates/bevy_math/src/ops.rs @@ -463,11 +463,7 @@ mod libm_ops_for_no_std { let result = libm::remainderf(x, y); // libm::remainderf has a range of -y/2 to +y/2 - if result < 0. { - result + y - } else { - result - } + if result < 0. { result + y } else { result } } /// Computes the absolute value of x. diff --git a/crates/bevy_math/src/primitives/dim2.rs b/crates/bevy_math/src/primitives/dim2.rs index c336edac45a76..8867999f13fc3 100644 --- a/crates/bevy_math/src/primitives/dim2.rs +++ b/crates/bevy_math/src/primitives/dim2.rs @@ -4,15 +4,15 @@ use thiserror::Error; use super::{Measured2d, Primitive2d, WindingOrder}; use crate::{ - ops::{self, FloatPow}, Dir2, Rot2, Vec2, + ops::{self, FloatPow}, }; #[cfg(feature = "alloc")] use super::polygon::is_polygon_simple; #[cfg(feature = "bevy_reflect")] -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; #[cfg(all(feature = "serialize", feature = "bevy_reflect"))] use bevy_reflect::{ReflectDeserialize, ReflectSerialize}; diff --git a/crates/bevy_math/src/primitives/dim3.rs b/crates/bevy_math/src/primitives/dim3.rs index a828fa8247587..ec0c1b33452de 100644 --- a/crates/bevy_math/src/primitives/dim3.rs +++ b/crates/bevy_math/src/primitives/dim3.rs @@ -2,12 +2,12 @@ use core::f32::consts::{FRAC_PI_3, PI}; use super::{Circle, Measured2d, Measured3d, Primitive2d, Primitive3d}; use crate::{ - ops::{self, FloatPow}, Dir3, InvalidDirectionError, Isometry3d, Mat3, Vec2, Vec3, + ops::{self, FloatPow}, }; #[cfg(feature = "bevy_reflect")] -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; #[cfg(all(feature = "serialize", feature = "bevy_reflect"))] use bevy_reflect::{ReflectDeserialize, ReflectSerialize}; use glam::Quat; diff --git a/crates/bevy_math/src/primitives/polygon.rs b/crates/bevy_math/src/primitives/polygon.rs index 20d35b552c827..afa8d55db5b4a 100644 --- a/crates/bevy_math/src/primitives/polygon.rs +++ b/crates/bevy_math/src/primitives/polygon.rs @@ -322,7 +322,7 @@ pub fn is_polygon_simple(vertices: &[Vec2]) -> bool { #[cfg(test)] mod tests { - use crate::{primitives::polygon::is_polygon_simple, Vec2}; + use crate::{Vec2, primitives::polygon::is_polygon_simple}; #[test] fn complex_polygon() { diff --git a/crates/bevy_math/src/primitives/serde.rs b/crates/bevy_math/src/primitives/serde.rs index 7db6be9700114..91dff0c278b02 100644 --- a/crates/bevy_math/src/primitives/serde.rs +++ b/crates/bevy_math/src/primitives/serde.rs @@ -6,9 +6,9 @@ pub(crate) mod array { use core::marker::PhantomData; use serde::{ + Deserialize, Deserializer, Serialize, Serializer, de::{SeqAccess, Visitor}, ser::SerializeTuple, - Deserialize, Deserializer, Serialize, Serializer, }; pub fn serialize( diff --git a/crates/bevy_math/src/ray.rs b/crates/bevy_math/src/ray.rs index 273ed61fa4b97..07364e7bb4a3c 100644 --- a/crates/bevy_math/src/ray.rs +++ b/crates/bevy_math/src/ray.rs @@ -1,7 +1,6 @@ use crate::{ - ops, + Dir2, Dir3, Vec2, Vec3, ops, primitives::{InfinitePlane3d, Plane2d}, - Dir2, Dir3, Vec2, Vec3, }; #[cfg(feature = "bevy_reflect")] @@ -110,31 +109,36 @@ mod tests { ray.intersect_plane(Vec2::Y, Plane2d::new(Vec2::NEG_Y)), Some(1.0) ); - assert!(ray - .intersect_plane(Vec2::NEG_Y, Plane2d::new(Vec2::Y)) - .is_none()); - assert!(ray - .intersect_plane(Vec2::NEG_Y, Plane2d::new(Vec2::NEG_Y)) - .is_none()); + assert!( + ray.intersect_plane(Vec2::NEG_Y, Plane2d::new(Vec2::Y)) + .is_none() + ); + assert!( + ray.intersect_plane(Vec2::NEG_Y, Plane2d::new(Vec2::NEG_Y)) + .is_none() + ); // Diagonal assert_eq!( ray.intersect_plane(Vec2::Y, Plane2d::new(Vec2::ONE)), Some(1.0) ); - assert!(ray - .intersect_plane(Vec2::NEG_Y, Plane2d::new(Vec2::ONE)) - .is_none()); + assert!( + ray.intersect_plane(Vec2::NEG_Y, Plane2d::new(Vec2::ONE)) + .is_none() + ); // Parallel - assert!(ray - .intersect_plane(Vec2::X, Plane2d::new(Vec2::X)) - .is_none()); + assert!( + ray.intersect_plane(Vec2::X, Plane2d::new(Vec2::X)) + .is_none() + ); // Parallel with simulated rounding error - assert!(ray - .intersect_plane(Vec2::X, Plane2d::new(Vec2::X + Vec2::Y * f32::EPSILON)) - .is_none()); + assert!( + ray.intersect_plane(Vec2::X, Plane2d::new(Vec2::X + Vec2::Y * f32::EPSILON)) + .is_none() + ); } #[test] @@ -150,33 +154,38 @@ mod tests { ray.intersect_plane(Vec3::Z, InfinitePlane3d::new(Vec3::NEG_Z)), Some(1.0) ); - assert!(ray - .intersect_plane(Vec3::NEG_Z, InfinitePlane3d::new(Vec3::Z)) - .is_none()); - assert!(ray - .intersect_plane(Vec3::NEG_Z, InfinitePlane3d::new(Vec3::NEG_Z)) - .is_none()); + assert!( + ray.intersect_plane(Vec3::NEG_Z, InfinitePlane3d::new(Vec3::Z)) + .is_none() + ); + assert!( + ray.intersect_plane(Vec3::NEG_Z, InfinitePlane3d::new(Vec3::NEG_Z)) + .is_none() + ); // Diagonal assert_eq!( ray.intersect_plane(Vec3::Z, InfinitePlane3d::new(Vec3::ONE)), Some(1.0) ); - assert!(ray - .intersect_plane(Vec3::NEG_Z, InfinitePlane3d::new(Vec3::ONE)) - .is_none()); + assert!( + ray.intersect_plane(Vec3::NEG_Z, InfinitePlane3d::new(Vec3::ONE)) + .is_none() + ); // Parallel - assert!(ray - .intersect_plane(Vec3::X, InfinitePlane3d::new(Vec3::X)) - .is_none()); + assert!( + ray.intersect_plane(Vec3::X, InfinitePlane3d::new(Vec3::X)) + .is_none() + ); // Parallel with simulated rounding error - assert!(ray - .intersect_plane( + assert!( + ray.intersect_plane( Vec3::X, InfinitePlane3d::new(Vec3::X + Vec3::Z * f32::EPSILON) ) - .is_none()); + .is_none() + ); } } diff --git a/crates/bevy_math/src/rects/irect.rs b/crates/bevy_math/src/rects/irect.rs index 73e830f085e29..6fc7acd476a46 100644 --- a/crates/bevy_math/src/rects/irect.rs +++ b/crates/bevy_math/src/rects/irect.rs @@ -1,7 +1,7 @@ use crate::{IVec2, Rect, URect}; #[cfg(feature = "bevy_reflect")] -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; #[cfg(all(feature = "serialize", feature = "bevy_reflect"))] use bevy_reflect::{ReflectDeserialize, ReflectSerialize}; diff --git a/crates/bevy_math/src/rects/rect.rs b/crates/bevy_math/src/rects/rect.rs index 901a569a71f4e..a0d6ab4a60cf2 100644 --- a/crates/bevy_math/src/rects/rect.rs +++ b/crates/bevy_math/src/rects/rect.rs @@ -1,7 +1,7 @@ use crate::{IRect, URect, Vec2}; #[cfg(feature = "bevy_reflect")] -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; #[cfg(all(feature = "serialize", feature = "bevy_reflect"))] use bevy_reflect::{ReflectDeserialize, ReflectSerialize}; diff --git a/crates/bevy_math/src/rects/urect.rs b/crates/bevy_math/src/rects/urect.rs index 54127504654ca..7f47c43c46d8d 100644 --- a/crates/bevy_math/src/rects/urect.rs +++ b/crates/bevy_math/src/rects/urect.rs @@ -1,7 +1,7 @@ use crate::{IRect, Rect, UVec2}; #[cfg(feature = "bevy_reflect")] -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; #[cfg(all(feature = "serialize", feature = "bevy_reflect"))] use bevy_reflect::{ReflectDeserialize, ReflectSerialize}; @@ -101,7 +101,10 @@ impl URect { /// ``` #[inline] pub fn from_center_size(origin: UVec2, size: UVec2) -> Self { - assert!(origin.cmpge(size / 2).all(), "Origin must always be greater than or equal to (size / 2) otherwise the rectangle is undefined! Origin was {origin} and size was {size}"); + assert!( + origin.cmpge(size / 2).all(), + "Origin must always be greater than or equal to (size / 2) otherwise the rectangle is undefined! Origin was {origin} and size was {size}" + ); let half_size = size / 2; Self::from_center_half_size(origin, half_size) } @@ -122,7 +125,10 @@ impl URect { /// ``` #[inline] pub fn from_center_half_size(origin: UVec2, half_size: UVec2) -> Self { - assert!(origin.cmpge(half_size).all(), "Origin must always be greater than or equal to half_size otherwise the rectangle is undefined! Origin was {origin} and half_size was {half_size}"); + assert!( + origin.cmpge(half_size).all(), + "Origin must always be greater than or equal to half_size otherwise the rectangle is undefined! Origin was {origin} and half_size was {half_size}" + ); Self { min: origin - half_size, max: origin + half_size, diff --git a/crates/bevy_math/src/rotation2d.rs b/crates/bevy_math/src/rotation2d.rs index 3f5d3031cf1a9..167ed0bc8d700 100644 --- a/crates/bevy_math/src/rotation2d.rs +++ b/crates/bevy_math/src/rotation2d.rs @@ -8,7 +8,7 @@ use crate::{ }; #[cfg(feature = "bevy_reflect")] -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; #[cfg(all(feature = "serialize", feature = "bevy_reflect"))] use bevy_reflect::{ReflectDeserialize, ReflectSerialize}; @@ -518,7 +518,7 @@ mod tests { use approx::assert_relative_eq; - use crate::{ops, Dir2, Rot2, Vec2}; + use crate::{Dir2, Rot2, Vec2, ops}; #[test] fn creation() { @@ -656,31 +656,37 @@ mod tests { #[test] fn try_normalize() { // Valid - assert!(Rot2 { - sin: 10.0, - cos: 5.0, - } - .try_normalize() - .is_some()); + assert!( + Rot2 { + sin: 10.0, + cos: 5.0, + } + .try_normalize() + .is_some() + ); // NaN - assert!(Rot2 { - sin: f32::NAN, - cos: 5.0, - } - .try_normalize() - .is_none()); + assert!( + Rot2 { + sin: f32::NAN, + cos: 5.0, + } + .try_normalize() + .is_none() + ); // Zero assert!(Rot2 { sin: 0.0, cos: 0.0 }.try_normalize().is_none()); // Non-finite - assert!(Rot2 { - sin: f32::INFINITY, - cos: 5.0, - } - .try_normalize() - .is_none()); + assert!( + Rot2 { + sin: f32::INFINITY, + cos: 5.0, + } + .try_normalize() + .is_none() + ); } #[test] diff --git a/crates/bevy_math/src/sampling/mesh_sampling.rs b/crates/bevy_math/src/sampling/mesh_sampling.rs index 898198dea4261..8e4def3fecde5 100644 --- a/crates/bevy_math/src/sampling/mesh_sampling.rs +++ b/crates/bevy_math/src/sampling/mesh_sampling.rs @@ -1,8 +1,8 @@ //! Functionality related to random sampling from triangle meshes. use crate::{ - primitives::{Measured2d, Triangle3d}, ShapeSample, Vec3, + primitives::{Measured2d, Triangle3d}, }; use alloc::vec::Vec; use rand::Rng; diff --git a/crates/bevy_math/src/sampling/shape_sampling.rs b/crates/bevy_math/src/sampling/shape_sampling.rs index 3be0ead1da98e..6dc6324362153 100644 --- a/crates/bevy_math/src/sampling/shape_sampling.rs +++ b/crates/bevy_math/src/sampling/shape_sampling.rs @@ -40,10 +40,10 @@ use core::f32::consts::{PI, TAU}; -use crate::{ops, primitives::*, NormedVectorSpace, Vec2, Vec3}; +use crate::{NormedVectorSpace, Vec2, Vec3, ops, primitives::*}; use rand::{ - distributions::{Distribution, WeightedIndex}, Rng, + distributions::{Distribution, WeightedIndex}, }; /// Exposes methods to uniformly sample a variety of primitive shapes. diff --git a/crates/bevy_math/src/sampling/standard.rs b/crates/bevy_math/src/sampling/standard.rs index 7de8270e30ea1..8ec2e99265800 100644 --- a/crates/bevy_math/src/sampling/standard.rs +++ b/crates/bevy_math/src/sampling/standard.rs @@ -24,12 +24,12 @@ use core::f32::consts::TAU; use crate::{ - primitives::{Circle, Sphere}, Dir2, Dir3, Dir3A, Quat, Rot2, ShapeSample, Vec3A, + primitives::{Circle, Sphere}, }; use rand::{ - distributions::{Distribution, Standard}, Rng, + distributions::{Distribution, Standard}, }; /// Ergonomics trait for a type with a [`Standard`] distribution, allowing values to be generated diff --git a/crates/bevy_mesh/src/conversions.rs b/crates/bevy_mesh/src/conversions.rs index f68c2d6f74321..506ba7341d47c 100644 --- a/crates/bevy_mesh/src/conversions.rs +++ b/crates/bevy_mesh/src/conversions.rs @@ -453,7 +453,9 @@ mod tests { error.to_string(), "cannot convert VertexAttributeValues::Uint32x4 to alloc::vec::Vec" ); - assert_eq!(format!("{error:?}"), - "FromVertexAttributeError { from: Uint32x4([[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]), variant: \"Uint32x4\", into: \"alloc::vec::Vec\" }"); + assert_eq!( + format!("{error:?}"), + "FromVertexAttributeError { from: Uint32x4([[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]), variant: \"Uint32x4\", into: \"alloc::vec::Vec\" }" + ); } } diff --git a/crates/bevy_mesh/src/mesh.rs b/crates/bevy_mesh/src/mesh.rs index 44b313434e299..9594a812ba49f 100644 --- a/crates/bevy_mesh/src/mesh.rs +++ b/crates/bevy_mesh/src/mesh.rs @@ -2,10 +2,10 @@ use bevy_transform::components::Transform; pub use wgpu_types::PrimitiveTopology; use super::{ - face_area_normal, face_normal, generate_tangents_for_mesh, scale_normal, FourIterators, - GenerateTangentsError, Indices, MeshAttributeData, MeshTrianglesError, MeshVertexAttribute, - MeshVertexAttributeId, MeshVertexBufferLayout, MeshVertexBufferLayoutRef, + FourIterators, GenerateTangentsError, Indices, MeshAttributeData, MeshTrianglesError, + MeshVertexAttribute, MeshVertexAttributeId, MeshVertexBufferLayout, MeshVertexBufferLayoutRef, MeshVertexBufferLayouts, MeshWindingInvertError, VertexAttributeValues, VertexBufferLayout, + face_area_normal, face_normal, generate_tangents_for_mesh, scale_normal, }; use alloc::collections::BTreeMap; use bevy_asset::{Asset, Handle, RenderAssetUsages}; @@ -442,8 +442,10 @@ impl Mesh { .map(|data| data.attribute.name.to_string()) .unwrap_or_else(|| format!("{attribute_id:?}")); - warn!("{name} has a different vertex count ({attribute_len}) than other attributes ({previous_vertex_count}) in this mesh, \ - all attributes will be truncated to match the smallest."); + warn!( + "{name} has a different vertex count ({attribute_len}) than other attributes ({previous_vertex_count}) in this mesh, \ + all attributes will be truncated to match the smallest." + ); vertex_count = Some(core::cmp::min(previous_vertex_count, attribute_len)); } } else { @@ -849,7 +851,7 @@ impl Mesh { other_attribute: other .attribute_data(attribute.id) .map(|data| data.attribute), - }) + }); } } } @@ -1236,11 +1238,11 @@ pub struct MergeMeshError { #[cfg(test)] mod tests { use super::Mesh; - use crate::mesh::{Indices, MeshWindingInvertError, VertexAttributeValues}; use crate::PrimitiveTopology; + use crate::mesh::{Indices, MeshWindingInvertError, VertexAttributeValues}; use bevy_asset::RenderAssetUsages; - use bevy_math::primitives::Triangle3d; use bevy_math::Vec3; + use bevy_math::primitives::Triangle3d; use bevy_transform::components::Transform; #[test] diff --git a/crates/bevy_mesh/src/primitives/dim2.rs b/crates/bevy_mesh/src/primitives/dim2.rs index 16440e9b00f34..131052c3c1b6a 100644 --- a/crates/bevy_mesh/src/primitives/dim2.rs +++ b/crates/bevy_mesh/src/primitives/dim2.rs @@ -1,16 +1,15 @@ use core::f32::consts::FRAC_PI_2; -use crate::{primitives::dim3::triangle3d, Indices, Mesh, PerimeterSegment}; +use crate::{Indices, Mesh, PerimeterSegment, primitives::dim3::triangle3d}; use bevy_asset::RenderAssetUsages; use super::{Extrudable, MeshBuilder, Meshable}; use bevy_math::{ - ops, + FloatExt, Vec2, ops, primitives::{ Annulus, Capsule2d, Circle, CircularSector, CircularSegment, ConvexPolygon, Ellipse, Rectangle, RegularPolygon, Rhombus, Triangle2d, Triangle3d, WindingOrder, }, - FloatExt, Vec2, }; use bevy_reflect::prelude::*; use wgpu_types::PrimitiveTopology; @@ -1175,7 +1174,7 @@ impl From for Mesh { #[cfg(test)] mod tests { - use bevy_math::{prelude::Annulus, primitives::RegularPolygon, FloatOrd}; + use bevy_math::{FloatOrd, prelude::Annulus, primitives::RegularPolygon}; use bevy_platform_support::collections::HashSet; use crate::{Mesh, MeshBuilder, Meshable, VertexAttributeValues}; diff --git a/crates/bevy_mesh/src/primitives/dim3/capsule.rs b/crates/bevy_mesh/src/primitives/dim3/capsule.rs index 81c7f77306085..6ceb5817225ae 100644 --- a/crates/bevy_mesh/src/primitives/dim3/capsule.rs +++ b/crates/bevy_mesh/src/primitives/dim3/capsule.rs @@ -1,6 +1,6 @@ use crate::{Indices, Mesh, MeshBuilder, Meshable, PrimitiveTopology}; use bevy_asset::RenderAssetUsages; -use bevy_math::{ops, primitives::Capsule3d, Vec2, Vec3}; +use bevy_math::{Vec2, Vec3, ops, primitives::Capsule3d}; use bevy_reflect::prelude::*; /// Manner in which UV coordinates are distributed vertically. diff --git a/crates/bevy_mesh/src/primitives/dim3/cone.rs b/crates/bevy_mesh/src/primitives/dim3/cone.rs index fde442537025e..1ae9678df1006 100644 --- a/crates/bevy_mesh/src/primitives/dim3/cone.rs +++ b/crates/bevy_mesh/src/primitives/dim3/cone.rs @@ -1,6 +1,6 @@ use crate::{Indices, Mesh, MeshBuilder, Meshable, PrimitiveTopology}; use bevy_asset::RenderAssetUsages; -use bevy_math::{ops, primitives::Cone, Vec3}; +use bevy_math::{Vec3, ops, primitives::Cone}; use bevy_reflect::prelude::*; /// Anchoring options for [`ConeMeshBuilder`] @@ -191,7 +191,7 @@ impl From for Mesh { #[cfg(test)] mod tests { use crate::{Mesh, MeshBuilder, Meshable, VertexAttributeValues}; - use bevy_math::{primitives::Cone, Vec2}; + use bevy_math::{Vec2, primitives::Cone}; /// Rounds floats to handle floating point error in tests. fn round_floats(points: &mut [[f32; N]]) { diff --git a/crates/bevy_mesh/src/primitives/dim3/conical_frustum.rs b/crates/bevy_mesh/src/primitives/dim3/conical_frustum.rs index a90e9f972dc5c..2a1a7eda13ecd 100644 --- a/crates/bevy_mesh/src/primitives/dim3/conical_frustum.rs +++ b/crates/bevy_mesh/src/primitives/dim3/conical_frustum.rs @@ -1,6 +1,6 @@ use crate::{Indices, Mesh, MeshBuilder, Meshable, PrimitiveTopology}; use bevy_asset::RenderAssetUsages; -use bevy_math::{ops, primitives::ConicalFrustum, Vec3}; +use bevy_math::{Vec3, ops, primitives::ConicalFrustum}; use bevy_reflect::prelude::*; /// A builder used for creating a [`Mesh`] with a [`ConicalFrustum`] shape. diff --git a/crates/bevy_mesh/src/primitives/dim3/cuboid.rs b/crates/bevy_mesh/src/primitives/dim3/cuboid.rs index 30689ab1318c6..96391f4794f4d 100644 --- a/crates/bevy_mesh/src/primitives/dim3/cuboid.rs +++ b/crates/bevy_mesh/src/primitives/dim3/cuboid.rs @@ -1,6 +1,6 @@ use crate::{Indices, Mesh, MeshBuilder, Meshable, PrimitiveTopology}; use bevy_asset::RenderAssetUsages; -use bevy_math::{primitives::Cuboid, Vec3}; +use bevy_math::{Vec3, primitives::Cuboid}; use bevy_reflect::prelude::*; /// A builder used for creating a [`Mesh`] with a [`Cuboid`] shape. diff --git a/crates/bevy_mesh/src/primitives/dim3/plane.rs b/crates/bevy_mesh/src/primitives/dim3/plane.rs index 9a2621a163194..c723469b270c2 100644 --- a/crates/bevy_mesh/src/primitives/dim3/plane.rs +++ b/crates/bevy_mesh/src/primitives/dim3/plane.rs @@ -1,6 +1,6 @@ use crate::{Indices, Mesh, MeshBuilder, Meshable, PrimitiveTopology}; use bevy_asset::RenderAssetUsages; -use bevy_math::{primitives::Plane3d, Dir3, Quat, Vec2, Vec3}; +use bevy_math::{Dir3, Quat, Vec2, Vec3, primitives::Plane3d}; use bevy_reflect::prelude::*; /// A builder used for creating a [`Mesh`] with a [`Plane3d`] shape. diff --git a/crates/bevy_mesh/src/primitives/dim3/sphere.rs b/crates/bevy_mesh/src/primitives/dim3/sphere.rs index 686887b13e9db..083582b58ac76 100644 --- a/crates/bevy_mesh/src/primitives/dim3/sphere.rs +++ b/crates/bevy_mesh/src/primitives/dim3/sphere.rs @@ -10,7 +10,9 @@ use thiserror::Error; #[derive(Clone, Copy, Debug, Error)] pub enum IcosphereError { /// The icosphere has too many vertices. - #[error("Cannot create an icosphere of {subdivisions} subdivisions due to there being too many vertices being generated: {number_of_resulting_points}. (Limited to 65535 vertices or 79 subdivisions)")] + #[error( + "Cannot create an icosphere of {subdivisions} subdivisions due to there being too many vertices being generated: {number_of_resulting_points}. (Limited to 65535 vertices or 79 subdivisions)" + )] TooManyVertices { /// The number of subdivisions used. 79 is the largest allowed value for a mesh to be generated. subdivisions: u32, diff --git a/crates/bevy_mesh/src/primitives/dim3/torus.rs b/crates/bevy_mesh/src/primitives/dim3/torus.rs index 6d9c802e6cbd9..5520e907811f7 100644 --- a/crates/bevy_mesh/src/primitives/dim3/torus.rs +++ b/crates/bevy_mesh/src/primitives/dim3/torus.rs @@ -1,6 +1,6 @@ use crate::{Indices, Mesh, MeshBuilder, Meshable, PrimitiveTopology}; use bevy_asset::RenderAssetUsages; -use bevy_math::{ops, primitives::Torus, Vec3}; +use bevy_math::{Vec3, ops, primitives::Torus}; use bevy_reflect::prelude::*; use core::ops::RangeInclusive; diff --git a/crates/bevy_mesh/src/primitives/dim3/triangle3d.rs b/crates/bevy_mesh/src/primitives/dim3/triangle3d.rs index f605dbeaf1761..6bcafa7405b4c 100644 --- a/crates/bevy_mesh/src/primitives/dim3/triangle3d.rs +++ b/crates/bevy_mesh/src/primitives/dim3/triangle3d.rs @@ -1,6 +1,6 @@ use crate::{Indices, Mesh, MeshBuilder, Meshable, PrimitiveTopology}; use bevy_asset::RenderAssetUsages; -use bevy_math::{primitives::Triangle3d, Vec3}; +use bevy_math::{Vec3, primitives::Triangle3d}; use bevy_reflect::prelude::*; /// A builder used for creating a [`Mesh`] with a [`Triangle3d`] shape. diff --git a/crates/bevy_mesh/src/primitives/extrusion.rs b/crates/bevy_mesh/src/primitives/extrusion.rs index 2a9e5d7551caa..863a1bca277c1 100644 --- a/crates/bevy_mesh/src/primitives/extrusion.rs +++ b/crates/bevy_mesh/src/primitives/extrusion.rs @@ -1,6 +1,6 @@ use bevy_math::{ - primitives::{Annulus, Capsule2d, Circle, Ellipse, Extrusion, Primitive2d}, Vec2, Vec3, + primitives::{Annulus, Capsule2d, Circle, Ellipse, Extrusion, Primitive2d}, }; use super::{MeshBuilder, Meshable}; @@ -207,7 +207,9 @@ where } }, _ => { - panic!("Meshes used with Extrusions must have a primitive topology of `PrimitiveTopology::TriangleList`"); + panic!( + "Meshes used with Extrusions must have a primitive topology of `PrimitiveTopology::TriangleList`" + ); } }; } diff --git a/crates/bevy_mikktspace/src/generated.rs b/crates/bevy_mikktspace/src/generated.rs index 8e6a2b27b398b..24c02bca12b2a 100644 --- a/crates/bevy_mikktspace/src/generated.rs +++ b/crates/bevy_mikktspace/src/generated.rs @@ -50,7 +50,7 @@ use core::ptr::{self, null_mut}; use glam::Vec3; -use crate::{face_vert_to_index, get_normal, get_position, get_tex_coord, Geometry}; +use crate::{Geometry, face_vert_to_index, get_normal, get_position, get_tex_coord}; #[derive(Copy, Clone)] pub struct STSpace { @@ -1669,11 +1669,7 @@ unsafe fn MergeVertsFast( if iL == iR { let bReadyRightSwap_0: bool = (*pTmpVert.offset(iR as isize)).vert[channel as usize] < fSep; - if bReadyRightSwap_0 { - iL += 1 - } else { - iR -= 1 - } + if bReadyRightSwap_0 { iL += 1 } else { iR -= 1 } } if iL_in < iR { MergeVertsFast(piTriList_in_and_out, pTmpVert, geometry, iL_in, iR); @@ -1694,11 +1690,7 @@ unsafe fn FindGridCell(fMin: f32, fMax: f32, fVal: f32) -> usize { let fIndex = g_iCells as f32 * ((fVal - fMin) / (fMax - fMin)); let iIndex = fIndex as isize; return if iIndex < g_iCells as isize { - if iIndex >= 0 { - iIndex as usize - } else { - 0 - } + if iIndex >= 0 { iIndex as usize } else { 0 } } else { g_iCells - 1 }; diff --git a/crates/bevy_mikktspace/tests/regression_test.rs b/crates/bevy_mikktspace/tests/regression_test.rs index a0632b76e29b5..76959cf16a143 100644 --- a/crates/bevy_mikktspace/tests/regression_test.rs +++ b/crates/bevy_mikktspace/tests/regression_test.rs @@ -5,7 +5,7 @@ clippy::useless_conversion )] -use bevy_mikktspace::{generate_tangents, Geometry}; +use bevy_mikktspace::{Geometry, generate_tangents}; use glam::{Vec2, Vec3}; pub type Face = [u32; 3]; diff --git a/crates/bevy_pbr/src/atmosphere/mod.rs b/crates/bevy_pbr/src/atmosphere/mod.rs index f525c0e2b8d3d..2339c3fc2e4f4 100644 --- a/crates/bevy_pbr/src/atmosphere/mod.rs +++ b/crates/bevy_pbr/src/atmosphere/mod.rs @@ -36,44 +36,44 @@ use bevy_app::{App, Plugin}; use bevy_asset::load_internal_asset; use bevy_core_pipeline::core_3d::graph::Node3d; use bevy_ecs::{ - component::{require, Component}, + component::{Component, require}, query::{Changed, QueryItem, With}, schedule::IntoSystemConfigs, - system::{lifetimeless::Read, Query}, + system::{Query, lifetimeless::Read}, }; use bevy_math::{UVec2, UVec3, Vec3}; use bevy_reflect::Reflect; use bevy_render::{ - extract_component::UniformComponentPlugin, - render_resource::{DownlevelFlags, ShaderType, SpecializedRenderPipelines}, - renderer::RenderDevice, - settings::WgpuFeatures, -}; -use bevy_render::{ + Render, RenderApp, RenderSet, extract_component::{ExtractComponent, ExtractComponentPlugin}, render_graph::{RenderGraphApp, ViewNodeRunner}, render_resource::{Shader, TextureFormat, TextureUsages}, renderer::RenderAdapter, - Render, RenderApp, RenderSet, +}; +use bevy_render::{ + extract_component::UniformComponentPlugin, + render_resource::{DownlevelFlags, ShaderType, SpecializedRenderPipelines}, + renderer::RenderDevice, + settings::WgpuFeatures, }; -use bevy_core_pipeline::core_3d::{graph::Core3d, Camera3d}; +use bevy_core_pipeline::core_3d::{Camera3d, graph::Core3d}; use resources::{ - prepare_atmosphere_transforms, queue_render_sky_pipelines, AtmosphereTransforms, - RenderSkyBindGroupLayouts, + AtmosphereTransforms, RenderSkyBindGroupLayouts, prepare_atmosphere_transforms, + queue_render_sky_pipelines, }; use tracing::warn; use self::{ node::{AtmosphereLutsNode, AtmosphereNode, RenderSkyNode}, resources::{ - prepare_atmosphere_bind_groups, prepare_atmosphere_textures, AtmosphereBindGroupLayouts, - AtmosphereLutPipelines, AtmosphereSamplers, + AtmosphereBindGroupLayouts, AtmosphereLutPipelines, AtmosphereSamplers, + prepare_atmosphere_bind_groups, prepare_atmosphere_textures, }, }; mod shaders { - use bevy_asset::{weak_handle, Handle}; + use bevy_asset::{Handle, weak_handle}; use bevy_render::render_resource::Shader; pub const TYPES: Handle = weak_handle!("ef7e147e-30a0-4513-bae3-ddde2a6c20c5"); @@ -183,7 +183,9 @@ impl Plugin for AtmospherePlugin { .allowed_usages .contains(TextureUsages::STORAGE_BINDING) { - warn!("AtmospherePlugin not loaded. GPU lacks support: TextureFormat::Rgba16Float does not support TextureUsages::STORAGE_BINDING."); + warn!( + "AtmospherePlugin not loaded. GPU lacks support: TextureFormat::Rgba16Float does not support TextureUsages::STORAGE_BINDING." + ); return; } diff --git a/crates/bevy_pbr/src/atmosphere/node.rs b/crates/bevy_pbr/src/atmosphere/node.rs index 851447d760fc3..54a91138a7887 100644 --- a/crates/bevy_pbr/src/atmosphere/node.rs +++ b/crates/bevy_pbr/src/atmosphere/node.rs @@ -11,11 +11,11 @@ use bevy_render::{ use crate::ViewLightsUniformOffset; use super::{ + Atmosphere, AtmosphereSettings, resources::{ AtmosphereBindGroups, AtmosphereLutPipelines, AtmosphereTransformsOffset, RenderSkyPipelineId, }, - Atmosphere, AtmosphereSettings, }; #[derive(PartialEq, Eq, Debug, Copy, Clone, Hash, RenderLabel)] diff --git a/crates/bevy_pbr/src/atmosphere/resources.rs b/crates/bevy_pbr/src/atmosphere/resources.rs index 71bf26da2d75a..c73e8b1154020 100644 --- a/crates/bevy_pbr/src/atmosphere/resources.rs +++ b/crates/bevy_pbr/src/atmosphere/resources.rs @@ -21,7 +21,7 @@ use bevy_render::{ use crate::{GpuLights, LightMeta}; -use super::{shaders, Atmosphere, AtmosphereSettings}; +use super::{Atmosphere, AtmosphereSettings, shaders}; #[derive(Resource)] pub(crate) struct AtmosphereBindGroupLayouts { diff --git a/crates/bevy_pbr/src/cluster/assign.rs b/crates/bevy_pbr/src/cluster/assign.rs index 36a4aadfb31d6..46a7d305dc978 100644 --- a/crates/bevy_pbr/src/cluster/assign.rs +++ b/crates/bevy_pbr/src/cluster/assign.rs @@ -6,8 +6,8 @@ use bevy_ecs::{ system::{Commands, Local, Query, Res, ResMut}, }; use bevy_math::{ - ops::{self, sin_cos}, Mat4, UVec3, Vec2, Vec3, Vec3A, Vec3Swizzles as _, Vec4, Vec4Swizzles as _, + ops::{self, sin_cos}, }; use bevy_render::{ camera::Camera, @@ -21,12 +21,12 @@ use bevy_utils::prelude::default; use tracing::warn; use crate::{ + CLUSTERED_FORWARD_STORAGE_BUFFER_COUNT, ClusterConfig, ClusterFarZMode, Clusters, + ExtractedPointLight, GlobalVisibleClusterableObjects, LightProbe, + MAX_UNIFORM_BUFFER_CLUSTERABLE_OBJECTS, PointLight, SpotLight, ViewClusterBindings, + VisibleClusterableObjects, VolumetricLight, decal::{self, clustered::ClusteredDecal}, prelude::EnvironmentMapLight, - ClusterConfig, ClusterFarZMode, Clusters, ExtractedPointLight, GlobalVisibleClusterableObjects, - LightProbe, PointLight, SpotLight, ViewClusterBindings, VisibleClusterableObjects, - VolumetricLight, CLUSTERED_FORWARD_STORAGE_BUFFER_COUNT, - MAX_UNIFORM_BUFFER_CLUSTERABLE_OBJECTS, }; const NDC_MIN: Vec2 = Vec2::NEG_ONE; diff --git a/crates/bevy_pbr/src/cluster/mod.rs b/crates/bevy_pbr/src/cluster/mod.rs index d8a1466320383..818281df01900 100644 --- a/crates/bevy_pbr/src/cluster/mod.rs +++ b/crates/bevy_pbr/src/cluster/mod.rs @@ -5,17 +5,18 @@ use core::num::NonZero; use bevy_core_pipeline::core_3d::Camera3d; use bevy_ecs::{ component::Component, - entity::{hash_map::EntityHashMap, Entity}, + entity::{Entity, hash_map::EntityHashMap}, query::{With, Without}, reflect::ReflectComponent, resource::Resource, system::{Commands, Query, Res}, world::{FromWorld, World}, }; -use bevy_math::{uvec4, AspectRatio, UVec2, UVec3, UVec4, Vec3Swizzles as _, Vec4}; +use bevy_math::{AspectRatio, UVec2, UVec3, UVec4, Vec3Swizzles as _, Vec4, uvec4}; use bevy_platform_support::collections::HashSet; -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; use bevy_render::{ + Extract, camera::Camera, render_resource::{ BindingResource, BufferBindingType, ShaderSize as _, ShaderType, StorageBuffer, @@ -23,12 +24,11 @@ use bevy_render::{ }, renderer::{RenderDevice, RenderQueue}, sync_world::RenderEntity, - Extract, }; use tracing::warn; -pub(crate) use crate::cluster::assign::assign_objects_to_clusters; use crate::MeshPipeline; +pub(crate) use crate::cluster::assign::assign_objects_to_clusters; pub(crate) mod assign; diff --git a/crates/bevy_pbr/src/components.rs b/crates/bevy_pbr/src/components.rs index d5418910eb37e..8557c5e9ede9e 100644 --- a/crates/bevy_pbr/src/components.rs +++ b/crates/bevy_pbr/src/components.rs @@ -1,8 +1,8 @@ use bevy_derive::{Deref, DerefMut}; use bevy_ecs::component::Component; -use bevy_ecs::entity::{hash_map::EntityHashMap, Entity}; +use bevy_ecs::entity::{Entity, hash_map::EntityHashMap}; use bevy_ecs::reflect::ReflectComponent; -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; use bevy_render::sync_world::MainEntity; /// Collection of mesh entities visible for 3D lighting. /// diff --git a/crates/bevy_pbr/src/decal/clustered.rs b/crates/bevy_pbr/src/decal/clustered.rs index 43edcd0bc34d5..f5a6d19ba235e 100644 --- a/crates/bevy_pbr/src/decal/clustered.rs +++ b/crates/bevy_pbr/src/decal/clustered.rs @@ -17,11 +17,11 @@ use core::{num::NonZero, ops::Deref}; use bevy_app::{App, Plugin}; -use bevy_asset::{load_internal_asset, weak_handle, AssetId, Handle}; +use bevy_asset::{AssetId, Handle, load_internal_asset, weak_handle}; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::{ - component::{require, Component}, - entity::{hash_map::EntityHashMap, Entity}, + component::{Component, require}, + entity::{Entity, hash_map::EntityHashMap}, prelude::ReflectComponent, query::With, resource::Resource, @@ -33,23 +33,23 @@ use bevy_math::Mat4; use bevy_platform_support::collections::HashMap; use bevy_reflect::Reflect; use bevy_render::{ + Extract, ExtractSchedule, Render, RenderApp, RenderSet, extract_component::{ExtractComponent, ExtractComponentPlugin}, render_asset::RenderAssets, render_resource::{ - binding_types, BindGroupLayoutEntryBuilder, Buffer, BufferUsages, RawBufferVec, Sampler, - SamplerBindingType, Shader, ShaderType, TextureSampleType, TextureView, + BindGroupLayoutEntryBuilder, Buffer, BufferUsages, RawBufferVec, Sampler, + SamplerBindingType, Shader, ShaderType, TextureSampleType, TextureView, binding_types, }, renderer::{RenderAdapter, RenderDevice, RenderQueue}, sync_world::RenderEntity, texture::{FallbackImage, GpuImage}, view::{self, ViewVisibility, Visibility, VisibilityClass}, - Extract, ExtractSchedule, Render, RenderApp, RenderSet, }; use bevy_transform::{components::GlobalTransform, prelude::Transform}; use bytemuck::{Pod, Zeroable}; use crate::{ - binding_arrays_are_usable, prepare_lights, GlobalClusterableObjectMeta, LightVisibilityClass, + GlobalClusterableObjectMeta, LightVisibilityClass, binding_arrays_are_usable, prepare_lights, }; /// The handle to the `clustered.wgsl` shader. diff --git a/crates/bevy_pbr/src/decal/forward.rs b/crates/bevy_pbr/src/decal/forward.rs index 7732f1d3a4ab3..a4103c7654c95 100644 --- a/crates/bevy_pbr/src/decal/forward.rs +++ b/crates/bevy_pbr/src/decal/forward.rs @@ -3,18 +3,18 @@ use crate::{ MaterialPlugin, StandardMaterial, }; use bevy_app::{App, Plugin}; -use bevy_asset::{load_internal_asset, weak_handle, Asset, Assets, Handle}; -use bevy_ecs::component::{require, Component}; -use bevy_math::{prelude::Rectangle, Quat, Vec2, Vec3}; +use bevy_asset::{Asset, Assets, Handle, load_internal_asset, weak_handle}; +use bevy_ecs::component::{Component, require}; +use bevy_math::{Quat, Vec2, Vec3, prelude::Rectangle}; use bevy_reflect::{Reflect, TypePath}; use bevy_render::{ + RenderDebugFlags, alpha::AlphaMode, mesh::{Mesh, Mesh3d, MeshBuilder, MeshVertexBufferLayoutRef, Meshable}, render_resource::{ AsBindGroup, CompareFunction, RenderPipelineDescriptor, Shader, SpecializedMeshPipelineError, }, - RenderDebugFlags, }; const FORWARD_DECAL_MESH_HANDLE: Handle = diff --git a/crates/bevy_pbr/src/deferred/mod.rs b/crates/bevy_pbr/src/deferred/mod.rs index c7d7e04636150..aa44f53d9d998 100644 --- a/crates/bevy_pbr/src/deferred/mod.rs +++ b/crates/bevy_pbr/src/deferred/mod.rs @@ -1,20 +1,20 @@ -use crate::{ - graph::NodePbr, irradiance_volume::IrradianceVolume, prelude::EnvironmentMapLight, - MeshPipeline, MeshViewBindGroup, RenderViewLightProbes, ScreenSpaceAmbientOcclusion, - ScreenSpaceReflectionsUniform, ViewEnvironmentMapUniformOffset, ViewLightProbesUniformOffset, - ViewScreenSpaceReflectionsUniformOffset, TONEMAPPING_LUT_SAMPLER_BINDING_INDEX, - TONEMAPPING_LUT_TEXTURE_BINDING_INDEX, -}; use crate::{ DistanceFog, MeshPipelineKey, ShadowFilteringMethod, ViewFogUniformOffset, ViewLightsUniformOffset, }; +use crate::{ + MeshPipeline, MeshViewBindGroup, RenderViewLightProbes, ScreenSpaceAmbientOcclusion, + ScreenSpaceReflectionsUniform, TONEMAPPING_LUT_SAMPLER_BINDING_INDEX, + TONEMAPPING_LUT_TEXTURE_BINDING_INDEX, ViewEnvironmentMapUniformOffset, + ViewLightProbesUniformOffset, ViewScreenSpaceReflectionsUniformOffset, graph::NodePbr, + irradiance_volume::IrradianceVolume, prelude::EnvironmentMapLight, +}; use bevy_app::prelude::*; -use bevy_asset::{load_internal_asset, weak_handle, Handle}; +use bevy_asset::{Handle, load_internal_asset, weak_handle}; use bevy_core_pipeline::{ core_3d::graph::{Core3d, Node3d}, deferred::{ - copy_lighting_id::DeferredLightingIdDepthTexture, DEFERRED_LIGHTING_PASS_ID_DEPTH_FORMAT, + DEFERRED_LIGHTING_PASS_ID_DEPTH_FORMAT, copy_lighting_id::DeferredLightingIdDepthTexture, }, prepass::{DeferredPrepass, DepthPrepass, MotionVectorPrepass, NormalPrepass}, tonemapping::{DebandDither, Tonemapping}, @@ -22,6 +22,7 @@ use bevy_core_pipeline::{ use bevy_ecs::{prelude::*, query::QueryItem}; use bevy_image::BevyDefault as _; use bevy_render::{ + Render, RenderApp, RenderSet, extract_component::{ ComponentUniforms, ExtractComponent, ExtractComponentPlugin, UniformComponentPlugin, }, @@ -29,7 +30,6 @@ use bevy_render::{ render_resource::{binding_types::uniform_buffer, *}, renderer::{RenderContext, RenderDevice}, view::{ExtractedView, ViewTarget, ViewUniformOffset}, - Render, RenderApp, RenderSet, }; pub struct DeferredPbrLightingPlugin; diff --git a/crates/bevy_pbr/src/extended_material.rs b/crates/bevy_pbr/src/extended_material.rs index 68690439030fc..05af20454c320 100644 --- a/crates/bevy_pbr/src/extended_material.rs +++ b/crates/bevy_pbr/src/extended_material.rs @@ -1,6 +1,6 @@ use bevy_asset::{Asset, Handle}; use bevy_ecs::system::SystemParamItem; -use bevy_reflect::{impl_type_path, Reflect}; +use bevy_reflect::{Reflect, impl_type_path}; use bevy_render::{ alpha::AlphaMode, mesh::MeshVertexBufferLayoutRef, diff --git a/crates/bevy_pbr/src/fog.rs b/crates/bevy_pbr/src/fog.rs index 831ec6928c424..17e175d942daa 100644 --- a/crates/bevy_pbr/src/fog.rs +++ b/crates/bevy_pbr/src/fog.rs @@ -1,7 +1,7 @@ use bevy_color::{Color, ColorToComponents, LinearRgba}; use bevy_ecs::prelude::*; -use bevy_math::{ops, Vec3}; -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_math::{Vec3, ops}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; use bevy_render::{extract_component::ExtractComponent, prelude::Camera}; /// Configures the “classic” computer graphics [distance fog](https://en.wikipedia.org/wiki/Distance_fog) effect, diff --git a/crates/bevy_pbr/src/lib.rs b/crates/bevy_pbr/src/lib.rs index 543a4665fc54d..abea389b7e019 100644 --- a/crates/bevy_pbr/src/lib.rs +++ b/crates/bevy_pbr/src/lib.rs @@ -74,8 +74,8 @@ pub mod prelude { #[doc(hidden)] pub use crate::{ fog::{DistanceFog, FogFalloff}, - light::{light_consts, AmbientLight, DirectionalLight, PointLight, SpotLight}, - light_probe::{environment_map::EnvironmentMapLight, LightProbe}, + light::{AmbientLight, DirectionalLight, PointLight, SpotLight, light_consts}, + light_probe::{LightProbe, environment_map::EnvironmentMapLight}, material::{Material, MaterialPlugin}, mesh_material::MeshMaterial3d, parallax::ParallaxMappingMethod, @@ -124,11 +124,12 @@ pub mod graph { use crate::{deferred::DeferredPbrLightingPlugin, graph::NodePbr}; use bevy_app::prelude::*; -use bevy_asset::{load_internal_asset, weak_handle, AssetApp, Assets, Handle}; +use bevy_asset::{AssetApp, Assets, Handle, load_internal_asset, weak_handle}; use bevy_core_pipeline::core_3d::graph::{Core3d, Node3d}; use bevy_ecs::prelude::*; use bevy_image::Image; use bevy_render::{ + ExtractSchedule, Render, RenderApp, RenderDebugFlags, RenderSet, alpha::AlphaMode, camera::{CameraUpdateSystem, Projection}, extract_component::ExtractComponentPlugin, @@ -139,7 +140,6 @@ use bevy_render::{ sync_component::SyncComponentPlugin, texture::GpuImage, view::VisibilitySystems, - ExtractSchedule, Render, RenderApp, RenderDebugFlags, RenderSet, }; use bevy_transform::TransformSystem; diff --git a/crates/bevy_pbr/src/light/mod.rs b/crates/bevy_pbr/src/light/mod.rs index 1c9dc61374a1e..1f62ee19885a3 100644 --- a/crates/bevy_pbr/src/light/mod.rs +++ b/crates/bevy_pbr/src/light/mod.rs @@ -4,7 +4,7 @@ use bevy_ecs::{ entity::{hash_map::EntityHashMap, hash_set::EntityHashSet}, prelude::*, }; -use bevy_math::{ops, Mat4, Vec3A, Vec4}; +use bevy_math::{Mat4, Vec3A, Vec4, ops}; use bevy_reflect::prelude::*; use bevy_render::{ camera::{Camera, CameraProjection, Projection}, diff --git a/crates/bevy_pbr/src/light_probe/environment_map.rs b/crates/bevy_pbr/src/light_probe/environment_map.rs index 8069f2acac752..9d2299c344ff4 100644 --- a/crates/bevy_pbr/src/light_probe/environment_map.rs +++ b/crates/bevy_pbr/src/light_probe/environment_map.rs @@ -44,20 +44,20 @@ //! //! [several pre-filtered environment maps]: https://github.com/KhronosGroup/glTF-Sample-Environments -use bevy_asset::{weak_handle, AssetId, Handle}; +use bevy_asset::{AssetId, Handle, weak_handle}; use bevy_ecs::{ component::Component, query::QueryItem, reflect::ReflectComponent, system::lifetimeless::Read, }; use bevy_image::Image; use bevy_math::Quat; -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; use bevy_render::{ extract_instances::ExtractInstance, render_asset::RenderAssets, render_resource::{ - binding_types::{self, uniform_buffer}, BindGroupLayoutEntryBuilder, Sampler, SamplerBindingType, Shader, ShaderStages, TextureSampleType, TextureView, + binding_types::{self, uniform_buffer}, }, renderer::{RenderAdapter, RenderDevice}, texture::{FallbackImage, GpuImage}, @@ -66,8 +66,8 @@ use bevy_render::{ use core::{num::NonZero, ops::Deref}; use crate::{ - add_cubemap_texture_view, binding_arrays_are_usable, EnvironmentMapUniform, - MAX_VIEW_LIGHT_PROBES, + EnvironmentMapUniform, MAX_VIEW_LIGHT_PROBES, add_cubemap_texture_view, + binding_arrays_are_usable, }; use super::{LightProbeComponent, RenderViewLightProbes}; diff --git a/crates/bevy_pbr/src/light_probe/irradiance_volume.rs b/crates/bevy_pbr/src/light_probe/irradiance_volume.rs index 799329e98284b..bf5c8e2409374 100644 --- a/crates/bevy_pbr/src/light_probe/irradiance_volume.rs +++ b/crates/bevy_pbr/src/light_probe/irradiance_volume.rs @@ -137,8 +137,8 @@ use bevy_image::Image; use bevy_render::{ render_asset::RenderAssets, render_resource::{ - binding_types, BindGroupLayoutEntryBuilder, Sampler, SamplerBindingType, Shader, - TextureSampleType, TextureView, + BindGroupLayoutEntryBuilder, Sampler, SamplerBindingType, Shader, TextureSampleType, + TextureView, binding_types, }, renderer::{RenderAdapter, RenderDevice}, texture::{FallbackImage, GpuImage}, @@ -146,12 +146,12 @@ use bevy_render::{ use bevy_utils::default; use core::{num::NonZero, ops::Deref}; -use bevy_asset::{weak_handle, AssetId, Handle}; -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_asset::{AssetId, Handle, weak_handle}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; use crate::{ - add_cubemap_texture_view, binding_arrays_are_usable, RenderViewLightProbes, - MAX_VIEW_LIGHT_PROBES, + MAX_VIEW_LIGHT_PROBES, RenderViewLightProbes, add_cubemap_texture_view, + binding_arrays_are_usable, }; use super::LightProbeComponent; diff --git a/crates/bevy_pbr/src/light_probe/mod.rs b/crates/bevy_pbr/src/light_probe/mod.rs index 3ef3e78db85f4..34870950711c5 100644 --- a/crates/bevy_pbr/src/light_probe/mod.rs +++ b/crates/bevy_pbr/src/light_probe/mod.rs @@ -1,11 +1,11 @@ //! Light probes for baked global illumination. use bevy_app::{App, Plugin}; -use bevy_asset::{load_internal_asset, weak_handle, AssetId, Handle}; +use bevy_asset::{AssetId, Handle, load_internal_asset, weak_handle}; use bevy_core_pipeline::core_3d::Camera3d; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::{ - component::{require, Component}, + component::{Component, require}, entity::Entity, query::With, reflect::ReflectComponent, @@ -16,8 +16,9 @@ use bevy_ecs::{ use bevy_image::Image; use bevy_math::{Affine3A, FloatOrd, Mat4, Vec3A, Vec4}; use bevy_platform_support::collections::HashMap; -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; use bevy_render::{ + Extract, ExtractSchedule, Render, RenderApp, RenderSet, extract_instances::ExtractInstancesPlugin, primitives::{Aabb, Frustum}, render_asset::RenderAssets, @@ -27,7 +28,6 @@ use bevy_render::{ sync_world::RenderEntity, texture::{FallbackImage, GpuImage}, view::{ExtractedView, Visibility}, - Extract, ExtractSchedule, Render, RenderApp, RenderSet, }; use bevy_transform::{components::Transform, prelude::GlobalTransform}; use tracing::error; @@ -37,7 +37,7 @@ use core::{hash::Hash, ops::Deref}; use crate::{ irradiance_volume::IRRADIANCE_VOLUME_SHADER_HANDLE, light_probe::environment_map::{ - EnvironmentMapIds, EnvironmentMapLight, ENVIRONMENT_MAP_SHADER_HANDLE, + ENVIRONMENT_MAP_SHADER_HANDLE, EnvironmentMapIds, EnvironmentMapLight, }, }; diff --git a/crates/bevy_pbr/src/lightmap/mod.rs b/crates/bevy_pbr/src/lightmap/mod.rs index afaa71d7926bd..dae7f322f434b 100644 --- a/crates/bevy_pbr/src/lightmap/mod.rs +++ b/crates/bevy_pbr/src/lightmap/mod.rs @@ -32,7 +32,7 @@ //! [`bevy-baked-gi`]: https://github.com/pcwalton/bevy-baked-gi use bevy_app::{App, Plugin}; -use bevy_asset::{load_internal_asset, weak_handle, AssetId, Handle}; +use bevy_asset::{AssetId, Handle, load_internal_asset, weak_handle}; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::{ component::Component, @@ -46,17 +46,17 @@ use bevy_ecs::{ world::{FromWorld, World}, }; use bevy_image::Image; -use bevy_math::{uvec2, vec4, Rect, UVec2}; +use bevy_math::{Rect, UVec2, uvec2, vec4}; use bevy_platform_support::collections::HashSet; -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; use bevy_render::{ + Extract, ExtractSchedule, RenderApp, render_asset::RenderAssets, render_resource::{Sampler, Shader, TextureView, WgpuSampler, WgpuTextureView}, renderer::RenderAdapter, sync_world::MainEntity, texture::{FallbackImage, GpuImage}, view::ViewVisibility, - Extract, ExtractSchedule, RenderApp, }; use bevy_render::{renderer::RenderDevice, sync_world::MainEntityHashMap}; use bevy_utils::default; @@ -64,7 +64,7 @@ use fixedbitset::FixedBitSet; use nonmax::{NonMaxU16, NonMaxU32}; use tracing::error; -use crate::{binding_arrays_are_usable, ExtractMeshesSet}; +use crate::{ExtractMeshesSet, binding_arrays_are_usable}; /// The ID of the lightmap shader. pub const LIGHTMAP_SHADER_HANDLE: Handle = diff --git a/crates/bevy_pbr/src/material.rs b/crates/bevy_pbr/src/material.rs index d91ff14633af9..7593a6f7c7535 100644 --- a/crates/bevy_pbr/src/material.rs +++ b/crates/bevy_pbr/src/material.rs @@ -3,8 +3,8 @@ use crate::material_bind_groups::{ }; #[cfg(feature = "meshlet")] use crate::meshlet::{ - prepare_material_meshlet_meshes_main_opaque_pass, queue_material_meshlet_meshes, - InstanceManager, + InstanceManager, prepare_material_meshlet_meshes_main_opaque_pass, + queue_material_meshlet_meshes, }; use crate::*; use bevy_asset::prelude::AssetChanged; @@ -25,17 +25,18 @@ use bevy_ecs::system::SystemChangeTick; use bevy_ecs::{ prelude::*, system::{ - lifetimeless::{SRes, SResMut}, SystemParamItem, + lifetimeless::{SRes, SResMut}, }, }; use bevy_platform_support::collections::{HashMap, HashSet}; use bevy_platform_support::hash::FixedHasher; -use bevy_reflect::std_traits::ReflectDefault; use bevy_reflect::Reflect; +use bevy_reflect::std_traits::ReflectDefault; use bevy_render::mesh::mark_3d_meshes_as_changed_if_their_assets_changed; use bevy_render::renderer::RenderQueue; use bevy_render::{ + Extract, batching::gpu_preprocessing::GpuPreprocessingSupport, extract_resource::ExtractResource, mesh::{Mesh3d, MeshVertexBufferLayoutRef, RenderMesh}, @@ -45,7 +46,6 @@ use bevy_render::{ renderer::RenderDevice, sync_world::MainEntity, view::{ExtractedView, Msaa, RenderVisibilityRanges, RetainedViewEntity, ViewVisibility}, - Extract, }; use bevy_render::{mesh::allocator::MeshAllocator, sync_world::MainEntityHashMap}; use bevy_render::{texture::FallbackImage, view::RenderVisibleEntities}; @@ -1381,14 +1381,9 @@ impl RenderAsset for PreparedMaterial { fn unload_asset( source_asset: AssetId, - ( - _, - _, - _, - bind_group_allocator, - render_material_bindings, - .., - ): &mut SystemParamItem, + (_, _, _, bind_group_allocator, render_material_bindings, ..): &mut SystemParamItem< + Self::Param, + >, ) { let Some(material_binding_id) = render_material_bindings.remove(&source_asset.untyped()) else { diff --git a/crates/bevy_pbr/src/material_bind_groups.rs b/crates/bevy_pbr/src/material_bind_groups.rs index ea152d2272646..13a9b34014917 100644 --- a/crates/bevy_pbr/src/material_bind_groups.rs +++ b/crates/bevy_pbr/src/material_bind_groups.rs @@ -12,7 +12,7 @@ use bevy_ecs::{ world::{FromWorld, World}, }; use bevy_platform_support::collections::{HashMap, HashSet}; -use bevy_reflect::{prelude::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, prelude::ReflectDefault}; use bevy_render::{ render_resource::{ BindGroup, BindGroupEntry, BindGroupLayout, BindingNumber, BindingResource, diff --git a/crates/bevy_pbr/src/mesh_material.rs b/crates/bevy_pbr/src/mesh_material.rs index c3f81943ecbcf..e5d9a6b3b683b 100644 --- a/crates/bevy_pbr/src/mesh_material.rs +++ b/crates/bevy_pbr/src/mesh_material.rs @@ -2,7 +2,7 @@ use crate::Material; use bevy_asset::{AsAssetId, AssetId, Handle}; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::{component::Component, reflect::ReflectComponent}; -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; use derive_more::derive::From; /// A [material](Material) used for rendering a [`Mesh3d`]. diff --git a/crates/bevy_pbr/src/meshlet/asset.rs b/crates/bevy_pbr/src/meshlet/asset.rs index c158650d1bd4c..324dc53189ec3 100644 --- a/crates/bevy_pbr/src/meshlet/asset.rs +++ b/crates/bevy_pbr/src/meshlet/asset.rs @@ -1,8 +1,8 @@ use alloc::sync::Arc; use bevy_asset::{ + Asset, AssetLoader, AsyncReadExt, AsyncWriteExt, LoadContext, io::{Reader, Writer}, saver::{AssetSaver, SavedAsset}, - Asset, AssetLoader, AsyncReadExt, AsyncWriteExt, LoadContext, }; use bevy_math::{Vec2, Vec3}; use bevy_reflect::TypePath; diff --git a/crates/bevy_pbr/src/meshlet/from_mesh.rs b/crates/bevy_pbr/src/meshlet/from_mesh.rs index 7b959eef46887..dcf867ea32a4e 100644 --- a/crates/bevy_pbr/src/meshlet/from_mesh.rs +++ b/crates/bevy_pbr/src/meshlet/from_mesh.rs @@ -2,7 +2,7 @@ use super::asset::{ Meshlet, MeshletBoundingSphere, MeshletBoundingSpheres, MeshletMesh, MeshletSimplificationError, }; use alloc::borrow::Cow; -use bevy_math::{ops::log2, IVec3, Vec2, Vec3, Vec3Swizzles}; +use bevy_math::{IVec3, Vec2, Vec3, Vec3Swizzles, ops::log2}; use bevy_platform_support::collections::HashMap; use bevy_render::{ mesh::{Indices, Mesh}, @@ -13,10 +13,10 @@ use core::{iter, ops::Range}; use half::f16; use itertools::Itertools; use meshopt::{ - build_meshlets, ffi::meshopt_Meshlet, generate_vertex_remap_multi, - simplify_with_attributes_and_locks, Meshlets, SimplifyOptions, VertexDataAdapter, VertexStream, + Meshlets, SimplifyOptions, VertexDataAdapter, VertexStream, build_meshlets, + ffi::meshopt_Meshlet, generate_vertex_remap_multi, simplify_with_attributes_and_locks, }; -use metis::{option::Opt, Graph}; +use metis::{Graph, option::Opt}; use smallvec::SmallVec; use thiserror::Error; @@ -705,11 +705,7 @@ fn octahedral_encode(v: Vec3) -> Vec2 { if n.x >= 0.0 { 1.0 } else { -1.0 }, if n.y >= 0.0 { 1.0 } else { -1.0 }, ); - if n.z >= 0.0 { - n.xy() - } else { - octahedral_wrap - } + if n.z >= 0.0 { n.xy() } else { octahedral_wrap } } // https://www.w3.org/TR/WGSL/#pack2x16snorm-builtin diff --git a/crates/bevy_pbr/src/meshlet/instance_manager.rs b/crates/bevy_pbr/src/meshlet/instance_manager.rs index 26f6432a1fdf7..5fea0ffdee132 100644 --- a/crates/bevy_pbr/src/meshlet/instance_manager.rs +++ b/crates/bevy_pbr/src/meshlet/instance_manager.rs @@ -1,4 +1,4 @@ -use super::{meshlet_mesh_manager::MeshletMeshManager, MeshletMesh, MeshletMesh3d}; +use super::{MeshletMesh, MeshletMesh3d, meshlet_mesh_manager::MeshletMeshManager}; use crate::{ Material, MeshFlags, MeshTransforms, MeshUniform, NotShadowCaster, NotShadowReceiver, PreviousGlobalTransform, RenderMaterialBindings, RenderMaterialInstances, @@ -6,7 +6,7 @@ use crate::{ }; use bevy_asset::{AssetEvent, AssetServer, Assets, UntypedAssetId}; use bevy_ecs::{ - entity::{hash_map::EntityHashMap, Entities, Entity}, + entity::{Entities, Entity, hash_map::EntityHashMap}, event::EventReader, query::Has, resource::Resource, @@ -14,7 +14,7 @@ use bevy_ecs::{ }; use bevy_platform_support::collections::{HashMap, HashSet}; use bevy_render::{ - render_resource::StorageBuffer, sync_world::MainEntity, view::RenderLayers, MainWorld, + MainWorld, render_resource::StorageBuffer, sync_world::MainEntity, view::RenderLayers, }; use bevy_transform::components::GlobalTransform; use core::ops::{DerefMut, Range}; diff --git a/crates/bevy_pbr/src/meshlet/material_pipeline_prepare.rs b/crates/bevy_pbr/src/meshlet/material_pipeline_prepare.rs index 2351c7756d9c2..55f5d0d5e67dc 100644 --- a/crates/bevy_pbr/src/meshlet/material_pipeline_prepare.rs +++ b/crates/bevy_pbr/src/meshlet/material_pipeline_prepare.rs @@ -1,6 +1,6 @@ use super::{ - instance_manager::InstanceManager, resource_manager::ResourceManager, - MESHLET_MESH_MATERIAL_SHADER_HANDLE, + MESHLET_MESH_MATERIAL_SHADER_HANDLE, instance_manager::InstanceManager, + resource_manager::ResourceManager, }; use crate::{ environment_map::EnvironmentMapLight, irradiance_volume::IrradianceVolume, diff --git a/crates/bevy_pbr/src/meshlet/material_shade_nodes.rs b/crates/bevy_pbr/src/meshlet/material_shade_nodes.rs index 9c2d432d8856a..1cf09f54ab9bc 100644 --- a/crates/bevy_pbr/src/meshlet/material_shade_nodes.rs +++ b/crates/bevy_pbr/src/meshlet/material_shade_nodes.rs @@ -1,10 +1,10 @@ use super::{ + InstanceManager, material_pipeline_prepare::{ MeshletViewMaterialsDeferredGBufferPrepass, MeshletViewMaterialsMainOpaquePass, MeshletViewMaterialsPrepass, }, resource_manager::{MeshletViewBindGroups, MeshletViewResources}, - InstanceManager, }; use crate::{ MeshViewBindGroup, PrepassViewBindGroup, ViewEnvironmentMapUniformOffset, ViewFogUniformOffset, diff --git a/crates/bevy_pbr/src/meshlet/meshlet_mesh_manager.rs b/crates/bevy_pbr/src/meshlet/meshlet_mesh_manager.rs index 2bc686fe43cc7..81d1af032bcf6 100644 --- a/crates/bevy_pbr/src/meshlet/meshlet_mesh_manager.rs +++ b/crates/bevy_pbr/src/meshlet/meshlet_mesh_manager.rs @@ -1,7 +1,7 @@ use super::{ + MeshletMesh, asset::{Meshlet, MeshletBoundingSpheres, MeshletSimplificationError}, persistent_buffer::PersistentGpuBuffer, - MeshletMesh, }; use alloc::sync::Arc; use bevy_asset::{AssetId, Assets}; @@ -116,7 +116,15 @@ impl MeshletMeshManager { pub fn remove(&mut self, asset_id: &AssetId) { if let Some( - [vertex_positions_slice, vertex_normals_slice, vertex_uvs_slice, indices_slice, meshlets_slice, meshlet_bounding_spheres_slice, meshlet_simplification_errors_slice], + [ + vertex_positions_slice, + vertex_normals_slice, + vertex_uvs_slice, + indices_slice, + meshlets_slice, + meshlet_bounding_spheres_slice, + meshlet_simplification_errors_slice, + ], ) = self.meshlet_mesh_slices.remove(asset_id) { self.vertex_positions diff --git a/crates/bevy_pbr/src/meshlet/mod.rs b/crates/bevy_pbr/src/meshlet/mod.rs index 4057f29e39a3c..33dbb6762d11d 100644 --- a/crates/bevy_pbr/src/meshlet/mod.rs +++ b/crates/bevy_pbr/src/meshlet/mod.rs @@ -26,18 +26,18 @@ pub mod graph { } pub(crate) use self::{ - instance_manager::{queue_material_meshlet_meshes, InstanceManager}, + instance_manager::{InstanceManager, queue_material_meshlet_meshes}, material_pipeline_prepare::{ prepare_material_meshlet_meshes_main_opaque_pass, prepare_material_meshlet_meshes_prepass, }, }; pub use self::asset::{ - MeshletMesh, MeshletMeshLoader, MeshletMeshSaver, MESHLET_MESH_ASSET_VERSION, + MESHLET_MESH_ASSET_VERSION, MeshletMesh, MeshletMeshLoader, MeshletMeshSaver, }; #[cfg(feature = "meshlet_processor")] pub use self::from_mesh::{ - MeshToMeshletMeshConversionError, MESHLET_DEFAULT_VERTEX_POSITION_QUANTIZATION_FACTOR, + MESHLET_DEFAULT_VERTEX_POSITION_QUANTIZATION_FACTOR, MeshToMeshletMeshConversionError, }; use self::{ graph::NodeMeshlet, @@ -49,37 +49,37 @@ use self::{ material_shade_nodes::{ MeshletDeferredGBufferPrepassNode, MeshletMainOpaquePass3dNode, MeshletPrepassNode, }, - meshlet_mesh_manager::{perform_pending_meshlet_mesh_writes, MeshletMeshManager}, + meshlet_mesh_manager::{MeshletMeshManager, perform_pending_meshlet_mesh_writes}, pipelines::*, resource_manager::{ - prepare_meshlet_per_frame_resources, prepare_meshlet_view_bind_groups, ResourceManager, + ResourceManager, prepare_meshlet_per_frame_resources, prepare_meshlet_view_bind_groups, }, visibility_buffer_raster_node::MeshletVisibilityBufferRasterPassNode, }; -use crate::{graph::NodePbr, PreviousGlobalTransform}; +use crate::{PreviousGlobalTransform, graph::NodePbr}; use bevy_app::{App, Plugin}; -use bevy_asset::{load_internal_asset, weak_handle, AssetApp, AssetId, Handle}; +use bevy_asset::{AssetApp, AssetId, Handle, load_internal_asset, weak_handle}; use bevy_core_pipeline::{ core_3d::graph::{Core3d, Node3d}, prepass::{DeferredPrepass, MotionVectorPrepass, NormalPrepass}, }; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::{ - component::{require, Component}, + component::{Component, require}, entity::Entity, query::Has, reflect::ReflectComponent, schedule::IntoSystemConfigs, system::{Commands, Query}, }; -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; use bevy_render::{ + ExtractSchedule, Render, RenderApp, RenderSet, render_graph::{RenderGraphApp, ViewNodeRunner}, render_resource::Shader, renderer::RenderDevice, settings::WgpuFeatures, - view::{self, prepare_view_targets, Msaa, Visibility, VisibilityClass}, - ExtractSchedule, Render, RenderApp, RenderSet, + view::{self, Msaa, Visibility, VisibilityClass, prepare_view_targets}, }; use bevy_transform::components::Transform; use derive_more::From; @@ -319,7 +319,9 @@ fn configure_meshlet_views( ) { for (entity, msaa, normal_prepass, motion_vector_prepass, deferred_prepass) in &mut views_3d { if *msaa != Msaa::Off { - error!("MeshletPlugin can't be used with MSAA. Add Msaa::Off to your camera to use this plugin."); + error!( + "MeshletPlugin can't be used with MSAA. Add Msaa::Off to your camera to use this plugin." + ); std::process::exit(1); } diff --git a/crates/bevy_pbr/src/meshlet/persistent_buffer.rs b/crates/bevy_pbr/src/meshlet/persistent_buffer.rs index 85dec457f9808..63f29fd528926 100644 --- a/crates/bevy_pbr/src/meshlet/persistent_buffer.rs +++ b/crates/bevy_pbr/src/meshlet/persistent_buffer.rs @@ -1,7 +1,7 @@ use bevy_render::{ render_resource::{ BindingResource, Buffer, BufferAddress, BufferDescriptor, BufferUsages, - CommandEncoderDescriptor, COPY_BUFFER_ALIGNMENT, + COPY_BUFFER_ALIGNMENT, CommandEncoderDescriptor, }, renderer::{RenderDevice, RenderQueue}, }; diff --git a/crates/bevy_pbr/src/meshlet/pipelines.rs b/crates/bevy_pbr/src/meshlet/pipelines.rs index c25d896b8a385..8d08b356340d7 100644 --- a/crates/bevy_pbr/src/meshlet/pipelines.rs +++ b/crates/bevy_pbr/src/meshlet/pipelines.rs @@ -1,5 +1,5 @@ use super::resource_manager::ResourceManager; -use bevy_asset::{weak_handle, Handle}; +use bevy_asset::{Handle, weak_handle}; use bevy_core_pipeline::{ core_3d::CORE_3D_DEPTH_FORMAT, experimental::mip_generation::DOWNSAMPLE_DEPTH_SHADER_HANDLE, fullscreen_vertex_shader::fullscreen_shader_vertex_state, diff --git a/crates/bevy_pbr/src/meshlet/resource_manager.rs b/crates/bevy_pbr/src/meshlet/resource_manager.rs index 1d3828b95e184..85654a5af44fe 100644 --- a/crates/bevy_pbr/src/meshlet/resource_manager.rs +++ b/crates/bevy_pbr/src/meshlet/resource_manager.rs @@ -8,7 +8,7 @@ use bevy_core_pipeline::{ }; use bevy_ecs::{ component::Component, - entity::{hash_map::EntityHashMap, Entity}, + entity::{Entity, hash_map::EntityHashMap}, query::AnyOf, resource::Resource, system::{Commands, Query, Res, ResMut}, diff --git a/crates/bevy_pbr/src/meshlet/visibility_buffer_raster_node.rs b/crates/bevy_pbr/src/meshlet/visibility_buffer_raster_node.rs index 20054d2d2f53a..ace14f2df5df7 100644 --- a/crates/bevy_pbr/src/meshlet/visibility_buffer_raster_node.rs +++ b/crates/bevy_pbr/src/meshlet/visibility_buffer_raster_node.rs @@ -9,7 +9,7 @@ use bevy_ecs::{ query::QueryState, world::{FromWorld, World}, }; -use bevy_math::{ops, UVec2}; +use bevy_math::{UVec2, ops}; use bevy_render::{ camera::ExtractedCamera, render_graph::{Node, NodeRunError, RenderGraphContext}, diff --git a/crates/bevy_pbr/src/pbr_material.rs b/crates/bevy_pbr/src/pbr_material.rs index 44d1b960dff52..543157f347149 100644 --- a/crates/bevy_pbr/src/pbr_material.rs +++ b/crates/bevy_pbr/src/pbr_material.rs @@ -1,7 +1,7 @@ use bevy_asset::Asset; use bevy_color::{Alpha, ColorToComponents}; use bevy_math::{Affine2, Affine3, Mat2, Mat3, Vec2, Vec3, Vec4}; -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; use bevy_render::{ mesh::MeshVertexBufferLayoutRef, render_asset::RenderAssets, render_resource::*, }; diff --git a/crates/bevy_pbr/src/prepass/mod.rs b/crates/bevy_pbr/src/prepass/mod.rs index 9b3420cbc20b5..5288588adc3be 100644 --- a/crates/bevy_pbr/src/prepass/mod.rs +++ b/crates/bevy_pbr/src/prepass/mod.rs @@ -1,41 +1,42 @@ mod prepass_bindings; use crate::{ + DrawMesh, EntitySpecializationTicks, Material, MaterialPipeline, MaterialPipelineKey, + MeshLayouts, MeshPipeline, MeshPipelineKey, OpaqueRendererMethod, PreparedMaterial, + RenderLightmaps, RenderMaterialInstances, RenderMeshInstanceFlags, RenderMeshInstances, + RenderPhaseType, SetMaterialBindGroup, SetMeshBindGroup, ShadowView, StandardMaterial, alpha_mode_pipeline_key, binding_arrays_are_usable, buffer_layout, collect_meshes_for_gpu_building, material_bind_groups::MaterialBindGroupAllocator, - queue_material_meshes, setup_morph_and_skinning_defs, skin, DrawMesh, - EntitySpecializationTicks, Material, MaterialPipeline, MaterialPipelineKey, MeshLayouts, - MeshPipeline, MeshPipelineKey, OpaqueRendererMethod, PreparedMaterial, RenderLightmaps, - RenderMaterialInstances, RenderMeshInstanceFlags, RenderMeshInstances, RenderPhaseType, - SetMaterialBindGroup, SetMeshBindGroup, ShadowView, StandardMaterial, + queue_material_meshes, setup_morph_and_skinning_defs, skin, }; use bevy_app::{App, Plugin, PreUpdate}; use bevy_render::{ + ExtractSchedule, Render, RenderApp, RenderDebugFlags, RenderSet, alpha::AlphaMode, batching::gpu_preprocessing::GpuPreprocessingSupport, - mesh::{allocator::MeshAllocator, Mesh3d, MeshVertexBufferLayoutRef, RenderMesh}, + mesh::{Mesh3d, MeshVertexBufferLayoutRef, RenderMesh, allocator::MeshAllocator}, render_asset::prepare_assets, render_resource::binding_types::uniform_buffer, renderer::RenderAdapter, sync_world::RenderEntity, view::{RenderVisibilityRanges, RetainedViewEntity, VISIBILITY_RANGES_STORAGE_BUFFER_COUNT}, - ExtractSchedule, Render, RenderApp, RenderDebugFlags, RenderSet, }; pub use prepass_bindings::*; -use bevy_asset::{load_internal_asset, weak_handle, AssetServer, Handle}; +use bevy_asset::{AssetServer, Handle, load_internal_asset, weak_handle}; use bevy_core_pipeline::{ core_3d::CORE_3D_DEPTH_FORMAT, deferred::*, prelude::Camera3d, prepass::*, }; use bevy_ecs::{ prelude::*, system::{ - lifetimeless::{Read, SRes}, SystemParamItem, + lifetimeless::{Read, SRes}, }, }; use bevy_math::{Affine3A, Vec4}; use bevy_render::{ + Extract, globals::{GlobalsBuffer, GlobalsUniform}, prelude::{Camera, Mesh}, render_asset::RenderAssets, @@ -43,24 +44,23 @@ use bevy_render::{ render_resource::*, renderer::{RenderDevice, RenderQueue}, view::{ExtractedView, Msaa, ViewUniform, ViewUniformOffset, ViewUniforms}, - Extract, }; use bevy_transform::prelude::GlobalTransform; use tracing::{error, warn}; #[cfg(feature = "meshlet")] use crate::meshlet::{ - prepare_material_meshlet_meshes_prepass, queue_material_meshlet_meshes, InstanceManager, - MeshletMesh3d, + InstanceManager, MeshletMesh3d, prepare_material_meshlet_meshes_prepass, + queue_material_meshlet_meshes, }; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::component::Tick; use bevy_ecs::system::SystemChangeTick; use bevy_platform_support::collections::HashMap; +use bevy_render::RenderSet::{PrepareAssets, PrepareResources}; use bevy_render::sync_world::MainEntityHashMap; use bevy_render::view::RenderVisibleEntities; -use bevy_render::RenderSet::{PrepareAssets, PrepareResources}; use core::{hash::Hash, marker::PhantomData}; pub const PREPASS_SHADER_HANDLE: Handle = diff --git a/crates/bevy_pbr/src/prepass/prepass_bindings.rs b/crates/bevy_pbr/src/prepass/prepass_bindings.rs index 3c66625ed8254..8fdb369b0a85e 100644 --- a/crates/bevy_pbr/src/prepass/prepass_bindings.rs +++ b/crates/bevy_pbr/src/prepass/prepass_bindings.rs @@ -1,10 +1,10 @@ use bevy_core_pipeline::prepass::ViewPrepassTextures; use bevy_render::render_resource::{ + BindGroupLayoutEntryBuilder, TextureAspect, TextureSampleType, TextureView, + TextureViewDescriptor, binding_types::{ texture_2d, texture_2d_multisampled, texture_depth_2d, texture_depth_2d_multisampled, }, - BindGroupLayoutEntryBuilder, TextureAspect, TextureSampleType, TextureView, - TextureViewDescriptor, }; use bevy_utils::default; diff --git a/crates/bevy_pbr/src/render/fog.rs b/crates/bevy_pbr/src/render/fog.rs index 9394380f7186d..855537bf9705c 100644 --- a/crates/bevy_pbr/src/render/fog.rs +++ b/crates/bevy_pbr/src/render/fog.rs @@ -1,14 +1,14 @@ use bevy_app::{App, Plugin}; -use bevy_asset::{load_internal_asset, weak_handle, Handle}; +use bevy_asset::{Handle, load_internal_asset, weak_handle}; use bevy_color::{ColorToComponents, LinearRgba}; use bevy_ecs::prelude::*; use bevy_math::{Vec3, Vec4}; use bevy_render::{ + Render, RenderApp, RenderSet, extract_component::ExtractComponentPlugin, render_resource::{DynamicUniformBuffer, Shader, ShaderType}, renderer::{RenderDevice, RenderQueue}, view::ExtractedView, - Render, RenderApp, RenderSet, }; use crate::{DistanceFog, FogFalloff}; diff --git a/crates/bevy_pbr/src/render/gpu_preprocess.rs b/crates/bevy_pbr/src/render/gpu_preprocess.rs index e6f8addeed551..ea7be47b02b77 100644 --- a/crates/bevy_pbr/src/render/gpu_preprocess.rs +++ b/crates/bevy_pbr/src/render/gpu_preprocess.rs @@ -9,7 +9,7 @@ use core::num::{NonZero, NonZeroU64}; use bevy_app::{App, Plugin}; -use bevy_asset::{load_internal_asset, weak_handle, Handle}; +use bevy_asset::{Handle, load_internal_asset, weak_handle}; use bevy_core_pipeline::{ core_3d::graph::{Core3d, Node3d}, experimental::mip_generation::ViewDepthPyramid, @@ -23,13 +23,14 @@ use bevy_ecs::{ query::{Has, Or, QueryState, With, Without}, resource::Resource, schedule::IntoSystemConfigs as _, - system::{lifetimeless::Read, Commands, Query, Res, ResMut}, + system::{Commands, Query, Res, ResMut, lifetimeless::Read}, world::{FromWorld, World}, }; use bevy_render::batching::gpu_preprocessing::{ IndirectParametersGpuMetadata, UntypedPhaseIndirectParametersBuffers, }; use bevy_render::{ + Render, RenderApp, RenderSet, batching::gpu_preprocessing::{ BatchedInstanceBuffers, GpuOcclusionCullingWorkItemBuffers, GpuPreprocessingSupport, IndirectBatchSet, IndirectParametersBuffers, IndirectParametersCpuMetadata, @@ -40,25 +41,24 @@ use bevy_render::{ experimental::occlusion_culling::OcclusionCulling, render_graph::{Node, NodeRunError, RenderGraphApp, RenderGraphContext}, render_resource::{ - binding_types::{storage_buffer, storage_buffer_read_only, texture_2d, uniform_buffer}, BindGroup, BindGroupEntries, BindGroupLayout, BindingResource, Buffer, BufferBinding, CachedComputePipelineId, ComputePassDescriptor, ComputePipelineDescriptor, DynamicBindGroupLayoutEntries, PipelineCache, PushConstantRange, RawBufferVec, Shader, ShaderStages, ShaderType, SpecializedComputePipeline, SpecializedComputePipelines, TextureSampleType, UninitBufferVec, + binding_types::{storage_buffer, storage_buffer_read_only, texture_2d, uniform_buffer}, }, renderer::{RenderContext, RenderDevice, RenderQueue}, settings::WgpuFeatures, view::{ExtractedView, NoIndirectDrawing, ViewUniform, ViewUniformOffset, ViewUniforms}, - Render, RenderApp, RenderSet, }; use bevy_utils::TypeIdMap; use bitflags::bitflags; -use smallvec::{smallvec, SmallVec}; +use smallvec::{SmallVec, smallvec}; use tracing::warn; use crate::{ - graph::NodePbr, MeshCullingData, MeshCullingDataBuffer, MeshInputUniform, MeshUniform, + MeshCullingData, MeshCullingDataBuffer, MeshInputUniform, MeshUniform, graph::NodePbr, }; use super::{ShadowView, ViewLightEntities}; diff --git a/crates/bevy_pbr/src/render/light.rs b/crates/bevy_pbr/src/render/light.rs index 5dc225d4662bc..1b1c3ce0849d0 100644 --- a/crates/bevy_pbr/src/render/light.rs +++ b/crates/bevy_pbr/src/render/light.rs @@ -3,7 +3,7 @@ use crate::material_bind_groups::MaterialBindGroupAllocator; use crate::*; use bevy_asset::UntypedAssetId; use bevy_color::ColorToComponents; -use bevy_core_pipeline::core_3d::{Camera3d, CORE_3D_DEPTH_FORMAT}; +use bevy_core_pipeline::core_3d::{CORE_3D_DEPTH_FORMAT, Camera3d}; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::component::Tick; use bevy_ecs::system::SystemChangeTick; @@ -12,7 +12,7 @@ use bevy_ecs::{ prelude::*, system::lifetimeless::Read, }; -use bevy_math::{ops, Mat4, UVec4, Vec2, Vec3, Vec3Swizzles, Vec4, Vec4Swizzles}; +use bevy_math::{Mat4, UVec4, Vec2, Vec3, Vec3Swizzles, Vec4, Vec4Swizzles, ops}; use bevy_platform_support::collections::{HashMap, HashSet}; use bevy_platform_support::hash::FixedHasher; use bevy_render::experimental::occlusion_culling::{ @@ -20,12 +20,7 @@ use bevy_render::experimental::occlusion_culling::{ }; use bevy_render::sync_world::MainEntityHashMap; use bevy_render::{ - batching::gpu_preprocessing::{GpuPreprocessingMode, GpuPreprocessingSupport}, - camera::SortedCameras, - mesh::allocator::MeshAllocator, - view::{NoIndirectDrawing, RetainedViewEntity}, -}; -use bevy_render::{ + Extract, diagnostic::RecordDiagnostics, mesh::RenderMesh, primitives::{CascadesFrusta, CubemapFrusta, Frustum, HalfSpace}, @@ -36,7 +31,12 @@ use bevy_render::{ renderer::{RenderContext, RenderDevice, RenderQueue}, texture::*, view::{ExtractedView, RenderLayers, ViewVisibility}, - Extract, +}; +use bevy_render::{ + batching::gpu_preprocessing::{GpuPreprocessingMode, GpuPreprocessingSupport}, + camera::SortedCameras, + mesh::allocator::MeshAllocator, + view::{NoIndirectDrawing, RetainedViewEntity}, }; use bevy_render::{ mesh::allocator::SlabId, diff --git a/crates/bevy_pbr/src/render/mesh.rs b/crates/bevy_pbr/src/render/mesh.rs index e9e21a6a66f36..c98ac9668a00b 100644 --- a/crates/bevy_pbr/src/render/mesh.rs +++ b/crates/bevy_pbr/src/render/mesh.rs @@ -1,10 +1,10 @@ use crate::material_bind_groups::{MaterialBindGroupIndex, MaterialBindGroupSlot}; use allocator::MeshAllocator; -use bevy_asset::{load_internal_asset, AssetId, UntypedAssetId}; +use bevy_asset::{AssetId, UntypedAssetId, load_internal_asset}; use bevy_core_pipeline::{ - core_3d::{AlphaMask3d, Opaque3d, Transmissive3d, Transparent3d, CORE_3D_DEPTH_FORMAT}, + core_3d::{AlphaMask3d, CORE_3D_DEPTH_FORMAT, Opaque3d, Transmissive3d, Transparent3d}, deferred::{AlphaMask3dDeferred, Opaque3dDeferred}, - oit::{prepare_oit_buffers, OrderIndependentTransparencySettingsOffset}, + oit::{OrderIndependentTransparencySettingsOffset, prepare_oit_buffers}, prepass::MotionVectorPrepass, }; use bevy_derive::{Deref, DerefMut}; @@ -12,19 +12,21 @@ use bevy_diagnostic::FrameCount; use bevy_ecs::{ prelude::*, query::ROQueryItem, - system::{lifetimeless::*, SystemParamItem, SystemState}, + system::{SystemParamItem, SystemState, lifetimeless::*}, }; use bevy_image::{BevyDefault, ImageSampler, TextureFormatPixelInfo}; use bevy_math::{Affine3, Rect, UVec2, Vec3, Vec4}; -use bevy_platform_support::collections::{hash_map::Entry, HashMap}; +use bevy_platform_support::collections::{HashMap, hash_map::Entry}; use bevy_render::{ + Extract, batching::{ + GetBatchData, GetFullBatchData, NoAutomaticBatching, gpu_preprocessing::{ self, GpuPreprocessingSupport, IndirectBatchSet, IndirectParametersBuffers, IndirectParametersCpuMetadata, IndirectParametersIndexed, IndirectParametersNonIndexed, InstanceInputUniformBuffer, UntypedPhaseIndirectParametersBuffers, }, - no_gpu_preprocessing, GetBatchData, GetFullBatchData, NoAutomaticBatching, + no_gpu_preprocessing, }, camera::Camera, mesh::{skinning::SkinnedMesh, *}, @@ -41,10 +43,9 @@ use bevy_render::{ self, NoFrustumCulling, NoIndirectDrawing, RenderVisibilityRanges, RetainedViewEntity, ViewTarget, ViewUniformOffset, ViewVisibility, VisibilityRange, }, - Extract, }; use bevy_transform::components::GlobalTransform; -use bevy_utils::{default, Parallel, TypeIdMap}; +use bevy_utils::{Parallel, TypeIdMap, default}; use core::any::TypeId; use core::mem::size_of; use material_bind_groups::MaterialBindingId; @@ -57,8 +58,8 @@ use crate::irradiance_volume::IrradianceVolume; use crate::{ render::{ morph::{ - extract_morphs, no_automatic_morph_batching, prepare_morphs, MorphIndices, - MorphUniforms, + MorphIndices, MorphUniforms, extract_morphs, no_automatic_morph_batching, + prepare_morphs, }, skin::no_automatic_skin_batching, }, @@ -70,14 +71,14 @@ use bevy_core_pipeline::prepass::{DeferredPrepass, DepthPrepass, NormalPrepass}; use bevy_core_pipeline::tonemapping::{DebandDither, Tonemapping}; use bevy_ecs::component::Tick; use bevy_ecs::system::SystemChangeTick; +use bevy_render::RenderSet::PrepareAssets; use bevy_render::camera::TemporalJitter; use bevy_render::prelude::Msaa; use bevy_render::sync_world::{MainEntity, MainEntityHashMap}; use bevy_render::view::ExtractedView; -use bevy_render::RenderSet::PrepareAssets; use bytemuck::{Pod, Zeroable}; use nonmax::{NonMaxU16, NonMaxU32}; -use smallvec::{smallvec, SmallVec}; +use smallvec::{SmallVec, smallvec}; use static_assertions::const_assert_eq; /// Provides support for rendering 3D meshes. diff --git a/crates/bevy_pbr/src/render/mesh_bindings.rs b/crates/bevy_pbr/src/render/mesh_bindings.rs index 51b28389dcd0c..0e3acd2816a94 100644 --- a/crates/bevy_pbr/src/render/mesh_bindings.rs +++ b/crates/bevy_pbr/src/render/mesh_bindings.rs @@ -7,7 +7,7 @@ use bevy_render::{ renderer::{RenderAdapter, RenderDevice}, }; -use crate::{binding_arrays_are_usable, render::skin::MAX_JOINTS, LightmapSlab}; +use crate::{LightmapSlab, binding_arrays_are_usable, render::skin::MAX_JOINTS}; const MORPH_WEIGHT_SIZE: usize = size_of::(); @@ -26,15 +26,15 @@ mod layout_entry { use core::num::NonZeroU32; use super::{JOINT_BUFFER_SIZE, MORPH_BUFFER_SIZE}; - use crate::{render::skin, MeshUniform, LIGHTMAPS_PER_SLAB}; + use crate::{LIGHTMAPS_PER_SLAB, MeshUniform, render::skin}; use bevy_render::{ render_resource::{ + BindGroupLayoutEntryBuilder, BufferSize, GpuArrayBuffer, SamplerBindingType, + ShaderStages, TextureSampleType, binding_types::{ sampler, storage_buffer_read_only_sized, texture_2d, texture_3d, uniform_buffer_sized, }, - BindGroupLayoutEntryBuilder, BufferSize, GpuArrayBuffer, SamplerBindingType, - ShaderStages, TextureSampleType, }, renderer::RenderDevice, }; diff --git a/crates/bevy_pbr/src/render/mesh_view_bindings.rs b/crates/bevy_pbr/src/render/mesh_view_bindings.rs index 796ae096c2e26..4adf9feb7688f 100644 --- a/crates/bevy_pbr/src/render/mesh_view_bindings.rs +++ b/crates/bevy_pbr/src/render/mesh_view_bindings.rs @@ -4,7 +4,7 @@ use bevy_core_pipeline::{ oit::{OitBuffers, OrderIndependentTransparencySettings}, prepass::ViewPrepassTextures, tonemapping::{ - get_lut_bind_group_layout_entries, get_lut_bindings, Tonemapping, TonemappingLuts, + Tonemapping, TonemappingLuts, get_lut_bind_group_layout_entries, get_lut_bindings, }, }; use bevy_derive::{Deref, DerefMut}; @@ -25,14 +25,19 @@ use bevy_render::{ renderer::{RenderAdapter, RenderDevice}, texture::{FallbackImage, FallbackImageMsaa, FallbackImageZero, GpuImage}, view::{ - Msaa, RenderVisibilityRanges, ViewUniform, ViewUniforms, - VISIBILITY_RANGES_STORAGE_BUFFER_COUNT, + Msaa, RenderVisibilityRanges, VISIBILITY_RANGES_STORAGE_BUFFER_COUNT, ViewUniform, + ViewUniforms, }, }; use core::{array, num::NonZero}; use environment_map::EnvironmentMapLight; use crate::{ + CLUSTERED_FORWARD_STORAGE_BUFFER_COUNT, EnvironmentMapUniformBuffer, FogMeta, + GlobalClusterableObjectMeta, GpuClusterableObjects, GpuFog, GpuLights, LightMeta, + LightProbesBuffer, LightProbesUniform, MeshPipeline, MeshPipelineKey, RenderViewLightProbes, + ScreenSpaceAmbientOcclusionResources, ScreenSpaceReflectionsBuffer, + ScreenSpaceReflectionsUniform, ShadowSamplers, ViewClusterBindings, ViewShadowBindings, decal::{ self, clustered::{ @@ -41,14 +46,10 @@ use crate::{ }, environment_map::{self, RenderViewEnvironmentMapBindGroupEntries}, irradiance_volume::{ - self, IrradianceVolume, RenderViewIrradianceVolumeBindGroupEntries, - IRRADIANCE_VOLUMES_ARE_USABLE, + self, IRRADIANCE_VOLUMES_ARE_USABLE, IrradianceVolume, + RenderViewIrradianceVolumeBindGroupEntries, }, - prepass, EnvironmentMapUniformBuffer, FogMeta, GlobalClusterableObjectMeta, - GpuClusterableObjects, GpuFog, GpuLights, LightMeta, LightProbesBuffer, LightProbesUniform, - MeshPipeline, MeshPipelineKey, RenderViewLightProbes, ScreenSpaceAmbientOcclusionResources, - ScreenSpaceReflectionsBuffer, ScreenSpaceReflectionsUniform, ShadowSamplers, - ViewClusterBindings, ViewShadowBindings, CLUSTERED_FORWARD_STORAGE_BUFFER_COUNT, + prepass, }; #[cfg(all(feature = "webgl", target_arch = "wasm32", not(feature = "webgpu")))] @@ -461,7 +462,9 @@ impl MeshPipelineViewLayouts { #[cfg(debug_assertions)] if layout.texture_count > MESH_PIPELINE_VIEW_LAYOUT_SAFE_MAX_TEXTURES { // Issue our own warning here because Naga's error message is a bit cryptic in this situation - once!(warn!("Too many textures in mesh pipeline view layout, this might cause us to hit `wgpu::Limits::max_sampled_textures_per_shader_stage` in some environments.")); + once!(warn!( + "Too many textures in mesh pipeline view layout, this might cause us to hit `wgpu::Limits::max_sampled_textures_per_shader_stage` in some environments." + )); } &layout.bind_group_layout diff --git a/crates/bevy_pbr/src/render/mod.rs b/crates/bevy_pbr/src/render/mod.rs index 4b0a20ebecff5..13304aa5cd1ec 100644 --- a/crates/bevy_pbr/src/render/mod.rs +++ b/crates/bevy_pbr/src/render/mod.rs @@ -13,4 +13,4 @@ pub use light::*; pub use mesh::*; pub use mesh_bindings::MeshLayouts; pub use mesh_view_bindings::*; -pub use skin::{extract_skins, prepare_skins, SkinUniforms, MAX_JOINTS}; +pub use skin::{MAX_JOINTS, SkinUniforms, extract_skins, prepare_skins}; diff --git a/crates/bevy_pbr/src/render/morph.rs b/crates/bevy_pbr/src/render/morph.rs index 4b1ed68ce87a3..ae2f15ec158d4 100644 --- a/crates/bevy_pbr/src/render/morph.rs +++ b/crates/bevy_pbr/src/render/morph.rs @@ -3,12 +3,12 @@ use core::{iter, mem}; use bevy_ecs::prelude::*; use bevy_render::sync_world::MainEntityHashMap; use bevy_render::{ + Extract, batching::NoAutomaticBatching, - mesh::morph::{MeshMorphWeights, MAX_MORPH_WEIGHTS}, + mesh::morph::{MAX_MORPH_WEIGHTS, MeshMorphWeights}, render_resource::{BufferUsages, RawBufferVec}, renderer::{RenderDevice, RenderQueue}, view::ViewVisibility, - Extract, }; use bytemuck::NoUninit; diff --git a/crates/bevy_pbr/src/render/skin.rs b/crates/bevy_pbr/src/render/skin.rs index bec846a038e6a..39ee722c47b79 100644 --- a/crates/bevy_pbr/src/render/skin.rs +++ b/crates/bevy_pbr/src/render/skin.rs @@ -1,19 +1,19 @@ use core::mem::{self, size_of}; use std::sync::OnceLock; -use bevy_asset::{prelude::AssetChanged, Assets}; +use bevy_asset::{Assets, prelude::AssetChanged}; use bevy_ecs::prelude::*; use bevy_math::Mat4; use bevy_platform_support::collections::hash_map::Entry; use bevy_render::render_resource::{Buffer, BufferDescriptor}; use bevy_render::sync_world::{MainEntity, MainEntityHashMap, MainEntityHashSet}; use bevy_render::{ + Extract, batching::NoAutomaticBatching, mesh::skinning::{SkinnedMesh, SkinnedMeshInverseBindposes}, render_resource::BufferUsages, renderer::{RenderDevice, RenderQueue}, view::ViewVisibility, - Extract, }; use bevy_transform::prelude::GlobalTransform; use offset_allocator::{Allocation, Allocator}; diff --git a/crates/bevy_pbr/src/ssao/mod.rs b/crates/bevy_pbr/src/ssao/mod.rs index 4d97f52cff4ff..6e8a1ef423131 100644 --- a/crates/bevy_pbr/src/ssao/mod.rs +++ b/crates/bevy_pbr/src/ssao/mod.rs @@ -1,13 +1,13 @@ use crate::NodePbr; use bevy_app::{App, Plugin}; -use bevy_asset::{load_internal_asset, weak_handle, Handle}; +use bevy_asset::{Handle, load_internal_asset, weak_handle}; use bevy_core_pipeline::{ core_3d::graph::{Core3d, Node3d}, prelude::Camera3d, prepass::{DepthPrepass, NormalPrepass, ViewPrepassTextures}, }; use bevy_ecs::{ - prelude::{require, Component, Entity}, + prelude::{Component, Entity, require}, query::{Has, QueryItem, With}, reflect::ReflectComponent, resource::Resource, @@ -15,8 +15,9 @@ use bevy_ecs::{ system::{Commands, Query, Res, ResMut}, world::{FromWorld, World}, }; -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; use bevy_render::{ + Extract, ExtractSchedule, Render, RenderApp, RenderSet, camera::{ExtractedCamera, TemporalJitter}, extract_component::ExtractComponent, globals::{GlobalsBuffer, GlobalsUniform}, @@ -33,7 +34,6 @@ use bevy_render::{ sync_world::RenderEntity, texture::{CachedTexture, TextureCache}, view::{Msaa, ViewUniform, ViewUniformOffset, ViewUniforms}, - Extract, ExtractSchedule, Render, RenderApp, RenderSet, }; use bevy_utils::prelude::default; use core::mem; @@ -89,7 +89,9 @@ impl Plugin for ScreenSpaceAmbientOcclusionPlugin { .allowed_usages .contains(TextureUsages::STORAGE_BINDING) { - warn!("ScreenSpaceAmbientOcclusionPlugin not loaded. GPU lacks support: TextureFormat::R16Float does not support TextureUsages::STORAGE_BINDING."); + warn!( + "ScreenSpaceAmbientOcclusionPlugin not loaded. GPU lacks support: TextureFormat::R16Float does not support TextureUsages::STORAGE_BINDING." + ); return; } @@ -100,7 +102,9 @@ impl Plugin for ScreenSpaceAmbientOcclusionPlugin { .max_storage_textures_per_shader_stage < 5 { - warn!("ScreenSpaceAmbientOcclusionPlugin not loaded. GPU lacks support: Limits::max_storage_textures_per_shader_stage is less than 5."); + warn!( + "ScreenSpaceAmbientOcclusionPlugin not loaded. GPU lacks support: Limits::max_storage_textures_per_shader_stage is less than 5." + ); return; } diff --git a/crates/bevy_pbr/src/ssr/mod.rs b/crates/bevy_pbr/src/ssr/mod.rs index 15b783cef5d5f..ac62cd7540770 100644 --- a/crates/bevy_pbr/src/ssr/mod.rs +++ b/crates/bevy_pbr/src/ssr/mod.rs @@ -1,52 +1,52 @@ //! Screen space reflections implemented via raymarching. use bevy_app::{App, Plugin}; -use bevy_asset::{load_internal_asset, weak_handle, Handle}; +use bevy_asset::{Handle, load_internal_asset, weak_handle}; use bevy_core_pipeline::{ core_3d::{ - graph::{Core3d, Node3d}, DEPTH_TEXTURE_SAMPLING_SUPPORTED, + graph::{Core3d, Node3d}, }, fullscreen_vertex_shader, prepass::{DeferredPrepass, DepthPrepass, MotionVectorPrepass, NormalPrepass}, }; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::{ - component::{require, Component}, + component::{Component, require}, entity::Entity, query::{Has, QueryItem, With}, reflect::ReflectComponent, resource::Resource, schedule::IntoSystemConfigs as _, - system::{lifetimeless::Read, Commands, Query, Res, ResMut}, + system::{Commands, Query, Res, ResMut, lifetimeless::Read}, world::{FromWorld, World}, }; use bevy_image::BevyDefault as _; -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; use bevy_render::render_graph::RenderGraph; use bevy_render::{ + Render, RenderApp, RenderSet, extract_component::{ExtractComponent, ExtractComponentPlugin}, render_graph::{NodeRunError, RenderGraphApp, RenderGraphContext, ViewNode, ViewNodeRunner}, render_resource::{ - binding_types, AddressMode, BindGroupEntries, BindGroupLayout, BindGroupLayoutEntries, + AddressMode, BindGroupEntries, BindGroupLayout, BindGroupLayoutEntries, CachedRenderPipelineId, ColorTargetState, ColorWrites, DynamicUniformBuffer, FilterMode, FragmentState, Operations, PipelineCache, RenderPassColorAttachment, RenderPassDescriptor, RenderPipelineDescriptor, Sampler, SamplerBindingType, SamplerDescriptor, Shader, ShaderStages, ShaderType, SpecializedRenderPipeline, SpecializedRenderPipelines, - TextureFormat, TextureSampleType, + TextureFormat, TextureSampleType, binding_types, }, renderer::{RenderAdapter, RenderContext, RenderDevice, RenderQueue}, view::{ExtractedView, Msaa, ViewTarget, ViewUniformOffset}, - Render, RenderApp, RenderSet, }; use bevy_utils::{once, prelude::default}; use tracing::info; use crate::{ - binding_arrays_are_usable, graph::NodePbr, prelude::EnvironmentMapLight, MeshPipelineViewLayoutKey, MeshPipelineViewLayouts, MeshViewBindGroup, RenderViewLightProbes, ViewEnvironmentMapUniformOffset, ViewFogUniformOffset, ViewLightProbesUniformOffset, - ViewLightsUniformOffset, + ViewLightsUniformOffset, binding_arrays_are_usable, graph::NodePbr, + prelude::EnvironmentMapLight, }; const SSR_SHADER_HANDLE: Handle = weak_handle!("0b559df2-0d61-4f53-bf62-aea16cf32787"); diff --git a/crates/bevy_pbr/src/volumetric_fog/mod.rs b/crates/bevy_pbr/src/volumetric_fog/mod.rs index 4b90d63afccb7..ede171a456a8c 100644 --- a/crates/bevy_pbr/src/volumetric_fog/mod.rs +++ b/crates/bevy_pbr/src/volumetric_fog/mod.rs @@ -30,35 +30,35 @@ //! [Henyey-Greenstein phase function]: https://www.pbr-book.org/4ed/Volume_Scattering/Phase_Functions#TheHenyeyndashGreensteinPhaseFunction use bevy_app::{App, Plugin}; -use bevy_asset::{load_internal_asset, Assets, Handle}; +use bevy_asset::{Assets, Handle, load_internal_asset}; use bevy_color::Color; use bevy_core_pipeline::core_3d::{ graph::{Core3d, Node3d}, prepare_core_3d_depth_textures, }; use bevy_ecs::{ - component::{require, Component}, + component::{Component, require}, reflect::ReflectComponent, schedule::IntoSystemConfigs as _, }; use bevy_image::Image; use bevy_math::{ - primitives::{Cuboid, Plane3d}, Vec2, Vec3, + primitives::{Cuboid, Plane3d}, }; -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; use bevy_render::{ + ExtractSchedule, Render, RenderApp, RenderSet, mesh::{Mesh, Meshable}, render_graph::{RenderGraphApp, ViewNodeRunner}, render_resource::{Shader, SpecializedRenderPipelines}, sync_component::SyncComponentPlugin, view::Visibility, - ExtractSchedule, Render, RenderApp, RenderSet, }; use bevy_transform::components::Transform; use render::{ - VolumetricFogNode, VolumetricFogPipeline, VolumetricFogUniformBuffer, CUBE_MESH, PLANE_MESH, - VOLUMETRIC_FOG_HANDLE, + CUBE_MESH, PLANE_MESH, VOLUMETRIC_FOG_HANDLE, VolumetricFogNode, VolumetricFogPipeline, + VolumetricFogUniformBuffer, }; use crate::graph::NodePbr; diff --git a/crates/bevy_pbr/src/volumetric_fog/render.rs b/crates/bevy_pbr/src/volumetric_fog/render.rs index 292ad1c86ae1a..d6b9b352f12c4 100644 --- a/crates/bevy_pbr/src/volumetric_fog/render.rs +++ b/crates/bevy_pbr/src/volumetric_fog/render.rs @@ -2,7 +2,7 @@ use core::array; -use bevy_asset::{weak_handle, AssetId, Handle}; +use bevy_asset::{AssetId, Handle, weak_handle}; use bevy_color::ColorToComponents as _; use bevy_core_pipeline::{ core_3d::Camera3d, @@ -14,21 +14,19 @@ use bevy_ecs::{ entity::Entity, query::{Has, QueryItem, With}, resource::Resource, - system::{lifetimeless::Read, Commands, Local, Query, Res, ResMut}, + system::{Commands, Local, Query, Res, ResMut, lifetimeless::Read}, world::{FromWorld, World}, }; use bevy_image::{BevyDefault, Image}; -use bevy_math::{vec4, Mat3A, Mat4, Vec3, Vec3A, Vec4, Vec4Swizzles as _}; +use bevy_math::{Mat3A, Mat4, Vec3, Vec3A, Vec4, Vec4Swizzles as _, vec4}; use bevy_render::{ + Extract, mesh::{ - allocator::MeshAllocator, Mesh, MeshVertexBufferLayoutRef, RenderMesh, RenderMeshBufferInfo, + Mesh, MeshVertexBufferLayoutRef, RenderMesh, RenderMeshBufferInfo, allocator::MeshAllocator, }, render_asset::RenderAssets, render_graph::{NodeRunError, RenderGraphContext, ViewNode}, render_resource::{ - binding_types::{ - sampler, texture_3d, texture_depth_2d, texture_depth_2d_multisampled, uniform_buffer, - }, BindGroupLayout, BindGroupLayoutEntries, BindingResource, BlendComponent, BlendFactor, BlendOperation, BlendState, CachedRenderPipelineId, ColorTargetState, ColorWrites, DynamicBindGroupEntries, DynamicUniformBuffer, Face, FragmentState, LoadOp, @@ -36,12 +34,14 @@ use bevy_render::{ RenderPassDescriptor, RenderPipelineDescriptor, SamplerBindingType, Shader, ShaderStages, ShaderType, SpecializedRenderPipeline, SpecializedRenderPipelines, StoreOp, TextureFormat, TextureSampleType, TextureUsages, VertexState, + binding_types::{ + sampler, texture_3d, texture_depth_2d, texture_depth_2d_multisampled, uniform_buffer, + }, }, renderer::{RenderContext, RenderDevice, RenderQueue}, sync_world::RenderEntity, texture::GpuImage, view::{ExtractedView, Msaa, ViewDepthTexture, ViewTarget, ViewUniformOffset}, - Extract, }; use bevy_transform::components::GlobalTransform; use bevy_utils::prelude::default; diff --git a/crates/bevy_pbr/src/wireframe.rs b/crates/bevy_pbr/src/wireframe.rs index 68862bbf711ed..494b68cbb9591 100644 --- a/crates/bevy_pbr/src/wireframe.rs +++ b/crates/bevy_pbr/src/wireframe.rs @@ -1,9 +1,9 @@ use crate::{Material, MaterialPipeline, MaterialPipelineKey, MaterialPlugin, MeshMaterial3d}; use bevy_app::{Plugin, Startup, Update}; -use bevy_asset::{load_internal_asset, weak_handle, Asset, AssetApp, Assets, Handle}; +use bevy_asset::{Asset, AssetApp, Assets, Handle, load_internal_asset, weak_handle}; use bevy_color::{Color, LinearRgba}; use bevy_ecs::prelude::*; -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; use bevy_render::{ extract_resource::ExtractResource, mesh::{Mesh3d, MeshVertexBufferLayoutRef}, diff --git a/crates/bevy_picking/src/backend.rs b/crates/bevy_picking/src/backend.rs index 5c18d57211af7..3e6cf51e1ab79 100644 --- a/crates/bevy_picking/src/backend.rs +++ b/crates/bevy_picking/src/backend.rs @@ -39,10 +39,10 @@ use bevy_reflect::Reflect; /// /// This includes the most common types in this module, re-exported for your convenience. pub mod prelude { - pub use super::{ray::RayMap, HitData, PointerHits}; + pub use super::{HitData, PointerHits, ray::RayMap}; pub use crate::{ - pointer::{PointerId, PointerLocation}, PickSet, Pickable, + pointer::{PointerId, PointerLocation}, }; } @@ -130,7 +130,7 @@ pub mod ray { use crate::backend::prelude::{PointerId, PointerLocation}; use bevy_ecs::prelude::*; use bevy_math::Ray3d; - use bevy_platform_support::collections::{hash_map::Iter, HashMap}; + use bevy_platform_support::collections::{HashMap, hash_map::Iter}; use bevy_reflect::Reflect; use bevy_render::camera::Camera; use bevy_transform::prelude::GlobalTransform; diff --git a/crates/bevy_picking/src/events.rs b/crates/bevy_picking/src/events.rs index 243208ca8ac06..21898d104bd96 100644 --- a/crates/bevy_picking/src/events.rs +++ b/crates/bevy_picking/src/events.rs @@ -50,7 +50,7 @@ use bevy_window::Window; use tracing::debug; use crate::{ - backend::{prelude::PointerLocation, HitData}, + backend::{HitData, prelude::PointerLocation}, hover::{HoverMap, PreviousHoverMap}, pointer::{Location, PointerAction, PointerButton, PointerId, PointerInput, PointerMap}, }; diff --git a/crates/bevy_picking/src/hover.rs b/crates/bevy_picking/src/hover.rs index 69edb6d9aa9f8..0150f8762830e 100644 --- a/crates/bevy_picking/src/hover.rs +++ b/crates/bevy_picking/src/hover.rs @@ -8,9 +8,9 @@ use core::fmt::Debug; use std::collections::HashSet; use crate::{ + Pickable, backend::{self, HitData}, pointer::{PointerAction, PointerId, PointerInput, PointerInteraction, PointerPress}, - Pickable, }; use bevy_derive::{Deref, DerefMut}; diff --git a/crates/bevy_picking/src/input.rs b/crates/bevy_picking/src/input.rs index eeb4adac15d3a..e399d4dd4a637 100644 --- a/crates/bevy_picking/src/input.rs +++ b/crates/bevy_picking/src/input.rs @@ -14,10 +14,10 @@ use bevy_app::prelude::*; use bevy_ecs::prelude::*; use bevy_input::{ + ButtonState, mouse::MouseWheel, prelude::*, touch::{TouchInput, TouchPhase}, - ButtonState, }; use bevy_math::Vec2; use bevy_platform_support::collections::{HashMap, HashSet}; diff --git a/crates/bevy_picking/src/lib.rs b/crates/bevy_picking/src/lib.rs index 7b9c990aed62c..2716b9b983f02 100644 --- a/crates/bevy_picking/src/lib.rs +++ b/crates/bevy_picking/src/lib.rs @@ -167,7 +167,7 @@ pub mod mesh_picking; pub mod pointer; pub mod window; -use bevy_app::{prelude::*, PluginGroupBuilder}; +use bevy_app::{PluginGroupBuilder, prelude::*}; use bevy_ecs::prelude::*; use bevy_reflect::prelude::*; @@ -178,13 +178,13 @@ pub mod prelude { #[cfg(feature = "bevy_mesh_picking_backend")] #[doc(hidden)] pub use crate::mesh_picking::{ - ray_cast::{MeshRayCast, MeshRayCastSettings, RayCastBackfaces, RayCastVisibility}, MeshPickingPlugin, MeshPickingSettings, RayCastPickable, + ray_cast::{MeshRayCast, MeshRayCastSettings, RayCastBackfaces, RayCastVisibility}, }; #[doc(hidden)] pub use crate::{ - events::*, input::PointerInputPlugin, pointer::PointerButton, DefaultPickingPlugins, - InteractionPlugin, Pickable, PickingPlugin, + DefaultPickingPlugins, InteractionPlugin, Pickable, PickingPlugin, events::*, + input::PointerInputPlugin, pointer::PointerButton, }; } diff --git a/crates/bevy_picking/src/mesh_picking/mod.rs b/crates/bevy_picking/src/mesh_picking/mod.rs index 5860fbc2b51c9..45fe2e89597ac 100644 --- a/crates/bevy_picking/src/mesh_picking/mod.rs +++ b/crates/bevy_picking/src/mesh_picking/mod.rs @@ -16,9 +16,9 @@ pub mod ray_cast; use crate::{ - backend::{ray::RayMap, HitData, PointerHits}, - prelude::*, PickSet, + backend::{HitData, PointerHits, ray::RayMap}, + prelude::*, }; use bevy_app::prelude::*; use bevy_ecs::prelude::*; diff --git a/crates/bevy_picking/src/mesh_picking/ray_cast/intersections.rs b/crates/bevy_picking/src/mesh_picking/ray_cast/intersections.rs index d4ec97e1f3549..9191343dd4588 100644 --- a/crates/bevy_picking/src/mesh_picking/ray_cast/intersections.rs +++ b/crates/bevy_picking/src/mesh_picking/ray_cast/intersections.rs @@ -1,4 +1,4 @@ -use bevy_math::{bounding::Aabb3d, Dir3, Mat4, Ray3d, Vec3, Vec3A}; +use bevy_math::{Dir3, Mat4, Ray3d, Vec3, Vec3A, bounding::Aabb3d}; use bevy_reflect::Reflect; use bevy_render::mesh::{Indices, Mesh, PrimitiveTopology}; @@ -303,11 +303,7 @@ pub fn ray_aabb_intersection_3d(ray: Ray3d, aabb: &Aabb3d, model_to_world: &Mat4 let tmin = tmin.max_element().max(0.0); let tmax = tmax.min_element(); - if tmin <= tmax { - Some(tmin) - } else { - None - } + if tmin <= tmax { Some(tmin) } else { None } } #[cfg(test)] diff --git a/crates/bevy_picking/src/mesh_picking/ray_cast/mod.rs b/crates/bevy_picking/src/mesh_picking/ray_cast/mod.rs index ef6f187416b46..c6608d5c23dcf 100644 --- a/crates/bevy_picking/src/mesh_picking/ray_cast/mod.rs +++ b/crates/bevy_picking/src/mesh_picking/ray_cast/mod.rs @@ -6,15 +6,15 @@ mod intersections; use bevy_derive::{Deref, DerefMut}; -use bevy_math::{bounding::Aabb3d, Ray3d}; -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_math::{Ray3d, bounding::Aabb3d}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; use bevy_render::mesh::Mesh; use intersections::*; -pub use intersections::{ray_aabb_intersection_3d, ray_mesh_intersection, RayMeshHit}; +pub use intersections::{RayMeshHit, ray_aabb_intersection_3d, ray_mesh_intersection}; use bevy_asset::{Assets, Handle}; -use bevy_ecs::{prelude::*, system::lifetimeless::Read, system::SystemParam}; +use bevy_ecs::{prelude::*, system::SystemParam, system::lifetimeless::Read}; use bevy_math::FloatOrd; use bevy_render::{prelude::*, primitives::Aabb}; use bevy_transform::components::GlobalTransform; diff --git a/crates/bevy_platform_support/src/sync/atomic.rs b/crates/bevy_platform_support/src/sync/atomic.rs index 9e8eadb3df8de..d4d1ec84a7c83 100644 --- a/crates/bevy_platform_support/src/sync/atomic.rs +++ b/crates/bevy_platform_support/src/sync/atomic.rs @@ -6,8 +6,8 @@ //! feature gates in your own code. pub use atomic::{ - AtomicBool, AtomicI16, AtomicI32, AtomicI64, AtomicI8, AtomicIsize, AtomicPtr, AtomicU16, - AtomicU32, AtomicU64, AtomicU8, AtomicUsize, Ordering, + AtomicBool, AtomicI8, AtomicI16, AtomicI32, AtomicI64, AtomicIsize, AtomicPtr, AtomicU8, + AtomicU16, AtomicU32, AtomicU64, AtomicUsize, Ordering, }; #[cfg(not(feature = "portable-atomic"))] diff --git a/crates/bevy_platform_support/src/time.rs b/crates/bevy_platform_support/src/time.rs index 79fc81c7fe85d..f7a77987cd38f 100644 --- a/crates/bevy_platform_support/src/time.rs +++ b/crates/bevy_platform_support/src/time.rs @@ -186,7 +186,9 @@ mod fallback { } #[cfg(not(any(target_arch = "x86", target_arch = "x86_64", target_arch = "aarch64")))] - panic!("An elapsed time getter has not been provided to `Instant`. Please use `Instant::set_elapsed(...)` before calling `Instant::now()`"); + panic!( + "An elapsed time getter has not been provided to `Instant`. Please use `Instant::set_elapsed(...)` before calling `Instant::now()`" + ); #[cfg(any(target_arch = "x86", target_arch = "x86_64", target_arch = "aarch64"))] return Duration::from_nanos(_nanos); diff --git a/crates/bevy_reflect/derive/src/container_attributes.rs b/crates/bevy_reflect/derive/src/container_attributes.rs index bdb94db06bc7e..4c8cd7ae7e5be 100644 --- a/crates/bevy_reflect/derive/src/container_attributes.rs +++ b/crates/bevy_reflect/derive/src/container_attributes.rs @@ -13,8 +13,8 @@ use bevy_macro_utils::fq_std::{FQAny, FQOption}; use proc_macro2::{Ident, Span}; use quote::quote_spanned; use syn::{ - ext::IdentExt, parenthesized, parse::ParseStream, spanned::Spanned, token, Expr, LitBool, - MetaList, MetaNameValue, Path, Token, WhereClause, + Expr, LitBool, MetaList, MetaNameValue, Path, Token, WhereClause, ext::IdentExt, parenthesized, + parse::ParseStream, spanned::Spanned, token, }; mod kw { @@ -257,9 +257,12 @@ impl ContainerAttributes { let ident = input.parse::()?; if input.peek(token::Paren) { - return Err(syn::Error::new(ident.span(), format!( - "only [{DEBUG_ATTR:?}, {PARTIAL_EQ_ATTR:?}, {HASH_ATTR:?}] may specify custom functions", - ))); + return Err(syn::Error::new( + ident.span(), + format!( + "only [{DEBUG_ATTR:?}, {PARTIAL_EQ_ATTR:?}, {HASH_ATTR:?}] may specify custom functions", + ), + )); } let ident_name = ident.to_string(); diff --git a/crates/bevy_reflect/derive/src/custom_attributes.rs b/crates/bevy_reflect/derive/src/custom_attributes.rs index f12b6d7c12480..78e42842c6645 100644 --- a/crates/bevy_reflect/derive/src/custom_attributes.rs +++ b/crates/bevy_reflect/derive/src/custom_attributes.rs @@ -1,6 +1,6 @@ use proc_macro2::TokenStream; use quote::quote; -use syn::{parse::ParseStream, Expr, Path, Token}; +use syn::{Expr, Path, Token, parse::ParseStream}; #[derive(Default, Clone)] pub(crate) struct CustomAttributes { diff --git a/crates/bevy_reflect/derive/src/derive_data.rs b/crates/bevy_reflect/derive/src/derive_data.rs index e739c91ebb912..9b736b8b1f426 100644 --- a/crates/bevy_reflect/derive/src/derive_data.rs +++ b/crates/bevy_reflect/derive/src/derive_data.rs @@ -2,6 +2,7 @@ use core::fmt; use proc_macro2::Span; use crate::{ + REFLECT_ATTRIBUTE_NAME, TYPE_NAME_ATTRIBUTE_NAME, TYPE_PATH_ATTRIBUTE_NAME, container_attributes::{ContainerAttributes, FromReflectAttrs, TypePathAttrs}, field_attributes::FieldAttributes, remote::RemoteType, @@ -10,15 +11,14 @@ use crate::{ string_expr::StringExpr, type_path::parse_path_no_leading_colon, where_clause_options::WhereClauseOptions, - REFLECT_ATTRIBUTE_NAME, TYPE_NAME_ATTRIBUTE_NAME, TYPE_PATH_ATTRIBUTE_NAME, }; -use quote::{quote, ToTokens}; +use quote::{ToTokens, quote}; use syn::token::Comma; use crate::generics::generate_generics; use syn::{ - parse_str, punctuated::Punctuated, spanned::Spanned, Data, DeriveInput, Field, Fields, - GenericParam, Generics, Ident, LitStr, Meta, Path, PathSegment, Type, TypeParam, Variant, + Data, DeriveInput, Field, Fields, GenericParam, Generics, Ident, LitStr, Meta, Path, + PathSegment, Type, TypeParam, Variant, parse_str, punctuated::Punctuated, spanned::Spanned, }; pub(crate) enum ReflectDerive<'a> { @@ -202,7 +202,9 @@ impl<'a> ReflectDerive<'a> { else { return Err(syn::Error::new( pair.span(), - format_args!("`#[{TYPE_PATH_ATTRIBUTE_NAME} = \"...\"]` must be a string literal"), + format_args!( + "`#[{TYPE_PATH_ATTRIBUTE_NAME} = \"...\"]` must be a string literal" + ), )); }; @@ -219,7 +221,9 @@ impl<'a> ReflectDerive<'a> { else { return Err(syn::Error::new( pair.span(), - format_args!("`#[{TYPE_NAME_ATTRIBUTE_NAME} = \"...\"]` must be a string literal"), + format_args!( + "`#[{TYPE_NAME_ATTRIBUTE_NAME} = \"...\"]` must be a string literal" + ), )); }; @@ -246,7 +250,9 @@ impl<'a> ReflectDerive<'a> { (None, Some(name)) => { return Err(syn::Error::new( name.span(), - format!("cannot use `#[{TYPE_NAME_ATTRIBUTE_NAME} = \"...\"]` without a `#[{TYPE_PATH_ATTRIBUTE_NAME} = \"...\"]` attribute."), + format!( + "cannot use `#[{TYPE_NAME_ATTRIBUTE_NAME} = \"...\"]` without a `#[{TYPE_PATH_ATTRIBUTE_NAME} = \"...\"]` attribute." + ), )); } _ => (), @@ -266,7 +272,9 @@ impl<'a> ReflectDerive<'a> { { return Err(syn::Error::new( meta.type_path().span(), - format!("a #[{TYPE_PATH_ATTRIBUTE_NAME} = \"...\"] attribute must be specified when using {provenance}") + format!( + "a #[{TYPE_PATH_ATTRIBUTE_NAME} = \"...\"] attribute must be specified when using {provenance}" + ), )); } diff --git a/crates/bevy_reflect/derive/src/documentation.rs b/crates/bevy_reflect/derive/src/documentation.rs index 33aec4c4f3221..696b9da81226a 100644 --- a/crates/bevy_reflect/derive/src/documentation.rs +++ b/crates/bevy_reflect/derive/src/documentation.rs @@ -2,7 +2,7 @@ use bevy_macro_utils::fq_std::FQOption; use proc_macro2::TokenStream; -use quote::{quote, ToTokens}; +use quote::{ToTokens, quote}; use syn::{Attribute, Expr, ExprLit, Lit, Meta}; /// A struct used to represent a type's documentation, if any. diff --git a/crates/bevy_reflect/derive/src/field_attributes.rs b/crates/bevy_reflect/derive/src/field_attributes.rs index 6cddb50e61bda..233ee26fb33e6 100644 --- a/crates/bevy_reflect/derive/src/field_attributes.rs +++ b/crates/bevy_reflect/derive/src/field_attributes.rs @@ -5,11 +5,11 @@ //! the derive helper attribute for `Reflect`, which looks like: `#[reflect(ignore)]`. use crate::{ - attribute_parser::terminated_parser, custom_attributes::CustomAttributes, - REFLECT_ATTRIBUTE_NAME, + REFLECT_ATTRIBUTE_NAME, attribute_parser::terminated_parser, + custom_attributes::CustomAttributes, }; use quote::ToTokens; -use syn::{parse::ParseStream, Attribute, LitStr, Meta, Token, Type}; +use syn::{Attribute, LitStr, Meta, Token, Type, parse::ParseStream}; mod kw { syn::custom_keyword!(ignore); diff --git a/crates/bevy_reflect/derive/src/from_reflect.rs b/crates/bevy_reflect/derive/src/from_reflect.rs index d994cbd2f79a2..aabfaee649fd4 100644 --- a/crates/bevy_reflect/derive/src/from_reflect.rs +++ b/crates/bevy_reflect/derive/src/from_reflect.rs @@ -1,15 +1,15 @@ use crate::{ + ReflectMeta, ReflectStruct, container_attributes::REFLECT_DEFAULT, derive_data::ReflectEnum, enum_utility::{EnumVariantOutputData, FromReflectVariantBuilder, VariantBuilder}, field_attributes::DefaultBehavior, ident::ident_or_index, where_clause_options::WhereClauseOptions, - ReflectMeta, ReflectStruct, }; use bevy_macro_utils::fq_std::{FQClone, FQDefault, FQOption}; use proc_macro2::Span; -use quote::{quote, ToTokens}; +use quote::{ToTokens, quote}; use syn::{Field, Ident, Lit, LitInt, LitStr, Member}; /// Implements `FromReflect` for the given struct diff --git a/crates/bevy_reflect/derive/src/impls/opaque.rs b/crates/bevy_reflect/derive/src/impls/opaque.rs index bdee656a964cc..75f33bd6305cf 100644 --- a/crates/bevy_reflect/derive/src/impls/opaque.rs +++ b/crates/bevy_reflect/derive/src/impls/opaque.rs @@ -1,7 +1,7 @@ use crate::{ + ReflectMeta, impls::{common_partial_reflect_methods, impl_full_reflect, impl_type_path, impl_typed}, where_clause_options::WhereClauseOptions, - ReflectMeta, }; use bevy_macro_utils::fq_std::{FQClone, FQOption, FQResult}; use quote::quote; diff --git a/crates/bevy_reflect/derive/src/impls/structs.rs b/crates/bevy_reflect/derive/src/impls/structs.rs index c1db19ca9c80b..46b2c2ab1e0d6 100644 --- a/crates/bevy_reflect/derive/src/impls/structs.rs +++ b/crates/bevy_reflect/derive/src/impls/structs.rs @@ -1,10 +1,10 @@ use crate::{ + ReflectStruct, impls::{common_partial_reflect_methods, impl_full_reflect, impl_type_path, impl_typed}, struct_utility::FieldAccessors, - ReflectStruct, }; use bevy_macro_utils::fq_std::{FQDefault, FQOption, FQResult}; -use quote::{quote, ToTokens}; +use quote::{ToTokens, quote}; /// Implements `Struct`, `GetTypeRegistration`, and `Reflect` for the given derive data. pub(crate) fn impl_struct(reflect_struct: &ReflectStruct) -> proc_macro2::TokenStream { diff --git a/crates/bevy_reflect/derive/src/impls/tuple_structs.rs b/crates/bevy_reflect/derive/src/impls/tuple_structs.rs index a0037c64ca57e..dd61d5725fd82 100644 --- a/crates/bevy_reflect/derive/src/impls/tuple_structs.rs +++ b/crates/bevy_reflect/derive/src/impls/tuple_structs.rs @@ -1,10 +1,10 @@ use crate::{ + ReflectStruct, impls::{common_partial_reflect_methods, impl_full_reflect, impl_type_path, impl_typed}, struct_utility::FieldAccessors, - ReflectStruct, }; use bevy_macro_utils::fq_std::{FQDefault, FQOption, FQResult}; -use quote::{quote, ToTokens}; +use quote::{ToTokens, quote}; /// Implements `TupleStruct`, `GetTypeRegistration`, and `Reflect` for the given derive data. pub(crate) fn impl_tuple_struct(reflect_struct: &ReflectStruct) -> proc_macro2::TokenStream { diff --git a/crates/bevy_reflect/derive/src/impls/typed.rs b/crates/bevy_reflect/derive/src/impls/typed.rs index da8254d149339..6b7b7641e63b6 100644 --- a/crates/bevy_reflect/derive/src/impls/typed.rs +++ b/crates/bevy_reflect/derive/src/impls/typed.rs @@ -5,7 +5,7 @@ use crate::{ }; use bevy_macro_utils::fq_std::FQOption; use proc_macro2::TokenStream; -use quote::{quote, ToTokens}; +use quote::{ToTokens, quote}; /// Returns an expression for a `NonGenericTypeCell` or `GenericTypeCell` to generate `'static` references. fn static_type_cell( diff --git a/crates/bevy_reflect/derive/src/lib.rs b/crates/bevy_reflect/derive/src/lib.rs index 276371427b620..f01e2035e65a8 100644 --- a/crates/bevy_reflect/derive/src/lib.rs +++ b/crates/bevy_reflect/derive/src/lib.rs @@ -46,7 +46,7 @@ use derive_data::{ReflectImplSource, ReflectProvenance, ReflectTraitToImpl, Refl use proc_macro::TokenStream; use quote::quote; use reflect_opaque::ReflectOpaqueDef; -use syn::{parse_macro_input, DeriveInput}; +use syn::{DeriveInput, parse_macro_input}; use type_path::NamedTypePathDef; pub(crate) static REFLECT_ATTRIBUTE_NAME: &str = "reflect"; diff --git a/crates/bevy_reflect/derive/src/reflect_opaque.rs b/crates/bevy_reflect/derive/src/reflect_opaque.rs index 7cebcd7aff16c..2edde061c76c3 100644 --- a/crates/bevy_reflect/derive/src/reflect_opaque.rs +++ b/crates/bevy_reflect/derive/src/reflect_opaque.rs @@ -2,7 +2,7 @@ use crate::{ container_attributes::ContainerAttributes, derive_data::ReflectTraitToImpl, type_path::CustomPathDef, }; -use syn::{parenthesized, parse::ParseStream, token::Paren, Attribute, Generics, Path}; +use syn::{Attribute, Generics, Path, parenthesized, parse::ParseStream, token::Paren}; /// A struct used to define a simple reflection-opaque types (including primitives). /// diff --git a/crates/bevy_reflect/derive/src/remote.rs b/crates/bevy_reflect/derive/src/remote.rs index 13cbe681ed4c7..d3f82aa75eacc 100644 --- a/crates/bevy_reflect/derive/src/remote.rs +++ b/crates/bevy_reflect/derive/src/remote.rs @@ -1,21 +1,21 @@ use crate::{ + REFLECT_ATTRIBUTE_NAME, ReflectDerive, derive_data::{ReflectImplSource, ReflectProvenance, ReflectTraitToImpl}, from_reflect, ident::ident_or_index, impls, impls::impl_assertions, - ReflectDerive, REFLECT_ATTRIBUTE_NAME, }; use bevy_macro_utils::fq_std::FQOption; use proc_macro::TokenStream; use proc_macro2::{Ident, Span}; use quote::{format_ident, quote, quote_spanned}; use syn::{ + DeriveInput, ExprPath, Generics, Member, PathArguments, Type, TypePath, parse::{Parse, ParseStream}, parse_macro_input, spanned::Spanned, token::PathSep, - DeriveInput, ExprPath, Generics, Member, PathArguments, Type, TypePath, }; /// Generates the remote wrapper type and implements all the necessary traits. @@ -473,7 +473,7 @@ impl<'a> RemoteType<'a> { return Err(syn::Error::new( arg.span(), "cannot use parenthesized type as remote type", - )) + )); } } } diff --git a/crates/bevy_reflect/derive/src/serialization.rs b/crates/bevy_reflect/derive/src/serialization.rs index 75df7b7b930b2..93474e571d243 100644 --- a/crates/bevy_reflect/derive/src/serialization.rs +++ b/crates/bevy_reflect/derive/src/serialization.rs @@ -5,7 +5,7 @@ use crate::{ use bevy_macro_utils::fq_std::FQDefault; use quote::quote; use std::collections::HashMap; -use syn::{spanned::Spanned, Path}; +use syn::{Path, spanned::Spanned}; type ReflectionIndex = usize; diff --git a/crates/bevy_reflect/derive/src/string_expr.rs b/crates/bevy_reflect/derive/src/string_expr.rs index cc48a90b91735..a552f58bc90d3 100644 --- a/crates/bevy_reflect/derive/src/string_expr.rs +++ b/crates/bevy_reflect/derive/src/string_expr.rs @@ -1,6 +1,6 @@ use proc_macro2::TokenStream; -use quote::{quote, ToTokens}; -use syn::{spanned::Spanned, LitStr}; +use quote::{ToTokens, quote}; +use syn::{LitStr, spanned::Spanned}; /// Contains tokens representing different kinds of string. #[derive(Clone)] diff --git a/crates/bevy_reflect/derive/src/struct_utility.rs b/crates/bevy_reflect/derive/src/struct_utility.rs index 09604419b6043..87c9659ee1b48 100644 --- a/crates/bevy_reflect/derive/src/struct_utility.rs +++ b/crates/bevy_reflect/derive/src/struct_utility.rs @@ -1,4 +1,4 @@ -use crate::{derive_data::StructField, ReflectStruct}; +use crate::{ReflectStruct, derive_data::StructField}; use quote::quote; /// A helper struct for creating remote-aware field accessors. diff --git a/crates/bevy_reflect/derive/src/trait_reflection.rs b/crates/bevy_reflect/derive/src/trait_reflection.rs index 8df40e47a5fd0..aa6d3ae769614 100644 --- a/crates/bevy_reflect/derive/src/trait_reflection.rs +++ b/crates/bevy_reflect/derive/src/trait_reflection.rs @@ -1,7 +1,7 @@ use bevy_macro_utils::fq_std::{FQClone, FQOption, FQResult}; use proc_macro::TokenStream; use quote::quote; -use syn::{parse::Parse, parse_macro_input, Attribute, ItemTrait, Token}; +use syn::{Attribute, ItemTrait, Token, parse::Parse, parse_macro_input}; pub(crate) struct TraitInfo { item_trait: ItemTrait, diff --git a/crates/bevy_reflect/derive/src/type_path.rs b/crates/bevy_reflect/derive/src/type_path.rs index 3ef92981a33d9..6f26a6adeb1d8 100644 --- a/crates/bevy_reflect/derive/src/type_path.rs +++ b/crates/bevy_reflect/derive/src/type_path.rs @@ -1,9 +1,8 @@ use proc_macro2::Ident; use syn::{ - parenthesized, + Generics, Path, PathSegment, Token, parenthesized, parse::{Parse, ParseStream}, token::Paren, - Generics, Path, PathSegment, Token, }; pub(crate) fn parse_path_no_leading_colon(input: ParseStream) -> syn::Result { diff --git a/crates/bevy_reflect/derive/src/where_clause_options.rs b/crates/bevy_reflect/derive/src/where_clause_options.rs index 1551e008d017c..dec1ab87fd04c 100644 --- a/crates/bevy_reflect/derive/src/where_clause_options.rs +++ b/crates/bevy_reflect/derive/src/where_clause_options.rs @@ -1,8 +1,8 @@ use crate::derive_data::ReflectMeta; use bevy_macro_utils::fq_std::{FQAny, FQSend, FQSync}; use proc_macro2::TokenStream; -use quote::{quote, ToTokens}; -use syn::{punctuated::Punctuated, Token, Type, WhereClause}; +use quote::{ToTokens, quote}; +use syn::{Token, Type, WhereClause, punctuated::Punctuated}; /// Options defining how to extend the `where` clause for reflection. pub(crate) struct WhereClauseOptions<'a, 'b> { diff --git a/crates/bevy_reflect/examples/reflect_docs.rs b/crates/bevy_reflect/examples/reflect_docs.rs index 10852185c00d8..c3942438c2033 100644 --- a/crates/bevy_reflect/examples/reflect_docs.rs +++ b/crates/bevy_reflect/examples/reflect_docs.rs @@ -36,7 +36,10 @@ fn main() { // From here, we already have access to the struct's docs: let player_docs = player_info.docs().unwrap(); - assert_eq!(" The struct that defines our player.\n\n # Example\n\n ```\n let player = Player::new(\"Urist McPlayer\");\n ```", player_docs); + assert_eq!( + " The struct that defines our player.\n\n # Example\n\n ```\n let player = Player::new(\"Urist McPlayer\");\n ```", + player_docs + ); println!("=====[ Player ]=====\n{player_docs}"); // We can then iterate through our struct's fields to get their documentation as well: diff --git a/crates/bevy_reflect/src/array.rs b/crates/bevy_reflect/src/array.rs index 300e69c2a71e9..13c83b3cd1816 100644 --- a/crates/bevy_reflect/src/array.rs +++ b/crates/bevy_reflect/src/array.rs @@ -1,8 +1,8 @@ use crate::generics::impl_generic_info_methods; use crate::{ - type_info::impl_type_methods, utility::reflect_hasher, ApplyError, Generics, MaybeTyped, - PartialReflect, Reflect, ReflectKind, ReflectMut, ReflectOwned, ReflectRef, Type, TypeInfo, - TypePath, + ApplyError, Generics, MaybeTyped, PartialReflect, Reflect, ReflectKind, ReflectMut, + ReflectOwned, ReflectRef, Type, TypeInfo, TypePath, type_info::impl_type_methods, + utility::reflect_hasher, }; use alloc::{boxed::Box, vec::Vec}; use bevy_reflect_derive::impl_type_path; diff --git a/crates/bevy_reflect/src/attributes.rs b/crates/bevy_reflect/src/attributes.rs index a6edefab25c65..052aab92d1b26 100644 --- a/crates/bevy_reflect/src/attributes.rs +++ b/crates/bevy_reflect/src/attributes.rs @@ -178,7 +178,7 @@ pub(crate) use impl_custom_attribute_methods; #[cfg(test)] mod tests { use super::*; - use crate::{type_info::Typed, TypeInfo, VariantInfo}; + use crate::{TypeInfo, VariantInfo, type_info::Typed}; use alloc::{format, string::String}; use core::ops::RangeInclusive; @@ -204,9 +204,11 @@ mod tests { let attributes = CustomAttributes::default().with_attribute(String::from("Hello, World!")); let value = attributes.get_by_id(TypeId::of::()).unwrap(); - assert!(value - .reflect_partial_eq(&String::from("Hello, World!")) - .unwrap()); + assert!( + value + .reflect_partial_eq(&String::from("Hello, World!")) + .unwrap() + ); } #[test] diff --git a/crates/bevy_reflect/src/enums/dynamic_enum.rs b/crates/bevy_reflect/src/enums/dynamic_enum.rs index d9e228c07eaae..c93f08bd9e178 100644 --- a/crates/bevy_reflect/src/enums/dynamic_enum.rs +++ b/crates/bevy_reflect/src/enums/dynamic_enum.rs @@ -1,9 +1,9 @@ use bevy_reflect_derive::impl_type_path; use crate::{ - enum_debug, enum_hash, enum_partial_eq, ApplyError, DynamicStruct, DynamicTuple, Enum, - PartialReflect, Reflect, ReflectKind, ReflectMut, ReflectOwned, ReflectRef, Struct, Tuple, - TypeInfo, VariantFieldIter, VariantType, + ApplyError, DynamicStruct, DynamicTuple, Enum, PartialReflect, Reflect, ReflectKind, + ReflectMut, ReflectOwned, ReflectRef, Struct, Tuple, TypeInfo, VariantFieldIter, VariantType, + enum_debug, enum_hash, enum_partial_eq, }; use alloc::{boxed::Box, string::String}; diff --git a/crates/bevy_reflect/src/enums/enum_trait.rs b/crates/bevy_reflect/src/enums/enum_trait.rs index d3f6550640012..79c25e1ab8b14 100644 --- a/crates/bevy_reflect/src/enums/enum_trait.rs +++ b/crates/bevy_reflect/src/enums/enum_trait.rs @@ -1,8 +1,8 @@ use crate::generics::impl_generic_info_methods; use crate::{ - attributes::{impl_custom_attribute_methods, CustomAttributes}, - type_info::impl_type_methods, DynamicEnum, Generics, PartialReflect, Type, TypePath, VariantInfo, VariantType, + attributes::{CustomAttributes, impl_custom_attribute_methods}, + type_info::impl_type_methods, }; use alloc::{boxed::Box, format, string::String}; use bevy_platform_support::collections::HashMap; diff --git a/crates/bevy_reflect/src/enums/helpers.rs b/crates/bevy_reflect/src/enums/helpers.rs index 659d0bd7bc823..7c69810539bef 100644 --- a/crates/bevy_reflect/src/enums/helpers.rs +++ b/crates/bevy_reflect/src/enums/helpers.rs @@ -1,4 +1,4 @@ -use crate::{utility::reflect_hasher, Enum, PartialReflect, ReflectRef, VariantType}; +use crate::{Enum, PartialReflect, ReflectRef, VariantType, utility::reflect_hasher}; use core::{ fmt::Debug, hash::{Hash, Hasher}, diff --git a/crates/bevy_reflect/src/enums/mod.rs b/crates/bevy_reflect/src/enums/mod.rs index fd657ffa7f25a..1bb5d18f56510 100644 --- a/crates/bevy_reflect/src/enums/mod.rs +++ b/crates/bevy_reflect/src/enums/mod.rs @@ -50,18 +50,22 @@ mod tests { if let VariantInfo::Tuple(variant) = info.variant("B").unwrap() { assert!(variant.field_at(0).unwrap().is::()); assert!(variant.field_at(1).unwrap().is::()); - assert!(variant - .field_at(0) - .unwrap() - .type_info() - .unwrap() - .is::()); - assert!(variant - .field_at(1) - .unwrap() - .type_info() - .unwrap() - .is::()); + assert!( + variant + .field_at(0) + .unwrap() + .type_info() + .unwrap() + .is::() + ); + assert!( + variant + .field_at(1) + .unwrap() + .type_info() + .unwrap() + .is::() + ); } else { panic!("Expected `VariantInfo::Tuple`"); } @@ -72,12 +76,14 @@ mod tests { if let VariantInfo::Struct(variant) = info.variant("C").unwrap() { assert!(variant.field_at(0).unwrap().is::()); assert!(variant.field("foo").unwrap().is::()); - assert!(variant - .field("foo") - .unwrap() - .type_info() - .unwrap() - .is::()); + assert!( + variant + .field("foo") + .unwrap() + .type_info() + .unwrap() + .is::() + ); } else { panic!("Expected `VariantInfo::Struct`"); } @@ -229,14 +235,16 @@ mod tests { let value: &dyn Enum = &MyEnum::B(123, 321); assert_eq!(2, value.field_len()); let mut iter = value.iter_fields(); - assert!(iter - .next() - .and_then(|field| field.value().reflect_partial_eq(&123_usize)) - .unwrap_or_default()); - assert!(iter - .next() - .and_then(|field| field.value().reflect_partial_eq(&321_i32)) - .unwrap_or_default()); + assert!( + iter.next() + .and_then(|field| field.value().reflect_partial_eq(&123_usize)) + .unwrap_or_default() + ); + assert!( + iter.next() + .and_then(|field| field.value().reflect_partial_eq(&321_i32)) + .unwrap_or_default() + ); // === Struct === // let value: &dyn Enum = &MyEnum::C { @@ -245,20 +253,22 @@ mod tests { }; assert_eq!(2, value.field_len()); let mut iter = value.iter_fields(); - assert!(iter - .next() - .and_then(|field| field - .value() - .reflect_partial_eq(&1.23_f32) - .and(field.name().map(|name| name == "foo"))) - .unwrap_or_default()); - assert!(iter - .next() - .and_then(|field| field - .value() - .reflect_partial_eq(&true) - .and(field.name().map(|name| name == "bar"))) - .unwrap_or_default()); + assert!( + iter.next() + .and_then(|field| field + .value() + .reflect_partial_eq(&1.23_f32) + .and(field.name().map(|name| name == "foo"))) + .unwrap_or_default() + ); + assert!( + iter.next() + .and_then(|field| field + .value() + .reflect_partial_eq(&true) + .and(field.name().map(|name| name == "bar"))) + .unwrap_or_default() + ); } #[test] @@ -502,45 +512,55 @@ mod tests { // === MyEnum::A -> MyEnum::B === // value.apply(&MyEnum::B(123, 321)); - assert!(value - .reflect_partial_eq(&MyEnum::B(123, 321)) - .unwrap_or_default()); + assert!( + value + .reflect_partial_eq(&MyEnum::B(123, 321)) + .unwrap_or_default() + ); // === MyEnum::B -> MyEnum::B === // value.apply(&MyEnum::B(321, 123)); - assert!(value - .reflect_partial_eq(&MyEnum::B(321, 123)) - .unwrap_or_default()); + assert!( + value + .reflect_partial_eq(&MyEnum::B(321, 123)) + .unwrap_or_default() + ); // === MyEnum::B -> MyEnum::C === // value.apply(&MyEnum::C { foo: 1.23, bar: true, }); - assert!(value - .reflect_partial_eq(&MyEnum::C { - foo: 1.23, - bar: true - }) - .unwrap_or_default()); + assert!( + value + .reflect_partial_eq(&MyEnum::C { + foo: 1.23, + bar: true + }) + .unwrap_or_default() + ); // === MyEnum::C -> MyEnum::C === // value.apply(&MyEnum::C { foo: 3.21, bar: false, }); - assert!(value - .reflect_partial_eq(&MyEnum::C { - foo: 3.21, - bar: false - }) - .unwrap_or_default()); + assert!( + value + .reflect_partial_eq(&MyEnum::C { + foo: 3.21, + bar: false + }) + .unwrap_or_default() + ); // === MyEnum::C -> MyEnum::B === // value.apply(&MyEnum::B(123, 321)); - assert!(value - .reflect_partial_eq(&MyEnum::B(123, 321)) - .unwrap_or_default()); + assert!( + value + .reflect_partial_eq(&MyEnum::B(123, 321)) + .unwrap_or_default() + ); // === MyEnum::B -> MyEnum::A === // value.apply(&MyEnum::A); @@ -557,15 +577,19 @@ mod tests { // === MyEnum::A -> MyEnum::B === // value.set(Box::new(MyEnum::B(123, 321))).unwrap(); - assert!(value - .reflect_partial_eq(&MyEnum::B(123, 321)) - .unwrap_or_default()); + assert!( + value + .reflect_partial_eq(&MyEnum::B(123, 321)) + .unwrap_or_default() + ); // === MyEnum::B -> MyEnum::B === // value.set(Box::new(MyEnum::B(321, 123))).unwrap(); - assert!(value - .reflect_partial_eq(&MyEnum::B(321, 123)) - .unwrap_or_default()); + assert!( + value + .reflect_partial_eq(&MyEnum::B(321, 123)) + .unwrap_or_default() + ); // === MyEnum::B -> MyEnum::C === // value @@ -574,12 +598,14 @@ mod tests { bar: true, })) .unwrap(); - assert!(value - .reflect_partial_eq(&MyEnum::C { - foo: 1.23, - bar: true - }) - .unwrap_or_default()); + assert!( + value + .reflect_partial_eq(&MyEnum::C { + foo: 1.23, + bar: true + }) + .unwrap_or_default() + ); // === MyEnum::C -> MyEnum::C === // value @@ -588,18 +614,22 @@ mod tests { bar: false, })) .unwrap(); - assert!(value - .reflect_partial_eq(&MyEnum::C { - foo: 3.21, - bar: false - }) - .unwrap_or_default()); + assert!( + value + .reflect_partial_eq(&MyEnum::C { + foo: 3.21, + bar: false + }) + .unwrap_or_default() + ); // === MyEnum::C -> MyEnum::B === // value.set(Box::new(MyEnum::B(123, 321))).unwrap(); - assert!(value - .reflect_partial_eq(&MyEnum::B(123, 321)) - .unwrap_or_default()); + assert!( + value + .reflect_partial_eq(&MyEnum::B(123, 321)) + .unwrap_or_default() + ); // === MyEnum::B -> MyEnum::A === // value.set(Box::new(MyEnum::A)).unwrap(); diff --git a/crates/bevy_reflect/src/enums/variants.rs b/crates/bevy_reflect/src/enums/variants.rs index 25e40334e7187..b610644569952 100644 --- a/crates/bevy_reflect/src/enums/variants.rs +++ b/crates/bevy_reflect/src/enums/variants.rs @@ -1,6 +1,6 @@ use crate::{ - attributes::{impl_custom_attribute_methods, CustomAttributes}, NamedField, UnnamedField, + attributes::{CustomAttributes, impl_custom_attribute_methods}, }; use alloc::boxed::Box; use bevy_platform_support::collections::HashMap; diff --git a/crates/bevy_reflect/src/fields.rs b/crates/bevy_reflect/src/fields.rs index 3a521c21ccbee..5608d9adbc7ce 100644 --- a/crates/bevy_reflect/src/fields.rs +++ b/crates/bevy_reflect/src/fields.rs @@ -1,7 +1,7 @@ use crate::{ - attributes::{impl_custom_attribute_methods, CustomAttributes}, - type_info::impl_type_methods, MaybeTyped, PartialReflect, Type, TypeInfo, TypePath, + attributes::{CustomAttributes, impl_custom_attribute_methods}, + type_info::impl_type_methods, }; use bevy_platform_support::sync::Arc; diff --git a/crates/bevy_reflect/src/func/args/arg.rs b/crates/bevy_reflect/src/func/args/arg.rs index 8ca03aafd36ff..4af2c47f656c6 100644 --- a/crates/bevy_reflect/src/func/args/arg.rs +++ b/crates/bevy_reflect/src/func/args/arg.rs @@ -1,6 +1,6 @@ use crate::{ - func::args::{ArgError, FromArg, Ownership}, PartialReflect, Reflect, TypePath, + func::args::{ArgError, FromArg, Ownership}, }; use alloc::{boxed::Box, string::ToString}; use core::ops::Deref; diff --git a/crates/bevy_reflect/src/func/args/info.rs b/crates/bevy_reflect/src/func/args/info.rs index b1a81f3059a2e..9e76cdfea327b 100644 --- a/crates/bevy_reflect/src/func/args/info.rs +++ b/crates/bevy_reflect/src/func/args/info.rs @@ -1,9 +1,9 @@ use alloc::borrow::Cow; use crate::{ + Type, TypePath, func::args::{GetOwnership, Ownership}, type_info::impl_type_methods, - Type, TypePath, }; /// Type information for an [`Arg`] used in a [`DynamicFunction`] or [`DynamicFunctionMut`]. diff --git a/crates/bevy_reflect/src/func/args/list.rs b/crates/bevy_reflect/src/func/args/list.rs index ee0964e71a644..7f0995b1b59aa 100644 --- a/crates/bevy_reflect/src/func/args/list.rs +++ b/crates/bevy_reflect/src/func/args/list.rs @@ -1,9 +1,9 @@ use crate::{ + PartialReflect, Reflect, TypePath, func::{ - args::{Arg, ArgValue, FromArg}, ArgError, + args::{Arg, ArgValue, FromArg}, }, - PartialReflect, Reflect, TypePath, }; use alloc::{ boxed::Box, diff --git a/crates/bevy_reflect/src/func/dynamic_function.rs b/crates/bevy_reflect/src/func/dynamic_function.rs index c090442ce483f..392b2264744eb 100644 --- a/crates/bevy_reflect/src/func/dynamic_function.rs +++ b/crates/bevy_reflect/src/func/dynamic_function.rs @@ -1,14 +1,14 @@ use crate::{ __macro_exports::RegisterForReflection, + ApplyError, MaybeTyped, PartialReflect, Reflect, ReflectKind, ReflectMut, ReflectOwned, + ReflectRef, TypeInfo, TypePath, func::{ + DynamicFunctionMut, Function, FunctionOverloadError, FunctionResult, IntoFunction, + IntoFunctionMut, args::{ArgCount, ArgList}, dynamic_function_internal::DynamicFunctionInternal, info::FunctionInfo, - DynamicFunctionMut, Function, FunctionOverloadError, FunctionResult, IntoFunction, - IntoFunctionMut, }, - ApplyError, MaybeTyped, PartialReflect, Reflect, ReflectKind, ReflectMut, ReflectOwned, - ReflectRef, TypeInfo, TypePath, }; use alloc::{borrow::Cow, boxed::Box}; use bevy_platform_support::sync::Arc; @@ -480,9 +480,9 @@ impl<'env> IntoFunctionMut<'env, ()> for DynamicFunction<'env> { #[cfg(test)] mod tests { use super::*; + use crate::Type; use crate::func::signature::ArgumentSignature; use crate::func::{FunctionError, IntoReturn, SignatureInfo}; - use crate::Type; use alloc::{format, string::String, vec, vec::Vec}; use bevy_platform_support::collections::HashSet; use core::ops::Add; @@ -780,7 +780,10 @@ mod tests { let function = greet.into_function(); let debug = format!("{:?}", function); - assert_eq!(debug, "DynamicFunction(fn bevy_reflect::func::dynamic_function::tests::should_debug_dynamic_function::greet(_: &alloc::string::String) -> alloc::string::String)"); + assert_eq!( + debug, + "DynamicFunction(fn bevy_reflect::func::dynamic_function::tests::should_debug_dynamic_function::greet(_: &alloc::string::String) -> alloc::string::String)" + ); } #[test] diff --git a/crates/bevy_reflect/src/func/dynamic_function_internal.rs b/crates/bevy_reflect/src/func/dynamic_function_internal.rs index 65b98e5e13a67..076ccf3500fc3 100644 --- a/crates/bevy_reflect/src/func/dynamic_function_internal.rs +++ b/crates/bevy_reflect/src/func/dynamic_function_internal.rs @@ -185,8 +185,8 @@ impl Debug for DynamicFunctionInternal { #[cfg(test)] mod tests { use super::*; - use crate::func::{FunctionInfo, SignatureInfo}; use crate::Type; + use crate::func::{FunctionInfo, SignatureInfo}; #[test] fn should_merge_single_into_single() { diff --git a/crates/bevy_reflect/src/func/dynamic_function_mut.rs b/crates/bevy_reflect/src/func/dynamic_function_mut.rs index b706ac620ac84..514eced2c6d55 100644 --- a/crates/bevy_reflect/src/func/dynamic_function_mut.rs +++ b/crates/bevy_reflect/src/func/dynamic_function_mut.rs @@ -3,9 +3,9 @@ use bevy_platform_support::sync::Arc; use core::fmt::{Debug, Formatter}; use crate::func::{ + DynamicFunction, FunctionInfo, FunctionOverloadError, FunctionResult, IntoFunctionMut, args::{ArgCount, ArgList}, dynamic_function_internal::DynamicFunctionInternal, - DynamicFunction, FunctionInfo, FunctionOverloadError, FunctionResult, IntoFunctionMut, }; /// A [`Box`] containing a callback to a reflected function. diff --git a/crates/bevy_reflect/src/func/error.rs b/crates/bevy_reflect/src/func/error.rs index d4407d9698428..812e1f9c5875b 100644 --- a/crates/bevy_reflect/src/func/error.rs +++ b/crates/bevy_reflect/src/func/error.rs @@ -1,7 +1,7 @@ use crate::func::signature::ArgumentSignature; use crate::func::{ - args::{ArgCount, ArgError}, Return, + args::{ArgCount, ArgError}, }; use alloc::borrow::Cow; use bevy_platform_support::collections::HashSet; @@ -20,7 +20,9 @@ pub enum FunctionError { #[error("received {received} arguments but expected one of {expected:?}")] ArgCountMismatch { expected: ArgCount, received: usize }, /// No overload was found for the given set of arguments. - #[error("no overload found for arguments with signature `{received:?}`, expected one of `{expected:?}`")] + #[error( + "no overload found for arguments with signature `{received:?}`, expected one of `{expected:?}`" + )] NoOverload { expected: HashSet, received: ArgumentSignature, diff --git a/crates/bevy_reflect/src/func/function.rs b/crates/bevy_reflect/src/func/function.rs index 2ae8c1877b4de..615beddb32a31 100644 --- a/crates/bevy_reflect/src/func/function.rs +++ b/crates/bevy_reflect/src/func/function.rs @@ -1,9 +1,9 @@ use crate::{ + PartialReflect, func::{ - args::{ArgCount, ArgList}, DynamicFunction, FunctionInfo, FunctionResult, + args::{ArgCount, ArgList}, }, - PartialReflect, }; use alloc::borrow::Cow; use core::fmt::Debug; diff --git a/crates/bevy_reflect/src/func/info.rs b/crates/bevy_reflect/src/func/info.rs index 53737fd891dbd..25fc0b4342bc4 100644 --- a/crates/bevy_reflect/src/func/info.rs +++ b/crates/bevy_reflect/src/func/info.rs @@ -2,11 +2,11 @@ use alloc::{borrow::Cow, boxed::Box, vec, vec::Vec}; use core::fmt::{Debug, Formatter}; use crate::{ + Type, TypePath, + func::FunctionOverloadError, func::args::{ArgCount, ArgCountOutOfBoundsError, ArgInfo, GetOwnership, Ownership}, func::signature::ArgumentSignature, - func::FunctionOverloadError, type_info::impl_type_methods, - Type, TypePath, }; use variadics_please::all_tuples; diff --git a/crates/bevy_reflect/src/func/mod.rs b/crates/bevy_reflect/src/func/mod.rs index 74a89282c6d2d..cfedcab7e04cb 100644 --- a/crates/bevy_reflect/src/func/mod.rs +++ b/crates/bevy_reflect/src/func/mod.rs @@ -194,8 +194,8 @@ mod tests { use super::*; use crate::func::args::ArgCount; use crate::{ - func::args::{ArgError, ArgList, Ownership}, TypePath, + func::args::{ArgError, ArgList, Ownership}, }; #[test] diff --git a/crates/bevy_reflect/src/func/reflect_fn.rs b/crates/bevy_reflect/src/func/reflect_fn.rs index 6ef7c22eb177a..f8693c3ae5416 100644 --- a/crates/bevy_reflect/src/func/reflect_fn.rs +++ b/crates/bevy_reflect/src/func/reflect_fn.rs @@ -1,12 +1,12 @@ use variadics_please::all_tuples; use crate::{ + Reflect, TypePath, func::{ + ArgList, FunctionError, FunctionResult, IntoReturn, ReflectFnMut, args::{ArgCount, FromArg}, macros::count_tokens, - ArgList, FunctionError, FunctionResult, IntoReturn, ReflectFnMut, }, - Reflect, TypePath, }; /// A reflection-based version of the [`Fn`] trait. diff --git a/crates/bevy_reflect/src/func/reflect_fn_mut.rs b/crates/bevy_reflect/src/func/reflect_fn_mut.rs index 98db2b45907ef..25a3c4bfdd173 100644 --- a/crates/bevy_reflect/src/func/reflect_fn_mut.rs +++ b/crates/bevy_reflect/src/func/reflect_fn_mut.rs @@ -1,12 +1,12 @@ use variadics_please::all_tuples; use crate::{ + Reflect, TypePath, func::{ + ArgList, FunctionError, FunctionResult, IntoReturn, args::{ArgCount, FromArg}, macros::count_tokens, - ArgList, FunctionError, FunctionResult, IntoReturn, }, - Reflect, TypePath, }; /// A reflection-based version of the [`FnMut`] trait. diff --git a/crates/bevy_reflect/src/func/signature.rs b/crates/bevy_reflect/src/func/signature.rs index c8862b35d0d90..9421a54937309 100644 --- a/crates/bevy_reflect/src/func/signature.rs +++ b/crates/bevy_reflect/src/func/signature.rs @@ -11,9 +11,9 @@ //! //! [`FunctionInfo`]: crate::func::info::FunctionInfo +use crate::Type; use crate::func::args::ArgInfo; use crate::func::{ArgList, SignatureInfo}; -use crate::Type; use alloc::boxed::Box; use bevy_platform_support::collections::Equivalent; use core::borrow::Borrow; diff --git a/crates/bevy_reflect/src/impls/glam.rs b/crates/bevy_reflect/src/impls/glam.rs index 653eb3edaa55b..db3e91c7eeb2a 100644 --- a/crates/bevy_reflect/src/impls/glam.rs +++ b/crates/bevy_reflect/src/impls/glam.rs @@ -1,4 +1,4 @@ -use crate::{std_traits::ReflectDefault, ReflectDeserialize, ReflectSerialize}; +use crate::{ReflectDeserialize, ReflectSerialize, std_traits::ReflectDefault}; use assert_type_match::assert_type_match; use bevy_reflect_derive::{impl_reflect, impl_reflect_opaque}; use glam::*; @@ -498,16 +498,16 @@ impl_reflect_opaque!(::glam::BVec4A(Debug, Default, Deserialize, Serialize)); mod tests { use alloc::{format, string::String}; use ron::{ - ser::{to_string_pretty, PrettyConfig}, Deserializer, + ser::{PrettyConfig, to_string_pretty}, }; use serde::de::DeserializeSeed; use static_assertions::assert_impl_all; use crate::{ + Enum, GetTypeRegistration, TypeRegistry, prelude::*, serde::{ReflectDeserializer, ReflectSerializer}, - Enum, GetTypeRegistration, TypeRegistry, }; use super::*; diff --git a/crates/bevy_reflect/src/impls/petgraph.rs b/crates/bevy_reflect/src/impls/petgraph.rs index 2264c9cb4b9b2..f4d23f2084d41 100644 --- a/crates/bevy_reflect/src/impls/petgraph.rs +++ b/crates/bevy_reflect/src/impls/petgraph.rs @@ -1,4 +1,4 @@ -use crate::{impl_reflect_opaque, prelude::ReflectDefault, ReflectDeserialize, ReflectSerialize}; +use crate::{ReflectDeserialize, ReflectSerialize, impl_reflect_opaque, prelude::ReflectDefault}; impl_reflect_opaque!(::petgraph::graph::NodeIndex( Default, diff --git a/crates/bevy_reflect/src/impls/smallvec.rs b/crates/bevy_reflect/src/impls/smallvec.rs index afb75aff8d997..de6c55cd18747 100644 --- a/crates/bevy_reflect/src/impls/smallvec.rs +++ b/crates/bevy_reflect/src/impls/smallvec.rs @@ -4,10 +4,10 @@ use core::any::Any; use smallvec::{Array as SmallArray, SmallVec}; use crate::{ - utility::GenericTypeInfoCell, ApplyError, FromReflect, FromType, Generics, GetTypeRegistration, - List, ListInfo, ListIter, MaybeTyped, PartialReflect, Reflect, ReflectFromPtr, ReflectKind, - ReflectMut, ReflectOwned, ReflectRef, TypeInfo, TypeParamInfo, TypePath, TypeRegistration, - Typed, + ApplyError, FromReflect, FromType, Generics, GetTypeRegistration, List, ListInfo, ListIter, + MaybeTyped, PartialReflect, Reflect, ReflectFromPtr, ReflectKind, ReflectMut, ReflectOwned, + ReflectRef, TypeInfo, TypeParamInfo, TypePath, TypeRegistration, Typed, + utility::GenericTypeInfoCell, }; impl List for SmallVec diff --git a/crates/bevy_reflect/src/impls/smol_str.rs b/crates/bevy_reflect/src/impls/smol_str.rs index e2c09b206b3be..f2b08dea9356c 100644 --- a/crates/bevy_reflect/src/impls/smol_str.rs +++ b/crates/bevy_reflect/src/impls/smol_str.rs @@ -1,4 +1,4 @@ -use crate::{std_traits::ReflectDefault, ReflectDeserialize, ReflectSerialize}; +use crate::{ReflectDeserialize, ReflectSerialize, std_traits::ReflectDefault}; use bevy_reflect_derive::impl_reflect_opaque; impl_reflect_opaque!(::smol_str::SmolStr( diff --git a/crates/bevy_reflect/src/impls/std.rs b/crates/bevy_reflect/src/impls/std.rs index 447e480f14273..185badad1c2e1 100644 --- a/crates/bevy_reflect/src/impls/std.rs +++ b/crates/bevy_reflect/src/impls/std.rs @@ -4,16 +4,16 @@ )] use crate::{ - impl_type_path, map_apply, map_partial_eq, map_try_apply, - prelude::ReflectDefault, - reflect::impl_full_reflect, - set_apply, set_partial_eq, set_try_apply, - utility::{reflect_hasher, GenericTypeInfoCell, GenericTypePathCell, NonGenericTypeInfoCell}, ApplyError, Array, ArrayInfo, ArrayIter, DynamicMap, DynamicSet, DynamicTypePath, FromReflect, FromType, Generics, GetTypeRegistration, List, ListInfo, ListIter, Map, MapInfo, MapIter, MaybeTyped, OpaqueInfo, PartialReflect, Reflect, ReflectDeserialize, ReflectFromPtr, ReflectFromReflect, ReflectKind, ReflectMut, ReflectOwned, ReflectRef, ReflectSerialize, Set, SetInfo, TypeInfo, TypeParamInfo, TypePath, TypeRegistration, TypeRegistry, Typed, + impl_type_path, map_apply, map_partial_eq, map_try_apply, + prelude::ReflectDefault, + reflect::impl_full_reflect, + set_apply, set_partial_eq, set_try_apply, + utility::{GenericTypeInfoCell, GenericTypePathCell, NonGenericTypeInfoCell, reflect_hasher}, }; use alloc::{ borrow::{Cow, ToOwned}, @@ -2536,12 +2536,14 @@ mod tests { let a: &dyn Reflect = &a; let b: &dyn Reflect = &b; let c: &dyn Reflect = &c; - assert!(a - .reflect_partial_eq(b.as_partial_reflect()) - .unwrap_or_default()); - assert!(!a - .reflect_partial_eq(c.as_partial_reflect()) - .unwrap_or_default()); + assert!( + a.reflect_partial_eq(b.as_partial_reflect()) + .unwrap_or_default() + ); + assert!( + !a.reflect_partial_eq(c.as_partial_reflect()) + .unwrap_or_default() + ); } #[test] @@ -2557,12 +2559,16 @@ mod tests { let mut value = Some(123usize); - assert!(value - .reflect_partial_eq(&Some(123usize)) - .unwrap_or_default()); - assert!(!value - .reflect_partial_eq(&Some(321usize)) - .unwrap_or_default()); + assert!( + value + .reflect_partial_eq(&Some(123usize)) + .unwrap_or_default() + ); + assert!( + !value + .reflect_partial_eq(&Some(321usize)) + .unwrap_or_default() + ); assert_eq!("Some", value.variant_name()); assert_eq!("core::option::Option::Some", value.variant_path()); diff --git a/crates/bevy_reflect/src/impls/uuid.rs b/crates/bevy_reflect/src/impls/uuid.rs index 56beedd41ab41..afdf630fcacff 100644 --- a/crates/bevy_reflect/src/impls/uuid.rs +++ b/crates/bevy_reflect/src/impls/uuid.rs @@ -1,4 +1,4 @@ -use crate::{std_traits::ReflectDefault, ReflectDeserialize, ReflectSerialize}; +use crate::{ReflectDeserialize, ReflectSerialize, std_traits::ReflectDefault}; use bevy_reflect_derive::impl_reflect_opaque; impl_reflect_opaque!(::uuid::Uuid( diff --git a/crates/bevy_reflect/src/impls/wgpu_types.rs b/crates/bevy_reflect/src/impls/wgpu_types.rs index b4a1750ba1242..164007affce3b 100644 --- a/crates/bevy_reflect/src/impls/wgpu_types.rs +++ b/crates/bevy_reflect/src/impls/wgpu_types.rs @@ -1,4 +1,4 @@ -use crate::{impl_reflect_opaque, ReflectDeserialize, ReflectSerialize}; +use crate::{ReflectDeserialize, ReflectSerialize, impl_reflect_opaque}; impl_reflect_opaque!(::wgpu_types::TextureFormat( Debug, diff --git a/crates/bevy_reflect/src/lib.rs b/crates/bevy_reflect/src/lib.rs index 2845c716c5d54..b8420b71330a8 100644 --- a/crates/bevy_reflect/src/lib.rs +++ b/crates/bevy_reflect/src/lib.rs @@ -622,9 +622,9 @@ pub mod prelude { #[doc(hidden)] pub use crate::{ - reflect_trait, FromReflect, GetField, GetPath, GetTupleStructField, PartialReflect, - Reflect, ReflectDeserialize, ReflectFromReflect, ReflectPath, ReflectSerialize, Struct, - TupleStruct, TypePath, + FromReflect, GetField, GetPath, GetTupleStructField, PartialReflect, Reflect, + ReflectDeserialize, ReflectFromReflect, ReflectPath, ReflectSerialize, Struct, TupleStruct, + TypePath, reflect_trait, }; #[cfg(feature = "functions")] @@ -723,7 +723,7 @@ pub mod __macro_exports { reason = "We don't need the exact value of Pi here." )] mod tests { - use ::serde::{de::DeserializeSeed, Deserialize, Serialize}; + use ::serde::{Deserialize, Serialize, de::DeserializeSeed}; use alloc::{ borrow::Cow, boxed::Box, @@ -741,8 +741,8 @@ mod tests { }; use disqualified::ShortName; use ron::{ - ser::{to_string_pretty, PrettyConfig}, Deserializer, + ser::{PrettyConfig, to_string_pretty}, }; use static_assertions::{assert_impl_all, assert_not_impl_all}; @@ -1012,13 +1012,17 @@ mod tests { // Assert let expected = MyStruct { foo: 123 }; - assert!(expected - .reflect_partial_eq(reflected.as_partial_reflect()) - .unwrap_or_default()); + assert!( + expected + .reflect_partial_eq(reflected.as_partial_reflect()) + .unwrap_or_default() + ); let not_expected = MyStruct { foo: 321 }; - assert!(!not_expected - .reflect_partial_eq(reflected.as_partial_reflect()) - .unwrap_or_default()); + assert!( + !not_expected + .reflect_partial_eq(reflected.as_partial_reflect()) + .unwrap_or_default() + ); } #[test] @@ -2009,7 +2013,9 @@ mod tests { let info = ::type_info(); assert_eq!( - Some(" Some struct.\n\n # Example\n\n ```ignore (This is only used for a unit test, no need to doc test)\n let some_struct = SomeStruct;\n ```"), + Some( + " Some struct.\n\n # Example\n\n ```ignore (This is only used for a unit test, no need to doc test)\n let some_struct = SomeStruct;\n ```" + ), info.docs() ); @@ -2021,7 +2027,9 @@ mod tests { let info = ::type_info(); assert_eq!( - Some("The compiler automatically converts `///`-style comments into `#[doc]` attributes.\nOf course, you _could_ use the attribute directly if you wanted to.\nBoth will be reflected."), + Some( + "The compiler automatically converts `///`-style comments into `#[doc]` attributes.\nOf course, you _could_ use the attribute directly if you wanted to.\nBoth will be reflected." + ), info.docs() ); @@ -2455,7 +2463,10 @@ bevy_reflect::tests::Test { // Can use `TypePath` let path = as TypePath>::type_path(); - assert_eq!("bevy_reflect::tests::can_opt_out_type_path::Foo", path); + assert_eq!( + "bevy_reflect::tests::can_opt_out_type_path::Foo", + path + ); // Can register the type let mut registry = TypeRegistry::default(); @@ -3027,7 +3038,7 @@ bevy_reflect::tests::Test { #[cfg(feature = "glam")] mod glam { use super::*; - use ::glam::{quat, vec3, Quat, Vec3}; + use ::glam::{Quat, Vec3, quat, vec3}; #[test] fn quat_serialization() { diff --git a/crates/bevy_reflect/src/list.rs b/crates/bevy_reflect/src/list.rs index e0f019c4b26dc..6806b21e33561 100644 --- a/crates/bevy_reflect/src/list.rs +++ b/crates/bevy_reflect/src/list.rs @@ -9,9 +9,9 @@ use bevy_reflect_derive::impl_type_path; use crate::generics::impl_generic_info_methods; use crate::{ - type_info::impl_type_methods, utility::reflect_hasher, ApplyError, FromReflect, Generics, - MaybeTyped, PartialReflect, Reflect, ReflectKind, ReflectMut, ReflectOwned, ReflectRef, Type, - TypeInfo, TypePath, + ApplyError, FromReflect, Generics, MaybeTyped, PartialReflect, Reflect, ReflectKind, + ReflectMut, ReflectOwned, ReflectRef, Type, TypeInfo, TypePath, type_info::impl_type_methods, + utility::reflect_hasher, }; /// A trait used to power [list-like] operations via [reflection]. diff --git a/crates/bevy_reflect/src/map.rs b/crates/bevy_reflect/src/map.rs index 1ce685b127854..784caf65156b7 100644 --- a/crates/bevy_reflect/src/map.rs +++ b/crates/bevy_reflect/src/map.rs @@ -4,9 +4,9 @@ use bevy_platform_support::collections::HashTable; use bevy_reflect_derive::impl_type_path; use crate::{ - generics::impl_generic_info_methods, type_info::impl_type_methods, ApplyError, Generics, - MaybeTyped, PartialReflect, Reflect, ReflectKind, ReflectMut, ReflectOwned, ReflectRef, Type, - TypeInfo, TypePath, + ApplyError, Generics, MaybeTyped, PartialReflect, Reflect, ReflectKind, ReflectMut, + ReflectOwned, ReflectRef, Type, TypeInfo, TypePath, generics::impl_generic_info_methods, + type_info::impl_type_methods, }; use alloc::{boxed::Box, format, vec::Vec}; diff --git a/crates/bevy_reflect/src/path/error.rs b/crates/bevy_reflect/src/path/error.rs index 0e900c8315ecb..b149446f0383b 100644 --- a/crates/bevy_reflect/src/path/error.rs +++ b/crates/bevy_reflect/src/path/error.rs @@ -89,30 +89,28 @@ impl fmt::Display for AccessError<'_> { write!(f, ": ")?; match kind { - AccessErrorKind::MissingField(type_accessed) => { - match access { - Access::Field(field) => write!( - f, - "The {type_accessed} accessed doesn't have {} `{}` field", - if let Some("a" | "e" | "i" | "o" | "u") = field.get(0..1) { - "an" - } else { - "a" - }, - access.display_value() - ), - Access::FieldIndex(_) => write!( - f, - "The {type_accessed} accessed doesn't have field index `{}`", - access.display_value(), - ), - Access::TupleIndex(_) | Access::ListIndex(_) => write!( - f, - "The {type_accessed} accessed doesn't have index `{}`", - access.display_value() - ) - } - } + AccessErrorKind::MissingField(type_accessed) => match access { + Access::Field(field) => write!( + f, + "The {type_accessed} accessed doesn't have {} `{}` field", + if let Some("a" | "e" | "i" | "o" | "u") = field.get(0..1) { + "an" + } else { + "a" + }, + access.display_value() + ), + Access::FieldIndex(_) => write!( + f, + "The {type_accessed} accessed doesn't have field index `{}`", + access.display_value(), + ), + Access::TupleIndex(_) | Access::ListIndex(_) => write!( + f, + "The {type_accessed} accessed doesn't have index `{}`", + access.display_value() + ), + }, AccessErrorKind::IncompatibleTypes { expected, actual } => write!( f, "Expected {} access to access a {expected}, found a {actual} instead.", diff --git a/crates/bevy_reflect/src/reflect.rs b/crates/bevy_reflect/src/reflect.rs index 0898ff3630fe9..c7b4a7b2fa337 100644 --- a/crates/bevy_reflect/src/reflect.rs +++ b/crates/bevy_reflect/src/reflect.rs @@ -1,7 +1,7 @@ use crate::{ - array_debug, enum_debug, list_debug, map_debug, set_debug, struct_debug, tuple_debug, - tuple_struct_debug, DynamicTypePath, DynamicTyped, OpaqueInfo, ReflectKind, - ReflectKindMismatchError, ReflectMut, ReflectOwned, ReflectRef, TypeInfo, TypePath, Typed, + DynamicTypePath, DynamicTyped, OpaqueInfo, ReflectKind, ReflectKindMismatchError, ReflectMut, + ReflectOwned, ReflectRef, TypeInfo, TypePath, Typed, array_debug, enum_debug, list_debug, + map_debug, set_debug, struct_debug, tuple_debug, tuple_struct_debug, }; use alloc::boxed::Box; use core::{ diff --git a/crates/bevy_reflect/src/serde/de/arrays.rs b/crates/bevy_reflect/src/serde/de/arrays.rs index f1e0d60dd6154..2e386df629271 100644 --- a/crates/bevy_reflect/src/serde/de/arrays.rs +++ b/crates/bevy_reflect/src/serde/de/arrays.rs @@ -1,6 +1,6 @@ use crate::{ - serde::{de::registration_utils::try_get_registration, TypedReflectDeserializer}, ArrayInfo, DynamicArray, TypeRegistry, + serde::{TypedReflectDeserializer, de::registration_utils::try_get_registration}, }; use alloc::{string::ToString, vec::Vec}; use core::{fmt, fmt::Formatter}; diff --git a/crates/bevy_reflect/src/serde/de/deserializer.rs b/crates/bevy_reflect/src/serde/de/deserializer.rs index 1c20eaad07abc..b48f976190a40 100644 --- a/crates/bevy_reflect/src/serde/de/deserializer.rs +++ b/crates/bevy_reflect/src/serde/de/deserializer.rs @@ -2,15 +2,15 @@ use crate::serde::de::error_utils::TYPE_INFO_STACK; use crate::serde::{ReflectDeserializeWithRegistry, SerializationData}; use crate::{ + PartialReflect, ReflectDeserialize, TypeInfo, TypePath, TypeRegistration, TypeRegistry, serde::{ + TypeRegistrationDeserializer, de::{ arrays::ArrayVisitor, enums::EnumVisitor, error_utils::make_custom_error, lists::ListVisitor, maps::MapVisitor, options::OptionVisitor, sets::SetVisitor, structs::StructVisitor, tuple_structs::TupleStructVisitor, tuples::TupleVisitor, }, - TypeRegistrationDeserializer, }, - PartialReflect, ReflectDeserialize, TypeInfo, TypePath, TypeRegistration, TypeRegistry, }; use alloc::boxed::Box; use core::{fmt, fmt::Formatter}; diff --git a/crates/bevy_reflect/src/serde/de/enums.rs b/crates/bevy_reflect/src/serde/de/enums.rs index 21cbf46f9ecb1..72ee3b0271e5c 100644 --- a/crates/bevy_reflect/src/serde/de/enums.rs +++ b/crates/bevy_reflect/src/serde/de/enums.rs @@ -1,16 +1,16 @@ use crate::{ + DynamicEnum, DynamicStruct, DynamicTuple, DynamicVariant, EnumInfo, StructVariantInfo, + TupleVariantInfo, TypeRegistration, TypeRegistry, VariantInfo, serde::{ + TypedReflectDeserializer, de::{ error_utils::make_custom_error, helpers::ExpectedValues, registration_utils::try_get_registration, struct_utils::{visit_struct, visit_struct_seq}, - tuple_utils::{visit_tuple, TupleLikeInfo}, + tuple_utils::{TupleLikeInfo, visit_tuple}, }, - TypedReflectDeserializer, }, - DynamicEnum, DynamicStruct, DynamicTuple, DynamicVariant, EnumInfo, StructVariantInfo, - TupleVariantInfo, TypeRegistration, TypeRegistry, VariantInfo, }; use core::{fmt, fmt::Formatter}; use serde::de::{DeserializeSeed, EnumAccess, Error, MapAccess, SeqAccess, VariantAccess, Visitor}; diff --git a/crates/bevy_reflect/src/serde/de/helpers.rs b/crates/bevy_reflect/src/serde/de/helpers.rs index c48f8f83527a6..3f8e9c7097a07 100644 --- a/crates/bevy_reflect/src/serde/de/helpers.rs +++ b/crates/bevy_reflect/src/serde/de/helpers.rs @@ -7,8 +7,8 @@ use core::{ fmt::{Debug, Display, Formatter}, }; use serde::{ - de::{Error, Visitor}, Deserialize, + de::{Error, Visitor}, }; /// A debug struct used for error messages that displays a list of expected values. diff --git a/crates/bevy_reflect/src/serde/de/lists.rs b/crates/bevy_reflect/src/serde/de/lists.rs index b85e46874a335..1b8a5decb68bb 100644 --- a/crates/bevy_reflect/src/serde/de/lists.rs +++ b/crates/bevy_reflect/src/serde/de/lists.rs @@ -1,6 +1,6 @@ use crate::{ - serde::{de::registration_utils::try_get_registration, TypedReflectDeserializer}, DynamicList, ListInfo, TypeRegistry, + serde::{TypedReflectDeserializer, de::registration_utils::try_get_registration}, }; use core::{fmt, fmt::Formatter}; use serde::de::{SeqAccess, Visitor}; diff --git a/crates/bevy_reflect/src/serde/de/maps.rs b/crates/bevy_reflect/src/serde/de/maps.rs index 95b1c1f83e25b..b6c8664b82244 100644 --- a/crates/bevy_reflect/src/serde/de/maps.rs +++ b/crates/bevy_reflect/src/serde/de/maps.rs @@ -1,6 +1,6 @@ use crate::{ - serde::{de::registration_utils::try_get_registration, TypedReflectDeserializer}, DynamicMap, Map, MapInfo, TypeRegistry, + serde::{TypedReflectDeserializer, de::registration_utils::try_get_registration}, }; use core::{fmt, fmt::Formatter}; use serde::de::{MapAccess, Visitor}; diff --git a/crates/bevy_reflect/src/serde/de/mod.rs b/crates/bevy_reflect/src/serde/de/mod.rs index c6907b56ecbe3..5dec21e5b503e 100644 --- a/crates/bevy_reflect/src/serde/de/mod.rs +++ b/crates/bevy_reflect/src/serde/de/mod.rs @@ -32,18 +32,18 @@ mod tests { }; use bincode::Options; use core::{any::TypeId, f32::consts::PI, ops::RangeInclusive}; - use serde::{de::DeserializeSeed, Deserialize}; - use serde::{de::IgnoredAny, Deserializer}; + use serde::{Deserialize, de::DeserializeSeed}; + use serde::{Deserializer, de::IgnoredAny}; use bevy_platform_support::collections::{HashMap, HashSet}; use crate::{ + DynamicEnum, FromReflect, PartialReflect, Reflect, ReflectDeserialize, TypeRegistration, + TypeRegistry, serde::{ ReflectDeserializer, ReflectDeserializerProcessor, ReflectSerializer, TypedReflectDeserializer, }, - DynamicEnum, FromReflect, PartialReflect, Reflect, ReflectDeserialize, TypeRegistration, - TypeRegistry, }; #[derive(Reflect, Debug, PartialEq)] @@ -406,9 +406,11 @@ mod tests { let output = reflect_deserializer.deserialize(&mut deserializer).unwrap(); let expected = DynamicEnum::from(MyEnum::Tuple(1.23, 3.21)); - assert!(expected - .reflect_partial_eq(output.as_partial_reflect()) - .unwrap()); + assert!( + expected + .reflect_partial_eq(output.as_partial_reflect()) + .unwrap() + ); // === Struct Variant === // let input = r#"{ @@ -423,9 +425,11 @@ mod tests { let expected = DynamicEnum::from(MyEnum::Struct { value: String::from("I <3 Enums"), }); - assert!(expected - .reflect_partial_eq(output.as_partial_reflect()) - .unwrap()); + assert!( + expected + .reflect_partial_eq(output.as_partial_reflect()) + .unwrap() + ); } // Regression test for https://github.com/bevyengine/bevy/issues/12462 diff --git a/crates/bevy_reflect/src/serde/de/options.rs b/crates/bevy_reflect/src/serde/de/options.rs index f347c4a67d8e3..e65175b006c1e 100644 --- a/crates/bevy_reflect/src/serde/de/options.rs +++ b/crates/bevy_reflect/src/serde/de/options.rs @@ -1,9 +1,9 @@ use crate::{ + DynamicEnum, DynamicTuple, EnumInfo, TypeRegistry, VariantInfo, serde::{ - de::{error_utils::make_custom_error, registration_utils::try_get_registration}, TypedReflectDeserializer, + de::{error_utils::make_custom_error, registration_utils::try_get_registration}, }, - DynamicEnum, DynamicTuple, EnumInfo, TypeRegistry, VariantInfo, }; use core::{fmt, fmt::Formatter}; use serde::de::{DeserializeSeed, Error, Visitor}; diff --git a/crates/bevy_reflect/src/serde/de/registration_utils.rs b/crates/bevy_reflect/src/serde/de/registration_utils.rs index 0559af70afe55..0004535eda807 100644 --- a/crates/bevy_reflect/src/serde/de/registration_utils.rs +++ b/crates/bevy_reflect/src/serde/de/registration_utils.rs @@ -1,4 +1,4 @@ -use crate::{serde::de::error_utils::make_custom_error, Type, TypeRegistration, TypeRegistry}; +use crate::{Type, TypeRegistration, TypeRegistry, serde::de::error_utils::make_custom_error}; use serde::de::Error; /// Attempts to find the [`TypeRegistration`] for a given [type]. diff --git a/crates/bevy_reflect/src/serde/de/registrations.rs b/crates/bevy_reflect/src/serde/de/registrations.rs index adc0025c5489a..e44d754322713 100644 --- a/crates/bevy_reflect/src/serde/de/registrations.rs +++ b/crates/bevy_reflect/src/serde/de/registrations.rs @@ -1,4 +1,4 @@ -use crate::{serde::de::error_utils::make_custom_error, TypeRegistration, TypeRegistry}; +use crate::{TypeRegistration, TypeRegistry, serde::de::error_utils::make_custom_error}; use core::{fmt, fmt::Formatter}; use serde::de::{DeserializeSeed, Error, Visitor}; diff --git a/crates/bevy_reflect/src/serde/de/sets.rs b/crates/bevy_reflect/src/serde/de/sets.rs index ed1a469df3d7d..0a1d2f7c092a1 100644 --- a/crates/bevy_reflect/src/serde/de/sets.rs +++ b/crates/bevy_reflect/src/serde/de/sets.rs @@ -1,6 +1,6 @@ use crate::{ - serde::{de::registration_utils::try_get_registration, TypedReflectDeserializer}, DynamicSet, Set, SetInfo, TypeRegistry, + serde::{TypedReflectDeserializer, de::registration_utils::try_get_registration}, }; use core::{fmt, fmt::Formatter}; use serde::de::{SeqAccess, Visitor}; diff --git a/crates/bevy_reflect/src/serde/de/struct_utils.rs b/crates/bevy_reflect/src/serde/de/struct_utils.rs index 9ac56d9a4a88b..3fc38f2897768 100644 --- a/crates/bevy_reflect/src/serde/de/struct_utils.rs +++ b/crates/bevy_reflect/src/serde/de/struct_utils.rs @@ -1,13 +1,13 @@ use crate::{ + DynamicStruct, NamedField, StructInfo, StructVariantInfo, TypeRegistration, TypeRegistry, serde::{ + SerializationData, TypedReflectDeserializer, de::{ error_utils::make_custom_error, helpers::{ExpectedValues, Ident}, registration_utils::try_get_registration, }, - SerializationData, TypedReflectDeserializer, }, - DynamicStruct, NamedField, StructInfo, StructVariantInfo, TypeRegistration, TypeRegistry, }; use alloc::string::ToString; use core::slice::Iter; diff --git a/crates/bevy_reflect/src/serde/de/structs.rs b/crates/bevy_reflect/src/serde/de/structs.rs index 0135e96358580..0f0d8489d877d 100644 --- a/crates/bevy_reflect/src/serde/de/structs.rs +++ b/crates/bevy_reflect/src/serde/de/structs.rs @@ -1,6 +1,6 @@ use crate::{ - serde::de::struct_utils::{visit_struct, visit_struct_seq}, DynamicStruct, StructInfo, TypeRegistration, TypeRegistry, + serde::de::struct_utils::{visit_struct, visit_struct_seq}, }; use core::{fmt, fmt::Formatter}; use serde::de::{MapAccess, SeqAccess, Visitor}; diff --git a/crates/bevy_reflect/src/serde/de/tuple_structs.rs b/crates/bevy_reflect/src/serde/de/tuple_structs.rs index af33b8d0b3c33..e51fb769d32ff 100644 --- a/crates/bevy_reflect/src/serde/de/tuple_structs.rs +++ b/crates/bevy_reflect/src/serde/de/tuple_structs.rs @@ -1,11 +1,11 @@ use crate::{ - serde::{de::tuple_utils::visit_tuple, SerializationData}, DynamicTupleStruct, TupleStructInfo, TypeRegistration, TypeRegistry, + serde::{SerializationData, de::tuple_utils::visit_tuple}, }; use core::{fmt, fmt::Formatter}; use serde::de::{DeserializeSeed, SeqAccess, Visitor}; -use super::{registration_utils::try_get_registration, TypedReflectDeserializer}; +use super::{TypedReflectDeserializer, registration_utils::try_get_registration}; use super::ReflectDeserializerProcessor; diff --git a/crates/bevy_reflect/src/serde/de/tuple_utils.rs b/crates/bevy_reflect/src/serde/de/tuple_utils.rs index 13a65b4dd64ec..1eeb1f1e87aac 100644 --- a/crates/bevy_reflect/src/serde/de/tuple_utils.rs +++ b/crates/bevy_reflect/src/serde/de/tuple_utils.rs @@ -1,10 +1,10 @@ use crate::{ + DynamicTuple, TupleInfo, TupleStructInfo, TupleVariantInfo, TypeRegistration, TypeRegistry, + UnnamedField, serde::{ - de::{error_utils::make_custom_error, registration_utils::try_get_registration}, SerializationData, TypedReflectDeserializer, + de::{error_utils::make_custom_error, registration_utils::try_get_registration}, }, - DynamicTuple, TupleInfo, TupleStructInfo, TupleVariantInfo, TypeRegistration, TypeRegistry, - UnnamedField, }; use alloc::string::ToString; use serde::de::{Error, SeqAccess}; diff --git a/crates/bevy_reflect/src/serde/de/tuples.rs b/crates/bevy_reflect/src/serde/de/tuples.rs index 87b9fc81c9439..2bb3190d23e0c 100644 --- a/crates/bevy_reflect/src/serde/de/tuples.rs +++ b/crates/bevy_reflect/src/serde/de/tuples.rs @@ -1,5 +1,5 @@ use crate::{ - serde::de::tuple_utils::visit_tuple, DynamicTuple, TupleInfo, TypeRegistration, TypeRegistry, + DynamicTuple, TupleInfo, TypeRegistration, TypeRegistry, serde::de::tuple_utils::visit_tuple, }; use core::{fmt, fmt::Formatter}; use serde::de::{SeqAccess, Visitor}; diff --git a/crates/bevy_reflect/src/serde/mod.rs b/crates/bevy_reflect/src/serde/mod.rs index c31d97456679f..6b3fdeaaa23b1 100644 --- a/crates/bevy_reflect/src/serde/mod.rs +++ b/crates/bevy_reflect/src/serde/mod.rs @@ -10,8 +10,8 @@ pub use type_data::*; mod tests { use super::*; use crate::{ - type_registry::TypeRegistry, DynamicStruct, DynamicTupleStruct, FromReflect, - PartialReflect, Reflect, Struct, + DynamicStruct, DynamicTupleStruct, FromReflect, PartialReflect, Reflect, Struct, + type_registry::TypeRegistry, }; use serde::de::DeserializeSeed; @@ -178,9 +178,11 @@ mod tests { let expected = value.clone_value(); let result = reflect_deserializer.deserialize(&mut deserializer).unwrap(); - assert!(expected - .reflect_partial_eq(result.as_partial_reflect()) - .unwrap()); + assert!( + expected + .reflect_partial_eq(result.as_partial_reflect()) + .unwrap() + ); } mod type_data { diff --git a/crates/bevy_reflect/src/serde/ser/arrays.rs b/crates/bevy_reflect/src/serde/ser/arrays.rs index 9d565344aeb44..563d0b4027deb 100644 --- a/crates/bevy_reflect/src/serde/ser/arrays.rs +++ b/crates/bevy_reflect/src/serde/ser/arrays.rs @@ -1,5 +1,5 @@ -use crate::{serde::TypedReflectSerializer, Array, TypeRegistry}; -use serde::{ser::SerializeTuple, Serialize}; +use crate::{Array, TypeRegistry, serde::TypedReflectSerializer}; +use serde::{Serialize, ser::SerializeTuple}; use super::ReflectSerializerProcessor; diff --git a/crates/bevy_reflect/src/serde/ser/custom_serialization.rs b/crates/bevy_reflect/src/serde/ser/custom_serialization.rs index 18d2abed9c010..0d7794d376a3f 100644 --- a/crates/bevy_reflect/src/serde/ser/custom_serialization.rs +++ b/crates/bevy_reflect/src/serde/ser/custom_serialization.rs @@ -1,7 +1,7 @@ -use crate::serde::ser::error_utils::make_custom_error; +use crate::serde::ReflectSerializeWithRegistry; #[cfg(feature = "debug_stack")] use crate::serde::ser::error_utils::TYPE_INFO_STACK; -use crate::serde::ReflectSerializeWithRegistry; +use crate::serde::ser::error_utils::make_custom_error; use crate::{PartialReflect, ReflectSerialize, TypeRegistry}; use core::borrow::Borrow; use serde::{Serialize, Serializer}; @@ -54,9 +54,12 @@ pub(super) fn try_custom_serialize( Ok(reflect_serialize_with_registry.serialize(value, serializer, type_registry)) } else { - Err((serializer, make_custom_error(format_args!( - "type `{}` did not register the `ReflectSerialize` or `ReflectSerializeWithRegistry` type data. For certain types, this may need to be registered manually using `register_type_data`", - info.type_path(), - )))) + Err(( + serializer, + make_custom_error(format_args!( + "type `{}` did not register the `ReflectSerialize` or `ReflectSerializeWithRegistry` type data. For certain types, this may need to be registered manually using `register_type_data`", + info.type_path(), + )), + )) } } diff --git a/crates/bevy_reflect/src/serde/ser/enums.rs b/crates/bevy_reflect/src/serde/ser/enums.rs index 86c4360ce037b..29d1c7466456f 100644 --- a/crates/bevy_reflect/src/serde/ser/enums.rs +++ b/crates/bevy_reflect/src/serde/ser/enums.rs @@ -1,10 +1,10 @@ use crate::{ - serde::{ser::error_utils::make_custom_error, TypedReflectSerializer}, Enum, TypeInfo, TypeRegistry, VariantInfo, VariantType, + serde::{TypedReflectSerializer, ser::error_utils::make_custom_error}, }; use serde::{ - ser::{SerializeStructVariant, SerializeTupleVariant}, Serialize, + ser::{SerializeStructVariant, SerializeTupleVariant}, }; use super::ReflectSerializerProcessor; diff --git a/crates/bevy_reflect/src/serde/ser/lists.rs b/crates/bevy_reflect/src/serde/ser/lists.rs index 4c3fb6b33dd25..42d8e87122e87 100644 --- a/crates/bevy_reflect/src/serde/ser/lists.rs +++ b/crates/bevy_reflect/src/serde/ser/lists.rs @@ -1,5 +1,5 @@ -use crate::{serde::TypedReflectSerializer, List, TypeRegistry}; -use serde::{ser::SerializeSeq, Serialize}; +use crate::{List, TypeRegistry, serde::TypedReflectSerializer}; +use serde::{Serialize, ser::SerializeSeq}; use super::ReflectSerializerProcessor; diff --git a/crates/bevy_reflect/src/serde/ser/maps.rs b/crates/bevy_reflect/src/serde/ser/maps.rs index c1a8c287c1b3f..8ba1dd8cfedca 100644 --- a/crates/bevy_reflect/src/serde/ser/maps.rs +++ b/crates/bevy_reflect/src/serde/ser/maps.rs @@ -1,5 +1,5 @@ -use crate::{serde::TypedReflectSerializer, Map, TypeRegistry}; -use serde::{ser::SerializeMap, Serialize}; +use crate::{Map, TypeRegistry, serde::TypedReflectSerializer}; +use serde::{Serialize, ser::SerializeMap}; use super::ReflectSerializerProcessor; diff --git a/crates/bevy_reflect/src/serde/ser/mod.rs b/crates/bevy_reflect/src/serde/ser/mod.rs index 6cfebc747f285..8f402ea2874c9 100644 --- a/crates/bevy_reflect/src/serde/ser/mod.rs +++ b/crates/bevy_reflect/src/serde/ser/mod.rs @@ -21,8 +21,8 @@ mod tuples; #[cfg(test)] mod tests { use crate::{ - serde::{ReflectSerializer, ReflectSerializerProcessor}, PartialReflect, Reflect, ReflectSerialize, Struct, TypeRegistry, + serde::{ReflectSerializer, ReflectSerializerProcessor}, }; use alloc::{ boxed::Box, diff --git a/crates/bevy_reflect/src/serde/ser/serializer.rs b/crates/bevy_reflect/src/serde/ser/serializer.rs index afe6b56b1dfaf..f174660d89ade 100644 --- a/crates/bevy_reflect/src/serde/ser/serializer.rs +++ b/crates/bevy_reflect/src/serde/ser/serializer.rs @@ -1,15 +1,15 @@ #[cfg(feature = "debug_stack")] use crate::serde::ser::error_utils::TYPE_INFO_STACK; use crate::{ + PartialReflect, ReflectRef, TypeRegistry, serde::ser::{ arrays::ArraySerializer, custom_serialization::try_custom_serialize, enums::EnumSerializer, error_utils::make_custom_error, lists::ListSerializer, maps::MapSerializer, sets::SetSerializer, structs::StructSerializer, tuple_structs::TupleStructSerializer, tuples::TupleSerializer, }, - PartialReflect, ReflectRef, TypeRegistry, }; -use serde::{ser::SerializeMap, Serialize, Serializer}; +use serde::{Serialize, Serializer, ser::SerializeMap}; use super::ReflectSerializerProcessor; diff --git a/crates/bevy_reflect/src/serde/ser/sets.rs b/crates/bevy_reflect/src/serde/ser/sets.rs index 34e8899d58c95..45f2949fe8491 100644 --- a/crates/bevy_reflect/src/serde/ser/sets.rs +++ b/crates/bevy_reflect/src/serde/ser/sets.rs @@ -1,5 +1,5 @@ -use crate::{serde::TypedReflectSerializer, Set, TypeRegistry}; -use serde::{ser::SerializeSeq, Serialize}; +use crate::{Set, TypeRegistry, serde::TypedReflectSerializer}; +use serde::{Serialize, ser::SerializeSeq}; use super::ReflectSerializerProcessor; diff --git a/crates/bevy_reflect/src/serde/ser/structs.rs b/crates/bevy_reflect/src/serde/ser/structs.rs index 828eb3e6cb829..5d40f80095d2e 100644 --- a/crates/bevy_reflect/src/serde/ser/structs.rs +++ b/crates/bevy_reflect/src/serde/ser/structs.rs @@ -1,8 +1,8 @@ use crate::{ - serde::{ser::error_utils::make_custom_error, SerializationData, TypedReflectSerializer}, Struct, TypeInfo, TypeRegistry, + serde::{SerializationData, TypedReflectSerializer, ser::error_utils::make_custom_error}, }; -use serde::{ser::SerializeStruct, Serialize}; +use serde::{Serialize, ser::SerializeStruct}; use super::ReflectSerializerProcessor; diff --git a/crates/bevy_reflect/src/serde/ser/tuple_structs.rs b/crates/bevy_reflect/src/serde/ser/tuple_structs.rs index 00554c0a86694..73d6070f87692 100644 --- a/crates/bevy_reflect/src/serde/ser/tuple_structs.rs +++ b/crates/bevy_reflect/src/serde/ser/tuple_structs.rs @@ -1,8 +1,8 @@ use crate::{ - serde::{ser::error_utils::make_custom_error, SerializationData, TypedReflectSerializer}, TupleStruct, TypeInfo, TypeRegistry, + serde::{SerializationData, TypedReflectSerializer, ser::error_utils::make_custom_error}, }; -use serde::{ser::SerializeTupleStruct, Serialize}; +use serde::{Serialize, ser::SerializeTupleStruct}; use super::ReflectSerializerProcessor; diff --git a/crates/bevy_reflect/src/serde/ser/tuples.rs b/crates/bevy_reflect/src/serde/ser/tuples.rs index 195d1e492d76b..5e1b02109af68 100644 --- a/crates/bevy_reflect/src/serde/ser/tuples.rs +++ b/crates/bevy_reflect/src/serde/ser/tuples.rs @@ -1,5 +1,5 @@ -use crate::{serde::TypedReflectSerializer, Tuple, TypeRegistry}; -use serde::{ser::SerializeTuple, Serialize}; +use crate::{Tuple, TypeRegistry, serde::TypedReflectSerializer}; +use serde::{Serialize, ser::SerializeTuple}; use super::ReflectSerializerProcessor; diff --git a/crates/bevy_reflect/src/serde/type_data.rs b/crates/bevy_reflect/src/serde/type_data.rs index 8df80c700f100..cc3c5ad881546 100644 --- a/crates/bevy_reflect/src/serde/type_data.rs +++ b/crates/bevy_reflect/src/serde/type_data.rs @@ -1,6 +1,6 @@ use crate::Reflect; use alloc::boxed::Box; -use bevy_platform_support::collections::{hash_map::Iter, HashMap}; +use bevy_platform_support::collections::{HashMap, hash_map::Iter}; /// Contains data relevant to the automatic reflect powered (de)serialization of a type. #[derive(Debug, Clone)] diff --git a/crates/bevy_reflect/src/set.rs b/crates/bevy_reflect/src/set.rs index 799499a8adcd7..98db4a775d43e 100644 --- a/crates/bevy_reflect/src/set.rs +++ b/crates/bevy_reflect/src/set.rs @@ -2,14 +2,14 @@ use alloc::{boxed::Box, format, vec::Vec}; use core::fmt::{Debug, Formatter}; use bevy_platform_support::collections::{ - hash_table::OccupiedEntry as HashTableOccupiedEntry, HashTable, + HashTable, hash_table::OccupiedEntry as HashTableOccupiedEntry, }; use bevy_reflect_derive::impl_type_path; use crate::{ - generics::impl_generic_info_methods, hash_error, type_info::impl_type_methods, ApplyError, - Generics, PartialReflect, Reflect, ReflectKind, ReflectMut, ReflectOwned, ReflectRef, Type, - TypeInfo, TypePath, + ApplyError, Generics, PartialReflect, Reflect, ReflectKind, ReflectMut, ReflectOwned, + ReflectRef, Type, TypeInfo, TypePath, generics::impl_generic_info_methods, hash_error, + type_info::impl_type_methods, }; /// A trait used to power [set-like] operations via [reflection]. diff --git a/crates/bevy_reflect/src/struct_trait.rs b/crates/bevy_reflect/src/struct_trait.rs index dc7ed55cefef3..71ab1be571862 100644 --- a/crates/bevy_reflect/src/struct_trait.rs +++ b/crates/bevy_reflect/src/struct_trait.rs @@ -1,9 +1,9 @@ use crate::generics::impl_generic_info_methods; use crate::{ - attributes::{impl_custom_attribute_methods, CustomAttributes}, - type_info::impl_type_methods, ApplyError, Generics, NamedField, PartialReflect, Reflect, ReflectKind, ReflectMut, ReflectOwned, ReflectRef, Type, TypeInfo, TypePath, + attributes::{CustomAttributes, impl_custom_attribute_methods}, + type_info::impl_type_methods, }; use alloc::{borrow::Cow, boxed::Box, vec::Vec}; use bevy_platform_support::collections::HashMap; diff --git a/crates/bevy_reflect/src/tuple.rs b/crates/bevy_reflect/src/tuple.rs index 28f95b6886cd8..ce535a43bcef3 100644 --- a/crates/bevy_reflect/src/tuple.rs +++ b/crates/bevy_reflect/src/tuple.rs @@ -3,10 +3,9 @@ use variadics_please::all_tuples; use crate::generics::impl_generic_info_methods; use crate::{ - type_info::impl_type_methods, utility::GenericTypePathCell, ApplyError, FromReflect, Generics, - GetTypeRegistration, MaybeTyped, PartialReflect, Reflect, ReflectKind, ReflectMut, - ReflectOwned, ReflectRef, Type, TypeInfo, TypePath, TypeRegistration, TypeRegistry, Typed, - UnnamedField, + ApplyError, FromReflect, Generics, GetTypeRegistration, MaybeTyped, PartialReflect, Reflect, + ReflectKind, ReflectMut, ReflectOwned, ReflectRef, Type, TypeInfo, TypePath, TypeRegistration, + TypeRegistry, Typed, UnnamedField, type_info::impl_type_methods, utility::GenericTypePathCell, }; use alloc::{boxed::Box, vec, vec::Vec}; use core::{ diff --git a/crates/bevy_reflect/src/tuple_struct.rs b/crates/bevy_reflect/src/tuple_struct.rs index 8348ca7740861..cd58f0f38a795 100644 --- a/crates/bevy_reflect/src/tuple_struct.rs +++ b/crates/bevy_reflect/src/tuple_struct.rs @@ -2,10 +2,10 @@ use bevy_reflect_derive::impl_type_path; use crate::generics::impl_generic_info_methods; use crate::{ - attributes::{impl_custom_attribute_methods, CustomAttributes}, - type_info::impl_type_methods, ApplyError, DynamicTuple, Generics, PartialReflect, Reflect, ReflectKind, ReflectMut, ReflectOwned, ReflectRef, Tuple, Type, TypeInfo, TypePath, UnnamedField, + attributes::{CustomAttributes, impl_custom_attribute_methods}, + type_info::impl_type_methods, }; use alloc::{boxed::Box, vec::Vec}; use bevy_platform_support::sync::Arc; diff --git a/crates/bevy_reflect/src/type_registry.rs b/crates/bevy_reflect/src/type_registry.rs index cf80749edebbb..e6bd3c2082947 100644 --- a/crates/bevy_reflect/src/type_registry.rs +++ b/crates/bevy_reflect/src/type_registry.rs @@ -1,4 +1,4 @@ -use crate::{serde::Serializable, FromReflect, Reflect, TypeInfo, TypePath, Typed}; +use crate::{FromReflect, Reflect, TypeInfo, TypePath, Typed, serde::Serializable}; use alloc::{boxed::Box, string::String}; use bevy_platform_support::{ collections::{HashMap, HashSet}, @@ -11,7 +11,7 @@ use core::{ fmt::Debug, ops::{Deref, DerefMut}, }; -use downcast_rs::{impl_downcast, Downcast}; +use downcast_rs::{Downcast, impl_downcast}; use serde::Deserialize; /// A registry of [reflected] types. diff --git a/crates/bevy_remote/src/builtin_methods.rs b/crates/bevy_remote/src/builtin_methods.rs index 80dc592d9a525..44366af25e9ff 100644 --- a/crates/bevy_remote/src/builtin_methods.rs +++ b/crates/bevy_remote/src/builtin_methods.rs @@ -2,7 +2,7 @@ use core::any::TypeId; -use anyhow::{anyhow, Result as AnyhowResult}; +use anyhow::{Result as AnyhowResult, anyhow}; use bevy_ecs::{ component::ComponentId, entity::Entity, @@ -16,15 +16,15 @@ use bevy_ecs::{ }; use bevy_platform_support::collections::HashMap; use bevy_reflect::{ - prelude::ReflectDefault, - serde::{ReflectSerializer, TypedReflectDeserializer}, GetPath as _, NamedField, OpaqueInfo, PartialReflect, ReflectDeserialize, ReflectSerialize, TypeInfo, TypeRegistration, TypeRegistry, VariantInfo, + prelude::ReflectDefault, + serde::{ReflectSerializer, TypedReflectDeserializer}, }; -use serde::{de::DeserializeSeed as _, Deserialize, Serialize}; -use serde_json::{json, Map, Value}; +use serde::{Deserialize, Serialize, de::DeserializeSeed as _}; +use serde_json::{Map, Value, json}; -use crate::{error_codes, BrpError, BrpResult}; +use crate::{BrpError, BrpResult, error_codes}; /// The method path for a `bevy/get` request. pub const BRP_GET_METHOD: &str = "bevy/get"; diff --git a/crates/bevy_remote/src/http.rs b/crates/bevy_remote/src/http.rs index 4e36e4a0bfe94..c4aa8f945ee62 100644 --- a/crates/bevy_remote/src/http.rs +++ b/crates/bevy_remote/src/http.rs @@ -9,7 +9,7 @@ #![cfg(not(target_family = "wasm"))] use crate::{ - error_codes, BrpBatch, BrpError, BrpMessage, BrpRequest, BrpResponse, BrpResult, BrpSender, + BrpBatch, BrpError, BrpMessage, BrpRequest, BrpResponse, BrpResult, BrpSender, error_codes, }; use anyhow::Result as AnyhowResult; use async_channel::{Receiver, Sender}; @@ -17,7 +17,7 @@ use async_io::Async; use bevy_app::{App, Plugin, Startup}; use bevy_ecs::resource::Resource; use bevy_ecs::system::Res; -use bevy_tasks::{futures_lite::StreamExt, IoTaskPool}; +use bevy_tasks::{IoTaskPool, futures_lite::StreamExt}; use core::{ convert::Infallible, net::{IpAddr, Ipv4Addr}, @@ -26,10 +26,11 @@ use core::{ }; use http_body_util::{BodyExt as _, Full}; use hyper::{ + Request, Response, body::{Body, Bytes, Frame, Incoming}, header::{HeaderName, HeaderValue}, server::conn::http1, - service, Request, Response, + service, }; use serde_json::Value; use smol_hyper::rt::{FuturesIo, SmolTimer}; diff --git a/crates/bevy_remote/src/lib.rs b/crates/bevy_remote/src/lib.rs index 75ba79d58e8da..7959308fac40f 100644 --- a/crates/bevy_remote/src/lib.rs +++ b/crates/bevy_remote/src/lib.rs @@ -319,7 +319,7 @@ //! [fully-qualified type name]: bevy_reflect::TypePath::type_path use async_channel::{Receiver, Sender}; -use bevy_app::{prelude::*, MainScheduleOrder}; +use bevy_app::{MainScheduleOrder, prelude::*}; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::{ entity::Entity, diff --git a/crates/bevy_render/macros/src/as_bind_group.rs b/crates/bevy_render/macros/src/as_bind_group.rs index 47cf8b7ce8aef..f470c324bbbca 100644 --- a/crates/bevy_render/macros/src/as_bind_group.rs +++ b/crates/bevy_render/macros/src/as_bind_group.rs @@ -1,13 +1,12 @@ -use bevy_macro_utils::{get_lit_bool, get_lit_str, BevyManifest, Symbol}; +use bevy_macro_utils::{BevyManifest, Symbol, get_lit_bool, get_lit_str}; use proc_macro::TokenStream; use proc_macro2::{Ident, Span}; -use quote::{quote, ToTokens}; +use quote::{ToTokens, quote}; use syn::{ - parenthesized, + Data, DataStruct, Error, Fields, LitInt, LitStr, Meta, MetaList, Result, parenthesized, parse::{Parse, ParseStream}, punctuated::Punctuated, token::Comma, - Data, DataStruct, Error, Fields, LitInt, LitStr, Meta, MetaList, Result, }; const UNIFORM_ATTRIBUTE_NAME: Symbol = Symbol("uniform"); @@ -309,13 +308,17 @@ pub fn derive_as_bind_group(ast: syn::DeriveInput) -> Result { } => { return Err(Error::new_spanned( attr, - format!("The '{field_name}' field cannot be assigned to binding {binding_index} because it is already occupied by the field '{occupied_ident}' of type {binding_type:?}.") + format!( + "The '{field_name}' field cannot be assigned to binding {binding_index} because it is already occupied by the field '{occupied_ident}' of type {binding_type:?}." + ), )); } BindingState::OccupiedConvertedUniform => { return Err(Error::new_spanned( attr, - format!("The '{field_name}' field cannot be assigned to binding {binding_index} because it is already occupied by a struct-level uniform binding at the same index.") + format!( + "The '{field_name}' field cannot be assigned to binding {binding_index} because it is already occupied by a struct-level uniform binding at the same index." + ), )); } BindingState::OccupiedMergeableUniform { uniform_fields } => match binding_type { @@ -324,9 +327,12 @@ pub fn derive_as_bind_group(ast: syn::DeriveInput) -> Result { } _ => { return Err(Error::new_spanned( - attr, - format!("The '{field_name}' field cannot be assigned to binding {binding_index} because it is already occupied by a {:?}.", BindingType::Uniform) - )); + attr, + format!( + "The '{field_name}' field cannot be assigned to binding {binding_index} because it is already occupied by a {:?}.", + BindingType::Uniform + ), + )); } }, } @@ -1183,7 +1189,7 @@ fn get_visibility_flag_value(meta_list: &MetaList) -> Result Result) -> Result { NameValue(m) => { return Err(Error::new_spanned( m.path, - "Not a valid name. Available attributes: `dimension`, `sample_type`, `multisampled`, or `filterable`." + "Not a valid name. Available attributes: `dimension`, `sample_type`, `multisampled`, or `filterable`.", )); } _ => { diff --git a/crates/bevy_render/macros/src/extract_component.rs b/crates/bevy_render/macros/src/extract_component.rs index 2bfd0e0e11133..9033b5820f373 100644 --- a/crates/bevy_render/macros/src/extract_component.rs +++ b/crates/bevy_render/macros/src/extract_component.rs @@ -1,6 +1,6 @@ use proc_macro::TokenStream; use quote::quote; -use syn::{parse_macro_input, parse_quote, DeriveInput, Path}; +use syn::{DeriveInput, Path, parse_macro_input, parse_quote}; pub fn derive_extract_component(input: TokenStream) -> TokenStream { let mut ast = parse_macro_input!(input as DeriveInput); diff --git a/crates/bevy_render/macros/src/extract_resource.rs b/crates/bevy_render/macros/src/extract_resource.rs index 0a35eb4d5dd2b..45cd2447a2f1a 100644 --- a/crates/bevy_render/macros/src/extract_resource.rs +++ b/crates/bevy_render/macros/src/extract_resource.rs @@ -1,6 +1,6 @@ use proc_macro::TokenStream; use quote::quote; -use syn::{parse_macro_input, parse_quote, DeriveInput, Path}; +use syn::{DeriveInput, Path, parse_macro_input, parse_quote}; pub fn derive_extract_resource(input: TokenStream) -> TokenStream { let mut ast = parse_macro_input!(input as DeriveInput); diff --git a/crates/bevy_render/macros/src/lib.rs b/crates/bevy_render/macros/src/lib.rs index 15b1add6b23b8..66a82d5c2cfd8 100644 --- a/crates/bevy_render/macros/src/lib.rs +++ b/crates/bevy_render/macros/src/lib.rs @@ -5,10 +5,10 @@ mod as_bind_group; mod extract_component; mod extract_resource; -use bevy_macro_utils::{derive_label, BevyManifest}; +use bevy_macro_utils::{BevyManifest, derive_label}; use proc_macro::TokenStream; use quote::format_ident; -use syn::{parse_macro_input, DeriveInput}; +use syn::{DeriveInput, parse_macro_input}; pub(crate) fn bevy_render_path() -> syn::Path { BevyManifest::shared().get_path("bevy_render") diff --git a/crates/bevy_render/src/alpha.rs b/crates/bevy_render/src/alpha.rs index 12e1377eabaab..cd08b1405fc4e 100644 --- a/crates/bevy_render/src/alpha.rs +++ b/crates/bevy_render/src/alpha.rs @@ -1,4 +1,4 @@ -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; // TODO: add discussion about performance. /// Sets how a material's base color alpha channel is used for transparency. diff --git a/crates/bevy_render/src/batching/gpu_preprocessing.rs b/crates/bevy_render/src/batching/gpu_preprocessing.rs index 3e29f72ba5840..c733170e21d20 100644 --- a/crates/bevy_render/src/batching/gpu_preprocessing.rs +++ b/crates/bevy_render/src/batching/gpu_preprocessing.rs @@ -14,16 +14,17 @@ use bevy_ecs::{ }; use bevy_encase_derive::ShaderType; use bevy_math::UVec4; -use bevy_platform_support::collections::{hash_map::Entry, HashMap, HashSet}; -use bevy_utils::{default, TypeIdMap}; +use bevy_platform_support::collections::{HashMap, HashSet, hash_map::Entry}; +use bevy_utils::{TypeIdMap, default}; use bytemuck::{Pod, Zeroable}; -use encase::{internal::WriteInto, ShaderSize}; +use encase::{ShaderSize, internal::WriteInto}; use indexmap::IndexMap; use nonmax::NonMaxU32; use tracing::error; use wgpu::{BindingResource, BufferUsages, DownlevelFlags, Features}; use crate::{ + Render, RenderApp, RenderDebugFlags, RenderSet, experimental::occlusion_culling::OcclusionCulling, render_phase::{ BinnedPhaseItem, BinnedRenderPhaseBatch, BinnedRenderPhaseBatchSet, @@ -36,7 +37,6 @@ use crate::{ renderer::{RenderAdapter, RenderDevice, RenderQueue}, sync_world::MainEntity, view::{ExtractedView, NoIndirectDrawing, RetainedViewEntity}, - Render, RenderApp, RenderDebugFlags, RenderSet, }; use super::{BatchMeta, GetBatchData, GetFullBatchData}; diff --git a/crates/bevy_render/src/batching/no_gpu_preprocessing.rs b/crates/bevy_render/src/batching/no_gpu_preprocessing.rs index 8bbbff8dd9e46..2af406967882c 100644 --- a/crates/bevy_render/src/batching/no_gpu_preprocessing.rs +++ b/crates/bevy_render/src/batching/no_gpu_preprocessing.rs @@ -4,7 +4,7 @@ use bevy_derive::{Deref, DerefMut}; use bevy_ecs::entity::Entity; use bevy_ecs::resource::Resource; use bevy_ecs::system::{Res, ResMut, StaticSystemParam}; -use smallvec::{smallvec, SmallVec}; +use smallvec::{SmallVec, smallvec}; use tracing::error; use wgpu::BindingResource; diff --git a/crates/bevy_render/src/camera/camera.rs b/crates/bevy_render/src/camera/camera.rs index 298be27c5fa9e..67f34b3a6d411 100644 --- a/crates/bevy_render/src/camera/camera.rs +++ b/crates/bevy_render/src/camera/camera.rs @@ -4,6 +4,7 @@ )] use super::{ClearColorConfig, Projection}; use crate::{ + Extract, batching::gpu_preprocessing::{GpuPreprocessingMode, GpuPreprocessingSupport}, camera::{CameraProjection, ManualTextureViewHandle, ManualTextureViews}, primitives::Frustum, @@ -16,7 +17,6 @@ use crate::{ ColorGrading, ExtractedView, ExtractedWindows, Msaa, NoIndirectDrawing, RenderLayers, RenderVisibleEntities, RetainedViewEntity, ViewUniformOffset, Visibility, VisibleEntities, }, - Extract, }; use bevy_asset::{AssetEvent, AssetId, Assets, Handle}; use bevy_derive::{Deref, DerefMut}; @@ -25,7 +25,7 @@ use bevy_ecs::{ component::{Component, HookContext}, entity::{Entity, EntityBorrow}, event::EventReader, - prelude::{require, With}, + prelude::{With, require}, query::Has, reflect::ReflectComponent, resource::Resource, @@ -33,7 +33,7 @@ use bevy_ecs::{ world::DeferredWorld, }; use bevy_image::Image; -use bevy_math::{ops, vec2, Dir3, FloatOrd, Mat4, Ray3d, Rect, URect, UVec2, UVec4, Vec2, Vec3}; +use bevy_math::{Dir3, FloatOrd, Mat4, Ray3d, Rect, URect, UVec2, UVec4, Vec2, Vec3, ops, vec2}; use bevy_platform_support::collections::{HashMap, HashSet}; use bevy_reflect::prelude::*; use bevy_render_macros::ExtractComponent; @@ -334,7 +334,12 @@ pub struct Camera { fn warn_on_no_render_graph(world: DeferredWorld, HookContext { entity, caller, .. }: HookContext) { if !world.entity(entity).contains::() { - warn!("{}Entity {entity} has a `Camera` component, but it doesn't have a render graph configured. Consider adding a `Camera2d` or `Camera3d` component, or manually adding a `CameraRenderGraph` component if you need a custom render graph.", caller.map(|location|format!("{location}: ")).unwrap_or_default()); + warn!( + "{}Entity {entity} has a `Camera` component, but it doesn't have a render graph configured. Consider adding a `Camera2d` or `Camera3d` component, or manually adding a `CameraRenderGraph` component if you need a custom render graph.", + caller + .map(|location| format!("{location}: ")) + .unwrap_or_default() + ); } } diff --git a/crates/bevy_render/src/camera/mod.rs b/crates/bevy_render/src/camera/mod.rs index 9b3c6907f60fc..db91f2a4f33c2 100644 --- a/crates/bevy_render/src/camera/mod.rs +++ b/crates/bevy_render/src/camera/mod.rs @@ -11,8 +11,8 @@ pub use manual_texture_view::*; pub use projection::*; use crate::{ - extract_component::ExtractComponentPlugin, extract_resource::ExtractResourcePlugin, - render_graph::RenderGraph, ExtractSchedule, Render, RenderApp, RenderSet, + ExtractSchedule, Render, RenderApp, RenderSet, extract_component::ExtractComponentPlugin, + extract_resource::ExtractResourcePlugin, render_graph::RenderGraph, }; use bevy_app::{App, Plugin}; use bevy_ecs::schedule::IntoSystemConfigs; diff --git a/crates/bevy_render/src/camera/projection.rs b/crates/bevy_render/src/camera/projection.rs index 2b75dab047247..543bad15e4441 100644 --- a/crates/bevy_render/src/camera/projection.rs +++ b/crates/bevy_render/src/camera/projection.rs @@ -5,9 +5,9 @@ use bevy_app::{App, Plugin, PostStartup, PostUpdate}; use bevy_asset::AssetEvents; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::prelude::*; -use bevy_math::{ops, AspectRatio, Mat4, Rect, Vec2, Vec3A, Vec4}; -use bevy_reflect::{std_traits::ReflectDefault, Reflect, ReflectDeserialize, ReflectSerialize}; -use bevy_transform::{components::GlobalTransform, TransformSystem}; +use bevy_math::{AspectRatio, Mat4, Rect, Vec2, Vec3A, Vec4, ops}; +use bevy_reflect::{Reflect, ReflectDeserialize, ReflectSerialize, std_traits::ReflectDefault}; +use bevy_transform::{TransformSystem, components::GlobalTransform}; use derive_more::derive::From; use serde::{Deserialize, Serialize}; diff --git a/crates/bevy_render/src/diagnostic/mod.rs b/crates/bevy_render/src/diagnostic/mod.rs index 09b6052c10ebe..353d32b15a43a 100644 --- a/crates/bevy_render/src/diagnostic/mod.rs +++ b/crates/bevy_render/src/diagnostic/mod.rs @@ -12,7 +12,7 @@ use bevy_app::{App, Plugin, PreUpdate}; use crate::RenderApp; use self::internal::{ - sync_diagnostics, DiagnosticsRecorder, Pass, RenderDiagnosticsMutex, WriteTimestamp, + DiagnosticsRecorder, Pass, RenderDiagnosticsMutex, WriteTimestamp, sync_diagnostics, }; use super::{RenderDevice, RenderQueue}; diff --git a/crates/bevy_render/src/experimental/occlusion_culling/mod.rs b/crates/bevy_render/src/experimental/occlusion_culling/mod.rs index 6bdfb4a102bf7..1bdbbf0ecd7a5 100644 --- a/crates/bevy_render/src/experimental/occlusion_culling/mod.rs +++ b/crates/bevy_render/src/experimental/occlusion_culling/mod.rs @@ -4,9 +4,9 @@ //! Bevy. use bevy_app::{App, Plugin}; -use bevy_asset::{load_internal_asset, weak_handle, Handle}; +use bevy_asset::{Handle, load_internal_asset, weak_handle}; use bevy_ecs::{component::Component, entity::Entity, prelude::ReflectComponent}; -use bevy_reflect::{prelude::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, prelude::ReflectDefault}; use crate::{ extract_component::ExtractComponent, diff --git a/crates/bevy_render/src/extract_component.rs b/crates/bevy_render/src/extract_component.rs index f77199842828c..75d9a4a24dd03 100644 --- a/crates/bevy_render/src/extract_component.rs +++ b/crates/bevy_render/src/extract_component.rs @@ -1,10 +1,10 @@ use crate::{ - render_resource::{encase::internal::WriteInto, DynamicUniformBuffer, ShaderType}, + Extract, ExtractSchedule, Render, RenderApp, RenderSet, + render_resource::{DynamicUniformBuffer, ShaderType, encase::internal::WriteInto}, renderer::{RenderDevice, RenderQueue}, sync_component::SyncComponentPlugin, sync_world::RenderEntity, view::ViewVisibility, - Extract, ExtractSchedule, Render, RenderApp, RenderSet, }; use bevy_app::{App, Plugin}; use bevy_ecs::{ diff --git a/crates/bevy_render/src/extract_instances.rs b/crates/bevy_render/src/extract_instances.rs index a8e5a9ecbdf92..fedcd3b3ed8a5 100644 --- a/crates/bevy_render/src/extract_instances.rs +++ b/crates/bevy_render/src/extract_instances.rs @@ -16,7 +16,7 @@ use bevy_ecs::{ }; use crate::sync_world::MainEntityHashMap; -use crate::{prelude::ViewVisibility, Extract, ExtractSchedule, RenderApp}; +use crate::{Extract, ExtractSchedule, RenderApp, prelude::ViewVisibility}; /// Describes how to extract data needed for rendering from a component or /// components. diff --git a/crates/bevy_render/src/globals.rs b/crates/bevy_render/src/globals.rs index b21b37ab8d963..a209654ac3c82 100644 --- a/crates/bevy_render/src/globals.rs +++ b/crates/bevy_render/src/globals.rs @@ -1,12 +1,12 @@ use crate::{ + Extract, ExtractSchedule, Render, RenderApp, RenderSet, extract_resource::ExtractResource, prelude::Shader, render_resource::{ShaderType, UniformBuffer}, renderer::{RenderDevice, RenderQueue}, - Extract, ExtractSchedule, Render, RenderApp, RenderSet, }; use bevy_app::{App, Plugin}; -use bevy_asset::{load_internal_asset, weak_handle, Handle}; +use bevy_asset::{Handle, load_internal_asset, weak_handle}; use bevy_diagnostic::FrameCount; use bevy_ecs::prelude::*; use bevy_reflect::prelude::*; diff --git a/crates/bevy_render/src/gpu_component_array_buffer.rs b/crates/bevy_render/src/gpu_component_array_buffer.rs index ac0f471a4a235..c3edc5c38393d 100644 --- a/crates/bevy_render/src/gpu_component_array_buffer.rs +++ b/crates/bevy_render/src/gpu_component_array_buffer.rs @@ -1,7 +1,7 @@ use crate::{ + Render, RenderApp, RenderSet, render_resource::{GpuArrayBuffer, GpuArrayBufferable}, renderer::{RenderDevice, RenderQueue}, - Render, RenderApp, RenderSet, }; use bevy_app::{App, Plugin}; use bevy_ecs::{ diff --git a/crates/bevy_render/src/gpu_readback.rs b/crates/bevy_render/src/gpu_readback.rs index 012ec1a6cb846..875d5de143f6b 100644 --- a/crates/bevy_render/src/gpu_readback.rs +++ b/crates/bevy_render/src/gpu_readback.rs @@ -1,15 +1,15 @@ use crate::{ + ExtractSchedule, MainWorld, Render, RenderApp, RenderSet, extract_component::ExtractComponentPlugin, render_asset::RenderAssets, render_resource::{ Buffer, BufferUsages, CommandEncoder, Extent3d, TexelCopyBufferLayout, Texture, TextureFormat, }, - renderer::{render_system, RenderDevice}, + renderer::{RenderDevice, render_system}, storage::{GpuShaderStorageBuffer, ShaderStorageBuffer}, sync_world::MainEntity, texture::GpuImage, - ExtractSchedule, MainWorld, Render, RenderApp, RenderSet, }; use async_channel::{Receiver, Sender}; use bevy_app::{App, Plugin}; @@ -27,9 +27,9 @@ use bevy_image::{Image, TextureFormatPixelInfo}; use bevy_platform_support::collections::HashMap; use bevy_reflect::Reflect; use bevy_render_macros::ExtractComponent; +use encase::ShaderType; use encase::internal::ReadFrom; use encase::private::Reader; -use encase::ShaderType; use tracing::warn; /// A plugin that enables reading back gpu buffers and textures to the cpu. diff --git a/crates/bevy_render/src/lib.rs b/crates/bevy_render/src/lib.rs index 4a91686dfb243..95c41fcf50ced 100644 --- a/crates/bevy_render/src/lib.rs +++ b/crates/bevy_render/src/lib.rs @@ -56,19 +56,19 @@ pub mod view; pub mod prelude { #[doc(hidden)] pub use crate::{ + ExtractSchedule, alpha::AlphaMode, camera::{ Camera, ClearColor, ClearColorConfig, OrthographicProjection, PerspectiveProjection, Projection, }, mesh::{ - morph::MorphWeights, primitives::MeshBuilder, primitives::Meshable, Mesh, Mesh2d, - Mesh3d, + Mesh, Mesh2d, Mesh3d, morph::MorphWeights, primitives::MeshBuilder, + primitives::Meshable, }, render_resource::Shader, texture::ImagePlugin, view::{InheritedVisibility, Msaa, ViewVisibility, Visibility}, - ExtractSchedule, }; } use batching::gpu_preprocessing::BatchingPlugin; @@ -84,7 +84,7 @@ use render_asset::RenderAssetBytesPerFrame; use renderer::{RenderAdapter, RenderDevice, RenderQueue}; use settings::RenderResources; use sync_world::{ - despawn_temporary_render_entities, entity_sync_system, SyncToRenderWorld, SyncWorldPlugin, + SyncToRenderWorld, SyncWorldPlugin, despawn_temporary_render_entities, entity_sync_system, }; use crate::gpu_readback::GpuReadbackPlugin; @@ -93,14 +93,14 @@ use crate::{ mesh::{MeshPlugin, MorphPlugin, RenderMesh}, render_asset::prepare_assets, render_resource::{PipelineCache, Shader, ShaderLoader}, - renderer::{render_system, RenderInstance, WgpuWrapper}, + renderer::{RenderInstance, WgpuWrapper, render_system}, settings::RenderCreation, storage::StoragePlugin, view::{ViewPlugin, WindowRenderPlugin}, }; use alloc::sync::Arc; use bevy_app::{App, AppLabel, Plugin, SubApp}; -use bevy_asset::{load_internal_asset, weak_handle, AssetApp, AssetServer, Handle}; +use bevy_asset::{AssetApp, AssetServer, Handle, load_internal_asset, weak_handle}; use bevy_ecs::{prelude::*, schedule::ScheduleLabel}; use bitflags::bitflags; use core::ops::{Deref, DerefMut}; diff --git a/crates/bevy_render/src/mesh/allocator.rs b/crates/bevy_render/src/mesh/allocator.rs index 3af1ce1ea83fc..528e34e3359af 100644 --- a/crates/bevy_render/src/mesh/allocator.rs +++ b/crates/bevy_render/src/mesh/allocator.rs @@ -16,21 +16,21 @@ use bevy_ecs::{ system::{Res, ResMut}, world::{FromWorld, World}, }; -use bevy_platform_support::collections::{hash_map::Entry, HashMap, HashSet}; +use bevy_platform_support::collections::{HashMap, HashSet, hash_map::Entry}; use bevy_utils::default; use offset_allocator::{Allocation, Allocator}; use tracing::error; use wgpu::{ - BufferDescriptor, BufferSize, BufferUsages, CommandEncoderDescriptor, DownlevelFlags, - COPY_BUFFER_ALIGNMENT, + BufferDescriptor, BufferSize, BufferUsages, COPY_BUFFER_ALIGNMENT, CommandEncoderDescriptor, + DownlevelFlags, }; use crate::{ + Render, RenderApp, RenderSet, mesh::{Indices, Mesh, MeshVertexBufferLayouts, RenderMesh}, - render_asset::{prepare_assets, ExtractedAssets}, + render_asset::{ExtractedAssets, prepare_assets}, render_resource::Buffer, renderer::{RenderAdapter, RenderDevice, RenderQueue}, - Render, RenderApp, RenderSet, }; /// A plugin that manages GPU memory for mesh data. @@ -763,9 +763,7 @@ impl MeshAllocator { // Mark the allocation as pending. Don't copy it in just yet; further // meshes loaded this frame may result in its final allocation location // changing. - if let Some(Slab::General(general_slab)) = - self.slabs.get_mut(&mesh_allocation.slab_id) - { + if let Some(Slab::General(general_slab)) = self.slabs.get_mut(&mesh_allocation.slab_id) { general_slab .pending_allocations .insert(*mesh_id, mesh_allocation.slab_allocation); diff --git a/crates/bevy_render/src/mesh/components.rs b/crates/bevy_render/src/mesh/components.rs index b5b03ac2b8f27..c2dc3b0cf1038 100644 --- a/crates/bevy_render/src/mesh/components.rs +++ b/crates/bevy_render/src/mesh/components.rs @@ -9,7 +9,7 @@ use bevy_ecs::{ reflect::ReflectComponent, system::Query, }; use bevy_platform_support::{collections::HashSet, hash::FixedHasher}; -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; use bevy_transform::components::Transform; use derive_more::derive::From; diff --git a/crates/bevy_render/src/mesh/mod.rs b/crates/bevy_render/src/mesh/mod.rs index fbd530c14da42..0d9d6b27115df 100644 --- a/crates/bevy_render/src/mesh/mod.rs +++ b/crates/bevy_render/src/mesh/mod.rs @@ -4,12 +4,12 @@ use morph::{MeshMorphWeights, MorphWeights}; pub mod allocator; mod components; use crate::{ + RenderApp, primitives::Aabb, render_asset::{PrepareAssetError, RenderAsset, RenderAssetPlugin, RenderAssets}, render_resource::TextureView, texture::GpuImage, view::VisibilitySystems, - RenderApp, }; use allocator::MeshAllocatorPlugin; use bevy_app::{App, Plugin, PostUpdate}; @@ -17,11 +17,11 @@ use bevy_asset::{AssetApp, AssetEvents, AssetId, RenderAssetUsages}; use bevy_ecs::{ prelude::*, system::{ - lifetimeless::{SRes, SResMut}, SystemParamItem, + lifetimeless::{SRes, SResMut}, }, }; -pub use components::{mark_3d_meshes_as_changed_if_their_assets_changed, Mesh2d, Mesh3d, MeshTag}; +pub use components::{Mesh2d, Mesh3d, MeshTag, mark_3d_meshes_as_changed_if_their_assets_changed}; use wgpu::IndexFormat; /// Registers all [`MeshBuilder`] types. diff --git a/crates/bevy_render/src/primitives/mod.rs b/crates/bevy_render/src/primitives/mod.rs index 9123e95b5e946..3ac5e4293dfd5 100644 --- a/crates/bevy_render/src/primitives/mod.rs +++ b/crates/bevy_render/src/primitives/mod.rs @@ -353,7 +353,7 @@ pub struct CascadesFrusta { mod tests { use core::f32::consts::PI; - use bevy_math::{ops, Quat}; + use bevy_math::{Quat, ops}; use bevy_transform::components::GlobalTransform; use crate::camera::{CameraProjection, PerspectiveProjection}; diff --git a/crates/bevy_render/src/render_asset.rs b/crates/bevy_render/src/render_asset.rs index 043b3554a148a..a0b377b210e0e 100644 --- a/crates/bevy_render/src/render_asset.rs +++ b/crates/bevy_render/src/render_asset.rs @@ -1,5 +1,5 @@ use crate::{ - render_resource::AsBindGroupError, ExtractSchedule, MainWorld, Render, RenderApp, RenderSet, + ExtractSchedule, MainWorld, Render, RenderApp, RenderSet, render_resource::AsBindGroupError, }; use bevy_app::{App, Plugin, SubApp}; pub use bevy_asset::RenderAssetUsages; diff --git a/crates/bevy_render/src/render_graph/context.rs b/crates/bevy_render/src/render_graph/context.rs index 4c6ecd30c1d67..ccba753a6340d 100644 --- a/crates/bevy_render/src/render_graph/context.rs +++ b/crates/bevy_render/src/render_graph/context.rs @@ -242,7 +242,9 @@ pub enum RunSubGraphError { MissingSubGraph(InternedRenderSubGraph), #[error("attempted to pass inputs to sub-graph `{0:?}`, which has no input slots")] SubGraphHasNoInputs(InternedRenderSubGraph), - #[error("sub graph (name: `{graph_name:?}`) could not be run because slot `{slot_name}` at index {slot_index} has no value")] + #[error( + "sub graph (name: `{graph_name:?}`) could not be run because slot `{slot_name}` at index {slot_index} has no value" + )] MissingInput { slot_index: usize, slot_name: Cow<'static, str>, @@ -262,7 +264,9 @@ pub enum RunSubGraphError { pub enum OutputSlotError { #[error("output slot `{0:?}` does not exist")] InvalidSlot(SlotLabel), - #[error("attempted to output a value of type `{actual}` to output slot `{label:?}`, which has type `{expected}`")] + #[error( + "attempted to output a value of type `{actual}` to output slot `{label:?}`, which has type `{expected}`" + )] MismatchedSlotType { label: SlotLabel, expected: SlotType, @@ -274,7 +278,9 @@ pub enum OutputSlotError { pub enum InputSlotError { #[error("input slot `{0:?}` does not exist")] InvalidSlot(SlotLabel), - #[error("attempted to retrieve a value of type `{actual}` from input slot `{label:?}`, which has type `{expected}`")] + #[error( + "attempted to retrieve a value of type `{actual}` from input slot `{label:?}`, which has type `{expected}`" + )] MismatchedSlotType { label: SlotLabel, expected: SlotType, diff --git a/crates/bevy_render/src/render_graph/graph.rs b/crates/bevy_render/src/render_graph/graph.rs index 78e6cbf324724..799797c57f557 100644 --- a/crates/bevy_render/src/render_graph/graph.rs +++ b/crates/bevy_render/src/render_graph/graph.rs @@ -674,8 +674,8 @@ impl Node for GraphInputNode { mod tests { use crate::{ render_graph::{ - node::IntoRenderNodeArray, Edge, InternedRenderLabel, Node, NodeRunError, RenderGraph, - RenderGraphContext, RenderGraphError, RenderLabel, SlotInfo, SlotType, + Edge, InternedRenderLabel, Node, NodeRunError, RenderGraph, RenderGraphContext, + RenderGraphError, RenderLabel, SlotInfo, SlotType, node::IntoRenderNodeArray, }, renderer::RenderContext, }; diff --git a/crates/bevy_render/src/render_graph/mod.rs b/crates/bevy_render/src/render_graph/mod.rs index fbed33a23c6f4..1eead0a027cee 100644 --- a/crates/bevy_render/src/render_graph/mod.rs +++ b/crates/bevy_render/src/render_graph/mod.rs @@ -24,7 +24,9 @@ pub enum RenderGraphError { InvalidInputNodeSlot(SlotLabel), #[error("node does not match the given type")] WrongNodeType, - #[error("attempted to connect output slot {output_slot} from node {output_node:?} to incompatible input slot {input_slot} from node {input_node:?}")] + #[error( + "attempted to connect output slot {output_slot} from node {output_node:?} to incompatible input slot {input_slot} from node {input_node:?}" + )] MismatchedNodeSlots { output_node: InternedRenderLabel, output_slot: usize, diff --git a/crates/bevy_render/src/render_graph/node.rs b/crates/bevy_render/src/render_graph/node.rs index 0a634c2598461..735856fbcc78e 100644 --- a/crates/bevy_render/src/render_graph/node.rs +++ b/crates/bevy_render/src/render_graph/node.rs @@ -14,7 +14,7 @@ use bevy_ecs::{ world::{FromWorld, World}, }; use core::fmt::Debug; -use downcast_rs::{impl_downcast, Downcast}; +use downcast_rs::{Downcast, impl_downcast}; use thiserror::Error; use variadics_please::all_tuples_with_size; diff --git a/crates/bevy_render/src/render_phase/draw.rs b/crates/bevy_render/src/render_phase/draw.rs index a12d336018508..9e23f57b14452 100644 --- a/crates/bevy_render/src/render_phase/draw.rs +++ b/crates/bevy_render/src/render_phase/draw.rs @@ -333,11 +333,11 @@ where Ok(view) => view, Err(err) => match err { QueryEntityError::EntityDoesNotExist(_) => { - return Err(DrawError::ViewEntityNotFound) + return Err(DrawError::ViewEntityNotFound); } QueryEntityError::QueryDoesNotMatch(_, _) | QueryEntityError::AliasedMutability(_) => { - return Err(DrawError::InvalidViewQuery) + return Err(DrawError::InvalidViewQuery); } }, }; diff --git a/crates/bevy_render/src/render_phase/draw_state.rs b/crates/bevy_render/src/render_phase/draw_state.rs index a7b8acdc00393..42a8477a11604 100644 --- a/crates/bevy_render/src/render_phase/draw_state.rs +++ b/crates/bevy_render/src/render_phase/draw_state.rs @@ -196,18 +196,14 @@ impl<'a> TrackedRenderPass<'a> { #[cfg(feature = "detailed_trace")] trace!( "set bind_group {} (already set): {:?} ({:?})", - index, - bind_group, - dynamic_uniform_indices + index, bind_group, dynamic_uniform_indices ); return; } #[cfg(feature = "detailed_trace")] trace!( "set bind_group {}: {:?} ({:?})", - index, - bind_group, - dynamic_uniform_indices + index, bind_group, dynamic_uniform_indices ); self.pass @@ -298,9 +294,7 @@ impl<'a> TrackedRenderPass<'a> { #[cfg(feature = "detailed_trace")] trace!( "draw indexed: {:?} {} {:?}", - indices, - base_vertex, - instances + indices, base_vertex, instances ); self.pass.draw_indexed(indices, base_vertex, instances); } @@ -351,8 +345,7 @@ impl<'a> TrackedRenderPass<'a> { #[cfg(feature = "detailed_trace")] trace!( "draw indexed indirect: {:?} {}", - indirect_buffer, - indirect_offset + indirect_buffer, indirect_offset ); self.pass .draw_indexed_indirect(indirect_buffer, indirect_offset); @@ -384,9 +377,7 @@ impl<'a> TrackedRenderPass<'a> { #[cfg(feature = "detailed_trace")] trace!( "multi draw indirect: {:?} {}, {}x", - indirect_buffer, - indirect_offset, - count + indirect_buffer, indirect_offset, count ); self.pass .multi_draw_indirect(indirect_buffer, indirect_offset, count); @@ -425,11 +416,7 @@ impl<'a> TrackedRenderPass<'a> { #[cfg(feature = "detailed_trace")] trace!( "multi draw indirect count: {:?} {}, ({:?} {})x, max {}x", - indirect_buffer, - indirect_offset, - count_buffer, - count_offset, - max_count + indirect_buffer, indirect_offset, count_buffer, count_offset, max_count ); self.pass.multi_draw_indirect_count( indirect_buffer, @@ -468,9 +455,7 @@ impl<'a> TrackedRenderPass<'a> { #[cfg(feature = "detailed_trace")] trace!( "multi draw indexed indirect: {:?} {}, {}x", - indirect_buffer, - indirect_offset, - count + indirect_buffer, indirect_offset, count ); self.pass .multi_draw_indexed_indirect(indirect_buffer, indirect_offset, count); @@ -511,11 +496,7 @@ impl<'a> TrackedRenderPass<'a> { #[cfg(feature = "detailed_trace")] trace!( "multi draw indexed indirect count: {:?} {}, ({:?} {})x, max {}x", - indirect_buffer, - indirect_offset, - count_buffer, - count_offset, - max_count + indirect_buffer, indirect_offset, count_buffer, count_offset, max_count ); self.pass.multi_draw_indexed_indirect_count( indirect_buffer, @@ -573,12 +554,7 @@ impl<'a> TrackedRenderPass<'a> { #[cfg(feature = "detailed_trace")] trace!( "set viewport: {} {} {} {} {} {}", - x, - y, - width, - height, - min_depth, - max_depth + x, y, width, height, min_depth, max_depth ); self.pass .set_viewport(x, y, width, height, min_depth, max_depth); diff --git a/crates/bevy_render/src/render_phase/mod.rs b/crates/bevy_render/src/render_phase/mod.rs index 9c538a1377c1a..617bbf61a2e97 100644 --- a/crates/bevy_render/src/render_phase/mod.rs +++ b/crates/bevy_render/src/render_phase/mod.rs @@ -32,17 +32,18 @@ use bevy_app::{App, Plugin}; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::component::Tick; use bevy_ecs::entity::EntityHash; -use bevy_platform_support::collections::{hash_map::Entry, HashMap}; +use bevy_platform_support::collections::{HashMap, hash_map::Entry}; use bevy_utils::default; pub use draw::*; pub use draw_state::*; -use encase::{internal::WriteInto, ShaderSize}; +use encase::{ShaderSize, internal::WriteInto}; use fixedbitset::{Block, FixedBitSet}; use indexmap::IndexMap; use nonmax::NonMaxU32; pub use rangefinder::*; use wgpu::Features; +use crate::RenderDebugFlags; use crate::batching::gpu_preprocessing::{ GpuPreprocessingMode, GpuPreprocessingSupport, PhaseBatchedInstanceBuffers, PhaseIndirectParametersBuffers, @@ -50,20 +51,18 @@ use crate::batching::gpu_preprocessing::{ use crate::renderer::RenderDevice; use crate::sync_world::{MainEntity, MainEntityHashMap}; use crate::view::RetainedViewEntity; -use crate::RenderDebugFlags; use crate::{ + Render, RenderApp, RenderSet, batching::{ - self, + self, GetFullBatchData, gpu_preprocessing::{self, BatchedInstanceBuffers}, no_gpu_preprocessing::{self, BatchedInstanceBuffer}, - GetFullBatchData, }, render_resource::{CachedRenderPipelineId, GpuArrayBufferIndex, PipelineCache}, - Render, RenderApp, RenderSet, }; use bevy_ecs::{ prelude::*, - system::{lifetimeless::SRes, SystemParamItem}, + system::{SystemParamItem, lifetimeless::SRes}, }; use core::{fmt::Debug, hash::Hash, iter, marker::PhantomData, ops::Range, slice::SliceIndex}; use smallvec::SmallVec; diff --git a/crates/bevy_render/src/render_resource/batched_uniform_buffer.rs b/crates/bevy_render/src/render_resource/batched_uniform_buffer.rs index fecc90feac1a4..8b6cb5323ef9e 100644 --- a/crates/bevy_render/src/render_resource/batched_uniform_buffer.rs +++ b/crates/bevy_render/src/render_resource/batched_uniform_buffer.rs @@ -5,8 +5,8 @@ use crate::{ }; use core::{marker::PhantomData, num::NonZero}; use encase::{ - private::{ArrayMetadata, BufferMut, Metadata, RuntimeSizedArray, WriteInto, Writer}, ShaderType, + private::{ArrayMetadata, BufferMut, Metadata, RuntimeSizedArray, WriteInto, Writer}, }; use nonmax::NonMaxU32; use wgpu::{BindingResource, Limits}; diff --git a/crates/bevy_render/src/render_resource/bind_group.rs b/crates/bevy_render/src/render_resource/bind_group.rs index 9fe835bb1b8ab..0b0b4ee2998aa 100644 --- a/crates/bevy_render/src/render_resource/bind_group.rs +++ b/crates/bevy_render/src/render_resource/bind_group.rs @@ -537,7 +537,9 @@ pub enum AsBindGroupError { RetryNextUpdate, #[error("Create the bind group via `as_bind_group()` instead")] CreateBindGroupDirectly, - #[error("At binding index {0}, the provided image sampler `{1}` does not match the required sampler type(s) `{2}`.")] + #[error( + "At binding index {0}, the provided image sampler `{1}` does not match the required sampler type(s) `{2}`." + )] InvalidSamplerType(u32, String, String), } diff --git a/crates/bevy_render/src/render_resource/bind_group_layout_entries.rs b/crates/bevy_render/src/render_resource/bind_group_layout_entries.rs index bc4a7d306da4b..bfdacced5c114 100644 --- a/crates/bevy_render/src/render_resource/bind_group_layout_entries.rs +++ b/crates/bevy_render/src/render_resource/bind_group_layout_entries.rs @@ -222,7 +222,9 @@ impl IntoBindGroupLayoutEntryBuilder for BindingType { impl IntoBindGroupLayoutEntryBuilder for BindGroupLayoutEntry { fn into_bind_group_layout_entry_builder(self) -> BindGroupLayoutEntryBuilder { if self.binding != u32::MAX { - tracing::warn!("The BindGroupLayoutEntries api ignores the binding index when converting a raw wgpu::BindGroupLayoutEntry. You can ignore this warning by setting it to u32::MAX."); + tracing::warn!( + "The BindGroupLayoutEntries api ignores the binding index when converting a raw wgpu::BindGroupLayoutEntry. You can ignore this warning by setting it to u32::MAX." + ); } BindGroupLayoutEntryBuilder { ty: self.ty, diff --git a/crates/bevy_render/src/render_resource/buffer_vec.rs b/crates/bevy_render/src/render_resource/buffer_vec.rs index 2077024215463..3d0e5131f4846 100644 --- a/crates/bevy_render/src/render_resource/buffer_vec.rs +++ b/crates/bevy_render/src/render_resource/buffer_vec.rs @@ -4,10 +4,10 @@ use crate::{ render_resource::Buffer, renderer::{RenderDevice, RenderQueue}, }; -use bytemuck::{must_cast_slice, NoUninit}; +use bytemuck::{NoUninit, must_cast_slice}; use encase::{ - internal::{WriteInto, Writer}, ShaderType, + internal::{WriteInto, Writer}, }; use wgpu::{BindingResource, BufferAddress, BufferUsages}; diff --git a/crates/bevy_render/src/render_resource/gpu_array_buffer.rs b/crates/bevy_render/src/render_resource/gpu_array_buffer.rs index 195920ee0ceb7..05346fb89563c 100644 --- a/crates/bevy_render/src/render_resource/gpu_array_buffer.rs +++ b/crates/bevy_render/src/render_resource/gpu_array_buffer.rs @@ -1,6 +1,6 @@ use super::{ - binding_types::{storage_buffer_read_only, uniform_buffer_sized}, BindGroupLayoutEntryBuilder, BufferVec, + binding_types::{storage_buffer_read_only, uniform_buffer_sized}, }; use crate::{ render_resource::batched_uniform_buffer::BatchedUniformBuffer, @@ -8,7 +8,7 @@ use crate::{ }; use bevy_ecs::{prelude::Component, resource::Resource}; use core::marker::PhantomData; -use encase::{private::WriteInto, ShaderSize, ShaderType}; +use encase::{ShaderSize, ShaderType, private::WriteInto}; use nonmax::NonMaxU32; use wgpu::{BindingResource, BufferUsages}; diff --git a/crates/bevy_render/src/render_resource/mod.rs b/crates/bevy_render/src/render_resource/mod.rs index aab2fe5b6a798..81c5926c59bc5 100644 --- a/crates/bevy_render/src/render_resource/mod.rs +++ b/crates/bevy_render/src/render_resource/mod.rs @@ -34,18 +34,15 @@ pub use uniform_buffer::*; // TODO: decide where re-exports should go pub use wgpu::{ - util::{ - BufferInitDescriptor, DispatchIndirectArgs, DrawIndexedIndirectArgs, DrawIndirectArgs, - TextureDataOrder, - }, AdapterInfo as WgpuAdapterInfo, AddressMode, AstcBlock, AstcChannel, BindGroupDescriptor, BindGroupEntry, BindGroupLayoutDescriptor, BindGroupLayoutEntry, BindingResource, BindingType, BlendComponent, BlendFactor, BlendOperation, BlendState, BufferAddress, BufferAsyncError, - BufferBinding, BufferBindingType, BufferDescriptor, BufferSize, BufferUsages, ColorTargetState, - ColorWrites, CommandEncoder, CommandEncoderDescriptor, CompareFunction, ComputePass, - ComputePassDescriptor, ComputePipelineDescriptor as RawComputePipelineDescriptor, - DepthBiasState, DepthStencilState, DownlevelFlags, Extent3d, Face, Features as WgpuFeatures, - FilterMode, FragmentState as RawFragmentState, FrontFace, ImageSubresourceRange, IndexFormat, + BufferBinding, BufferBindingType, BufferDescriptor, BufferSize, BufferUsages, + COPY_BUFFER_ALIGNMENT, ColorTargetState, ColorWrites, CommandEncoder, CommandEncoderDescriptor, + CompareFunction, ComputePass, ComputePassDescriptor, + ComputePipelineDescriptor as RawComputePipelineDescriptor, DepthBiasState, DepthStencilState, + DownlevelFlags, Extent3d, Face, Features as WgpuFeatures, FilterMode, + FragmentState as RawFragmentState, FrontFace, ImageSubresourceRange, IndexFormat, Limits as WgpuLimits, LoadOp, Maintain, MapMode, MultisampleState, Operations, Origin3d, PipelineCompilationOptions, PipelineLayout, PipelineLayoutDescriptor, PolygonMode, PrimitiveState, PrimitiveTopology, PushConstantRange, RenderPassColorAttachment, @@ -58,7 +55,11 @@ pub use wgpu::{ TextureDimension, TextureFormat, TextureSampleType, TextureUsages, TextureView as WgpuTextureView, TextureViewDescriptor, TextureViewDimension, VertexAttribute, VertexBufferLayout as RawVertexBufferLayout, VertexFormat, VertexState as RawVertexState, - VertexStepMode, COPY_BUFFER_ALIGNMENT, + VertexStepMode, + util::{ + BufferInitDescriptor, DispatchIndirectArgs, DrawIndexedIndirectArgs, DrawIndirectArgs, + TextureDataOrder, + }, }; pub use crate::mesh::VertexBufferLayout; diff --git a/crates/bevy_render/src/render_resource/pipeline_cache.rs b/crates/bevy_render/src/render_resource/pipeline_cache.rs index 7be7d1f724c43..83167a538e2a5 100644 --- a/crates/bevy_render/src/render_resource/pipeline_cache.rs +++ b/crates/bevy_render/src/render_resource/pipeline_cache.rs @@ -1,8 +1,8 @@ use crate::renderer::WgpuWrapper; use crate::{ + Extract, render_resource::*, renderer::{RenderAdapter, RenderDevice}, - Extract, }; use alloc::{borrow::Cow, sync::Arc}; use bevy_asset::{AssetEvent, AssetId, Assets}; @@ -11,7 +11,7 @@ use bevy_ecs::{ resource::Resource, system::{Res, ResMut}, }; -use bevy_platform_support::collections::{hash_map::EntryRef, HashMap, HashSet}; +use bevy_platform_support::collections::{HashMap, HashSet, hash_map::EntryRef}; use bevy_tasks::Task; use bevy_utils::default; use core::{future::Future, hash::Hash, mem, ops::Deref}; @@ -882,16 +882,14 @@ impl PipelineCache { }; } - CachedPipelineState::Creating(task) => { - match bevy_tasks::futures::check_ready(task) { - Some(Ok(pipeline)) => { - cached_pipeline.state = CachedPipelineState::Ok(pipeline); - return; - } - Some(Err(err)) => cached_pipeline.state = CachedPipelineState::Err(err), - _ => (), + CachedPipelineState::Creating(task) => match bevy_tasks::futures::check_ready(task) { + Some(Ok(pipeline)) => { + cached_pipeline.state = CachedPipelineState::Ok(pipeline); + return; } - } + Some(Err(err)) => cached_pipeline.state = CachedPipelineState::Err(err), + _ => (), + }, CachedPipelineState::Err(err) => match err { // Retry diff --git a/crates/bevy_render/src/render_resource/pipeline_specializer.rs b/crates/bevy_render/src/render_resource/pipeline_specializer.rs index 67f737a6a4193..ed4bbb2ddc8c4 100644 --- a/crates/bevy_render/src/render_resource/pipeline_specializer.rs +++ b/crates/bevy_render/src/render_resource/pipeline_specializer.rs @@ -8,8 +8,8 @@ use crate::{ use bevy_ecs::resource::Resource; use bevy_platform_support::{ collections::{ - hash_map::{Entry, RawEntryMut, VacantEntry}, HashMap, + hash_map::{Entry, RawEntryMut, VacantEntry}, }, hash::FixedHasher, }; diff --git a/crates/bevy_render/src/render_resource/shader.rs b/crates/bevy_render/src/render_resource/shader.rs index e1d00ec0d7f30..f4f927e94a82a 100644 --- a/crates/bevy_render/src/render_resource/shader.rs +++ b/crates/bevy_render/src/render_resource/shader.rs @@ -1,7 +1,7 @@ use super::ShaderDefVal; use crate::define_atomic_id; use alloc::borrow::Cow; -use bevy_asset::{io::Reader, Asset, AssetLoader, AssetPath, Handle, LoadContext}; +use bevy_asset::{Asset, AssetLoader, AssetPath, Handle, LoadContext, io::Reader}; use bevy_reflect::TypePath; use core::marker::Copy; use thiserror::Error; diff --git a/crates/bevy_render/src/render_resource/storage_buffer.rs b/crates/bevy_render/src/render_resource/storage_buffer.rs index b407e22d8f9e6..5f92a6fe719dd 100644 --- a/crates/bevy_render/src/render_resource/storage_buffer.rs +++ b/crates/bevy_render/src/render_resource/storage_buffer.rs @@ -3,10 +3,10 @@ use core::marker::PhantomData; use super::Buffer; use crate::renderer::{RenderDevice, RenderQueue}; use encase::{ - internal::WriteInto, DynamicStorageBuffer as DynamicStorageBufferWrapper, ShaderType, - StorageBuffer as StorageBufferWrapper, + DynamicStorageBuffer as DynamicStorageBufferWrapper, ShaderType, + StorageBuffer as StorageBufferWrapper, internal::WriteInto, }; -use wgpu::{util::BufferInitDescriptor, BindingResource, BufferBinding, BufferSize, BufferUsages}; +use wgpu::{BindingResource, BufferBinding, BufferSize, BufferUsages, util::BufferInitDescriptor}; use super::IntoBinding; diff --git a/crates/bevy_render/src/render_resource/uniform_buffer.rs b/crates/bevy_render/src/render_resource/uniform_buffer.rs index b7d22972df469..f7cd03f594e64 100644 --- a/crates/bevy_render/src/render_resource/uniform_buffer.rs +++ b/crates/bevy_render/src/render_resource/uniform_buffer.rs @@ -5,12 +5,12 @@ use crate::{ renderer::{RenderDevice, RenderQueue}, }; use encase::{ - internal::{AlignmentValue, BufferMut, WriteInto}, DynamicUniformBuffer as DynamicUniformBufferWrapper, ShaderType, UniformBuffer as UniformBufferWrapper, + internal::{AlignmentValue, BufferMut, WriteInto}, }; use wgpu::{ - util::BufferInitDescriptor, BindingResource, BufferBinding, BufferDescriptor, BufferUsages, + BindingResource, BufferBinding, BufferDescriptor, BufferUsages, util::BufferInitDescriptor, }; use super::IntoBinding; diff --git a/crates/bevy_render/src/renderer/graph_runner.rs b/crates/bevy_render/src/renderer/graph_runner.rs index cc03374ea4316..f0cd7fc6bc1e3 100644 --- a/crates/bevy_render/src/renderer/graph_runner.rs +++ b/crates/bevy_render/src/renderer/graph_runner.rs @@ -4,7 +4,7 @@ use bevy_platform_support::collections::HashMap; use tracing::info_span; use alloc::{borrow::Cow, collections::VecDeque}; -use smallvec::{smallvec, SmallVec}; +use smallvec::{SmallVec, smallvec}; use thiserror::Error; use crate::{ @@ -39,7 +39,9 @@ pub enum RenderGraphRunnerError { slot_index: usize, slot_name: Cow<'static, str>, }, - #[error("graph '{sub_graph:?}' could not be run because slot '{slot_name}' at index {slot_index} has no value")] + #[error( + "graph '{sub_graph:?}' could not be run because slot '{slot_name}' at index {slot_index} has no value" + )] MissingInput { slot_index: usize, slot_name: Cow<'static, str>, diff --git a/crates/bevy_render/src/renderer/mod.rs b/crates/bevy_render/src/renderer/mod.rs index 7d81db5a19402..02a4fdb193792 100644 --- a/crates/bevy_render/src/renderer/mod.rs +++ b/crates/bevy_render/src/renderer/mod.rs @@ -9,7 +9,7 @@ pub use render_device::*; use tracing::{error, info, info_span, warn}; use crate::{ - diagnostic::{internal::DiagnosticsRecorder, RecordDiagnostics}, + diagnostic::{RecordDiagnostics, internal::DiagnosticsRecorder}, render_graph::RenderGraph, render_phase::TrackedRenderPass, render_resource::RenderPassDescriptor, @@ -111,7 +111,9 @@ pub fn render_system(world: &mut World, state: &mut SystemState { - panic!("The TimeSender channel should always be empty during render. You might need to add the bevy::core::time_system to your app.",); + panic!( + "The TimeSender channel should always be empty during render. You might need to add the bevy::core::time_system to your app.", + ); } bevy_time::TrySendError::Disconnected(_) => { // ignore disconnected errors, the main world probably just got dropped during shutdown diff --git a/crates/bevy_render/src/renderer/render_device.rs b/crates/bevy_render/src/renderer/render_device.rs index d33139745baf8..9b6383fde4538 100644 --- a/crates/bevy_render/src/renderer/render_device.rs +++ b/crates/bevy_render/src/renderer/render_device.rs @@ -1,13 +1,13 @@ use super::RenderQueue; +use crate::WgpuWrapper; use crate::render_resource::{ BindGroup, BindGroupLayout, Buffer, ComputePipeline, RawRenderPipelineDescriptor, RenderPipeline, Sampler, Texture, }; -use crate::WgpuWrapper; use bevy_ecs::resource::Resource; use wgpu::{ - util::DeviceExt, BindGroupDescriptor, BindGroupEntry, BindGroupLayoutDescriptor, - BindGroupLayoutEntry, BufferAsyncError, BufferBindingType, MaintainResult, + BindGroupDescriptor, BindGroupEntry, BindGroupLayoutDescriptor, BindGroupLayoutEntry, + BufferAsyncError, BufferBindingType, MaintainResult, util::DeviceExt, }; /// This GPU device is responsible for the creation of most rendering and compute resources. @@ -101,7 +101,9 @@ impl RenderDevice { ) -> wgpu::ShaderModule { #[cfg(feature = "spirv_shader_passthrough")] match &desc.source { - wgpu::ShaderSource::SpirV(_source) => panic!("no safety checks are performed for spirv shaders. use `create_shader_module` instead"), + wgpu::ShaderSource::SpirV(_source) => panic!( + "no safety checks are performed for spirv shaders. use `create_shader_module` instead" + ), _ => self.device.create_shader_module(desc), } #[cfg(not(feature = "spirv_shader_passthrough"))] diff --git a/crates/bevy_render/src/storage.rs b/crates/bevy_render/src/storage.rs index 7434f3999f3dc..4a18d3bbe2902 100644 --- a/crates/bevy_render/src/storage.rs +++ b/crates/bevy_render/src/storage.rs @@ -5,10 +5,10 @@ use crate::{ }; use bevy_app::{App, Plugin}; use bevy_asset::{Asset, AssetApp, AssetId}; -use bevy_ecs::system::{lifetimeless::SRes, SystemParamItem}; -use bevy_reflect::{prelude::ReflectDefault, Reflect}; +use bevy_ecs::system::{SystemParamItem, lifetimeless::SRes}; +use bevy_reflect::{Reflect, prelude::ReflectDefault}; use bevy_utils::default; -use encase::{internal::WriteInto, ShaderType}; +use encase::{ShaderType, internal::WriteInto}; use wgpu::util::BufferInitDescriptor; /// Adds [`ShaderStorageBuffer`] as an asset that is extracted and uploaded to the GPU. diff --git a/crates/bevy_render/src/sync_world.rs b/crates/bevy_render/src/sync_world.rs index 3c9dc57ff8f40..c092e52d075ca 100644 --- a/crates/bevy_render/src/sync_world.rs +++ b/crates/bevy_render/src/sync_world.rs @@ -279,7 +279,7 @@ mod render_entities_world_query_impls { entity::Entity, query::{FilteredAccess, QueryData, ReadOnlyQueryData, WorldQuery}, storage::{Table, TableRow}, - world::{unsafe_world_cell::UnsafeWorldCell, World}, + world::{World, unsafe_world_cell::UnsafeWorldCell}, }; /// SAFETY: defers completely to `&RenderEntity` implementation, @@ -492,8 +492,8 @@ mod tests { }; use super::{ - entity_sync_system, EntityRecord, MainEntity, PendingSyncEntity, RenderEntity, - SyncToRenderWorld, + EntityRecord, MainEntity, PendingSyncEntity, RenderEntity, SyncToRenderWorld, + entity_sync_system, }; #[derive(Component)] diff --git a/crates/bevy_render/src/texture/gpu_image.rs b/crates/bevy_render/src/texture/gpu_image.rs index 551bd3ee02e09..6ed90fcdedc07 100644 --- a/crates/bevy_render/src/texture/gpu_image.rs +++ b/crates/bevy_render/src/texture/gpu_image.rs @@ -4,7 +4,7 @@ use crate::{ renderer::{RenderDevice, RenderQueue}, }; use bevy_asset::AssetId; -use bevy_ecs::system::{lifetimeless::SRes, SystemParamItem}; +use bevy_ecs::system::{SystemParamItem, lifetimeless::SRes}; use bevy_image::{Image, ImageSampler}; use bevy_math::{AspectRatio, UVec2}; use wgpu::{Extent3d, TextureFormat, TextureViewDescriptor}; diff --git a/crates/bevy_render/src/texture/mod.rs b/crates/bevy_render/src/texture/mod.rs index 6955de7ff4fc2..64402714cf815 100644 --- a/crates/bevy_render/src/texture/mod.rs +++ b/crates/bevy_render/src/texture/mod.rs @@ -15,10 +15,10 @@ pub use texture_attachment::*; pub use texture_cache::*; use crate::{ - render_asset::RenderAssetPlugin, renderer::RenderDevice, Render, RenderApp, RenderSet, + Render, RenderApp, RenderSet, render_asset::RenderAssetPlugin, renderer::RenderDevice, }; use bevy_app::{App, Plugin}; -use bevy_asset::{weak_handle, AssetApp, Assets, Handle}; +use bevy_asset::{AssetApp, Assets, Handle, weak_handle}; use bevy_ecs::prelude::*; /// A handle to a 1 x 1 transparent white image. diff --git a/crates/bevy_render/src/texture/texture_cache.rs b/crates/bevy_render/src/texture/texture_cache.rs index 8a3fb010109d5..5e65ac8054efa 100644 --- a/crates/bevy_render/src/texture/texture_cache.rs +++ b/crates/bevy_render/src/texture/texture_cache.rs @@ -3,7 +3,7 @@ use crate::{ renderer::RenderDevice, }; use bevy_ecs::{prelude::ResMut, resource::Resource}; -use bevy_platform_support::collections::{hash_map::Entry, HashMap}; +use bevy_platform_support::collections::{HashMap, hash_map::Entry}; use wgpu::{TextureDescriptor, TextureViewDescriptor}; /// The internal representation of a [`CachedTexture`] used to track whether it was recently used diff --git a/crates/bevy_render/src/view/mod.rs b/crates/bevy_render/src/view/mod.rs index ba0f8cca62ced..4642f56248b4f 100644 --- a/crates/bevy_render/src/view/mod.rs +++ b/crates/bevy_render/src/view/mod.rs @@ -1,12 +1,13 @@ pub mod visibility; pub mod window; -use bevy_asset::{load_internal_asset, weak_handle, Handle}; +use bevy_asset::{Handle, load_internal_asset, weak_handle}; use bevy_diagnostic::FrameCount; pub use visibility::*; pub use window::*; use crate::{ + Render, RenderApp, RenderSet, camera::{ CameraMainTextureUsages, ClearColor, ClearColorConfig, Exposure, ExtractedCamera, ManualTextureViews, MipBias, NormalizedRenderTarget, TemporalJitter, @@ -24,7 +25,6 @@ use crate::{ CachedTexture, ColorAttachment, DepthAttachment, GpuImage, OutputColorAttachment, TextureCache, }, - Render, RenderApp, RenderSet, }; use alloc::sync::Arc; use bevy_app::{App, Plugin}; @@ -32,9 +32,9 @@ use bevy_color::LinearRgba; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::prelude::*; use bevy_image::BevyDefault as _; -use bevy_math::{mat3, vec2, vec3, Mat3, Mat4, UVec4, Vec2, Vec3, Vec4, Vec4Swizzles}; -use bevy_platform_support::collections::{hash_map::Entry, HashMap}; -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_math::{Mat3, Mat4, UVec4, Vec2, Vec3, Vec4, Vec4Swizzles, mat3, vec2, vec3}; +use bevy_platform_support::collections::{HashMap, hash_map::Entry}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; use bevy_render_macros::ExtractComponent; use bevy_transform::components::GlobalTransform; use core::{ diff --git a/crates/bevy_render/src/view/visibility/mod.rs b/crates/bevy_render/src/view/visibility/mod.rs index 09dc516b6ea9b..7afa00e470d86 100644 --- a/crates/bevy_render/src/view/visibility/mod.rs +++ b/crates/bevy_render/src/view/visibility/mod.rs @@ -13,8 +13,8 @@ pub use render_layers::*; use bevy_app::{Plugin, PostUpdate}; use bevy_asset::Assets; use bevy_ecs::{hierarchy::validate_parent_has_component, prelude::*}; -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; -use bevy_transform::{components::GlobalTransform, TransformSystem}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_transform::{TransformSystem, components::GlobalTransform}; use bevy_utils::{Parallel, TypeIdMap}; use smallvec::SmallVec; diff --git a/crates/bevy_render/src/view/visibility/range.rs b/crates/bevy_render/src/view/visibility/range.rs index fe0af5b08afb1..a5f8ebb6ac0a4 100644 --- a/crates/bevy_render/src/view/visibility/range.rs +++ b/crates/bevy_render/src/view/visibility/range.rs @@ -9,7 +9,7 @@ use core::{ use bevy_app::{App, Plugin, PostUpdate}; use bevy_ecs::{ component::Component, - entity::{hash_map::EntityHashMap, Entity}, + entity::{Entity, hash_map::EntityHashMap}, query::{Changed, With}, reflect::ReflectComponent, removal_detection::RemovedComponents, @@ -17,7 +17,7 @@ use bevy_ecs::{ schedule::IntoSystemConfigs as _, system::{Query, Res, ResMut}, }; -use bevy_math::{vec4, FloatOrd, Vec4}; +use bevy_math::{FloatOrd, Vec4, vec4}; use bevy_platform_support::collections::HashMap; use bevy_reflect::Reflect; use bevy_transform::components::GlobalTransform; @@ -25,14 +25,14 @@ use bevy_utils::prelude::default; use nonmax::NonMaxU16; use wgpu::{BufferBindingType, BufferUsages}; -use super::{check_visibility, VisibilitySystems}; +use super::{VisibilitySystems, check_visibility}; use crate::sync_world::{MainEntity, MainEntityHashMap}; use crate::{ + Extract, ExtractSchedule, Render, RenderApp, RenderSet, camera::Camera, primitives::Aabb, render_resource::BufferVec, renderer::{RenderDevice, RenderQueue}, - Extract, ExtractSchedule, Render, RenderApp, RenderSet, }; /// We need at least 4 storage buffer bindings available to enable the diff --git a/crates/bevy_render/src/view/visibility/render_layers.rs b/crates/bevy_render/src/view/visibility/render_layers.rs index 1932abdf71fba..29cf6ff59f3eb 100644 --- a/crates/bevy_render/src/view/visibility/render_layers.rs +++ b/crates/bevy_render/src/view/visibility/render_layers.rs @@ -1,5 +1,5 @@ use bevy_ecs::prelude::{Component, ReflectComponent}; -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; use smallvec::SmallVec; pub const DEFAULT_LAYERS: &RenderLayers = &RenderLayers::layer(0); diff --git a/crates/bevy_render/src/view/window/mod.rs b/crates/bevy_render/src/view/window/mod.rs index 14a984ff3921e..5b1714a8814f8 100644 --- a/crates/bevy_render/src/view/window/mod.rs +++ b/crates/bevy_render/src/view/window/mod.rs @@ -1,7 +1,7 @@ use crate::{ + Extract, ExtractSchedule, Render, RenderApp, RenderSet, WgpuWrapper, render_resource::{SurfaceTexture, TextureView}, renderer::{RenderAdapter, RenderDevice, RenderInstance}, - Extract, ExtractSchedule, Render, RenderApp, RenderSet, WgpuWrapper, }; use bevy_app::{App, Plugin}; use bevy_ecs::{entity::hash_map::EntityHashMap, prelude::*}; diff --git a/crates/bevy_render/src/view/window/screenshot.rs b/crates/bevy_render/src/view/window/screenshot.rs index d8a309036edb4..e9c5bd513ba16 100644 --- a/crates/bevy_render/src/view/window/screenshot.rs +++ b/crates/bevy_render/src/view/window/screenshot.rs @@ -1,23 +1,23 @@ use super::ExtractedWindows; use crate::{ + ExtractSchedule, MainWorld, Render, RenderApp, RenderSet, camera::{ManualTextureViewHandle, ManualTextureViews, NormalizedRenderTarget, RenderTarget}, gpu_readback, prelude::Shader, render_asset::{RenderAssetUsages, RenderAssets}, render_resource::{ - binding_types::texture_2d, BindGroup, BindGroupEntries, BindGroupLayout, - BindGroupLayoutEntries, Buffer, BufferUsages, CachedRenderPipelineId, FragmentState, - PipelineCache, RenderPipelineDescriptor, SpecializedRenderPipeline, - SpecializedRenderPipelines, Texture, TextureUsages, TextureView, VertexState, + BindGroup, BindGroupEntries, BindGroupLayout, BindGroupLayoutEntries, Buffer, BufferUsages, + CachedRenderPipelineId, FragmentState, PipelineCache, RenderPipelineDescriptor, + SpecializedRenderPipeline, SpecializedRenderPipelines, Texture, TextureUsages, TextureView, + VertexState, binding_types::texture_2d, }, renderer::RenderDevice, texture::{GpuImage, OutputColorAttachment}, - view::{prepare_view_attachments, prepare_view_targets, ViewTargetAttachments, WindowSurfaces}, - ExtractSchedule, MainWorld, Render, RenderApp, RenderSet, + view::{ViewTargetAttachments, WindowSurfaces, prepare_view_attachments, prepare_view_targets}, }; use alloc::{borrow::Cow, sync::Arc}; use bevy_app::{First, Plugin, Update}; -use bevy_asset::{load_internal_asset, weak_handle, Handle}; +use bevy_asset::{Handle, load_internal_asset, weak_handle}; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::{ entity::hash_map::EntityHashMap, event::event_update_system, prelude::*, system::SystemState, @@ -32,8 +32,8 @@ use core::ops::Deref; use std::{ path::Path, sync::{ - mpsc::{Receiver, Sender}, Mutex, + mpsc::{Receiver, Sender}, }, }; use tracing::{error, info, warn}; diff --git a/crates/bevy_scene/src/components.rs b/crates/bevy_scene/src/components.rs index 8709c7990fd50..ba1d6134e7fbc 100644 --- a/crates/bevy_scene/src/components.rs +++ b/crates/bevy_scene/src/components.rs @@ -1,10 +1,10 @@ use bevy_asset::Handle; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::{ - component::{require, Component}, + component::{Component, require}, prelude::ReflectComponent, }; -use bevy_reflect::{prelude::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, prelude::ReflectDefault}; use bevy_transform::components::Transform; use derive_more::derive::From; diff --git a/crates/bevy_scene/src/dynamic_scene.rs b/crates/bevy_scene/src/dynamic_scene.rs index be45b54a811a9..c05ddf7119c92 100644 --- a/crates/bevy_scene/src/dynamic_scene.rs +++ b/crates/bevy_scene/src/dynamic_scene.rs @@ -1,8 +1,8 @@ -use crate::{ron, DynamicSceneBuilder, Scene, SceneSpawnError}; +use crate::{DynamicSceneBuilder, Scene, SceneSpawnError, ron}; use bevy_asset::Asset; use bevy_ecs::reflect::{ReflectMapEntities, ReflectResource}; use bevy_ecs::{ - entity::{hash_map::EntityHashMap, Entity, SceneEntityMapper}, + entity::{Entity, SceneEntityMapper, hash_map::EntityHashMap}, reflect::{AppTypeRegistry, ReflectComponent}, world::World, }; @@ -209,8 +209,8 @@ mod tests { use bevy_ecs::{ component::Component, entity::{ - hash_map::EntityHashMap, Entity, EntityMapper, MapEntities, VisitEntities, - VisitEntitiesMut, + Entity, EntityMapper, MapEntities, VisitEntities, VisitEntitiesMut, + hash_map::EntityHashMap, }, hierarchy::ChildOf, reflect::{AppTypeRegistry, ReflectComponent, ReflectMapEntities, ReflectResource}, diff --git a/crates/bevy_scene/src/dynamic_scene_builder.rs b/crates/bevy_scene/src/dynamic_scene_builder.rs index c33346373bcc7..86e07d7ac206c 100644 --- a/crates/bevy_scene/src/dynamic_scene_builder.rs +++ b/crates/bevy_scene/src/dynamic_scene_builder.rs @@ -731,15 +731,19 @@ mod tests { .build(); let component = &scene.entities[0].components[0]; - assert!(component - .try_as_reflect() - .expect("component should be concrete due to `FromReflect`") - .is::()); + assert!( + component + .try_as_reflect() + .expect("component should be concrete due to `FromReflect`") + .is::() + ); let resource = &scene.resources[0]; - assert!(resource - .try_as_reflect() - .expect("resource should be concrete due to `FromReflect`") - .is::()); + assert!( + resource + .try_as_reflect() + .expect("resource should be concrete due to `FromReflect`") + .is::() + ); } } diff --git a/crates/bevy_scene/src/scene.rs b/crates/bevy_scene/src/scene.rs index 9040b15e85f7c..27ac065d4f3de 100644 --- a/crates/bevy_scene/src/scene.rs +++ b/crates/bevy_scene/src/scene.rs @@ -4,7 +4,7 @@ use crate::{DynamicScene, SceneSpawnError}; use bevy_asset::Asset; use bevy_ecs::{ component::ComponentCloneBehavior, - entity::{hash_map::EntityHashMap, Entity, SceneEntityMapper}, + entity::{Entity, SceneEntityMapper, hash_map::EntityHashMap}, entity_disabling::DefaultQueryFilters, reflect::{AppTypeRegistry, ReflectComponent, ReflectResource}, world::World, diff --git a/crates/bevy_scene/src/scene_filter.rs b/crates/bevy_scene/src/scene_filter.rs index 732a1e5f15490..9f94f2b8bc11b 100644 --- a/crates/bevy_scene/src/scene_filter.rs +++ b/crates/bevy_scene/src/scene_filter.rs @@ -1,4 +1,4 @@ -use bevy_platform_support::collections::{hash_set::IntoIter, HashSet}; +use bevy_platform_support::collections::{HashSet, hash_set::IntoIter}; use core::any::{Any, TypeId}; /// A filter used to control which types can be added to a [`DynamicScene`]. diff --git a/crates/bevy_scene/src/scene_loader.rs b/crates/bevy_scene/src/scene_loader.rs index 481b7ebc04124..bf3b3ab30a5aa 100644 --- a/crates/bevy_scene/src/scene_loader.rs +++ b/crates/bevy_scene/src/scene_loader.rs @@ -1,7 +1,7 @@ #[cfg(feature = "serialize")] use crate::serde::SceneDeserializer; -use crate::{ron, DynamicScene}; -use bevy_asset::{io::Reader, AssetLoader, LoadContext}; +use crate::{DynamicScene, ron}; +use bevy_asset::{AssetLoader, LoadContext, io::Reader}; use bevy_ecs::{ reflect::AppTypeRegistry, world::{FromWorld, World}, diff --git a/crates/bevy_scene/src/scene_spawner.rs b/crates/bevy_scene/src/scene_spawner.rs index 3d4014f123534..c5fb7f7c7d019 100644 --- a/crates/bevy_scene/src/scene_spawner.rs +++ b/crates/bevy_scene/src/scene_spawner.rs @@ -1,7 +1,7 @@ use crate::{DynamicScene, Scene}; use bevy_asset::{AssetEvent, AssetId, Assets, Handle}; use bevy_ecs::{ - entity::{hash_map::EntityHashMap, Entity}, + entity::{Entity, hash_map::EntityHashMap}, event::{Event, EventCursor, Events}, hierarchy::ChildOf, reflect::AppTypeRegistry, @@ -85,13 +85,17 @@ pub struct SceneSpawner { #[derive(Error, Debug)] pub enum SceneSpawnError { /// Scene contains an unregistered component type. - #[error("scene contains the unregistered component `{type_path}`. consider adding `#[reflect(Component)]` to your type")] + #[error( + "scene contains the unregistered component `{type_path}`. consider adding `#[reflect(Component)]` to your type" + )] UnregisteredComponent { /// Type of the unregistered component. type_path: String, }, /// Scene contains an unregistered resource type. - #[error("scene contains the unregistered resource `{type_path}`. consider adding `#[reflect(Resource)]` to your type")] + #[error( + "scene contains the unregistered resource `{type_path}`. consider adding `#[reflect(Resource)]` to your type" + )] UnregisteredResource { /// Type of the unregistered resource. type_path: String, @@ -116,7 +120,9 @@ pub enum SceneSpawnError { type_path: String, }, /// Scene contains a proxy without a represented type. - #[error("scene contains dynamic type `{type_path}` without a represented type. consider changing this using `set_represented_type`.")] + #[error( + "scene contains dynamic type `{type_path}` without a represented type. consider changing this using `set_represented_type`." + )] NoRepresentedType { /// The dynamic instance type. type_path: String, diff --git a/crates/bevy_scene/src/serde.rs b/crates/bevy_scene/src/serde.rs index 8e26863e792ee..726745846193c 100644 --- a/crates/bevy_scene/src/serde.rs +++ b/crates/bevy_scene/src/serde.rs @@ -4,17 +4,17 @@ use crate::{DynamicEntity, DynamicScene}; use bevy_ecs::entity::Entity; use bevy_platform_support::collections::HashSet; use bevy_reflect::{ + PartialReflect, ReflectFromReflect, TypeRegistry, serde::{ ReflectDeserializer, TypeRegistrationDeserializer, TypedReflectDeserializer, TypedReflectSerializer, }, - PartialReflect, ReflectFromReflect, TypeRegistry, }; use core::fmt::Formatter; use serde::{ + Deserialize, Deserializer, Serialize, Serializer, de::{DeserializeSeed, Error, MapAccess, SeqAccess, Visitor}, ser::{SerializeMap, SerializeStruct}, - Deserialize, Deserializer, Serialize, Serializer, }; /// Name of the serialized scene struct type. @@ -510,12 +510,11 @@ impl<'a, 'de> Visitor<'de> for SceneMapVisitor<'a> { #[cfg(test)] mod tests { use crate::{ - ron, + DynamicScene, DynamicSceneBuilder, ron, serde::{SceneDeserializer, SceneSerializer}, - DynamicScene, DynamicSceneBuilder, }; use bevy_ecs::{ - entity::{hash_map::EntityHashMap, Entity}, + entity::{Entity, hash_map::EntityHashMap}, prelude::{Component, ReflectComponent, ReflectResource, Resource, World}, query::{With, Without}, reflect::AppTypeRegistry, @@ -523,7 +522,7 @@ mod tests { }; use bevy_reflect::{Reflect, ReflectDeserialize, ReflectSerialize}; use bincode::Options; - use serde::{de::DeserializeSeed, Deserialize, Serialize}; + use serde::{Deserialize, Serialize, de::DeserializeSeed}; use std::io::BufReader; #[derive(Component, Reflect, Default)] @@ -538,7 +537,7 @@ mod tests { // De/serialize as hex. mod qux { - use serde::{de::Error, Deserialize, Deserializer, Serializer}; + use serde::{Deserialize, Deserializer, Serializer, de::Error}; pub fn serialize(value: &u32, serializer: S) -> Result where @@ -772,10 +771,12 @@ mod tests { .unwrap(); assert_eq!(foo, bar_to_foo.0); - assert!(dst_world - .query_filtered::<&MyEntityRef, With>() - .iter(&dst_world) - .all(|r| world.get_entity(r.0).is_err())); + assert!( + dst_world + .query_filtered::<&MyEntityRef, With>() + .iter(&dst_world) + .all(|r| world.get_entity(r.0).is_err()) + ); } #[test] diff --git a/crates/bevy_sprite/src/lib.rs b/crates/bevy_sprite/src/lib.rs index 568701725d605..cac9864fa264a 100644 --- a/crates/bevy_sprite/src/lib.rs +++ b/crates/bevy_sprite/src/lib.rs @@ -23,9 +23,9 @@ mod texture_slice; pub mod prelude { #[doc(hidden)] pub use crate::{ + ColorMaterial, MeshMaterial2d, ScalingMode, sprite::{Sprite, SpriteImageMode}, texture_slice::{BorderRect, SliceScaleMode, TextureSlice, TextureSlicer}, - ColorMaterial, MeshMaterial2d, ScalingMode, }; } @@ -37,18 +37,18 @@ pub use sprite::*; pub use texture_slice::*; use bevy_app::prelude::*; -use bevy_asset::{load_internal_asset, weak_handle, AssetEvents, Assets, Handle}; +use bevy_asset::{AssetEvents, Assets, Handle, load_internal_asset, weak_handle}; use bevy_core_pipeline::core_2d::{AlphaMask2d, Opaque2d, Transparent2d}; use bevy_ecs::prelude::*; -use bevy_image::{prelude::*, TextureAtlasPlugin}; +use bevy_image::{TextureAtlasPlugin, prelude::*}; use bevy_render::{ + ExtractSchedule, Render, RenderApp, RenderSet, batching::sort_binned_render_phase, mesh::{Mesh, Mesh2d, MeshAabb}, primitives::Aabb, render_phase::AddRenderCommand, render_resource::{Shader, SpecializedRenderPipelines}, view::{NoFrustumCulling, VisibilitySystems}, - ExtractSchedule, Render, RenderApp, RenderSet, }; /// Adds support for 2D sprite rendering. @@ -246,21 +246,23 @@ mod test { let entity = app.world_mut().spawn(Sprite::from_image(image_handle)).id(); // Verify that the entity does not have an AABB - assert!(!app - .world() - .get_entity(entity) - .expect("Could not find entity") - .contains::()); + assert!( + !app.world() + .get_entity(entity) + .expect("Could not find entity") + .contains::() + ); // Run system app.update(); // Verify the AABB exists - assert!(app - .world() - .get_entity(entity) - .expect("Could not find entity") - .contains::()); + assert!( + app.world() + .get_entity(entity) + .expect("Could not find entity") + .contains::() + ); } #[test] diff --git a/crates/bevy_sprite/src/mesh2d/color_material.rs b/crates/bevy_sprite/src/mesh2d/color_material.rs index 15c965b7a788d..b4aca40a3eb86 100644 --- a/crates/bevy_sprite/src/mesh2d/color_material.rs +++ b/crates/bevy_sprite/src/mesh2d/color_material.rs @@ -1,6 +1,6 @@ use crate::{AlphaMode2d, Material2d, Material2dPlugin}; use bevy_app::{App, Plugin}; -use bevy_asset::{load_internal_asset, weak_handle, Asset, AssetApp, Assets, Handle}; +use bevy_asset::{Asset, AssetApp, Assets, Handle, load_internal_asset, weak_handle}; use bevy_color::{Alpha, Color, ColorToComponents, LinearRgba}; use bevy_image::Image; use bevy_math::Vec4; diff --git a/crates/bevy_sprite/src/mesh2d/material.rs b/crates/bevy_sprite/src/mesh2d/material.rs index fbe2c2132cdb6..cde64361f68f9 100644 --- a/crates/bevy_sprite/src/mesh2d/material.rs +++ b/crates/bevy_sprite/src/mesh2d/material.rs @@ -16,18 +16,19 @@ use bevy_ecs::component::Tick; use bevy_ecs::system::SystemChangeTick; use bevy_ecs::{ prelude::*, - system::{lifetimeless::SRes, SystemParamItem}, + system::{SystemParamItem, lifetimeless::SRes}, }; use bevy_math::FloatOrd; use bevy_platform_support::collections::HashMap; -use bevy_reflect::{prelude::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, prelude::ReflectDefault}; use bevy_render::render_phase::{DrawFunctionId, InputUniformIndex}; use bevy_render::render_resource::CachedRenderPipelineId; use bevy_render::view::RenderVisibleEntities; use bevy_render::{ + Extract, ExtractSchedule, Render, RenderApp, RenderSet, mesh::{MeshVertexBufferLayoutRef, RenderMesh}, render_asset::{ - prepare_assets, PrepareAssetError, RenderAsset, RenderAssetPlugin, RenderAssets, + PrepareAssetError, RenderAsset, RenderAssetPlugin, RenderAssets, prepare_assets, }, render_phase::{ AddRenderCommand, BinnedRenderPhaseType, DrawFunctions, PhaseItem, PhaseItemExtraIndex, @@ -42,7 +43,6 @@ use bevy_render::{ renderer::RenderDevice, sync_world::{MainEntity, MainEntityHashMap}, view::{ExtractedView, ViewVisibility}, - Extract, ExtractSchedule, Render, RenderApp, RenderSet, }; use core::{hash::Hash, marker::PhantomData}; use derive_more::derive::From; diff --git a/crates/bevy_sprite/src/mesh2d/mesh.rs b/crates/bevy_sprite/src/mesh2d/mesh.rs index 5822d47ed6231..8a9908d32d869 100644 --- a/crates/bevy_sprite/src/mesh2d/mesh.rs +++ b/crates/bevy_sprite/src/mesh2d/mesh.rs @@ -1,12 +1,12 @@ use bevy_app::Plugin; -use bevy_asset::{load_internal_asset, weak_handle, AssetId, Handle}; +use bevy_asset::{AssetId, Handle, load_internal_asset, weak_handle}; -use crate::{tonemapping_pipeline_key, Material2dBindGroupId}; +use crate::{Material2dBindGroupId, tonemapping_pipeline_key}; use bevy_core_pipeline::tonemapping::DebandDither; use bevy_core_pipeline::{ - core_2d::{AlphaMask2d, Camera2d, Opaque2d, Transparent2d, CORE_2D_DEPTH_FORMAT}, + core_2d::{AlphaMask2d, CORE_2D_DEPTH_FORMAT, Camera2d, Opaque2d, Transparent2d}, tonemapping::{ - get_lut_bind_group_layout_entries, get_lut_bindings, Tonemapping, TonemappingLuts, + Tonemapping, TonemappingLuts, get_lut_bind_group_layout_entries, get_lut_bindings, }, }; use bevy_derive::{Deref, DerefMut}; @@ -15,31 +15,32 @@ use bevy_ecs::system::SystemChangeTick; use bevy_ecs::{ prelude::*, query::ROQueryItem, - system::{lifetimeless::*, SystemParamItem, SystemState}, + system::{SystemParamItem, SystemState, lifetimeless::*}, }; use bevy_image::{BevyDefault, Image, ImageSampler, TextureFormatPixelInfo}; use bevy_math::{Affine3, Vec4}; +use bevy_render::RenderSet::PrepareAssets; use bevy_render::mesh::MeshTag; use bevy_render::prelude::Msaa; -use bevy_render::RenderSet::PrepareAssets; use bevy_render::{ + Extract, ExtractSchedule, Render, RenderApp, RenderSet, batching::{ + GetBatchData, GetFullBatchData, NoAutomaticBatching, gpu_preprocessing::IndirectParametersCpuMetadata, no_gpu_preprocessing::{ - self, batch_and_prepare_binned_render_phase, batch_and_prepare_sorted_render_phase, - write_batched_instance_buffer, BatchedInstanceBuffer, + self, BatchedInstanceBuffer, batch_and_prepare_binned_render_phase, + batch_and_prepare_sorted_render_phase, write_batched_instance_buffer, }, - GetBatchData, GetFullBatchData, NoAutomaticBatching, }, globals::{GlobalsBuffer, GlobalsUniform}, mesh::{ - allocator::MeshAllocator, Mesh, Mesh2d, MeshVertexBufferLayoutRef, RenderMesh, - RenderMeshBufferInfo, + Mesh, Mesh2d, MeshVertexBufferLayoutRef, RenderMesh, RenderMeshBufferInfo, + allocator::MeshAllocator, }, render_asset::RenderAssets, render_phase::{ - sweep_old_entities, PhaseItem, PhaseItemExtraIndex, RenderCommand, RenderCommandResult, - TrackedRenderPass, + PhaseItem, PhaseItemExtraIndex, RenderCommand, RenderCommandResult, TrackedRenderPass, + sweep_old_entities, }, render_resource::{binding_types::uniform_buffer, *}, renderer::{RenderDevice, RenderQueue}, @@ -48,7 +49,6 @@ use bevy_render::{ view::{ ExtractedView, ViewTarget, ViewUniform, ViewUniformOffset, ViewUniforms, ViewVisibility, }, - Extract, ExtractSchedule, Render, RenderApp, RenderSet, }; use bevy_transform::components::GlobalTransform; use nonmax::NonMaxU32; diff --git a/crates/bevy_sprite/src/mesh2d/wireframe2d.rs b/crates/bevy_sprite/src/mesh2d/wireframe2d.rs index 4547f83d9b6af..bea60e8b13b5d 100644 --- a/crates/bevy_sprite/src/mesh2d/wireframe2d.rs +++ b/crates/bevy_sprite/src/mesh2d/wireframe2d.rs @@ -1,9 +1,9 @@ use crate::{Material2d, Material2dKey, Material2dPlugin, Mesh2d}; use bevy_app::{Plugin, Startup, Update}; -use bevy_asset::{load_internal_asset, weak_handle, Asset, AssetApp, Assets, Handle}; +use bevy_asset::{Asset, AssetApp, Assets, Handle, load_internal_asset, weak_handle}; use bevy_color::{Color, LinearRgba}; use bevy_ecs::prelude::*; -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; use bevy_render::{ extract_resource::ExtractResource, mesh::MeshVertexBufferLayoutRef, prelude::*, render_resource::*, diff --git a/crates/bevy_sprite/src/picking_backend.rs b/crates/bevy_sprite/src/picking_backend.rs index 18fe21891ede3..56a779526781e 100644 --- a/crates/bevy_sprite/src/picking_backend.rs +++ b/crates/bevy_sprite/src/picking_backend.rs @@ -13,7 +13,7 @@ use bevy_asset::prelude::*; use bevy_color::Alpha; use bevy_ecs::prelude::*; use bevy_image::prelude::*; -use bevy_math::{prelude::*, FloatExt}; +use bevy_math::{FloatExt, prelude::*}; use bevy_picking::backend::prelude::*; use bevy_reflect::prelude::*; use bevy_render::prelude::*; diff --git a/crates/bevy_sprite/src/render/mod.rs b/crates/bevy_sprite/src/render/mod.rs index b188ebbc1aa47..480152329dc63 100644 --- a/crates/bevy_sprite/src/render/mod.rs +++ b/crates/bevy_sprite/src/render/mod.rs @@ -1,20 +1,20 @@ use core::ops::Range; -use crate::{ComputedTextureSlices, ScalingMode, Sprite, SPRITE_SHADER_HANDLE}; +use crate::{ComputedTextureSlices, SPRITE_SHADER_HANDLE, ScalingMode, Sprite}; use bevy_asset::{AssetEvent, AssetId, Assets}; use bevy_color::{ColorToComponents, LinearRgba}; use bevy_core_pipeline::{ - core_2d::{Transparent2d, CORE_2D_DEPTH_FORMAT}, + core_2d::{CORE_2D_DEPTH_FORMAT, Transparent2d}, tonemapping::{ - get_lut_bind_group_layout_entries, get_lut_bindings, DebandDither, Tonemapping, - TonemappingLuts, + DebandDither, Tonemapping, TonemappingLuts, get_lut_bind_group_layout_entries, + get_lut_bindings, }, }; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::{ prelude::*, query::ROQueryItem, - system::{lifetimeless::*, SystemParamItem, SystemState}, + system::{SystemParamItem, SystemState, lifetimeless::*}, }; use bevy_image::{BevyDefault, Image, ImageSampler, TextureAtlasLayout, TextureFormatPixelInfo}; use bevy_math::{Affine3A, FloatOrd, Quat, Rect, Vec2, Vec4}; @@ -22,6 +22,7 @@ use bevy_platform_support::collections::HashMap; use bevy_render::sync_world::MainEntity; use bevy_render::view::{RenderVisibleEntities, RetainedViewEntity}; use bevy_render::{ + Extract, render_asset::RenderAssets, render_phase::{ DrawFunctions, PhaseItem, PhaseItemExtraIndex, RenderCommand, RenderCommandResult, @@ -38,7 +39,6 @@ use bevy_render::{ ExtractedView, Msaa, ViewTarget, ViewUniform, ViewUniformOffset, ViewUniforms, ViewVisibility, }, - Extract, }; use bevy_transform::components::GlobalTransform; use bytemuck::{Pod, Zeroable}; diff --git a/crates/bevy_sprite/src/sprite.rs b/crates/bevy_sprite/src/sprite.rs index 59c60071a0293..5bf6c0693779e 100644 --- a/crates/bevy_sprite/src/sprite.rs +++ b/crates/bevy_sprite/src/sprite.rs @@ -1,12 +1,12 @@ use bevy_asset::{Assets, Handle}; use bevy_color::Color; use bevy_ecs::{ - component::{require, Component}, + component::{Component, require}, reflect::ReflectComponent, }; use bevy_image::{Image, TextureAtlas, TextureAtlasLayout}; use bevy_math::{Rect, UVec2, Vec2}; -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; use bevy_render::{ sync_world::SyncToRenderWorld, view::{self, Visibility, VisibilityClass}, diff --git a/crates/bevy_sprite/src/texture_slice/mod.rs b/crates/bevy_sprite/src/texture_slice/mod.rs index 7ea01d5839dc2..bbbf4221ed7ff 100644 --- a/crates/bevy_sprite/src/texture_slice/mod.rs +++ b/crates/bevy_sprite/src/texture_slice/mod.rs @@ -7,7 +7,7 @@ pub use border_rect::BorderRect; pub use slicer::{SliceScaleMode, TextureSlicer}; pub(crate) use computed_slices::{ - compute_slices_on_asset_event, compute_slices_on_sprite_change, ComputedTextureSlices, + ComputedTextureSlices, compute_slices_on_asset_event, compute_slices_on_sprite_change, }; /// Single texture slice, representing a texture rect to draw in a given area @@ -86,7 +86,10 @@ impl TextureSlice { remaining_columns -= size_y; } if slices.len() > 1_000 { - tracing::warn!("One of your tiled textures has generated {} slices. You might want to use higher stretch values to avoid a great performance cost", slices.len()); + tracing::warn!( + "One of your tiled textures has generated {} slices. You might want to use higher stretch values to avoid a great performance cost", + slices.len() + ); } slices } diff --git a/crates/bevy_sprite/src/texture_slice/slicer.rs b/crates/bevy_sprite/src/texture_slice/slicer.rs index 7250533550dff..07cd97162f4e7 100644 --- a/crates/bevy_sprite/src/texture_slice/slicer.rs +++ b/crates/bevy_sprite/src/texture_slice/slicer.rs @@ -1,5 +1,5 @@ use super::{BorderRect, TextureSlice}; -use bevy_math::{vec2, Rect, Vec2}; +use bevy_math::{Rect, Vec2, vec2}; use bevy_reflect::Reflect; /// Slices a texture using the **9-slicing** technique. This allows to reuse an image at various sizes diff --git a/crates/bevy_state/macros/src/states.rs b/crates/bevy_state/macros/src/states.rs index 52c133f6ee204..7cc0087370463 100644 --- a/crates/bevy_state/macros/src/states.rs +++ b/crates/bevy_state/macros/src/states.rs @@ -1,6 +1,6 @@ use proc_macro::TokenStream; use quote::{format_ident, quote}; -use syn::{parse_macro_input, spanned::Spanned, DeriveInput, Pat, Path, Result}; +use syn::{DeriveInput, Pat, Path, Result, parse_macro_input, spanned::Spanned}; use crate::bevy_state_path; diff --git a/crates/bevy_state/src/app.rs b/crates/bevy_state/src/app.rs index 2419efd4d8a99..3f3ee06c2aaba 100644 --- a/crates/bevy_state/src/app.rs +++ b/crates/bevy_state/src/app.rs @@ -5,8 +5,9 @@ use log::warn; use crate::{ state::{ - setup_state_transitions_in_world, ComputedStates, FreelyMutableState, NextState, State, - StateTransition, StateTransitionEvent, StateTransitionSteps, States, SubStates, + ComputedStates, FreelyMutableState, NextState, State, StateTransition, + StateTransitionEvent, StateTransitionSteps, States, SubStates, + setup_state_transitions_in_world, }, state_scoped::clear_state_scoped_entities, }; @@ -220,7 +221,10 @@ impl AppExtStates for SubApp { .contains_resource::>>() { let name = core::any::type_name::(); - warn!("State scoped entities are enabled for state `{}`, but the state isn't installed in the app!", name); + warn!( + "State scoped entities are enabled for state `{}`, but the state isn't installed in the app!", + name + ); } // We work with [`StateTransition`] in set [`StateTransitionSteps::ExitSchedules`] as opposed to [`OnExit`], // because [`OnExit`] only runs for one specific variant of the state. diff --git a/crates/bevy_state/src/lib.rs b/crates/bevy_state/src/lib.rs index b2714b50c5025..bf1dc541d99b4 100644 --- a/crates/bevy_state/src/lib.rs +++ b/crates/bevy_state/src/lib.rs @@ -85,9 +85,9 @@ pub mod prelude { commands::CommandsStatesExt, condition::*, state::{ - last_transition, ComputedStates, EnterSchedules, ExitSchedules, NextState, OnEnter, - OnExit, OnTransition, State, StateSet, StateTransition, StateTransitionEvent, States, - SubStates, TransitionSchedules, + ComputedStates, EnterSchedules, ExitSchedules, NextState, OnEnter, OnExit, + OnTransition, State, StateSet, StateTransition, StateTransitionEvent, States, + SubStates, TransitionSchedules, last_transition, }, state_scoped::StateScoped, }; diff --git a/crates/bevy_state/src/state/freely_mutable_state.rs b/crates/bevy_state/src/state/freely_mutable_state.rs index 2bc186ebe0fb2..55983d5a0d632 100644 --- a/crates/bevy_state/src/state/freely_mutable_state.rs +++ b/crates/bevy_state/src/state/freely_mutable_state.rs @@ -5,7 +5,7 @@ use bevy_ecs::{ system::{Commands, IntoSystem, ResMut}, }; -use super::{states::States, take_next_state, transitions::*, NextState, State}; +use super::{NextState, State, states::States, take_next_state, transitions::*}; /// This trait allows a state to be mutated directly using the [`NextState`](crate::state::NextState) resource. /// diff --git a/crates/bevy_state/src/state/mod.rs b/crates/bevy_state/src/state/mod.rs index 9267478281575..867c964ec6a21 100644 --- a/crates/bevy_state/src/state/mod.rs +++ b/crates/bevy_state/src/state/mod.rs @@ -525,9 +525,11 @@ mod tests { world.run_schedule(StateTransition); assert_eq!(world.resource::>().0, SimpleState::A); - assert!(world - .resource::>>() - .is_empty()); + assert!( + world + .resource::>>() + .is_empty() + ); world.insert_resource(TransitionCounter::default()); world.insert_resource(NextState::Pending(SimpleState::A)); diff --git a/crates/bevy_state/src/state/state_set.rs b/crates/bevy_state/src/state/state_set.rs index ca167d4970596..4d6f42afbdb58 100644 --- a/crates/bevy_state/src/state/state_set.rs +++ b/crates/bevy_state/src/state/state_set.rs @@ -8,10 +8,10 @@ use variadics_please::all_tuples; use self::sealed::StateSetSealed; use super::{ - computed_states::ComputedStates, internal_apply_state_transition, last_transition, run_enter, - run_exit, run_transition, sub_states::SubStates, take_next_state, ApplyStateTransition, - EnterSchedules, ExitSchedules, NextState, State, StateTransitionEvent, StateTransitionSteps, - States, TransitionSchedules, + ApplyStateTransition, EnterSchedules, ExitSchedules, NextState, State, StateTransitionEvent, + StateTransitionSteps, States, TransitionSchedules, computed_states::ComputedStates, + internal_apply_state_transition, last_transition, run_enter, run_exit, run_transition, + sub_states::SubStates, take_next_state, }; mod sealed { diff --git a/crates/bevy_tasks/src/task_pool.rs b/crates/bevy_tasks/src/task_pool.rs index b9c0e9f98261a..891c971b356b4 100644 --- a/crates/bevy_tasks/src/task_pool.rs +++ b/crates/bevy_tasks/src/task_pool.rs @@ -11,9 +11,8 @@ use concurrent_queue::ConcurrentQueue; use futures_lite::FutureExt; use crate::{ - block_on, + Task, block_on, thread_executor::{ThreadExecutor, ThreadExecutorTicker}, - Task, }; struct CallOnDrop(Option>); diff --git a/crates/bevy_text/src/bounds.rs b/crates/bevy_text/src/bounds.rs index 98d42e3a34b28..ce7193c5fdd02 100644 --- a/crates/bevy_text/src/bounds.rs +++ b/crates/bevy_text/src/bounds.rs @@ -1,6 +1,6 @@ use bevy_ecs::{component::Component, reflect::ReflectComponent}; use bevy_math::Vec2; -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; /// The maximum width and height of text. The text will wrap according to the specified size. /// diff --git a/crates/bevy_text/src/font_atlas.rs b/crates/bevy_text/src/font_atlas.rs index e14157cb38f8a..1bf4c021208e0 100644 --- a/crates/bevy_text/src/font_atlas.rs +++ b/crates/bevy_text/src/font_atlas.rs @@ -1,5 +1,5 @@ use bevy_asset::{Assets, Handle}; -use bevy_image::{prelude::*, ImageSampler}; +use bevy_image::{ImageSampler, prelude::*}; use bevy_math::{IVec2, UVec2}; use bevy_platform_support::collections::HashMap; use bevy_render::{ diff --git a/crates/bevy_text/src/font_atlas_set.rs b/crates/bevy_text/src/font_atlas_set.rs index 92b71ef535842..144b15fd5f6c2 100644 --- a/crates/bevy_text/src/font_atlas_set.rs +++ b/crates/bevy_text/src/font_atlas_set.rs @@ -9,7 +9,7 @@ use bevy_render::{ render_resource::{Extent3d, TextureDimension, TextureFormat}, }; -use crate::{error::TextError, Font, FontAtlas, FontSmoothing, GlyphAtlasInfo}; +use crate::{Font, FontAtlas, FontSmoothing, GlyphAtlasInfo, error::TextError}; /// A map of font faces to their corresponding [`FontAtlasSet`]s. #[derive(Debug, Default, Resource)] diff --git a/crates/bevy_text/src/font_loader.rs b/crates/bevy_text/src/font_loader.rs index 9e0f2185a234e..12a1be8ba4d88 100644 --- a/crates/bevy_text/src/font_loader.rs +++ b/crates/bevy_text/src/font_loader.rs @@ -1,5 +1,5 @@ use crate::Font; -use bevy_asset::{io::Reader, AssetLoader, LoadContext}; +use bevy_asset::{AssetLoader, LoadContext, io::Reader}; use thiserror::Error; #[derive(Default)] diff --git a/crates/bevy_text/src/lib.rs b/crates/bevy_text/src/lib.rs index 670f793c31c15..0542c17d46c92 100644 --- a/crates/bevy_text/src/lib.rs +++ b/crates/bevy_text/src/lib.rs @@ -52,8 +52,8 @@ pub use font_loader::*; pub use glyph::*; pub use pipeline::*; pub use text::*; -pub use text2d::*; pub use text_access::*; +pub use text2d::*; /// The text prelude. /// @@ -66,13 +66,13 @@ pub mod prelude { }; } -use bevy_app::{prelude::*, Animation}; -#[cfg(feature = "default_font")] -use bevy_asset::{load_internal_binary_asset, Handle}; +use bevy_app::{Animation, prelude::*}; use bevy_asset::{AssetApp, AssetEvents}; +#[cfg(feature = "default_font")] +use bevy_asset::{Handle, load_internal_binary_asset}; use bevy_ecs::prelude::*; use bevy_render::{ - camera::CameraUpdateSystem, view::VisibilitySystems, ExtractSchedule, RenderApp, + ExtractSchedule, RenderApp, camera::CameraUpdateSystem, view::VisibilitySystems, }; use bevy_sprite::SpriteSystem; diff --git a/crates/bevy_text/src/pipeline.rs b/crates/bevy_text/src/pipeline.rs index e7774569cfb25..a742e52b178ce 100644 --- a/crates/bevy_text/src/pipeline.rs +++ b/crates/bevy_text/src/pipeline.rs @@ -11,13 +11,13 @@ use bevy_image::prelude::*; use bevy_log::{once, warn}; use bevy_math::{UVec2, Vec2}; use bevy_platform_support::collections::HashMap; -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; use cosmic_text::{Attrs, Buffer, Family, Metrics, Shaping, Wrap}; use crate::{ - error::TextError, ComputedTextBlock, Font, FontAtlasSets, FontSmoothing, JustifyText, - LineBreak, PositionedGlyph, TextBounds, TextEntity, TextFont, TextLayout, YAxisOrientation, + ComputedTextBlock, Font, FontAtlasSets, FontSmoothing, JustifyText, LineBreak, PositionedGlyph, + TextBounds, TextEntity, TextFont, TextLayout, YAxisOrientation, error::TextError, }; /// A wrapper resource around a [`cosmic_text::FontSystem`] diff --git a/crates/bevy_text/src/text.rs b/crates/bevy_text/src/text.rs index 7c88010de9118..7314ec9b3b8bb 100644 --- a/crates/bevy_text/src/text.rs +++ b/crates/bevy_text/src/text.rs @@ -497,8 +497,12 @@ pub fn detect_text_needs_rerender( // - Root children changed (can include additions and removals). for root in changed_roots.iter() { let Ok((_, Some(mut computed), _)) = computed.get_mut(root) else { - once!(warn!("found entity {} with a root text component ({}) but no ComputedTextBlock; this warning only \ - prints once", root, core::any::type_name::())); + once!(warn!( + "found entity {} with a root text component ({}) but no ComputedTextBlock; this warning only \ + prints once", + root, + core::any::type_name::() + )); continue; }; computed.needs_rerender = true; @@ -510,9 +514,12 @@ pub fn detect_text_needs_rerender( // - Span children changed (can include additions and removals). for (entity, maybe_span_parent, has_text_block) in changed_spans.iter() { if has_text_block { - once!(warn!("found entity {} with a TextSpan that has a TextLayout, which should only be on root \ + once!(warn!( + "found entity {} with a TextSpan that has a TextLayout, which should only be on root \ text entities (that have {}); this warning only prints once", - entity, core::any::type_name::())); + entity, + core::any::type_name::() + )); } let Some(span_parent) = maybe_span_parent else { @@ -531,9 +538,11 @@ pub fn detect_text_needs_rerender( // is outweighed by the expense of tracking visited spans. loop { let Ok((maybe_parent, maybe_computed, has_span)) = computed.get_mut(parent) else { - once!(warn!("found entity {} with a TextSpan that is part of a broken hierarchy with a ChildOf \ + once!(warn!( + "found entity {} with a TextSpan that is part of a broken hierarchy with a ChildOf \ component that points at non-existent entity {}; this warning only prints once", - entity, parent)); + entity, parent + )); break; }; if let Some(mut computed) = maybe_computed { @@ -541,9 +550,11 @@ pub fn detect_text_needs_rerender( break; } if !has_span { - once!(warn!("found entity {} with a TextSpan that has an ancestor ({}) that does not have a text \ + once!(warn!( + "found entity {} with a TextSpan that has an ancestor ({}) that does not have a text \ span component or a ComputedTextBlock component; this warning only prints once", - entity, parent)); + entity, parent + )); break; } let Some(next_parent) = maybe_parent else { diff --git a/crates/bevy_text/src/text2d.rs b/crates/bevy_text/src/text2d.rs index 952627a6b785c..0e475881c71c5 100644 --- a/crates/bevy_text/src/text2d.rs +++ b/crates/bevy_text/src/text2d.rs @@ -10,7 +10,7 @@ use bevy_derive::{Deref, DerefMut}; use bevy_ecs::entity::hash_set::EntityHashSet; use bevy_ecs::{ change_detection::{DetectChanges, Ref}, - component::{require, Component}, + component::{Component, require}, entity::Entity, prelude::{ReflectComponent, With}, query::{Changed, Without}, @@ -18,13 +18,13 @@ use bevy_ecs::{ }; use bevy_image::prelude::*; use bevy_math::Vec2; -use bevy_reflect::{prelude::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, prelude::ReflectDefault}; use bevy_render::sync_world::TemporaryRenderEntity; use bevy_render::view::{self, Visibility, VisibilityClass}; use bevy_render::{ + Extract, primitives::Aabb, view::{NoFrustumCulling, ViewVisibility}, - Extract, }; use bevy_sprite::{Anchor, ExtractedSprite, ExtractedSprites, Sprite}; use bevy_transform::components::Transform; @@ -370,10 +370,10 @@ pub fn calculate_bounds_text2d( mod tests { use bevy_app::{App, Update}; - use bevy_asset::{load_internal_binary_asset, Handle}; + use bevy_asset::{Handle, load_internal_binary_asset}; use bevy_ecs::schedule::IntoSystemConfigs; - use crate::{detect_text_needs_rerender, TextIterScratch}; + use crate::{TextIterScratch, detect_text_needs_rerender}; use super::*; @@ -417,11 +417,12 @@ mod tests { fn calculate_bounds_text2d_create_aabb() { let (mut app, entity) = setup(); - assert!(!app - .world() - .get_entity(entity) - .expect("Could not find entity") - .contains::()); + assert!( + !app.world() + .get_entity(entity) + .expect("Could not find entity") + .contains::() + ); // Creates the AABB after text layouting. app.update(); diff --git a/crates/bevy_time/src/lib.rs b/crates/bevy_time/src/lib.rs index 334ff549a958c..ca4821e78698f 100644 --- a/crates/bevy_time/src/lib.rs +++ b/crates/bevy_time/src/lib.rs @@ -36,9 +36,9 @@ pub mod prelude { pub use crate::{Fixed, Real, Time, Timer, TimerMode, Virtual}; } -use bevy_app::{prelude::*, RunFixedMainLoop}; +use bevy_app::{RunFixedMainLoop, prelude::*}; use bevy_ecs::{ - event::{event_update_system, signal_event_update_system, EventRegistry, ShouldUpdateEvents}, + event::{EventRegistry, ShouldUpdateEvents, event_update_system, signal_event_update_system}, prelude::*, }; use bevy_platform_support::time::Instant; @@ -153,7 +153,9 @@ pub fn time_system( } Some(Err(_)) => { if *has_received_time { - log::warn!("time_system did not receive the time from the render world! Calculations depending on the time may be incorrect."); + log::warn!( + "time_system did not receive the time from the render world! Calculations depending on the time may be incorrect." + ); } None } @@ -355,7 +357,9 @@ mod tests { let event_registry = app.world().resource::(); let should_update = event_registry.should_update; - println!("Frame {frame}, {fixed_updates_seen} fixed updates seen. Should update: {should_update:?}"); + println!( + "Frame {frame}, {fixed_updates_seen} fixed updates seen. Should update: {should_update:?}" + ); println!("Total events: {n_total_events} | Current events: {n_current_events}",); match frame { diff --git a/crates/bevy_time/src/stopwatch.rs b/crates/bevy_time/src/stopwatch.rs index f90503ee24b6f..6bc95c4918d76 100644 --- a/crates/bevy_time/src/stopwatch.rs +++ b/crates/bevy_time/src/stopwatch.rs @@ -1,5 +1,5 @@ #[cfg(feature = "bevy_reflect")] -use bevy_reflect::{prelude::*, Reflect}; +use bevy_reflect::{Reflect, prelude::*}; use core::time::Duration; /// A Stopwatch is a struct that tracks elapsed time when started. diff --git a/crates/bevy_time/src/time.rs b/crates/bevy_time/src/time.rs index 3b5dbc8e26633..bcc54b1fc49a2 100644 --- a/crates/bevy_time/src/time.rs +++ b/crates/bevy_time/src/time.rs @@ -3,7 +3,7 @@ use core::time::Duration; #[cfg(feature = "bevy_reflect")] use { bevy_ecs::reflect::ReflectResource, - bevy_reflect::{std_traits::ReflectDefault, Reflect}, + bevy_reflect::{Reflect, std_traits::ReflectDefault}, }; /// A generic clock resource that tracks how much it has advanced since its diff --git a/crates/bevy_transform/src/components/global_transform.rs b/crates/bevy_transform/src/components/global_transform.rs index ecd59fac9d7da..601af69c40088 100644 --- a/crates/bevy_transform/src/components/global_transform.rs +++ b/crates/bevy_transform/src/components/global_transform.rs @@ -1,7 +1,7 @@ use core::ops::Mul; use super::Transform; -use bevy_math::{ops, Affine3A, Dir3, Isometry3d, Mat4, Quat, Vec3, Vec3A}; +use bevy_math::{Affine3A, Dir3, Isometry3d, Mat4, Quat, Vec3, Vec3A, ops}; use derive_more::derive::From; #[cfg(all(feature = "bevy_reflect", feature = "serialize"))] @@ -13,7 +13,7 @@ use bevy_ecs::{component::Component, hierarchy::validate_parent_has_component}; #[cfg(feature = "bevy_reflect")] use { bevy_ecs::reflect::ReflectComponent, - bevy_reflect::{std_traits::ReflectDefault, Reflect}, + bevy_reflect::{Reflect, std_traits::ReflectDefault}, }; /// [`GlobalTransform`] is an affine transformation from entity-local coordinates to worldspace coordinates. diff --git a/crates/bevy_transform/src/helper.rs b/crates/bevy_transform/src/helper.rs index 777ca81a9dbd5..a4f28cbf9d8ae 100644 --- a/crates/bevy_transform/src/helper.rs +++ b/crates/bevy_transform/src/helper.rs @@ -96,9 +96,11 @@ mod tests { #[test] fn match_transform_propagation_systems() { // Single transform - match_transform_propagation_systems_inner(vec![Transform::from_translation(Vec3::X) - .with_rotation(Quat::from_rotation_y(TAU / 4.)) - .with_scale(Vec3::splat(2.))]); + match_transform_propagation_systems_inner(vec![ + Transform::from_translation(Vec3::X) + .with_rotation(Quat::from_rotation_y(TAU / 4.)) + .with_scale(Vec3::splat(2.)), + ]); // Transform hierarchy match_transform_propagation_systems_inner(vec![ diff --git a/crates/bevy_transform/src/systems.rs b/crates/bevy_transform/src/systems.rs index 5f070c2ed65d3..2a2764bc095e9 100644 --- a/crates/bevy_transform/src/systems.rs +++ b/crates/bevy_transform/src/systems.rs @@ -160,7 +160,8 @@ unsafe fn propagate_recursive( let Some(children) = children else { return }; for (child, actual_parent) in parent_query.iter_many(children) { assert_eq!( - actual_parent.get(), entity, + actual_parent.get(), + entity, "Malformed hierarchy. This probably means that your hierarchy has been improperly maintained, or contains a cycle" ); // SAFETY: The caller guarantees that `transform_query` will not be fetched @@ -185,7 +186,7 @@ mod test { use alloc::vec; use bevy_app::prelude::*; use bevy_ecs::{prelude::*, world::CommandQueue}; - use bevy_math::{vec3, Vec3}; + use bevy_math::{Vec3, vec3}; use bevy_tasks::{ComputeTaskPool, TaskPool}; use crate::systems::*; @@ -453,23 +454,16 @@ mod test { .spawn(Transform::IDENTITY) .add_children(&[child]); - let mut child_entity = app - .world_mut() - .entity_mut(child); + let mut child_entity = app.world_mut().entity_mut(child); - let mut grandchild_entity = temp - .entity_mut(grandchild); + let mut grandchild_entity = temp.entity_mut(grandchild); #[expect( unsafe_code, reason = "ChildOf is not mutable but this is for a test to produce a scenario that cannot happen" )] // SAFETY: ChildOf is not mutable but this is for a test to produce a scenario that cannot happen - let mut a = unsafe { - child_entity - .get_mut_assume_mutable::() - .unwrap() - }; + let mut a = unsafe { child_entity.get_mut_assume_mutable::().unwrap() }; // SAFETY: ChildOf is not mutable but this is for a test to produce a scenario that cannot happen #[expect( @@ -482,10 +476,7 @@ mod test { .unwrap() }; - core::mem::swap( - a.as_mut(), - b.as_mut(), - ); + core::mem::swap(a.as_mut(), b.as_mut()); app.update(); } @@ -514,12 +505,16 @@ mod test { // Child should be positioned relative to its parent let parent_global_transform = *world.entity(parent).get::().unwrap(); let child_global_transform = *world.entity(child).get::().unwrap(); - assert!(parent_global_transform - .translation() - .abs_diff_eq(translation, 0.1)); - assert!(child_global_transform - .translation() - .abs_diff_eq(2. * translation, 0.1)); + assert!( + parent_global_transform + .translation() + .abs_diff_eq(translation, 0.1) + ); + assert!( + child_global_transform + .translation() + .abs_diff_eq(2. * translation, 0.1) + ); // Reparent child world.entity_mut(child).remove::(); diff --git a/crates/bevy_ui/src/accessibility.rs b/crates/bevy_ui/src/accessibility.rs index 95686530ce37e..5e8ffc217df3d 100644 --- a/crates/bevy_ui/src/accessibility.rs +++ b/crates/bevy_ui/src/accessibility.rs @@ -1,8 +1,8 @@ use crate::{ + ComputedNode, experimental::UiChildren, prelude::{Button, Label}, widget::{ImageNode, TextUiReader}, - ComputedNode, }; use bevy_a11y::AccessibilityNode; use bevy_app::{App, Plugin, PostUpdate}; diff --git a/crates/bevy_ui/src/experimental/ghost_hierarchy.rs b/crates/bevy_ui/src/experimental/ghost_hierarchy.rs index 8e663964f7eb9..ecc0ef4be24a7 100644 --- a/crates/bevy_ui/src/experimental/ghost_hierarchy.rs +++ b/crates/bevy_ui/src/experimental/ghost_hierarchy.rs @@ -1,8 +1,8 @@ //! This module contains [`GhostNode`] and utilities to flatten the UI hierarchy, traversing past ghost nodes. +use crate::Node; #[cfg(feature = "ghost_nodes")] use crate::ui_node::ComputedNodeTarget; -use crate::Node; use bevy_ecs::{prelude::*, system::SystemParam}; #[cfg(feature = "ghost_nodes")] use bevy_reflect::prelude::*; diff --git a/crates/bevy_ui/src/focus.rs b/crates/bevy_ui/src/focus.rs index 4093b81d55347..78b55c37832e4 100644 --- a/crates/bevy_ui/src/focus.rs +++ b/crates/bevy_ui/src/focus.rs @@ -7,10 +7,10 @@ use bevy_ecs::{ reflect::ReflectComponent, system::{Local, Query, Res}, }; -use bevy_input::{mouse::MouseButton, touch::Touches, ButtonInput}; +use bevy_input::{ButtonInput, mouse::MouseButton, touch::Touches}; use bevy_math::{Rect, Vec2}; use bevy_platform_support::collections::HashMap; -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; use bevy_render::{camera::NormalizedRenderTarget, prelude::Camera, view::InheritedVisibility}; use bevy_transform::components::GlobalTransform; use bevy_window::{PrimaryWindow, Window}; diff --git a/crates/bevy_ui/src/geometry.rs b/crates/bevy_ui/src/geometry.rs index a8b523d696fa1..755868f311358 100644 --- a/crates/bevy_ui/src/geometry.rs +++ b/crates/bevy_ui/src/geometry.rs @@ -1,5 +1,5 @@ use bevy_math::Vec2; -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; use core::ops::{Div, DivAssign, Mul, MulAssign, Neg}; use thiserror::Error; diff --git a/crates/bevy_ui/src/layout/mod.rs b/crates/bevy_ui/src/layout/mod.rs index 912079fdaeac8..d8833649b0bd1 100644 --- a/crates/bevy_ui/src/layout/mod.rs +++ b/crates/bevy_ui/src/layout/mod.rs @@ -1,7 +1,7 @@ use crate::{ - experimental::{UiChildren, UiRootNodes}, BorderRadius, ComputedNode, ComputedNodeTarget, ContentSize, Display, LayoutConfig, Node, Outline, OverflowAxis, ScrollPosition, Val, + experimental::{UiChildren, UiRootNodes}, }; use bevy_ecs::{ change_detection::{DetectChanges, DetectChangesMut}, @@ -364,8 +364,8 @@ mod tests { }; use crate::{ - layout::ui_surface::UiSurface, prelude::*, ui_layout_system, - update::update_ui_context_system, ContentSize, LayoutContext, + ContentSize, LayoutContext, layout::ui_surface::UiSurface, prelude::*, ui_layout_system, + update::update_ui_context_system, }; // these window dimensions are easy to convert to and from percentage values @@ -580,24 +580,30 @@ mod tests { ui_surface.taffy.parent(child_node.id), Some(ui_parent_node.id) ); - assert!(ui_surface - .taffy - .children(ui_parent_node.id) - .unwrap() - .contains(&child_node.id)); + assert!( + ui_surface + .taffy + .children(ui_parent_node.id) + .unwrap() + .contains(&child_node.id) + ); } // the nodes of the deleted children should have been removed from the layout tree for deleted_child_entity in &deleted_children { - assert!(!ui_surface - .entity_to_taffy - .contains_key(deleted_child_entity)); + assert!( + !ui_surface + .entity_to_taffy + .contains_key(deleted_child_entity) + ); let deleted_child_node = child_node_map[deleted_child_entity]; - assert!(!ui_surface - .taffy - .children(ui_parent_node.id) - .unwrap() - .contains(&deleted_child_node.id)); + assert!( + !ui_surface + .taffy + .children(ui_parent_node.id) + .unwrap() + .contains(&deleted_child_node.id) + ); } // despawn the parent entity and its descendants @@ -712,7 +718,10 @@ mod tests { let Some((_rect, is_overlapping)) = overlap_check else { unreachable!("test not setup properly"); }; - assert!(is_overlapping, "root ui nodes are expected to behave like they have absolute position and be independent from each other"); + assert!( + is_overlapping, + "root ui nodes are expected to behave like they have absolute position and be independent from each other" + ); } #[test] @@ -852,7 +861,9 @@ mod tests { let current_taffy_node_count = get_taffy_node_count(&world); if current_taffy_node_count > expected_max_taffy_node_count { - panic!("extra taffy nodes detected: current: {current_taffy_node_count} max expected: {expected_max_taffy_node_count}"); + panic!( + "extra taffy nodes detected: current: {current_taffy_node_count} max expected: {expected_max_taffy_node_count}" + ); } } diff --git a/crates/bevy_ui/src/layout/ui_surface.rs b/crates/bevy_ui/src/layout/ui_surface.rs index e0333763b83d2..bdb52fe753859 100644 --- a/crates/bevy_ui/src/layout/ui_surface.rs +++ b/crates/bevy_ui/src/layout/ui_surface.rs @@ -4,13 +4,13 @@ use bevy_platform_support::collections::hash_map::Entry; use taffy::TaffyTree; use bevy_ecs::{ - entity::{hash_map::EntityHashMap, Entity}, + entity::{Entity, hash_map::EntityHashMap}, prelude::Resource, }; use bevy_math::{UVec2, Vec2}; use bevy_utils::default; -use crate::{layout::convert, LayoutContext, LayoutError, Measure, MeasureArgs, Node, NodeMeasure}; +use crate::{LayoutContext, LayoutError, Measure, MeasureArgs, Node, NodeMeasure, layout::convert}; use bevy_text::CosmicFontSystem; #[derive(Debug, Copy, Clone, PartialEq, Eq)] @@ -373,9 +373,11 @@ mod tests { let mut content_size = ContentSize::default(); content_size.set(NodeMeasure::Fixed(FixedMeasure { size: Vec2::ONE })); let measure_func = content_size.measure.take().unwrap(); - assert!(ui_surface - .update_node_context(root_node_entity, measure_func) - .is_some()); + assert!( + ui_surface + .update_node_context(root_node_entity, measure_func) + .is_some() + ); } #[test] diff --git a/crates/bevy_ui/src/lib.rs b/crates/bevy_ui/src/lib.rs index 5dfb4feeebaf1..c92744bc6f895 100644 --- a/crates/bevy_ui/src/lib.rs +++ b/crates/bevy_ui/src/lib.rs @@ -19,7 +19,7 @@ pub mod widget; pub mod picking_backend; use bevy_derive::{Deref, DerefMut}; -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; mod accessibility; // This module is not re-exported, but is instead made public. // This is intended to discourage accidental use of the experimental API. @@ -53,25 +53,25 @@ pub mod prelude { #[doc(hidden)] pub use { crate::{ + Interaction, MaterialNode, UiMaterialPlugin, UiScale, geometry::*, ui_material::*, ui_node::*, widget::{Button, ImageNode, Label, NodeImageMode}, - Interaction, MaterialNode, UiMaterialPlugin, UiScale, }, // `bevy_sprite` re-exports for texture slicing bevy_sprite::{BorderRect, SliceScaleMode, SpriteImageMode, TextureSlicer}, }; } -use bevy_app::{prelude::*, Animation}; +use bevy_app::{Animation, prelude::*}; use bevy_ecs::prelude::*; use bevy_input::InputSystem; -use bevy_render::{camera::CameraUpdateSystem, RenderApp}; +use bevy_render::{RenderApp, camera::CameraUpdateSystem}; use bevy_transform::TransformSystem; use layout::ui_surface::UiSurface; -use stack::ui_stack_system; pub use stack::UiStack; +use stack::ui_stack_system; use update::{update_clipping_system, update_ui_context_system}; /// The basic plugin for Bevy UI diff --git a/crates/bevy_ui/src/measurement.rs b/crates/bevy_ui/src/measurement.rs index 029498ab8de9d..5cd51ffa89a0c 100644 --- a/crates/bevy_ui/src/measurement.rs +++ b/crates/bevy_ui/src/measurement.rs @@ -1,6 +1,6 @@ use bevy_ecs::{prelude::Component, reflect::ReflectComponent}; use bevy_math::Vec2; -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; use bevy_text::CosmicFontSystem; use core::fmt::Formatter; pub use taffy::style::AvailableSpace; diff --git a/crates/bevy_ui/src/picking_backend.rs b/crates/bevy_ui/src/picking_backend.rs index afb2aecae3b32..8460a7fd7585e 100644 --- a/crates/bevy_ui/src/picking_backend.rs +++ b/crates/bevy_ui/src/picking_backend.rs @@ -24,7 +24,7 @@ #![deny(missing_docs)] -use crate::{focus::pick_rounded_rect, prelude::*, UiStack}; +use crate::{UiStack, focus::pick_rounded_rect, prelude::*}; use bevy_app::prelude::*; use bevy_ecs::{prelude::*, query::QueryData}; use bevy_math::{Rect, Vec2}; diff --git a/crates/bevy_ui/src/render/box_shadow.rs b/crates/bevy_ui/src/render/box_shadow.rs index 0e501783564a4..30ca38f290b45 100644 --- a/crates/bevy_ui/src/render/box_shadow.rs +++ b/crates/bevy_ui/src/render/box_shadow.rs @@ -18,21 +18,21 @@ use bevy_ecs::{ }, }; use bevy_image::BevyDefault as _; -use bevy_math::{vec2, FloatOrd, Mat4, Rect, Vec2, Vec3Swizzles, Vec4Swizzles}; -use bevy_render::sync_world::MainEntity; +use bevy_math::{FloatOrd, Mat4, Rect, Vec2, Vec3Swizzles, Vec4Swizzles, vec2}; use bevy_render::RenderApp; +use bevy_render::sync_world::MainEntity; use bevy_render::{ + Extract, ExtractSchedule, Render, RenderSet, render_phase::*, render_resource::{binding_types::uniform_buffer, *}, renderer::{RenderDevice, RenderQueue}, sync_world::TemporaryRenderEntity, view::*, - Extract, ExtractSchedule, Render, RenderSet, }; use bevy_transform::prelude::GlobalTransform; use bytemuck::{Pod, Zeroable}; -use super::{stack_z_offsets, UiCameraMap, UiCameraView, QUAD_INDICES, QUAD_VERTEX_POSITIONS}; +use super::{QUAD_INDICES, QUAD_VERTEX_POSITIONS, UiCameraMap, UiCameraView, stack_z_offsets}; pub const BOX_SHADOW_SHADER_HANDLE: Handle = weak_handle!("d2991ecd-134f-4f82-adf5-0fcc86f02227"); diff --git a/crates/bevy_ui/src/render/debug_overlay.rs b/crates/bevy_ui/src/render/debug_overlay.rs index 79001f3ba1982..ab2eaf4ee9e08 100644 --- a/crates/bevy_ui/src/render/debug_overlay.rs +++ b/crates/bevy_ui/src/render/debug_overlay.rs @@ -1,6 +1,6 @@ -use crate::ui_node::ComputedNodeTarget; use crate::CalculatedClip; use crate::ComputedNode; +use crate::ui_node::ComputedNodeTarget; use bevy_asset::AssetId; use bevy_color::Hsla; use bevy_ecs::entity::Entity; @@ -11,9 +11,9 @@ use bevy_ecs::system::Res; use bevy_ecs::system::ResMut; use bevy_math::Rect; use bevy_math::Vec2; +use bevy_render::Extract; use bevy_render::sync_world::TemporaryRenderEntity; use bevy_render::view::InheritedVisibility; -use bevy_render::Extract; use bevy_sprite::BorderRect; use bevy_transform::components::GlobalTransform; diff --git a/crates/bevy_ui/src/render/mod.rs b/crates/bevy_ui/src/render/mod.rs index f41c8f2b81620..67b77583d0bf7 100644 --- a/crates/bevy_ui/src/render/mod.rs +++ b/crates/bevy_ui/src/render/mod.rs @@ -14,7 +14,7 @@ use crate::{ UiTargetCamera, }; use bevy_app::prelude::*; -use bevy_asset::{load_internal_asset, weak_handle, AssetEvent, AssetId, Assets, Handle}; +use bevy_asset::{AssetEvent, AssetId, Assets, Handle, load_internal_asset, weak_handle}; use bevy_color::{Alpha, ColorToComponents, LinearRgba}; use bevy_core_pipeline::core_2d::graph::{Core2d, Node2d}; use bevy_core_pipeline::core_3d::graph::{Core3d, Node3d}; @@ -30,21 +30,21 @@ use bevy_render::sync_world::MainEntity; use bevy_render::texture::TRANSPARENT_IMAGE_HANDLE; use bevy_render::view::RetainedViewEntity; use bevy_render::{ + Extract, RenderApp, RenderSet, camera::Camera, render_asset::RenderAssets, render_graph::{Node as RenderGraphNode, RenderGraph}, - render_phase::{sort_phase_system, AddRenderCommand, DrawFunctions}, + render_phase::{AddRenderCommand, DrawFunctions, sort_phase_system}, render_resource::*, renderer::{RenderDevice, RenderQueue}, view::{ExtractedView, ViewUniforms}, - Extract, RenderApp, RenderSet, }; use bevy_render::{ + ExtractSchedule, Render, render_phase::{PhaseItem, PhaseItemExtraIndex}, sync_world::{RenderEntity, TemporaryRenderEntity}, texture::GpuImage, view::InheritedVisibility, - ExtractSchedule, Render, }; use bevy_sprite::{BorderRect, SpriteAssetEvents}; #[cfg(feature = "bevy_ui_debug")] diff --git a/crates/bevy_ui/src/render/render_pass.rs b/crates/bevy_ui/src/render/render_pass.rs index f89133e31e3c4..b13ab6b72c7e6 100644 --- a/crates/bevy_ui/src/render/render_pass.rs +++ b/crates/bevy_ui/src/render/render_pass.rs @@ -4,7 +4,7 @@ use super::{ImageNodeBindGroups, UiBatch, UiMeta, UiViewTarget}; use crate::UiCameraView; use bevy_ecs::{ prelude::*, - system::{lifetimeless::*, SystemParamItem}, + system::{SystemParamItem, lifetimeless::*}, }; use bevy_math::FloatOrd; use bevy_render::sync_world::MainEntity; diff --git a/crates/bevy_ui/src/render/ui_material_pipeline.rs b/crates/bevy_ui/src/render/ui_material_pipeline.rs index 8267668c0b297..d0544aecc1d18 100644 --- a/crates/bevy_ui/src/render/ui_material_pipeline.rs +++ b/crates/bevy_ui/src/render/ui_material_pipeline.rs @@ -14,6 +14,7 @@ use bevy_image::BevyDefault as _; use bevy_math::{FloatOrd, Mat4, Rect, Vec2, Vec4Swizzles}; use bevy_render::sync_world::{MainEntity, TemporaryRenderEntity}; use bevy_render::{ + Extract, ExtractSchedule, Render, RenderSet, extract_component::ExtractComponentPlugin, globals::{GlobalsBuffer, GlobalsUniform}, render_asset::{PrepareAssetError, RenderAsset, RenderAssetPlugin, RenderAssets}, @@ -21,7 +22,6 @@ use bevy_render::{ render_resource::{binding_types::uniform_buffer, *}, renderer::{RenderDevice, RenderQueue}, view::*, - Extract, ExtractSchedule, Render, RenderSet, }; use bevy_sprite::BorderRect; use bevy_transform::prelude::GlobalTransform; diff --git a/crates/bevy_ui/src/render/ui_texture_slice_pipeline.rs b/crates/bevy_ui/src/render/ui_texture_slice_pipeline.rs index fd9799b679149..a682a3a414a89 100644 --- a/crates/bevy_ui/src/render/ui_texture_slice_pipeline.rs +++ b/crates/bevy_ui/src/render/ui_texture_slice_pipeline.rs @@ -15,6 +15,7 @@ use bevy_math::{FloatOrd, Mat4, Rect, Vec2, Vec4Swizzles}; use bevy_platform_support::collections::HashMap; use bevy_render::sync_world::MainEntity; use bevy_render::{ + Extract, ExtractSchedule, Render, RenderSet, render_asset::RenderAssets, render_phase::*, render_resource::{binding_types::uniform_buffer, *}, @@ -22,7 +23,6 @@ use bevy_render::{ sync_world::TemporaryRenderEntity, texture::{GpuImage, TRANSPARENT_IMAGE_HANDLE}, view::*, - Extract, ExtractSchedule, Render, RenderSet, }; use bevy_sprite::{SliceScaleMode, SpriteAssetEvents, SpriteImageMode, TextureSlicer}; use bevy_transform::prelude::GlobalTransform; diff --git a/crates/bevy_ui/src/stack.rs b/crates/bevy_ui/src/stack.rs index c8dfde318d5d2..fbf8ff2b0eda5 100644 --- a/crates/bevy_ui/src/stack.rs +++ b/crates/bevy_ui/src/stack.rs @@ -4,8 +4,8 @@ use bevy_ecs::prelude::*; use bevy_platform_support::collections::HashSet; use crate::{ - experimental::{UiChildren, UiRootNodes}, ComputedNode, GlobalZIndex, ZIndex, + experimental::{UiChildren, UiRootNodes}, }; /// The current UI stack, which contains all UI nodes ordered by their depth (back-to-front). diff --git a/crates/bevy_ui/src/ui_material.rs b/crates/bevy_ui/src/ui_material.rs index a9d712d5be548..4e812a1fd91b2 100644 --- a/crates/bevy_ui/src/ui_material.rs +++ b/crates/bevy_ui/src/ui_material.rs @@ -2,10 +2,10 @@ use crate::Node; use bevy_asset::{Asset, AssetId, Handle}; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::{ - component::{require, Component}, + component::{Component, require}, reflect::ReflectComponent, }; -use bevy_reflect::{prelude::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, prelude::ReflectDefault}; use bevy_render::{ extract_component::ExtractComponent, render_resource::{AsBindGroup, RenderPipelineDescriptor, ShaderRef}, diff --git a/crates/bevy_ui/src/ui_node.rs b/crates/bevy_ui/src/ui_node.rs index 96d9d2aeb2410..6175a9aee38cc 100644 --- a/crates/bevy_ui/src/ui_node.rs +++ b/crates/bevy_ui/src/ui_node.rs @@ -2,7 +2,7 @@ use crate::{FocusPolicy, UiRect, Val}; use bevy_color::Color; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::{prelude::*, system::SystemParam}; -use bevy_math::{vec4, Rect, UVec2, Vec2, Vec4Swizzles}; +use bevy_math::{Rect, UVec2, Vec2, Vec4Swizzles, vec4}; use bevy_reflect::prelude::*; use bevy_render::{ camera::{Camera, RenderTarget}, diff --git a/crates/bevy_ui/src/update.rs b/crates/bevy_ui/src/update.rs index 4c3b28a6923f9..2a38ba4b02cf3 100644 --- a/crates/bevy_ui/src/update.rs +++ b/crates/bevy_ui/src/update.rs @@ -1,15 +1,15 @@ //! This module contains systems that update the UI when something changes use crate::{ - experimental::{UiChildren, UiRootNodes}, CalculatedClip, ComputedNodeTarget, DefaultUiCamera, Display, Node, OverflowAxis, UiScale, UiTargetCamera, + experimental::{UiChildren, UiRootNodes}, }; use super::ComputedNode; use bevy_ecs::{ change_detection::DetectChangesMut, - entity::{hash_set::EntityHashSet, Entity}, + entity::{Entity, hash_set::EntityHashSet}, hierarchy::ChildOf, query::{Changed, With}, system::{Commands, Local, Query, Res}, diff --git a/crates/bevy_ui/src/widget/button.rs b/crates/bevy_ui/src/widget/button.rs index 8445a4ad6266b..0f8cd15773bdf 100644 --- a/crates/bevy_ui/src/widget/button.rs +++ b/crates/bevy_ui/src/widget/button.rs @@ -1,9 +1,9 @@ use crate::{FocusPolicy, Interaction, Node}; use bevy_ecs::{ - prelude::{require, Component}, + prelude::{Component, require}, reflect::ReflectComponent, }; -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; /// Marker struct for buttons #[derive(Component, Debug, Default, Clone, Copy, PartialEq, Eq, Reflect)] diff --git a/crates/bevy_ui/src/widget/image.rs b/crates/bevy_ui/src/widget/image.rs index 9c6abbbf82809..d64b3efcf6c54 100644 --- a/crates/bevy_ui/src/widget/image.rs +++ b/crates/bevy_ui/src/widget/image.rs @@ -4,7 +4,7 @@ use bevy_color::Color; use bevy_ecs::prelude::*; use bevy_image::prelude::*; use bevy_math::{Rect, UVec2, Vec2}; -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; use bevy_render::texture::TRANSPARENT_IMAGE_HANDLE; use bevy_sprite::TextureSlicer; use taffy::{MaybeMath, MaybeResolve}; diff --git a/crates/bevy_ui/src/widget/label.rs b/crates/bevy_ui/src/widget/label.rs index f464fea527fc4..efacb2ec38866 100644 --- a/crates/bevy_ui/src/widget/label.rs +++ b/crates/bevy_ui/src/widget/label.rs @@ -1,5 +1,5 @@ use bevy_ecs::{prelude::Component, reflect::ReflectComponent}; -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; /// Marker struct for labels #[derive(Component, Debug, Default, Clone, Copy, Reflect)] diff --git a/crates/bevy_ui/src/widget/text.rs b/crates/bevy_ui/src/widget/text.rs index e1be210950a0b..8bbba52810cdd 100644 --- a/crates/bevy_ui/src/widget/text.rs +++ b/crates/bevy_ui/src/widget/text.rs @@ -8,7 +8,7 @@ use bevy_derive::{Deref, DerefMut}; use bevy_ecs::{ change_detection::DetectChanges, entity::Entity, - prelude::{require, Component}, + prelude::{Component, require}, query::With, reflect::ReflectComponent, system::{Query, Res, ResMut}, @@ -16,11 +16,11 @@ use bevy_ecs::{ }; use bevy_image::prelude::*; use bevy_math::Vec2; -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; use bevy_text::{ - scale_value, ComputedTextBlock, CosmicFontSystem, Font, FontAtlasSets, LineBreak, SwashCache, - TextBounds, TextColor, TextError, TextFont, TextLayout, TextLayoutInfo, TextMeasureInfo, - TextPipeline, TextReader, TextRoot, TextSpanAccess, TextWriter, YAxisOrientation, + ComputedTextBlock, CosmicFontSystem, Font, FontAtlasSets, LineBreak, SwashCache, TextBounds, + TextColor, TextError, TextFont, TextLayout, TextLayoutInfo, TextMeasureInfo, TextPipeline, + TextReader, TextRoot, TextSpanAccess, TextWriter, YAxisOrientation, scale_value, }; use taffy::style::AvailableSpace; use tracing::error; diff --git a/crates/bevy_window/src/system_cursor.rs b/crates/bevy_window/src/system_cursor.rs index 8db274ae9a807..08aa3791f009e 100644 --- a/crates/bevy_window/src/system_cursor.rs +++ b/crates/bevy_window/src/system_cursor.rs @@ -69,7 +69,7 @@ // -------------------------------------------------------------- #[cfg(feature = "bevy_reflect")] -use bevy_reflect::{prelude::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, prelude::ReflectDefault}; #[cfg(feature = "serialize")] use bevy_reflect::{ReflectDeserialize, ReflectSerialize}; diff --git a/crates/bevy_window/src/window.rs b/crates/bevy_window/src/window.rs index 92455a908b2eb..8a4deba68cf62 100644 --- a/crates/bevy_window/src/window.rs +++ b/crates/bevy_window/src/window.rs @@ -11,7 +11,7 @@ use log::warn; #[cfg(feature = "bevy_reflect")] use { bevy_ecs::prelude::ReflectComponent, - bevy_reflect::{std_traits::ReflectDefault, Reflect}, + bevy_reflect::{Reflect, std_traits::ReflectDefault}, }; #[cfg(all(feature = "serialize", feature = "bevy_reflect"))] diff --git a/crates/bevy_winit/src/converters.rs b/crates/bevy_winit/src/converters.rs index ba41c6253474d..effdd444301ca 100644 --- a/crates/bevy_winit/src/converters.rs +++ b/crates/bevy_winit/src/converters.rs @@ -1,9 +1,9 @@ use bevy_ecs::entity::Entity; use bevy_input::{ + ButtonState, keyboard::{KeyCode, KeyboardInput, NativeKeyCode}, mouse::MouseButton, touch::{ForceTouch, TouchInput, TouchPhase}, - ButtonState, }; use bevy_math::{CompassOctant, Vec2}; use bevy_window::SystemCursorIcon; diff --git a/crates/bevy_winit/src/cursor.rs b/crates/bevy_winit/src/cursor.rs index 6e601f24294d8..022fd7f2fcdd1 100644 --- a/crates/bevy_winit/src/cursor.rs +++ b/crates/bevy_winit/src/cursor.rs @@ -1,17 +1,17 @@ //! Components to customize winit cursor -use crate::{ - converters::convert_system_cursor_icon, - state::{CursorSource, PendingCursor}, -}; #[cfg(feature = "custom_cursor")] use crate::{ + WinitCustomCursor, custom_cursor::{ - calculate_effective_rect, extract_and_transform_rgba_pixels, extract_rgba_pixels, - transform_hotspot, CustomCursorPlugin, + CustomCursorPlugin, calculate_effective_rect, extract_and_transform_rgba_pixels, + extract_rgba_pixels, transform_hotspot, }, state::{CustomCursorCache, CustomCursorCacheKey}, - WinitCustomCursor, +}; +use crate::{ + converters::convert_system_cursor_icon, + state::{CursorSource, PendingCursor}, }; use bevy_app::{App, Last, Plugin}; #[cfg(feature = "custom_cursor")] @@ -31,7 +31,7 @@ use bevy_ecs::{ #[cfg(feature = "custom_cursor")] use bevy_image::{Image, TextureAtlasLayout}; use bevy_platform_support::collections::HashSet; -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; use bevy_window::{SystemCursorIcon, Window}; #[cfg(feature = "custom_cursor")] use tracing::warn; @@ -134,7 +134,9 @@ fn update_cursors( }; let Some(rgba) = maybe_rgba else { - warn!("Cursor image {handle:?} not accepted because it's not rgba8 or rgba32float format"); + warn!( + "Cursor image {handle:?} not accepted because it's not rgba8 or rgba32float format" + ); continue; }; diff --git a/crates/bevy_winit/src/custom_cursor.rs b/crates/bevy_winit/src/custom_cursor.rs index f6c90da6e20b8..d51f6c855b9d8 100644 --- a/crates/bevy_winit/src/custom_cursor.rs +++ b/crates/bevy_winit/src/custom_cursor.rs @@ -1,8 +1,8 @@ use bevy_app::{App, Plugin}; use bevy_asset::{Assets, Handle}; use bevy_image::{Image, TextureAtlas, TextureAtlasLayout, TextureAtlasPlugin}; -use bevy_math::{ops, Rect, URect, UVec2, Vec2}; -use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_math::{Rect, URect, UVec2, Vec2, ops}; +use bevy_reflect::{Reflect, std_traits::ReflectDefault}; use wgpu_types::TextureFormat; use crate::{cursor::CursorIcon, state::CustomCursorCache}; diff --git a/crates/bevy_winit/src/lib.rs b/crates/bevy_winit/src/lib.rs index c2a3eddc52f04..85fb69c8e963c 100644 --- a/crates/bevy_winit/src/lib.rs +++ b/crates/bevy_winit/src/lib.rs @@ -15,8 +15,8 @@ extern crate alloc; use bevy_derive::Deref; -use bevy_reflect::prelude::ReflectDefault; use bevy_reflect::Reflect; +use bevy_reflect::prelude::ReflectDefault; use bevy_window::{RawHandleWrapperHolder, WindowEvent}; use core::marker::PhantomData; use winit::{event_loop::EventLoop, window::WindowId}; @@ -24,7 +24,7 @@ use winit::{event_loop::EventLoop, window::WindowId}; use bevy_a11y::AccessibilityRequested; use bevy_app::{App, Last, Plugin}; use bevy_ecs::prelude::*; -use bevy_window::{exit_on_all_closed, Window, WindowCreated}; +use bevy_window::{Window, WindowCreated, exit_on_all_closed}; use system::{changed_windows, check_keyboard_focus_lost, despawn_windows}; pub use system::{create_monitors, create_windows}; #[cfg(all(target_family = "wasm", target_os = "unknown"))] diff --git a/crates/bevy_winit/src/state.rs b/crates/bevy_winit/src/state.rs index 0c1a02e0ce0b4..fdaf8f2e652eb 100644 --- a/crates/bevy_winit/src/state.rs +++ b/crates/bevy_winit/src/state.rs @@ -19,7 +19,7 @@ use bevy_input::{ use bevy_log::{error, trace, warn}; #[cfg(feature = "custom_cursor")] use bevy_math::URect; -use bevy_math::{ivec2, DVec2, Vec2}; +use bevy_math::{DVec2, Vec2, ivec2}; #[cfg(feature = "custom_cursor")] use bevy_platform_support::collections::HashMap; use bevy_platform_support::time::Instant; @@ -47,11 +47,11 @@ use bevy_window::{ use bevy_window::{PrimaryWindow, RawHandleWrapper}; use crate::{ - accessibility::AccessKitAdapters, - converters, create_windows, - system::{create_monitors, CachedWindow}, AppSendEvent, CreateMonitorParams, CreateWindowParams, EventLoopProxyWrapper, RawWinitWindowEvent, UpdateMode, WinitSettings, WinitWindows, + accessibility::AccessKitAdapters, + converters, create_windows, + system::{CachedWindow, create_monitors}, }; /// Persistent state that is used to run the [`App`] according to the current diff --git a/crates/bevy_winit/src/system.rs b/crates/bevy_winit/src/system.rs index 2c481f960878c..b71df7432a6f3 100644 --- a/crates/bevy_winit/src/system.rs +++ b/crates/bevy_winit/src/system.rs @@ -27,6 +27,7 @@ use winit::platform::ios::WindowExtIOS; use winit::platform::web::WindowExtWebSys; use crate::{ + CreateMonitorParams, CreateWindowParams, WinitWindows, converters::{ convert_enabled_buttons, convert_resize_direction, convert_window_level, convert_window_theme, convert_winit_theme, @@ -34,7 +35,6 @@ use crate::{ get_best_videomode, get_fitting_videomode, select_monitor, state::react_to_resize, winit_monitors::WinitMonitors, - CreateMonitorParams, CreateWindowParams, WinitWindows, }; /// Creates new windows on the [`winit`] backend for each entity with a newly-added @@ -532,7 +532,9 @@ pub(crate) fn changed_windows( cache.window.recognize_pan_gesture, ) { (Some(_), Some(_)) => { - warn!("Bevy currently doesn't support modifying PanGesture number of fingers recognition. Please disable it before re-enabling it with the new number of fingers"); + warn!( + "Bevy currently doesn't support modifying PanGesture number of fingers recognition. Please disable it before re-enabling it with the new number of fingers" + ); } (Some((min, max)), _) => winit_window.recognize_pan_gesture(true, min, max), _ => winit_window.recognize_pan_gesture(false, 0, 0), diff --git a/crates/bevy_winit/src/winit_windows.rs b/crates/bevy_winit/src/winit_windows.rs index cae20f15afc84..c36d989ef224c 100644 --- a/crates/bevy_winit/src/winit_windows.rs +++ b/crates/bevy_winit/src/winit_windows.rs @@ -19,7 +19,7 @@ use winit::{ use crate::{ accessibility::{ - prepare_accessibility_for_window, AccessKitAdapters, WinitActionRequestHandlers, + AccessKitAdapters, WinitActionRequestHandlers, prepare_accessibility_for_window, }, converters::{convert_enabled_buttons, convert_window_level, convert_window_theme}, winit_monitors::WinitMonitors, @@ -460,7 +460,9 @@ pub fn select_monitor( match monitor_selection { Current => { if current_monitor.is_none() { - warn!("Can't select current monitor on window creation or cannot find current monitor!"); + warn!( + "Can't select current monitor on window creation or cannot find current monitor!" + ); } current_monitor } diff --git a/examples/2d/cpu_draw.rs b/examples/2d/cpu_draw.rs index f142f50d1d214..ba98e1051e8f7 100644 --- a/examples/2d/cpu_draw.rs +++ b/examples/2d/cpu_draw.rs @@ -101,7 +101,11 @@ fn draw( ) { if *i == 0 { // Generate a random color on first run. - *draw_color = Color::linear_rgb(seeded_rng.0.r#gen(), seeded_rng.0.r#gen(), seeded_rng.0.r#gen()); + *draw_color = Color::linear_rgb( + seeded_rng.0.r#gen(), + seeded_rng.0.r#gen(), + seeded_rng.0.r#gen(), + ); } // Get the image from Bevy's asset storage. @@ -124,7 +128,11 @@ fn draw( // If the old color is our current color, change our drawing color. let tolerance = 1.0 / 255.0; if old_color.distance(&draw_color) <= tolerance { - *draw_color = Color::linear_rgb(seeded_rng.0.r#gen(), seeded_rng.0.r#gen(), seeded_rng.0.r#gen()); + *draw_color = Color::linear_rgb( + seeded_rng.0.r#gen(), + seeded_rng.0.r#gen(), + seeded_rng.0.r#gen(), + ); } // Set the new color, but keep old alpha value from image. diff --git a/examples/2d/mesh2d_arcs.rs b/examples/2d/mesh2d_arcs.rs index db66b784acd54..a39253d459deb 100644 --- a/examples/2d/mesh2d_arcs.rs +++ b/examples/2d/mesh2d_arcs.rs @@ -7,8 +7,8 @@ use std::f32::consts::FRAC_PI_2; use bevy::{ color::palettes::css::{BLUE, GRAY, RED}, math::{ - bounding::{Bounded2d, BoundingVolume}, Isometry2d, + bounding::{Bounded2d, BoundingVolume}, }, prelude::*, render::mesh::{CircularMeshUvMode, CircularSectorMeshBuilder, CircularSegmentMeshBuilder}, diff --git a/examples/2d/mesh2d_manual.rs b/examples/2d/mesh2d_manual.rs index ca99a71ba034c..aaf54606df380 100644 --- a/examples/2d/mesh2d_manual.rs +++ b/examples/2d/mesh2d_manual.rs @@ -8,10 +8,11 @@ use bevy::{ asset::weak_handle, color::palettes::basic::YELLOW, - core_pipeline::core_2d::{Transparent2d, CORE_2D_DEPTH_FORMAT}, - math::{ops, FloatOrd}, + core_pipeline::core_2d::{CORE_2D_DEPTH_FORMAT, Transparent2d}, + math::{FloatOrd, ops}, prelude::*, render::{ + Extract, Render, RenderApp, RenderSet, mesh::{Indices, MeshVertexAttribute, RenderMesh}, render_asset::{RenderAssetUsages, RenderAssets}, render_phase::{ @@ -27,12 +28,11 @@ use bevy::{ }, sync_world::MainEntityHashMap, view::{ExtractedView, RenderVisibleEntities, ViewTarget}, - Extract, Render, RenderApp, RenderSet, }, sprite::{ - extract_mesh2d, DrawMesh2d, Material2dBindGroupId, Mesh2dPipeline, Mesh2dPipelineKey, - Mesh2dTransforms, MeshFlags, RenderMesh2dInstance, SetMesh2dBindGroup, - SetMesh2dViewBindGroup, + DrawMesh2d, Material2dBindGroupId, Mesh2dPipeline, Mesh2dPipelineKey, Mesh2dTransforms, + MeshFlags, RenderMesh2dInstance, SetMesh2dBindGroup, SetMesh2dViewBindGroup, + extract_mesh2d, }, }; use std::f32::consts::PI; diff --git a/examples/2d/wireframe_2d.rs b/examples/2d/wireframe_2d.rs index fe4cc261870dd..b6cd2a3cc4c83 100644 --- a/examples/2d/wireframe_2d.rs +++ b/examples/2d/wireframe_2d.rs @@ -12,9 +12,9 @@ use bevy::{ color::palettes::basic::{GREEN, RED, WHITE}, prelude::*, render::{ + RenderPlugin, render_resource::WgpuFeatures, settings::{RenderCreation, WgpuSettings}, - RenderPlugin, }, sprite::{NoWireframe2d, Wireframe2d, Wireframe2dColor, Wireframe2dConfig, Wireframe2dPlugin}, }; diff --git a/examples/3d/atmosphere.rs b/examples/3d/atmosphere.rs index 53c5c91dfa687..02a05e100aa98 100644 --- a/examples/3d/atmosphere.rs +++ b/examples/3d/atmosphere.rs @@ -4,7 +4,7 @@ use std::f32::consts::PI; use bevy::{ core_pipeline::{bloom::Bloom, tonemapping::Tonemapping}, - pbr::{light_consts::lux, Atmosphere, AtmosphereSettings, CascadeShadowConfigBuilder}, + pbr::{Atmosphere, AtmosphereSettings, CascadeShadowConfigBuilder, light_consts::lux}, prelude::*, render::camera::Exposure, }; diff --git a/examples/3d/auto_exposure.rs b/examples/3d/auto_exposure.rs index 79fece61c8e36..0b2b8ef644e34 100644 --- a/examples/3d/auto_exposure.rs +++ b/examples/3d/auto_exposure.rs @@ -13,8 +13,8 @@ use bevy::{ core_pipeline::{ - auto_exposure::{AutoExposure, AutoExposureCompensationCurve, AutoExposurePlugin}, Skybox, + auto_exposure::{AutoExposure, AutoExposureCompensationCurve, AutoExposurePlugin}, }, math::{cubic_splines::LinearSpline, primitives::Plane3d, vec2}, prelude::*, diff --git a/examples/3d/clearcoat.rs b/examples/3d/clearcoat.rs index c04b12d5814ed..2c092ffbfc721 100644 --- a/examples/3d/clearcoat.rs +++ b/examples/3d/clearcoat.rs @@ -21,7 +21,7 @@ use std::f32::consts::PI; use bevy::{ color::palettes::css::{BLUE, GOLD, WHITE}, - core_pipeline::{tonemapping::Tonemapping::AcesFitted, Skybox}, + core_pipeline::{Skybox, tonemapping::Tonemapping::AcesFitted}, image::ImageLoaderSettings, math::vec3, prelude::*, diff --git a/examples/3d/clustered_decals.rs b/examples/3d/clustered_decals.rs index 108efe586ef1e..4031a7627bca6 100644 --- a/examples/3d/clustered_decals.rs +++ b/examples/3d/clustered_decals.rs @@ -8,8 +8,8 @@ use bevy::{ color::palettes::css::{LIME, ORANGE_RED, SILVER}, input::mouse::AccumulatedMouseMotion, pbr::{ - decal::{self, clustered::ClusteredDecal}, ExtendedMaterial, MaterialExtension, + decal::{self, clustered::ClusteredDecal}, }, prelude::*, render::{ @@ -21,8 +21,8 @@ use bevy::{ }; use ops::{acos, cos, sin}; use widgets::{ - WidgetClickEvent, WidgetClickSender, BUTTON_BORDER, BUTTON_BORDER_COLOR, - BUTTON_BORDER_RADIUS_SIZE, BUTTON_PADDING, + BUTTON_BORDER, BUTTON_BORDER_COLOR, BUTTON_BORDER_RADIUS_SIZE, BUTTON_PADDING, + WidgetClickEvent, WidgetClickSender, }; #[path = "../helpers/widgets.rs"] diff --git a/examples/3d/edit_material_on_gltf.rs b/examples/3d/edit_material_on_gltf.rs index f9de5842a92fe..73fc0c8648b06 100644 --- a/examples/3d/edit_material_on_gltf.rs +++ b/examples/3d/edit_material_on_gltf.rs @@ -1,16 +1,16 @@ //! Showcases how to change the material of a `Scene` spawned from a Gltf use bevy::{ + DefaultPlugins, app::{App, PluginGroup, Startup}, asset::{AssetServer, Assets}, audio::AudioPlugin, - color::{palettes, Color}, + color::{Color, palettes}, gltf::GltfAssetLabel, math::{Dir3, Vec3}, pbr::{DirectionalLight, MeshMaterial3d, StandardMaterial}, prelude::{Camera3d, Children, Commands, Component, Query, Res, ResMut, Transform, Trigger}, scene::{SceneInstanceReady, SceneRoot}, - DefaultPlugins, }; fn main() { diff --git a/examples/3d/fog.rs b/examples/3d/fog.rs index ed2a2a0dd6867..9793ae0ad356a 100644 --- a/examples/3d/fog.rs +++ b/examples/3d/fog.rs @@ -185,11 +185,7 @@ fn update_system( } // Linear Fog Controls - if let FogFalloff::Linear { - start, - end, - } = &mut fog.falloff - { + if let FogFalloff::Linear { start, end } = &mut fog.falloff { text.push_str("\nA / S - Move Start Distance\nZ / X - Move End Distance"); if keycode.pressed(KeyCode::KeyA) { diff --git a/examples/3d/irradiance_volumes.rs b/examples/3d/irradiance_volumes.rs index 31529c421986d..dcb03396847e1 100644 --- a/examples/3d/irradiance_volumes.rs +++ b/examples/3d/irradiance_volumes.rs @@ -18,7 +18,7 @@ use bevy::{ core_pipeline::Skybox, math::{uvec3, vec3}, pbr::{ - irradiance_volume::IrradianceVolume, ExtendedMaterial, MaterialExtension, NotShadowCaster, + ExtendedMaterial, MaterialExtension, NotShadowCaster, irradiance_volume::IrradianceVolume, }, prelude::*, render::render_resource::{AsBindGroup, ShaderRef, ShaderType}, diff --git a/examples/3d/meshlet.rs b/examples/3d/meshlet.rs index 0bab7d750198c..3fdb144bf63e9 100644 --- a/examples/3d/meshlet.rs +++ b/examples/3d/meshlet.rs @@ -7,8 +7,8 @@ mod camera_controller; use bevy::{ pbr::{ - experimental::meshlet::{MeshletMesh3d, MeshletPlugin}, CascadeShadowConfigBuilder, DirectionalLightShadowMap, + experimental::meshlet::{MeshletMesh3d, MeshletPlugin}, }, prelude::*, render::render_resource::AsBindGroup, @@ -16,12 +16,13 @@ use bevy::{ use camera_controller::{CameraController, CameraControllerPlugin}; use std::{f32::consts::PI, path::Path, process::ExitCode}; -const ASSET_URL: &str = - "https://raw.githubusercontent.com/JMS55/bevy_meshlet_asset/7a7c14138021f63904b584d5f7b73b695c7f4bbf/bunny.meshlet_mesh"; +const ASSET_URL: &str = "https://raw.githubusercontent.com/JMS55/bevy_meshlet_asset/7a7c14138021f63904b584d5f7b73b695c7f4bbf/bunny.meshlet_mesh"; fn main() -> ExitCode { if !Path::new("./assets/external/models/bunny.meshlet_mesh").exists() { - eprintln!("ERROR: Asset at path /assets/external/models/bunny.meshlet_mesh is missing. Please download it from {ASSET_URL}"); + eprintln!( + "ERROR: Asset at path /assets/external/models/bunny.meshlet_mesh is missing. Please download it from {ASSET_URL}" + ); return ExitCode::FAILURE; } diff --git a/examples/3d/occlusion_culling.rs b/examples/3d/occlusion_culling.rs index 4c69db0a4a101..5ffa5ef4c5af8 100644 --- a/examples/3d/occlusion_culling.rs +++ b/examples/3d/occlusion_culling.rs @@ -17,14 +17,15 @@ use bevy::{ color::palettes::css::{SILVER, WHITE}, core_pipeline::{ core_3d::{ - graph::{Core3d, Node3d}, Opaque3d, + graph::{Core3d, Node3d}, }, prepass::DepthPrepass, }, pbr::PbrPlugin, prelude::*, render::{ + Render, RenderApp, RenderDebugFlags, RenderPlugin, RenderSet, batching::gpu_preprocessing::{ GpuPreprocessingMode, GpuPreprocessingSupport, IndirectParametersBuffers, IndirectParametersIndexed, @@ -34,7 +35,6 @@ use bevy::{ render_resource::{Buffer, BufferDescriptor, BufferUsages, MapMode}, renderer::{RenderAdapter, RenderContext, RenderDevice}, settings::WgpuFeatures, - Render, RenderApp, RenderDebugFlags, RenderPlugin, RenderSet, }, }; use bytemuck::Pod; diff --git a/examples/3d/pcss.rs b/examples/3d/pcss.rs index 0f96396cb0e9c..8d3965c20c63e 100644 --- a/examples/3d/pcss.rs +++ b/examples/3d/pcss.rs @@ -4,9 +4,9 @@ use std::f32::consts::PI; use bevy::{ core_pipeline::{ + Skybox, experimental::taa::{TemporalAntiAliasPlugin, TemporalAntiAliasing}, prepass::{DepthPrepass, MotionVectorPrepass}, - Skybox, }, math::vec3, pbr::{CubemapVisibleEntities, ShadowFilteringMethod, VisibleMeshEntities}, diff --git a/examples/3d/rotate_environment_map.rs b/examples/3d/rotate_environment_map.rs index 68ecceeccf7de..59f8c3ba7dcd0 100644 --- a/examples/3d/rotate_environment_map.rs +++ b/examples/3d/rotate_environment_map.rs @@ -4,7 +4,7 @@ use std::f32::consts::PI; use bevy::{ color::palettes::css::{GOLD, WHITE}, - core_pipeline::{tonemapping::Tonemapping::AcesFitted, Skybox}, + core_pipeline::{Skybox, tonemapping::Tonemapping::AcesFitted}, image::ImageLoaderSettings, prelude::*, }; diff --git a/examples/3d/ssr.rs b/examples/3d/ssr.rs index 9d0026fbbcf98..bef631b0abdea 100644 --- a/examples/3d/ssr.rs +++ b/examples/3d/ssr.rs @@ -4,7 +4,7 @@ use std::ops::Range; use bevy::{ color::palettes::css::{BLACK, WHITE}, - core_pipeline::{fxaa::Fxaa, Skybox}, + core_pipeline::{Skybox, fxaa::Fxaa}, image::{ ImageAddressMode, ImageFilterMode, ImageLoaderSettings, ImageSampler, ImageSamplerDescriptor, diff --git a/examples/3d/visibility_range.rs b/examples/3d/visibility_range.rs index 013b39d8d1e2c..0765a1156a558 100644 --- a/examples/3d/visibility_range.rs +++ b/examples/3d/visibility_range.rs @@ -6,7 +6,7 @@ use bevy::{ core_pipeline::prepass::{DepthPrepass, NormalPrepass}, input::mouse::MouseWheel, math::vec3, - pbr::{light_consts::lux::FULL_DAYLIGHT, CascadeShadowConfigBuilder}, + pbr::{CascadeShadowConfigBuilder, light_consts::lux::FULL_DAYLIGHT}, prelude::*, render::view::VisibilityRange, }; diff --git a/examples/3d/volumetric_fog.rs b/examples/3d/volumetric_fog.rs index 9cfef624c6594..6e8a3445f9913 100644 --- a/examples/3d/volumetric_fog.rs +++ b/examples/3d/volumetric_fog.rs @@ -2,7 +2,7 @@ use bevy::{ color::palettes::css::RED, - core_pipeline::{bloom::Bloom, tonemapping::Tonemapping, Skybox}, + core_pipeline::{Skybox, bloom::Bloom, tonemapping::Tonemapping}, math::vec3, pbr::{FogVolume, VolumetricFog, VolumetricLight}, prelude::*, diff --git a/examples/3d/wireframe.rs b/examples/3d/wireframe.rs index e62e9f0029537..babee4bd2becb 100644 --- a/examples/3d/wireframe.rs +++ b/examples/3d/wireframe.rs @@ -13,9 +13,9 @@ use bevy::{ pbr::wireframe::{NoWireframe, Wireframe, WireframeColor, WireframeConfig, WireframePlugin}, prelude::*, render::{ + RenderPlugin, render_resource::WgpuFeatures, settings::{RenderCreation, WgpuSettings}, - RenderPlugin, }, }; diff --git a/examples/animation/animated_transform.rs b/examples/animation/animated_transform.rs index decb3d34a69df..caa0717ce7ac2 100644 --- a/examples/animation/animated_transform.rs +++ b/examples/animation/animated_transform.rs @@ -3,7 +3,7 @@ use std::f32::consts::PI; use bevy::{ - animation::{animated_field, AnimationTarget, AnimationTargetId}, + animation::{AnimationTarget, AnimationTargetId, animated_field}, prelude::*, }; diff --git a/examples/animation/animated_ui.rs b/examples/animation/animated_ui.rs index f31b2ccd5eb4b..349d24899a510 100644 --- a/examples/animation/animated_ui.rs +++ b/examples/animation/animated_ui.rs @@ -2,8 +2,8 @@ use bevy::{ animation::{ - animated_field, AnimationEntityMut, AnimationEvaluationError, AnimationTarget, - AnimationTargetId, + AnimationEntityMut, AnimationEvaluationError, AnimationTarget, AnimationTargetId, + animated_field, }, prelude::*, }; diff --git a/examples/animation/custom_skinned_mesh.rs b/examples/animation/custom_skinned_mesh.rs index b091f2dd4254c..356fbbb2a5b88 100644 --- a/examples/animation/custom_skinned_mesh.rs +++ b/examples/animation/custom_skinned_mesh.rs @@ -8,8 +8,8 @@ use bevy::{ prelude::*, render::{ mesh::{ - skinning::{SkinnedMesh, SkinnedMeshInverseBindposes}, Indices, PrimitiveTopology, VertexAttributeValues, + skinning::{SkinnedMesh, SkinnedMeshInverseBindposes}, }, render_asset::RenderAssetUsages, }, diff --git a/examples/animation/eased_motion.rs b/examples/animation/eased_motion.rs index f6254cd65de35..53f9aa876bae9 100644 --- a/examples/animation/eased_motion.rs +++ b/examples/animation/eased_motion.rs @@ -3,7 +3,7 @@ use std::f32::consts::FRAC_PI_2; use bevy::{ - animation::{animated_field, AnimationTarget, AnimationTargetId}, + animation::{AnimationTarget, AnimationTargetId, animated_field}, color::palettes::css::{ORANGE, SILVER}, math::vec3, prelude::*, diff --git a/examples/app/headless.rs b/examples/app/headless.rs index 536da8c26e0a9..316a2892ae7f4 100644 --- a/examples/app/headless.rs +++ b/examples/app/headless.rs @@ -15,7 +15,9 @@ use core::time::Duration; fn main() { if cfg!(feature = "bevy_window") { - println!("This example is running with the bevy_window feature enabled and will not run headless."); + println!( + "This example is running with the bevy_window feature enabled and will not run headless." + ); println!("Disable the default features and rerun the example to run headless."); println!("To do so, run:"); println!(); diff --git a/examples/app/headless_renderer.rs b/examples/app/headless_renderer.rs index 619404dc901c5..8dab39236bed5 100644 --- a/examples/app/headless_renderer.rs +++ b/examples/app/headless_renderer.rs @@ -13,6 +13,7 @@ use bevy::{ image::TextureFormatPixelInfo, prelude::*, render::{ + Extract, Render, RenderApp, RenderSet, camera::RenderTarget, render_asset::{RenderAssetUsages, RenderAssets}, render_graph::{self, NodeRunError, RenderGraph, RenderGraphContext, RenderLabel}, @@ -22,7 +23,6 @@ use bevy::{ TextureUsages, }, renderer::{RenderContext, RenderDevice, RenderQueue}, - Extract, Render, RenderApp, RenderSet, }, winit::WinitPlugin, }; @@ -31,8 +31,8 @@ use std::{ ops::{Deref, DerefMut}, path::PathBuf, sync::{ - atomic::{AtomicBool, Ordering}, Arc, + atomic::{AtomicBool, Ordering}, }, time::Duration, }; diff --git a/examples/app/log_layers.rs b/examples/app/log_layers.rs index 558d5b2ba5a48..7c710336b3f74 100644 --- a/examples/app/log_layers.rs +++ b/examples/app/log_layers.rs @@ -2,9 +2,9 @@ use bevy::{ log::{ + BoxedLayer, tracing::{self, Subscriber}, tracing_subscriber::Layer, - BoxedLayer, }, prelude::*, }; diff --git a/examples/app/log_layers_ecs.rs b/examples/app/log_layers_ecs.rs index 30cba02b8ddb8..d69ee9fca3cdb 100644 --- a/examples/app/log_layers_ecs.rs +++ b/examples/app/log_layers_ecs.rs @@ -15,9 +15,9 @@ use std::sync::mpsc; use bevy::{ log::{ + BoxedLayer, Level, tracing::{self, Subscriber}, tracing_subscriber::{self, Layer}, - BoxedLayer, Level, }, prelude::*, }; diff --git a/examples/app/no_renderer.rs b/examples/app/no_renderer.rs index 5109bba128c8f..8b0059b924b9c 100644 --- a/examples/app/no_renderer.rs +++ b/examples/app/no_renderer.rs @@ -6,7 +6,7 @@ use bevy::{ prelude::*, - render::{settings::WgpuSettings, RenderPlugin}, + render::{RenderPlugin, settings::WgpuSettings}, }; fn main() { diff --git a/examples/asset/asset_decompression.rs b/examples/asset/asset_decompression.rs index edc42ab853fb3..1eb3afe2f3b8e 100644 --- a/examples/asset/asset_decompression.rs +++ b/examples/asset/asset_decompression.rs @@ -2,8 +2,8 @@ use bevy::{ asset::{ - io::{Reader, VecReader}, AssetLoader, CompleteErasedLoadedAsset, LoadContext, LoadDirectError, + io::{Reader, VecReader}, }, prelude::*, reflect::TypePath, diff --git a/examples/asset/asset_loading.rs b/examples/asset/asset_loading.rs index 88867ea458b8b..28ab31fe98bdc 100644 --- a/examples/asset/asset_loading.rs +++ b/examples/asset/asset_loading.rs @@ -36,14 +36,17 @@ fn setup( ); // All assets end up in their Assets collection once they are done loading: - match meshes.get(&sphere_handle) { Some(sphere) => { - // You might notice that this doesn't run! This is because assets load in parallel without - // blocking. When an asset has loaded, it will appear in relevant Assets - // collection. - info!("{:?}", sphere.primitive_topology()); - } _ => { - info!("sphere hasn't loaded yet"); - }} + match meshes.get(&sphere_handle) { + Some(sphere) => { + // You might notice that this doesn't run! This is because assets load in parallel without + // blocking. When an asset has loaded, it will appear in relevant Assets + // collection. + info!("{:?}", sphere.primitive_topology()); + } + _ => { + info!("sphere hasn't loaded yet"); + } + } // You can load all assets in a folder like this. They will be loaded in parallel without // blocking. The LoadedFolder asset holds handles to each asset in the folder. These are all diff --git a/examples/asset/custom_asset.rs b/examples/asset/custom_asset.rs index 8d4ac958ecdd1..fdfd010cc463b 100644 --- a/examples/asset/custom_asset.rs +++ b/examples/asset/custom_asset.rs @@ -1,7 +1,7 @@ //! Implements loader for a custom asset type. use bevy::{ - asset::{io::Reader, AssetLoader, LoadContext}, + asset::{AssetLoader, LoadContext, io::Reader}, prelude::*, reflect::TypePath, }; diff --git a/examples/asset/embedded_asset.rs b/examples/asset/embedded_asset.rs index 66349cfc5aef8..689969aedca5f 100644 --- a/examples/asset/embedded_asset.rs +++ b/examples/asset/embedded_asset.rs @@ -1,7 +1,7 @@ //! Example of loading an embedded asset. use bevy::{ - asset::{embedded_asset, io::AssetSourceId, AssetPath}, + asset::{AssetPath, embedded_asset, io::AssetSourceId}, prelude::*, }; use std::path::Path; diff --git a/examples/asset/extra_source.rs b/examples/asset/extra_source.rs index 298b9d4aa85c7..cf6e07bf267f4 100644 --- a/examples/asset/extra_source.rs +++ b/examples/asset/extra_source.rs @@ -3,8 +3,8 @@ use bevy::{ asset::{ - io::{AssetSourceBuilder, AssetSourceId}, AssetPath, + io::{AssetSourceBuilder, AssetSourceId}, }, prelude::*, }; diff --git a/examples/asset/multi_asset_sync.rs b/examples/asset/multi_asset_sync.rs index 758bb4a06d01c..af84dea08b30f 100644 --- a/examples/asset/multi_asset_sync.rs +++ b/examples/asset/multi_asset_sync.rs @@ -4,8 +4,8 @@ use std::{ f32::consts::PI, ops::Drop, sync::{ - atomic::{AtomicBool, AtomicU32, Ordering}, Arc, + atomic::{AtomicBool, AtomicU32, Ordering}, }, }; diff --git a/examples/asset/processing/asset_processing.rs b/examples/asset/processing/asset_processing.rs index b24f7afb14bc1..c3948c4a9412f 100644 --- a/examples/asset/processing/asset_processing.rs +++ b/examples/asset/processing/asset_processing.rs @@ -2,12 +2,11 @@ use bevy::{ asset::{ - embedded_asset, + AssetLoader, AsyncWriteExt, LoadContext, embedded_asset, io::{Reader, Writer}, processor::LoadTransformAndSave, saver::{AssetSaver, SavedAsset}, transformer::{AssetTransformer, TransformedAsset}, - AssetLoader, AsyncWriteExt, LoadContext, }, prelude::*, reflect::TypePath, diff --git a/examples/async_tasks/async_compute.rs b/examples/async_tasks/async_compute.rs index 0b5a044563528..af9a0bb1cf3ce 100644 --- a/examples/async_tasks/async_compute.rs +++ b/examples/async_tasks/async_compute.rs @@ -4,7 +4,7 @@ use bevy::{ ecs::{system::SystemState, world::CommandQueue}, prelude::*, - tasks::{block_on, futures_lite::future, AsyncComputeTaskPool, Task}, + tasks::{AsyncComputeTaskPool, Task, block_on, futures_lite::future}, }; use rand::Rng; use std::time::Duration; diff --git a/examples/async_tasks/external_source_external_thread.rs b/examples/async_tasks/external_source_external_thread.rs index 92c7c60a82968..94ba29a6ee98f 100644 --- a/examples/async_tasks/external_source_external_thread.rs +++ b/examples/async_tasks/external_source_external_thread.rs @@ -2,7 +2,7 @@ use bevy::prelude::*; // Using crossbeam_channel instead of std as std `Receiver` is `!Sync` -use crossbeam_channel::{bounded, Receiver}; +use crossbeam_channel::{Receiver, bounded}; use rand::{Rng, SeedableRng}; use rand_chacha::ChaCha8Rng; diff --git a/examples/ecs/fallible_systems.rs b/examples/ecs/fallible_systems.rs index 59e82371a353a..42f4a425da554 100644 --- a/examples/ecs/fallible_systems.rs +++ b/examples/ecs/fallible_systems.rs @@ -5,8 +5,8 @@ use bevy::ecs::world::DeferredWorld; use bevy::math::sampling::UniformMeshSampler; use bevy::prelude::*; -use rand::distributions::Distribution; use rand::SeedableRng; +use rand::distributions::Distribution; use rand_chacha::ChaCha8Rng; fn main() { diff --git a/examples/ecs/iter_combinations.rs b/examples/ecs/iter_combinations.rs index b112a0a698a24..08b827ff80062 100644 --- a/examples/ecs/iter_combinations.rs +++ b/examples/ecs/iter_combinations.rs @@ -121,8 +121,12 @@ fn generate_bodies( fn interact_bodies(mut query: Query<(&Mass, &GlobalTransform, &mut Acceleration)>) { let mut iter = query.iter_combinations_mut(); - while let Some([(Mass(m1), transform1, mut acc1), (Mass(m2), transform2, mut acc2)]) = - iter.fetch_next() + while let Some( + [ + (Mass(m1), transform1, mut acc1), + (Mass(m2), transform2, mut acc2), + ], + ) = iter.fetch_next() { let delta = transform2.translation() - transform1.translation(); let distance_sq: f32 = delta.length_squared(); diff --git a/examples/ecs/observer_propagation.rs b/examples/ecs/observer_propagation.rs index 0ca64686d0156..97129876ea85d 100644 --- a/examples/ecs/observer_propagation.rs +++ b/examples/ecs/observer_propagation.rs @@ -3,7 +3,7 @@ use std::time::Duration; use bevy::{log::LogPlugin, prelude::*, time::common_conditions::on_timer}; -use rand::{seq::IteratorRandom, thread_rng, Rng}; +use rand::{Rng, seq::IteratorRandom, thread_rng}; fn main() { App::new() diff --git a/examples/ecs/run_conditions.rs b/examples/ecs/run_conditions.rs index 47c4c76d818e1..3c3d8629c1b4b 100644 --- a/examples/ecs/run_conditions.rs +++ b/examples/ecs/run_conditions.rs @@ -5,7 +5,9 @@ use bevy::prelude::*; fn main() { println!(); println!("For the first 2 seconds you will not be able to increment the counter"); - println!("Once that time has passed you can press space, enter, left mouse, right mouse or touch the screen to increment the counter"); + println!( + "Once that time has passed you can press space, enter, left mouse, right mouse or touch the screen to increment the counter" + ); println!(); App::new() diff --git a/examples/ecs/system_piping.rs b/examples/ecs/system_piping.rs index a3607c085de6d..9436aca6c2530 100644 --- a/examples/ecs/system_piping.rs +++ b/examples/ecs/system_piping.rs @@ -4,7 +4,7 @@ use bevy::prelude::*; use std::num::ParseIntError; -use bevy::log::{debug, error, info, Level, LogPlugin}; +use bevy::log::{Level, LogPlugin, debug, error, info}; fn main() { App::new() diff --git a/examples/games/alien_cake_addict.rs b/examples/games/alien_cake_addict.rs index 67267a8b6fac2..da603a39dc25f 100644 --- a/examples/games/alien_cake_addict.rs +++ b/examples/games/alien_cake_addict.rs @@ -271,25 +271,30 @@ fn focus_camera( ) { const SPEED: f32 = 2.0; // if there is both a player and a bonus, target the mid-point of them - match (game.player.entity, game.bonus.entity) { (Some(player_entity), Some(bonus_entity)) => { - let transform_query = transforms.p1(); - if let (Ok(player_transform), Ok(bonus_transform)) = ( - transform_query.get(player_entity), - transform_query.get(bonus_entity), - ) { - game.camera_should_focus = player_transform - .translation - .lerp(bonus_transform.translation, 0.5); + match (game.player.entity, game.bonus.entity) { + (Some(player_entity), Some(bonus_entity)) => { + let transform_query = transforms.p1(); + if let (Ok(player_transform), Ok(bonus_transform)) = ( + transform_query.get(player_entity), + transform_query.get(bonus_entity), + ) { + game.camera_should_focus = player_transform + .translation + .lerp(bonus_transform.translation, 0.5); + } + // otherwise, if there is only a player, target the player } - // otherwise, if there is only a player, target the player - } _ => if let Some(player_entity) = game.player.entity { - if let Ok(player_transform) = transforms.p1().get(player_entity) { - game.camera_should_focus = player_transform.translation; + _ => { + if let Some(player_entity) = game.player.entity { + if let Ok(player_transform) = transforms.p1().get(player_entity) { + game.camera_should_focus = player_transform.translation; + } + // otherwise, target the middle + } else { + game.camera_should_focus = Vec3::from(RESET_FOCUS); + } } - // otherwise, target the middle - } else { - game.camera_should_focus = Vec3::from(RESET_FOCUS); - }} + } // calculate the camera motion based on the difference between where the camera is looking // and where it should be looking; the greater the distance, the faster the motion; // smooth out the camera movement using the frame time diff --git a/examples/games/game_menu.rs b/examples/games/game_menu.rs index 03056cbe30151..fdc9dac508fa8 100644 --- a/examples/games/game_menu.rs +++ b/examples/games/game_menu.rs @@ -48,7 +48,7 @@ fn setup(mut commands: Commands) { mod splash { use bevy::prelude::*; - use super::{despawn_screen, GameState}; + use super::{GameState, despawn_screen}; // This plugin will display a splash screen with Bevy logo for 1 second before switching to the menu pub fn splash_plugin(app: &mut App) { @@ -113,7 +113,7 @@ mod game { prelude::*, }; - use super::{despawn_screen, DisplayQuality, GameState, Volume, TEXT_COLOR}; + use super::{DisplayQuality, GameState, TEXT_COLOR, Volume, despawn_screen}; // This plugin will contain the game. In this case, it's just be a screen that will // display the current settings for 5 seconds before returning to the menu @@ -229,7 +229,7 @@ mod menu { prelude::*, }; - use super::{despawn_screen, DisplayQuality, GameState, Volume, TEXT_COLOR}; + use super::{DisplayQuality, GameState, TEXT_COLOR, Volume, despawn_screen}; // This plugin manages the menu, with 5 different screens: // - a main menu with "New Game", "Settings", "Quit" diff --git a/examples/math/bounding_2d.rs b/examples/math/bounding_2d.rs index 8fbb41d784456..9b6539c875689 100644 --- a/examples/math/bounding_2d.rs +++ b/examples/math/bounding_2d.rs @@ -2,7 +2,7 @@ use bevy::{ color::palettes::css::*, - math::{bounding::*, ops, Isometry2d}, + math::{Isometry2d, bounding::*, ops}, prelude::*, }; diff --git a/examples/math/cubic_splines.rs b/examples/math/cubic_splines.rs index d4c74c7c73bc3..ec5a266936b18 100644 --- a/examples/math/cubic_splines.rs +++ b/examples/math/cubic_splines.rs @@ -5,7 +5,7 @@ use bevy::{ color::*, ecs::system::Commands, gizmos::gizmos::Gizmos, - input::{mouse::MouseButtonInput, ButtonState}, + input::{ButtonState, mouse::MouseButtonInput}, math::{cubic_splines::*, vec2}, prelude::*, }; diff --git a/examples/math/custom_primitives.rs b/examples/math/custom_primitives.rs index a072b4476412c..3a7c880691e02 100644 --- a/examples/math/custom_primitives.rs +++ b/examples/math/custom_primitives.rs @@ -7,10 +7,10 @@ use bevy::{ color::palettes::css::{RED, WHITE}, input::common_conditions::input_just_pressed, math::{ + Isometry2d, bounding::{ Aabb2d, Bounded2d, Bounded3d, BoundedExtrusion, BoundingCircle, BoundingVolume, }, - Isometry2d, }, prelude::*, render::{ diff --git a/examples/math/random_sampling.rs b/examples/math/random_sampling.rs index 33018c7734c8e..8696fcf8f31de 100644 --- a/examples/math/random_sampling.rs +++ b/examples/math/random_sampling.rs @@ -6,7 +6,7 @@ use bevy::{ prelude::*, render::mesh::SphereKind, }; -use rand::{distributions::Distribution, SeedableRng}; +use rand::{SeedableRng, distributions::Distribution}; use rand_chacha::ChaCha8Rng; fn main() { diff --git a/examples/math/sampling_primitives.rs b/examples/math/sampling_primitives.rs index 446f6c911fe06..082edd679d393 100644 --- a/examples/math/sampling_primitives.rs +++ b/examples/math/sampling_primitives.rs @@ -8,7 +8,7 @@ use bevy::{ math::prelude::*, prelude::*, }; -use rand::{seq::SliceRandom, Rng, SeedableRng}; +use rand::{Rng, SeedableRng, seq::SliceRandom}; use rand_chacha::ChaCha8Rng; fn main() { diff --git a/examples/movement/smooth_follow.rs b/examples/movement/smooth_follow.rs index ccf31e7cf66ee..b74f57b3cce99 100644 --- a/examples/movement/smooth_follow.rs +++ b/examples/movement/smooth_follow.rs @@ -1,7 +1,7 @@ //! This example demonstrates how to use interpolation to make one entity smoothly follow another. use bevy::{ - math::{prelude::*, vec3, NormedVectorSpace}, + math::{NormedVectorSpace, prelude::*, vec3}, prelude::*, }; use rand::SeedableRng; diff --git a/examples/reflection/dynamic_types.rs b/examples/reflection/dynamic_types.rs index 387fe7d0ed34d..88306d1d60ff7 100644 --- a/examples/reflection/dynamic_types.rs +++ b/examples/reflection/dynamic_types.rs @@ -1,10 +1,10 @@ //! This example demonstrates the use of dynamic types in Bevy's reflection system. use bevy::reflect::{ - reflect_trait, serde::TypedReflectDeserializer, std_traits::ReflectDefault, DynamicArray, - DynamicEnum, DynamicList, DynamicMap, DynamicSet, DynamicStruct, DynamicTuple, + DynamicArray, DynamicEnum, DynamicList, DynamicMap, DynamicSet, DynamicStruct, DynamicTuple, DynamicTupleStruct, DynamicVariant, FromReflect, PartialReflect, Reflect, ReflectFromReflect, - Set, TypeRegistry, Typed, + Set, TypeRegistry, Typed, reflect_trait, serde::TypedReflectDeserializer, + std_traits::ReflectDefault, }; use serde::de::DeserializeSeed; use std::collections::{HashMap, HashSet}; @@ -87,10 +87,12 @@ fn main() { // since it doesn't implement `Reflect`, only `PartialReflect`. // Similarly, trying to force the operation will fail. // This fails since the underlying type of `deserialized` is `DynamicStruct` and not `Player`. - assert!(deserialized - .try_as_reflect() - .and_then(|reflect_trait_obj| reflect_identifiable.get(reflect_trait_obj)) - .is_none()); + assert!( + deserialized + .try_as_reflect() + .and_then(|reflect_trait_obj| reflect_identifiable.get(reflect_trait_obj)) + .is_none() + ); // So how can we go from a dynamic type to a concrete type? // There are two ways: @@ -147,13 +149,17 @@ fn main() { assert_eq!(my_list, vec![1, 2, 3]); // And if you want it to actually proxy a type, you can configure it to do that as well: - assert!(!my_dynamic_list - .as_partial_reflect() - .represents::>()); + assert!( + !my_dynamic_list + .as_partial_reflect() + .represents::>() + ); my_dynamic_list.set_represented_type(Some(>::type_info())); - assert!(my_dynamic_list - .as_partial_reflect() - .represents::>()); + assert!( + my_dynamic_list + .as_partial_reflect() + .represents::>() + ); // ============================= REFERENCE ============================= // // For reference, here are all the available dynamic types: diff --git a/examples/reflection/function_reflection.rs b/examples/reflection/function_reflection.rs index 4a4f97497ec67..578603dc4ead2 100644 --- a/examples/reflection/function_reflection.rs +++ b/examples/reflection/function_reflection.rs @@ -7,11 +7,11 @@ //! processing deserialized reflection data, or even just storing type-erased versions of your functions. use bevy::reflect::{ + PartialReflect, Reflect, func::{ ArgList, DynamicFunction, DynamicFunctionMut, FunctionResult, IntoFunction, IntoFunctionMut, Return, SignatureInfo, }, - PartialReflect, Reflect, }; // Note that the `dbg!` invocations are used purely for demonstration purposes diff --git a/examples/reflection/reflection.rs b/examples/reflection/reflection.rs index f2130c35de37f..369cebf0dd1a7 100644 --- a/examples/reflection/reflection.rs +++ b/examples/reflection/reflection.rs @@ -7,8 +7,8 @@ use bevy::{ prelude::*, reflect::{ - serde::{ReflectDeserializer, ReflectSerializer}, DynamicStruct, PartialReflect, + serde::{ReflectDeserializer, ReflectSerializer}, }, }; use serde::de::DeserializeSeed; diff --git a/examples/remote/client.rs b/examples/remote/client.rs index 1188dd0876634..8a65de55a0c95 100644 --- a/examples/remote/client.rs +++ b/examples/remote/client.rs @@ -4,10 +4,10 @@ use anyhow::Result as AnyhowResult; use argh::FromArgs; use bevy::remote::{ - builtin_methods::{BrpQuery, BrpQueryFilter, BrpQueryParams, BRP_QUERY_METHOD}, + BrpRequest, + builtin_methods::{BRP_QUERY_METHOD, BrpQuery, BrpQueryFilter, BrpQueryParams}, http::DEFAULT_ADDR, http::DEFAULT_PORT, - BrpRequest, }; /// Struct containing the command-line arguments that can be passed to this example. diff --git a/examples/remote/server.rs b/examples/remote/server.rs index 39033218a7379..f6f91c18c709b 100644 --- a/examples/remote/server.rs +++ b/examples/remote/server.rs @@ -4,7 +4,7 @@ use bevy::math::ops::cos; use bevy::{ input::common_conditions::input_just_pressed, prelude::*, - remote::{http::RemoteHttpPlugin, RemotePlugin}, + remote::{RemotePlugin, http::RemoteHttpPlugin}, }; use serde::{Deserialize, Serialize}; diff --git a/examples/shader/compute_shader_game_of_life.rs b/examples/shader/compute_shader_game_of_life.rs index af9fe3b2928b2..7118588fb6ee9 100644 --- a/examples/shader/compute_shader_game_of_life.rs +++ b/examples/shader/compute_shader_game_of_life.rs @@ -6,13 +6,13 @@ use bevy::{ prelude::*, render::{ + Render, RenderApp, RenderSet, extract_resource::{ExtractResource, ExtractResourcePlugin}, render_asset::{RenderAssetUsages, RenderAssets}, render_graph::{self, RenderGraph, RenderLabel}, render_resource::{binding_types::texture_storage_2d, *}, renderer::{RenderContext, RenderDevice}, texture::GpuImage, - Render, RenderApp, RenderSet, }, }; use std::borrow::Cow; diff --git a/examples/shader/custom_phase_item.rs b/examples/shader/custom_phase_item.rs index fe69c5b8125ac..5728ba509d09a 100644 --- a/examples/shader/custom_phase_item.rs +++ b/examples/shader/custom_phase_item.rs @@ -8,14 +8,15 @@ //! for better reuse of parts of Bevy's built-in mesh rendering logic. use bevy::{ - core_pipeline::core_3d::{Opaque3d, Opaque3dBatchSetKey, Opaque3dBinKey, CORE_3D_DEPTH_FORMAT}, + core_pipeline::core_3d::{CORE_3D_DEPTH_FORMAT, Opaque3d, Opaque3dBatchSetKey, Opaque3dBinKey}, ecs::{ component::Tick, query::ROQueryItem, - system::{lifetimeless::SRes, SystemParamItem}, + system::{SystemParamItem, lifetimeless::SRes}, }, prelude::*, render::{ + Render, RenderApp, RenderSet, extract_component::{ExtractComponent, ExtractComponentPlugin}, primitives::Aabb, render_phase::{ @@ -32,7 +33,6 @@ use bevy::{ }, renderer::{RenderDevice, RenderQueue}, view::{self, ExtractedView, RenderVisibleEntities, VisibilityClass}, - Render, RenderApp, RenderSet, }, }; use bytemuck::{Pod, Zeroable}; diff --git a/examples/shader/custom_post_processing.rs b/examples/shader/custom_post_processing.rs index ec532071bf2b8..9ccf79083ab64 100644 --- a/examples/shader/custom_post_processing.rs +++ b/examples/shader/custom_post_processing.rs @@ -14,6 +14,7 @@ use bevy::{ ecs::query::QueryItem, prelude::*, render::{ + RenderApp, extract_component::{ ComponentUniforms, DynamicUniformIndex, ExtractComponent, ExtractComponentPlugin, UniformComponentPlugin, @@ -27,7 +28,6 @@ use bevy::{ }, renderer::{RenderContext, RenderDevice}, view::ViewTarget, - RenderApp, }, }; diff --git a/examples/shader/custom_render_phase.rs b/examples/shader/custom_render_phase.rs index 47aad1b88faef..84c24fcabb65d 100644 --- a/examples/shader/custom_render_phase.rs +++ b/examples/shader/custom_render_phase.rs @@ -16,7 +16,7 @@ use bevy::{ core_pipeline::core_3d::graph::{Core3d, Node3d}, ecs::{ query::QueryItem, - system::{lifetimeless::SRes, SystemParamItem}, + system::{SystemParamItem, lifetimeless::SRes}, }, math::FloatOrd, pbr::{ @@ -26,24 +26,25 @@ use bevy::{ platform_support::collections::HashSet, prelude::*, render::{ + Extract, Render, RenderApp, RenderDebugFlags, RenderSet, batching::{ + GetBatchData, GetFullBatchData, gpu_preprocessing::{ - batch_and_prepare_sorted_render_phase, IndirectParametersCpuMetadata, - UntypedPhaseIndirectParametersBuffers, + IndirectParametersCpuMetadata, UntypedPhaseIndirectParametersBuffers, + batch_and_prepare_sorted_render_phase, }, - GetBatchData, GetFullBatchData, }, camera::ExtractedCamera, extract_component::{ExtractComponent, ExtractComponentPlugin}, - mesh::{allocator::MeshAllocator, MeshVertexBufferLayoutRef, RenderMesh}, + mesh::{MeshVertexBufferLayoutRef, RenderMesh, allocator::MeshAllocator}, render_asset::RenderAssets, render_graph::{ NodeRunError, RenderGraphApp, RenderGraphContext, RenderLabel, ViewNode, ViewNodeRunner, }, render_phase::{ - sort_phase_system, AddRenderCommand, CachedRenderPipelinePhaseItem, DrawFunctionId, - DrawFunctions, PhaseItem, PhaseItemExtraIndex, SetItemPipeline, SortedPhaseItem, - SortedRenderPhasePlugin, ViewSortedRenderPhases, + AddRenderCommand, CachedRenderPipelinePhaseItem, DrawFunctionId, DrawFunctions, + PhaseItem, PhaseItemExtraIndex, SetItemPipeline, SortedPhaseItem, + SortedRenderPhasePlugin, ViewSortedRenderPhases, sort_phase_system, }, render_resource::{ CachedRenderPipelineId, ColorTargetState, ColorWrites, Face, FragmentState, FrontFace, @@ -54,7 +55,6 @@ use bevy::{ renderer::RenderContext, sync_world::MainEntity, view::{ExtractedView, RenderVisibleEntities, RetainedViewEntity, ViewTarget}, - Extract, Render, RenderApp, RenderDebugFlags, RenderSet, }, }; use nonmax::NonMaxU32; diff --git a/examples/shader/custom_shader_instancing.rs b/examples/shader/custom_shader_instancing.rs index cd5909c36fff1..f4d7a359d8b90 100644 --- a/examples/shader/custom_shader_instancing.rs +++ b/examples/shader/custom_shader_instancing.rs @@ -11,16 +11,17 @@ use bevy::{ core_pipeline::core_3d::Transparent3d, ecs::{ query::QueryItem, - system::{lifetimeless::*, SystemParamItem}, + system::{SystemParamItem, lifetimeless::*}, }, pbr::{ MeshPipeline, MeshPipelineKey, RenderMeshInstances, SetMeshBindGroup, SetMeshViewBindGroup, }, prelude::*, render::{ + Render, RenderApp, RenderSet, extract_component::{ExtractComponent, ExtractComponentPlugin}, mesh::{ - allocator::MeshAllocator, MeshVertexBufferLayoutRef, RenderMesh, RenderMeshBufferInfo, + MeshVertexBufferLayoutRef, RenderMesh, RenderMeshBufferInfo, allocator::MeshAllocator, }, render_asset::RenderAssets, render_phase::{ @@ -31,7 +32,6 @@ use bevy::{ renderer::RenderDevice, sync_world::MainEntity, view::{ExtractedView, NoFrustumCulling, NoIndirectDrawing}, - Render, RenderApp, RenderSet, }, }; use bytemuck::{Pod, Zeroable}; diff --git a/examples/shader/gpu_readback.rs b/examples/shader/gpu_readback.rs index 55a752b315915..228a2c62783f7 100644 --- a/examples/shader/gpu_readback.rs +++ b/examples/shader/gpu_readback.rs @@ -4,6 +4,7 @@ use bevy::{ prelude::*, render::{ + Render, RenderApp, RenderSet, extract_resource::{ExtractResource, ExtractResourcePlugin}, gpu_readback::{Readback, ReadbackComplete}, render_asset::{RenderAssetUsages, RenderAssets}, @@ -15,7 +16,6 @@ use bevy::{ renderer::{RenderContext, RenderDevice}, storage::{GpuShaderStorageBuffer, ShaderStorageBuffer}, texture::GpuImage, - Render, RenderApp, RenderSet, }, }; diff --git a/examples/shader/specialized_mesh_pipeline.rs b/examples/shader/specialized_mesh_pipeline.rs index 66f42f5872ecc..f1e3626c1482e 100644 --- a/examples/shader/specialized_mesh_pipeline.rs +++ b/examples/shader/specialized_mesh_pipeline.rs @@ -7,7 +7,7 @@ //! [`SpecializedMeshPipeline`] let's you customize the entire pipeline used when rendering a mesh. use bevy::{ - core_pipeline::core_3d::{Opaque3d, Opaque3dBatchSetKey, Opaque3dBinKey, CORE_3D_DEPTH_FORMAT}, + core_pipeline::core_3d::{CORE_3D_DEPTH_FORMAT, Opaque3d, Opaque3dBatchSetKey, Opaque3dBinKey}, ecs::{component::Tick, system::StaticSystemParam}, math::{vec3, vec4}, pbr::{ @@ -16,12 +16,13 @@ use bevy::{ }, prelude::*, render::{ + Render, RenderApp, RenderSet, batching::{ + GetBatchData, GetFullBatchData, gpu_preprocessing::{ self, PhaseBatchedInstanceBuffers, PhaseIndirectParametersBuffers, PreprocessWorkItem, UntypedPhaseBatchedInstanceBuffers, }, - GetBatchData, GetFullBatchData, }, experimental::occlusion_culling::OcclusionCulling, extract_component::{ExtractComponent, ExtractComponentPlugin}, @@ -39,7 +40,6 @@ use bevy::{ }, view::NoIndirectDrawing, view::{self, ExtractedView, RenderVisibleEntities, ViewTarget, VisibilityClass}, - Render, RenderApp, RenderSet, }, }; diff --git a/examples/shader/texture_binding_array.rs b/examples/shader/texture_binding_array.rs index bf5dc3da9debe..ff7fd3739ac6f 100644 --- a/examples/shader/texture_binding_array.rs +++ b/examples/shader/texture_binding_array.rs @@ -2,10 +2,11 @@ //! `binding_array>` shader binding slot and sample non-uniformly. use bevy::{ - ecs::system::{lifetimeless::SRes, SystemParamItem}, + ecs::system::{SystemParamItem, lifetimeless::SRes}, prelude::*, reflect::TypePath, render::{ + RenderApp, render_asset::RenderAssets, render_resource::{ binding_types::{sampler, texture_2d}, @@ -13,7 +14,6 @@ use bevy::{ }, renderer::RenderDevice, texture::{FallbackImage, GpuImage}, - RenderApp, }, }; use std::{num::NonZero, process::exit}; diff --git a/examples/stress_tests/bevymark.rs b/examples/stress_tests/bevymark.rs index 1ee719d93f85c..116c82e54d149 100644 --- a/examples/stress_tests/bevymark.rs +++ b/examples/stress_tests/bevymark.rs @@ -18,7 +18,7 @@ use bevy::{ window::{PresentMode, WindowResolution}, winit::{UpdateMode, WinitSettings}, }; -use rand::{seq::SliceRandom, Rng, SeedableRng}; +use rand::{Rng, SeedableRng, seq::SliceRandom}; use rand_chacha::ChaCha8Rng; const BIRDS_PER_SECOND: u32 = 10000; diff --git a/examples/stress_tests/many_components.rs b/examples/stress_tests/many_components.rs index f047445f94bbe..36ad4e8d44fc3 100644 --- a/examples/stress_tests/many_components.rs +++ b/examples/stress_tests/many_components.rs @@ -13,6 +13,7 @@ //! If no valid number is provided, for each argument there's a reasonable default. use bevy::{ + MinimalPlugins, diagnostic::{ DiagnosticPath, DiagnosticsPlugin, FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin, }, @@ -24,7 +25,6 @@ use bevy::{ log::LogPlugin, prelude::{App, In, IntoSystem, Query, Schedule, SystemParamBuilder, Update}, ptr::{OwningPtr, PtrMut}, - MinimalPlugins, }; use rand::prelude::{Rng, SeedableRng, SliceRandom}; diff --git a/examples/stress_tests/many_cubes.rs b/examples/stress_tests/many_cubes.rs index 1d8a50313152f..98e377ac567de 100644 --- a/examples/stress_tests/many_cubes.rs +++ b/examples/stress_tests/many_cubes.rs @@ -25,7 +25,7 @@ use bevy::{ window::{PresentMode, WindowResolution}, winit::{UpdateMode, WinitSettings}, }; -use rand::{seq::SliceRandom, Rng, SeedableRng}; +use rand::{Rng, SeedableRng, seq::SliceRandom}; use rand_chacha::ChaCha8Rng; #[derive(FromArgs, Resource)] diff --git a/examples/stress_tests/many_lights.rs b/examples/stress_tests/many_lights.rs index a19f02d156725..74acd59ed4574 100644 --- a/examples/stress_tests/many_lights.rs +++ b/examples/stress_tests/many_lights.rs @@ -9,11 +9,11 @@ use bevy::{ math::{DVec2, DVec3}, pbr::{ExtractedPointLight, GlobalClusterableObjectMeta}, prelude::*, - render::{camera::ScalingMode, Render, RenderApp, RenderSet}, + render::{Render, RenderApp, RenderSet, camera::ScalingMode}, window::{PresentMode, WindowResolution}, winit::{UpdateMode, WinitSettings}, }; -use rand::{thread_rng, Rng}; +use rand::{Rng, thread_rng}; fn main() { App::new() diff --git a/examples/stress_tests/many_text2d.rs b/examples/stress_tests/many_text2d.rs index 65c133a813c77..08472046ee100 100644 --- a/examples/stress_tests/many_text2d.rs +++ b/examples/stress_tests/many_text2d.rs @@ -12,8 +12,8 @@ use bevy::{ use argh::FromArgs; use rand::{ - seq::{IteratorRandom, SliceRandom}, Rng, SeedableRng, + seq::{IteratorRandom, SliceRandom}, }; use rand_chacha::ChaCha8Rng; diff --git a/examples/tools/scene_viewer/scene_viewer_plugin.rs b/examples/tools/scene_viewer/scene_viewer_plugin.rs index 49f4805d06eb7..2e2990b3fc8d1 100644 --- a/examples/tools/scene_viewer/scene_viewer_plugin.rs +++ b/examples/tools/scene_viewer/scene_viewer_plugin.rs @@ -101,7 +101,9 @@ fn scene_load_check( scene_handle.scene_index, gltf.scenes.len() ); - info!("You can select the scene by adding '#Scene' followed by a number to the end of the file path (e.g '#Scene1' to load the second scene)."); + info!( + "You can select the scene by adding '#Scene' followed by a number to the end of the file path (e.g '#Scene1' to load the second scene)." + ); } let gltf_scene_handle = diff --git a/examples/ui/directional_navigation.rs b/examples/ui/directional_navigation.rs index 0512c7498db54..d3e918e790e9b 100644 --- a/examples/ui/directional_navigation.rs +++ b/examples/ui/directional_navigation.rs @@ -9,10 +9,10 @@ use std::time::Duration; use bevy::{ input_focus::{ + InputDispatchPlugin, InputFocus, InputFocusVisible, directional_navigation::{ DirectionalNavigation, DirectionalNavigationMap, DirectionalNavigationPlugin, }, - InputDispatchPlugin, InputFocus, InputFocusVisible, }, math::{CompassOctant, FloatOrd}, picking::{ diff --git a/examples/ui/tab_navigation.rs b/examples/ui/tab_navigation.rs index c6060bd848e07..60d57568559df 100644 --- a/examples/ui/tab_navigation.rs +++ b/examples/ui/tab_navigation.rs @@ -3,8 +3,8 @@ use bevy::{ color::palettes::basic::*, input_focus::{ - tab_navigation::{TabGroup, TabIndex, TabNavigationPlugin}, InputDispatchPlugin, InputFocus, + tab_navigation::{TabGroup, TabIndex, TabNavigationPlugin}, }, prelude::*, winit::WinitSettings, diff --git a/examples/window/custom_user_event.rs b/examples/window/custom_user_event.rs index c01df5fa6d549..68376482e88ad 100644 --- a/examples/window/custom_user_event.rs +++ b/examples/window/custom_user_event.rs @@ -83,7 +83,7 @@ fn handle_event(mut events: EventReader) { pub(crate) mod wasm { use super::*; use bevy::winit::EventLoopProxy; - use wasm_bindgen::{prelude::*, JsCast}; + use wasm_bindgen::{JsCast, prelude::*}; use web_sys::KeyboardEvent; pub(crate) fn setup_js_closure(event_loop: Res>) { diff --git a/examples/window/screenshot.rs b/examples/window/screenshot.rs index 84c15a6837349..854b6dea6d01c 100644 --- a/examples/window/screenshot.rs +++ b/examples/window/screenshot.rs @@ -2,7 +2,7 @@ use bevy::{ prelude::*, - render::view::screenshot::{save_to_disk, Capturing, Screenshot}, + render::view::screenshot::{Capturing, Screenshot, save_to_disk}, window::SystemCursorIcon, winit::cursor::CursorIcon, }; diff --git a/tools/build-easefunction-graphs/src/main.rs b/tools/build-easefunction-graphs/src/main.rs index 5034251ab2a47..caf9f74eb241a 100644 --- a/tools/build-easefunction-graphs/src/main.rs +++ b/tools/build-easefunction-graphs/src/main.rs @@ -3,8 +3,8 @@ use std::path::PathBuf; use bevy_math::curve::{CurveExt, EaseFunction, EasingCurve, JumpAt}; use svg::{ - node::element::{self, path::Data}, Document, + node::element::{self, path::Data}, }; fn main() { diff --git a/tools/build-wasm-example/src/main.rs b/tools/build-wasm-example/src/main.rs index 1162aaece7449..9e3e79a46b8ec 100644 --- a/tools/build-wasm-example/src/main.rs +++ b/tools/build-wasm-example/src/main.rs @@ -3,7 +3,7 @@ use std::{fs::File, io::Write}; use clap::{Parser, ValueEnum}; -use xshell::{cmd, Shell}; +use xshell::{Shell, cmd}; #[derive(Debug, Copy, Clone, ValueEnum)] enum WebApi { diff --git a/tools/ci/src/commands/compile.rs b/tools/ci/src/commands/compile.rs index f445aaca57331..58bd1f9006fcd 100644 --- a/tools/ci/src/commands/compile.rs +++ b/tools/ci/src/commands/compile.rs @@ -1,9 +1,9 @@ use crate::{ + Flag, Prepare, PreparedCommand, commands::{ BenchCheckCommand, CompileCheckCommand, CompileFailCommand, ExampleCheckCommand, IntegrationTestCheckCommand, TestCheckCommand, }, - Flag, Prepare, PreparedCommand, }; use argh::FromArgs; diff --git a/tools/ci/src/commands/doc.rs b/tools/ci/src/commands/doc.rs index fb8074ca8cf48..f62eea7691f67 100644 --- a/tools/ci/src/commands/doc.rs +++ b/tools/ci/src/commands/doc.rs @@ -1,6 +1,6 @@ use crate::{ - commands::{DocCheckCommand, DocTestCommand}, Flag, Prepare, PreparedCommand, + commands::{DocCheckCommand, DocTestCommand}, }; use argh::FromArgs; diff --git a/tools/ci/src/commands/integration_test.rs b/tools/ci/src/commands/integration_test.rs index b86a027a56026..ba4adbcd9d34a 100644 --- a/tools/ci/src/commands/integration_test.rs +++ b/tools/ci/src/commands/integration_test.rs @@ -1,4 +1,4 @@ -use crate::{commands::get_integration_tests, Flag, Prepare, PreparedCommand}; +use crate::{Flag, Prepare, PreparedCommand, commands::get_integration_tests}; use argh::FromArgs; use xshell::cmd; diff --git a/tools/ci/src/commands/lints.rs b/tools/ci/src/commands/lints.rs index befdaf5fc5d48..28cd047c5f1c4 100644 --- a/tools/ci/src/commands/lints.rs +++ b/tools/ci/src/commands/lints.rs @@ -1,6 +1,6 @@ use crate::{ - commands::{ClippyCommand, FormatCommand}, Flag, Prepare, PreparedCommand, + commands::{ClippyCommand, FormatCommand}, }; use argh::FromArgs; diff --git a/tools/compile_fail_utils/src/lib.rs b/tools/compile_fail_utils/src/lib.rs index 816e81d062865..dedfb56dc2882 100644 --- a/tools/compile_fail_utils/src/lib.rs +++ b/tools/compile_fail_utils/src/lib.rs @@ -7,13 +7,13 @@ use std::{ pub use ui_test; use ui_test::{ + Args, Config, OutputConflictHandling, color_eyre::eyre::eyre, default_file_filter, default_per_file_config, dependencies::DependencyBuilder, run_tests_generic, spanned::Spanned, status_emitter::{Gha, StatusEmitter, Text}, - Args, Config, OutputConflictHandling, }; /// Use this instead of hand rolling configs. diff --git a/tools/example-showcase/src/main.rs b/tools/example-showcase/src/main.rs index 49afb15c2048c..ee810dde50211 100644 --- a/tools/example-showcase/src/main.rs +++ b/tools/example-showcase/src/main.rs @@ -6,7 +6,7 @@ use core::{ time::Duration, }; use std::{ - collections::{hash_map::DefaultHasher, HashMap}, + collections::{HashMap, hash_map::DefaultHasher}, fs::{self, File}, io::Write, path::{Path, PathBuf}, @@ -15,11 +15,11 @@ use std::{ time::Instant, }; -use clap::{error::ErrorKind, CommandFactory, Parser, ValueEnum}; +use clap::{CommandFactory, Parser, ValueEnum, error::ErrorKind}; use pbr::ProgressBar; use regex::Regex; use toml_edit::{DocumentMut, Item}; -use xshell::{cmd, Shell}; +use xshell::{Shell, cmd}; #[derive(Parser, Debug)] struct Args { From d0b5271a7ff857a3d853c41f6e759ce74f23a9b8 Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Fri, 21 Feb 2025 22:48:15 +1100 Subject: [PATCH 20/34] Revert "cargo fmt" This reverts commit 1984e6c506551586e34fd7f8206e2a7552f60e35. --- benches/benches/bevy_ecs/change_detection.rs | 4 +- benches/benches/bevy_ecs/components/mod.rs | 2 +- benches/benches/bevy_ecs/empty_archetypes.rs | 2 +- benches/benches/bevy_ecs/entity_cloning.rs | 2 +- benches/benches/bevy_ecs/events/mod.rs | 2 +- .../iteration/iter_frag_foreach_wide.rs | 22 +- .../iter_frag_foreach_wide_sparse.rs | 22 +- .../bevy_ecs/iteration/iter_frag_wide.rs | 22 +- .../iteration/iter_frag_wide_sparse.rs | 22 +- .../iteration/iter_simple_foreach_hybrid.rs | 2 +- .../iteration/iter_simple_foreach_wide.rs | 8 +- .../iter_simple_foreach_wide_sparse_set.rs | 8 +- .../bevy_ecs/iteration/iter_simple_wide.rs | 8 +- .../iteration/iter_simple_wide_sparse_set.rs | 8 +- benches/benches/bevy_ecs/iteration/mod.rs | 2 +- .../par_iter_simple_foreach_hybrid.rs | 2 +- .../benches/bevy_ecs/observers/propagation.rs | 2 +- benches/benches/bevy_ecs/observers/simple.rs | 2 +- benches/benches/bevy_ecs/world/entity_hash.rs | 2 +- benches/benches/bevy_ecs/world/world_get.rs | 2 +- benches/benches/bevy_math/bezier.rs | 4 +- .../bevy_picking/ray_mesh_intersection.rs | 2 +- benches/benches/bevy_reflect/function.rs | 2 +- benches/benches/bevy_reflect/list.rs | 4 +- benches/benches/bevy_reflect/map.rs | 4 +- benches/benches/bevy_reflect/path.rs | 4 +- benches/benches/bevy_reflect/struct.rs | 4 +- benches/benches/bevy_render/render_layers.rs | 2 +- benches/benches/bevy_render/torus.rs | 2 +- benches/benches/bevy_tasks/iter.rs | 2 +- crates/bevy_a11y/src/lib.rs | 4 +- crates/bevy_animation/src/animation_curves.rs | 6 +- crates/bevy_animation/src/gltf_curves.rs | 11 +- crates/bevy_animation/src/graph.rs | 6 +- crates/bevy_animation/src/lib.rs | 8 +- crates/bevy_animation/src/transition.rs | 4 +- crates/bevy_animation/src/util.rs | 6 +- crates/bevy_app/src/app.rs | 2 +- crates/bevy_app/src/lib.rs | 2 +- crates/bevy_app/src/plugin.rs | 2 +- crates/bevy_app/src/plugin_group.rs | 3 +- crates/bevy_app/src/schedule_runner.rs | 4 +- .../bevy_app/src/terminal_ctrl_c_handler.rs | 4 +- crates/bevy_asset/macros/src/lib.rs | 2 +- crates/bevy_asset/src/assets.rs | 4 +- crates/bevy_asset/src/direct_access_ext.rs | 2 +- crates/bevy_asset/src/handle.rs | 12 +- crates/bevy_asset/src/id.rs | 4 +- crates/bevy_asset/src/io/android.rs | 2 +- .../src/io/embedded/embedded_watcher.rs | 6 +- crates/bevy_asset/src/io/embedded/mod.rs | 12 +- crates/bevy_asset/src/io/file/file_asset.rs | 6 +- crates/bevy_asset/src/io/file/file_watcher.rs | 14 +- .../bevy_asset/src/io/file/sync_file_asset.rs | 6 +- crates/bevy_asset/src/io/memory.rs | 2 +- crates/bevy_asset/src/io/mod.rs | 2 +- crates/bevy_asset/src/io/processor_gated.rs | 2 +- crates/bevy_asset/src/io/source.rs | 26 +- crates/bevy_asset/src/io/wasm.rs | 6 +- crates/bevy_asset/src/lib.rs | 41 +-- crates/bevy_asset/src/loader.rs | 14 +- crates/bevy_asset/src/loader_builders.rs | 4 +- crates/bevy_asset/src/meta.rs | 6 +- crates/bevy_asset/src/path.rs | 10 +- crates/bevy_asset/src/processor/mod.rs | 55 ++-- crates/bevy_asset/src/processor/process.rs | 16 +- crates/bevy_asset/src/reflect.rs | 2 +- crates/bevy_asset/src/saver.rs | 4 +- crates/bevy_asset/src/server/info.rs | 16 +- crates/bevy_asset/src/server/loaders.rs | 14 +- crates/bevy_asset/src/server/mod.rs | 22 +- crates/bevy_asset/src/transformer.rs | 4 +- crates/bevy_audio/src/audio_source.rs | 2 +- crates/bevy_audio/src/lib.rs | 2 +- crates/bevy_audio/src/pitch.rs | 2 +- crates/bevy_color/src/color.rs | 4 +- crates/bevy_color/src/color_gradient.rs | 4 +- crates/bevy_color/src/color_ops.rs | 4 +- crates/bevy_color/src/color_range.rs | 2 +- crates/bevy_color/src/hwba.rs | 2 +- crates/bevy_color/src/laba.rs | 6 +- crates/bevy_color/src/lcha.rs | 8 +- crates/bevy_color/src/linear_rgba.rs | 6 +- crates/bevy_color/src/oklaba.rs | 6 +- crates/bevy_color/src/oklcha.rs | 6 +- crates/bevy_color/src/srgba.rs | 6 +- crates/bevy_color/src/xyza.rs | 8 +- .../src/auto_exposure/buffers.rs | 6 +- .../src/auto_exposure/compensation_curve.rs | 4 +- .../src/auto_exposure/mod.rs | 8 +- .../src/auto_exposure/node.rs | 2 +- .../src/auto_exposure/settings.rs | 2 +- crates/bevy_core_pipeline/src/blit/mod.rs | 4 +- .../src/bloom/downsampling_pipeline.rs | 2 +- crates/bevy_core_pipeline/src/bloom/mod.rs | 12 +- .../bevy_core_pipeline/src/bloom/settings.rs | 2 +- .../src/bloom/upsampling_pipeline.rs | 4 +- .../src/contrast_adaptive_sharpening/mod.rs | 6 +- .../src/core_2d/camera_2d.rs | 2 +- crates/bevy_core_pipeline/src/core_2d/mod.rs | 8 +- .../src/core_3d/camera_3d.rs | 2 +- crates/bevy_core_pipeline/src/core_3d/mod.rs | 20 +- .../src/deferred/copy_lighting_id.rs | 4 +- crates/bevy_core_pipeline/src/dof/mod.rs | 20 +- .../src/experimental/mip_generation/mod.rs | 12 +- .../src/fullscreen_vertex_shader/mod.rs | 2 +- crates/bevy_core_pipeline/src/fxaa/mod.rs | 6 +- .../bevy_core_pipeline/src/motion_blur/mod.rs | 8 +- .../src/motion_blur/node.rs | 2 +- .../src/motion_blur/pipeline.rs | 10 +- .../bevy_core_pipeline/src/msaa_writeback.rs | 2 +- crates/bevy_core_pipeline/src/oit/mod.rs | 16 +- .../bevy_core_pipeline/src/oit/resolve/mod.rs | 10 +- .../src/post_process/mod.rs | 10 +- crates/bevy_core_pipeline/src/prepass/mod.rs | 2 +- crates/bevy_core_pipeline/src/skybox/mod.rs | 8 +- .../bevy_core_pipeline/src/skybox/prepass.rs | 16 +- crates/bevy_core_pipeline/src/smaa/mod.rs | 12 +- crates/bevy_core_pipeline/src/taa/mod.rs | 10 +- .../bevy_core_pipeline/src/tonemapping/mod.rs | 6 +- .../src/tonemapping/node.rs | 2 +- .../bevy_core_pipeline/src/upscaling/mod.rs | 2 +- crates/bevy_derive/src/bevy_main.rs | 2 +- crates/bevy_derive/src/derefs.rs | 6 +- crates/bevy_derive/src/enum_variant_meta.rs | 4 +- crates/bevy_derive/src/lib.rs | 2 +- .../bevy_dev_tools/src/ci_testing/systems.rs | 2 +- crates/bevy_dev_tools/src/fps_overlay.rs | 4 +- crates/bevy_dev_tools/src/picking_debug.rs | 2 +- .../src/frame_count_diagnostics_plugin.rs | 4 +- .../src/frame_time_diagnostics_plugin.rs | 4 +- crates/bevy_diagnostic/src/lib.rs | 2 +- .../system_information_diagnostics_plugin.rs | 2 +- crates/bevy_ecs/macros/src/component.rs | 12 +- crates/bevy_ecs/macros/src/lib.rs | 6 +- crates/bevy_ecs/macros/src/query_data.rs | 4 +- crates/bevy_ecs/macros/src/query_filter.rs | 2 +- crates/bevy_ecs/macros/src/states.rs | 2 +- crates/bevy_ecs/src/bundle.rs | 2 +- crates/bevy_ecs/src/change_detection.rs | 4 +- crates/bevy_ecs/src/component.rs | 2 +- crates/bevy_ecs/src/entity/clone_entities.rs | 14 +- crates/bevy_ecs/src/entity/map_entities.rs | 12 +- crates/bevy_ecs/src/entity/mod.rs | 4 +- crates/bevy_ecs/src/entity/unique_slice.rs | 4 +- crates/bevy_ecs/src/entity/unique_vec.rs | 4 +- crates/bevy_ecs/src/entity/visit_entities.rs | 2 +- crates/bevy_ecs/src/event/collections.rs | 2 +- crates/bevy_ecs/src/event/mod.rs | 26 +- crates/bevy_ecs/src/lib.rs | 64 ++--- crates/bevy_ecs/src/name.rs | 6 +- crates/bevy_ecs/src/observer/mod.rs | 16 +- crates/bevy_ecs/src/query/access.rs | 2 +- crates/bevy_ecs/src/query/fetch.rs | 6 +- crates/bevy_ecs/src/query/filter.rs | 12 +- crates/bevy_ecs/src/query/iter.rs | 4 +- crates/bevy_ecs/src/query/mod.rs | 20 +- crates/bevy_ecs/src/query/state.rs | 17 +- crates/bevy_ecs/src/query/world_query.rs | 2 +- crates/bevy_ecs/src/reflect/bundle.rs | 2 +- crates/bevy_ecs/src/reflect/component.rs | 16 +- .../bevy_ecs/src/reflect/entity_commands.rs | 10 +- crates/bevy_ecs/src/reflect/mod.rs | 4 +- crates/bevy_ecs/src/reflect/resource.rs | 2 +- crates/bevy_ecs/src/relationship/mod.rs | 11 +- .../relationship_source_collection.rs | 2 +- crates/bevy_ecs/src/removal_detection.rs | 2 +- .../schedule/auto_insert_apply_deferred.rs | 4 +- crates/bevy_ecs/src/schedule/condition.rs | 2 +- crates/bevy_ecs/src/schedule/config.rs | 2 +- crates/bevy_ecs/src/schedule/executor/mod.rs | 4 +- .../src/schedule/executor/multi_threaded.rs | 6 +- .../bevy_ecs/src/schedule/executor/simple.rs | 2 +- .../src/schedule/executor/single_threaded.rs | 2 +- crates/bevy_ecs/src/schedule/graph/node.rs | 2 +- crates/bevy_ecs/src/schedule/schedule.rs | 32 +-- crates/bevy_ecs/src/schedule/set.rs | 2 +- crates/bevy_ecs/src/storage/resource.rs | 2 +- crates/bevy_ecs/src/storage/table/mod.rs | 2 +- crates/bevy_ecs/src/system/adapter_system.rs | 2 +- crates/bevy_ecs/src/system/builder.rs | 26 +- crates/bevy_ecs/src/system/combinator.rs | 2 +- .../bevy_ecs/src/system/commands/command.rs | 2 +- .../src/system/commands/entity_command.rs | 14 +- crates/bevy_ecs/src/system/commands/mod.rs | 10 +- .../src/system/exclusive_function_system.rs | 6 +- crates/bevy_ecs/src/system/function_system.rs | 24 +- crates/bevy_ecs/src/system/mod.rs | 32 +-- crates/bevy_ecs/src/system/observer_system.rs | 4 +- crates/bevy_ecs/src/system/query.rs | 10 +- crates/bevy_ecs/src/system/schedule_system.rs | 4 +- crates/bevy_ecs/src/system/system.rs | 10 +- crates/bevy_ecs/src/system/system_param.rs | 34 +-- crates/bevy_ecs/src/system/system_registry.rs | 12 +- crates/bevy_ecs/src/world/command_queue.rs | 8 +- crates/bevy_ecs/src/world/deferred_world.rs | 4 +- crates/bevy_ecs/src/world/entity_fetch.rs | 6 +- crates/bevy_ecs/src/world/entity_ref.rs | 24 +- crates/bevy_ecs/src/world/error.rs | 4 +- .../bevy_ecs/src/world/filtered_resource.rs | 2 +- crates/bevy_ecs/src/world/mod.rs | 77 ++---- crates/bevy_ecs/src/world/reflect.rs | 8 +- crates/bevy_gilrs/src/gilrs_system.rs | 4 +- crates/bevy_gilrs/src/lib.rs | 2 +- crates/bevy_gilrs/src/rumble.rs | 4 +- crates/bevy_gizmos/macros/src/lib.rs | 2 +- crates/bevy_gizmos/src/aabb.rs | 6 +- crates/bevy_gizmos/src/arrows.rs | 2 +- crates/bevy_gizmos/src/circles.rs | 2 +- crates/bevy_gizmos/src/config.rs | 12 +- crates/bevy_gizmos/src/curves.rs | 2 +- crates/bevy_gizmos/src/gizmos.rs | 2 +- crates/bevy_gizmos/src/grid.rs | 8 +- crates/bevy_gizmos/src/lib.rs | 34 +-- crates/bevy_gizmos/src/light.rs | 11 +- crates/bevy_gizmos/src/pipeline_2d.rs | 16 +- crates/bevy_gizmos/src/pipeline_3d.rs | 16 +- crates/bevy_gizmos/src/primitives/dim2.rs | 11 +- crates/bevy_gizmos/src/primitives/dim3.rs | 2 +- crates/bevy_gizmos/src/primitives/helpers.rs | 2 +- crates/bevy_gizmos/src/retained.rs | 16 +- crates/bevy_gltf/src/lib.rs | 4 +- crates/bevy_gltf/src/loader.rs | 62 ++--- crates/bevy_image/src/basis.rs | 2 +- crates/bevy_image/src/dds.rs | 2 +- .../src/dynamic_texture_atlas_builder.rs | 6 +- crates/bevy_image/src/exr_texture_loader.rs | 2 +- crates/bevy_image/src/hdr_texture_loader.rs | 2 +- crates/bevy_image/src/image.rs | 6 +- crates/bevy_image/src/image_loader.rs | 2 +- crates/bevy_image/src/ktx2.rs | 8 +- crates/bevy_image/src/lib.rs | 2 +- crates/bevy_image/src/texture_atlas.rs | 2 +- .../bevy_image/src/texture_atlas_builder.rs | 4 +- crates/bevy_input/src/axis.rs | 2 +- crates/bevy_input/src/button_input.rs | 2 +- crates/bevy_input/src/gamepad.rs | 234 ++++++++---------- crates/bevy_input/src/lib.rs | 16 +- crates/bevy_input/src/mouse.rs | 2 +- crates/bevy_input/src/touch.rs | 20 +- crates/bevy_input_focus/src/autofocus.rs | 2 +- .../src/directional_navigation.rs | 2 +- crates/bevy_input_focus/src/lib.rs | 4 +- crates/bevy_input_focus/src/tab_navigation.rs | 8 +- crates/bevy_internal/src/default_plugins.rs | 2 +- crates/bevy_internal/src/prelude.rs | 8 +- crates/bevy_log/src/android_tracing.rs | 4 +- crates/bevy_log/src/lib.rs | 16 +- crates/bevy_macro_utils/src/attrs.rs | 4 +- crates/bevy_macro_utils/src/fq_std.rs | 2 +- crates/bevy_macro_utils/src/label.rs | 2 +- crates/bevy_macro_utils/src/shape.rs | 2 +- .../bevy_math/src/bounding/bounded2d/mod.rs | 9 +- .../src/bounding/bounded2d/primitive_impls.rs | 4 +- .../src/bounding/bounded3d/extrusion.rs | 4 +- .../bevy_math/src/bounding/bounded3d/mod.rs | 8 +- .../src/bounding/bounded3d/primitive_impls.rs | 6 +- crates/bevy_math/src/bounding/raycast2d.rs | 8 +- crates/bevy_math/src/bounding/raycast3d.rs | 8 +- crates/bevy_math/src/common_traits.rs | 2 +- .../src/cubic_splines/curve_impls.rs | 2 +- crates/bevy_math/src/cubic_splines/mod.rs | 42 ++-- crates/bevy_math/src/curve/adaptors.rs | 6 +- crates/bevy_math/src/curve/cores.rs | 6 +- .../src/curve/derivatives/adaptor_impls.rs | 4 +- crates/bevy_math/src/curve/easing.rs | 4 +- crates/bevy_math/src/curve/interval.rs | 16 +- crates/bevy_math/src/curve/mod.rs | 6 +- crates/bevy_math/src/curve/sample_curves.rs | 4 +- crates/bevy_math/src/direction.rs | 2 +- crates/bevy_math/src/isometry.rs | 2 +- crates/bevy_math/src/lib.rs | 10 +- crates/bevy_math/src/ops.rs | 6 +- crates/bevy_math/src/primitives/dim2.rs | 4 +- crates/bevy_math/src/primitives/dim3.rs | 4 +- crates/bevy_math/src/primitives/polygon.rs | 2 +- crates/bevy_math/src/primitives/serde.rs | 2 +- crates/bevy_math/src/ray.rs | 73 +++--- crates/bevy_math/src/rects/irect.rs | 2 +- crates/bevy_math/src/rects/rect.rs | 2 +- crates/bevy_math/src/rects/urect.rs | 12 +- crates/bevy_math/src/rotation2d.rs | 46 ++-- .../bevy_math/src/sampling/mesh_sampling.rs | 2 +- .../bevy_math/src/sampling/shape_sampling.rs | 4 +- crates/bevy_math/src/sampling/standard.rs | 4 +- crates/bevy_mesh/src/conversions.rs | 6 +- crates/bevy_mesh/src/mesh.rs | 18 +- crates/bevy_mesh/src/primitives/dim2.rs | 7 +- .../bevy_mesh/src/primitives/dim3/capsule.rs | 2 +- crates/bevy_mesh/src/primitives/dim3/cone.rs | 4 +- .../src/primitives/dim3/conical_frustum.rs | 2 +- .../bevy_mesh/src/primitives/dim3/cuboid.rs | 2 +- crates/bevy_mesh/src/primitives/dim3/plane.rs | 2 +- .../bevy_mesh/src/primitives/dim3/sphere.rs | 4 +- crates/bevy_mesh/src/primitives/dim3/torus.rs | 2 +- .../src/primitives/dim3/triangle3d.rs | 2 +- crates/bevy_mesh/src/primitives/extrusion.rs | 6 +- crates/bevy_mikktspace/src/generated.rs | 14 +- .../bevy_mikktspace/tests/regression_test.rs | 2 +- crates/bevy_pbr/src/atmosphere/mod.rs | 34 ++- crates/bevy_pbr/src/atmosphere/node.rs | 2 +- crates/bevy_pbr/src/atmosphere/resources.rs | 2 +- crates/bevy_pbr/src/cluster/assign.rs | 10 +- crates/bevy_pbr/src/cluster/mod.rs | 10 +- crates/bevy_pbr/src/components.rs | 4 +- crates/bevy_pbr/src/decal/clustered.rs | 14 +- crates/bevy_pbr/src/decal/forward.rs | 8 +- crates/bevy_pbr/src/deferred/mod.rs | 20 +- crates/bevy_pbr/src/extended_material.rs | 2 +- crates/bevy_pbr/src/fog.rs | 4 +- crates/bevy_pbr/src/lib.rs | 8 +- crates/bevy_pbr/src/light/mod.rs | 2 +- .../src/light_probe/environment_map.rs | 10 +- .../src/light_probe/irradiance_volume.rs | 12 +- crates/bevy_pbr/src/light_probe/mod.rs | 10 +- crates/bevy_pbr/src/lightmap/mod.rs | 10 +- crates/bevy_pbr/src/material.rs | 21 +- crates/bevy_pbr/src/material_bind_groups.rs | 2 +- crates/bevy_pbr/src/mesh_material.rs | 2 +- crates/bevy_pbr/src/meshlet/asset.rs | 2 +- crates/bevy_pbr/src/meshlet/from_mesh.rs | 14 +- .../bevy_pbr/src/meshlet/instance_manager.rs | 6 +- .../src/meshlet/material_pipeline_prepare.rs | 4 +- .../src/meshlet/material_shade_nodes.rs | 2 +- .../src/meshlet/meshlet_mesh_manager.rs | 12 +- crates/bevy_pbr/src/meshlet/mod.rs | 26 +- .../bevy_pbr/src/meshlet/persistent_buffer.rs | 2 +- crates/bevy_pbr/src/meshlet/pipelines.rs | 2 +- .../bevy_pbr/src/meshlet/resource_manager.rs | 2 +- .../meshlet/visibility_buffer_raster_node.rs | 2 +- crates/bevy_pbr/src/pbr_material.rs | 2 +- crates/bevy_pbr/src/prepass/mod.rs | 26 +- .../bevy_pbr/src/prepass/prepass_bindings.rs | 4 +- crates/bevy_pbr/src/render/fog.rs | 4 +- crates/bevy_pbr/src/render/gpu_preprocess.rs | 12 +- crates/bevy_pbr/src/render/light.rs | 18 +- crates/bevy_pbr/src/render/mesh.rs | 25 +- crates/bevy_pbr/src/render/mesh_bindings.rs | 8 +- .../bevy_pbr/src/render/mesh_view_bindings.rs | 25 +- crates/bevy_pbr/src/render/mod.rs | 2 +- crates/bevy_pbr/src/render/morph.rs | 4 +- crates/bevy_pbr/src/render/skin.rs | 4 +- crates/bevy_pbr/src/ssao/mod.rs | 16 +- crates/bevy_pbr/src/ssr/mod.rs | 20 +- crates/bevy_pbr/src/volumetric_fog/mod.rs | 14 +- crates/bevy_pbr/src/volumetric_fog/render.rs | 16 +- crates/bevy_pbr/src/wireframe.rs | 4 +- crates/bevy_picking/src/backend.rs | 6 +- crates/bevy_picking/src/events.rs | 2 +- crates/bevy_picking/src/hover.rs | 2 +- crates/bevy_picking/src/input.rs | 2 +- crates/bevy_picking/src/lib.rs | 8 +- crates/bevy_picking/src/mesh_picking/mod.rs | 4 +- .../mesh_picking/ray_cast/intersections.rs | 8 +- .../src/mesh_picking/ray_cast/mod.rs | 8 +- .../bevy_platform_support/src/sync/atomic.rs | 4 +- crates/bevy_platform_support/src/time.rs | 4 +- .../derive/src/container_attributes.rs | 13 +- .../derive/src/custom_attributes.rs | 2 +- crates/bevy_reflect/derive/src/derive_data.rs | 24 +- .../bevy_reflect/derive/src/documentation.rs | 2 +- .../derive/src/field_attributes.rs | 6 +- .../bevy_reflect/derive/src/from_reflect.rs | 4 +- .../bevy_reflect/derive/src/impls/opaque.rs | 2 +- .../bevy_reflect/derive/src/impls/structs.rs | 4 +- .../derive/src/impls/tuple_structs.rs | 4 +- crates/bevy_reflect/derive/src/impls/typed.rs | 2 +- crates/bevy_reflect/derive/src/lib.rs | 2 +- .../bevy_reflect/derive/src/reflect_opaque.rs | 2 +- crates/bevy_reflect/derive/src/remote.rs | 6 +- .../bevy_reflect/derive/src/serialization.rs | 2 +- crates/bevy_reflect/derive/src/string_expr.rs | 4 +- .../bevy_reflect/derive/src/struct_utility.rs | 2 +- .../derive/src/trait_reflection.rs | 2 +- crates/bevy_reflect/derive/src/type_path.rs | 3 +- .../derive/src/where_clause_options.rs | 4 +- crates/bevy_reflect/examples/reflect_docs.rs | 5 +- crates/bevy_reflect/src/array.rs | 6 +- crates/bevy_reflect/src/attributes.rs | 10 +- crates/bevy_reflect/src/enums/dynamic_enum.rs | 6 +- crates/bevy_reflect/src/enums/enum_trait.rs | 4 +- crates/bevy_reflect/src/enums/helpers.rs | 2 +- crates/bevy_reflect/src/enums/mod.rs | 194 ++++++--------- crates/bevy_reflect/src/enums/variants.rs | 2 +- crates/bevy_reflect/src/fields.rs | 4 +- crates/bevy_reflect/src/func/args/arg.rs | 2 +- crates/bevy_reflect/src/func/args/info.rs | 2 +- crates/bevy_reflect/src/func/args/list.rs | 4 +- .../bevy_reflect/src/func/dynamic_function.rs | 15 +- .../src/func/dynamic_function_internal.rs | 2 +- .../src/func/dynamic_function_mut.rs | 2 +- crates/bevy_reflect/src/func/error.rs | 6 +- crates/bevy_reflect/src/func/function.rs | 4 +- crates/bevy_reflect/src/func/info.rs | 4 +- crates/bevy_reflect/src/func/mod.rs | 2 +- crates/bevy_reflect/src/func/reflect_fn.rs | 4 +- .../bevy_reflect/src/func/reflect_fn_mut.rs | 4 +- crates/bevy_reflect/src/func/signature.rs | 2 +- crates/bevy_reflect/src/impls/glam.rs | 6 +- crates/bevy_reflect/src/impls/petgraph.rs | 2 +- crates/bevy_reflect/src/impls/smallvec.rs | 8 +- crates/bevy_reflect/src/impls/smol_str.rs | 2 +- crates/bevy_reflect/src/impls/std.rs | 40 ++- crates/bevy_reflect/src/impls/uuid.rs | 2 +- crates/bevy_reflect/src/impls/wgpu_types.rs | 2 +- crates/bevy_reflect/src/lib.rs | 41 ++- crates/bevy_reflect/src/list.rs | 6 +- crates/bevy_reflect/src/map.rs | 6 +- crates/bevy_reflect/src/path/error.rs | 46 ++-- crates/bevy_reflect/src/reflect.rs | 6 +- crates/bevy_reflect/src/serde/de/arrays.rs | 2 +- .../bevy_reflect/src/serde/de/deserializer.rs | 4 +- crates/bevy_reflect/src/serde/de/enums.rs | 8 +- crates/bevy_reflect/src/serde/de/helpers.rs | 2 +- crates/bevy_reflect/src/serde/de/lists.rs | 2 +- crates/bevy_reflect/src/serde/de/maps.rs | 2 +- crates/bevy_reflect/src/serde/de/mod.rs | 24 +- crates/bevy_reflect/src/serde/de/options.rs | 4 +- .../src/serde/de/registration_utils.rs | 2 +- .../src/serde/de/registrations.rs | 2 +- crates/bevy_reflect/src/serde/de/sets.rs | 2 +- .../bevy_reflect/src/serde/de/struct_utils.rs | 4 +- crates/bevy_reflect/src/serde/de/structs.rs | 2 +- .../src/serde/de/tuple_structs.rs | 4 +- .../bevy_reflect/src/serde/de/tuple_utils.rs | 6 +- crates/bevy_reflect/src/serde/de/tuples.rs | 2 +- crates/bevy_reflect/src/serde/mod.rs | 12 +- crates/bevy_reflect/src/serde/ser/arrays.rs | 4 +- .../src/serde/ser/custom_serialization.rs | 15 +- crates/bevy_reflect/src/serde/ser/enums.rs | 4 +- crates/bevy_reflect/src/serde/ser/lists.rs | 4 +- crates/bevy_reflect/src/serde/ser/maps.rs | 4 +- crates/bevy_reflect/src/serde/ser/mod.rs | 2 +- .../bevy_reflect/src/serde/ser/serializer.rs | 4 +- crates/bevy_reflect/src/serde/ser/sets.rs | 4 +- crates/bevy_reflect/src/serde/ser/structs.rs | 4 +- .../src/serde/ser/tuple_structs.rs | 4 +- crates/bevy_reflect/src/serde/ser/tuples.rs | 4 +- crates/bevy_reflect/src/serde/type_data.rs | 2 +- crates/bevy_reflect/src/set.rs | 8 +- crates/bevy_reflect/src/struct_trait.rs | 4 +- crates/bevy_reflect/src/tuple.rs | 7 +- crates/bevy_reflect/src/tuple_struct.rs | 4 +- crates/bevy_reflect/src/type_registry.rs | 4 +- crates/bevy_remote/src/builtin_methods.rs | 12 +- crates/bevy_remote/src/http.rs | 7 +- crates/bevy_remote/src/lib.rs | 2 +- .../bevy_render/macros/src/as_bind_group.rs | 30 +-- .../macros/src/extract_component.rs | 2 +- .../macros/src/extract_resource.rs | 2 +- crates/bevy_render/macros/src/lib.rs | 4 +- crates/bevy_render/src/alpha.rs | 2 +- .../src/batching/gpu_preprocessing.rs | 8 +- .../src/batching/no_gpu_preprocessing.rs | 2 +- crates/bevy_render/src/camera/camera.rs | 13 +- crates/bevy_render/src/camera/mod.rs | 4 +- crates/bevy_render/src/camera/projection.rs | 6 +- crates/bevy_render/src/diagnostic/mod.rs | 2 +- .../src/experimental/occlusion_culling/mod.rs | 4 +- crates/bevy_render/src/extract_component.rs | 4 +- crates/bevy_render/src/extract_instances.rs | 2 +- crates/bevy_render/src/globals.rs | 4 +- .../src/gpu_component_array_buffer.rs | 2 +- crates/bevy_render/src/gpu_readback.rs | 6 +- crates/bevy_render/src/lib.rs | 12 +- crates/bevy_render/src/mesh/allocator.rs | 14 +- crates/bevy_render/src/mesh/components.rs | 2 +- crates/bevy_render/src/mesh/mod.rs | 6 +- crates/bevy_render/src/primitives/mod.rs | 2 +- crates/bevy_render/src/render_asset.rs | 2 +- .../bevy_render/src/render_graph/context.rs | 12 +- crates/bevy_render/src/render_graph/graph.rs | 4 +- crates/bevy_render/src/render_graph/mod.rs | 4 +- crates/bevy_render/src/render_graph/node.rs | 2 +- crates/bevy_render/src/render_phase/draw.rs | 4 +- .../src/render_phase/draw_state.rs | 42 +++- crates/bevy_render/src/render_phase/mod.rs | 13 +- .../render_resource/batched_uniform_buffer.rs | 2 +- .../src/render_resource/bind_group.rs | 4 +- .../bind_group_layout_entries.rs | 4 +- .../src/render_resource/buffer_vec.rs | 4 +- .../src/render_resource/gpu_array_buffer.rs | 4 +- crates/bevy_render/src/render_resource/mod.rs | 21 +- .../src/render_resource/pipeline_cache.rs | 20 +- .../render_resource/pipeline_specializer.rs | 2 +- .../bevy_render/src/render_resource/shader.rs | 2 +- .../src/render_resource/storage_buffer.rs | 6 +- .../src/render_resource/uniform_buffer.rs | 4 +- .../bevy_render/src/renderer/graph_runner.rs | 6 +- crates/bevy_render/src/renderer/mod.rs | 6 +- .../bevy_render/src/renderer/render_device.rs | 10 +- crates/bevy_render/src/storage.rs | 6 +- crates/bevy_render/src/sync_world.rs | 6 +- crates/bevy_render/src/texture/gpu_image.rs | 2 +- crates/bevy_render/src/texture/mod.rs | 4 +- .../bevy_render/src/texture/texture_cache.rs | 2 +- crates/bevy_render/src/view/mod.rs | 10 +- crates/bevy_render/src/view/visibility/mod.rs | 4 +- .../bevy_render/src/view/visibility/range.rs | 8 +- .../src/view/visibility/render_layers.rs | 2 +- crates/bevy_render/src/view/window/mod.rs | 2 +- .../bevy_render/src/view/window/screenshot.rs | 16 +- crates/bevy_scene/src/components.rs | 4 +- crates/bevy_scene/src/dynamic_scene.rs | 8 +- .../bevy_scene/src/dynamic_scene_builder.rs | 20 +- crates/bevy_scene/src/scene.rs | 2 +- crates/bevy_scene/src/scene_filter.rs | 2 +- crates/bevy_scene/src/scene_loader.rs | 4 +- crates/bevy_scene/src/scene_spawner.rs | 14 +- crates/bevy_scene/src/serde.rs | 23 +- crates/bevy_sprite/src/lib.rs | 30 ++- .../bevy_sprite/src/mesh2d/color_material.rs | 2 +- crates/bevy_sprite/src/mesh2d/material.rs | 8 +- crates/bevy_sprite/src/mesh2d/mesh.rs | 28 +-- crates/bevy_sprite/src/mesh2d/wireframe2d.rs | 4 +- crates/bevy_sprite/src/picking_backend.rs | 2 +- crates/bevy_sprite/src/render/mod.rs | 12 +- crates/bevy_sprite/src/sprite.rs | 4 +- crates/bevy_sprite/src/texture_slice/mod.rs | 7 +- .../bevy_sprite/src/texture_slice/slicer.rs | 2 +- crates/bevy_state/macros/src/states.rs | 2 +- crates/bevy_state/src/app.rs | 10 +- crates/bevy_state/src/lib.rs | 6 +- .../src/state/freely_mutable_state.rs | 2 +- crates/bevy_state/src/state/mod.rs | 8 +- crates/bevy_state/src/state/state_set.rs | 8 +- crates/bevy_tasks/src/task_pool.rs | 3 +- crates/bevy_text/src/bounds.rs | 2 +- crates/bevy_text/src/font_atlas.rs | 2 +- crates/bevy_text/src/font_atlas_set.rs | 2 +- crates/bevy_text/src/font_loader.rs | 2 +- crates/bevy_text/src/lib.rs | 10 +- crates/bevy_text/src/pipeline.rs | 6 +- crates/bevy_text/src/text.rs | 27 +- crates/bevy_text/src/text2d.rs | 21 +- crates/bevy_time/src/lib.rs | 12 +- crates/bevy_time/src/stopwatch.rs | 2 +- crates/bevy_time/src/time.rs | 2 +- .../src/components/global_transform.rs | 4 +- crates/bevy_transform/src/helper.rs | 8 +- crates/bevy_transform/src/systems.rs | 39 +-- crates/bevy_ui/src/accessibility.rs | 2 +- .../src/experimental/ghost_hierarchy.rs | 2 +- crates/bevy_ui/src/focus.rs | 4 +- crates/bevy_ui/src/geometry.rs | 2 +- crates/bevy_ui/src/layout/mod.rs | 47 ++-- crates/bevy_ui/src/layout/ui_surface.rs | 12 +- crates/bevy_ui/src/lib.rs | 10 +- crates/bevy_ui/src/measurement.rs | 2 +- crates/bevy_ui/src/picking_backend.rs | 2 +- crates/bevy_ui/src/render/box_shadow.rs | 8 +- crates/bevy_ui/src/render/debug_overlay.rs | 4 +- crates/bevy_ui/src/render/mod.rs | 8 +- crates/bevy_ui/src/render/render_pass.rs | 2 +- .../src/render/ui_material_pipeline.rs | 2 +- .../src/render/ui_texture_slice_pipeline.rs | 2 +- crates/bevy_ui/src/stack.rs | 2 +- crates/bevy_ui/src/ui_material.rs | 4 +- crates/bevy_ui/src/ui_node.rs | 2 +- crates/bevy_ui/src/update.rs | 4 +- crates/bevy_ui/src/widget/button.rs | 4 +- crates/bevy_ui/src/widget/image.rs | 2 +- crates/bevy_ui/src/widget/label.rs | 2 +- crates/bevy_ui/src/widget/text.rs | 10 +- crates/bevy_window/src/system_cursor.rs | 2 +- crates/bevy_window/src/window.rs | 2 +- crates/bevy_winit/src/converters.rs | 2 +- crates/bevy_winit/src/cursor.rs | 20 +- crates/bevy_winit/src/custom_cursor.rs | 4 +- crates/bevy_winit/src/lib.rs | 4 +- crates/bevy_winit/src/state.rs | 8 +- crates/bevy_winit/src/system.rs | 6 +- crates/bevy_winit/src/winit_windows.rs | 6 +- examples/2d/cpu_draw.rs | 12 +- examples/2d/mesh2d_arcs.rs | 2 +- examples/2d/mesh2d_manual.rs | 12 +- examples/2d/wireframe_2d.rs | 2 +- examples/3d/atmosphere.rs | 2 +- examples/3d/auto_exposure.rs | 2 +- examples/3d/clearcoat.rs | 2 +- examples/3d/clustered_decals.rs | 6 +- examples/3d/edit_material_on_gltf.rs | 4 +- examples/3d/fog.rs | 6 +- examples/3d/irradiance_volumes.rs | 2 +- examples/3d/meshlet.rs | 9 +- examples/3d/occlusion_culling.rs | 4 +- examples/3d/pcss.rs | 2 +- examples/3d/rotate_environment_map.rs | 2 +- examples/3d/ssr.rs | 2 +- examples/3d/visibility_range.rs | 2 +- examples/3d/volumetric_fog.rs | 2 +- examples/3d/wireframe.rs | 2 +- examples/animation/animated_transform.rs | 2 +- examples/animation/animated_ui.rs | 4 +- examples/animation/custom_skinned_mesh.rs | 2 +- examples/animation/eased_motion.rs | 2 +- examples/app/headless.rs | 4 +- examples/app/headless_renderer.rs | 4 +- examples/app/log_layers.rs | 2 +- examples/app/log_layers_ecs.rs | 2 +- examples/app/no_renderer.rs | 2 +- examples/asset/asset_decompression.rs | 2 +- examples/asset/asset_loading.rs | 19 +- examples/asset/custom_asset.rs | 2 +- examples/asset/embedded_asset.rs | 2 +- examples/asset/extra_source.rs | 2 +- examples/asset/multi_asset_sync.rs | 2 +- examples/asset/processing/asset_processing.rs | 3 +- examples/async_tasks/async_compute.rs | 2 +- .../external_source_external_thread.rs | 2 +- examples/ecs/fallible_systems.rs | 2 +- examples/ecs/iter_combinations.rs | 8 +- examples/ecs/observer_propagation.rs | 2 +- examples/ecs/run_conditions.rs | 4 +- examples/ecs/system_piping.rs | 2 +- examples/games/alien_cake_addict.rs | 39 ++- examples/games/game_menu.rs | 6 +- examples/math/bounding_2d.rs | 2 +- examples/math/cubic_splines.rs | 2 +- examples/math/custom_primitives.rs | 2 +- examples/math/random_sampling.rs | 2 +- examples/math/sampling_primitives.rs | 2 +- examples/movement/smooth_follow.rs | 2 +- examples/reflection/dynamic_types.rs | 32 +-- examples/reflection/function_reflection.rs | 2 +- examples/reflection/reflection.rs | 2 +- examples/remote/client.rs | 4 +- examples/remote/server.rs | 2 +- .../shader/compute_shader_game_of_life.rs | 2 +- examples/shader/custom_phase_item.rs | 6 +- examples/shader/custom_post_processing.rs | 2 +- examples/shader/custom_render_phase.rs | 18 +- examples/shader/custom_shader_instancing.rs | 6 +- examples/shader/gpu_readback.rs | 2 +- examples/shader/specialized_mesh_pipeline.rs | 6 +- examples/shader/texture_binding_array.rs | 4 +- examples/stress_tests/bevymark.rs | 2 +- examples/stress_tests/many_components.rs | 2 +- examples/stress_tests/many_cubes.rs | 2 +- examples/stress_tests/many_lights.rs | 4 +- examples/stress_tests/many_text2d.rs | 2 +- .../tools/scene_viewer/scene_viewer_plugin.rs | 4 +- examples/ui/directional_navigation.rs | 2 +- examples/ui/tab_navigation.rs | 2 +- examples/window/custom_user_event.rs | 2 +- examples/window/screenshot.rs | 2 +- tools/build-easefunction-graphs/src/main.rs | 2 +- tools/build-wasm-example/src/main.rs | 2 +- tools/ci/src/commands/compile.rs | 2 +- tools/ci/src/commands/doc.rs | 2 +- tools/ci/src/commands/integration_test.rs | 2 +- tools/ci/src/commands/lints.rs | 2 +- tools/compile_fail_utils/src/lib.rs | 2 +- tools/example-showcase/src/main.rs | 6 +- 654 files changed, 2297 insertions(+), 2776 deletions(-) diff --git a/benches/benches/bevy_ecs/change_detection.rs b/benches/benches/bevy_ecs/change_detection.rs index 88214c81f31ff..92f3251abc2b4 100644 --- a/benches/benches/bevy_ecs/change_detection.rs +++ b/benches/benches/bevy_ecs/change_detection.rs @@ -7,8 +7,8 @@ use bevy_ecs::{ query::QueryFilter, world::World, }; -use criterion::{Criterion, criterion_group}; -use rand::{SeedableRng, prelude::SliceRandom}; +use criterion::{criterion_group, Criterion}; +use rand::{prelude::SliceRandom, SeedableRng}; use rand_chacha::ChaCha8Rng; criterion_group!( diff --git a/benches/benches/bevy_ecs/components/mod.rs b/benches/benches/bevy_ecs/components/mod.rs index 165c66bf3a009..aec44ed27c9d0 100644 --- a/benches/benches/bevy_ecs/components/mod.rs +++ b/benches/benches/bevy_ecs/components/mod.rs @@ -9,7 +9,7 @@ mod insert_simple; mod insert_simple_unbatched; use archetype_updates::*; -use criterion::{Criterion, criterion_group}; +use criterion::{criterion_group, Criterion}; criterion_group!( benches, diff --git a/benches/benches/bevy_ecs/empty_archetypes.rs b/benches/benches/bevy_ecs/empty_archetypes.rs index e959a7ae56188..e5e7639066fe8 100644 --- a/benches/benches/bevy_ecs/empty_archetypes.rs +++ b/benches/benches/bevy_ecs/empty_archetypes.rs @@ -1,7 +1,7 @@ use core::hint::black_box; use bevy_ecs::{component::Component, prelude::*, schedule::ExecutorKind, world::World}; -use criterion::{BenchmarkId, Criterion, criterion_group}; +use criterion::{criterion_group, BenchmarkId, Criterion}; criterion_group!(benches, empty_archetypes); diff --git a/benches/benches/bevy_ecs/entity_cloning.rs b/benches/benches/bevy_ecs/entity_cloning.rs index d049330938e4f..7c474cc4f8aaf 100644 --- a/benches/benches/bevy_ecs/entity_cloning.rs +++ b/benches/benches/bevy_ecs/entity_cloning.rs @@ -9,7 +9,7 @@ use bevy_ecs::reflect::AppTypeRegistry; use bevy_ecs::{component::Component, world::World}; use bevy_math::Mat4; use bevy_reflect::{GetTypeRegistration, Reflect}; -use criterion::{Bencher, Criterion, Throughput, criterion_group}; +use criterion::{criterion_group, Bencher, Criterion, Throughput}; criterion_group!( benches, diff --git a/benches/benches/bevy_ecs/events/mod.rs b/benches/benches/bevy_ecs/events/mod.rs index 0785de1a03206..4367c45c3e28d 100644 --- a/benches/benches/bevy_ecs/events/mod.rs +++ b/benches/benches/bevy_ecs/events/mod.rs @@ -1,7 +1,7 @@ mod iter; mod send; -use criterion::{Criterion, criterion_group}; +use criterion::{criterion_group, Criterion}; criterion_group!(benches, send, iter); diff --git a/benches/benches/bevy_ecs/iteration/iter_frag_foreach_wide.rs b/benches/benches/bevy_ecs/iteration/iter_frag_foreach_wide.rs index dc336aba4d54d..0ea09053b8251 100644 --- a/benches/benches/bevy_ecs/iteration/iter_frag_foreach_wide.rs +++ b/benches/benches/bevy_ecs/iteration/iter_frag_foreach_wide.rs @@ -58,17 +58,17 @@ impl<'w> Benchmark<'w> { #[inline(never)] pub fn run(&mut self) { self.1.iter_mut(&mut self.0).for_each(|mut data| { - data.0.0 *= 2.0; - data.1.0 *= 2.0; - data.2.0 *= 2.0; - data.3.0 *= 2.0; - data.4.0 *= 2.0; - data.5.0 *= 2.0; - data.6.0 *= 2.0; - data.7.0 *= 2.0; - data.8.0 *= 2.0; - data.9.0 *= 2.0; - data.10.0 *= 2.0; + data.0 .0 *= 2.0; + data.1 .0 *= 2.0; + data.2 .0 *= 2.0; + data.3 .0 *= 2.0; + data.4 .0 *= 2.0; + data.5 .0 *= 2.0; + data.6 .0 *= 2.0; + data.7 .0 *= 2.0; + data.8 .0 *= 2.0; + data.9 .0 *= 2.0; + data.10 .0 *= 2.0; }); } } diff --git a/benches/benches/bevy_ecs/iteration/iter_frag_foreach_wide_sparse.rs b/benches/benches/bevy_ecs/iteration/iter_frag_foreach_wide_sparse.rs index 77e85f7495267..6949d1b90d23b 100644 --- a/benches/benches/bevy_ecs/iteration/iter_frag_foreach_wide_sparse.rs +++ b/benches/benches/bevy_ecs/iteration/iter_frag_foreach_wide_sparse.rs @@ -68,17 +68,17 @@ impl<'w> Benchmark<'w> { #[inline(never)] pub fn run(&mut self) { self.1.iter_mut(&mut self.0).for_each(|mut data| { - data.0.0 *= 2.0; - data.1.0 *= 2.0; - data.2.0 *= 2.0; - data.3.0 *= 2.0; - data.4.0 *= 2.0; - data.5.0 *= 2.0; - data.6.0 *= 2.0; - data.7.0 *= 2.0; - data.8.0 *= 2.0; - data.9.0 *= 2.0; - data.10.0 *= 2.0; + data.0 .0 *= 2.0; + data.1 .0 *= 2.0; + data.2 .0 *= 2.0; + data.3 .0 *= 2.0; + data.4 .0 *= 2.0; + data.5 .0 *= 2.0; + data.6 .0 *= 2.0; + data.7 .0 *= 2.0; + data.8 .0 *= 2.0; + data.9 .0 *= 2.0; + data.10 .0 *= 2.0; }); } } diff --git a/benches/benches/bevy_ecs/iteration/iter_frag_wide.rs b/benches/benches/bevy_ecs/iteration/iter_frag_wide.rs index b76e95938ceba..84442c78e547c 100644 --- a/benches/benches/bevy_ecs/iteration/iter_frag_wide.rs +++ b/benches/benches/bevy_ecs/iteration/iter_frag_wide.rs @@ -58,17 +58,17 @@ impl<'w> Benchmark<'w> { #[inline(never)] pub fn run(&mut self) { for mut data in self.1.iter_mut(&mut self.0) { - data.0.0 *= 2.0; - data.1.0 *= 2.0; - data.2.0 *= 2.0; - data.3.0 *= 2.0; - data.4.0 *= 2.0; - data.5.0 *= 2.0; - data.6.0 *= 2.0; - data.7.0 *= 2.0; - data.8.0 *= 2.0; - data.9.0 *= 2.0; - data.10.0 *= 2.0; + data.0 .0 *= 2.0; + data.1 .0 *= 2.0; + data.2 .0 *= 2.0; + data.3 .0 *= 2.0; + data.4 .0 *= 2.0; + data.5 .0 *= 2.0; + data.6 .0 *= 2.0; + data.7 .0 *= 2.0; + data.8 .0 *= 2.0; + data.9 .0 *= 2.0; + data.10 .0 *= 2.0; } } } diff --git a/benches/benches/bevy_ecs/iteration/iter_frag_wide_sparse.rs b/benches/benches/bevy_ecs/iteration/iter_frag_wide_sparse.rs index 08fd075e898b0..928ffea0731be 100644 --- a/benches/benches/bevy_ecs/iteration/iter_frag_wide_sparse.rs +++ b/benches/benches/bevy_ecs/iteration/iter_frag_wide_sparse.rs @@ -68,17 +68,17 @@ impl<'w> Benchmark<'w> { #[inline(never)] pub fn run(&mut self) { for mut data in self.1.iter_mut(&mut self.0) { - data.0.0 *= 2.0; - data.1.0 *= 2.0; - data.2.0 *= 2.0; - data.3.0 *= 2.0; - data.4.0 *= 2.0; - data.5.0 *= 2.0; - data.6.0 *= 2.0; - data.7.0 *= 2.0; - data.8.0 *= 2.0; - data.9.0 *= 2.0; - data.10.0 *= 2.0; + data.0 .0 *= 2.0; + data.1 .0 *= 2.0; + data.2 .0 *= 2.0; + data.3 .0 *= 2.0; + data.4 .0 *= 2.0; + data.5 .0 *= 2.0; + data.6 .0 *= 2.0; + data.7 .0 *= 2.0; + data.8 .0 *= 2.0; + data.9 .0 *= 2.0; + data.10 .0 *= 2.0; } } } diff --git a/benches/benches/bevy_ecs/iteration/iter_simple_foreach_hybrid.rs b/benches/benches/bevy_ecs/iteration/iter_simple_foreach_hybrid.rs index ce1a93a21438f..e6ee627e1849f 100644 --- a/benches/benches/bevy_ecs/iteration/iter_simple_foreach_hybrid.rs +++ b/benches/benches/bevy_ecs/iteration/iter_simple_foreach_hybrid.rs @@ -1,5 +1,5 @@ use bevy_ecs::prelude::*; -use rand::{SeedableRng, prelude::SliceRandom}; +use rand::{prelude::SliceRandom, SeedableRng}; use rand_chacha::ChaCha8Rng; #[derive(Component, Copy, Clone)] diff --git a/benches/benches/bevy_ecs/iteration/iter_simple_foreach_wide.rs b/benches/benches/bevy_ecs/iteration/iter_simple_foreach_wide.rs index f89991e1febcc..7dbd11d1e0499 100644 --- a/benches/benches/bevy_ecs/iteration/iter_simple_foreach_wide.rs +++ b/benches/benches/bevy_ecs/iteration/iter_simple_foreach_wide.rs @@ -58,10 +58,10 @@ impl<'w> Benchmark<'w> { #[inline(never)] pub fn run(&mut self) { self.1.iter_mut(&mut self.0).for_each(|mut item| { - item.1.0 += item.0.0; - item.3.0 += item.2.0; - item.5.0 += item.4.0; - item.7.0 += item.6.0; + item.1 .0 += item.0 .0; + item.3 .0 += item.2 .0; + item.5 .0 += item.4 .0; + item.7 .0 += item.6 .0; }); } } diff --git a/benches/benches/bevy_ecs/iteration/iter_simple_foreach_wide_sparse_set.rs b/benches/benches/bevy_ecs/iteration/iter_simple_foreach_wide_sparse_set.rs index c04ea68d7d299..f520ffde42662 100644 --- a/benches/benches/bevy_ecs/iteration/iter_simple_foreach_wide_sparse_set.rs +++ b/benches/benches/bevy_ecs/iteration/iter_simple_foreach_wide_sparse_set.rs @@ -60,10 +60,10 @@ impl<'w> Benchmark<'w> { #[inline(never)] pub fn run(&mut self) { self.1.iter_mut(&mut self.0).for_each(|mut item| { - item.1.0 += item.0.0; - item.3.0 += item.2.0; - item.5.0 += item.4.0; - item.7.0 += item.6.0; + item.1 .0 += item.0 .0; + item.3 .0 += item.2 .0; + item.5 .0 += item.4 .0; + item.7 .0 += item.6 .0; }); } } diff --git a/benches/benches/bevy_ecs/iteration/iter_simple_wide.rs b/benches/benches/bevy_ecs/iteration/iter_simple_wide.rs index 2851447437ae5..7d013b3bf6003 100644 --- a/benches/benches/bevy_ecs/iteration/iter_simple_wide.rs +++ b/benches/benches/bevy_ecs/iteration/iter_simple_wide.rs @@ -58,10 +58,10 @@ impl<'w> Benchmark<'w> { #[inline(never)] pub fn run(&mut self) { for mut item in self.1.iter_mut(&mut self.0) { - item.1.0 += item.0.0; - item.3.0 += item.2.0; - item.5.0 += item.4.0; - item.7.0 += item.6.0; + item.1 .0 += item.0 .0; + item.3 .0 += item.2 .0; + item.5 .0 += item.4 .0; + item.7 .0 += item.6 .0; } } } diff --git a/benches/benches/bevy_ecs/iteration/iter_simple_wide_sparse_set.rs b/benches/benches/bevy_ecs/iteration/iter_simple_wide_sparse_set.rs index ecea4ee71e2ee..28a6dbd85dc28 100644 --- a/benches/benches/bevy_ecs/iteration/iter_simple_wide_sparse_set.rs +++ b/benches/benches/bevy_ecs/iteration/iter_simple_wide_sparse_set.rs @@ -60,10 +60,10 @@ impl<'w> Benchmark<'w> { #[inline(never)] pub fn run(&mut self) { for mut item in self.1.iter_mut(&mut self.0) { - item.1.0 += item.0.0; - item.3.0 += item.2.0; - item.5.0 += item.4.0; - item.7.0 += item.6.0; + item.1 .0 += item.0 .0; + item.3 .0 += item.2 .0; + item.5 .0 += item.4 .0; + item.7 .0 += item.6 .0; } } } diff --git a/benches/benches/bevy_ecs/iteration/mod.rs b/benches/benches/bevy_ecs/iteration/mod.rs index 129354be6c66a..0fa7aced2894a 100644 --- a/benches/benches/bevy_ecs/iteration/mod.rs +++ b/benches/benches/bevy_ecs/iteration/mod.rs @@ -20,7 +20,7 @@ mod iter_simple_wide_sparse_set; mod par_iter_simple; mod par_iter_simple_foreach_hybrid; -use criterion::{Criterion, criterion_group}; +use criterion::{criterion_group, Criterion}; use heavy_compute::*; criterion_group!( diff --git a/benches/benches/bevy_ecs/iteration/par_iter_simple_foreach_hybrid.rs b/benches/benches/bevy_ecs/iteration/par_iter_simple_foreach_hybrid.rs index 0c2c31bad9db2..9dbcba87852f7 100644 --- a/benches/benches/bevy_ecs/iteration/par_iter_simple_foreach_hybrid.rs +++ b/benches/benches/bevy_ecs/iteration/par_iter_simple_foreach_hybrid.rs @@ -1,6 +1,6 @@ use bevy_ecs::prelude::*; use bevy_tasks::{ComputeTaskPool, TaskPool}; -use rand::{SeedableRng, prelude::SliceRandom}; +use rand::{prelude::SliceRandom, SeedableRng}; use rand_chacha::ChaCha8Rng; #[derive(Component, Copy, Clone)] diff --git a/benches/benches/bevy_ecs/observers/propagation.rs b/benches/benches/bevy_ecs/observers/propagation.rs index ad10768abafdc..65c15f7308deb 100644 --- a/benches/benches/bevy_ecs/observers/propagation.rs +++ b/benches/benches/bevy_ecs/observers/propagation.rs @@ -3,7 +3,7 @@ use core::hint::black_box; use bevy_ecs::prelude::*; use criterion::Criterion; use rand::SeedableRng; -use rand::{Rng, seq::IteratorRandom}; +use rand::{seq::IteratorRandom, Rng}; use rand_chacha::ChaCha8Rng; const DENSITY: usize = 20; // percent of nodes with listeners diff --git a/benches/benches/bevy_ecs/observers/simple.rs b/benches/benches/bevy_ecs/observers/simple.rs index 6716758cc3d07..bf2dd236d60ea 100644 --- a/benches/benches/bevy_ecs/observers/simple.rs +++ b/benches/benches/bevy_ecs/observers/simple.rs @@ -3,7 +3,7 @@ use core::hint::black_box; use bevy_ecs::{entity::Entity, event::Event, observer::Trigger, world::World}; use criterion::Criterion; -use rand::{SeedableRng, prelude::SliceRandom}; +use rand::{prelude::SliceRandom, SeedableRng}; use rand_chacha::ChaCha8Rng; fn deterministic_rand() -> ChaCha8Rng { ChaCha8Rng::seed_from_u64(42) diff --git a/benches/benches/bevy_ecs/world/entity_hash.rs b/benches/benches/bevy_ecs/world/entity_hash.rs index f8329e986e843..008b2cbbaa358 100644 --- a/benches/benches/bevy_ecs/world/entity_hash.rs +++ b/benches/benches/bevy_ecs/world/entity_hash.rs @@ -1,4 +1,4 @@ -use bevy_ecs::entity::{Entity, hash_set::EntityHashSet}; +use bevy_ecs::entity::{hash_set::EntityHashSet, Entity}; use criterion::{BenchmarkId, Criterion, Throughput}; use rand::{Rng, SeedableRng}; use rand_chacha::ChaCha8Rng; diff --git a/benches/benches/bevy_ecs/world/world_get.rs b/benches/benches/bevy_ecs/world/world_get.rs index 9b9867bec5c26..283b984186150 100644 --- a/benches/benches/bevy_ecs/world/world_get.rs +++ b/benches/benches/bevy_ecs/world/world_get.rs @@ -8,7 +8,7 @@ use bevy_ecs::{ world::World, }; use criterion::Criterion; -use rand::{SeedableRng, prelude::SliceRandom}; +use rand::{prelude::SliceRandom, SeedableRng}; use rand_chacha::ChaCha8Rng; #[derive(Component, Default)] diff --git a/benches/benches/bevy_math/bezier.rs b/benches/benches/bevy_math/bezier.rs index 30176ab38da6f..27affcaa71317 100644 --- a/benches/benches/bevy_math/bezier.rs +++ b/benches/benches/bevy_math/bezier.rs @@ -1,8 +1,8 @@ use benches::bench; -use bevy_math::{VectorSpace, prelude::*}; +use bevy_math::{prelude::*, VectorSpace}; use core::hint::black_box; use criterion::{ - BatchSize, BenchmarkGroup, BenchmarkId, Criterion, criterion_group, measurement::Measurement, + criterion_group, measurement::Measurement, BatchSize, BenchmarkGroup, BenchmarkId, Criterion, }; criterion_group!(benches, segment_ease, curve_position, curve_iter_positions); diff --git a/benches/benches/bevy_picking/ray_mesh_intersection.rs b/benches/benches/bevy_picking/ray_mesh_intersection.rs index 27894c7c62f79..ee81f1ac7fd87 100644 --- a/benches/benches/bevy_picking/ray_mesh_intersection.rs +++ b/benches/benches/bevy_picking/ray_mesh_intersection.rs @@ -4,7 +4,7 @@ use std::time::Duration; use benches::bench; use bevy_math::{Dir3, Mat4, Ray3d, Vec3}; use bevy_picking::mesh_picking::ray_cast::{self, Backfaces}; -use criterion::{AxisScale, BenchmarkId, Criterion, PlotConfiguration, criterion_group}; +use criterion::{criterion_group, AxisScale, BenchmarkId, Criterion, PlotConfiguration}; criterion_group!(benches, bench); diff --git a/benches/benches/bevy_reflect/function.rs b/benches/benches/bevy_reflect/function.rs index 2592f737cb371..ff4c8dca2ffc0 100644 --- a/benches/benches/bevy_reflect/function.rs +++ b/benches/benches/bevy_reflect/function.rs @@ -2,7 +2,7 @@ use core::hint::black_box; use benches::bench; use bevy_reflect::func::{ArgList, IntoFunction, IntoFunctionMut, TypedFunction}; -use criterion::{BatchSize, BenchmarkId, Criterion, criterion_group}; +use criterion::{criterion_group, BatchSize, BenchmarkId, Criterion}; criterion_group!( benches, diff --git a/benches/benches/bevy_reflect/list.rs b/benches/benches/bevy_reflect/list.rs index 7173b3fb0fce1..872c2dd0cb898 100644 --- a/benches/benches/bevy_reflect/list.rs +++ b/benches/benches/bevy_reflect/list.rs @@ -3,8 +3,8 @@ use core::{hint::black_box, iter, time::Duration}; use benches::bench; use bevy_reflect::{DynamicList, List}; use criterion::{ - AxisScale, BatchSize, BenchmarkGroup, BenchmarkId, Criterion, PlotConfiguration, Throughput, - criterion_group, measurement::Measurement, + criterion_group, measurement::Measurement, AxisScale, BatchSize, BenchmarkGroup, BenchmarkId, + Criterion, PlotConfiguration, Throughput, }; criterion_group!( diff --git a/benches/benches/bevy_reflect/map.rs b/benches/benches/bevy_reflect/map.rs index 985ac6ecb2b43..4525ed8598926 100644 --- a/benches/benches/bevy_reflect/map.rs +++ b/benches/benches/bevy_reflect/map.rs @@ -4,8 +4,8 @@ use benches::bench; use bevy_platform_support::collections::HashMap; use bevy_reflect::{DynamicMap, Map}; use criterion::{ - AxisScale, BatchSize, BenchmarkGroup, BenchmarkId, Criterion, PlotConfiguration, Throughput, - criterion_group, measurement::Measurement, + criterion_group, measurement::Measurement, AxisScale, BatchSize, BenchmarkGroup, BenchmarkId, + Criterion, PlotConfiguration, Throughput, }; criterion_group!( diff --git a/benches/benches/bevy_reflect/path.rs b/benches/benches/bevy_reflect/path.rs index 60cddd30ec23b..c0d8bfe0da732 100644 --- a/benches/benches/bevy_reflect/path.rs +++ b/benches/benches/bevy_reflect/path.rs @@ -2,8 +2,8 @@ use core::{fmt::Write, hint::black_box, str, time::Duration}; use benches::bench; use bevy_reflect::ParsedPath; -use criterion::{BatchSize, BenchmarkId, Criterion, Throughput, criterion_group}; -use rand::{Rng, SeedableRng, distributions::Uniform}; +use criterion::{criterion_group, BatchSize, BenchmarkId, Criterion, Throughput}; +use rand::{distributions::Uniform, Rng, SeedableRng}; use rand_chacha::ChaCha8Rng; criterion_group!(benches, parse_reflect_path); diff --git a/benches/benches/bevy_reflect/struct.rs b/benches/benches/bevy_reflect/struct.rs index 051d92ce6b243..d8f25554c36ba 100644 --- a/benches/benches/bevy_reflect/struct.rs +++ b/benches/benches/bevy_reflect/struct.rs @@ -3,8 +3,8 @@ use core::{hint::black_box, time::Duration}; use benches::bench; use bevy_reflect::{DynamicStruct, GetField, PartialReflect, Reflect, Struct}; use criterion::{ - AxisScale, BatchSize, BenchmarkGroup, BenchmarkId, Criterion, PlotConfiguration, Throughput, - criterion_group, measurement::Measurement, + criterion_group, measurement::Measurement, AxisScale, BatchSize, BenchmarkGroup, BenchmarkId, + Criterion, PlotConfiguration, Throughput, }; criterion_group!( diff --git a/benches/benches/bevy_render/render_layers.rs b/benches/benches/bevy_render/render_layers.rs index 6fa21030da247..d460a7bc96c48 100644 --- a/benches/benches/bevy_render/render_layers.rs +++ b/benches/benches/bevy_render/render_layers.rs @@ -1,6 +1,6 @@ use core::hint::black_box; -use criterion::{Criterion, criterion_group}; +use criterion::{criterion_group, Criterion}; use bevy_render::view::RenderLayers; diff --git a/benches/benches/bevy_render/torus.rs b/benches/benches/bevy_render/torus.rs index a6a1857a232a8..dcadd09180f9d 100644 --- a/benches/benches/bevy_render/torus.rs +++ b/benches/benches/bevy_render/torus.rs @@ -1,6 +1,6 @@ use core::hint::black_box; -use criterion::{Criterion, criterion_group}; +use criterion::{criterion_group, Criterion}; use bevy_render::mesh::TorusMeshBuilder; diff --git a/benches/benches/bevy_tasks/iter.rs b/benches/benches/bevy_tasks/iter.rs index c76b62737f2e6..7fe00ecb794db 100644 --- a/benches/benches/bevy_tasks/iter.rs +++ b/benches/benches/bevy_tasks/iter.rs @@ -1,7 +1,7 @@ use core::hint::black_box; use bevy_tasks::{ParallelIterator, TaskPoolBuilder}; -use criterion::{BenchmarkId, Criterion, criterion_group}; +use criterion::{criterion_group, BenchmarkId, Criterion}; struct ParChunks<'a, T>(core::slice::Chunks<'a, T>); impl<'a, T> ParallelIterator> for ParChunks<'a, T> diff --git a/crates/bevy_a11y/src/lib.rs b/crates/bevy_a11y/src/lib.rs index 10769ab3196a7..ccc7edf536c3c 100644 --- a/crates/bevy_a11y/src/lib.rs +++ b/crates/bevy_a11y/src/lib.rs @@ -33,8 +33,8 @@ use bevy_ecs::{ #[cfg(feature = "bevy_reflect")] use { - bevy_ecs::reflect::ReflectResource, bevy_reflect::Reflect, - bevy_reflect::std_traits::ReflectDefault, + bevy_ecs::reflect::ReflectResource, bevy_reflect::std_traits::ReflectDefault, + bevy_reflect::Reflect, }; #[cfg(feature = "serialize")] diff --git a/crates/bevy_animation/src/animation_curves.rs b/crates/bevy_animation/src/animation_curves.rs index 0fd258325be2b..4c944cdf6dd7e 100644 --- a/crates/bevy_animation/src/animation_curves.rs +++ b/crates/bevy_animation/src/animation_curves.rs @@ -90,20 +90,20 @@ use core::{ }; use crate::{ - AnimationEntityMut, AnimationEvaluationError, graph::AnimationNodeIndex, prelude::{Animatable, BlendInput}, + AnimationEntityMut, AnimationEvaluationError, }; use bevy_ecs::component::{Component, Mutable}; use bevy_math::curve::{ - Curve, Interval, cores::{UnevenCore, UnevenCoreError}, iterable::IterableCurve, + Curve, Interval, }; use bevy_platform_support::hash::Hashed; use bevy_reflect::{FromReflect, Reflect, Reflectable, TypeInfo, Typed}; use bevy_render::mesh::morph::MorphWeights; -use downcast_rs::{Downcast, impl_downcast}; +use downcast_rs::{impl_downcast, Downcast}; /// A value on a component that Bevy can animate. /// diff --git a/crates/bevy_animation/src/gltf_curves.rs b/crates/bevy_animation/src/gltf_curves.rs index fcb4fc4d7d47a..d5b2cbb6b984e 100644 --- a/crates/bevy_animation/src/gltf_curves.rs +++ b/crates/bevy_animation/src/gltf_curves.rs @@ -1,9 +1,8 @@ //! Concrete curve structures used to load glTF curves into the animation system. use bevy_math::{ - Quat, Vec4, VectorSpace, curve::{cores::*, iterable::IterableCurve, *}, - vec4, + vec4, Quat, Vec4, VectorSpace, }; use bevy_reflect::Reflect; use either::Either; @@ -248,10 +247,10 @@ where | InterpolationDatum::RightTail(v) => Either::Left(v.iter().cloned()), InterpolationDatum::Between(u, v, s) => { - let interpolated = u - .iter() - .zip(v.iter()) - .map(move |(x, y)| if s >= 1.0 { y.clone() } else { x.clone() }); + let interpolated = + u.iter() + .zip(v.iter()) + .map(move |(x, y)| if s >= 1.0 { y.clone() } else { x.clone() }); Either::Right(interpolated) } } diff --git a/crates/bevy_animation/src/graph.rs b/crates/bevy_animation/src/graph.rs index 82a5180848d5e..1729841f02641 100644 --- a/crates/bevy_animation/src/graph.rs +++ b/crates/bevy_animation/src/graph.rs @@ -7,7 +7,7 @@ use core::{ use std::io::{self, Write}; use bevy_asset::{ - Asset, AssetEvent, AssetId, AssetLoader, AssetPath, Assets, Handle, LoadContext, io::Reader, + io::Reader, Asset, AssetEvent, AssetId, AssetLoader, AssetPath, Assets, Handle, LoadContext, }; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::{ @@ -18,11 +18,11 @@ use bevy_ecs::{ system::{Res, ResMut}, }; use bevy_platform_support::collections::HashMap; -use bevy_reflect::{Reflect, ReflectSerialize, prelude::ReflectDefault}; +use bevy_reflect::{prelude::ReflectDefault, Reflect, ReflectSerialize}; use derive_more::derive::From; use petgraph::{ - Direction, graph::{DiGraph, NodeIndex}, + Direction, }; use ron::de::SpannedError; use serde::{Deserialize, Serialize}; diff --git a/crates/bevy_animation/src/lib.rs b/crates/bevy_animation/src/lib.rs index 43757a7e2a00b..8663ea3f3f970 100644 --- a/crates/bevy_animation/src/lib.rs +++ b/crates/bevy_animation/src/lib.rs @@ -36,7 +36,7 @@ use bevy_asset::{Asset, AssetApp, AssetEvents, Assets}; use bevy_ecs::{prelude::*, world::EntityMutExcept}; use bevy_math::FloatOrd; use bevy_platform_support::{collections::HashMap, hash::NoOpHash}; -use bevy_reflect::{Reflect, TypePath, prelude::ReflectDefault}; +use bevy_reflect::{prelude::ReflectDefault, Reflect, TypePath}; use bevy_time::Time; use bevy_transform::TransformSystem; use bevy_utils::{PreHashMap, PreHashMapExt, TypeIdMap}; @@ -52,15 +52,15 @@ use uuid::Uuid; pub mod prelude { #[doc(hidden)] pub use crate::{ - AnimationClip, AnimationPlayer, AnimationPlugin, VariableCurve, animatable::*, - animation_curves::*, graph::*, transition::*, + animatable::*, animation_curves::*, graph::*, transition::*, AnimationClip, + AnimationPlayer, AnimationPlugin, VariableCurve, }; } use crate::{ animation_curves::AnimationCurve, graph::{AnimationGraph, AnimationGraphAssetLoader, AnimationNodeIndex}, - transition::{AnimationTransitions, advance_transitions, expire_completed_transitions}, + transition::{advance_transitions, expire_completed_transitions, AnimationTransitions}, }; use alloc::sync::Arc; diff --git a/crates/bevy_animation/src/transition.rs b/crates/bevy_animation/src/transition.rs index 18954cc2ffbd5..c94378208b3a7 100644 --- a/crates/bevy_animation/src/transition.rs +++ b/crates/bevy_animation/src/transition.rs @@ -8,11 +8,11 @@ use bevy_ecs::{ reflect::ReflectComponent, system::{Query, Res}, }; -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_time::Time; use core::time::Duration; -use crate::{ActiveAnimation, AnimationPlayer, graph::AnimationNodeIndex}; +use crate::{graph::AnimationNodeIndex, ActiveAnimation, AnimationPlayer}; /// Manages fade-out of animation blend factors, allowing for smooth transitions /// between animations. diff --git a/crates/bevy_animation/src/util.rs b/crates/bevy_animation/src/util.rs index 13e9fd20c062b..67aaf8116e365 100644 --- a/crates/bevy_animation/src/util.rs +++ b/crates/bevy_animation/src/util.rs @@ -2,5 +2,9 @@ /// Returns `a` if `t < 1.0`, otherwise returns `b`. #[inline] pub(crate) fn step_unclamped(a: T, b: T, t: f32) -> T { - if t < 1.0 { a } else { b } + if t < 1.0 { + a + } else { + b + } } diff --git a/crates/bevy_app/src/app.rs b/crates/bevy_app/src/app.rs index 38b06221e4392..cee160f0e7049 100644 --- a/crates/bevy_app/src/app.rs +++ b/crates/bevy_app/src/app.rs @@ -10,7 +10,7 @@ use alloc::{ pub use bevy_derive::AppLabel; use bevy_ecs::{ component::RequiredComponentsError, - event::{EventCursor, event_update_system}, + event::{event_update_system, EventCursor}, intern::Interned, prelude::*, result::{Error, SystemErrorContext}, diff --git a/crates/bevy_app/src/lib.rs b/crates/bevy_app/src/lib.rs index 46b9c47333132..489b5415e30a3 100644 --- a/crates/bevy_app/src/lib.rs +++ b/crates/bevy_app/src/lib.rs @@ -53,7 +53,6 @@ pub use terminal_ctrl_c_handler::*; pub mod prelude { #[doc(hidden)] pub use crate::{ - Plugin, PluginGroup, app::{App, AppExit}, main_schedule::{ First, FixedFirst, FixedLast, FixedPostUpdate, FixedPreUpdate, FixedUpdate, Last, Main, @@ -61,6 +60,7 @@ pub mod prelude { RunFixedMainLoopSystem, SpawnScene, Startup, Update, }, sub_app::SubApp, + Plugin, PluginGroup, }; #[cfg(feature = "bevy_tasks")] diff --git a/crates/bevy_app/src/plugin.rs b/crates/bevy_app/src/plugin.rs index a270acb9df0da..dc26e273f42c7 100644 --- a/crates/bevy_app/src/plugin.rs +++ b/crates/bevy_app/src/plugin.rs @@ -1,6 +1,6 @@ use crate::App; use core::any::Any; -use downcast_rs::{Downcast, impl_downcast}; +use downcast_rs::{impl_downcast, Downcast}; /// A collection of Bevy app logic and configuration. /// diff --git a/crates/bevy_app/src/plugin_group.rs b/crates/bevy_app/src/plugin_group.rs index 69cfaf8646cb0..dca847f77f8ee 100644 --- a/crates/bevy_app/src/plugin_group.rs +++ b/crates/bevy_app/src/plugin_group.rs @@ -525,7 +525,8 @@ impl PluginGroupBuilder { { panic!( "Error adding plugin {} in group {}: plugin was already added in application", - plugin_name, self.group_name + plugin_name, + self.group_name ); } } diff --git a/crates/bevy_app/src/schedule_runner.rs b/crates/bevy_app/src/schedule_runner.rs index 61f6c3dad2c64..2a0e1f966a49e 100644 --- a/crates/bevy_app/src/schedule_runner.rs +++ b/crates/bevy_app/src/schedule_runner.rs @@ -1,7 +1,7 @@ use crate::{ - PluginsState, app::{App, AppExit}, plugin::Plugin, + PluginsState, }; use bevy_platform_support::time::Instant; use core::time::Duration; @@ -10,7 +10,7 @@ use core::time::Duration; use { alloc::{boxed::Box, rc::Rc}, core::cell::RefCell, - wasm_bindgen::{JsCast, prelude::*}, + wasm_bindgen::{prelude::*, JsCast}, }; /// Determines the method used to run an [`App`]'s [`Schedule`](bevy_ecs::schedule::Schedule). diff --git a/crates/bevy_app/src/terminal_ctrl_c_handler.rs b/crates/bevy_app/src/terminal_ctrl_c_handler.rs index c063c677d2c1f..0eb34ccdbe98e 100644 --- a/crates/bevy_app/src/terminal_ctrl_c_handler.rs +++ b/crates/bevy_app/src/terminal_ctrl_c_handler.rs @@ -63,9 +63,7 @@ impl Plugin for TerminalCtrlCHandlerPlugin { match result { Ok(()) => {} Err(ctrlc::Error::MultipleHandlers) => { - log::info!( - "Skipping installing `Ctrl+C` handler as one was already installed. Please call `TerminalCtrlCHandlerPlugin::gracefully_exit` in your own `Ctrl+C` handler if you want Bevy to gracefully exit on `Ctrl+C`." - ); + log::info!("Skipping installing `Ctrl+C` handler as one was already installed. Please call `TerminalCtrlCHandlerPlugin::gracefully_exit` in your own `Ctrl+C` handler if you want Bevy to gracefully exit on `Ctrl+C`."); } Err(err) => log::warn!("Failed to set `Ctrl+C` handler: {err}"), } diff --git a/crates/bevy_asset/macros/src/lib.rs b/crates/bevy_asset/macros/src/lib.rs index b969db1d66038..443bd09ab9b36 100644 --- a/crates/bevy_asset/macros/src/lib.rs +++ b/crates/bevy_asset/macros/src/lib.rs @@ -4,7 +4,7 @@ use bevy_macro_utils::BevyManifest; use proc_macro::{Span, TokenStream}; use quote::{format_ident, quote}; -use syn::{Data, DeriveInput, Path, parse_macro_input}; +use syn::{parse_macro_input, Data, DeriveInput, Path}; pub(crate) fn bevy_asset_path() -> Path { BevyManifest::shared().get_path("bevy_asset") diff --git a/crates/bevy_asset/src/assets.rs b/crates/bevy_asset/src/assets.rs index 0e26bddcbcc1c..ebc9a0f588722 100644 --- a/crates/bevy_asset/src/assets.rs +++ b/crates/bevy_asset/src/assets.rs @@ -634,9 +634,7 @@ impl<'a, A: Asset> Iterator for AssetsMutIterator<'a, A> { /// An error returned when an [`AssetIndex`] has an invalid generation. #[derive(Error, Debug)] -#[error( - "AssetIndex {index:?} has an invalid generation. The current generation is: '{current_generation}'." -)] +#[error("AssetIndex {index:?} has an invalid generation. The current generation is: '{current_generation}'.")] pub struct InvalidGenerationError { index: AssetIndex, current_generation: u32, diff --git a/crates/bevy_asset/src/direct_access_ext.rs b/crates/bevy_asset/src/direct_access_ext.rs index baa5f60a2f6bc..792d523a30063 100644 --- a/crates/bevy_asset/src/direct_access_ext.rs +++ b/crates/bevy_asset/src/direct_access_ext.rs @@ -3,7 +3,7 @@ use bevy_ecs::world::World; -use crate::{Asset, AssetPath, AssetServer, Assets, Handle, meta::Settings}; +use crate::{meta::Settings, Asset, AssetPath, AssetServer, Assets, Handle}; /// An extension trait for methods for working with assets directly from a [`World`]. pub trait DirectAssetAccessExt { diff --git a/crates/bevy_asset/src/handle.rs b/crates/bevy_asset/src/handle.rs index 15217ed837469..f2401c951b5a2 100644 --- a/crates/bevy_asset/src/handle.rs +++ b/crates/bevy_asset/src/handle.rs @@ -1,9 +1,9 @@ use crate::{ - Asset, AssetId, AssetIndexAllocator, AssetPath, InternalAssetId, UntypedAssetId, - meta::MetaTransform, + meta::MetaTransform, Asset, AssetId, AssetIndexAllocator, AssetPath, InternalAssetId, + UntypedAssetId, }; use alloc::sync::Arc; -use bevy_reflect::{Reflect, TypePath, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect, TypePath}; use core::{ any::TypeId, hash::{Hash, Hasher}, @@ -700,11 +700,7 @@ mod tests { let from_reflect_handle: Handle = FromReflect::from_reflect(&*cloned_handle).unwrap(); - assert_eq!( - Arc::strong_count(strong), - 3, - "Converting the reflected value back to a handle should increase the strong count to 3" - ); + assert_eq!(Arc::strong_count(strong), 3, "Converting the reflected value back to a handle should increase the strong count to 3"); assert!( from_reflect_handle.is_strong(), "The cloned handle should still be strong" diff --git a/crates/bevy_asset/src/id.rs b/crates/bevy_asset/src/id.rs index d44529b2c1f2b..4caf546163a75 100644 --- a/crates/bevy_asset/src/id.rs +++ b/crates/bevy_asset/src/id.rs @@ -418,9 +418,7 @@ impl TryFrom for AssetId { #[non_exhaustive] pub enum UntypedAssetIdConversionError { /// Caused when trying to convert an [`UntypedAssetId`] into an [`AssetId`] of the wrong type. - #[error( - "This UntypedAssetId is for {found:?} and cannot be converted into an AssetId<{expected:?}>" - )] + #[error("This UntypedAssetId is for {found:?} and cannot be converted into an AssetId<{expected:?}>")] TypeIdMismatch { /// The [`TypeId`] of the asset that we are trying to convert to. expected: TypeId, diff --git a/crates/bevy_asset/src/io/android.rs b/crates/bevy_asset/src/io/android.rs index 98fc045668e67..67ca8e339a22c 100644 --- a/crates/bevy_asset/src/io/android.rs +++ b/crates/bevy_asset/src/io/android.rs @@ -1,4 +1,4 @@ -use crate::io::{AssetReader, AssetReaderError, PathStream, Reader, VecReader, get_meta_path}; +use crate::io::{get_meta_path, AssetReader, AssetReaderError, PathStream, Reader, VecReader}; use alloc::{borrow::ToOwned, boxed::Box, ffi::CString, vec::Vec}; use futures_lite::stream; use std::path::Path; diff --git a/crates/bevy_asset/src/io/embedded/embedded_watcher.rs b/crates/bevy_asset/src/io/embedded/embedded_watcher.rs index 743e13de80c62..89ac9b3826a8f 100644 --- a/crates/bevy_asset/src/io/embedded/embedded_watcher.rs +++ b/crates/bevy_asset/src/io/embedded/embedded_watcher.rs @@ -1,12 +1,12 @@ use crate::io::{ - AssetSourceEvent, AssetWatcher, - file::{FilesystemEventHandler, get_asset_path, get_base_path, new_asset_event_debouncer}, + file::{get_asset_path, get_base_path, new_asset_event_debouncer, FilesystemEventHandler}, memory::Dir, + AssetSourceEvent, AssetWatcher, }; use alloc::{boxed::Box, sync::Arc, vec::Vec}; use bevy_platform_support::collections::HashMap; use core::time::Duration; -use notify_debouncer_full::{Debouncer, RecommendedCache, notify::RecommendedWatcher}; +use notify_debouncer_full::{notify::RecommendedWatcher, Debouncer, RecommendedCache}; use parking_lot::RwLock; use std::{ fs::File, diff --git a/crates/bevy_asset/src/io/embedded/mod.rs b/crates/bevy_asset/src/io/embedded/mod.rs index be2ea1129099a..fce5149462247 100644 --- a/crates/bevy_asset/src/io/embedded/mod.rs +++ b/crates/bevy_asset/src/io/embedded/mod.rs @@ -5,8 +5,8 @@ mod embedded_watcher; pub use embedded_watcher::*; use crate::io::{ - AssetSource, AssetSourceBuilders, memory::{Dir, MemoryAssetReader, Value}, + AssetSource, AssetSourceBuilders, }; use alloc::boxed::Box; use bevy_ecs::resource::Resource; @@ -139,7 +139,9 @@ impl EmbeddedAssetRegistry { /// [`embedded_asset`]: crate::embedded_asset #[macro_export] macro_rules! embedded_path { - ($path_str: expr) => {{ embedded_path!("src", $path_str) }}; + ($path_str: expr) => {{ + embedded_path!("src", $path_str) + }}; ($source_path: expr, $path_str: expr) => {{ let crate_name = module_path!().split(':').next().unwrap(); @@ -249,7 +251,9 @@ pub fn _embedded_asset_path( /// [`embedded_path`]: crate::embedded_path #[macro_export] macro_rules! embedded_asset { - ($app: ident, $path: expr) => {{ $crate::embedded_asset!($app, "src", $path) }}; + ($app: ident, $path: expr) => {{ + $crate::embedded_asset!($app, "src", $path) + }}; ($app: ident, $source_path: expr, $path: expr) => {{ let mut embedded = $app @@ -329,7 +333,7 @@ macro_rules! load_internal_binary_asset { #[cfg(test)] mod tests { - use super::{_embedded_asset_path, EmbeddedAssetRegistry}; + use super::{EmbeddedAssetRegistry, _embedded_asset_path}; use std::path::Path; // Relative paths show up if this macro is being invoked by a local crate. diff --git a/crates/bevy_asset/src/io/file/file_asset.rs b/crates/bevy_asset/src/io/file/file_asset.rs index 42bffeb8d804a..f65680217bc2a 100644 --- a/crates/bevy_asset/src/io/file/file_asset.rs +++ b/crates/bevy_asset/src/io/file/file_asset.rs @@ -1,8 +1,8 @@ use crate::io::{ - AssetReader, AssetReaderError, AssetWriter, AssetWriterError, AsyncSeekForward, PathStream, - Reader, Writer, get_meta_path, + get_meta_path, AssetReader, AssetReaderError, AssetWriter, AssetWriterError, AsyncSeekForward, + PathStream, Reader, Writer, }; -use async_fs::{File, read_dir}; +use async_fs::{read_dir, File}; use futures_io::AsyncSeek; use futures_lite::StreamExt; diff --git a/crates/bevy_asset/src/io/file/file_watcher.rs b/crates/bevy_asset/src/io/file/file_watcher.rs index 0922db8717dc6..64d3e711c975a 100644 --- a/crates/bevy_asset/src/io/file/file_watcher.rs +++ b/crates/bevy_asset/src/io/file/file_watcher.rs @@ -6,11 +6,13 @@ use alloc::borrow::ToOwned; use core::time::Duration; use crossbeam_channel::Sender; use notify_debouncer_full::{ - DebounceEventResult, Debouncer, RecommendedCache, new_debouncer, + new_debouncer, notify::{ - self, RecommendedWatcher, RecursiveMode, + self, event::{AccessKind, AccessMode, CreateKind, ModifyKind, RemoveKind, RenameMode}, + RecommendedWatcher, RecursiveMode, }, + DebounceEventResult, Debouncer, RecommendedCache, }; use std::path::{Path, PathBuf}; use tracing::error; @@ -188,13 +190,13 @@ pub(crate) fn new_asset_event_debouncer( } (true, false) => { error!( - "Asset metafile {old_path:?} was changed to asset file {new_path:?}, which is not supported. Try restarting your app to see if configuration is still valid" - ); + "Asset metafile {old_path:?} was changed to asset file {new_path:?}, which is not supported. Try restarting your app to see if configuration is still valid" + ); } (false, true) => { error!( - "Asset file {old_path:?} was changed to meta file {new_path:?}, which is not supported. Try restarting your app to see if configuration is still valid" - ); + "Asset file {old_path:?} was changed to meta file {new_path:?}, which is not supported. Try restarting your app to see if configuration is still valid" + ); } } } diff --git a/crates/bevy_asset/src/io/file/sync_file_asset.rs b/crates/bevy_asset/src/io/file/sync_file_asset.rs index 38255efba0a09..7533256204a8d 100644 --- a/crates/bevy_asset/src/io/file/sync_file_asset.rs +++ b/crates/bevy_asset/src/io/file/sync_file_asset.rs @@ -2,14 +2,14 @@ use futures_io::{AsyncRead, AsyncWrite}; use futures_lite::Stream; use crate::io::{ - AssetReader, AssetReaderError, AssetWriter, AssetWriterError, AsyncSeekForward, PathStream, - Reader, Writer, get_meta_path, + get_meta_path, AssetReader, AssetReaderError, AssetWriter, AssetWriterError, AsyncSeekForward, + PathStream, Reader, Writer, }; use alloc::{borrow::ToOwned, boxed::Box, vec::Vec}; use core::{pin::Pin, task::Poll}; use std::{ - fs::{File, read_dir}, + fs::{read_dir, File}, io::{Read, Seek, Write}, path::{Path, PathBuf}, }; diff --git a/crates/bevy_asset/src/io/memory.rs b/crates/bevy_asset/src/io/memory.rs index 3806c0954c828..5b9e5389c2199 100644 --- a/crates/bevy_asset/src/io/memory.rs +++ b/crates/bevy_asset/src/io/memory.rs @@ -3,7 +3,7 @@ use alloc::{borrow::ToOwned, boxed::Box, sync::Arc, vec::Vec}; use bevy_platform_support::collections::HashMap; use core::{pin::Pin, task::Poll}; use futures_io::AsyncRead; -use futures_lite::{Stream, ready}; +use futures_lite::{ready, Stream}; use parking_lot::RwLock; use std::path::{Path, PathBuf}; diff --git a/crates/bevy_asset/src/io/mod.rs b/crates/bevy_asset/src/io/mod.rs index 814703bc4c096..aa7256bbd927b 100644 --- a/crates/bevy_asset/src/io/mod.rs +++ b/crates/bevy_asset/src/io/mod.rs @@ -30,7 +30,7 @@ use core::{ task::{Context, Poll}, }; use futures_io::{AsyncRead, AsyncWrite}; -use futures_lite::{Stream, ready}; +use futures_lite::{ready, Stream}; use std::path::{Path, PathBuf}; use thiserror::Error; diff --git a/crates/bevy_asset/src/io/processor_gated.rs b/crates/bevy_asset/src/io/processor_gated.rs index b1e606f9ca4f7..da439f56f5e18 100644 --- a/crates/bevy_asset/src/io/processor_gated.rs +++ b/crates/bevy_asset/src/io/processor_gated.rs @@ -1,7 +1,7 @@ use crate::{ - AssetPath, io::{AssetReader, AssetReaderError, AssetSourceId, PathStream, Reader}, processor::{AssetProcessorData, ProcessStatus}, + AssetPath, }; use alloc::{borrow::ToOwned, boxed::Box, sync::Arc, vec::Vec}; use async_lock::RwLockReadGuardArc; diff --git a/crates/bevy_asset/src/io/source.rs b/crates/bevy_asset/src/io/source.rs index d8e4d822b599d..58c5006a8047e 100644 --- a/crates/bevy_asset/src/io/source.rs +++ b/crates/bevy_asset/src/io/source.rs @@ -1,5 +1,5 @@ use crate::{ - io::{AssetSourceEvent, AssetWatcher, processor_gated::ProcessorGatedReader}, + io::{processor_gated::ProcessorGatedReader, AssetSourceEvent, AssetWatcher}, processor::AssetProcessorData, }; use alloc::{ @@ -240,12 +240,10 @@ impl AssetSourceBuilder { /// Will use the given `watcher` function to construct unprocessed [`AssetWatcher`] instances. pub fn with_watcher( mut self, - watcher: impl FnMut( - crossbeam_channel::Sender, - ) -> Option> - + Send - + Sync - + 'static, + watcher: impl FnMut(crossbeam_channel::Sender) -> Option> + + Send + + Sync + + 'static, ) -> Self { self.watcher = Some(Box::new(watcher)); self @@ -272,12 +270,10 @@ impl AssetSourceBuilder { /// Will use the given `watcher` function to construct processed [`AssetWatcher`] instances. pub fn with_processed_watcher( mut self, - watcher: impl FnMut( - crossbeam_channel::Sender, - ) -> Option> - + Send - + Sync - + 'static, + watcher: impl FnMut(crossbeam_channel::Sender) -> Option> + + Send + + Sync + + 'static, ) -> Self { self.processed_watcher = Some(Box::new(watcher)); self @@ -536,8 +532,8 @@ impl AssetSource { path: String, file_debounce_wait_time: Duration, ) -> impl FnMut(crossbeam_channel::Sender) -> Option> - + Send - + Sync { + + Send + + Sync { move |sender: crossbeam_channel::Sender| { #[cfg(all( feature = "file_watcher", diff --git a/crates/bevy_asset/src/io/wasm.rs b/crates/bevy_asset/src/io/wasm.rs index 75c77fdb5c4e0..125543fc113a4 100644 --- a/crates/bevy_asset/src/io/wasm.rs +++ b/crates/bevy_asset/src/io/wasm.rs @@ -1,11 +1,11 @@ use crate::io::{ - AssetReader, AssetReaderError, EmptyPathStream, PathStream, Reader, VecReader, get_meta_path, + get_meta_path, AssetReader, AssetReaderError, EmptyPathStream, PathStream, Reader, VecReader, }; use alloc::{borrow::ToOwned, boxed::Box, format}; -use js_sys::{JSON, Uint8Array}; +use js_sys::{Uint8Array, JSON}; use std::path::{Path, PathBuf}; use tracing::error; -use wasm_bindgen::{JsCast, JsValue, prelude::wasm_bindgen}; +use wasm_bindgen::{prelude::wasm_bindgen, JsCast, JsValue}; use wasm_bindgen_futures::JsFuture; use web_sys::Response; diff --git a/crates/bevy_asset/src/lib.rs b/crates/bevy_asset/src/lib.rs index a7bbd8aa385a0..f0b8e92a9320d 100644 --- a/crates/bevy_asset/src/lib.rs +++ b/crates/bevy_asset/src/lib.rs @@ -208,7 +208,7 @@ pub use ron; pub use uuid; use crate::{ - io::{AssetSourceBuilder, AssetSourceBuilders, AssetSourceId, embedded::EmbeddedAssetRegistry}, + io::{embedded::EmbeddedAssetRegistry, AssetSourceBuilder, AssetSourceBuilders, AssetSourceId}, processor::{AssetProcessor, Process}, }; use alloc::{ @@ -536,10 +536,7 @@ impl AssetApp for App { ) -> &mut Self { let id = AssetSourceId::from_static(id); if self.world().get_resource::().is_some() { - error!( - "{} must be registered before `AssetPlugin` (typically added as part of `DefaultPlugins`)", - id - ); + error!("{} must be registered before `AssetPlugin` (typically added as part of `DefaultPlugins`)", id); } { @@ -633,16 +630,16 @@ pub struct AssetEvents; #[cfg(test)] mod tests { use crate::{ - Asset, AssetApp, AssetEvent, AssetId, AssetLoadError, AssetLoadFailedEvent, AssetPath, - AssetPlugin, AssetServer, Assets, folder::LoadedFolder, handle::Handle, io::{ - AssetReader, AssetReaderError, AssetSource, AssetSourceId, Reader, gated::{GateOpener, GatedReader}, memory::{Dir, MemoryAssetReader}, + AssetReader, AssetReaderError, AssetSource, AssetSourceId, Reader, }, loader::{AssetLoader, LoadContext}, + Asset, AssetApp, AssetEvent, AssetId, AssetLoadError, AssetLoadFailedEvent, AssetPath, + AssetPlugin, AssetServer, Assets, }; use alloc::{ boxed::Box, @@ -866,9 +863,7 @@ mod tests { fn load_dependencies() { // The particular usage of GatedReader in this test will cause deadlocking if running single-threaded #[cfg(not(feature = "multi_threaded"))] - panic!( - "This test requires the \"multi_threaded\" feature, otherwise it will deadlock.\ncargo test --package bevy_asset --features multi_threaded" - ); + panic!("This test requires the \"multi_threaded\" feature, otherwise it will deadlock.\ncargo test --package bevy_asset --features multi_threaded"); let dir = Dir::default(); @@ -1176,9 +1171,7 @@ mod tests { fn failure_load_states() { // The particular usage of GatedReader in this test will cause deadlocking if running single-threaded #[cfg(not(feature = "multi_threaded"))] - panic!( - "This test requires the \"multi_threaded\" feature, otherwise it will deadlock.\ncargo test --package bevy_asset --features multi_threaded" - ); + panic!("This test requires the \"multi_threaded\" feature, otherwise it will deadlock.\ncargo test --package bevy_asset --features multi_threaded"); let dir = Dir::default(); @@ -1295,11 +1288,9 @@ mod tests { assert!(asset_server.load_state(a_id).is_loaded()); assert!(asset_server.dependency_load_state(a_id).is_loaded()); - assert!( - asset_server - .recursive_dependency_load_state(a_id) - .is_failed() - ); + assert!(asset_server + .recursive_dependency_load_state(a_id) + .is_failed()); assert!(asset_server.is_loaded(a_id)); assert!(asset_server.is_loaded_with_direct_dependencies(a_id)); @@ -1313,9 +1304,7 @@ mod tests { fn dependency_load_states() { // The particular usage of GatedReader in this test will cause deadlocking if running single-threaded #[cfg(not(feature = "multi_threaded"))] - panic!( - "This test requires the \"multi_threaded\" feature, otherwise it will deadlock.\ncargo test --package bevy_asset --features multi_threaded" - ); + panic!("This test requires the \"multi_threaded\" feature, otherwise it will deadlock.\ncargo test --package bevy_asset --features multi_threaded"); let a_path = "a.cool.ron"; let a_ron = r#" @@ -1454,9 +1443,7 @@ mod tests { fn manual_asset_management() { // The particular usage of GatedReader in this test will cause deadlocking if running single-threaded #[cfg(not(feature = "multi_threaded"))] - panic!( - "This test requires the \"multi_threaded\" feature, otherwise it will deadlock.\ncargo test --package bevy_asset --features multi_threaded" - ); + panic!("This test requires the \"multi_threaded\" feature, otherwise it will deadlock.\ncargo test --package bevy_asset --features multi_threaded"); let dir = Dir::default(); let dep_path = "dep.cool.ron"; @@ -1557,9 +1544,7 @@ mod tests { fn load_folder() { // The particular usage of GatedReader in this test will cause deadlocking if running single-threaded #[cfg(not(feature = "multi_threaded"))] - panic!( - "This test requires the \"multi_threaded\" feature, otherwise it will deadlock.\ncargo test --package bevy_asset --features multi_threaded" - ); + panic!("This test requires the \"multi_threaded\" feature, otherwise it will deadlock.\ncargo test --package bevy_asset --features multi_threaded"); let dir = Dir::default(); diff --git a/crates/bevy_asset/src/loader.rs b/crates/bevy_asset/src/loader.rs index 6b1bded0cf418..3be672e0c194d 100644 --- a/crates/bevy_asset/src/loader.rs +++ b/crates/bevy_asset/src/loader.rs @@ -1,10 +1,10 @@ use crate::{ - Asset, AssetLoadError, AssetServer, AssetServerMode, Assets, Handle, UntypedAssetId, - UntypedHandle, io::{AssetReaderError, MissingAssetSourceError, MissingProcessedAssetReaderError, Reader}, loader_builders::{Deferred, NestedLoader, StaticTyped}, meta::{AssetHash, AssetMeta, AssetMetaDyn, ProcessedInfoMinimal, Settings}, path::AssetPath, + Asset, AssetLoadError, AssetServer, AssetServerMode, Assets, Handle, UntypedAssetId, + UntypedHandle, }; use alloc::{ boxed::Box, @@ -17,7 +17,7 @@ use bevy_log::warn; use bevy_platform_support::collections::{HashMap, HashSet}; use bevy_tasks::{BoxedFuture, ConditionalSendFuture}; use core::any::{Any, TypeId}; -use downcast_rs::{Downcast, impl_downcast}; +use downcast_rs::{impl_downcast, Downcast}; use ron::error::SpannedError; use serde::{Deserialize, Serialize}; use std::path::{Path, PathBuf}; @@ -508,9 +508,7 @@ impl<'a> LoadContext<'a> { ); for (label, asset) in labeled_assets { if self.labeled_assets.insert(label.clone(), asset).is_some() { - warn!( - "A labeled asset with the label \"{label}\" already exists. Replacing with the new asset." - ); + warn!("A labeled asset with the label \"{label}\" already exists. Replacing with the new asset."); } } handle @@ -660,8 +658,6 @@ pub enum ReadAssetBytesError { path: PathBuf, source: std::io::Error, }, - #[error( - "The LoadContext for this read_asset_bytes call requires hash metadata, but it was not provided. This is likely an internal implementation error." - )] + #[error("The LoadContext for this read_asset_bytes call requires hash metadata, but it was not provided. This is likely an internal implementation error.")] MissingAssetHash, } diff --git a/crates/bevy_asset/src/loader_builders.rs b/crates/bevy_asset/src/loader_builders.rs index f02a79c516bcf..630ab1f92cd18 100644 --- a/crates/bevy_asset/src/loader_builders.rs +++ b/crates/bevy_asset/src/loader_builders.rs @@ -2,10 +2,10 @@ //! [`LoadContext::loader`]. use crate::{ + io::Reader, + meta::{meta_transform_settings, AssetMetaDyn, MetaTransform, Settings}, Asset, AssetLoadError, AssetPath, CompleteErasedLoadedAsset, CompleteLoadedAsset, ErasedAssetLoader, Handle, LoadContext, LoadDirectError, LoadedUntypedAsset, UntypedHandle, - io::Reader, - meta::{AssetMetaDyn, MetaTransform, Settings, meta_transform_settings}, }; use alloc::{borrow::ToOwned, boxed::Box, sync::Arc}; use core::any::TypeId; diff --git a/crates/bevy_asset/src/meta.rs b/crates/bevy_asset/src/meta.rs index d870ba1c7cd14..0e972261198cc 100644 --- a/crates/bevy_asset/src/meta.rs +++ b/crates/bevy_asset/src/meta.rs @@ -5,10 +5,10 @@ use alloc::{ }; use crate::{ - Asset, AssetPath, DeserializeMetaError, VisitAssetDependencies, loader::AssetLoader, - processor::Process, + loader::AssetLoader, processor::Process, Asset, AssetPath, DeserializeMetaError, + VisitAssetDependencies, }; -use downcast_rs::{Downcast, impl_downcast}; +use downcast_rs::{impl_downcast, Downcast}; use ron::ser::PrettyConfig; use serde::{Deserialize, Serialize}; use tracing::error; diff --git a/crates/bevy_asset/src/path.rs b/crates/bevy_asset/src/path.rs index e2345c38e02ed..3038c52fbadbe 100644 --- a/crates/bevy_asset/src/path.rs +++ b/crates/bevy_asset/src/path.rs @@ -10,7 +10,7 @@ use core::{ hash::Hash, ops::Deref, }; -use serde::{Deserialize, Serialize, de::Visitor}; +use serde::{de::Visitor, Deserialize, Serialize}; use std::path::{Path, PathBuf}; use thiserror::Error; @@ -89,14 +89,10 @@ pub enum ParseAssetPathError { #[error("Asset label must not contain a `://` substring")] InvalidLabelSyntax, /// Error that occurs when a path string has an [`AssetPath::source`] delimiter `://` with no characters preceding it. E.g. `://file.test`. - #[error( - "Asset source must be at least one character. Either specify the source before the '://' or remove the `://`" - )] + #[error("Asset source must be at least one character. Either specify the source before the '://' or remove the `://`")] MissingSource, /// Error that occurs when a path string has an [`AssetPath::label`] delimiter `#` with no characters succeeding it. E.g. `file.test#` - #[error( - "Asset label must be at least one character. Either specify the label after the '#' or remove the '#'" - )] + #[error("Asset label must be at least one character. Either specify the label after the '#' or remove the '#'")] MissingLabel, } diff --git a/crates/bevy_asset/src/processor/mod.rs b/crates/bevy_asset/src/processor/mod.rs index eed13a28b1f19..bfc9a295d86d3 100644 --- a/crates/bevy_asset/src/processor/mod.rs +++ b/crates/bevy_asset/src/processor/mod.rs @@ -44,17 +44,17 @@ pub use log::*; pub use process::*; use crate::{ - AssetLoadError, AssetMetaCheck, AssetPath, AssetServer, AssetServerMode, DeserializeMetaError, - MissingAssetLoaderForExtensionError, io::{ AssetReaderError, AssetSource, AssetSourceBuilders, AssetSourceEvent, AssetSourceId, AssetSources, AssetWriterError, ErasedAssetReader, ErasedAssetWriter, MissingAssetSourceError, }, meta::{ - AssetAction, AssetActionMinimal, AssetHash, AssetMeta, AssetMetaDyn, AssetMetaMinimal, - ProcessedInfo, ProcessedInfoMinimal, get_asset_hash, get_full_asset_hash, + get_asset_hash, get_full_asset_hash, AssetAction, AssetActionMinimal, AssetHash, AssetMeta, + AssetMetaDyn, AssetMetaMinimal, ProcessedInfo, ProcessedInfoMinimal, }, + AssetLoadError, AssetMetaCheck, AssetPath, AssetServer, AssetServerMode, DeserializeMetaError, + MissingAssetLoaderForExtensionError, }; use alloc::{borrow::ToOwned, boxed::Box, collections::VecDeque, sync::Arc, vec, vec::Vec}; use bevy_ecs::prelude::*; @@ -428,9 +428,7 @@ impl AssetProcessor { // then we automatically clean up this folder if err.kind() != ErrorKind::NotFound { let asset_path = AssetPath::from_path(path).with_source(source.id()); - error!( - "Failed to remove destination folder that no longer exists in {asset_path}: {err}" - ); + error!("Failed to remove destination folder that no longer exists in {asset_path}: {err}"); } } } @@ -655,18 +653,14 @@ impl AssetProcessor { info.processed_info = minimal.processed_info; } Err(err) => { - trace!( - "Removing processed data for {asset_path} because meta could not be parsed: {err}" - ); + trace!("Removing processed data for {asset_path} because meta could not be parsed: {err}"); self.remove_processed_asset_and_meta(source, asset_path.path()) .await; } } } Err(err) => { - trace!( - "Removing processed data for {asset_path} because meta failed to load: {err}" - ); + trace!("Removing processed data for {asset_path} because meta failed to load: {err}"); self.remove_processed_asset_and_meta(source, asset_path.path()) .await; } @@ -706,9 +700,7 @@ impl AssetProcessor { async fn clean_empty_processed_ancestor_folders(&self, source: &AssetSource, path: &Path) { // As a safety precaution don't delete absolute paths to avoid deleting folders outside of the destination folder if path.is_absolute() { - error!( - "Attempted to clean up ancestor folders of an absolute path. This is unsafe so the operation was skipped." - ); + error!("Attempted to clean up ancestor folders of an absolute path. This is unsafe so the operation was skipped."); return; } while let Some(parent) = path.parent() { @@ -820,7 +812,7 @@ impl AssetProcessor { return Err(ProcessError::ReadAssetMetaError { path: asset_path.clone(), err, - }); + }) } }; @@ -934,15 +926,11 @@ impl AssetProcessor { if let Err(err) = ProcessorTransactionLog::validate().await { let state_is_valid = match err { ValidateLogError::ReadLogError(err) => { - error!( - "Failed to read processor log file. Processed assets cannot be validated so they must be re-generated {err}" - ); + error!("Failed to read processor log file. Processed assets cannot be validated so they must be re-generated {err}"); false } ValidateLogError::UnrecoverableError => { - error!( - "Encountered an unrecoverable error in the last run. Processed assets cannot be validated so they must be re-generated" - ); + error!("Encountered an unrecoverable error in the last run. Processed assets cannot be validated so they must be re-generated"); false } ValidateLogError::EntryErrors(entry_errors) => { @@ -956,9 +944,7 @@ impl AssetProcessor { break; } LogEntryError::UnfinishedTransaction(path) => { - debug!( - "Asset {path:?} did not finish processing. Clearing state for that asset" - ); + debug!("Asset {path:?} did not finish processing. Clearing state for that asset"); let mut unrecoverable_err = |message: &dyn core::fmt::Display| { error!("Failed to remove asset {path:?}: {message}"); state_is_valid = false; @@ -968,9 +954,7 @@ impl AssetProcessor { continue; }; let Ok(processed_writer) = source.processed_writer() else { - unrecoverable_err( - &"AssetSource does not have a processed AssetWriter registered", - ); + unrecoverable_err(&"AssetSource does not have a processed AssetWriter registered"); continue; }; @@ -1002,9 +986,7 @@ impl AssetProcessor { }; if !state_is_valid { - error!( - "Processed asset transaction log state was invalid and unrecoverable for some reason (see previous logs). Removing processed assets and starting fresh." - ); + error!("Processed asset transaction log state was invalid and unrecoverable for some reason (see previous logs). Removing processed assets and starting fresh."); for source in self.sources().iter_processed() { let Ok(processed_writer) = source.processed_writer() else { continue; @@ -1013,9 +995,7 @@ impl AssetProcessor { .remove_assets_in_directory(Path::new("")) .await { - panic!( - "Processed assets were in a bad state. To correct this, the asset processor attempted to remove all processed assets and start from scratch. This failed. There is no way to continue. Try restarting, or deleting imported asset folder manually. {err}" - ); + panic!("Processed assets were in a bad state. To correct this, the asset processor attempted to remove all processed assets and start from scratch. This failed. There is no way to continue. Try restarting, or deleting imported asset folder manually. {err}"); } } } @@ -1023,10 +1003,7 @@ impl AssetProcessor { let mut log = self.data.log.write().await; *log = match ProcessorTransactionLog::new().await { Ok(log) => Some(log), - Err(err) => panic!( - "Failed to initialize asset processor log. This cannot be recovered. Try restarting. If that doesn't work, try deleting processed asset folder. {}", - err - ), + Err(err) => panic!("Failed to initialize asset processor log. This cannot be recovered. Try restarting. If that doesn't work, try deleting processed asset folder. {}", err), }; } } diff --git a/crates/bevy_asset/src/processor/process.rs b/crates/bevy_asset/src/processor/process.rs index f987f662d90a3..d2202d2334d23 100644 --- a/crates/bevy_asset/src/processor/process.rs +++ b/crates/bevy_asset/src/processor/process.rs @@ -1,6 +1,4 @@ use crate::{ - AssetLoadError, AssetLoader, AssetPath, CompleteErasedLoadedAsset, DeserializeMetaError, - MissingAssetLoaderForExtensionError, MissingAssetLoaderForTypeNameError, io::{ AssetReaderError, AssetWriterError, MissingAssetWriterError, MissingProcessedAssetReaderError, MissingProcessedAssetWriterError, SliceReader, Writer, @@ -9,6 +7,8 @@ use crate::{ processor::AssetProcessor, saver::{AssetSaver, SavedAsset}, transformer::{AssetTransformer, IdentityAssetTransformer, TransformedAsset}, + AssetLoadError, AssetLoader, AssetPath, CompleteErasedLoadedAsset, DeserializeMetaError, + MissingAssetLoaderForExtensionError, MissingAssetLoaderForTypeNameError, }; use alloc::{ borrow::ToOwned, @@ -96,10 +96,10 @@ pub struct LoadTransformAndSaveSettings, - S: AssetSaver, -> LoadTransformAndSave + L: AssetLoader, + T: AssetTransformer, + S: AssetSaver, + > LoadTransformAndSave { pub fn new(transformer: T, saver: S) -> Self { LoadTransformAndSave { @@ -148,9 +148,7 @@ pub enum ProcessError { DeserializeMetaError(#[from] DeserializeMetaError), #[error(transparent)] AssetLoadError(#[from] AssetLoadError), - #[error( - "The wrong meta type was passed into a processor. This is probably an internal implementation error." - )] + #[error("The wrong meta type was passed into a processor. This is probably an internal implementation error.")] WrongMetaType, #[error("Encountered an error while saving the asset: {0}")] #[from(ignore)] diff --git a/crates/bevy_asset/src/reflect.rs b/crates/bevy_asset/src/reflect.rs index 2743b5a14c5c8..5c436c10610f0 100644 --- a/crates/bevy_asset/src/reflect.rs +++ b/crates/bevy_asset/src/reflect.rs @@ -1,7 +1,7 @@ use alloc::boxed::Box; use core::any::{Any, TypeId}; -use bevy_ecs::world::{World, unsafe_world_cell::UnsafeWorldCell}; +use bevy_ecs::world::{unsafe_world_cell::UnsafeWorldCell, World}; use bevy_reflect::{FromReflect, FromType, PartialReflect, Reflect}; use crate::{Asset, AssetId, Assets, Handle, UntypedAssetId, UntypedHandle}; diff --git a/crates/bevy_asset/src/saver.rs b/crates/bevy_asset/src/saver.rs index d4136c1e80865..3b187e96ef88a 100644 --- a/crates/bevy_asset/src/saver.rs +++ b/crates/bevy_asset/src/saver.rs @@ -1,6 +1,6 @@ use crate::{ - Asset, AssetLoader, CompleteErasedLoadedAsset, ErasedLoadedAsset, Handle, LabeledAsset, - UntypedHandle, io::Writer, meta::Settings, transformer::TransformedAsset, + io::Writer, meta::Settings, transformer::TransformedAsset, Asset, AssetLoader, + CompleteErasedLoadedAsset, ErasedLoadedAsset, Handle, LabeledAsset, UntypedHandle, }; use alloc::boxed::Box; use atomicow::CowArc; diff --git a/crates/bevy_asset/src/server/info.rs b/crates/bevy_asset/src/server/info.rs index 00974987974ea..e519bf86aeebf 100644 --- a/crates/bevy_asset/src/server/info.rs +++ b/crates/bevy_asset/src/server/info.rs @@ -1,8 +1,8 @@ use crate::{ + meta::{AssetHash, MetaTransform}, Asset, AssetHandleProvider, AssetLoadError, AssetPath, DependencyLoadState, ErasedLoadedAsset, Handle, InternalAssetEvent, LoadState, RecursiveDependencyLoadState, StrongHandle, UntypedAssetId, UntypedHandle, - meta::{AssetHash, MetaTransform}, }; use alloc::{ borrow::ToOwned, @@ -11,7 +11,7 @@ use alloc::{ vec::Vec, }; use bevy_ecs::world::World; -use bevy_platform_support::collections::{HashMap, HashSet, hash_map::Entry}; +use bevy_platform_support::collections::{hash_map::Entry, HashMap, HashSet}; use bevy_tasks::Task; use bevy_utils::TypeIdMap; use core::{any::TypeId, task::Waker}; @@ -782,16 +782,12 @@ pub(crate) fn unwrap_with_context( Err(GetOrCreateHandleInternalError::HandleMissingButTypeIdNotSpecified) => None, Err(GetOrCreateHandleInternalError::MissingHandleProviderError(_)) => match type_info { Either::Left(type_name) => { - panic!( - "Cannot allocate an Asset Handle of type '{type_name}' because the asset type has not been initialized. \ - Make sure you have called `app.init_asset::<{type_name}>()`" - ); + panic!("Cannot allocate an Asset Handle of type '{type_name}' because the asset type has not been initialized. \ + Make sure you have called `app.init_asset::<{type_name}>()`"); } Either::Right(type_id) => { - panic!( - "Cannot allocate an AssetHandle of type '{type_id:?}' because the asset type has not been initialized. \ - Make sure you have called `app.init_asset::<(actual asset type)>()`" - ) + panic!("Cannot allocate an AssetHandle of type '{type_id:?}' because the asset type has not been initialized. \ + Make sure you have called `app.init_asset::<(actual asset type)>()`") } }, } diff --git a/crates/bevy_asset/src/server/loaders.rs b/crates/bevy_asset/src/server/loaders.rs index 1d5a30d8e7dd7..1250ff666ae9f 100644 --- a/crates/bevy_asset/src/server/loaders.rs +++ b/crates/bevy_asset/src/server/loaders.rs @@ -73,10 +73,8 @@ impl AssetLoaders { list.push(loader_index); } if !duplicate_extensions.is_empty() { - warn!( - "Duplicate AssetLoader registered for Asset type `{loader_asset_type_name}` with extensions `{duplicate_extensions:?}`. \ - Loader must be specified in a .meta file in order to load assets of this type with these extensions." - ); + warn!("Duplicate AssetLoader registered for Asset type `{loader_asset_type_name}` with extensions `{duplicate_extensions:?}`. \ + Loader must be specified in a .meta file in order to load assets of this type with these extensions."); } self.type_name_to_loader.insert(type_name, loader_index); @@ -141,10 +139,8 @@ impl AssetLoaders { list.push(loader_index); } if !duplicate_extensions.is_empty() { - warn!( - "Duplicate AssetLoader preregistered for Asset type `{loader_asset_type_name}` with extensions `{duplicate_extensions:?}`. \ - Loader must be specified in a .meta file in order to load assets of this type with these extensions." - ); + warn!("Duplicate AssetLoader preregistered for Asset type `{loader_asset_type_name}` with extensions `{duplicate_extensions:?}`. \ + Loader must be specified in a .meta file in order to load assets of this type with these extensions."); } self.type_id_to_loaders @@ -350,7 +346,7 @@ mod tests { use core::marker::PhantomData; use std::{ path::Path, - sync::mpsc::{Receiver, Sender, channel}, + sync::mpsc::{channel, Receiver, Sender}, }; use bevy_reflect::TypePath; diff --git a/crates/bevy_asset/src/server/mod.rs b/crates/bevy_asset/src/server/mod.rs index 9518e0e697e5d..e65bbd2b6acb7 100644 --- a/crates/bevy_asset/src/server/mod.rs +++ b/crates/bevy_asset/src/server/mod.rs @@ -2,9 +2,6 @@ mod info; mod loaders; use crate::{ - Asset, AssetEvent, AssetHandleProvider, AssetId, AssetLoadFailedEvent, AssetMetaCheck, Assets, - CompleteErasedLoadedAsset, DeserializeMetaError, ErasedLoadedAsset, Handle, LoadedUntypedAsset, - UntypedAssetId, UntypedAssetLoadFailedEvent, UntypedHandle, folder::LoadedFolder, io::{ AssetReaderError, AssetSource, AssetSourceEvent, AssetSourceId, AssetSources, @@ -12,10 +9,13 @@ use crate::{ }, loader::{AssetLoader, ErasedAssetLoader, LoadContext, LoadedAsset}, meta::{ - AssetActionMinimal, AssetMetaDyn, AssetMetaMinimal, MetaTransform, Settings, - loader_settings_meta_transform, + loader_settings_meta_transform, AssetActionMinimal, AssetMetaDyn, AssetMetaMinimal, + MetaTransform, Settings, }, path::AssetPath, + Asset, AssetEvent, AssetHandleProvider, AssetId, AssetLoadFailedEvent, AssetMetaCheck, Assets, + CompleteErasedLoadedAsset, DeserializeMetaError, ErasedLoadedAsset, Handle, LoadedUntypedAsset, + UntypedAssetId, UntypedAssetLoadFailedEvent, UntypedHandle, }; use alloc::{borrow::ToOwned, boxed::Box, vec, vec::Vec}; use alloc::{ @@ -1261,12 +1261,12 @@ impl AssetServer { AssetActionMinimal::Process { .. } => { return Err(AssetLoadError::CannotLoadProcessedAsset { path: asset_path.clone_owned(), - }); + }) } AssetActionMinimal::Ignore => { return Err(AssetLoadError::CannotLoadIgnoredAsset { path: asset_path.clone_owned(), - }); + }) } }; let loader = self.get_asset_loader_with_type_name(&loader_name).await?; @@ -1742,18 +1742,14 @@ impl RecursiveDependencyLoadState { reason = "Adding docs to the variants would not add information beyond the error message and the names" )] pub enum AssetLoadError { - #[error( - "Requested handle of type {requested:?} for asset '{path}' does not match actual asset type '{actual_asset_name}', which used loader '{loader_name}'" - )] + #[error("Requested handle of type {requested:?} for asset '{path}' does not match actual asset type '{actual_asset_name}', which used loader '{loader_name}'")] RequestedHandleTypeMismatch { path: AssetPath<'static>, requested: TypeId, actual_asset_name: &'static str, loader_name: &'static str, }, - #[error( - "Could not find an asset loader matching: Loader Name: {loader_name:?}; Asset Type: {loader_name:?}; Extension: {extension:?}; Path: {asset_path:?};" - )] + #[error("Could not find an asset loader matching: Loader Name: {loader_name:?}; Asset Type: {loader_name:?}; Extension: {extension:?}; Path: {asset_path:?};")] MissingAssetLoader { loader_name: Option, asset_type_id: Option, diff --git a/crates/bevy_asset/src/transformer.rs b/crates/bevy_asset/src/transformer.rs index 7eed5b565a2a3..d2573582f16f0 100644 --- a/crates/bevy_asset/src/transformer.rs +++ b/crates/bevy_asset/src/transformer.rs @@ -1,6 +1,6 @@ use crate::{ - Asset, CompleteErasedLoadedAsset, ErasedLoadedAsset, Handle, LabeledAsset, UntypedHandle, - meta::Settings, + meta::Settings, Asset, CompleteErasedLoadedAsset, ErasedLoadedAsset, Handle, LabeledAsset, + UntypedHandle, }; use alloc::boxed::Box; use atomicow::CowArc; diff --git a/crates/bevy_audio/src/audio_source.rs b/crates/bevy_audio/src/audio_source.rs index 250e0df4e7db5..9cf3ca988b0b1 100644 --- a/crates/bevy_audio/src/audio_source.rs +++ b/crates/bevy_audio/src/audio_source.rs @@ -1,5 +1,5 @@ use alloc::sync::Arc; -use bevy_asset::{Asset, AssetLoader, LoadContext, io::Reader}; +use bevy_asset::{io::Reader, Asset, AssetLoader, LoadContext}; use bevy_reflect::TypePath; use std::io::Cursor; diff --git a/crates/bevy_audio/src/lib.rs b/crates/bevy_audio/src/lib.rs index 3f57cf6f24661..babae2f8a9be9 100644 --- a/crates/bevy_audio/src/lib.rs +++ b/crates/bevy_audio/src/lib.rs @@ -52,7 +52,7 @@ pub use audio_source::*; pub use pitch::*; pub use volume::*; -pub use rodio::{Sample, cpal::Sample as CpalSample, source::Source}; +pub use rodio::{cpal::Sample as CpalSample, source::Source, Sample}; pub use sinks::*; use bevy_app::prelude::*; diff --git a/crates/bevy_audio/src/pitch.rs b/crates/bevy_audio/src/pitch.rs index e511356b9d662..d85b9b31cf071 100644 --- a/crates/bevy_audio/src/pitch.rs +++ b/crates/bevy_audio/src/pitch.rs @@ -2,8 +2,8 @@ use crate::Decodable; use bevy_asset::Asset; use bevy_reflect::TypePath; use rodio::{ - Source, source::{SineWave, TakeDuration}, + Source, }; /// A source of sine wave sound diff --git a/crates/bevy_color/src/color.rs b/crates/bevy_color/src/color.rs index c2995daea95a7..d4754d204eff5 100644 --- a/crates/bevy_color/src/color.rs +++ b/crates/bevy_color/src/color.rs @@ -1,6 +1,6 @@ use crate::{ - Alpha, Hsla, Hsva, Hue, Hwba, Laba, Lcha, LinearRgba, Luminance, Mix, Oklaba, Oklcha, Srgba, - StandardColor, Xyza, color_difference::EuclideanDistance, + color_difference::EuclideanDistance, Alpha, Hsla, Hsva, Hue, Hwba, Laba, Lcha, LinearRgba, + Luminance, Mix, Oklaba, Oklcha, Srgba, StandardColor, Xyza, }; #[cfg(feature = "bevy_reflect")] use bevy_reflect::prelude::*; diff --git a/crates/bevy_color/src/color_gradient.rs b/crates/bevy_color/src/color_gradient.rs index 5fa2c2c894f75..b087205bb6b49 100644 --- a/crates/bevy_color/src/color_gradient.rs +++ b/crates/bevy_color/src/color_gradient.rs @@ -1,8 +1,8 @@ use crate::Mix; use alloc::vec::Vec; use bevy_math::curve::{ - Curve, Interval, cores::{EvenCore, EvenCoreError}, + Curve, Interval, }; /// A curve whose samples are defined by a collection of colors. @@ -75,7 +75,7 @@ where #[cfg(test)] mod tests { use super::*; - use crate::{Srgba, palettes::basic}; + use crate::{palettes::basic, Srgba}; use bevy_math::curve::{Curve, CurveExt}; #[test] diff --git a/crates/bevy_color/src/color_ops.rs b/crates/bevy_color/src/color_ops.rs index 745a4c9c27d63..235c8c8bf3ae1 100644 --- a/crates/bevy_color/src/color_ops.rs +++ b/crates/bevy_color/src/color_ops.rs @@ -1,4 +1,4 @@ -use bevy_math::{Vec3, Vec4, ops}; +use bevy_math::{ops, Vec3, Vec4}; /// Methods for changing the luminance of a color. Note that these methods are not /// guaranteed to produce consistent results across color spaces, @@ -140,7 +140,7 @@ mod tests { use core::fmt::Debug; use super::*; - use crate::{Hsla, testing::assert_approx_eq}; + use crate::{testing::assert_approx_eq, Hsla}; #[test] fn test_rotate_hue() { diff --git a/crates/bevy_color/src/color_range.rs b/crates/bevy_color/src/color_range.rs index 8448eb187ccd7..48afa5418225d 100644 --- a/crates/bevy_color/src/color_range.rs +++ b/crates/bevy_color/src/color_range.rs @@ -22,7 +22,7 @@ impl ColorRange for Range { #[cfg(test)] mod tests { use super::*; - use crate::{LinearRgba, Srgba, palettes::basic}; + use crate::{palettes::basic, LinearRgba, Srgba}; #[test] fn test_color_range() { diff --git a/crates/bevy_color/src/hwba.rs b/crates/bevy_color/src/hwba.rs index 10c22121fd033..459b5d82dc4fd 100644 --- a/crates/bevy_color/src/hwba.rs +++ b/crates/bevy_color/src/hwba.rs @@ -5,7 +5,7 @@ use crate::{ Alpha, ColorToComponents, Gray, Hue, Lcha, LinearRgba, Mix, Srgba, StandardColor, Xyza, }; -use bevy_math::{Vec3, Vec4, ops}; +use bevy_math::{ops, Vec3, Vec4}; #[cfg(feature = "bevy_reflect")] use bevy_reflect::prelude::*; diff --git a/crates/bevy_color/src/laba.rs b/crates/bevy_color/src/laba.rs index b09f86b4a7028..39ac37f8ffa1a 100644 --- a/crates/bevy_color/src/laba.rs +++ b/crates/bevy_color/src/laba.rs @@ -1,8 +1,8 @@ use crate::{ - Alpha, ColorToComponents, Gray, Hsla, Hsva, Hwba, LinearRgba, Luminance, Mix, Oklaba, Srgba, - StandardColor, Xyza, impl_componentwise_vector_space, + impl_componentwise_vector_space, Alpha, ColorToComponents, Gray, Hsla, Hsva, Hwba, LinearRgba, + Luminance, Mix, Oklaba, Srgba, StandardColor, Xyza, }; -use bevy_math::{Vec3, Vec4, ops}; +use bevy_math::{ops, Vec3, Vec4}; #[cfg(feature = "bevy_reflect")] use bevy_reflect::prelude::*; diff --git a/crates/bevy_color/src/lcha.rs b/crates/bevy_color/src/lcha.rs index 85b3c7c93d943..f1437d34969aa 100644 --- a/crates/bevy_color/src/lcha.rs +++ b/crates/bevy_color/src/lcha.rs @@ -2,7 +2,7 @@ use crate::{ Alpha, ColorToComponents, Gray, Hue, Laba, LinearRgba, Luminance, Mix, Srgba, StandardColor, Xyza, }; -use bevy_math::{Vec3, Vec4, ops}; +use bevy_math::{ops, Vec3, Vec4}; #[cfg(feature = "bevy_reflect")] use bevy_reflect::prelude::*; @@ -279,7 +279,11 @@ impl From for Lcha { let h = { let h = ops::atan2(b.to_radians(), a.to_radians()).to_degrees(); - if h < 0.0 { h + 360.0 } else { h } + if h < 0.0 { + h + 360.0 + } else { + h + } }; let chroma = c.clamp(0.0, 1.5); diff --git a/crates/bevy_color/src/linear_rgba.rs b/crates/bevy_color/src/linear_rgba.rs index a2dda83568e52..d1781bfc4192c 100644 --- a/crates/bevy_color/src/linear_rgba.rs +++ b/crates/bevy_color/src/linear_rgba.rs @@ -1,8 +1,8 @@ use crate::{ - Alpha, ColorToComponents, ColorToPacked, Gray, Luminance, Mix, StandardColor, - color_difference::EuclideanDistance, impl_componentwise_vector_space, + color_difference::EuclideanDistance, impl_componentwise_vector_space, Alpha, ColorToComponents, + ColorToPacked, Gray, Luminance, Mix, StandardColor, }; -use bevy_math::{Vec3, Vec4, ops}; +use bevy_math::{ops, Vec3, Vec4}; #[cfg(feature = "bevy_reflect")] use bevy_reflect::prelude::*; use bytemuck::{Pod, Zeroable}; diff --git a/crates/bevy_color/src/oklaba.rs b/crates/bevy_color/src/oklaba.rs index d4af0870e4efa..1281109d02a96 100644 --- a/crates/bevy_color/src/oklaba.rs +++ b/crates/bevy_color/src/oklaba.rs @@ -1,8 +1,8 @@ use crate::{ - Alpha, ColorToComponents, Gray, Hsla, Hsva, Hwba, Lcha, LinearRgba, Luminance, Mix, Srgba, - StandardColor, Xyza, color_difference::EuclideanDistance, impl_componentwise_vector_space, + color_difference::EuclideanDistance, impl_componentwise_vector_space, Alpha, ColorToComponents, + Gray, Hsla, Hsva, Hwba, Lcha, LinearRgba, Luminance, Mix, Srgba, StandardColor, Xyza, }; -use bevy_math::{FloatPow, Vec3, Vec4, ops}; +use bevy_math::{ops, FloatPow, Vec3, Vec4}; #[cfg(feature = "bevy_reflect")] use bevy_reflect::prelude::*; diff --git a/crates/bevy_color/src/oklcha.rs b/crates/bevy_color/src/oklcha.rs index 194e775f00d29..70c150ed0fc97 100644 --- a/crates/bevy_color/src/oklcha.rs +++ b/crates/bevy_color/src/oklcha.rs @@ -1,8 +1,8 @@ use crate::{ - Alpha, ColorToComponents, Gray, Hsla, Hsva, Hue, Hwba, Laba, Lcha, LinearRgba, Luminance, Mix, - Oklaba, Srgba, StandardColor, Xyza, color_difference::EuclideanDistance, + color_difference::EuclideanDistance, Alpha, ColorToComponents, Gray, Hsla, Hsva, Hue, Hwba, + Laba, Lcha, LinearRgba, Luminance, Mix, Oklaba, Srgba, StandardColor, Xyza, }; -use bevy_math::{FloatPow, Vec3, Vec4, ops}; +use bevy_math::{ops, FloatPow, Vec3, Vec4}; #[cfg(feature = "bevy_reflect")] use bevy_reflect::prelude::*; diff --git a/crates/bevy_color/src/srgba.rs b/crates/bevy_color/src/srgba.rs index 0821d88d53a4c..49e40792b7d3e 100644 --- a/crates/bevy_color/src/srgba.rs +++ b/crates/bevy_color/src/srgba.rs @@ -1,10 +1,10 @@ use crate::{ - Alpha, ColorToComponents, ColorToPacked, Gray, LinearRgba, Luminance, Mix, StandardColor, Xyza, - color_difference::EuclideanDistance, impl_componentwise_vector_space, + color_difference::EuclideanDistance, impl_componentwise_vector_space, Alpha, ColorToComponents, + ColorToPacked, Gray, LinearRgba, Luminance, Mix, StandardColor, Xyza, }; #[cfg(feature = "alloc")] use alloc::{format, string::String}; -use bevy_math::{Vec3, Vec4, ops}; +use bevy_math::{ops, Vec3, Vec4}; #[cfg(feature = "bevy_reflect")] use bevy_reflect::prelude::*; use thiserror::Error; diff --git a/crates/bevy_color/src/xyza.rs b/crates/bevy_color/src/xyza.rs index d6a831b899c8d..a9fb422bef110 100644 --- a/crates/bevy_color/src/xyza.rs +++ b/crates/bevy_color/src/xyza.rs @@ -1,6 +1,6 @@ use crate::{ - Alpha, ColorToComponents, Gray, LinearRgba, Luminance, Mix, StandardColor, - impl_componentwise_vector_space, + impl_componentwise_vector_space, Alpha, ColorToComponents, Gray, LinearRgba, Luminance, Mix, + StandardColor, }; use bevy_math::{Vec3, Vec4}; #[cfg(feature = "bevy_reflect")] @@ -245,8 +245,8 @@ impl From for LinearRgba { mod tests { use super::*; use crate::{ - Srgba, color_difference::EuclideanDistance, test_colors::TEST_COLORS, - testing::assert_approx_eq, + color_difference::EuclideanDistance, test_colors::TEST_COLORS, testing::assert_approx_eq, + Srgba, }; #[test] diff --git a/crates/bevy_core_pipeline/src/auto_exposure/buffers.rs b/crates/bevy_core_pipeline/src/auto_exposure/buffers.rs index b0492b74ab397..cc16cd4630d6d 100644 --- a/crates/bevy_core_pipeline/src/auto_exposure/buffers.rs +++ b/crates/bevy_core_pipeline/src/auto_exposure/buffers.rs @@ -1,13 +1,13 @@ use bevy_ecs::prelude::*; -use bevy_platform_support::collections::{HashMap, hash_map::Entry}; +use bevy_platform_support::collections::{hash_map::Entry, HashMap}; use bevy_render::{ - Extract, render_resource::{StorageBuffer, UniformBuffer}, renderer::{RenderDevice, RenderQueue}, sync_world::RenderEntity, + Extract, }; -use super::{AutoExposure, pipeline::AutoExposureUniform}; +use super::{pipeline::AutoExposureUniform, AutoExposure}; #[derive(Resource, Default)] pub(super) struct AutoExposureBuffers { diff --git a/crates/bevy_core_pipeline/src/auto_exposure/compensation_curve.rs b/crates/bevy_core_pipeline/src/auto_exposure/compensation_curve.rs index 0028a721442ce..7a89de331c19c 100644 --- a/crates/bevy_core_pipeline/src/auto_exposure/compensation_curve.rs +++ b/crates/bevy_core_pipeline/src/auto_exposure/compensation_curve.rs @@ -1,6 +1,6 @@ use bevy_asset::prelude::*; -use bevy_ecs::system::{SystemParamItem, lifetimeless::SRes}; -use bevy_math::{FloatExt, Vec2, cubic_splines::CubicGenerator}; +use bevy_ecs::system::{lifetimeless::SRes, SystemParamItem}; +use bevy_math::{cubic_splines::CubicGenerator, FloatExt, Vec2}; use bevy_reflect::prelude::*; use bevy_render::{ render_asset::{RenderAsset, RenderAssetUsages}, diff --git a/crates/bevy_core_pipeline/src/auto_exposure/mod.rs b/crates/bevy_core_pipeline/src/auto_exposure/mod.rs index ffe41663c334d..f94a61d09be16 100644 --- a/crates/bevy_core_pipeline/src/auto_exposure/mod.rs +++ b/crates/bevy_core_pipeline/src/auto_exposure/mod.rs @@ -1,8 +1,7 @@ use bevy_app::prelude::*; -use bevy_asset::{AssetApp, Assets, Handle, load_internal_asset}; +use bevy_asset::{load_internal_asset, AssetApp, Assets, Handle}; use bevy_ecs::prelude::*; use bevy_render::{ - ExtractSchedule, Render, RenderApp, RenderSet, extract_component::ExtractComponentPlugin, render_asset::RenderAssetPlugin, render_graph::RenderGraphApp, @@ -10,6 +9,7 @@ use bevy_render::{ Buffer, BufferDescriptor, BufferUsages, PipelineCache, Shader, SpecializedComputePipelines, }, renderer::RenderDevice, + ExtractSchedule, Render, RenderApp, RenderSet, }; mod buffers; @@ -18,11 +18,11 @@ mod node; mod pipeline; mod settings; -use buffers::{AutoExposureBuffers, extract_buffers, prepare_buffers}; +use buffers::{extract_buffers, prepare_buffers, AutoExposureBuffers}; pub use compensation_curve::{AutoExposureCompensationCurve, AutoExposureCompensationCurveError}; use node::AutoExposureNode; use pipeline::{ - AutoExposurePass, AutoExposurePipeline, METERING_SHADER_HANDLE, ViewAutoExposurePipeline, + AutoExposurePass, AutoExposurePipeline, ViewAutoExposurePipeline, METERING_SHADER_HANDLE, }; pub use settings::AutoExposure; diff --git a/crates/bevy_core_pipeline/src/auto_exposure/node.rs b/crates/bevy_core_pipeline/src/auto_exposure/node.rs index 171d2aa5ea8ea..222efe5c62bd0 100644 --- a/crates/bevy_core_pipeline/src/auto_exposure/node.rs +++ b/crates/bevy_core_pipeline/src/auto_exposure/node.rs @@ -1,8 +1,8 @@ use super::{ - AutoExposureResources, buffers::AutoExposureBuffers, compensation_curve::GpuAutoExposureCompensationCurve, pipeline::{AutoExposurePipeline, ViewAutoExposurePipeline}, + AutoExposureResources, }; use bevy_ecs::{ query::QueryState, diff --git a/crates/bevy_core_pipeline/src/auto_exposure/settings.rs b/crates/bevy_core_pipeline/src/auto_exposure/settings.rs index e938989f9ff85..b5039030ac969 100644 --- a/crates/bevy_core_pipeline/src/auto_exposure/settings.rs +++ b/crates/bevy_core_pipeline/src/auto_exposure/settings.rs @@ -4,7 +4,7 @@ use super::compensation_curve::AutoExposureCompensationCurve; use bevy_asset::Handle; use bevy_ecs::{prelude::Component, reflect::ReflectComponent}; use bevy_image::Image; -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::extract_component::ExtractComponent; use bevy_utils::default; diff --git a/crates/bevy_core_pipeline/src/blit/mod.rs b/crates/bevy_core_pipeline/src/blit/mod.rs index 8dc4bb57bfa28..53c54c6d2d7aa 100644 --- a/crates/bevy_core_pipeline/src/blit/mod.rs +++ b/crates/bevy_core_pipeline/src/blit/mod.rs @@ -1,13 +1,13 @@ use bevy_app::{App, Plugin}; -use bevy_asset::{Handle, load_internal_asset, weak_handle}; +use bevy_asset::{load_internal_asset, weak_handle, Handle}; use bevy_ecs::prelude::*; use bevy_render::{ - RenderApp, render_resource::{ binding_types::{sampler, texture_2d}, *, }, renderer::RenderDevice, + RenderApp, }; use crate::fullscreen_vertex_shader::fullscreen_shader_vertex_state; diff --git a/crates/bevy_core_pipeline/src/bloom/downsampling_pipeline.rs b/crates/bevy_core_pipeline/src/bloom/downsampling_pipeline.rs index cbbc0da4680f4..544b420bfdb68 100644 --- a/crates/bevy_core_pipeline/src/bloom/downsampling_pipeline.rs +++ b/crates/bevy_core_pipeline/src/bloom/downsampling_pipeline.rs @@ -1,4 +1,4 @@ -use super::{BLOOM_SHADER_HANDLE, BLOOM_TEXTURE_FORMAT, Bloom}; +use super::{Bloom, BLOOM_SHADER_HANDLE, BLOOM_TEXTURE_FORMAT}; use crate::fullscreen_vertex_shader::fullscreen_shader_vertex_state; use bevy_ecs::{ prelude::{Component, Entity}, diff --git a/crates/bevy_core_pipeline/src/bloom/mod.rs b/crates/bevy_core_pipeline/src/bloom/mod.rs index a64323517bae9..295b04c6ad0f1 100644 --- a/crates/bevy_core_pipeline/src/bloom/mod.rs +++ b/crates/bevy_core_pipeline/src/bloom/mod.rs @@ -10,11 +10,10 @@ use crate::{ core_3d::graph::{Core3d, Node3d}, }; use bevy_app::{App, Plugin}; -use bevy_asset::{Handle, load_internal_asset, weak_handle}; +use bevy_asset::{load_internal_asset, weak_handle, Handle}; use bevy_ecs::{prelude::*, query::QueryItem}; -use bevy_math::{UVec2, ops}; +use bevy_math::{ops, UVec2}; use bevy_render::{ - Render, RenderApp, RenderSet, camera::ExtractedCamera, diagnostic::RecordDiagnostics, extract_component::{ @@ -25,13 +24,14 @@ use bevy_render::{ renderer::{RenderContext, RenderDevice}, texture::{CachedTexture, TextureCache}, view::ViewTarget, + Render, RenderApp, RenderSet, }; use downsampling_pipeline::{ - BloomDownsamplingPipeline, BloomDownsamplingPipelineIds, BloomUniforms, - prepare_downsampling_pipeline, + prepare_downsampling_pipeline, BloomDownsamplingPipeline, BloomDownsamplingPipelineIds, + BloomUniforms, }; use upsampling_pipeline::{ - BloomUpsamplingPipeline, UpsamplingPipelineIds, prepare_upsampling_pipeline, + prepare_upsampling_pipeline, BloomUpsamplingPipeline, UpsamplingPipelineIds, }; const BLOOM_SHADER_HANDLE: Handle = weak_handle!("c9190ddc-573b-4472-8b21-573cab502b73"); diff --git a/crates/bevy_core_pipeline/src/bloom/settings.rs b/crates/bevy_core_pipeline/src/bloom/settings.rs index fded0e5f2dcb8..2e22875a35f12 100644 --- a/crates/bevy_core_pipeline/src/bloom/settings.rs +++ b/crates/bevy_core_pipeline/src/bloom/settings.rs @@ -1,7 +1,7 @@ use super::downsampling_pipeline::BloomUniforms; use bevy_ecs::{prelude::Component, query::QueryItem, reflect::ReflectComponent}; use bevy_math::{AspectRatio, URect, UVec4, Vec2, Vec4}; -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::{extract_component::ExtractComponent, prelude::Camera}; /// Applies a bloom effect to an HDR-enabled 2d or 3d camera. diff --git a/crates/bevy_core_pipeline/src/bloom/upsampling_pipeline.rs b/crates/bevy_core_pipeline/src/bloom/upsampling_pipeline.rs index 6992636ea6ed1..e4c4ed4a647f9 100644 --- a/crates/bevy_core_pipeline/src/bloom/upsampling_pipeline.rs +++ b/crates/bevy_core_pipeline/src/bloom/upsampling_pipeline.rs @@ -1,6 +1,6 @@ use super::{ - BLOOM_SHADER_HANDLE, BLOOM_TEXTURE_FORMAT, Bloom, BloomCompositeMode, - downsampling_pipeline::BloomUniforms, + downsampling_pipeline::BloomUniforms, Bloom, BloomCompositeMode, BLOOM_SHADER_HANDLE, + BLOOM_TEXTURE_FORMAT, }; use crate::fullscreen_vertex_shader::fullscreen_shader_vertex_state; use bevy_ecs::{ diff --git a/crates/bevy_core_pipeline/src/contrast_adaptive_sharpening/mod.rs b/crates/bevy_core_pipeline/src/contrast_adaptive_sharpening/mod.rs index 60e4791e65883..586108469451f 100644 --- a/crates/bevy_core_pipeline/src/contrast_adaptive_sharpening/mod.rs +++ b/crates/bevy_core_pipeline/src/contrast_adaptive_sharpening/mod.rs @@ -4,12 +4,11 @@ use crate::{ fullscreen_vertex_shader::fullscreen_shader_vertex_state, }; use bevy_app::prelude::*; -use bevy_asset::{Handle, load_internal_asset, weak_handle}; +use bevy_asset::{load_internal_asset, weak_handle, Handle}; use bevy_ecs::{prelude::*, query::QueryItem}; use bevy_image::BevyDefault as _; -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::{ - Render, RenderApp, RenderSet, extract_component::{ExtractComponent, ExtractComponentPlugin, UniformComponentPlugin}, prelude::Camera, render_graph::RenderGraphApp, @@ -19,6 +18,7 @@ use bevy_render::{ }, renderer::RenderDevice, view::{ExtractedView, ViewTarget}, + Render, RenderApp, RenderSet, }; mod node; diff --git a/crates/bevy_core_pipeline/src/core_2d/camera_2d.rs b/crates/bevy_core_pipeline/src/core_2d/camera_2d.rs index d51aa2f1f9ce9..9780ddd31f63e 100644 --- a/crates/bevy_core_pipeline/src/core_2d/camera_2d.rs +++ b/crates/bevy_core_pipeline/src/core_2d/camera_2d.rs @@ -3,7 +3,7 @@ use crate::{ tonemapping::{DebandDither, Tonemapping}, }; use bevy_ecs::prelude::*; -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::{ camera::{Camera, CameraProjection, CameraRenderGraph, OrthographicProjection, Projection}, extract_component::ExtractComponent, diff --git a/crates/bevy_core_pipeline/src/core_2d/mod.rs b/crates/bevy_core_pipeline/src/core_2d/mod.rs index 7704bebd54799..f32775727772f 100644 --- a/crates/bevy_core_pipeline/src/core_2d/mod.rs +++ b/crates/bevy_core_pipeline/src/core_2d/mod.rs @@ -48,14 +48,13 @@ use bevy_app::{App, Plugin}; use bevy_ecs::prelude::*; use bevy_math::FloatOrd; use bevy_render::{ - Extract, ExtractSchedule, Render, RenderApp, RenderSet, camera::{Camera, ExtractedCamera}, extract_component::ExtractComponentPlugin, render_graph::{EmptyNode, RenderGraphApp, ViewNodeRunner}, render_phase::{ - BinnedPhaseItem, CachedRenderPipelinePhaseItem, DrawFunctionId, DrawFunctions, PhaseItem, - PhaseItemExtraIndex, SortedPhaseItem, ViewBinnedRenderPhases, ViewSortedRenderPhases, - sort_phase_system, + sort_phase_system, BinnedPhaseItem, CachedRenderPipelinePhaseItem, DrawFunctionId, + DrawFunctions, PhaseItem, PhaseItemExtraIndex, SortedPhaseItem, ViewBinnedRenderPhases, + ViewSortedRenderPhases, }, render_resource::{ BindGroupId, CachedRenderPipelineId, Extent3d, TextureDescriptor, TextureDimension, @@ -65,6 +64,7 @@ use bevy_render::{ sync_world::MainEntity, texture::TextureCache, view::{Msaa, ViewDepthTexture}, + Extract, ExtractSchedule, Render, RenderApp, RenderSet, }; use self::graph::{Core2d, Node2d}; diff --git a/crates/bevy_core_pipeline/src/core_3d/camera_3d.rs b/crates/bevy_core_pipeline/src/core_3d/camera_3d.rs index 20fce333acb1b..418d3b8d482a3 100644 --- a/crates/bevy_core_pipeline/src/core_3d/camera_3d.rs +++ b/crates/bevy_core_pipeline/src/core_3d/camera_3d.rs @@ -3,7 +3,7 @@ use crate::{ tonemapping::{DebandDither, Tonemapping}, }; use bevy_ecs::prelude::*; -use bevy_reflect::{Reflect, ReflectDeserialize, ReflectSerialize, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect, ReflectDeserialize, ReflectSerialize}; use bevy_render::{ camera::{Camera, CameraRenderGraph, Exposure, Projection}, extract_component::ExtractComponent, diff --git a/crates/bevy_core_pipeline/src/core_3d/mod.rs b/crates/bevy_core_pipeline/src/core_3d/mod.rs index f748a729dcb3c..fa092b7fd494c 100644 --- a/crates/bevy_core_pipeline/src/core_3d/mod.rs +++ b/crates/bevy_core_pipeline/src/core_3d/mod.rs @@ -74,7 +74,7 @@ use bevy_render::{ experimental::occlusion_culling::OcclusionCulling, mesh::allocator::SlabId, render_phase::PhaseItemBatchSetKey, - view::{NoIndirectDrawing, RetainedViewEntity, prepare_view_targets}, + view::{prepare_view_targets, NoIndirectDrawing, RetainedViewEntity}, }; pub use camera_3d::*; pub use main_opaque_pass_3d_node::*; @@ -88,15 +88,14 @@ use bevy_image::BevyDefault; use bevy_math::FloatOrd; use bevy_platform_support::collections::{HashMap, HashSet}; use bevy_render::{ - Extract, ExtractSchedule, Render, RenderApp, RenderSet, camera::{Camera, ExtractedCamera}, extract_component::ExtractComponentPlugin, prelude::Msaa, render_graph::{EmptyNode, RenderGraphApp, ViewNodeRunner}, render_phase::{ - BinnedPhaseItem, CachedRenderPipelinePhaseItem, DrawFunctionId, DrawFunctions, PhaseItem, - PhaseItemExtraIndex, SortedPhaseItem, ViewBinnedRenderPhases, ViewSortedRenderPhases, - sort_phase_system, + sort_phase_system, BinnedPhaseItem, CachedRenderPipelinePhaseItem, DrawFunctionId, + DrawFunctions, PhaseItem, PhaseItemExtraIndex, SortedPhaseItem, ViewBinnedRenderPhases, + ViewSortedRenderPhases, }, render_resource::{ CachedRenderPipelineId, Extent3d, FilterMode, Sampler, SamplerDescriptor, Texture, @@ -106,6 +105,7 @@ use bevy_render::{ sync_world::{MainEntity, RenderEntity}, texture::{ColorAttachment, TextureCache}, view::{ExtractedView, ViewDepthTexture, ViewTarget}, + Extract, ExtractSchedule, Render, RenderApp, RenderSet, }; use nonmax::NonMaxU32; use tracing::warn; @@ -113,17 +113,17 @@ use tracing::warn; use crate::{ core_3d::main_transmissive_pass_3d_node::MainTransmissivePass3dNode, deferred::{ - AlphaMask3dDeferred, DEFERRED_LIGHTING_PASS_ID_FORMAT, DEFERRED_PREPASS_FORMAT, - Opaque3dDeferred, copy_lighting_id::CopyDeferredLightingIdNode, node::{EarlyDeferredGBufferPrepassNode, LateDeferredGBufferPrepassNode}, + AlphaMask3dDeferred, Opaque3dDeferred, DEFERRED_LIGHTING_PASS_ID_FORMAT, + DEFERRED_PREPASS_FORMAT, }, dof::DepthOfFieldNode, prepass::{ - AlphaMask3dPrepass, DeferredPrepass, DepthPrepass, MOTION_VECTOR_PREPASS_FORMAT, - MotionVectorPrepass, NORMAL_PREPASS_FORMAT, NormalPrepass, Opaque3dPrepass, - OpaqueNoLightmap3dBatchSetKey, OpaqueNoLightmap3dBinKey, ViewPrepassTextures, node::{EarlyPrepassNode, LatePrepassNode}, + AlphaMask3dPrepass, DeferredPrepass, DepthPrepass, MotionVectorPrepass, NormalPrepass, + Opaque3dPrepass, OpaqueNoLightmap3dBatchSetKey, OpaqueNoLightmap3dBinKey, + ViewPrepassTextures, MOTION_VECTOR_PREPASS_FORMAT, NORMAL_PREPASS_FORMAT, }, skybox::SkyboxPlugin, tonemapping::TonemappingNode, diff --git a/crates/bevy_core_pipeline/src/deferred/copy_lighting_id.rs b/crates/bevy_core_pipeline/src/deferred/copy_lighting_id.rs index 7df4ed4a027c4..966be880c28ce 100644 --- a/crates/bevy_core_pipeline/src/deferred/copy_lighting_id.rs +++ b/crates/bevy_core_pipeline/src/deferred/copy_lighting_id.rs @@ -3,16 +3,16 @@ use crate::{ prepass::{DeferredPrepass, ViewPrepassTextures}, }; use bevy_app::prelude::*; -use bevy_asset::{Handle, load_internal_asset, weak_handle}; +use bevy_asset::{load_internal_asset, weak_handle, Handle}; use bevy_ecs::prelude::*; use bevy_math::UVec2; use bevy_render::{ - Render, RenderApp, RenderSet, camera::ExtractedCamera, render_resource::{binding_types::texture_2d, *}, renderer::RenderDevice, texture::{CachedTexture, TextureCache}, view::ViewTarget, + Render, RenderApp, RenderSet, }; use bevy_ecs::query::QueryItem; diff --git a/crates/bevy_core_pipeline/src/dof/mod.rs b/crates/bevy_core_pipeline/src/dof/mod.rs index 2e8128704e207..028bc97350f56 100644 --- a/crates/bevy_core_pipeline/src/dof/mod.rs +++ b/crates/bevy_core_pipeline/src/dof/mod.rs @@ -15,7 +15,7 @@ //! [Depth of field]: https://en.wikipedia.org/wiki/Depth_of_field use bevy_app::{App, Plugin}; -use bevy_asset::{Handle, load_internal_asset, weak_handle}; +use bevy_asset::{load_internal_asset, weak_handle, Handle}; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::{ component::Component, @@ -24,38 +24,38 @@ use bevy_ecs::{ reflect::ReflectComponent, resource::Resource, schedule::IntoSystemConfigs as _, - system::{Commands, Query, Res, ResMut, lifetimeless::Read}, + system::{lifetimeless::Read, Commands, Query, Res, ResMut}, world::{FromWorld, World}, }; use bevy_image::BevyDefault as _; use bevy_math::ops; -use bevy_reflect::{Reflect, prelude::ReflectDefault}; +use bevy_reflect::{prelude::ReflectDefault, Reflect}; use bevy_render::{ - Extract, ExtractSchedule, Render, RenderApp, RenderSet, camera::{PhysicalCameraParameters, Projection}, extract_component::{ComponentUniforms, DynamicUniformIndex, UniformComponentPlugin}, render_graph::{ NodeRunError, RenderGraphApp as _, RenderGraphContext, ViewNode, ViewNodeRunner, }, render_resource::{ + binding_types::{ + sampler, texture_2d, texture_depth_2d, texture_depth_2d_multisampled, uniform_buffer, + }, BindGroup, BindGroupEntries, BindGroupLayout, BindGroupLayoutEntries, CachedRenderPipelineId, ColorTargetState, ColorWrites, FilterMode, FragmentState, LoadOp, Operations, PipelineCache, RenderPassColorAttachment, RenderPassDescriptor, RenderPipelineDescriptor, Sampler, SamplerBindingType, SamplerDescriptor, Shader, ShaderStages, ShaderType, SpecializedRenderPipeline, SpecializedRenderPipelines, StoreOp, TextureDescriptor, TextureDimension, TextureFormat, TextureSampleType, TextureUsages, - binding_types::{ - sampler, texture_2d, texture_depth_2d, texture_depth_2d_multisampled, uniform_buffer, - }, }, renderer::{RenderContext, RenderDevice}, sync_component::SyncComponentPlugin, sync_world::RenderEntity, texture::{CachedTexture, TextureCache}, view::{ - ExtractedView, Msaa, ViewDepthTexture, ViewTarget, ViewUniform, ViewUniformOffset, - ViewUniforms, prepare_view_targets, + prepare_view_targets, ExtractedView, Msaa, ViewDepthTexture, ViewTarget, ViewUniform, + ViewUniformOffset, ViewUniforms, }, + Extract, ExtractSchedule, Render, RenderApp, RenderSet, }; use bevy_utils::{default, once}; use smallvec::SmallVec; @@ -63,8 +63,8 @@ use tracing::{info, warn}; use crate::{ core_3d::{ - Camera3d, DEPTH_TEXTURE_SAMPLING_SUPPORTED, graph::{Core3d, Node3d}, + Camera3d, DEPTH_TEXTURE_SAMPLING_SUPPORTED, }, fullscreen_vertex_shader::fullscreen_shader_vertex_state, }; diff --git a/crates/bevy_core_pipeline/src/experimental/mip_generation/mod.rs b/crates/bevy_core_pipeline/src/experimental/mip_generation/mod.rs index 642c8b1b1fd9f..f324193983f3c 100644 --- a/crates/bevy_core_pipeline/src/experimental/mip_generation/mod.rs +++ b/crates/bevy_core_pipeline/src/experimental/mip_generation/mod.rs @@ -8,26 +8,26 @@ use core::array; use bevy_app::{App, Plugin}; -use bevy_asset::{Handle, load_internal_asset, weak_handle}; +use bevy_asset::{load_internal_asset, weak_handle, Handle}; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::{ component::Component, entity::Entity, - prelude::{Without, resource_exists}, + prelude::{resource_exists, Without}, query::{Or, QueryState, With}, resource::Resource, schedule::IntoSystemConfigs as _, - system::{Commands, Local, Query, Res, ResMut, lifetimeless::Read}, + system::{lifetimeless::Read, Commands, Local, Query, Res, ResMut}, world::{FromWorld, World}, }; -use bevy_math::{UVec2, Vec4Swizzles as _, uvec2}; +use bevy_math::{uvec2, UVec2, Vec4Swizzles as _}; use bevy_render::{ - Render, RenderApp, RenderSet, experimental::occlusion_culling::{ OcclusionCulling, OcclusionCullingSubview, OcclusionCullingSubviewEntities, }, render_graph::{Node, NodeRunError, RenderGraphApp, RenderGraphContext}, render_resource::{ + binding_types::{sampler, texture_2d, texture_2d_multisampled, texture_storage_2d}, BindGroup, BindGroupEntries, BindGroupLayout, BindGroupLayoutEntries, CachedComputePipelineId, ComputePassDescriptor, ComputePipeline, ComputePipelineDescriptor, DownlevelFlags, Extent3d, IntoBinding, PipelineCache, PushConstantRange, Sampler, @@ -35,11 +35,11 @@ use bevy_render::{ SpecializedComputePipelines, StorageTextureAccess, TextureAspect, TextureDescriptor, TextureDimension, TextureFormat, TextureSampleType, TextureUsages, TextureView, TextureViewDescriptor, TextureViewDimension, - binding_types::{sampler, texture_2d, texture_2d_multisampled, texture_storage_2d}, }, renderer::{RenderAdapter, RenderContext, RenderDevice}, texture::TextureCache, view::{ExtractedView, NoIndirectDrawing, ViewDepthTexture}, + Render, RenderApp, RenderSet, }; use bitflags::bitflags; diff --git a/crates/bevy_core_pipeline/src/fullscreen_vertex_shader/mod.rs b/crates/bevy_core_pipeline/src/fullscreen_vertex_shader/mod.rs index 80bfc9de1b37e..fee17d1ec6412 100644 --- a/crates/bevy_core_pipeline/src/fullscreen_vertex_shader/mod.rs +++ b/crates/bevy_core_pipeline/src/fullscreen_vertex_shader/mod.rs @@ -1,4 +1,4 @@ -use bevy_asset::{Handle, weak_handle}; +use bevy_asset::{weak_handle, Handle}; use bevy_render::{prelude::Shader, render_resource::VertexState}; pub const FULLSCREEN_SHADER_HANDLE: Handle = diff --git a/crates/bevy_core_pipeline/src/fxaa/mod.rs b/crates/bevy_core_pipeline/src/fxaa/mod.rs index 86c36d9f96e7d..b8904bb1f9ffc 100644 --- a/crates/bevy_core_pipeline/src/fxaa/mod.rs +++ b/crates/bevy_core_pipeline/src/fxaa/mod.rs @@ -4,12 +4,11 @@ use crate::{ fullscreen_vertex_shader::fullscreen_shader_vertex_state, }; use bevy_app::prelude::*; -use bevy_asset::{Handle, load_internal_asset, weak_handle}; +use bevy_asset::{load_internal_asset, weak_handle, Handle}; use bevy_ecs::prelude::*; use bevy_image::BevyDefault as _; -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::{ - Render, RenderApp, RenderSet, extract_component::{ExtractComponent, ExtractComponentPlugin}, prelude::Camera, render_graph::{RenderGraphApp, ViewNodeRunner}, @@ -19,6 +18,7 @@ use bevy_render::{ }, renderer::RenderDevice, view::{ExtractedView, ViewTarget}, + Render, RenderApp, RenderSet, }; use bevy_utils::default; diff --git a/crates/bevy_core_pipeline/src/motion_blur/mod.rs b/crates/bevy_core_pipeline/src/motion_blur/mod.rs index 962c3ae57e0f6..7703698f1ab10 100644 --- a/crates/bevy_core_pipeline/src/motion_blur/mod.rs +++ b/crates/bevy_core_pipeline/src/motion_blur/mod.rs @@ -7,20 +7,20 @@ use crate::{ prepass::{DepthPrepass, MotionVectorPrepass}, }; use bevy_app::{App, Plugin}; -use bevy_asset::{Handle, load_internal_asset, weak_handle}; +use bevy_asset::{load_internal_asset, weak_handle, Handle}; use bevy_ecs::{ - component::{Component, require}, + component::{require, Component}, query::With, reflect::ReflectComponent, schedule::IntoSystemConfigs, }; -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::{ - Render, RenderApp, RenderSet, camera::Camera, extract_component::{ExtractComponent, ExtractComponentPlugin, UniformComponentPlugin}, render_graph::{RenderGraphApp, ViewNodeRunner}, render_resource::{Shader, ShaderType, SpecializedRenderPipelines}, + Render, RenderApp, RenderSet, }; pub mod node; diff --git a/crates/bevy_core_pipeline/src/motion_blur/node.rs b/crates/bevy_core_pipeline/src/motion_blur/node.rs index ca0de254cbccf..2497bd633deda 100644 --- a/crates/bevy_core_pipeline/src/motion_blur/node.rs +++ b/crates/bevy_core_pipeline/src/motion_blur/node.rs @@ -14,8 +14,8 @@ use bevy_render::{ use crate::prepass::ViewPrepassTextures; use super::{ - MotionBlur, pipeline::{MotionBlurPipeline, MotionBlurPipelineId}, + MotionBlur, }; #[derive(Default)] diff --git a/crates/bevy_core_pipeline/src/motion_blur/pipeline.rs b/crates/bevy_core_pipeline/src/motion_blur/pipeline.rs index f92d054d0d986..61bb7b60ce42e 100644 --- a/crates/bevy_core_pipeline/src/motion_blur/pipeline.rs +++ b/crates/bevy_core_pipeline/src/motion_blur/pipeline.rs @@ -10,15 +10,15 @@ use bevy_image::BevyDefault as _; use bevy_render::{ globals::GlobalsUniform, render_resource::{ + binding_types::{ + sampler, texture_2d, texture_2d_multisampled, texture_depth_2d, + texture_depth_2d_multisampled, uniform_buffer_sized, + }, BindGroupLayout, BindGroupLayoutEntries, CachedRenderPipelineId, ColorTargetState, ColorWrites, FragmentState, MultisampleState, PipelineCache, PrimitiveState, RenderPipelineDescriptor, Sampler, SamplerBindingType, SamplerDescriptor, ShaderDefVal, ShaderStages, ShaderType, SpecializedRenderPipeline, SpecializedRenderPipelines, TextureFormat, TextureSampleType, - binding_types::{ - sampler, texture_2d, texture_2d_multisampled, texture_depth_2d, - texture_depth_2d_multisampled, uniform_buffer_sized, - }, }, renderer::RenderDevice, view::{ExtractedView, Msaa, ViewTarget}, @@ -26,7 +26,7 @@ use bevy_render::{ use crate::fullscreen_vertex_shader::fullscreen_shader_vertex_state; -use super::{MOTION_BLUR_SHADER_HANDLE, MotionBlur}; +use super::{MotionBlur, MOTION_BLUR_SHADER_HANDLE}; #[derive(Resource)] pub struct MotionBlurPipeline { diff --git a/crates/bevy_core_pipeline/src/msaa_writeback.rs b/crates/bevy_core_pipeline/src/msaa_writeback.rs index 403ec3cfd4b42..f9c543aeff03c 100644 --- a/crates/bevy_core_pipeline/src/msaa_writeback.rs +++ b/crates/bevy_core_pipeline/src/msaa_writeback.rs @@ -7,12 +7,12 @@ use bevy_app::{App, Plugin}; use bevy_color::LinearRgba; use bevy_ecs::{prelude::*, query::QueryItem}; use bevy_render::{ - Render, RenderApp, RenderSet, camera::ExtractedCamera, render_graph::{NodeRunError, RenderGraphApp, RenderGraphContext, ViewNode, ViewNodeRunner}, render_resource::*, renderer::RenderContext, view::{Msaa, ViewTarget}, + Render, RenderApp, RenderSet, }; /// This enables "msaa writeback" support for the `core_2d` and `core_3d` pipelines, which can be enabled on cameras diff --git a/crates/bevy_core_pipeline/src/oit/mod.rs b/crates/bevy_core_pipeline/src/oit/mod.rs index 3d17673d0c7c6..63083f5ed7f77 100644 --- a/crates/bevy_core_pipeline/src/oit/mod.rs +++ b/crates/bevy_core_pipeline/src/oit/mod.rs @@ -1,14 +1,13 @@ //! Order Independent Transparency (OIT) for 3d rendering. See [`OrderIndependentTransparencyPlugin`] for more details. use bevy_app::prelude::*; -use bevy_asset::{Handle, load_internal_asset, weak_handle}; +use bevy_asset::{load_internal_asset, weak_handle, Handle}; use bevy_ecs::{component::*, prelude::*}; use bevy_math::UVec2; use bevy_platform_support::collections::HashSet; use bevy_platform_support::time::Instant; use bevy_reflect::Reflect; use bevy_render::{ - Render, RenderApp, RenderSet, camera::{Camera, ExtractedCamera}, extract_component::{ExtractComponent, ExtractComponentPlugin}, render_graph::{RenderGraphApp, ViewNodeRunner}, @@ -17,17 +16,18 @@ use bevy_render::{ }, renderer::{RenderDevice, RenderQueue}, view::Msaa, + Render, RenderApp, RenderSet, }; use bevy_window::PrimaryWindow; use resolve::{ - OitResolvePlugin, node::{OitResolveNode, OitResolvePass}, + OitResolvePlugin, }; use tracing::{trace, warn}; use crate::core_3d::{ - Camera3d, graph::{Core3d, Node3d}, + Camera3d, }; /// Module that defines the necessary systems to resolve the OIT buffer and render it to the screen. @@ -74,12 +74,8 @@ impl Component for OrderIndependentTransparencySettings { Some(|world, context| { if let Some(value) = world.get::(context.entity) { if value.layer_count > 32 { - warn!( - "{}OrderIndependentTransparencySettings layer_count set to {} might be too high.", - context - .caller - .map(|location| format!("{location}: ")) - .unwrap_or_default(), + warn!("{}OrderIndependentTransparencySettings layer_count set to {} might be too high.", + context.caller.map(|location|format!("{location}: ")).unwrap_or_default(), value.layer_count ); } diff --git a/crates/bevy_core_pipeline/src/oit/resolve/mod.rs b/crates/bevy_core_pipeline/src/oit/resolve/mod.rs index 5b27c169c782d..f73192b19dec9 100644 --- a/crates/bevy_core_pipeline/src/oit/resolve/mod.rs +++ b/crates/bevy_core_pipeline/src/oit/resolve/mod.rs @@ -3,7 +3,7 @@ use crate::{ oit::OrderIndependentTransparencySettings, }; use bevy_app::Plugin; -use bevy_asset::{Handle, load_internal_asset, weak_handle}; +use bevy_asset::{load_internal_asset, weak_handle, Handle}; use bevy_derive::Deref; use bevy_ecs::{ entity::{hash_map::EntityHashMap, hash_set::EntityHashSet}, @@ -11,16 +11,16 @@ use bevy_ecs::{ }; use bevy_image::BevyDefault as _; use bevy_render::{ - Render, RenderApp, RenderSet, render_resource::{ + binding_types::{storage_buffer_sized, texture_depth_2d, uniform_buffer}, BindGroup, BindGroupEntries, BindGroupLayout, BindGroupLayoutEntries, BlendComponent, BlendState, CachedRenderPipelineId, ColorTargetState, ColorWrites, DownlevelFlags, FragmentState, MultisampleState, PipelineCache, PrimitiveState, RenderPipelineDescriptor, Shader, ShaderDefVal, ShaderStages, TextureFormat, - binding_types::{storage_buffer_sized, texture_depth_2d, uniform_buffer}, }, renderer::{RenderAdapter, RenderDevice}, view::{ExtractedView, ViewTarget, ViewUniform, ViewUniforms}, + Render, RenderApp, RenderSet, }; use tracing::warn; @@ -57,9 +57,7 @@ impl Plugin for OitResolvePlugin { .flags .contains(DownlevelFlags::FRAGMENT_WRITABLE_STORAGE) { - warn!( - "OrderIndependentTransparencyPlugin not loaded. GPU lacks support: DownlevelFlags::FRAGMENT_WRITABLE_STORAGE." - ); + warn!("OrderIndependentTransparencyPlugin not loaded. GPU lacks support: DownlevelFlags::FRAGMENT_WRITABLE_STORAGE."); return; } diff --git a/crates/bevy_core_pipeline/src/post_process/mod.rs b/crates/bevy_core_pipeline/src/post_process/mod.rs index 5721873854eda..c8b1da4497363 100644 --- a/crates/bevy_core_pipeline/src/post_process/mod.rs +++ b/crates/bevy_core_pipeline/src/post_process/mod.rs @@ -3,7 +3,7 @@ //! Currently, this consists only of chromatic aberration. use bevy_app::{App, Plugin}; -use bevy_asset::{Assets, Handle, load_internal_asset, weak_handle}; +use bevy_asset::{load_internal_asset, weak_handle, Assets, Handle}; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::{ component::Component, @@ -12,13 +12,12 @@ use bevy_ecs::{ reflect::ReflectComponent, resource::Resource, schedule::IntoSystemConfigs as _, - system::{Commands, Query, Res, ResMut, lifetimeless::Read}, + system::{lifetimeless::Read, Commands, Query, Res, ResMut}, world::{FromWorld, World}, }; use bevy_image::{BevyDefault, Image}; -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::{ - Render, RenderApp, RenderSet, camera::Camera, extract_component::{ExtractComponent, ExtractComponentPlugin}, render_asset::{RenderAssetUsages, RenderAssets}, @@ -26,17 +25,18 @@ use bevy_render::{ NodeRunError, RenderGraphApp as _, RenderGraphContext, ViewNode, ViewNodeRunner, }, render_resource::{ + binding_types::{sampler, texture_2d, uniform_buffer}, BindGroupEntries, BindGroupLayout, BindGroupLayoutEntries, CachedRenderPipelineId, ColorTargetState, ColorWrites, DynamicUniformBuffer, Extent3d, FilterMode, FragmentState, Operations, PipelineCache, RenderPassColorAttachment, RenderPassDescriptor, RenderPipelineDescriptor, Sampler, SamplerBindingType, SamplerDescriptor, Shader, ShaderStages, ShaderType, SpecializedRenderPipeline, SpecializedRenderPipelines, TextureDimension, TextureFormat, TextureSampleType, - binding_types::{sampler, texture_2d, uniform_buffer}, }, renderer::{RenderContext, RenderDevice, RenderQueue}, texture::GpuImage, view::{ExtractedView, ViewTarget}, + Render, RenderApp, RenderSet, }; use bevy_utils::prelude::default; diff --git a/crates/bevy_core_pipeline/src/prepass/mod.rs b/crates/bevy_core_pipeline/src/prepass/mod.rs index db4b486b9837c..1e663a79a48b6 100644 --- a/crates/bevy_core_pipeline/src/prepass/mod.rs +++ b/crates/bevy_core_pipeline/src/prepass/mod.rs @@ -33,7 +33,7 @@ use crate::deferred::{DEFERRED_LIGHTING_PASS_ID_FORMAT, DEFERRED_PREPASS_FORMAT} use bevy_asset::UntypedAssetId; use bevy_ecs::prelude::*; use bevy_math::Mat4; -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::mesh::allocator::SlabId; use bevy_render::render_phase::PhaseItemBatchSetKey; use bevy_render::sync_world::MainEntity; diff --git a/crates/bevy_core_pipeline/src/skybox/mod.rs b/crates/bevy_core_pipeline/src/skybox/mod.rs index 8e92cd559c2f6..6e1a8422768a8 100644 --- a/crates/bevy_core_pipeline/src/skybox/mod.rs +++ b/crates/bevy_core_pipeline/src/skybox/mod.rs @@ -1,5 +1,5 @@ use bevy_app::{App, Plugin}; -use bevy_asset::{Handle, load_internal_asset, weak_handle}; +use bevy_asset::{load_internal_asset, weak_handle, Handle}; use bevy_ecs::{ prelude::{Component, Entity}, query::{QueryItem, With}, @@ -10,9 +10,8 @@ use bevy_ecs::{ }; use bevy_image::{BevyDefault, Image}; use bevy_math::{Mat4, Quat}; -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::{ - Render, RenderApp, RenderSet, camera::Exposure, extract_component::{ ComponentUniforms, DynamicUniformIndex, ExtractComponent, ExtractComponentPlugin, @@ -26,9 +25,10 @@ use bevy_render::{ renderer::RenderDevice, texture::GpuImage, view::{ExtractedView, Msaa, ViewTarget, ViewUniform, ViewUniforms}, + Render, RenderApp, RenderSet, }; use bevy_transform::components::Transform; -use prepass::{SKYBOX_PREPASS_SHADER_HANDLE, SkyboxPrepassPipeline}; +use prepass::{SkyboxPrepassPipeline, SKYBOX_PREPASS_SHADER_HANDLE}; use crate::{core_3d::CORE_3D_DEPTH_FORMAT, prepass::PreviousViewUniforms}; diff --git a/crates/bevy_core_pipeline/src/skybox/prepass.rs b/crates/bevy_core_pipeline/src/skybox/prepass.rs index 88037e3b5115b..658660bbc62ff 100644 --- a/crates/bevy_core_pipeline/src/skybox/prepass.rs +++ b/crates/bevy_core_pipeline/src/skybox/prepass.rs @@ -1,6 +1,6 @@ //! Adds motion vector support to skyboxes. See [`SkyboxPrepassPipeline`] for details. -use bevy_asset::{Handle, weak_handle}; +use bevy_asset::{weak_handle, Handle}; use bevy_ecs::{ component::Component, entity::Entity, @@ -11,10 +11,10 @@ use bevy_ecs::{ }; use bevy_render::{ render_resource::{ - BindGroup, BindGroupEntries, BindGroupLayout, BindGroupLayoutEntries, - CachedRenderPipelineId, CompareFunction, DepthStencilState, FragmentState, - MultisampleState, PipelineCache, RenderPipelineDescriptor, Shader, ShaderStages, - SpecializedRenderPipeline, SpecializedRenderPipelines, binding_types::uniform_buffer, + binding_types::uniform_buffer, BindGroup, BindGroupEntries, BindGroupLayout, + BindGroupLayoutEntries, CachedRenderPipelineId, CompareFunction, DepthStencilState, + FragmentState, MultisampleState, PipelineCache, RenderPipelineDescriptor, Shader, + ShaderStages, SpecializedRenderPipeline, SpecializedRenderPipelines, }, renderer::RenderDevice, view::{Msaa, ViewUniform, ViewUniforms}, @@ -22,12 +22,12 @@ use bevy_render::{ use bevy_utils::prelude::default; use crate::{ - Skybox, core_3d::CORE_3D_DEPTH_FORMAT, prepass::{ - MotionVectorPrepass, NormalPrepass, PreviousViewData, PreviousViewUniforms, - prepass_target_descriptors, + prepass_target_descriptors, MotionVectorPrepass, NormalPrepass, PreviousViewData, + PreviousViewUniforms, }, + Skybox, }; pub const SKYBOX_PREPASS_SHADER_HANDLE: Handle = diff --git a/crates/bevy_core_pipeline/src/smaa/mod.rs b/crates/bevy_core_pipeline/src/smaa/mod.rs index c708e124ef170..fb066a3ce538c 100644 --- a/crates/bevy_core_pipeline/src/smaa/mod.rs +++ b/crates/bevy_core_pipeline/src/smaa/mod.rs @@ -38,7 +38,7 @@ use crate::{ use bevy_app::{App, Plugin}; #[cfg(feature = "smaa_luts")] use bevy_asset::load_internal_binary_asset; -use bevy_asset::{Handle, load_internal_asset, weak_handle}; +use bevy_asset::{load_internal_asset, weak_handle, Handle}; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::{ component::Component, @@ -47,14 +47,13 @@ use bevy_ecs::{ reflect::ReflectComponent, resource::Resource, schedule::IntoSystemConfigs as _, - system::{Commands, Query, Res, ResMut, lifetimeless::Read}, + system::{lifetimeless::Read, Commands, Query, Res, ResMut}, world::{FromWorld, World}, }; use bevy_image::{BevyDefault, Image}; -use bevy_math::{Vec4, vec4}; -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_math::{vec4, Vec4}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::{ - Render, RenderApp, RenderSet, camera::ExtractedCamera, extract_component::{ExtractComponent, ExtractComponentPlugin}, render_asset::RenderAssets, @@ -62,6 +61,7 @@ use bevy_render::{ NodeRunError, RenderGraphApp as _, RenderGraphContext, ViewNode, ViewNodeRunner, }, render_resource::{ + binding_types::{sampler, texture_2d, uniform_buffer}, AddressMode, BindGroup, BindGroupEntries, BindGroupLayout, BindGroupLayoutEntries, CachedRenderPipelineId, ColorTargetState, ColorWrites, CompareFunction, DepthStencilState, DynamicUniformBuffer, Extent3d, FilterMode, FragmentState, LoadOp, MultisampleState, @@ -72,11 +72,11 @@ use bevy_render::{ StencilFaceState, StencilOperation, StencilState, StoreOp, TextureDescriptor, TextureDimension, TextureFormat, TextureSampleType, TextureUsages, TextureView, VertexState, - binding_types::{sampler, texture_2d, uniform_buffer}, }, renderer::{RenderContext, RenderDevice, RenderQueue}, texture::{CachedTexture, GpuImage, TextureCache}, view::{ExtractedView, ViewTarget}, + Render, RenderApp, RenderSet, }; use bevy_utils::prelude::default; diff --git a/crates/bevy_core_pipeline/src/taa/mod.rs b/crates/bevy_core_pipeline/src/taa/mod.rs index c672b156007f3..55eb25ae02ebf 100644 --- a/crates/bevy_core_pipeline/src/taa/mod.rs +++ b/crates/bevy_core_pipeline/src/taa/mod.rs @@ -5,10 +5,10 @@ use crate::{ prepass::{DepthPrepass, MotionVectorPrepass, ViewPrepassTextures}, }; use bevy_app::{App, Plugin}; -use bevy_asset::{Handle, load_internal_asset, weak_handle}; +use bevy_asset::{load_internal_asset, weak_handle, Handle}; use bevy_diagnostic::FrameCount; use bevy_ecs::{ - prelude::{Component, Entity, ReflectComponent, require}, + prelude::{require, Component, Entity, ReflectComponent}, query::{QueryItem, With}, resource::Resource, schedule::IntoSystemConfigs, @@ -17,26 +17,26 @@ use bevy_ecs::{ }; use bevy_image::BevyDefault as _; use bevy_math::vec2; -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::{ - ExtractSchedule, MainWorld, Render, RenderApp, RenderSet, camera::{ExtractedCamera, MipBias, TemporalJitter}, prelude::{Camera, Projection}, render_graph::{NodeRunError, RenderGraphApp, RenderGraphContext, ViewNode, ViewNodeRunner}, render_resource::{ + binding_types::{sampler, texture_2d, texture_depth_2d}, BindGroupEntries, BindGroupLayout, BindGroupLayoutEntries, CachedRenderPipelineId, ColorTargetState, ColorWrites, Extent3d, FilterMode, FragmentState, MultisampleState, Operations, PipelineCache, PrimitiveState, RenderPassColorAttachment, RenderPassDescriptor, RenderPipelineDescriptor, Sampler, SamplerBindingType, SamplerDescriptor, Shader, ShaderStages, SpecializedRenderPipeline, SpecializedRenderPipelines, TextureDescriptor, TextureDimension, TextureFormat, TextureSampleType, TextureUsages, - binding_types::{sampler, texture_2d, texture_depth_2d}, }, renderer::{RenderContext, RenderDevice}, sync_component::SyncComponentPlugin, sync_world::RenderEntity, texture::{CachedTexture, TextureCache}, view::{ExtractedView, Msaa, ViewTarget}, + ExtractSchedule, MainWorld, Render, RenderApp, RenderSet, }; use tracing::warn; diff --git a/crates/bevy_core_pipeline/src/tonemapping/mod.rs b/crates/bevy_core_pipeline/src/tonemapping/mod.rs index 9b90e0761180e..443b81327a8e6 100644 --- a/crates/bevy_core_pipeline/src/tonemapping/mod.rs +++ b/crates/bevy_core_pipeline/src/tonemapping/mod.rs @@ -1,11 +1,10 @@ use crate::fullscreen_vertex_shader::fullscreen_shader_vertex_state; use bevy_app::prelude::*; -use bevy_asset::{Assets, Handle, load_internal_asset, weak_handle}; +use bevy_asset::{load_internal_asset, weak_handle, Assets, Handle}; use bevy_ecs::prelude::*; use bevy_image::{CompressedImageFormats, Image, ImageSampler, ImageType}; -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::{ - Render, RenderApp, RenderSet, camera::Camera, extract_component::{ExtractComponent, ExtractComponentPlugin}, extract_resource::{ExtractResource, ExtractResourcePlugin}, @@ -17,6 +16,7 @@ use bevy_render::{ renderer::RenderDevice, texture::{FallbackImage, GpuImage}, view::{ExtractedView, ViewTarget, ViewUniform}, + Render, RenderApp, RenderSet, }; use bitflags::bitflags; #[cfg(not(feature = "tonemapping_luts"))] diff --git a/crates/bevy_core_pipeline/src/tonemapping/node.rs b/crates/bevy_core_pipeline/src/tonemapping/node.rs index ca88dfc610814..0f8f6edc49eb2 100644 --- a/crates/bevy_core_pipeline/src/tonemapping/node.rs +++ b/crates/bevy_core_pipeline/src/tonemapping/node.rs @@ -15,7 +15,7 @@ use bevy_render::{ view::{ViewTarget, ViewUniformOffset, ViewUniforms}, }; -use super::{Tonemapping, get_lut_bindings}; +use super::{get_lut_bindings, Tonemapping}; #[derive(Default)] pub struct TonemappingNode { diff --git a/crates/bevy_core_pipeline/src/upscaling/mod.rs b/crates/bevy_core_pipeline/src/upscaling/mod.rs index f57551c71656f..89f3f8d09e44a 100644 --- a/crates/bevy_core_pipeline/src/upscaling/mod.rs +++ b/crates/bevy_core_pipeline/src/upscaling/mod.rs @@ -3,10 +3,10 @@ use bevy_app::prelude::*; use bevy_ecs::prelude::*; use bevy_platform_support::collections::HashSet; use bevy_render::{ - Render, RenderApp, RenderSet, camera::{CameraOutputMode, ExtractedCamera}, render_resource::*, view::ViewTarget, + Render, RenderApp, RenderSet, }; mod node; diff --git a/crates/bevy_derive/src/bevy_main.rs b/crates/bevy_derive/src/bevy_main.rs index 9af4f54bdc8a8..8111a31338b56 100644 --- a/crates/bevy_derive/src/bevy_main.rs +++ b/crates/bevy_derive/src/bevy_main.rs @@ -1,6 +1,6 @@ use proc_macro::TokenStream; use quote::quote; -use syn::{ItemFn, parse_macro_input}; +use syn::{parse_macro_input, ItemFn}; pub fn bevy_main(_attr: TokenStream, item: TokenStream) -> TokenStream { let input = parse_macro_input!(item as ItemFn); diff --git a/crates/bevy_derive/src/derefs.rs b/crates/bevy_derive/src/derefs.rs index d5e1c3a2ded30..0dd3b152bfda5 100644 --- a/crates/bevy_derive/src/derefs.rs +++ b/crates/bevy_derive/src/derefs.rs @@ -1,6 +1,6 @@ use proc_macro::{Span, TokenStream}; use quote::quote; -use syn::{Data, DeriveInput, Field, Index, Member, Type, parse_macro_input}; +use syn::{parse_macro_input, Data, DeriveInput, Field, Index, Member, Type}; const DEREF: &str = "Deref"; const DEREF_MUT: &str = "DerefMut"; @@ -93,9 +93,7 @@ fn get_deref_field(ast: &DeriveInput, is_mut: bool) -> syn::Result<(Member, &Typ } else { Err(syn::Error::new( Span::call_site().into(), - format!( - "deriving {deref_kind} on multi-field structs requires one field to have the {deref_attr_str} attribute" - ), + format!("deriving {deref_kind} on multi-field structs requires one field to have the {deref_attr_str} attribute"), )) } } diff --git a/crates/bevy_derive/src/enum_variant_meta.rs b/crates/bevy_derive/src/enum_variant_meta.rs index 9d7eee4ff6286..afe400b09ab29 100644 --- a/crates/bevy_derive/src/enum_variant_meta.rs +++ b/crates/bevy_derive/src/enum_variant_meta.rs @@ -1,6 +1,6 @@ use proc_macro::{Span, TokenStream}; use quote::quote; -use syn::{Data, DeriveInput, parse_macro_input}; +use syn::{parse_macro_input, Data, DeriveInput}; pub fn derive_enum_variant_meta(input: TokenStream) -> TokenStream { let ast = parse_macro_input!(input as DeriveInput); @@ -9,7 +9,7 @@ pub fn derive_enum_variant_meta(input: TokenStream) -> TokenStream { _ => { return syn::Error::new(Span::call_site().into(), "Only enums are supported") .into_compile_error() - .into(); + .into() } }; diff --git a/crates/bevy_derive/src/lib.rs b/crates/bevy_derive/src/lib.rs index 46960bc9740dd..2636ffc57d13f 100644 --- a/crates/bevy_derive/src/lib.rs +++ b/crates/bevy_derive/src/lib.rs @@ -12,7 +12,7 @@ mod bevy_main; mod derefs; mod enum_variant_meta; -use bevy_macro_utils::{BevyManifest, derive_label}; +use bevy_macro_utils::{derive_label, BevyManifest}; use proc_macro::TokenStream; use quote::format_ident; diff --git a/crates/bevy_dev_tools/src/ci_testing/systems.rs b/crates/bevy_dev_tools/src/ci_testing/systems.rs index 068e62711571a..f9570133c0bba 100644 --- a/crates/bevy_dev_tools/src/ci_testing/systems.rs +++ b/crates/bevy_dev_tools/src/ci_testing/systems.rs @@ -1,7 +1,7 @@ use super::config::*; use bevy_app::AppExit; use bevy_ecs::prelude::*; -use bevy_render::view::screenshot::{Screenshot, save_to_disk}; +use bevy_render::view::screenshot::{save_to_disk, Screenshot}; use tracing::{debug, info}; pub(crate) fn send_events(world: &mut World, mut current_frame: Local) { diff --git a/crates/bevy_dev_tools/src/fps_overlay.rs b/crates/bevy_dev_tools/src/fps_overlay.rs index 4c2e292973e07..358a7f20455ed 100644 --- a/crates/bevy_dev_tools/src/fps_overlay.rs +++ b/crates/bevy_dev_tools/src/fps_overlay.rs @@ -11,15 +11,15 @@ use bevy_ecs::{ prelude::Local, query::With, resource::Resource, - schedule::{IntoSystemConfigs, common_conditions::resource_changed}, + schedule::{common_conditions::resource_changed, IntoSystemConfigs}, system::{Commands, Query, Res}, }; use bevy_render::view::Visibility; use bevy_text::{Font, TextColor, TextFont, TextSpan}; use bevy_time::Time; use bevy_ui::{ - GlobalZIndex, Node, PositionType, widget::{Text, TextUiWriter}, + GlobalZIndex, Node, PositionType, }; use core::time::Duration; diff --git a/crates/bevy_dev_tools/src/picking_debug.rs b/crates/bevy_dev_tools/src/picking_debug.rs index fbf7e6baef541..37defb557811a 100644 --- a/crates/bevy_dev_tools/src/picking_debug.rs +++ b/crates/bevy_dev_tools/src/picking_debug.rs @@ -8,7 +8,7 @@ use bevy_picking::backend::HitData; use bevy_picking::hover::HoverMap; use bevy_picking::pointer::{Location, PointerId, PointerPress}; use bevy_picking::prelude::*; -use bevy_picking::{PickSet, pointer}; +use bevy_picking::{pointer, PickSet}; use bevy_reflect::prelude::*; use bevy_render::prelude::*; use bevy_text::prelude::*; diff --git a/crates/bevy_diagnostic/src/frame_count_diagnostics_plugin.rs b/crates/bevy_diagnostic/src/frame_count_diagnostics_plugin.rs index 23c8b9c06425c..12a45ddd00251 100644 --- a/crates/bevy_diagnostic/src/frame_count_diagnostics_plugin.rs +++ b/crates/bevy_diagnostic/src/frame_count_diagnostics_plugin.rs @@ -3,8 +3,8 @@ use bevy_ecs::prelude::*; #[cfg(feature = "serialize")] use serde::{ - Deserialize, Deserializer, Serialize, Serializer, de::{Error, Visitor}, + Deserialize, Deserializer, Serialize, Serializer, }; /// Maintains a count of frames rendered since the start of the application. @@ -91,7 +91,7 @@ mod tests { mod serde_tests { use super::*; - use serde_test::{Token, assert_tokens}; + use serde_test::{assert_tokens, Token}; #[test] fn test_serde_frame_count() { diff --git a/crates/bevy_diagnostic/src/frame_time_diagnostics_plugin.rs b/crates/bevy_diagnostic/src/frame_time_diagnostics_plugin.rs index 016c7e7c0cc07..22b6176fa2856 100644 --- a/crates/bevy_diagnostic/src/frame_time_diagnostics_plugin.rs +++ b/crates/bevy_diagnostic/src/frame_time_diagnostics_plugin.rs @@ -1,6 +1,6 @@ use crate::{ - DEFAULT_MAX_HISTORY_LENGTH, Diagnostic, DiagnosticPath, Diagnostics, FrameCount, - RegisterDiagnostic, + Diagnostic, DiagnosticPath, Diagnostics, FrameCount, RegisterDiagnostic, + DEFAULT_MAX_HISTORY_LENGTH, }; use bevy_app::prelude::*; use bevy_ecs::prelude::*; diff --git a/crates/bevy_diagnostic/src/lib.rs b/crates/bevy_diagnostic/src/lib.rs index 17500ea528cff..e5098d6c6f46c 100644 --- a/crates/bevy_diagnostic/src/lib.rs +++ b/crates/bevy_diagnostic/src/lib.rs @@ -27,7 +27,7 @@ mod system_information_diagnostics_plugin; pub use diagnostic::*; pub use entity_count_diagnostics_plugin::EntityCountDiagnosticsPlugin; -pub use frame_count_diagnostics_plugin::{FrameCount, FrameCountPlugin, update_frame_count}; +pub use frame_count_diagnostics_plugin::{update_frame_count, FrameCount, FrameCountPlugin}; pub use frame_time_diagnostics_plugin::FrameTimeDiagnosticsPlugin; pub use log_diagnostics_plugin::LogDiagnosticsPlugin; #[cfg(feature = "sysinfo_plugin")] diff --git a/crates/bevy_diagnostic/src/system_information_diagnostics_plugin.rs b/crates/bevy_diagnostic/src/system_information_diagnostics_plugin.rs index dc6ae37185f18..55616fca4b961 100644 --- a/crates/bevy_diagnostic/src/system_information_diagnostics_plugin.rs +++ b/crates/bevy_diagnostic/src/system_information_diagnostics_plugin.rs @@ -71,7 +71,7 @@ pub mod internal { use bevy_ecs::resource::Resource; use bevy_ecs::{prelude::ResMut, system::Local}; use bevy_platform_support::time::Instant; - use bevy_tasks::{AsyncComputeTaskPool, Task, available_parallelism, block_on, poll_once}; + use bevy_tasks::{available_parallelism, block_on, poll_once, AsyncComputeTaskPool, Task}; use log::info; use std::sync::Mutex; use sysinfo::{CpuRefreshKind, MemoryRefreshKind, RefreshKind, System}; diff --git a/crates/bevy_ecs/macros/src/component.rs b/crates/bevy_ecs/macros/src/component.rs index 0ec47285bf80c..13f41c3b3ab28 100644 --- a/crates/bevy_ecs/macros/src/component.rs +++ b/crates/bevy_ecs/macros/src/component.rs @@ -1,15 +1,16 @@ use proc_macro::{TokenStream, TokenTree}; use proc_macro2::{Span, TokenStream as TokenStream2}; -use quote::{ToTokens, format_ident, quote}; +use quote::{format_ident, quote, ToTokens}; use std::collections::HashSet; use syn::{ - Data, DataStruct, DeriveInput, ExprClosure, ExprPath, Fields, Ident, Index, LitStr, Member, - Path, Result, Token, Visibility, parenthesized, + parenthesized, parse::Parse, parse_macro_input, parse_quote, punctuated::Punctuated, spanned::Spanned, token::{Comma, Paren}, + Data, DataStruct, DeriveInput, ExprClosure, ExprPath, Fields, Ident, Index, LitStr, Member, + Path, Result, Token, Visibility, }; pub fn derive_event(input: TokenStream) -> TokenStream { @@ -710,10 +711,7 @@ fn derive_relationship_target( { if let Some(first) = unnamed_fields.unnamed.first() { if first.vis != Visibility::Inherited { - return Err(syn::Error::new( - first.span(), - "The collection in RelationshipTarget must be private to prevent users from directly mutating it, which could invalidate the correctness of relationships.", - )); + return Err(syn::Error::new(first.span(), "The collection in RelationshipTarget must be private to prevent users from directly mutating it, which could invalidate the correctness of relationships.")); } first.ty.clone() } else { diff --git a/crates/bevy_ecs/macros/src/lib.rs b/crates/bevy_ecs/macros/src/lib.rs index 9e5d233ee61ee..f61889651df1e 100644 --- a/crates/bevy_ecs/macros/src/lib.rs +++ b/crates/bevy_ecs/macros/src/lib.rs @@ -10,13 +10,13 @@ mod states; mod world_query; use crate::{query_data::derive_query_data_impl, query_filter::derive_query_filter_impl}; -use bevy_macro_utils::{BevyManifest, derive_label, ensure_no_collision, get_struct_fields}; +use bevy_macro_utils::{derive_label, ensure_no_collision, get_struct_fields, BevyManifest}; use proc_macro::TokenStream; use proc_macro2::{Span, TokenStream as TokenStream2}; use quote::{format_ident, quote}; use syn::{ - ConstParam, Data, DataStruct, DeriveInput, GenericParam, Index, TypeParam, parse_macro_input, - parse_quote, punctuated::Punctuated, spanned::Spanned, token::Comma, + parse_macro_input, parse_quote, punctuated::Punctuated, spanned::Spanned, token::Comma, + ConstParam, Data, DataStruct, DeriveInput, GenericParam, Index, TypeParam, }; enum BundleFieldKind { diff --git a/crates/bevy_ecs/macros/src/query_data.rs b/crates/bevy_ecs/macros/src/query_data.rs index c27dde978f898..ffac58ef1d313 100644 --- a/crates/bevy_ecs/macros/src/query_data.rs +++ b/crates/bevy_ecs/macros/src/query_data.rs @@ -3,8 +3,8 @@ use proc_macro::TokenStream; use proc_macro2::{Ident, Span}; use quote::{format_ident, quote}; use syn::{ - Attribute, Data, DataStruct, DeriveInput, Field, Index, Meta, parse_macro_input, parse_quote, - punctuated::Punctuated, token, token::Comma, + parse_macro_input, parse_quote, punctuated::Punctuated, token, token::Comma, Attribute, Data, + DataStruct, DeriveInput, Field, Index, Meta, }; use crate::{ diff --git a/crates/bevy_ecs/macros/src/query_filter.rs b/crates/bevy_ecs/macros/src/query_filter.rs index ea8ff2a77a6d5..c7ddb9cc83521 100644 --- a/crates/bevy_ecs/macros/src/query_filter.rs +++ b/crates/bevy_ecs/macros/src/query_filter.rs @@ -2,7 +2,7 @@ use bevy_macro_utils::ensure_no_collision; use proc_macro::TokenStream; use proc_macro2::{Ident, Span}; use quote::{format_ident, quote}; -use syn::{Data, DataStruct, DeriveInput, Index, parse_macro_input, parse_quote}; +use syn::{parse_macro_input, parse_quote, Data, DataStruct, DeriveInput, Index}; use crate::{bevy_ecs_path, world_query::world_query_impl}; diff --git a/crates/bevy_ecs/macros/src/states.rs b/crates/bevy_ecs/macros/src/states.rs index d0ed1bb79f2dd..ff69812aea380 100644 --- a/crates/bevy_ecs/macros/src/states.rs +++ b/crates/bevy_ecs/macros/src/states.rs @@ -1,6 +1,6 @@ use proc_macro::TokenStream; use quote::{format_ident, quote}; -use syn::{DeriveInput, Pat, Path, Result, parse_macro_input, spanned::Spanned}; +use syn::{parse_macro_input, spanned::Spanned, DeriveInput, Pat, Path, Result}; use crate::bevy_ecs_path; diff --git a/crates/bevy_ecs/src/bundle.rs b/crates/bevy_ecs/src/bundle.rs index 7561bc1f00f6b..fcfd514f68838 100644 --- a/crates/bevy_ecs/src/bundle.rs +++ b/crates/bevy_ecs/src/bundle.rs @@ -19,7 +19,7 @@ use crate::{ prelude::World, query::DebugCheckedUnwrap, storage::{SparseSetIndex, SparseSets, Storages, Table, TableRow}, - world::{EntityWorldMut, ON_ADD, ON_INSERT, ON_REPLACE, unsafe_world_cell::UnsafeWorldCell}, + world::{unsafe_world_cell::UnsafeWorldCell, EntityWorldMut, ON_ADD, ON_INSERT, ON_REPLACE}, }; use alloc::{boxed::Box, vec, vec::Vec}; use bevy_platform_support::collections::{HashMap, HashSet}; diff --git a/crates/bevy_ecs/src/change_detection.rs b/crates/bevy_ecs/src/change_detection.rs index 12f02d558c36a..8731fb8eb7863 100644 --- a/crates/bevy_ecs/src/change_detection.rs +++ b/crates/bevy_ecs/src/change_detection.rs @@ -1476,8 +1476,8 @@ mod tests { use crate::{ change_detection::{ - CHECK_TICK_THRESHOLD, MAX_CHANGE_AGE, MaybeLocation, Mut, NonSendMut, Ref, ResMut, - TicksMut, + MaybeLocation, Mut, NonSendMut, Ref, ResMut, TicksMut, CHECK_TICK_THRESHOLD, + MAX_CHANGE_AGE, }, component::{Component, ComponentTicks, Tick}, system::{IntoSystem, Single, System}, diff --git a/crates/bevy_ecs/src/component.rs b/crates/bevy_ecs/src/component.rs index 0cc28c68026a9..0eaa329c61a30 100644 --- a/crates/bevy_ecs/src/component.rs +++ b/crates/bevy_ecs/src/component.rs @@ -3,7 +3,7 @@ use crate::{ archetype::ArchetypeFlags, bundle::BundleInfo, - change_detection::{MAX_CHANGE_AGE, MaybeLocation}, + change_detection::{MaybeLocation, MAX_CHANGE_AGE}, entity::{ComponentCloneCtx, Entity}, query::DebugCheckedUnwrap, resource::Resource, diff --git a/crates/bevy_ecs/src/entity/clone_entities.rs b/crates/bevy_ecs/src/entity/clone_entities.rs index 6d7f5d8ad16c1..389f30ff8d7b2 100644 --- a/crates/bevy_ecs/src/entity/clone_entities.rs +++ b/crates/bevy_ecs/src/entity/clone_entities.rs @@ -8,8 +8,8 @@ use core::{any::TypeId, ptr::NonNull}; use alloc::boxed::Box; use crate::component::{ComponentCloneBehavior, ComponentCloneFn}; -use crate::entity::EntityMapper; use crate::entity::hash_map::EntityHashMap; +use crate::entity::EntityMapper; use crate::system::Commands; use crate::{ bundle::Bundle, @@ -817,7 +817,7 @@ mod tests { use super::ComponentCloneCtx; use crate::{ component::{Component, ComponentCloneBehavior, ComponentDescriptor, StorageType}, - entity::{Entity, EntityCloner, hash_map::EntityHashMap}, + entity::{hash_map::EntityHashMap, Entity, EntityCloner}, prelude::{ChildOf, Children, Resource}, reflect::AppTypeRegistry, reflect::{ReflectComponent, ReflectFromWorld}, @@ -840,7 +840,7 @@ mod tests { system::Commands, }; use alloc::vec; - use bevy_reflect::{FromType, Reflect, ReflectFromPtr, std_traits::ReflectDefault}; + use bevy_reflect::{std_traits::ReflectDefault, FromType, Reflect, ReflectFromPtr}; #[test] fn clone_entity_using_reflect() { @@ -989,11 +989,9 @@ mod tests { EntityCloner::build(&mut world).clone_entity(e, e_clone); - assert!( - world - .get::(e_clone) - .is_some_and(|comp| *comp == A { field: 10 }) - ); + assert!(world + .get::(e_clone) + .is_some_and(|comp| *comp == A { field: 10 })); } #[test] diff --git a/crates/bevy_ecs/src/entity/map_entities.rs b/crates/bevy_ecs/src/entity/map_entities.rs index 97325f3f61db2..caa02eaeac2bd 100644 --- a/crates/bevy_ecs/src/entity/map_entities.rs +++ b/crates/bevy_ecs/src/entity/map_entities.rs @@ -1,10 +1,10 @@ use crate::{ entity::Entity, - identifier::masks::{HIGH_MASK, IdentifierMask}, + identifier::masks::{IdentifierMask, HIGH_MASK}, world::World, }; -use super::{VisitEntitiesMut, hash_map::EntityHashMap}; +use super::{hash_map::EntityHashMap, VisitEntitiesMut}; /// Operation to map all contained [`Entity`] fields in a type to new values. /// @@ -114,7 +114,11 @@ impl EntityMapper for () { impl EntityMapper for (Entity, Entity) { #[inline] fn get_mapped(&mut self, source: Entity) -> Entity { - if source == self.0 { self.1 } else { source } + if source == self.0 { + self.1 + } else { + source + } } fn set_mapped(&mut self, _source: Entity, _target: Entity) {} @@ -243,7 +247,7 @@ impl<'m> SceneEntityMapper<'m> { #[cfg(test)] mod tests { use crate::{ - entity::{Entity, EntityMapper, SceneEntityMapper, hash_map::EntityHashMap}, + entity::{hash_map::EntityHashMap, Entity, EntityMapper, SceneEntityMapper}, world::World, }; diff --git a/crates/bevy_ecs/src/entity/mod.rs b/crates/bevy_ecs/src/entity/mod.rs index c15a1da341281..853cb7e4818dc 100644 --- a/crates/bevy_ecs/src/entity/mod.rs +++ b/crates/bevy_ecs/src/entity/mod.rs @@ -74,10 +74,10 @@ use crate::{ archetype::{ArchetypeId, ArchetypeRow}, change_detection::MaybeLocation, identifier::{ - Identifier, error::IdentifierError, kinds::IdKind, - masks::{HIGH_MASK, IdentifierMask}, + masks::{IdentifierMask, HIGH_MASK}, + Identifier, }, storage::{SparseSetIndex, TableId, TableRow}, }; diff --git a/crates/bevy_ecs/src/entity/unique_slice.rs b/crates/bevy_ecs/src/entity/unique_slice.rs index 0de009551e67b..f3a6f66de7e87 100644 --- a/crates/bevy_ecs/src/entity/unique_slice.rs +++ b/crates/bevy_ecs/src/entity/unique_slice.rs @@ -21,8 +21,8 @@ use alloc::{ }; use super::{ - EntitySet, EntitySetIterator, FromEntitySetIterator, TrustedEntityBorrow, UniqueEntityIter, - UniqueEntityVec, unique_vec, + unique_vec, EntitySet, EntitySetIterator, FromEntitySetIterator, TrustedEntityBorrow, + UniqueEntityIter, UniqueEntityVec, }; /// A slice that contains only unique entities. diff --git a/crates/bevy_ecs/src/entity/unique_vec.rs b/crates/bevy_ecs/src/entity/unique_vec.rs index 3ea438997dcc1..9ea1f9c7a6b39 100644 --- a/crates/bevy_ecs/src/entity/unique_vec.rs +++ b/crates/bevy_ecs/src/entity/unique_vec.rs @@ -17,8 +17,8 @@ use alloc::{ }; use super::{ - EntitySet, FromEntitySetIterator, TrustedEntityBorrow, UniqueEntityIter, UniqueEntitySlice, - unique_slice, + unique_slice, EntitySet, FromEntitySetIterator, TrustedEntityBorrow, UniqueEntityIter, + UniqueEntitySlice, }; /// A `Vec` that contains only unique entities. diff --git a/crates/bevy_ecs/src/entity/visit_entities.rs b/crates/bevy_ecs/src/entity/visit_entities.rs index e302eafa8fb4c..734c96e1132b9 100644 --- a/crates/bevy_ecs/src/entity/visit_entities.rs +++ b/crates/bevy_ecs/src/entity/visit_entities.rs @@ -57,7 +57,7 @@ impl VisitEntitiesMut for Entity { #[cfg(test)] mod tests { use crate::{ - entity::{MapEntities, SceneEntityMapper, hash_map::EntityHashMap}, + entity::{hash_map::EntityHashMap, MapEntities, SceneEntityMapper}, world::World, }; use alloc::{string::String, vec, vec::Vec}; diff --git a/crates/bevy_ecs/src/event/collections.rs b/crates/bevy_ecs/src/event/collections.rs index 70555e30e639f..faa52ecd189af 100644 --- a/crates/bevy_ecs/src/event/collections.rs +++ b/crates/bevy_ecs/src/event/collections.rs @@ -11,7 +11,7 @@ use core::{ #[cfg(feature = "bevy_reflect")] use { bevy_ecs::reflect::ReflectResource, - bevy_reflect::{Reflect, std_traits::ReflectDefault}, + bevy_reflect::{std_traits::ReflectDefault, Reflect}, }; /// An event collection that represents the events that occurred within the last two diff --git a/crates/bevy_ecs/src/event/mod.rs b/crates/bevy_ecs/src/event/mod.rs index a8aa9c547e418..9c19dc16895e7 100644 --- a/crates/bevy_ecs/src/event/mod.rs +++ b/crates/bevy_ecs/src/event/mod.rs @@ -25,7 +25,7 @@ pub use mutator::EventMutator; pub use reader::EventReader; pub use registry::{EventRegistry, ShouldUpdateEvents}; pub use update::{ - EventUpdates, event_update_condition, event_update_system, signal_event_update_system, + event_update_condition, event_update_system, signal_event_update_system, EventUpdates, }; pub use writer::EventWriter; @@ -157,11 +157,9 @@ mod tests { events.update(); events.send(TestEvent { i: 3 }); - assert!( - reader - .read(&events) - .eq([TestEvent { i: 2 }, TestEvent { i: 3 }].iter()) - ); + assert!(reader + .read(&events) + .eq([TestEvent { i: 2 }, TestEvent { i: 3 }].iter())); } #[test] @@ -172,11 +170,9 @@ mod tests { #[test] fn test_events_drain_and_read() { events_clear_and_read_impl(|events| { - assert!( - events - .drain() - .eq(vec![TestEvent { i: 0 }, TestEvent { i: 1 }].into_iter()) - ); + assert!(events + .drain() + .eq(vec![TestEvent { i: 0 }, TestEvent { i: 1 }].into_iter())); }); } @@ -292,11 +288,9 @@ mod tests { let mut reader = events.get_cursor(); events.extend(vec![TestEvent { i: 0 }, TestEvent { i: 1 }]); - assert!( - reader - .read(&events) - .eq([TestEvent { i: 0 }, TestEvent { i: 1 }].iter()) - ); + assert!(reader + .read(&events) + .eq([TestEvent { i: 0 }, TestEvent { i: 1 }].iter())); } // Cursor diff --git a/crates/bevy_ecs/src/lib.rs b/crates/bevy_ecs/src/lib.rs index 26845da910b9c..8d415d7469183 100644 --- a/crates/bevy_ecs/src/lib.rs +++ b/crates/bevy_ecs/src/lib.rs @@ -72,7 +72,7 @@ pub mod prelude { bundle::Bundle, change_detection::{DetectChanges, DetectChangesMut, Mut, Ref}, children, - component::{Component, require}, + component::{require, Component}, entity::{Entity, EntityBorrow, EntityMapper}, event::{Event, EventMutator, EventReader, EventWriter, Events}, hierarchy::{ChildOf, ChildSpawner, ChildSpawnerCommands, Children}, @@ -85,8 +85,8 @@ pub mod prelude { resource::Resource, result::{Error, Result}, schedule::{ - ApplyDeferred, Condition, IntoSystemConfigs, IntoSystemSet, IntoSystemSetConfigs, - Schedule, Schedules, SystemSet, apply_deferred, common_conditions::*, + apply_deferred, common_conditions::*, ApplyDeferred, Condition, IntoSystemConfigs, + IntoSystemSet, IntoSystemSetConfigs, Schedule, Schedules, SystemSet, }, spawn::{Spawn, SpawnRelated}, system::{ @@ -132,7 +132,7 @@ mod tests { use crate::{ bundle::Bundle, change_detection::Ref, - component::{Component, ComponentId, RequiredComponents, RequiredComponentsError, require}, + component::{require, Component, ComponentId, RequiredComponents, RequiredComponentsError}, entity::Entity, entity_disabling::DefaultQueryFilters, prelude::Or, @@ -910,19 +910,15 @@ mod tests { 1 ); assert!(world.query::<&A>().get(&world, a).is_ok()); - assert!( - world - .query_filtered::<(), Added>() - .get(&world, a) - .is_ok() - ); + assert!(world + .query_filtered::<(), Added>() + .get(&world, a) + .is_ok()); assert!(world.query::<&A>().get(&world, a).is_ok()); - assert!( - world - .query_filtered::<(), Added>() - .get(&world, a) - .is_ok() - ); + assert!(world + .query_filtered::<(), Added>() + .get(&world, a) + .is_ok()); world.clear_trackers(); @@ -937,19 +933,15 @@ mod tests { 0 ); assert!(world.query::<&A>().get(&world, a).is_ok()); - assert!( - world - .query_filtered::<(), Added>() - .get(&world, a) - .is_err() - ); + assert!(world + .query_filtered::<(), Added>() + .get(&world, a) + .is_err()); assert!(world.query::<&A>().get(&world, a).is_ok()); - assert!( - world - .query_filtered::<(), Added>() - .get(&world, a) - .is_err() - ); + assert!(world + .query_filtered::<(), Added>() + .get(&world, a) + .is_err()); } #[test] @@ -1122,11 +1114,7 @@ mod tests { // ensure changing an entity's archetypes also moves its changed state world.entity_mut(e1).insert(C); - assert_eq!( - get_filtered::>(&mut world), - [e3, e1].into_iter().collect::>(), - "changed entities list should not change (although the order will due to archetype moves)" - ); + assert_eq!(get_filtered::>(&mut world), [e3, e1].into_iter().collect::>(), "changed entities list should not change (although the order will due to archetype moves)"); // spawning a new SparseStored entity should not change existing changed state world.entity_mut(e1).insert(SparseStored(0)); @@ -1836,11 +1824,7 @@ mod tests { assert_eq!( component_values, - [ - (Some(&A(0)), &B(1), &C), - (Some(&A(0)), &B(2), &C), - (None, &B(3), &C) - ], + [(Some(&A(0)), &B(1), &C), (Some(&A(0)), &B(2), &C), (None, &B(3), &C)], "all entities should have had their B component replaced, received C component, and had their A component (or lack thereof) unchanged" ); } @@ -2498,8 +2482,8 @@ mod tests { } #[test] - fn runtime_required_components_deep_require_does_not_override_shallow_require_deep_subtree_after_shallow() - { + fn runtime_required_components_deep_require_does_not_override_shallow_require_deep_subtree_after_shallow( + ) { #[derive(Component)] struct A; #[derive(Component, Default)] diff --git a/crates/bevy_ecs/src/name.rs b/crates/bevy_ecs/src/name.rs index 5c6bd8bfe01ac..9c38b28481e7f 100644 --- a/crates/bevy_ecs/src/name.rs +++ b/crates/bevy_ecs/src/name.rs @@ -16,15 +16,15 @@ use core::{ use { alloc::string::ToString, serde::{ - Deserialize, Deserializer, Serialize, Serializer, de::{Error, Visitor}, + Deserialize, Deserializer, Serialize, Serializer, }, }; #[cfg(feature = "bevy_reflect")] use { crate::reflect::ReflectComponent, - bevy_reflect::{Reflect, std_traits::ReflectDefault}, + bevy_reflect::{std_traits::ReflectDefault, Reflect}, }; #[cfg(all(feature = "serialize", feature = "bevy_reflect"))] @@ -286,7 +286,7 @@ mod tests { mod serde_tests { use super::Name; - use serde_test::{Token, assert_tokens}; + use serde_test::{assert_tokens, Token}; #[test] fn test_serde_name() { diff --git a/crates/bevy_ecs/src/observer/mod.rs b/crates/bevy_ecs/src/observer/mod.rs index ca715db051d9c..525e9751a684e 100644 --- a/crates/bevy_ecs/src/observer/mod.rs +++ b/crates/bevy_ecs/src/observer/mod.rs @@ -1166,9 +1166,11 @@ mod tests { let mut world = World::new(); world.init_resource::(); - world.spawn_empty().observe(|_: Trigger| -> () { - panic!("Trigger routed to non-targeted entity."); - }); + world + .spawn_empty() + .observe(|_: Trigger| -> () { + panic!("Trigger routed to non-targeted entity."); + }); world.add_observer(move |obs: Trigger, mut res: ResMut| { assert_eq!(obs.target(), Entity::PLACEHOLDER); res.observed("event_a"); @@ -1187,9 +1189,11 @@ mod tests { let mut world = World::new(); world.init_resource::(); - world.spawn_empty().observe(|_: Trigger| -> () { - panic!("Trigger routed to non-targeted entity."); - }); + world + .spawn_empty() + .observe(|_: Trigger| -> () { + panic!("Trigger routed to non-targeted entity."); + }); let entity = world .spawn_empty() .observe(|_: Trigger, mut res: ResMut| res.observed("a_1")) diff --git a/crates/bevy_ecs/src/query/access.rs b/crates/bevy_ecs/src/query/access.rs index 397835b677f41..089d6914c6358 100644 --- a/crates/bevy_ecs/src/query/access.rs +++ b/crates/bevy_ecs/src/query/access.rs @@ -1360,7 +1360,7 @@ impl Default for FilteredAccessSet { #[cfg(test)] mod tests { use crate::query::{ - Access, AccessConflicts, FilteredAccess, FilteredAccessSet, access::AccessFilters, + access::AccessFilters, Access, AccessConflicts, FilteredAccess, FilteredAccessSet, }; use alloc::vec; use core::marker::PhantomData; diff --git a/crates/bevy_ecs/src/query/fetch.rs b/crates/bevy_ecs/src/query/fetch.rs index 2a7cdec7de0a9..08e06d03f4478 100644 --- a/crates/bevy_ecs/src/query/fetch.rs +++ b/crates/bevy_ecs/src/query/fetch.rs @@ -7,8 +7,8 @@ use crate::{ query::{Access, DebugCheckedUnwrap, FilteredAccess, WorldQuery}, storage::{ComponentSparseSet, Table, TableRow}, world::{ - EntityMut, EntityMutExcept, EntityRef, EntityRefExcept, FilteredEntityMut, - FilteredEntityRef, Mut, Ref, World, unsafe_world_cell::UnsafeWorldCell, + unsafe_world_cell::UnsafeWorldCell, EntityMut, EntityMutExcept, EntityRef, EntityRefExcept, + FilteredEntityMut, FilteredEntityRef, Mut, Ref, World, }, }; use bevy_ptr::{ThinSlicePtr, UnsafeCellDeref}; @@ -2473,7 +2473,7 @@ mod tests { use bevy_ecs_macros::QueryData; use super::*; - use crate::system::{Query, assert_is_system}; + use crate::system::{assert_is_system, Query}; #[derive(Component)] pub struct A; diff --git a/crates/bevy_ecs/src/query/filter.rs b/crates/bevy_ecs/src/query/filter.rs index 3b3f77a0cc727..9e4f36a9655f6 100644 --- a/crates/bevy_ecs/src/query/filter.rs +++ b/crates/bevy_ecs/src/query/filter.rs @@ -4,7 +4,7 @@ use crate::{ entity::Entity, query::{DebugCheckedUnwrap, FilteredAccess, StorageSwitch, WorldQuery}, storage::{ComponentSparseSet, Table, TableRow}, - world::{World, unsafe_world_cell::UnsafeWorldCell}, + world::{unsafe_world_cell::UnsafeWorldCell, World}, }; use bevy_ptr::{ThinSlicePtr, UnsafeCellDeref}; use core::{cell::UnsafeCell, marker::PhantomData}; @@ -724,10 +724,7 @@ unsafe impl WorldQuery for Added { #[inline] fn update_component_access(&id: &ComponentId, access: &mut FilteredAccess) { if access.access().has_component_write(id) { - panic!( - "$state_name<{}> conflicts with a previous access in this query. Shared access cannot coincide with exclusive access.", - core::any::type_name::() - ); + panic!("$state_name<{}> conflicts with a previous access in this query. Shared access cannot coincide with exclusive access.",core::any::type_name::()); } access.add_component_read(id); } @@ -954,10 +951,7 @@ unsafe impl WorldQuery for Changed { #[inline] fn update_component_access(&id: &ComponentId, access: &mut FilteredAccess) { if access.access().has_component_write(id) { - panic!( - "$state_name<{}> conflicts with a previous access in this query. Shared access cannot coincide with exclusive access.", - core::any::type_name::() - ); + panic!("$state_name<{}> conflicts with a previous access in this query. Shared access cannot coincide with exclusive access.",core::any::type_name::()); } access.add_component_read(id); } diff --git a/crates/bevy_ecs/src/query/iter.rs b/crates/bevy_ecs/src/query/iter.rs index 53a1519a9820b..d81ce7b85928f 100644 --- a/crates/bevy_ecs/src/query/iter.rs +++ b/crates/bevy_ecs/src/query/iter.rs @@ -7,8 +7,8 @@ use crate::{ query::{ArchetypeFilter, DebugCheckedUnwrap, QueryState, StorageId}, storage::{Table, TableRow, Tables}, world::{ - EntityMut, EntityMutExcept, EntityRef, EntityRefExcept, FilteredEntityMut, - FilteredEntityRef, unsafe_world_cell::UnsafeWorldCell, + unsafe_world_cell::UnsafeWorldCell, EntityMut, EntityMutExcept, EntityRef, EntityRefExcept, + FilteredEntityMut, FilteredEntityRef, }, }; use alloc::vec::Vec; diff --git a/crates/bevy_ecs/src/query/mod.rs b/crates/bevy_ecs/src/query/mod.rs index c285d7bf837f6..7f304b7b712b5 100644 --- a/crates/bevy_ecs/src/query/mod.rs +++ b/crates/bevy_ecs/src/query/mod.rs @@ -113,8 +113,8 @@ mod tests { }, schedule::{IntoSystemConfigs, Schedule}, storage::{Table, TableRow}, - system::{IntoSystem, Query, System, SystemState, assert_is_system}, - world::{World, unsafe_world_cell::UnsafeWorldCell}, + system::{assert_is_system, IntoSystem, Query, System, SystemState}, + world::{unsafe_world_cell::UnsafeWorldCell, World}, }; use alloc::{vec, vec::Vec}; use bevy_ecs_macros::QueryFilter; @@ -920,15 +920,11 @@ mod tests { let mut write_res = IntoSystem::into_system(write_res); write_res.initialize(&mut world); - assert!( - read_query - .archetype_component_access() - .is_compatible(read_res.archetype_component_access()) - ); - assert!( - !read_query - .archetype_component_access() - .is_compatible(write_res.archetype_component_access()) - ); + assert!(read_query + .archetype_component_access() + .is_compatible(read_res.archetype_component_access())); + assert!(!read_query + .archetype_component_access() + .is_compatible(write_res.archetype_component_access())); } } diff --git a/crates/bevy_ecs/src/query/state.rs b/crates/bevy_ecs/src/query/state.rs index 211cd668ed255..1e851285dcb03 100644 --- a/crates/bevy_ecs/src/query/state.rs +++ b/crates/bevy_ecs/src/query/state.rs @@ -7,7 +7,7 @@ use crate::{ query::{Access, FilteredAccess, QueryCombinationIter, QueryIter, QueryParIter, WorldQuery}, storage::{SparseSetIndex, TableId}, system::Query, - world::{World, WorldId, unsafe_world_cell::UnsafeWorldCell}, + world::{unsafe_world_cell::UnsafeWorldCell, World, WorldId}, }; #[cfg(all(not(target_arch = "wasm32"), feature = "multi_threaded"))] @@ -591,9 +591,7 @@ impl QueryState { #[track_caller] #[cold] fn panic_mismatched(this: WorldId, other: WorldId) -> ! { - panic!( - "Encountered a mismatched World. This QueryState was created from {this:?}, but a method was called using {other:?}." - ); + panic!("Encountered a mismatched World. This QueryState was created from {this:?}, but a method was called using {other:?}."); } if self.world_id != world_id { @@ -763,8 +761,7 @@ impl QueryState { assert!( component_access.is_subset(&self.component_access), "Transmuted state for {} attempts to access terms that are not allowed by original state {}.", - core::any::type_name::<(NewD, NewF)>(), - core::any::type_name::<(D, F)>() + core::any::type_name::<(NewD, NewF)>(), core::any::type_name::<(D, F)>() ); QueryState { @@ -858,15 +855,11 @@ impl QueryState { assert!( component_access.is_subset(&joined_component_access), "Joined state for {} attempts to access terms that are not allowed by state {} joined with {}.", - core::any::type_name::<(NewD, NewF)>(), - core::any::type_name::<(D, F)>(), - core::any::type_name::<(OtherD, OtherF)>() + core::any::type_name::<(NewD, NewF)>(), core::any::type_name::<(D, F)>(), core::any::type_name::<(OtherD, OtherF)>() ); if self.archetype_generation != other.archetype_generation { - warn!( - "You have tried to join queries with different archetype_generations. This could lead to unpredictable results." - ); + warn!("You have tried to join queries with different archetype_generations. This could lead to unpredictable results."); } // the join is dense of both the queries were dense. diff --git a/crates/bevy_ecs/src/query/world_query.rs b/crates/bevy_ecs/src/query/world_query.rs index 82b14da2d6383..da147770e0fcf 100644 --- a/crates/bevy_ecs/src/query/world_query.rs +++ b/crates/bevy_ecs/src/query/world_query.rs @@ -3,7 +3,7 @@ use crate::{ component::{ComponentId, Components, Tick}, query::FilteredAccess, storage::Table, - world::{World, unsafe_world_cell::UnsafeWorldCell}, + world::{unsafe_world_cell::UnsafeWorldCell, World}, }; use variadics_please::all_tuples; diff --git a/crates/bevy_ecs/src/reflect/bundle.rs b/crates/bevy_ecs/src/reflect/bundle.rs index 8f763b7edf2b5..b7acf69d6aad9 100644 --- a/crates/bevy_ecs/src/reflect/bundle.rs +++ b/crates/bevy_ecs/src/reflect/bundle.rs @@ -17,7 +17,7 @@ use bevy_reflect::{ FromReflect, FromType, PartialReflect, Reflect, ReflectRef, TypePath, TypeRegistry, }; -use super::{ReflectComponent, from_reflect_with_fallback}; +use super::{from_reflect_with_fallback, ReflectComponent}; /// A struct used to operate on reflected [`Bundle`] trait of a type. /// diff --git a/crates/bevy_ecs/src/reflect/component.rs b/crates/bevy_ecs/src/reflect/component.rs index db9ad6fb09a80..bffd2e9c290b7 100644 --- a/crates/bevy_ecs/src/reflect/component.rs +++ b/crates/bevy_ecs/src/reflect/component.rs @@ -64,8 +64,8 @@ use crate::{ entity::{Entity, EntityMapper}, prelude::Component, world::{ - EntityMut, EntityWorldMut, FilteredEntityMut, FilteredEntityRef, World, - unsafe_world_cell::UnsafeEntityCell, + unsafe_world_cell::UnsafeEntityCell, EntityMut, EntityWorldMut, FilteredEntityMut, + FilteredEntityRef, World, }, }; use bevy_reflect::{FromReflect, FromType, PartialReflect, Reflect, TypePath, TypeRegistry}; @@ -313,9 +313,7 @@ impl FromType for ReflectComponent { apply: |mut entity, reflected_component| { if !C::Mutability::MUTABLE { let name = ShortName::of::(); - panic!( - "Cannot call `ReflectComponent::apply` on component {name}. It is immutable, and cannot modified through reflection" - ); + panic!("Cannot call `ReflectComponent::apply` on component {name}. It is immutable, and cannot modified through reflection"); } // SAFETY: guard ensures `C` is a mutable component @@ -363,9 +361,7 @@ impl FromType for ReflectComponent { reflect_mut: |entity| { if !C::Mutability::MUTABLE { let name = ShortName::of::(); - panic!( - "Cannot call `ReflectComponent::reflect_mut` on component {name}. It is immutable, and cannot modified through reflection" - ); + panic!("Cannot call `ReflectComponent::reflect_mut` on component {name}. It is immutable, and cannot modified through reflection"); } // SAFETY: guard ensures `C` is a mutable component @@ -378,9 +374,7 @@ impl FromType for ReflectComponent { reflect_unchecked_mut: |entity| { if !C::Mutability::MUTABLE { let name = ShortName::of::(); - panic!( - "Cannot call `ReflectComponent::reflect_unchecked_mut` on component {name}. It is immutable, and cannot modified through reflection" - ); + panic!("Cannot call `ReflectComponent::reflect_unchecked_mut` on component {name}. It is immutable, and cannot modified through reflection"); } // SAFETY: reflect_unchecked_mut is an unsafe function pointer used by diff --git a/crates/bevy_ecs/src/reflect/entity_commands.rs b/crates/bevy_ecs/src/reflect/entity_commands.rs index f5cb80cebdb5a..9aef8105a53ca 100644 --- a/crates/bevy_ecs/src/reflect/entity_commands.rs +++ b/crates/bevy_ecs/src/reflect/entity_commands.rs @@ -349,15 +349,11 @@ fn insert_reflect_with_registry_ref( .expect("component should represent a type."); let type_path = type_info.type_path(); let Ok(mut entity) = world.get_entity_mut(entity) else { - panic!( - "error[B0003]: Could not insert a reflected component (of type {type_path}) for entity {entity}, which {}. See: https://bevyengine.org/learn/errors/b0003", - world.entities().entity_does_not_exist_error_details(entity) - ); + panic!("error[B0003]: Could not insert a reflected component (of type {type_path}) for entity {entity}, which {}. See: https://bevyengine.org/learn/errors/b0003", + world.entities().entity_does_not_exist_error_details(entity)); }; let Some(type_registration) = type_registry.get(type_info.type_id()) else { - panic!( - "`{type_path}` should be registered in type registry via `App::register_type<{type_path}>`" - ); + panic!("`{type_path}` should be registered in type registry via `App::register_type<{type_path}>`"); }; if let Some(reflect_component) = type_registration.data::() { diff --git a/crates/bevy_ecs/src/reflect/mod.rs b/crates/bevy_ecs/src/reflect/mod.rs index 50c42530dcbc0..4d94945afc1e9 100644 --- a/crates/bevy_ecs/src/reflect/mod.rs +++ b/crates/bevy_ecs/src/reflect/mod.rs @@ -7,8 +7,8 @@ use core::{ use crate::{resource::Resource, world::World}; use bevy_reflect::{ - PartialReflect, Reflect, ReflectFromReflect, TypePath, TypeRegistry, TypeRegistryArc, - std_traits::ReflectDefault, + std_traits::ReflectDefault, PartialReflect, Reflect, ReflectFromReflect, TypePath, + TypeRegistry, TypeRegistryArc, }; mod bundle; diff --git a/crates/bevy_ecs/src/reflect/resource.rs b/crates/bevy_ecs/src/reflect/resource.rs index 67f9d3024909c..34e593a6ef00e 100644 --- a/crates/bevy_ecs/src/reflect/resource.rs +++ b/crates/bevy_ecs/src/reflect/resource.rs @@ -8,7 +8,7 @@ use crate::{ change_detection::Mut, component::ComponentId, resource::Resource, - world::{FilteredResources, FilteredResourcesMut, World, unsafe_world_cell::UnsafeWorldCell}, + world::{unsafe_world_cell::UnsafeWorldCell, FilteredResources, FilteredResourcesMut, World}, }; use bevy_reflect::{FromReflect, FromType, PartialReflect, Reflect, TypePath, TypeRegistry}; diff --git a/crates/bevy_ecs/src/relationship/mod.rs b/crates/bevy_ecs/src/relationship/mod.rs index 404e2b801536c..540b049541bd9 100644 --- a/crates/bevy_ecs/src/relationship/mod.rs +++ b/crates/bevy_ecs/src/relationship/mod.rs @@ -14,10 +14,9 @@ use crate::{ component::{Component, HookContext, Mutable}, entity::{ComponentCloneCtx, Entity}, system::{ - Commands, command::HandleError, entity_command::{self, CommandWithEntity}, - error_handler, + error_handler, Commands, }, world::{DeferredWorld, EntityWorldMut}, }; @@ -79,9 +78,7 @@ pub trait Relationship: Component + Sized { if target_entity == entity { warn!( "{}The {}({target_entity:?}) relationship on entity {entity:?} points to itself. The invalid {} relationship has been removed.", - caller - .map(|location| format!("{location}: ")) - .unwrap_or_default(), + caller.map(|location|format!("{location}: ")).unwrap_or_default(), core::any::type_name::(), core::any::type_name::() ); @@ -101,9 +98,7 @@ pub trait Relationship: Component + Sized { } else { warn!( "{}The {}({target_entity:?}) relationship on entity {entity:?} relates to an entity that does not exist. The invalid {} relationship has been removed.", - caller - .map(|location| format!("{location}: ")) - .unwrap_or_default(), + caller.map(|location|format!("{location}: ")).unwrap_or_default(), core::any::type_name::(), core::any::type_name::() ); diff --git a/crates/bevy_ecs/src/relationship/relationship_source_collection.rs b/crates/bevy_ecs/src/relationship/relationship_source_collection.rs index 5627e7649a3bf..013cdd63aaf2b 100644 --- a/crates/bevy_ecs/src/relationship/relationship_source_collection.rs +++ b/crates/bevy_ecs/src/relationship/relationship_source_collection.rs @@ -1,4 +1,4 @@ -use crate::entity::{Entity, hash_set::EntityHashSet}; +use crate::entity::{hash_set::EntityHashSet, Entity}; use alloc::vec::Vec; use smallvec::SmallVec; diff --git a/crates/bevy_ecs/src/removal_detection.rs b/crates/bevy_ecs/src/removal_detection.rs index bbfe6ac12771c..a1480a1923144 100644 --- a/crates/bevy_ecs/src/removal_detection.rs +++ b/crates/bevy_ecs/src/removal_detection.rs @@ -7,7 +7,7 @@ use crate::{ prelude::Local, storage::SparseSet, system::{ReadOnlySystemParam, SystemMeta, SystemParam}, - world::{World, unsafe_world_cell::UnsafeWorldCell}, + world::{unsafe_world_cell::UnsafeWorldCell, World}, }; use derive_more::derive::Into; diff --git a/crates/bevy_ecs/src/schedule/auto_insert_apply_deferred.rs b/crates/bevy_ecs/src/schedule/auto_insert_apply_deferred.rs index 901779127d421..8ad4725d86f95 100644 --- a/crates/bevy_ecs/src/schedule/auto_insert_apply_deferred.rs +++ b/crates/bevy_ecs/src/schedule/auto_insert_apply_deferred.rs @@ -6,8 +6,8 @@ use crate::system::IntoSystem; use crate::world::World; use super::{ - ApplyDeferred, DiGraph, Direction, NodeId, ReportCycles, ScheduleBuildError, ScheduleBuildPass, - ScheduleGraph, SystemNode, is_apply_deferred, + is_apply_deferred, ApplyDeferred, DiGraph, Direction, NodeId, ReportCycles, ScheduleBuildError, + ScheduleBuildPass, ScheduleGraph, SystemNode, }; /// A [`ScheduleBuildPass`] that inserts [`ApplyDeferred`] systems into the schedule graph diff --git a/crates/bevy_ecs/src/schedule/condition.rs b/crates/bevy_ecs/src/schedule/condition.rs index 26316f7fbd2c6..1bd0e9f4da304 100644 --- a/crates/bevy_ecs/src/schedule/condition.rs +++ b/crates/bevy_ecs/src/schedule/condition.rs @@ -1262,7 +1262,7 @@ where #[cfg(test)] mod tests { - use super::{Condition, common_conditions::*}; + use super::{common_conditions::*, Condition}; use crate::query::With; use crate::{ change_detection::ResMut, diff --git a/crates/bevy_ecs/src/schedule/config.rs b/crates/bevy_ecs/src/schedule/config.rs index e2f04de785953..898cf674245d2 100644 --- a/crates/bevy_ecs/src/schedule/config.rs +++ b/crates/bevy_ecs/src/schedule/config.rs @@ -4,11 +4,11 @@ use variadics_please::all_tuples; use crate::{ result::Result, schedule::{ - Chain, auto_insert_apply_deferred::IgnoreDeferred, condition::{BoxedCondition, Condition}, graph::{Ambiguity, Dependency, DependencyKind, GraphInfo}, set::{InternedSystemSet, IntoSystemSet, SystemSet}, + Chain, }, system::{BoxedSystem, InfallibleSystemWrapper, IntoSystem, ScheduleSystem, System}, }; diff --git a/crates/bevy_ecs/src/schedule/executor/mod.rs b/crates/bevy_ecs/src/schedule/executor/mod.rs index 427927cede91c..c99d263e046df 100644 --- a/crates/bevy_ecs/src/schedule/executor/mod.rs +++ b/crates/bevy_ecs/src/schedule/executor/mod.rs @@ -21,7 +21,7 @@ use crate::{ result::{Error, Result, SystemErrorContext}, schedule::{BoxedCondition, InternedSystemSet, NodeId, SystemTypeSet}, system::{ScheduleSystem, System, SystemIn}, - world::{DeferredWorld, World, unsafe_world_cell::UnsafeWorldCell}, + world::{unsafe_world_cell::UnsafeWorldCell, DeferredWorld, World}, }; /// Types that can run a [`SystemSchedule`] on a [`World`]. @@ -267,7 +267,7 @@ mod __rust_begin_short_backtrace { use crate::{ result::Result, system::{ReadOnlySystem, ScheduleSystem}, - world::{World, unsafe_world_cell::UnsafeWorldCell}, + world::{unsafe_world_cell::UnsafeWorldCell, World}, }; /// # Safety diff --git a/crates/bevy_ecs/src/schedule/executor/multi_threaded.rs b/crates/bevy_ecs/src/schedule/executor/multi_threaded.rs index 23ef0995c8213..e78cb666aedd4 100644 --- a/crates/bevy_ecs/src/schedule/executor/multi_threaded.rs +++ b/crates/bevy_ecs/src/schedule/executor/multi_threaded.rs @@ -11,16 +11,16 @@ use std::{ }; #[cfg(feature = "trace")] -use tracing::{Span, info_span}; +use tracing::{info_span, Span}; use crate::{ archetype::ArchetypeComponentId, prelude::Resource, query::Access, result::{Error, Result, SystemErrorContext}, - schedule::{BoxedCondition, ExecutorKind, SystemExecutor, SystemSchedule, is_apply_deferred}, + schedule::{is_apply_deferred, BoxedCondition, ExecutorKind, SystemExecutor, SystemSchedule}, system::ScheduleSystem, - world::{World, unsafe_world_cell::UnsafeWorldCell}, + world::{unsafe_world_cell::UnsafeWorldCell, World}, }; use super::__rust_begin_short_backtrace; diff --git a/crates/bevy_ecs/src/schedule/executor/simple.rs b/crates/bevy_ecs/src/schedule/executor/simple.rs index 1ad2a6d599ea9..ad01c324e9ea5 100644 --- a/crates/bevy_ecs/src/schedule/executor/simple.rs +++ b/crates/bevy_ecs/src/schedule/executor/simple.rs @@ -10,7 +10,7 @@ use std::eprintln; use crate::{ result::{Error, SystemErrorContext}, schedule::{ - BoxedCondition, ExecutorKind, SystemExecutor, SystemSchedule, executor::is_apply_deferred, + executor::is_apply_deferred, BoxedCondition, ExecutorKind, SystemExecutor, SystemSchedule, }, world::World, }; diff --git a/crates/bevy_ecs/src/schedule/executor/single_threaded.rs b/crates/bevy_ecs/src/schedule/executor/single_threaded.rs index 7e4a1051c0c1c..b5c44085d5db3 100644 --- a/crates/bevy_ecs/src/schedule/executor/single_threaded.rs +++ b/crates/bevy_ecs/src/schedule/executor/single_threaded.rs @@ -9,7 +9,7 @@ use std::eprintln; use crate::{ result::{Error, SystemErrorContext}, - schedule::{BoxedCondition, ExecutorKind, SystemExecutor, SystemSchedule, is_apply_deferred}, + schedule::{is_apply_deferred, BoxedCondition, ExecutorKind, SystemExecutor, SystemSchedule}, world::World, }; diff --git a/crates/bevy_ecs/src/schedule/graph/node.rs b/crates/bevy_ecs/src/schedule/graph/node.rs index 423c7045340b1..e4af143fc7a78 100644 --- a/crates/bevy_ecs/src/schedule/graph/node.rs +++ b/crates/bevy_ecs/src/schedule/graph/node.rs @@ -31,8 +31,8 @@ impl NodeId { /// Compare this [`NodeId`] with another. pub const fn cmp(&self, other: &Self) -> core::cmp::Ordering { - use NodeId::{Set, System}; use core::cmp::Ordering::{Equal, Greater, Less}; + use NodeId::{Set, System}; match (self, other) { (System(a), System(b)) | (Set(a), Set(b)) => match a.checked_sub(*b) { diff --git a/crates/bevy_ecs/src/schedule/schedule.rs b/crates/bevy_ecs/src/schedule/schedule.rs index 9ad2bce84c3fa..ef6c457332916 100644 --- a/crates/bevy_ecs/src/schedule/schedule.rs +++ b/crates/bevy_ecs/src/schedule/schedule.rs @@ -11,7 +11,7 @@ use alloc::{ vec::Vec, }; use bevy_platform_support::collections::{HashMap, HashSet}; -use bevy_utils::{TypeIdMap, default}; +use bevy_utils::{default, TypeIdMap}; use core::{ any::{Any, TypeId}, fmt::{Debug, Write}, @@ -35,8 +35,8 @@ use crate::{ }; use crate::{query::AccessConflicts, storage::SparseSetIndex}; -use Direction::{Incoming, Outgoing}; pub use stepping::Stepping; +use Direction::{Incoming, Outgoing}; /// Resource that stores [`Schedule`]s mapped to [`ScheduleLabel`]s excluding the current running [`Schedule`]. #[derive(Default, Resource)] @@ -1855,9 +1855,9 @@ impl ScheduleGraph { let n_ambiguities = ambiguities.len(); let mut message = format!( - "{n_ambiguities} pairs of systems with conflicting data access have indeterminate execution order. \ + "{n_ambiguities} pairs of systems with conflicting data access have indeterminate execution order. \ Consider adding `before`, `after`, or `ambiguous_with` relationships between these:\n", - ); + ); for (name_a, name_b, conflicts) in self.conflicts_to_string(ambiguities, components) { writeln!(message, " -- {name_a} and {name_b}").unwrap(); @@ -1942,19 +1942,13 @@ pub enum ScheduleBuildError { #[error("System dependencies contain cycle(s).\n{0}")] DependencyCycle(String), /// Tried to order a system (set) relative to a system set it belongs to. - #[error( - "`{0}` and `{1}` have both `in_set` and `before`-`after` relationships (these might be transitive). This combination is unsolvable as a system cannot run before or after a set it belongs to." - )] + #[error("`{0}` and `{1}` have both `in_set` and `before`-`after` relationships (these might be transitive). This combination is unsolvable as a system cannot run before or after a set it belongs to.")] CrossDependency(String, String), /// Tried to order system sets that share systems. - #[error( - "`{0}` and `{1}` have a `before`-`after` relationship (which may be transitive) but share systems." - )] + #[error("`{0}` and `{1}` have a `before`-`after` relationship (which may be transitive) but share systems.")] SetsHaveOrderButIntersect(String, String), /// Tried to order a system (set) relative to all instances of some system function. - #[error( - "Tried to order against `{0}` in a schedule that has more than one `{0}` instance. `{0}` is a `SystemTypeSet` and cannot be used for ordering if ambiguous. Use a different set without this restriction." - )] + #[error("Tried to order against `{0}` in a schedule that has more than one `{0}` instance. `{0}` is a `SystemTypeSet` and cannot be used for ordering if ambiguous. Use a different set without this restriction.")] SystemTypeSetAmbiguity(String), /// Systems with conflicting access have indeterminate run order. /// @@ -2044,8 +2038,8 @@ mod tests { use crate::{ prelude::{Res, Resource}, schedule::{ - IntoSystemConfigs, IntoSystemSetConfigs, Schedule, ScheduleBuildSettings, SystemSet, - tests::ResMut, + tests::ResMut, IntoSystemConfigs, IntoSystemSetConfigs, Schedule, + ScheduleBuildSettings, SystemSet, }, system::Commands, world::World, @@ -2070,11 +2064,9 @@ mod tests { schedule.configure_sets(Set.run_if(|| false)); schedule.add_systems( - (|| -> () { - panic!("This system must not run"); - }) - .ambiguous_with(|| ()) - .in_set(Set), + (|| -> () { panic!("This system must not run"); }) + .ambiguous_with(|| ()) + .in_set(Set), ); schedule.run(&mut world); } diff --git a/crates/bevy_ecs/src/schedule/set.rs b/crates/bevy_ecs/src/schedule/set.rs index 7a0bfc0675cee..896c7ed050ecc 100644 --- a/crates/bevy_ecs/src/schedule/set.rs +++ b/crates/bevy_ecs/src/schedule/set.rs @@ -218,7 +218,7 @@ where mod tests { use crate::{ resource::Resource, - schedule::{Schedule, tests::ResMut}, + schedule::{tests::ResMut, Schedule}, }; use super::*; diff --git a/crates/bevy_ecs/src/storage/resource.rs b/crates/bevy_ecs/src/storage/resource.rs index 2f253153f73d4..078acade7d9ef 100644 --- a/crates/bevy_ecs/src/storage/resource.rs +++ b/crates/bevy_ecs/src/storage/resource.rs @@ -2,7 +2,7 @@ use crate::{ archetype::ArchetypeComponentId, change_detection::{MaybeLocation, MutUntyped, TicksMut}, component::{ComponentId, ComponentTicks, Components, Tick, TickCells}, - storage::{SparseSet, blob_vec::BlobVec}, + storage::{blob_vec::BlobVec, SparseSet}, }; use alloc::string::String; use bevy_ptr::{OwningPtr, Ptr, UnsafeCellDeref}; diff --git a/crates/bevy_ecs/src/storage/table/mod.rs b/crates/bevy_ecs/src/storage/table/mod.rs index 0d6f42df599d5..159a716c4ed05 100644 --- a/crates/bevy_ecs/src/storage/table/mod.rs +++ b/crates/bevy_ecs/src/storage/table/mod.rs @@ -3,7 +3,7 @@ use crate::{ component::{ComponentId, ComponentInfo, ComponentTicks, Components, Tick}, entity::Entity, query::DebugCheckedUnwrap, - storage::{ImmutableSparseSet, SparseSet, blob_vec::BlobVec}, + storage::{blob_vec::BlobVec, ImmutableSparseSet, SparseSet}, }; use alloc::{boxed::Box, vec, vec::Vec}; use bevy_platform_support::collections::HashMap; diff --git a/crates/bevy_ecs/src/system/adapter_system.rs b/crates/bevy_ecs/src/system/adapter_system.rs index 38dfcaa7a5857..27e812928c8a1 100644 --- a/crates/bevy_ecs/src/system/adapter_system.rs +++ b/crates/bevy_ecs/src/system/adapter_system.rs @@ -3,7 +3,7 @@ use alloc::{borrow::Cow, vec::Vec}; use super::{IntoSystem, ReadOnlySystem, System}; use crate::{ schedule::InternedSystemSet, - system::{SystemIn, input::SystemInput}, + system::{input::SystemInput, SystemIn}, world::unsafe_world_cell::UnsafeWorldCell, }; diff --git a/crates/bevy_ecs/src/system/builder.rs b/crates/bevy_ecs/src/system/builder.rs index ca1d5868f2728..6261b9e35587e 100644 --- a/crates/bevy_ecs/src/system/builder.rs +++ b/crates/bevy_ecs/src/system/builder.rs @@ -16,7 +16,7 @@ use crate::{ }; use core::fmt::Debug; -use super::{Res, ResMut, SystemState, init_query_param}; +use super::{init_query_param, Res, ResMut, SystemState}; /// A builder that can create a [`SystemParam`]. /// @@ -201,8 +201,8 @@ impl ParamBuilder { } /// Helper method for adding a filtered [`Query`] as a param, equivalent to `of::>()` - pub fn query_filtered<'w, 's, D: QueryData + 'static, F: QueryFilter + 'static>() - -> impl SystemParamBuilder> { + pub fn query_filtered<'w, 's, D: QueryData + 'static, F: QueryFilter + 'static>( + ) -> impl SystemParamBuilder> { Self } } @@ -283,12 +283,12 @@ impl<'a, D: QueryData, F: QueryFilter> // SAFETY: Calls `init_query_param`, just like `Query::init_state`. unsafe impl< - 'w, - 's, - D: QueryData + 'static, - F: QueryFilter + 'static, - T: FnOnce(&mut QueryBuilder), -> SystemParamBuilder> for QueryParamBuilder + 'w, + 's, + D: QueryData + 'static, + F: QueryFilter + 'static, + T: FnOnce(&mut QueryBuilder), + > SystemParamBuilder> for QueryParamBuilder { fn build(self, world: &mut World, system_meta: &mut SystemMeta) -> QueryState { let mut builder = QueryBuilder::new(world); @@ -609,9 +609,7 @@ unsafe impl<'w, 's, T: FnOnce(&mut FilteredResourcesBuilder)> if !conflicts.is_empty() { let accesses = conflicts.format_conflict_list(world); let system_name = &meta.name; - panic!( - "error[B0002]: FilteredResources in system {system_name} accesses resources(s){accesses} in a way that conflicts with a previous system parameter. Consider removing the duplicate access. See: https://bevyengine.org/learn/errors/b0002" - ); + panic!("error[B0002]: FilteredResources in system {system_name} accesses resources(s){accesses} in a way that conflicts with a previous system parameter. Consider removing the duplicate access. See: https://bevyengine.org/learn/errors/b0002"); } if access.has_read_all_resources() { @@ -675,9 +673,7 @@ unsafe impl<'w, 's, T: FnOnce(&mut FilteredResourcesMutBuilder)> if !conflicts.is_empty() { let accesses = conflicts.format_conflict_list(world); let system_name = &meta.name; - panic!( - "error[B0002]: FilteredResourcesMut in system {system_name} accesses resources(s){accesses} in a way that conflicts with a previous system parameter. Consider removing the duplicate access. See: https://bevyengine.org/learn/errors/b0002" - ); + panic!("error[B0002]: FilteredResourcesMut in system {system_name} accesses resources(s){accesses} in a way that conflicts with a previous system parameter. Consider removing the duplicate access. See: https://bevyengine.org/learn/errors/b0002"); } if access.has_read_all_resources() { diff --git a/crates/bevy_ecs/src/system/combinator.rs b/crates/bevy_ecs/src/system/combinator.rs index 6244e86669824..f6e696a106a96 100644 --- a/crates/bevy_ecs/src/system/combinator.rs +++ b/crates/bevy_ecs/src/system/combinator.rs @@ -7,7 +7,7 @@ use crate::{ prelude::World, query::Access, schedule::InternedSystemSet, - system::{SystemIn, input::SystemInput}, + system::{input::SystemInput, SystemIn}, world::unsafe_world_cell::UnsafeWorldCell, }; diff --git a/crates/bevy_ecs/src/system/commands/command.rs b/crates/bevy_ecs/src/system/commands/command.rs index d7144fbcfbf21..68035560d018e 100644 --- a/crates/bevy_ecs/src/system/commands/command.rs +++ b/crates/bevy_ecs/src/system/commands/command.rs @@ -13,7 +13,7 @@ use crate::{ resource::Resource, result::{Error, Result}, schedule::ScheduleLabel, - system::{IntoSystem, SystemId, SystemInput, error_handler}, + system::{error_handler, IntoSystem, SystemId, SystemInput}, world::{FromWorld, SpawnBatchIter, World}, }; diff --git a/crates/bevy_ecs/src/system/commands/entity_command.rs b/crates/bevy_ecs/src/system/commands/entity_command.rs index e72121a0d2d92..20dd9e0289f2c 100644 --- a/crates/bevy_ecs/src/system/commands/entity_command.rs +++ b/crates/bevy_ecs/src/system/commands/entity_command.rs @@ -14,8 +14,8 @@ use crate::{ entity::{Entity, EntityClonerBuilder}, event::Event, result::Result, - system::{Command, IntoObserverSystem, command::HandleError}, - world::{EntityWorldMut, FromWorld, World, error::EntityMutableFetchError}, + system::{command::HandleError, Command, IntoObserverSystem}, + world::{error::EntityMutableFetchError, EntityWorldMut, FromWorld, World}, }; use bevy_ptr::OwningPtr; @@ -101,7 +101,7 @@ impl CommandWithEntity> fo self, entity: Entity, ) -> impl Command> - + HandleError> { + + HandleError> { move |world: &mut World| -> Result<(), EntityMutableFetchError> { let entity = world.get_entity_mut(entity)?; self.apply(entity); @@ -111,10 +111,10 @@ impl CommandWithEntity> fo } impl< - C: EntityCommand>, - T, - Err: core::fmt::Debug + core::fmt::Display + Send + Sync + 'static, -> CommandWithEntity>> for C + C: EntityCommand>, + T, + Err: core::fmt::Debug + core::fmt::Display + Send + Sync + 'static, + > CommandWithEntity>> for C { fn with_entity( self, diff --git a/crates/bevy_ecs/src/system/commands/mod.rs b/crates/bevy_ecs/src/system/commands/mod.rs index c4ffa5422e34a..04d0940a44c65 100644 --- a/crates/bevy_ecs/src/system/commands/mod.rs +++ b/crates/bevy_ecs/src/system/commands/mod.rs @@ -27,12 +27,12 @@ use crate::{ result::Error, schedule::ScheduleLabel, system::{ - Deferred, IntoObserverSystem, IntoSystem, RegisteredSystem, SystemId, command::HandleError, - entity_command::CommandWithEntity, input::SystemInput, + command::HandleError, entity_command::CommandWithEntity, input::SystemInput, Deferred, + IntoObserverSystem, IntoSystem, RegisteredSystem, SystemId, }, world::{ - CommandQueue, EntityWorldMut, FromWorld, World, command_queue::RawCommandQueue, - unsafe_world_cell::UnsafeWorldCell, + command_queue::RawCommandQueue, unsafe_world_cell::UnsafeWorldCell, CommandQueue, + EntityWorldMut, FromWorld, World, }, }; @@ -2201,7 +2201,7 @@ impl<'a, T: Component> EntityEntryCommands<'a, T> { #[cfg(test)] mod tests { use crate::{ - component::{Component, require}, + component::{require, Component}, resource::Resource, system::Commands, world::{CommandQueue, FromWorld, World}, diff --git a/crates/bevy_ecs/src/system/exclusive_function_system.rs b/crates/bevy_ecs/src/system/exclusive_function_system.rs index c0989aa7ad156..2b1c081d51db0 100644 --- a/crates/bevy_ecs/src/system/exclusive_function_system.rs +++ b/crates/bevy_ecs/src/system/exclusive_function_system.rs @@ -4,10 +4,10 @@ use crate::{ query::Access, schedule::{InternedSystemSet, SystemSet}, system::{ - ExclusiveSystemParam, ExclusiveSystemParamItem, IntoSystem, System, SystemIn, SystemInput, - SystemMeta, check_system_change_tick, + check_system_change_tick, ExclusiveSystemParam, ExclusiveSystemParamItem, IntoSystem, + System, SystemIn, SystemInput, SystemMeta, }, - world::{World, unsafe_world_cell::UnsafeWorldCell}, + world::{unsafe_world_cell::UnsafeWorldCell, World}, }; use alloc::{borrow::Cow, vec, vec::Vec}; diff --git a/crates/bevy_ecs/src/system/function_system.rs b/crates/bevy_ecs/src/system/function_system.rs index 151a5ec95a73a..0f3950d1d4ba6 100644 --- a/crates/bevy_ecs/src/system/function_system.rs +++ b/crates/bevy_ecs/src/system/function_system.rs @@ -5,10 +5,10 @@ use crate::{ query::{Access, FilteredAccessSet}, schedule::{InternedSystemSet, SystemSet}, system::{ - ReadOnlySystemParam, System, SystemIn, SystemInput, SystemParam, SystemParamItem, - check_system_change_tick, + check_system_change_tick, ReadOnlySystemParam, System, SystemIn, SystemInput, SystemParam, + SystemParamItem, }, - world::{DeferredWorld, World, WorldId, unsafe_world_cell::UnsafeWorldCell}, + world::{unsafe_world_cell::UnsafeWorldCell, DeferredWorld, World, WorldId}, }; use alloc::{borrow::Cow, vec, vec::Vec}; @@ -16,7 +16,7 @@ use core::marker::PhantomData; use variadics_please::all_tuples; #[cfg(feature = "trace")] -use tracing::{Span, info_span}; +use tracing::{info_span, Span}; use super::{IntoSystem, ReadOnlySystem, SystemParamBuilder}; @@ -537,9 +537,7 @@ impl SystemState { #[track_caller] #[cold] fn panic_mismatched(this: WorldId, other: WorldId) -> ! { - panic!( - "Encountered a mismatched World. This SystemState was created from {this:?}, but a method was called using {other:?}." - ); + panic!("Encountered a mismatched World. This SystemState was created from {this:?}, but a method was called using {other:?}."); } if !self.matches_world(world_id) { @@ -570,11 +568,7 @@ impl SystemState { /// This method only accesses world metadata. #[inline] pub fn update_archetypes_unsafe_world_cell(&mut self, world: UnsafeWorldCell) { - assert_eq!( - self.world_id, - world.id(), - "Encountered a mismatched World. A System cannot be used with Worlds other than the one it was initialized with." - ); + assert_eq!(self.world_id, world.id(), "Encountered a mismatched World. A System cannot be used with Worlds other than the one it was initialized with."); let archetypes = world.archetypes(); let old_generation = @@ -886,11 +880,7 @@ where fn update_archetype_component_access(&mut self, world: UnsafeWorldCell) { let state = self.state.as_mut().expect(Self::ERROR_UNINITIALIZED); - assert_eq!( - state.world_id, - world.id(), - "Encountered a mismatched World. A System cannot be used with Worlds other than the one it was initialized with." - ); + assert_eq!(state.world_id, world.id(), "Encountered a mismatched World. A System cannot be used with Worlds other than the one it was initialized with."); let archetypes = world.archetypes(); let old_generation = diff --git a/crates/bevy_ecs/src/system/mod.rs b/crates/bevy_ecs/src/system/mod.rs index df7f34fc2eb49..43f9c612d13c3 100644 --- a/crates/bevy_ecs/src/system/mod.rs +++ b/crates/bevy_ecs/src/system/mod.rs @@ -341,8 +341,8 @@ mod tests { resource::Resource, result::Result, schedule::{ - ApplyDeferred, Condition, IntoSystemConfigs, Schedule, - common_conditions::resource_exists, + common_conditions::resource_exists, ApplyDeferred, Condition, IntoSystemConfigs, + Schedule, }, system::{ Commands, In, IntoSystem, Local, NonSend, NonSendMut, ParamSet, Query, Res, ResMut, @@ -1490,11 +1490,9 @@ mod tests { system.initialize(&mut world); system.update_archetype_component_access(world.as_unsafe_world_cell()); let archetype_component_access = system.archetype_component_access(); - assert!( - expected_ids - .iter() - .all(|id| archetype_component_access.has_component_read(*id)) - ); + assert!(expected_ids + .iter() + .all(|id| archetype_component_access.has_component_read(*id))); // add some entities with archetypes that should match and save their ids expected_ids.insert( @@ -1519,11 +1517,9 @@ mod tests { // update system and verify its accesses are correct system.update_archetype_component_access(world.as_unsafe_world_cell()); let archetype_component_access = system.archetype_component_access(); - assert!( - expected_ids - .iter() - .all(|id| archetype_component_access.has_component_read(*id)) - ); + assert!(expected_ids + .iter() + .all(|id| archetype_component_access.has_component_read(*id))); // one more round expected_ids.insert( @@ -1536,11 +1532,9 @@ mod tests { world.spawn((A, B, D)); system.update_archetype_component_access(world.as_unsafe_world_cell()); let archetype_component_access = system.archetype_component_access(); - assert!( - expected_ids - .iter() - .all(|id| archetype_component_access.has_component_read(*id)) - ); + assert!(expected_ids + .iter() + .all(|id| archetype_component_access.has_component_read(*id))); } #[test] @@ -1654,9 +1648,7 @@ mod tests { #[should_panic] fn panic_inside_system() { let mut world = World::new(); - run_system(&mut world, || -> () { - panic!("this system panics"); - }); + run_system(&mut world, || -> () { panic!("this system panics"); }); } #[test] diff --git a/crates/bevy_ecs/src/system/observer_system.rs b/crates/bevy_ecs/src/system/observer_system.rs index 6cdd2ccdb2d00..8a8f82d99e361 100644 --- a/crates/bevy_ecs/src/system/observer_system.rs +++ b/crates/bevy_ecs/src/system/observer_system.rs @@ -8,8 +8,8 @@ use crate::{ query::Access, result::Result, schedule::{Fallible, Infallible}, - system::{System, input::SystemIn}, - world::{DeferredWorld, World, unsafe_world_cell::UnsafeWorldCell}, + system::{input::SystemIn, System}, + world::{unsafe_world_cell::UnsafeWorldCell, DeferredWorld, World}, }; use super::IntoSystem; diff --git a/crates/bevy_ecs/src/system/query.rs b/crates/bevy_ecs/src/system/query.rs index 2ec95b25f2752..a0457dc667b71 100644 --- a/crates/bevy_ecs/src/system/query.rs +++ b/crates/bevy_ecs/src/system/query.rs @@ -2596,12 +2596,10 @@ mod tests { // We don't care about aliased mutability for the read-only equivalent // SAFETY: Query does not access world data. - assert!( - query_state - .query_mut(&mut world) - .get_many_inner::<10>(entities.clone().try_into().unwrap()) - .is_ok() - ); + assert!(query_state + .query_mut(&mut world) + .get_many_inner::<10>(entities.clone().try_into().unwrap()) + .is_ok()); assert_eq!( query_state diff --git a/crates/bevy_ecs/src/system/schedule_system.rs b/crates/bevy_ecs/src/system/schedule_system.rs index cba0cb760b674..e0005f06f46d9 100644 --- a/crates/bevy_ecs/src/system/schedule_system.rs +++ b/crates/bevy_ecs/src/system/schedule_system.rs @@ -5,8 +5,8 @@ use crate::{ component::{ComponentId, Tick}, query::Access, result::Result, - system::{BoxedSystem, System, input::SystemIn}, - world::{DeferredWorld, World, unsafe_world_cell::UnsafeWorldCell}, + system::{input::SystemIn, BoxedSystem, System}, + world::{unsafe_world_cell::UnsafeWorldCell, DeferredWorld, World}, }; use super::IntoSystem; diff --git a/crates/bevy_ecs/src/system/system.rs b/crates/bevy_ecs/src/system/system.rs index e3959163ad891..d0990e907f8ec 100644 --- a/crates/bevy_ecs/src/system/system.rs +++ b/crates/bevy_ecs/src/system/system.rs @@ -11,8 +11,8 @@ use crate::{ component::{ComponentId, Tick}, query::Access, schedule::InternedSystemSet, - system::{SystemIn, input::SystemInput}, - world::{DeferredWorld, World, unsafe_world_cell::UnsafeWorldCell}, + system::{input::SystemInput, SystemIn}, + world::{unsafe_world_cell::UnsafeWorldCell, DeferredWorld, World}, }; use alloc::{borrow::Cow, boxed::Box, vec::Vec}; @@ -73,7 +73,7 @@ pub trait System: Send + Sync + 'static { /// point before this one, with the same exact [`World`]. If [`System::update_archetype_component_access`] /// panics (or otherwise does not return for any reason), this method must not be called. unsafe fn run_unsafe(&mut self, input: SystemIn<'_, Self>, world: UnsafeWorldCell) - -> Self::Out; + -> Self::Out; /// Runs the system with the given input in the world. /// @@ -366,9 +366,7 @@ pub enum RunSystemError { /// System could not be run due to parameters that failed validation. /// /// This can occur because the data required by the system was not present in the world. - #[error( - "The data required by the system {0:?} was not found in the world and the system did not run due to failed parameter validation." - )] + #[error("The data required by the system {0:?} was not found in the world and the system did not run due to failed parameter validation.")] InvalidParams(Cow<'static, str>), } diff --git a/crates/bevy_ecs/src/system/system_param.rs b/crates/bevy_ecs/src/system/system_param.rs index 73616dae19708..8ef804a926be5 100644 --- a/crates/bevy_ecs/src/system/system_param.rs +++ b/crates/bevy_ecs/src/system/system_param.rs @@ -13,8 +13,8 @@ use crate::{ storage::ResourceData, system::{Query, Single, SystemMeta}, world::{ - DeferredWorld, FilteredResources, FilteredResourcesMut, FromWorld, World, - unsafe_world_cell::UnsafeWorldCell, + unsafe_world_cell::UnsafeWorldCell, DeferredWorld, FilteredResources, FilteredResourcesMut, + FromWorld, World, }, }; use alloc::{borrow::ToOwned, boxed::Box, vec::Vec}; @@ -373,11 +373,7 @@ fn assert_component_access_compatibility( if !accesses.is_empty() { accesses.push(' '); } - panic!( - "error[B0001]: Query<{}, {}> in system {system_name} accesses component(s) {accesses}in a way that conflicts with a previous system parameter. Consider using `Without` to create disjoint Queries or merging conflicting Queries into a `ParamSet`. See: https://bevyengine.org/learn/errors/b0001", - ShortName(query_type), - ShortName(filter_type) - ); + panic!("error[B0001]: Query<{}, {}> in system {system_name} accesses component(s) {accesses}in a way that conflicts with a previous system parameter. Consider using `Without` to create disjoint Queries or merging conflicting Queries into a `ParamSet`. See: https://bevyengine.org/learn/errors/b0001", ShortName(query_type), ShortName(filter_type)); } // SAFETY: Relevant query ComponentId and ArchetypeComponentId access is applied to SystemMeta. If @@ -937,15 +933,11 @@ unsafe impl<'a, T: Resource> SystemParam for ResMut<'a, T> { if combined_access.has_resource_write(component_id) { panic!( "error[B0002]: ResMut<{}> in system {} conflicts with a previous ResMut<{0}> access. Consider removing the duplicate access. See: https://bevyengine.org/learn/errors/b0002", - core::any::type_name::(), - system_meta.name - ); + core::any::type_name::(), system_meta.name); } else if combined_access.has_resource_read(component_id) { panic!( "error[B0002]: ResMut<{}> in system {} conflicts with a previous Res<{0}> access. Consider removing the duplicate access. See: https://bevyengine.org/learn/errors/b0002", - core::any::type_name::(), - system_meta.name - ); + core::any::type_name::(), system_meta.name); } system_meta .component_access_set @@ -1050,9 +1042,7 @@ unsafe impl SystemParam for &'_ World { .archetype_component_access .is_compatible(&access) { - panic!( - "&World conflicts with a previous mutable system parameter. Allowing this would break Rust's mutability rules" - ); + panic!("&World conflicts with a previous mutable system parameter. Allowing this would break Rust's mutability rules"); } system_meta.archetype_component_access.extend(&access); @@ -1064,9 +1054,7 @@ unsafe impl SystemParam for &'_ World { .get_conflicts_single(&filtered_access) .is_empty() { - panic!( - "&World conflicts with a previous mutable system parameter. Allowing this would break Rust's mutability rules" - ); + panic!("&World conflicts with a previous mutable system parameter. Allowing this would break Rust's mutability rules"); } system_meta.component_access_set.add(filtered_access); } @@ -1624,15 +1612,11 @@ unsafe impl<'a, T: 'static> SystemParam for NonSendMut<'a, T> { if combined_access.has_component_write(component_id) { panic!( "error[B0002]: NonSendMut<{}> in system {} conflicts with a previous mutable resource access ({0}). Consider removing the duplicate access. See: https://bevyengine.org/learn/errors/b0002", - core::any::type_name::(), - system_meta.name - ); + core::any::type_name::(), system_meta.name); } else if combined_access.has_component_read(component_id) { panic!( "error[B0002]: NonSendMut<{}> in system {} conflicts with a previous immutable resource access ({0}). Consider removing the duplicate access. See: https://bevyengine.org/learn/errors/b0002", - core::any::type_name::(), - system_meta.name - ); + core::any::type_name::(), system_meta.name); } system_meta .component_access_set diff --git a/crates/bevy_ecs/src/system/system_registry.rs b/crates/bevy_ecs/src/system/system_registry.rs index 52b74ee5d073c..2d849dda95666 100644 --- a/crates/bevy_ecs/src/system/system_registry.rs +++ b/crates/bevy_ecs/src/system/system_registry.rs @@ -3,11 +3,11 @@ use crate::reflect::ReflectComponent; use crate::{ change_detection::Mut, entity::Entity, - system::{BoxedSystem, IntoSystem, System, input::SystemInput}, + system::{input::SystemInput, BoxedSystem, IntoSystem, System}, world::World, }; use alloc::boxed::Box; -use bevy_ecs_macros::{Component, Resource, require}; +use bevy_ecs_macros::{require, Component, Resource}; #[cfg(feature = "bevy_reflect")] use bevy_reflect::Reflect; use core::marker::PhantomData; @@ -477,9 +477,7 @@ pub enum RegisteredSystemError { /// System could not be run due to parameters that failed validation. /// /// This can occur because the data required by the system was not present in the world. - #[error( - "The data required by the system {0:?} was not found in the world and the system did not run due to failed parameter validation." - )] + #[error("The data required by the system {0:?} was not found in the world and the system did not run due to failed parameter validation.")] InvalidParams(SystemId), } @@ -538,8 +536,8 @@ mod tests { fn local_variables() { // The `Local` begins at the default value of 0 fn doubling(last_counter: Local, mut counter: ResMut) { - counter.0 += last_counter.0.0; - last_counter.0.0 = counter.0; + counter.0 += last_counter.0 .0; + last_counter.0 .0 = counter.0; } let mut world = World::new(); diff --git a/crates/bevy_ecs/src/world/command_queue.rs b/crates/bevy_ecs/src/world/command_queue.rs index b4f9cf613d060..e8f820c0661f4 100644 --- a/crates/bevy_ecs/src/world/command_queue.rs +++ b/crates/bevy_ecs/src/world/command_queue.rs @@ -6,9 +6,9 @@ use alloc::{boxed::Box, vec::Vec}; use bevy_ptr::{OwningPtr, Unaligned}; use core::{ fmt::Debug, - mem::{MaybeUninit, size_of}, + mem::{size_of, MaybeUninit}, panic::AssertUnwindSafe, - ptr::{NonNull, addr_of_mut}, + ptr::{addr_of_mut, NonNull}, }; use log::warn; @@ -311,9 +311,7 @@ impl RawCommandQueue { impl Drop for CommandQueue { fn drop(&mut self) { if !self.bytes.is_empty() { - warn!( - "CommandQueue has un-applied commands being dropped. Did you forget to call SystemState::apply?" - ); + warn!("CommandQueue has un-applied commands being dropped. Did you forget to call SystemState::apply?"); } // SAFETY: A reference is always a valid pointer unsafe { self.get_raw().apply_or_drop_queued(None) }; diff --git a/crates/bevy_ecs/src/world/deferred_world.rs b/crates/bevy_ecs/src/world/deferred_world.rs index 9e0622e1500b6..654d35266e29a 100644 --- a/crates/bevy_ecs/src/world/deferred_world.rs +++ b/crates/bevy_ecs/src/world/deferred_world.rs @@ -12,10 +12,10 @@ use crate::{ resource::Resource, system::{Commands, Query}, traversal::Traversal, - world::{WorldEntityFetch, error::EntityMutableFetchError}, + world::{error::EntityMutableFetchError, WorldEntityFetch}, }; -use super::{Mut, ON_INSERT, ON_REPLACE, World, unsafe_world_cell::UnsafeWorldCell}; +use super::{unsafe_world_cell::UnsafeWorldCell, Mut, World, ON_INSERT, ON_REPLACE}; /// A [`World`] reference that disallows structural ECS changes. /// This includes initializing resources, registering components or spawning entities. diff --git a/crates/bevy_ecs/src/world/entity_fetch.rs b/crates/bevy_ecs/src/world/entity_fetch.rs index cddb6effa584d..e731582f48b85 100644 --- a/crates/bevy_ecs/src/world/entity_fetch.rs +++ b/crates/bevy_ecs/src/world/entity_fetch.rs @@ -2,10 +2,10 @@ use alloc::vec::Vec; use core::mem::MaybeUninit; use crate::{ - entity::{Entity, EntityDoesNotExistError, hash_map::EntityHashMap, hash_set::EntityHashSet}, + entity::{hash_map::EntityHashMap, hash_set::EntityHashSet, Entity, EntityDoesNotExistError}, world::{ - EntityMut, EntityRef, EntityWorldMut, error::EntityMutableFetchError, - unsafe_world_cell::UnsafeWorldCell, + error::EntityMutableFetchError, unsafe_world_cell::UnsafeWorldCell, EntityMut, EntityRef, + EntityWorldMut, }, }; diff --git a/crates/bevy_ecs/src/world/entity_ref.rs b/crates/bevy_ecs/src/world/entity_ref.rs index f36e0c7ff1850..17367e56df70f 100644 --- a/crates/bevy_ecs/src/world/entity_ref.rs +++ b/crates/bevy_ecs/src/world/entity_ref.rs @@ -18,8 +18,8 @@ use crate::{ storage::Storages, system::IntoObserverSystem, world::{ - DeferredWorld, Mut, ON_DESPAWN, ON_REMOVE, ON_REPLACE, Ref, World, - error::EntityComponentError, unsafe_world_cell::UnsafeEntityCell, + error::EntityComponentError, unsafe_world_cell::UnsafeEntityCell, DeferredWorld, Mut, Ref, + World, ON_DESPAWN, ON_REMOVE, ON_REPLACE, }, }; use alloc::vec::Vec; @@ -4493,8 +4493,8 @@ mod tests { change_detection::{MaybeLocation, MutUntyped}, component::ComponentId, prelude::*, - system::{RunSystemOnce as _, assert_is_system}, - world::{DeferredWorld, FilteredEntityMut, FilteredEntityRef, error::EntityComponentError}, + system::{assert_is_system, RunSystemOnce as _}, + world::{error::EntityComponentError, DeferredWorld, FilteredEntityMut, FilteredEntityRef}, }; use super::{EntityMutExcept, EntityRefExcept}; @@ -5003,11 +5003,9 @@ mod tests { fn system(_: Query<&mut TestComponent>, mut query: Query>) { for mut entity_mut in query.iter_mut() { - assert!( - entity_mut - .get_mut::() - .is_some_and(|component| component.0 == 0) - ); + assert!(entity_mut + .get_mut::() + .is_some_and(|component| component.0 == 0)); } } } @@ -5023,11 +5021,9 @@ mod tests { fn system(_: Query<&mut TestComponent>, mut query: Query>) { for mut entity_mut in query.iter_mut() { - assert!( - entity_mut - .get_mut::() - .is_some_and(|component| component.0 == 0) - ); + assert!(entity_mut + .get_mut::() + .is_some_and(|component| component.0 == 0)); } } } diff --git a/crates/bevy_ecs/src/world/error.rs b/crates/bevy_ecs/src/world/error.rs index d9597a9bbe349..1542a128512d6 100644 --- a/crates/bevy_ecs/src/world/error.rs +++ b/crates/bevy_ecs/src/world/error.rs @@ -21,9 +21,7 @@ pub struct TryRunScheduleError(pub InternedScheduleLabel); /// [`World::try_insert_batch`]: crate::world::World::try_insert_batch /// [`World::try_insert_batch_if_new`]: crate::world::World::try_insert_batch_if_new #[derive(thiserror::Error, Debug, Clone)] -#[error( - "Could not insert bundles of type {bundle_type} into the entities with the following IDs because they do not exist: {entities:?}" -)] +#[error("Could not insert bundles of type {bundle_type} into the entities with the following IDs because they do not exist: {entities:?}")] pub struct TryInsertBatchError { /// The bundles' type name. pub bundle_type: &'static str, diff --git a/crates/bevy_ecs/src/world/filtered_resource.rs b/crates/bevy_ecs/src/world/filtered_resource.rs index 269e3ae000837..e5197e05703b6 100644 --- a/crates/bevy_ecs/src/world/filtered_resource.rs +++ b/crates/bevy_ecs/src/world/filtered_resource.rs @@ -3,7 +3,7 @@ use crate::{ component::{ComponentId, Tick}, query::Access, resource::Resource, - world::{World, unsafe_world_cell::UnsafeWorldCell}, + world::{unsafe_world_cell::UnsafeWorldCell, World}, }; use bevy_ptr::{Ptr, UnsafeCellDeref}; diff --git a/crates/bevy_ecs/src/world/mod.rs b/crates/bevy_ecs/src/world/mod.rs index 4ae12262b9c7f..db812ff1652a7 100644 --- a/crates/bevy_ecs/src/world/mod.rs +++ b/crates/bevy_ecs/src/world/mod.rs @@ -15,7 +15,7 @@ pub mod unsafe_world_cell; pub mod reflect; pub use crate::{ - change_detection::{CHECK_TICK_THRESHOLD, Mut, Ref}, + change_detection::{Mut, Ref, CHECK_TICK_THRESHOLD}, world::command_queue::CommandQueue, }; pub use bevy_ecs_macros::FromWorld; @@ -264,11 +264,7 @@ impl World { /// Will panic if `T` exists in any archetypes. pub fn register_component_hooks(&mut self) -> &mut ComponentHooks { let index = self.register_component::(); - assert!( - !self.archetypes.archetypes.iter().any(|a| a.contains(index)), - "Components hooks cannot be modified if the component already exists in an archetype, use register_component if {} may already be in use", - core::any::type_name::() - ); + assert!(!self.archetypes.archetypes.iter().any(|a| a.contains(index)), "Components hooks cannot be modified if the component already exists in an archetype, use register_component if {} may already be in use", core::any::type_name::()); // SAFETY: We just created this component unsafe { self.components.get_hooks_mut(index).debug_checked_unwrap() } } @@ -280,11 +276,7 @@ impl World { &mut self, id: ComponentId, ) -> Option<&mut ComponentHooks> { - assert!( - !self.archetypes.archetypes.iter().any(|a| a.contains(id)), - "Components hooks cannot be modified if the component already exists in an archetype, use register_component if the component with id {:?} may already be in use", - id - ); + assert!(!self.archetypes.archetypes.iter().any(|a| a.contains(id)), "Components hooks cannot be modified if the component already exists in an archetype, use register_component if the component with id {:?} may already be in use", id); self.components.get_hooks_mut(id) } @@ -2404,20 +2396,11 @@ impl World { .insert(entity, location, bundle, insert_mode, caller) }; } else { - panic!( - "error[B0003]: Could not insert a bundle (of type `{}`) for entity {entity}, which {}. See: https://bevyengine.org/learn/errors/b0003", - core::any::type_name::(), - self.entities.entity_does_not_exist_error_details(entity) - ); + panic!("error[B0003]: Could not insert a bundle (of type `{}`) for entity {entity}, which {}. See: https://bevyengine.org/learn/errors/b0003", core::any::type_name::(), self.entities.entity_does_not_exist_error_details(entity)); } } } else { - panic!( - "error[B0003]: Could not insert a bundle (of type `{}`) for entity {first_entity}, which {}. See: https://bevyengine.org/learn/errors/b0003", - core::any::type_name::(), - self.entities - .entity_does_not_exist_error_details(first_entity) - ); + panic!("error[B0003]: Could not insert a bundle (of type `{}`) for entity {first_entity}, which {}. See: https://bevyengine.org/learn/errors/b0003", core::any::type_name::(), self.entities.entity_does_not_exist_error_details(first_entity)); } } } @@ -2643,12 +2626,10 @@ impl World { changed_by: caller.as_mut(), }; let result = f(self, value_mut); - assert!( - !self.contains_resource::(), + assert!(!self.contains_resource::(), "Resource `{}` was inserted during a call to World::resource_scope.\n\ This is not allowed as the original resource is reinserted to the world after the closure is invoked.", - core::any::type_name::() - ); + core::any::type_name::()); OwningPtr::make(value, |ptr| { // SAFETY: pointer is of type R @@ -3442,9 +3423,7 @@ impl World { let old = self.resource_mut::().insert(schedule); if old.is_some() { - warn!( - "Schedule `{label:?}` was inserted during a call to `World::schedule_scope`: its value has been overwritten" - ); + warn!("Schedule `{label:?}` was inserted during a call to `World::schedule_scope`: its value has been overwritten"); } Ok(value) @@ -4170,17 +4149,13 @@ mod tests { assert!(world.get_entity(e1).is_ok()); assert!(world.get_entity([e1, e2]).is_ok()); - assert!( - world - .get_entity(&[e1, e2] /* this is an array not a slice */) - .is_ok() - ); + assert!(world + .get_entity(&[e1, e2] /* this is an array not a slice */) + .is_ok()); assert!(world.get_entity(&vec![e1, e2][..]).is_ok()); - assert!( - world - .get_entity(&EntityHashSet::from_iter([e1, e2])) - .is_ok() - ); + assert!(world + .get_entity(&EntityHashSet::from_iter([e1, e2])) + .is_ok()); world.entity_mut(e1).despawn(); @@ -4224,17 +4199,13 @@ mod tests { assert!(world.get_entity_mut(e1).is_ok()); assert!(world.get_entity_mut([e1, e2]).is_ok()); - assert!( - world - .get_entity_mut(&[e1, e2] /* this is an array not a slice */) - .is_ok() - ); + assert!(world + .get_entity_mut(&[e1, e2] /* this is an array not a slice */) + .is_ok()); assert!(world.get_entity_mut(&vec![e1, e2][..]).is_ok()); - assert!( - world - .get_entity_mut(&EntityHashSet::from_iter([e1, e2])) - .is_ok() - ); + assert!(world + .get_entity_mut(&EntityHashSet::from_iter([e1, e2])) + .is_ok()); assert_eq!( Err(EntityMutableFetchError::AliasedMutability(e1)), @@ -4251,11 +4222,9 @@ mod tests { world.get_entity_mut(&vec![e1, e2, e1][..]).map(|_| {}) ); // Aliased mutability isn't allowed by HashSets - assert!( - world - .get_entity_mut(&EntityHashSet::from_iter([e1, e2, e1])) - .is_ok() - ); + assert!(world + .get_entity_mut(&EntityHashSet::from_iter([e1, e2, e1])) + .is_ok()); world.entity_mut(e1).despawn(); diff --git a/crates/bevy_ecs/src/world/reflect.rs b/crates/bevy_ecs/src/world/reflect.rs index a8df06e1e781c..4337416aa2dc9 100644 --- a/crates/bevy_ecs/src/world/reflect.rs +++ b/crates/bevy_ecs/src/world/reflect.rs @@ -213,9 +213,7 @@ pub enum GetComponentReflectError { NoCorrespondingComponentId(TypeId), /// The given [`Entity`] does not have a [`Component`] corresponding to the given [`TypeId`]. - #[error( - "The given `Entity` {entity} does not have a `{component_name:?}` component ({component_id:?}, which corresponds to {type_id:?})" - )] + #[error("The given `Entity` {entity} does not have a `{component_name:?}` component ({component_id:?}, which corresponds to {type_id:?})")] EntityDoesNotHaveComponent { /// The given [`Entity`]. entity: Entity, @@ -243,9 +241,7 @@ pub enum GetComponentReflectError { /// [`TypeRegistry`]: bevy_reflect::TypeRegistry /// [`ReflectFromPtr`]: bevy_reflect::ReflectFromPtr /// [`App::register_type`]: ../../../bevy_app/struct.App.html#method.register_type - #[error( - "The `World`'s `TypeRegistry` did not contain `TypeData` for `ReflectFromPtr` for the given {0:?} (did you call `App::register_type()`?)" - )] + #[error("The `World`'s `TypeRegistry` did not contain `TypeData` for `ReflectFromPtr` for the given {0:?} (did you call `App::register_type()`?)")] MissingReflectFromPtrTypeData(TypeId), } diff --git a/crates/bevy_gilrs/src/gilrs_system.rs b/crates/bevy_gilrs/src/gilrs_system.rs index 1bb900e8bbce9..05f9aa02e9692 100644 --- a/crates/bevy_gilrs/src/gilrs_system.rs +++ b/crates/bevy_gilrs/src/gilrs_system.rs @@ -1,6 +1,6 @@ use crate::{ - Gilrs, GilrsGamepads, converter::{convert_axis, convert_button}, + Gilrs, GilrsGamepads, }; use bevy_ecs::event::EventWriter; use bevy_ecs::prelude::Commands; @@ -11,7 +11,7 @@ use bevy_input::gamepad::{ GamepadConnection, GamepadConnectionEvent, RawGamepadAxisChangedEvent, RawGamepadButtonChangedEvent, RawGamepadEvent, }; -use gilrs::{EventType, Filter, ev::filter::axis_dpad_to_button}; +use gilrs::{ev::filter::axis_dpad_to_button, EventType, Filter}; pub fn gilrs_event_startup_system( mut commands: Commands, diff --git a/crates/bevy_gilrs/src/lib.rs b/crates/bevy_gilrs/src/lib.rs index 3b143173f2aad..b9f1443e5b245 100644 --- a/crates/bevy_gilrs/src/lib.rs +++ b/crates/bevy_gilrs/src/lib.rs @@ -22,7 +22,7 @@ use bevy_platform_support::collections::HashMap; use bevy_utils::synccell::SyncCell; use gilrs::GilrsBuilder; use gilrs_system::{gilrs_event_startup_system, gilrs_event_system}; -use rumble::{RunningRumbleEffects, play_gilrs_rumble}; +use rumble::{play_gilrs_rumble, RunningRumbleEffects}; use tracing::error; #[cfg_attr(not(target_arch = "wasm32"), derive(Resource))] diff --git a/crates/bevy_gilrs/src/rumble.rs b/crates/bevy_gilrs/src/rumble.rs index e91fa7b1d6006..53a0c945cedef 100644 --- a/crates/bevy_gilrs/src/rumble.rs +++ b/crates/bevy_gilrs/src/rumble.rs @@ -9,8 +9,8 @@ use bevy_time::{Real, Time}; use bevy_utils::synccell::SyncCell; use core::time::Duration; use gilrs::{ - GamepadId, ff::{self, BaseEffect, BaseEffectType, Repeat, Replay}, + GamepadId, }; use thiserror::Error; use tracing::{debug, warn}; @@ -155,7 +155,7 @@ pub(crate) fn play_gilrs_rumble( debug!("Tried to rumble {gamepad:?}, but it doesn't support force feedback"); } else { warn!( - "Tried to handle rumble request for {gamepad:?} but an error occurred: {err}" + "Tried to handle rumble request for {gamepad:?} but an error occurred: {err}" ); } } diff --git a/crates/bevy_gizmos/macros/src/lib.rs b/crates/bevy_gizmos/macros/src/lib.rs index 464f4ad0d0240..441882d4b01ab 100644 --- a/crates/bevy_gizmos/macros/src/lib.rs +++ b/crates/bevy_gizmos/macros/src/lib.rs @@ -5,7 +5,7 @@ use bevy_macro_utils::BevyManifest; use proc_macro::TokenStream; use quote::quote; -use syn::{DeriveInput, Path, parse_macro_input, parse_quote}; +use syn::{parse_macro_input, parse_quote, DeriveInput, Path}; /// Implements the [`GizmoConfigGroup`] trait for a gizmo config group type. #[proc_macro_derive(GizmoConfigGroup)] diff --git a/crates/bevy_gizmos/src/aabb.rs b/crates/bevy_gizmos/src/aabb.rs index c2430f11ccf1d..605a4c2e88c6a 100644 --- a/crates/bevy_gizmos/src/aabb.rs +++ b/crates/bevy_gizmos/src/aabb.rs @@ -10,17 +10,17 @@ use bevy_ecs::{ schedule::IntoSystemConfigs, system::{Query, Res}, }; -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::primitives::Aabb; use bevy_transform::{ - TransformSystem, components::{GlobalTransform, Transform}, + TransformSystem, }; use crate::{ - AppGizmoBuilder, config::{GizmoConfigGroup, GizmoConfigStore}, gizmos::Gizmos, + AppGizmoBuilder, }; /// A [`Plugin`] that provides visualization of [`Aabb`]s for debugging. diff --git a/crates/bevy_gizmos/src/arrows.rs b/crates/bevy_gizmos/src/arrows.rs index ac20e6712bbf0..74fbdc97262b5 100644 --- a/crates/bevy_gizmos/src/arrows.rs +++ b/crates/bevy_gizmos/src/arrows.rs @@ -5,8 +5,8 @@ use crate::{gizmos::GizmoBuffer, prelude::GizmoConfigGroup}; use bevy_color::{ - Color, palettes::basic::{BLUE, GREEN, RED}, + Color, }; use bevy_math::{Quat, Vec2, Vec3, Vec3Swizzles}; use bevy_transform::TransformPoint; diff --git a/crates/bevy_gizmos/src/circles.rs b/crates/bevy_gizmos/src/circles.rs index 1adddb442f76b..e5a49398083ab 100644 --- a/crates/bevy_gizmos/src/circles.rs +++ b/crates/bevy_gizmos/src/circles.rs @@ -5,7 +5,7 @@ use crate::{gizmos::GizmoBuffer, prelude::GizmoConfigGroup}; use bevy_color::Color; -use bevy_math::{Isometry2d, Isometry3d, Quat, Vec2, Vec3, ops}; +use bevy_math::{ops, Isometry2d, Isometry3d, Quat, Vec2, Vec3}; use core::f32::consts::TAU; pub(crate) const DEFAULT_CIRCLE_RESOLUTION: u32 = 32; diff --git a/crates/bevy_gizmos/src/config.rs b/crates/bevy_gizmos/src/config.rs index 4d98457688b14..bba3ff284cb2e 100644 --- a/crates/bevy_gizmos/src/config.rs +++ b/crates/bevy_gizmos/src/config.rs @@ -9,7 +9,7 @@ pub use bevy_gizmos_macros::GizmoConfigGroup; use {crate::GizmoAsset, bevy_asset::Handle, bevy_ecs::component::Component}; use bevy_ecs::{reflect::ReflectResource, resource::Resource}; -use bevy_reflect::{Reflect, TypePath, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect, TypePath}; use bevy_utils::TypeIdMap; use core::{ any::TypeId, @@ -111,10 +111,7 @@ impl GizmoConfigStore { /// Returns [`GizmoConfig`] and [`GizmoConfigGroup`] associated with [`GizmoConfigGroup`] `T` pub fn config(&self) -> (&GizmoConfig, &T) { let Some((config, ext)) = self.get_config_dyn(&TypeId::of::()) else { - panic!( - "Requested config {} does not exist in `GizmoConfigStore`! Did you forget to add it using `app.init_gizmo_group()`?", - T::type_path() - ); + panic!("Requested config {} does not exist in `GizmoConfigStore`! Did you forget to add it using `app.init_gizmo_group()`?", T::type_path()); }; // hash map invariant guarantees that &dyn Reflect is of correct type T let ext = ext.as_any().downcast_ref().unwrap(); @@ -133,10 +130,7 @@ impl GizmoConfigStore { /// Returns mutable [`GizmoConfig`] and [`GizmoConfigGroup`] associated with [`GizmoConfigGroup`] `T` pub fn config_mut(&mut self) -> (&mut GizmoConfig, &mut T) { let Some((config, ext)) = self.get_config_mut_dyn(&TypeId::of::()) else { - panic!( - "Requested config {} does not exist in `GizmoConfigStore`! Did you forget to add it using `app.init_gizmo_group()`?", - T::type_path() - ); + panic!("Requested config {} does not exist in `GizmoConfigStore`! Did you forget to add it using `app.init_gizmo_group()`?", T::type_path()); }; // hash map invariant guarantees that &dyn Reflect is of correct type T let ext = ext.as_any_mut().downcast_mut().unwrap(); diff --git a/crates/bevy_gizmos/src/curves.rs b/crates/bevy_gizmos/src/curves.rs index f2b106a17196d..2d7a350ca29dc 100644 --- a/crates/bevy_gizmos/src/curves.rs +++ b/crates/bevy_gizmos/src/curves.rs @@ -5,8 +5,8 @@ use bevy_color::Color; use bevy_math::{ - Vec2, Vec3, curve::{Curve, CurveExt}, + Vec2, Vec3, }; use crate::{gizmos::GizmoBuffer, prelude::GizmoConfigGroup}; diff --git a/crates/bevy_gizmos/src/gizmos.rs b/crates/bevy_gizmos/src/gizmos.rs index 9762569e13f78..b1fe363f510cb 100644 --- a/crates/bevy_gizmos/src/gizmos.rs +++ b/crates/bevy_gizmos/src/gizmos.rs @@ -12,7 +12,7 @@ use bevy_ecs::{ component::Tick, resource::Resource, system::{Deferred, ReadOnlySystemParam, Res, SystemBuffer, SystemMeta, SystemParam}, - world::{World, unsafe_world_cell::UnsafeWorldCell}, + world::{unsafe_world_cell::UnsafeWorldCell, World}, }; use bevy_math::{Isometry2d, Isometry3d, Vec2, Vec3}; use bevy_reflect::Reflect; diff --git a/crates/bevy_gizmos/src/grid.rs b/crates/bevy_gizmos/src/grid.rs index f76eac9be4cc5..42742e196c77c 100644 --- a/crates/bevy_gizmos/src/grid.rs +++ b/crates/bevy_gizmos/src/grid.rs @@ -5,7 +5,7 @@ use crate::{gizmos::GizmoBuffer, prelude::GizmoConfigGroup}; use bevy_color::Color; -use bevy_math::{Isometry2d, Isometry3d, Quat, UVec2, UVec3, Vec2, Vec3, Vec3Swizzles, ops}; +use bevy_math::{ops, Isometry2d, Isometry3d, Quat, UVec2, UVec3, Vec2, Vec3, Vec3Swizzles}; /// A builder returned by [`GizmoBuffer::grid_3d`] pub struct GridBuilder3d<'a, Config, Clear> @@ -365,7 +365,11 @@ fn draw_grid( #[inline] fn or_zero(cond: bool, val: Vec3) -> Vec3 { - if cond { val } else { Vec3::ZERO } + if cond { + val + } else { + Vec3::ZERO + } } // Offset between two adjacent grid cells along the x/y-axis and accounting for skew. diff --git a/crates/bevy_gizmos/src/lib.rs b/crates/bevy_gizmos/src/lib.rs index 3582c5346026b..fdc2243233916 100644 --- a/crates/bevy_gizmos/src/lib.rs +++ b/crates/bevy_gizmos/src/lib.rs @@ -64,7 +64,6 @@ pub mod prelude { #[doc(hidden)] pub use crate::{ - AppGizmoBuilder, GizmoAsset, config::{ DefaultGizmoConfigGroup, GizmoConfig, GizmoConfigGroup, GizmoConfigStore, GizmoLineConfig, GizmoLineJoint, GizmoLineStyle, @@ -72,6 +71,7 @@ pub mod prelude { gizmos::Gizmos, primitives::{dim2::GizmoPrimitive2d, dim3::GizmoPrimitive3d}, retained::Gizmo, + AppGizmoBuilder, GizmoAsset, }; #[cfg(all(feature = "bevy_pbr", feature = "bevy_render"))] @@ -79,7 +79,7 @@ pub mod prelude { } use bevy_app::{App, FixedFirst, FixedLast, Last, Plugin, RunFixedMainLoop}; -use bevy_asset::{Asset, AssetApp, AssetId, Assets, Handle, weak_handle}; +use bevy_asset::{weak_handle, Asset, AssetApp, AssetId, Assets, Handle}; use bevy_ecs::{ resource::Resource, schedule::{IntoSystemConfigs, SystemSet}, @@ -104,23 +104,23 @@ use { entity::Entity, query::ROQueryItem, system::{ - Commands, SystemParamItem, lifetimeless::{Read, SRes}, + Commands, SystemParamItem, }, }, bevy_math::{Affine3, Affine3A}, bevy_render::{ - Extract, ExtractSchedule, Render, RenderApp, RenderSet, extract_component::{ComponentUniforms, DynamicUniformIndex, UniformComponentPlugin}, render_asset::{PrepareAssetError, RenderAsset, RenderAssetPlugin, RenderAssets}, render_phase::{PhaseItem, RenderCommand, RenderCommandResult, TrackedRenderPass}, render_resource::{ - BindGroup, BindGroupEntries, BindGroupLayout, BindGroupLayoutEntries, Buffer, - BufferInitDescriptor, BufferUsages, Shader, ShaderStages, ShaderType, VertexFormat, - binding_types::uniform_buffer, + binding_types::uniform_buffer, BindGroup, BindGroupEntries, BindGroupLayout, + BindGroupLayoutEntries, Buffer, BufferInitDescriptor, BufferUsages, Shader, + ShaderStages, ShaderType, VertexFormat, }, renderer::RenderDevice, sync_world::{MainEntity, TemporaryRenderEntity}, + Extract, ExtractSchedule, Render, RenderApp, RenderSet, }, bytemuck::cast_slice, }; @@ -194,22 +194,16 @@ impl Plugin for GizmoPlugin { if app.is_plugin_added::() { app.add_plugins(pipeline_2d::LineGizmo2dPlugin); } else { - tracing::warn!( - "bevy_sprite feature is enabled but bevy_sprite::SpritePlugin was not detected. Are you sure you loaded GizmoPlugin after SpritePlugin?" - ); + tracing::warn!("bevy_sprite feature is enabled but bevy_sprite::SpritePlugin was not detected. Are you sure you loaded GizmoPlugin after SpritePlugin?"); } #[cfg(feature = "bevy_pbr")] if app.is_plugin_added::() { app.add_plugins(pipeline_3d::LineGizmo3dPlugin); } else { - tracing::warn!( - "bevy_pbr feature is enabled but bevy_pbr::PbrPlugin was not detected. Are you sure you loaded GizmoPlugin after PbrPlugin?" - ); + tracing::warn!("bevy_pbr feature is enabled but bevy_pbr::PbrPlugin was not detected. Are you sure you loaded GizmoPlugin after PbrPlugin?"); } } else { - tracing::warn!( - "bevy_render feature is enabled but RenderApp was not detected. Are you sure you loaded GizmoPlugin after RenderPlugin?" - ); + tracing::warn!("bevy_render feature is enabled but RenderApp was not detected. Are you sure you loaded GizmoPlugin after RenderPlugin?"); } } @@ -459,14 +453,10 @@ fn extract_gizmo_data( } = config.line.style { if gap_scale <= 0.0 { - once!(warn!( - "When using gizmos with the line style `GizmoLineStyle::Dashed{{..}}` the gap scale should be greater than zero." - )); + once!(warn!("When using gizmos with the line style `GizmoLineStyle::Dashed{{..}}` the gap scale should be greater than zero.")); } if line_scale <= 0.0 { - once!(warn!( - "When using gizmos with the line style `GizmoLineStyle::Dashed{{..}}` the line scale should be greater than zero." - )); + once!(warn!("When using gizmos with the line style `GizmoLineStyle::Dashed{{..}}` the line scale should be greater than zero.")); } (gap_scale, line_scale) } else { diff --git a/crates/bevy_gizmos/src/light.rs b/crates/bevy_gizmos/src/light.rs index dc01045fd2ecc..d6df0b7d3bb20 100644 --- a/crates/bevy_gizmos/src/light.rs +++ b/crates/bevy_gizmos/src/light.rs @@ -6,8 +6,8 @@ use crate::primitives::dim3::GizmoPrimitive3d; use bevy_app::{Plugin, PostUpdate}; use bevy_color::{ - Color, Oklcha, palettes::basic::{BLUE, GREEN, RED}, + Color, Oklcha, }; use bevy_ecs::{ component::Component, @@ -18,17 +18,18 @@ use bevy_ecs::{ system::{Query, Res}, }; use bevy_math::{ - Isometry3d, Quat, Vec3, ops, + ops, primitives::{Cone, Sphere}, + Isometry3d, Quat, Vec3, }; use bevy_pbr::{DirectionalLight, PointLight, SpotLight}; -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; -use bevy_transform::{TransformSystem, components::GlobalTransform}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_transform::{components::GlobalTransform, TransformSystem}; use crate::{ - AppGizmoBuilder, config::{GizmoConfigGroup, GizmoConfigStore}, gizmos::Gizmos, + AppGizmoBuilder, }; /// Draws a standard sphere for the radius and an axis sphere for the range. diff --git a/crates/bevy_gizmos/src/pipeline_2d.rs b/crates/bevy_gizmos/src/pipeline_2d.rs index ea7ff04838f39..72a2428ff0b5b 100644 --- a/crates/bevy_gizmos/src/pipeline_2d.rs +++ b/crates/bevy_gizmos/src/pipeline_2d.rs @@ -1,11 +1,11 @@ use crate::{ - DrawLineGizmo, DrawLineJointGizmo, GizmoRenderSystem, GpuLineGizmo, LINE_JOINT_SHADER_HANDLE, - LINE_SHADER_HANDLE, LineGizmoUniformBindgroupLayout, SetLineGizmoBindGroup, config::{GizmoLineJoint, GizmoLineStyle, GizmoMeshConfig}, - line_gizmo_vertex_buffer_layouts, line_joint_gizmo_vertex_buffer_layouts, + line_gizmo_vertex_buffer_layouts, line_joint_gizmo_vertex_buffer_layouts, DrawLineGizmo, + DrawLineJointGizmo, GizmoRenderSystem, GpuLineGizmo, LineGizmoUniformBindgroupLayout, + SetLineGizmoBindGroup, LINE_JOINT_SHADER_HANDLE, LINE_SHADER_HANDLE, }; use bevy_app::{App, Plugin}; -use bevy_core_pipeline::core_2d::{CORE_2D_DEPTH_FORMAT, Transparent2d}; +use bevy_core_pipeline::core_2d::{Transparent2d, CORE_2D_DEPTH_FORMAT}; use bevy_ecs::{ prelude::Entity, @@ -18,14 +18,14 @@ use bevy_image::BevyDefault as _; use bevy_math::FloatOrd; use bevy_render::sync_world::MainEntity; use bevy_render::{ - Render, RenderApp, RenderSet, - render_asset::{RenderAssets, prepare_assets}, + render_asset::{prepare_assets, RenderAssets}, render_phase::{ AddRenderCommand, DrawFunctions, PhaseItemExtraIndex, SetItemPipeline, ViewSortedRenderPhases, }, render_resource::*, view::{ExtractedView, Msaa, RenderLayers, ViewTarget}, + Render, RenderApp, RenderSet, }; use bevy_sprite::{Mesh2dPipeline, Mesh2dPipelineKey, SetMesh2dViewBindGroup}; use tracing::error; @@ -214,9 +214,7 @@ impl SpecializedRenderPipeline for LineJointGizmoPipeline { ]; if key.joints == GizmoLineJoint::None { - error!( - "There is no entry point for line joints with GizmoLineJoints::None. Please consider aborting the drawing process before reaching this stage." - ); + error!("There is no entry point for line joints with GizmoLineJoints::None. Please consider aborting the drawing process before reaching this stage."); }; let entry_point = match key.joints { diff --git a/crates/bevy_gizmos/src/pipeline_3d.rs b/crates/bevy_gizmos/src/pipeline_3d.rs index e96c97252a058..f7806b64d65bf 100644 --- a/crates/bevy_gizmos/src/pipeline_3d.rs +++ b/crates/bevy_gizmos/src/pipeline_3d.rs @@ -1,12 +1,12 @@ use crate::{ - DrawLineGizmo, DrawLineJointGizmo, GizmoRenderSystem, GpuLineGizmo, LINE_JOINT_SHADER_HANDLE, - LINE_SHADER_HANDLE, LineGizmoUniformBindgroupLayout, SetLineGizmoBindGroup, config::{GizmoLineJoint, GizmoLineStyle, GizmoMeshConfig}, - line_gizmo_vertex_buffer_layouts, line_joint_gizmo_vertex_buffer_layouts, + line_gizmo_vertex_buffer_layouts, line_joint_gizmo_vertex_buffer_layouts, DrawLineGizmo, + DrawLineJointGizmo, GizmoRenderSystem, GpuLineGizmo, LineGizmoUniformBindgroupLayout, + SetLineGizmoBindGroup, LINE_JOINT_SHADER_HANDLE, LINE_SHADER_HANDLE, }; use bevy_app::{App, Plugin}; use bevy_core_pipeline::{ - core_3d::{CORE_3D_DEPTH_FORMAT, Transparent3d}, + core_3d::{Transparent3d, CORE_3D_DEPTH_FORMAT}, prepass::{DeferredPrepass, DepthPrepass, MotionVectorPrepass, NormalPrepass}, }; @@ -22,14 +22,14 @@ use bevy_image::BevyDefault as _; use bevy_pbr::{MeshPipeline, MeshPipelineKey, SetMeshViewBindGroup}; use bevy_render::sync_world::MainEntity; use bevy_render::{ - Render, RenderApp, RenderSet, - render_asset::{RenderAssets, prepare_assets}, + render_asset::{prepare_assets, RenderAssets}, render_phase::{ AddRenderCommand, DrawFunctions, PhaseItemExtraIndex, SetItemPipeline, ViewSortedRenderPhases, }, render_resource::*, view::{ExtractedView, Msaa, RenderLayers, ViewTarget}, + Render, RenderApp, RenderSet, }; use tracing::error; @@ -218,9 +218,7 @@ impl SpecializedRenderPipeline for LineJointGizmoPipeline { let layout = vec![view_layout, self.uniform_layout.clone()]; if key.joints == GizmoLineJoint::None { - error!( - "There is no entry point for line joints with GizmoLineJoints::None. Please consider aborting the drawing process before reaching this stage." - ); + error!("There is no entry point for line joints with GizmoLineJoints::None. Please consider aborting the drawing process before reaching this stage."); }; let entry_point = match key.joints { diff --git a/crates/bevy_gizmos/src/primitives/dim2.rs b/crates/bevy_gizmos/src/primitives/dim2.rs index 5cfdfd46b0bfb..d38ba3ab4ca95 100644 --- a/crates/bevy_gizmos/src/primitives/dim2.rs +++ b/crates/bevy_gizmos/src/primitives/dim2.rs @@ -6,12 +6,12 @@ use super::helpers::*; use bevy_color::Color; use bevy_math::{ - Dir2, Isometry2d, Rot2, Vec2, primitives::{ Annulus, Arc2d, BoxedPolygon, BoxedPolyline2d, Capsule2d, Circle, CircularSector, CircularSegment, Ellipse, Line2d, Plane2d, Polygon, Polyline2d, Primitive2d, Rectangle, RegularPolygon, Rhombus, Segment2d, Triangle2d, }, + Dir2, Isometry2d, Rot2, Vec2, }; use crate::{gizmos::GizmoBuffer, prelude::GizmoConfigGroup}; @@ -389,14 +389,7 @@ where } // transform points from the reference unit square to capsule "rectangle" - let [ - top_left, - top_right, - bottom_left, - bottom_right, - top_center, - bottom_center, - ] = [ + let [top_left, top_right, bottom_left, bottom_right, top_center, bottom_center] = [ [-1.0, 1.0], [1.0, 1.0], [-1.0, -1.0], diff --git a/crates/bevy_gizmos/src/primitives/dim3.rs b/crates/bevy_gizmos/src/primitives/dim3.rs index 16caa39b33a4d..31a2274e841b4 100644 --- a/crates/bevy_gizmos/src/primitives/dim3.rs +++ b/crates/bevy_gizmos/src/primitives/dim3.rs @@ -4,11 +4,11 @@ use super::helpers::*; use bevy_color::Color; use bevy_math::{ - Dir3, Isometry3d, Quat, UVec2, Vec2, Vec3, primitives::{ BoxedPolyline3d, Capsule3d, Cone, ConicalFrustum, Cuboid, Cylinder, Line3d, Plane3d, Polyline3d, Primitive3d, Segment3d, Sphere, Tetrahedron, Torus, Triangle3d, }, + Dir3, Isometry3d, Quat, UVec2, Vec2, Vec3, }; use crate::{circles::SphereBuilder, gizmos::GizmoBuffer, prelude::GizmoConfigGroup}; diff --git a/crates/bevy_gizmos/src/primitives/helpers.rs b/crates/bevy_gizmos/src/primitives/helpers.rs index fdbaa223852bf..37253b14a9ac9 100644 --- a/crates/bevy_gizmos/src/primitives/helpers.rs +++ b/crates/bevy_gizmos/src/primitives/helpers.rs @@ -1,6 +1,6 @@ use core::f32::consts::TAU; -use bevy_math::{Vec2, ops}; +use bevy_math::{ops, Vec2}; /// Calculates the `nth` coordinate of a circle. /// diff --git a/crates/bevy_gizmos/src/retained.rs b/crates/bevy_gizmos/src/retained.rs index b41f592210d88..435f417552463 100644 --- a/crates/bevy_gizmos/src/retained.rs +++ b/crates/bevy_gizmos/src/retained.rs @@ -4,7 +4,7 @@ use core::ops::{Deref, DerefMut}; use bevy_asset::Handle; use bevy_ecs::{ - component::{Component, require}, + component::{require, Component}, reflect::ReflectComponent, }; use bevy_reflect::Reflect; @@ -12,19 +12,19 @@ use bevy_transform::components::Transform; #[cfg(feature = "bevy_render")] use { - crate::{LineGizmoUniform, config::GizmoLineJoint}, + crate::{config::GizmoLineJoint, LineGizmoUniform}, bevy_ecs::{ entity::Entity, system::{Commands, Local, Query}, }, - bevy_render::{Extract, view::RenderLayers}, + bevy_render::{view::RenderLayers, Extract}, bevy_transform::components::GlobalTransform, }; use crate::{ - GizmoAsset, config::{ErasedGizmoConfigGroup, GizmoLineConfig}, gizmos::GizmoBuffer, + GizmoAsset, }; impl Deref for GizmoAsset { @@ -125,14 +125,10 @@ pub(crate) fn extract_linegizmos( } = gizmo.line_config.style { if gap_scale <= 0.0 { - once!(warn!( - "when using gizmos with the line style `GizmoLineStyle::Dashed{{..}}` the gap scale should be greater than zero" - )); + once!(warn!("when using gizmos with the line style `GizmoLineStyle::Dashed{{..}}` the gap scale should be greater than zero")); } if line_scale <= 0.0 { - once!(warn!( - "when using gizmos with the line style `GizmoLineStyle::Dashed{{..}}` the line scale should be greater than zero" - )); + once!(warn!("when using gizmos with the line style `GizmoLineStyle::Dashed{{..}}` the line scale should be greater than zero")); } (gap_scale, line_scale) } else { diff --git a/crates/bevy_gltf/src/lib.rs b/crates/bevy_gltf/src/lib.rs index b52768aedd2b6..27f0ad00bbc47 100644 --- a/crates/bevy_gltf/src/lib.rs +++ b/crates/bevy_gltf/src/lib.rs @@ -105,9 +105,9 @@ use bevy_asset::{Asset, AssetApp, AssetPath, Handle}; use bevy_ecs::{prelude::Component, reflect::ReflectComponent}; use bevy_image::CompressedImageFormats; use bevy_pbr::StandardMaterial; -use bevy_reflect::{Reflect, TypePath, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect, TypePath}; use bevy_render::{ - mesh::{Mesh, MeshVertexAttribute, skinning::SkinnedMeshInverseBindposes}, + mesh::{skinning::SkinnedMeshInverseBindposes, Mesh, MeshVertexAttribute}, renderer::RenderDevice, }; use bevy_scene::Scene; diff --git a/crates/bevy_gltf/src/loader.rs b/crates/bevy_gltf/src/loader.rs index 9ffe7e6ec7cdb..1a8e170ee793f 100644 --- a/crates/bevy_gltf/src/loader.rs +++ b/crates/bevy_gltf/src/loader.rs @@ -1,15 +1,15 @@ use crate::{ - Gltf, GltfAssetLabel, GltfExtras, GltfMaterialExtras, GltfMaterialName, GltfMeshExtras, - GltfNode, GltfSceneExtras, GltfSkin, vertex_attributes::convert_attribute, + vertex_attributes::convert_attribute, Gltf, GltfAssetLabel, GltfExtras, GltfMaterialExtras, + GltfMaterialName, GltfMeshExtras, GltfNode, GltfSceneExtras, GltfSkin, }; use bevy_asset::{ - AssetLoadError, AssetLoader, Handle, LoadContext, ReadAssetBytesError, io::Reader, + io::Reader, AssetLoadError, AssetLoader, Handle, LoadContext, ReadAssetBytesError, }; use bevy_color::{Color, LinearRgba}; use bevy_core_pipeline::prelude::Camera3d; use bevy_ecs::{ - entity::{Entity, hash_map::EntityHashMap}, + entity::{hash_map::EntityHashMap, Entity}, hierarchy::ChildSpawner, name::Name, world::World, @@ -20,17 +20,17 @@ use bevy_image::{ }; use bevy_math::{Affine2, Mat4, Vec3}; use bevy_pbr::{ - DirectionalLight, MAX_JOINTS, MeshMaterial3d, PointLight, SpotLight, StandardMaterial, - UvChannel, + DirectionalLight, MeshMaterial3d, PointLight, SpotLight, StandardMaterial, UvChannel, + MAX_JOINTS, }; use bevy_platform_support::collections::{HashMap, HashSet}; use bevy_render::{ alpha::AlphaMode, camera::{Camera, OrthographicProjection, PerspectiveProjection, Projection, ScalingMode}, mesh::{ - Indices, Mesh, Mesh3d, MeshVertexAttribute, VertexAttributeValues, morph::{MeshMorphWeights, MorphAttributes, MorphTargetImage, MorphWeights}, skinning::{SkinnedMesh, SkinnedMeshInverseBindposes}, + Indices, Mesh, Mesh3d, MeshVertexAttribute, VertexAttributeValues, }, primitives::Aabb, render_asset::RenderAssetUsages, @@ -43,12 +43,12 @@ use bevy_tasks::IoTaskPool; use bevy_transform::components::Transform; use fixedbitset::FixedBitSet; use gltf::{ - Document, Material, Node, Primitive, Semantic, accessor::Iter, image::Source, json, - mesh::{Mode, util::ReadIndices}, + mesh::{util::ReadIndices, Mode}, texture::{Info, MagFilter, MinFilter, TextureTransform, WrappingMode}, + Document, Material, Node, Primitive, Semantic, }; use itertools::Itertools; use serde::{Deserialize, Serialize}; @@ -57,7 +57,7 @@ use serde::{Deserialize, Serialize}; feature = "pbr_multi_layer_material_textures" ))] use serde_json::Map; -use serde_json::{Value, value}; +use serde_json::{value, Value}; use std::{ io::Error, path::{Path, PathBuf}, @@ -66,7 +66,7 @@ use thiserror::Error; use tracing::{error, info_span, warn}; #[cfg(feature = "bevy_animation")] use { - bevy_animation::{AnimationTarget, AnimationTargetId, prelude::*}, + bevy_animation::{prelude::*, AnimationTarget, AnimationTargetId}, smallvec::SmallVec, }; @@ -275,10 +275,10 @@ async fn load_gltf<'a, 'b, 'c>( #[cfg(feature = "bevy_animation")] let (animations, named_animations, animation_roots) = { - use bevy_animation::{VariableCurve, animated_field, animation_curves::*, gltf_curves::*}; + use bevy_animation::{animated_field, animation_curves::*, gltf_curves::*, VariableCurve}; use bevy_math::{ - Quat, Vec4, curve::{ConstantCurve, Interval, UnevenSampleAutoCurve}, + Quat, Vec4, }; use gltf::animation::util::ReadOutputs; let mut animations = vec![]; @@ -653,15 +653,13 @@ async fn load_gltf<'a, 'b, 'c>( if [Semantic::Joints(0), Semantic::Weights(0)].contains(&semantic) { if !meshes_on_skinned_nodes.contains(&gltf_mesh.index()) { warn!( - "Ignoring attribute {:?} for skinned mesh {} used on non skinned nodes (NODE_SKINNED_MESH_WITHOUT_SKIN)", - semantic, primitive_label - ); + "Ignoring attribute {:?} for skinned mesh {} used on non skinned nodes (NODE_SKINNED_MESH_WITHOUT_SKIN)", + semantic, + primitive_label + ); continue; } else if meshes_on_non_skinned_nodes.contains(&gltf_mesh.index()) { - error!( - "Skinned mesh {} used on both skinned and non skin nodes, this is likely to cause an error (NODE_SKINNED_MESH_WITHOUT_SKIN)", - primitive_label - ); + error!("Skinned mesh {} used on both skinned and non skin nodes, this is likely to cause an error (NODE_SKINNED_MESH_WITHOUT_SKIN)", primitive_label); } } match convert_attribute( @@ -719,11 +717,7 @@ async fn load_gltf<'a, 'b, 'c>( mesh.compute_flat_normals(); let vertex_count_after = mesh.count_vertices(); if vertex_count_before != vertex_count_after { - tracing::debug!( - "Missing vertex normals in indexed geometry, computing them as flat. Vertex count increased from {} to {}", - vertex_count_before, - vertex_count_after - ); + tracing::debug!("Missing vertex normals in indexed geometry, computing them as flat. Vertex count increased from {} to {}", vertex_count_before, vertex_count_after); } else { tracing::debug!( "Missing vertex normals in indexed geometry, computing them as flat." @@ -740,8 +734,7 @@ async fn load_gltf<'a, 'b, 'c>( && material_needs_tangents(&primitive.material()) { tracing::debug!( - "Missing vertex tangents for {}, computing them using the mikktspace algorithm. Consider using a tool such as Blender to pre-compute the tangents.", - file_name + "Missing vertex tangents for {}, computing them using the mikktspace algorithm. Consider using a tool such as Blender to pre-compute the tangents.", file_name ); let generate_tangents_span = info_span!("generate_tangents", name = file_name); @@ -1420,8 +1413,7 @@ fn warn_on_differing_texture_transforms( .unwrap_or_else(|| "default".to_string()); warn!( "Only texture transforms on base color textures are supported, but {material_name} ({material_index}) \ - has a texture transform on {texture_name} (index {}), which will be ignored.", - info.texture().index() + has a texture transform on {texture_name} (index {}), which will be ignored.", info.texture().index() ); } } @@ -1996,9 +1988,9 @@ impl<'s> Iterator for PrimitiveMorphAttributesIter<'s> { type Item = MorphAttributes; fn next(&mut self) -> Option { - let position = self.0.0.as_mut().and_then(Iterator::next); - let normal = self.0.1.as_mut().and_then(Iterator::next); - let tangent = self.0.2.as_mut().and_then(Iterator::next); + let position = self.0 .0.as_mut().and_then(Iterator::next); + let normal = self.0 .1.as_mut().and_then(Iterator::next); + let tangent = self.0 .2.as_mut().and_then(Iterator::next); if position.is_none() && normal.is_none() && tangent.is_none() { return None; } @@ -2391,15 +2383,15 @@ mod test { use crate::{Gltf, GltfAssetLabel, GltfNode, GltfSkin}; use bevy_app::{App, TaskPoolPlugin}; use bevy_asset::{ - AssetApp, AssetPlugin, AssetServer, Assets, Handle, LoadState, io::{ - AssetSource, AssetSourceId, memory::{Dir, MemoryAssetReader}, + AssetSource, AssetSourceId, }, + AssetApp, AssetPlugin, AssetServer, Assets, Handle, LoadState, }; use bevy_ecs::{resource::Resource, world::World}; use bevy_log::LogPlugin; - use bevy_render::mesh::{MeshPlugin, skinning::SkinnedMeshInverseBindposes}; + use bevy_render::mesh::{skinning::SkinnedMeshInverseBindposes, MeshPlugin}; use bevy_scene::ScenePlugin; fn test_app(dir: Dir) -> App { diff --git a/crates/bevy_image/src/basis.rs b/crates/bevy_image/src/basis.rs index 141d4d2caa308..553140b0024bf 100644 --- a/crates/bevy_image/src/basis.rs +++ b/crates/bevy_image/src/basis.rs @@ -113,7 +113,7 @@ pub fn basis_buffer_to_image( basis_texture_type => { return Err(TextureError::UnsupportedTextureFormat(format!( "{basis_texture_type:?}", - ))); + ))) } }; image.data = Some(transcoded); diff --git a/crates/bevy_image/src/dds.rs b/crates/bevy_image/src/dds.rs index 3254a2ad068cf..5198fb366a311 100644 --- a/crates/bevy_image/src/dds.rs +++ b/crates/bevy_image/src/dds.rs @@ -272,7 +272,7 @@ pub fn dds_format_to_texture_format( _ => { return Err(TextureError::UnsupportedTextureFormat(format!( "{dxgi_format:?}", - ))); + ))) } } } else { diff --git a/crates/bevy_image/src/dynamic_texture_atlas_builder.rs b/crates/bevy_image/src/dynamic_texture_atlas_builder.rs index b9eef1b0e7c4c..6e013aba29a45 100644 --- a/crates/bevy_image/src/dynamic_texture_atlas_builder.rs +++ b/crates/bevy_image/src/dynamic_texture_atlas_builder.rs @@ -1,7 +1,7 @@ use crate::{Image, TextureAtlasLayout, TextureFormatPixelInfo as _}; use bevy_asset::RenderAssetUsages; use bevy_math::{URect, UVec2}; -use guillotiere::{Allocation, AtlasAllocator, size2}; +use guillotiere::{size2, Allocation, AtlasAllocator}; use thiserror::Error; use tracing::error; @@ -63,9 +63,7 @@ impl DynamicTextureAtlasBuilder { )); if let Some(allocation) = allocation { assert!( - atlas_texture - .asset_usage - .contains(RenderAssetUsages::MAIN_WORLD), + atlas_texture.asset_usage.contains(RenderAssetUsages::MAIN_WORLD), "The atlas_texture image must have the RenderAssetUsages::MAIN_WORLD usage flag set" ); diff --git a/crates/bevy_image/src/exr_texture_loader.rs b/crates/bevy_image/src/exr_texture_loader.rs index 878e04d89c2ac..d9b89dd21e152 100644 --- a/crates/bevy_image/src/exr_texture_loader.rs +++ b/crates/bevy_image/src/exr_texture_loader.rs @@ -1,5 +1,5 @@ use crate::{Image, TextureFormatPixelInfo}; -use bevy_asset::{AssetLoader, LoadContext, RenderAssetUsages, io::Reader}; +use bevy_asset::{io::Reader, AssetLoader, LoadContext, RenderAssetUsages}; use image::ImageDecoder; use serde::{Deserialize, Serialize}; use thiserror::Error; diff --git a/crates/bevy_image/src/hdr_texture_loader.rs b/crates/bevy_image/src/hdr_texture_loader.rs index a0ee9418c9d56..3177e94865809 100644 --- a/crates/bevy_image/src/hdr_texture_loader.rs +++ b/crates/bevy_image/src/hdr_texture_loader.rs @@ -1,6 +1,6 @@ use crate::{Image, TextureFormatPixelInfo}; use bevy_asset::RenderAssetUsages; -use bevy_asset::{AssetLoader, LoadContext, io::Reader}; +use bevy_asset::{io::Reader, AssetLoader, LoadContext}; use image::DynamicImage; use serde::{Deserialize, Serialize}; use thiserror::Error; diff --git a/crates/bevy_image/src/image.rs b/crates/bevy_image/src/image.rs index 927d608c9dc57..e9a1ef2ddc420 100644 --- a/crates/bevy_image/src/image.rs +++ b/crates/bevy_image/src/image.rs @@ -5,7 +5,7 @@ use super::dds::*; #[cfg(feature = "ktx2")] use super::ktx2::*; #[cfg(feature = "bevy_reflect")] -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_asset::{Asset, RenderAssetUsages}; use bevy_color::{Color, ColorToComponents, Gray, LinearRgba, Srgba, Xyza}; @@ -856,9 +856,7 @@ impl Image { 0, ); } else { - warn!( - "Resized an uninitialized image. Directly modify image.texture_descriptor.size instead" - ); + warn!("Resized an uninitialized image. Directly modify image.texture_descriptor.size instead"); } } diff --git a/crates/bevy_image/src/image_loader.rs b/crates/bevy_image/src/image_loader.rs index cbc71f4b7cec8..949ee78e49d4b 100644 --- a/crates/bevy_image/src/image_loader.rs +++ b/crates/bevy_image/src/image_loader.rs @@ -1,5 +1,5 @@ use crate::image::{Image, ImageFormat, ImageType, TextureError}; -use bevy_asset::{AssetLoader, LoadContext, RenderAssetUsages, io::Reader}; +use bevy_asset::{io::Reader, AssetLoader, LoadContext, RenderAssetUsages}; use thiserror::Error; use super::{CompressedImageFormats, ImageSampler}; diff --git a/crates/bevy_image/src/ktx2.rs b/crates/bevy_image/src/ktx2.rs index c59f34424f290..a45b77a2a8fc9 100644 --- a/crates/bevy_image/src/ktx2.rs +++ b/crates/bevy_image/src/ktx2.rs @@ -1081,7 +1081,7 @@ pub fn ktx2_dfd_to_texture_format( return Err(TextureError::UnsupportedTextureFormat(format!( "Invalid ETC2 sample channel type: {}", sample.channel_type - ))); + ))) } } } @@ -1143,7 +1143,7 @@ pub fn ktx2_dfd_to_texture_format( return Err(TextureError::UnsupportedTextureFormat(format!( "Invalid ASTC dimension: {} x {}", d.0, d.1 - ))); + ))) } }, channel: if is_srgb { @@ -1178,7 +1178,7 @@ pub fn ktx2_dfd_to_texture_format( channel_type => { return Err(TextureError::UnsupportedTextureFormat(format!( "Invalid KTX2 UASTC channel type: {channel_type}", - ))); + ))) } }), )); @@ -1489,7 +1489,7 @@ pub fn ktx2_format_to_texture_format( _ => { return Err(TextureError::UnsupportedTextureFormat(format!( "{ktx2_format:?}" - ))); + ))) } }) } diff --git a/crates/bevy_image/src/lib.rs b/crates/bevy_image/src/lib.rs index 8f3ba82f710f2..55f74a5f14d35 100644 --- a/crates/bevy_image/src/lib.rs +++ b/crates/bevy_image/src/lib.rs @@ -4,9 +4,9 @@ extern crate alloc; pub mod prelude { pub use crate::{ - BevyDefault as _, Image, ImageFormat, TextureAtlasBuilder, TextureError, dynamic_texture_atlas_builder::DynamicTextureAtlasBuilder, texture_atlas::{TextureAtlas, TextureAtlasLayout, TextureAtlasSources}, + BevyDefault as _, Image, ImageFormat, TextureAtlasBuilder, TextureError, }; } diff --git a/crates/bevy_image/src/texture_atlas.rs b/crates/bevy_image/src/texture_atlas.rs index 68f0f4443b72b..36e2acd86456b 100644 --- a/crates/bevy_image/src/texture_atlas.rs +++ b/crates/bevy_image/src/texture_atlas.rs @@ -3,7 +3,7 @@ use bevy_asset::{Asset, AssetApp as _, AssetId, Assets, Handle}; use bevy_math::{URect, UVec2}; use bevy_platform_support::collections::HashMap; #[cfg(feature = "bevy_reflect")] -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; #[cfg(feature = "serialize")] use bevy_reflect::{ReflectDeserialize, ReflectSerialize}; diff --git a/crates/bevy_image/src/texture_atlas_builder.rs b/crates/bevy_image/src/texture_atlas_builder.rs index 3421e6e3b123e..443660eefc424 100644 --- a/crates/bevy_image/src/texture_atlas_builder.rs +++ b/crates/bevy_image/src/texture_atlas_builder.rs @@ -2,8 +2,8 @@ use bevy_asset::{AssetId, RenderAssetUsages}; use bevy_math::{URect, UVec2}; use bevy_platform_support::collections::HashMap; use rectangle_pack::{ - GroupedRectsToPlace, PackedLocation, RectToInsert, TargetBin, contains_smallest_box, - pack_rects, volume_heuristic, + contains_smallest_box, pack_rects, volume_heuristic, GroupedRectsToPlace, PackedLocation, + RectToInsert, TargetBin, }; use thiserror::Error; use tracing::{debug, error, warn}; diff --git a/crates/bevy_input/src/axis.rs b/crates/bevy_input/src/axis.rs index a60dcba8d435b..acdf0135f0eda 100644 --- a/crates/bevy_input/src/axis.rs +++ b/crates/bevy_input/src/axis.rs @@ -88,7 +88,7 @@ where #[cfg(test)] mod tests { - use crate::{Axis, gamepad::GamepadButton}; + use crate::{gamepad::GamepadButton, Axis}; #[test] fn test_axis_set() { diff --git a/crates/bevy_input/src/button_input.rs b/crates/bevy_input/src/button_input.rs index 8c32d0e7c0a9d..a1086edf66e78 100644 --- a/crates/bevy_input/src/button_input.rs +++ b/crates/bevy_input/src/button_input.rs @@ -6,7 +6,7 @@ use core::hash::Hash; #[cfg(feature = "bevy_reflect")] use { bevy_ecs::reflect::ReflectResource, - bevy_reflect::{Reflect, std_traits::ReflectDefault}, + bevy_reflect::{std_traits::ReflectDefault, Reflect}, }; /// A "press-able" input of type `T`. diff --git a/crates/bevy_input/src/gamepad.rs b/crates/bevy_input/src/gamepad.rs index bfc28be93211d..2da9916a7ed7a 100644 --- a/crates/bevy_input/src/gamepad.rs +++ b/crates/bevy_input/src/gamepad.rs @@ -15,11 +15,11 @@ use bevy_ecs::{ prelude::require, system::{Commands, Query}, }; -use bevy_math::Vec2; use bevy_math::ops; +use bevy_math::Vec2; use bevy_platform_support::collections::HashMap; #[cfg(feature = "bevy_reflect")] -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; #[cfg(all(feature = "serialize", feature = "bevy_reflect"))] use bevy_reflect::{ReflectDeserialize, ReflectSerialize}; use derive_more::derive::From; @@ -267,11 +267,7 @@ pub enum AxisSettingsError { #[error("invalid livezone_upperbound {0}, expected value [0.0..=1.0]")] LiveZoneUpperBoundOutOfRange(f32), /// Parameter `livezone_lowerbound` was not less than or equal to parameter `deadzone_lowerbound`. - #[error( - "invalid parameter values livezone_lowerbound {} deadzone_lowerbound {}, expected livezone_lowerbound <= deadzone_lowerbound", - livezone_lowerbound, - deadzone_lowerbound - )] + #[error("invalid parameter values livezone_lowerbound {} deadzone_lowerbound {}, expected livezone_lowerbound <= deadzone_lowerbound", livezone_lowerbound, deadzone_lowerbound)] LiveZoneLowerBoundGreaterThanDeadZoneLowerBound { /// The value of the `livezone_lowerbound` parameter. livezone_lowerbound: f32, @@ -279,11 +275,7 @@ pub enum AxisSettingsError { deadzone_lowerbound: f32, }, /// Parameter `deadzone_upperbound` was not less than or equal to parameter `livezone_upperbound`. - #[error( - "invalid parameter values livezone_upperbound {} deadzone_upperbound {}, expected deadzone_upperbound <= livezone_upperbound", - livezone_upperbound, - deadzone_upperbound - )] + #[error("invalid parameter values livezone_upperbound {} deadzone_upperbound {}, expected deadzone_upperbound <= livezone_upperbound", livezone_upperbound, deadzone_upperbound)] DeadZoneUpperBoundGreaterThanLiveZoneUpperBound { /// The value of the `livezone_upperbound` parameter. livezone_upperbound: f32, @@ -305,11 +297,7 @@ pub enum ButtonSettingsError { #[error("invalid press_threshold {0}, expected [0.0..=1.0]")] PressThresholdOutOfRange(f32), /// Parameter `release_threshold` was not less than or equal to `press_threshold`. - #[error( - "invalid parameter values release_threshold {} press_threshold {}, expected release_threshold <= press_threshold", - release_threshold, - press_threshold - )] + #[error("invalid parameter values release_threshold {} press_threshold {}, expected release_threshold <= press_threshold", release_threshold, press_threshold)] ReleaseThresholdGreaterThanPressThreshold { /// The value of the `press_threshold` parameter. press_threshold: f32, @@ -1488,10 +1476,7 @@ pub fn gamepad_connection_system( } GamepadConnection::Disconnected => { let Some(mut gamepad) = commands.get_entity(id) else { - warn!( - "Gamepad {} removed before handling disconnection event. You can ignore this if you manually removed it.", - id - ); + warn!("Gamepad {} removed before handling disconnection event. You can ignore this if you manually removed it.", id); continue; }; // Gamepad entities are left alive to preserve their state (e.g. [`GamepadSettings`]). @@ -1766,13 +1751,13 @@ impl GamepadRumbleRequest { #[cfg(test)] mod tests { use super::{ - AxisSettings, AxisSettingsError, ButtonAxisSettings, ButtonSettings, ButtonSettingsError, - Gamepad, GamepadAxis, GamepadAxisChangedEvent, GamepadButton, GamepadButtonChangedEvent, + gamepad_connection_system, gamepad_event_processing_system, AxisSettings, + AxisSettingsError, ButtonAxisSettings, ButtonSettings, ButtonSettingsError, Gamepad, + GamepadAxis, GamepadAxisChangedEvent, GamepadButton, GamepadButtonChangedEvent, GamepadButtonStateChangedEvent, GamepadConnection::{Connected, Disconnected}, GamepadConnectionEvent, GamepadEvent, GamepadSettings, RawGamepadAxisChangedEvent, - RawGamepadButtonChangedEvent, RawGamepadEvent, gamepad_connection_system, - gamepad_event_processing_system, + RawGamepadButtonChangedEvent, RawGamepadEvent, }; use crate::ButtonState; use alloc::string::ToString; @@ -1850,8 +1835,7 @@ mod tests { ) { let actual = settings.filter(new_raw_value, old_raw_value); assert_eq!( - expected, - actual.map(|f| f.scaled.to_f32()), + expected, actual.map(|f| f.scaled.to_f32()), "Testing filtering for {settings:?} with new_raw_value = {new_raw_value:?}, old_raw_value = {old_raw_value:?}", ); } @@ -2259,39 +2243,35 @@ mod tests { ctx.send_gamepad_disconnection_event(entity); ctx.update(); // Gamepad component should be removed - assert!( - ctx.app - .world_mut() - .query::<&Gamepad>() - .get(ctx.app.world(), entity) - .is_err() - ); + assert!(ctx + .app + .world_mut() + .query::<&Gamepad>() + .get(ctx.app.world(), entity) + .is_err()); // Settings should be kept - assert!( - ctx.app - .world_mut() - .query::<&GamepadSettings>() - .get(ctx.app.world(), entity) - .is_ok() - ); + assert!(ctx + .app + .world_mut() + .query::<&GamepadSettings>() + .get(ctx.app.world(), entity) + .is_ok()); // Mistakenly sending a second disconnection event shouldn't break anything ctx.send_gamepad_disconnection_event(entity); ctx.update(); - assert!( - ctx.app - .world_mut() - .query::<&Gamepad>() - .get(ctx.app.world(), entity) - .is_err() - ); - assert!( - ctx.app - .world_mut() - .query::<&GamepadSettings>() - .get(ctx.app.world(), entity) - .is_ok() - ); + assert!(ctx + .app + .world_mut() + .query::<&Gamepad>() + .get(ctx.app.world(), entity) + .is_err()); + assert!(ctx + .app + .world_mut() + .query::<&GamepadSettings>() + .get(ctx.app.world(), entity) + .is_ok()); } #[test] @@ -2309,21 +2289,19 @@ mod tests { ctx.send_gamepad_disconnection_event(entity); ctx.update(); // Gamepad component should be removed - assert!( - ctx.app - .world_mut() - .query::<&Gamepad>() - .get(ctx.app.world(), entity) - .is_err() - ); + assert!(ctx + .app + .world_mut() + .query::<&Gamepad>() + .get(ctx.app.world(), entity) + .is_err()); // Settings should be kept - assert!( - ctx.app - .world_mut() - .query::<&GamepadSettings>() - .get(ctx.app.world(), entity) - .is_ok() - ); + assert!(ctx + .app + .world_mut() + .query::<&GamepadSettings>() + .get(ctx.app.world(), entity) + .is_ok()); } #[test] @@ -2391,13 +2369,12 @@ mod tests { .len(), 0 ); - assert!( - ctx.app - .world_mut() - .query::<(Entity, &GamepadSettings)>() - .get(ctx.app.world(), entity) - .is_ok() - ); + assert!(ctx + .app + .world_mut() + .query::<(Entity, &GamepadSettings)>() + .get(ctx.app.world(), entity) + .is_ok()); } #[test] @@ -2707,14 +2684,13 @@ mod tests { assert_eq!(event.button, GamepadButton::DPadDown); assert_eq!(event.state, ButtonState::Pressed); } - assert!( - ctx.app - .world_mut() - .query::<&Gamepad>() - .get(ctx.app.world(), entity) - .unwrap() - .pressed(GamepadButton::DPadDown) - ); + assert!(ctx + .app + .world_mut() + .query::<&Gamepad>() + .get(ctx.app.world(), entity) + .unwrap() + .pressed(GamepadButton::DPadDown)); ctx.app .world_mut() @@ -2729,14 +2705,13 @@ mod tests { .len(), 0 ); - assert!( - ctx.app - .world_mut() - .query::<&Gamepad>() - .get(ctx.app.world(), entity) - .unwrap() - .pressed(GamepadButton::DPadDown) - ); + assert!(ctx + .app + .world_mut() + .query::<&Gamepad>() + .get(ctx.app.world(), entity) + .unwrap() + .pressed(GamepadButton::DPadDown)); } #[test] @@ -2755,25 +2730,23 @@ mod tests { ctx.update(); // Check it is flagged for this frame - assert!( - ctx.app - .world_mut() - .query::<&Gamepad>() - .get(ctx.app.world(), entity) - .unwrap() - .just_pressed(GamepadButton::DPadDown) - ); + assert!(ctx + .app + .world_mut() + .query::<&Gamepad>() + .get(ctx.app.world(), entity) + .unwrap() + .just_pressed(GamepadButton::DPadDown)); ctx.update(); //Check it clears next frame - assert!( - !ctx.app - .world_mut() - .query::<&Gamepad>() - .get(ctx.app.world(), entity) - .unwrap() - .just_pressed(GamepadButton::DPadDown) - ); + assert!(!ctx + .app + .world_mut() + .query::<&Gamepad>() + .get(ctx.app.world(), entity) + .unwrap() + .just_pressed(GamepadButton::DPadDown)); } #[test] fn gamepad_buttons_released() { @@ -2816,14 +2789,13 @@ mod tests { assert_eq!(event.button, GamepadButton::DPadDown); assert_eq!(event.state, ButtonState::Released); } - assert!( - !ctx.app - .world_mut() - .query::<&Gamepad>() - .get(ctx.app.world(), entity) - .unwrap() - .pressed(GamepadButton::DPadDown) - ); + assert!(!ctx + .app + .world_mut() + .query::<&Gamepad>() + .get(ctx.app.world(), entity) + .unwrap() + .pressed(GamepadButton::DPadDown)); ctx.app .world_mut() .resource_mut::>() @@ -2862,25 +2834,23 @@ mod tests { ctx.update(); // Check it is flagged for this frame - assert!( - ctx.app - .world_mut() - .query::<&Gamepad>() - .get(ctx.app.world(), entity) - .unwrap() - .just_released(GamepadButton::DPadDown) - ); + assert!(ctx + .app + .world_mut() + .query::<&Gamepad>() + .get(ctx.app.world(), entity) + .unwrap() + .just_released(GamepadButton::DPadDown)); ctx.update(); //Check it clears next frame - assert!( - !ctx.app - .world_mut() - .query::<&Gamepad>() - .get(ctx.app.world(), entity) - .unwrap() - .just_released(GamepadButton::DPadDown) - ); + assert!(!ctx + .app + .world_mut() + .query::<&Gamepad>() + .get(ctx.app.world(), entity) + .unwrap() + .just_released(GamepadButton::DPadDown)); } #[test] diff --git a/crates/bevy_input/src/lib.rs b/crates/bevy_input/src/lib.rs index ca0a6085c5e85..2da2c89cce8ca 100644 --- a/crates/bevy_input/src/lib.rs +++ b/crates/bevy_input/src/lib.rs @@ -36,11 +36,11 @@ pub use button_input::*; pub mod prelude { #[doc(hidden)] pub use crate::{ - Axis, ButtonInput, gamepad::{Gamepad, GamepadAxis, GamepadButton, GamepadSettings}, keyboard::KeyCode, mouse::MouseButton, touch::{TouchInput, Touches}, + Axis, ButtonInput, }; } @@ -49,22 +49,22 @@ use bevy_ecs::prelude::*; #[cfg(feature = "bevy_reflect")] use bevy_reflect::Reflect; use gestures::*; -use keyboard::{KeyCode, KeyboardFocusLost, KeyboardInput, keyboard_input_system}; +use keyboard::{keyboard_input_system, KeyCode, KeyboardFocusLost, KeyboardInput}; use mouse::{ + accumulate_mouse_motion_system, accumulate_mouse_scroll_system, mouse_button_input_system, AccumulatedMouseMotion, AccumulatedMouseScroll, MouseButton, MouseButtonInput, MouseMotion, - MouseWheel, accumulate_mouse_motion_system, accumulate_mouse_scroll_system, - mouse_button_input_system, + MouseWheel, }; -use touch::{TouchInput, Touches, touch_screen_input_system}; +use touch::{touch_screen_input_system, TouchInput, Touches}; #[cfg(feature = "bevy_reflect")] use gamepad::Gamepad; use gamepad::{ - GamepadAxis, GamepadAxisChangedEvent, GamepadButton, GamepadButtonChangedEvent, + gamepad_connection_system, gamepad_event_processing_system, GamepadAxis, + GamepadAxisChangedEvent, GamepadButton, GamepadButtonChangedEvent, GamepadButtonStateChangedEvent, GamepadConnection, GamepadConnectionEvent, GamepadEvent, GamepadInput, GamepadRumbleRequest, GamepadSettings, RawGamepadAxisChangedEvent, - RawGamepadButtonChangedEvent, RawGamepadEvent, gamepad_connection_system, - gamepad_event_processing_system, + RawGamepadButtonChangedEvent, RawGamepadEvent, }; #[cfg(all(feature = "serialize", feature = "bevy_reflect"))] diff --git a/crates/bevy_input/src/mouse.rs b/crates/bevy_input/src/mouse.rs index 8f6b926116f6e..977b6e0aea3bb 100644 --- a/crates/bevy_input/src/mouse.rs +++ b/crates/bevy_input/src/mouse.rs @@ -12,7 +12,7 @@ use bevy_math::Vec2; #[cfg(feature = "bevy_reflect")] use { bevy_ecs::reflect::ReflectResource, - bevy_reflect::{Reflect, std_traits::ReflectDefault}, + bevy_reflect::{std_traits::ReflectDefault, Reflect}, }; #[cfg(all(feature = "serialize", feature = "bevy_reflect"))] diff --git a/crates/bevy_input/src/touch.rs b/crates/bevy_input/src/touch.rs index 78ef52ab2c156..e1784c13fdfea 100644 --- a/crates/bevy_input/src/touch.rs +++ b/crates/bevy_input/src/touch.rs @@ -454,7 +454,7 @@ mod test { #[test] fn touch_update() { - use crate::{Touches, touch::Touch}; + use crate::{touch::Touch, Touches}; use bevy_math::Vec2; let mut touches = Touches::default(); @@ -485,7 +485,7 @@ mod test { #[test] fn touch_process() { - use crate::{TouchInput, Touches, touch::TouchPhase}; + use crate::{touch::TouchPhase, TouchInput, Touches}; use bevy_ecs::entity::Entity; use bevy_math::Vec2; @@ -570,7 +570,7 @@ mod test { // See https://github.com/bevyengine/bevy/issues/12442 #[test] fn touch_process_multi_event() { - use crate::{TouchInput, Touches, touch::TouchPhase}; + use crate::{touch::TouchPhase, TouchInput, Touches}; use bevy_ecs::entity::Entity; use bevy_math::Vec2; @@ -632,7 +632,7 @@ mod test { #[test] fn touch_pressed() { - use crate::{TouchInput, Touches, touch::TouchPhase}; + use crate::{touch::TouchPhase, TouchInput, Touches}; use bevy_ecs::entity::Entity; use bevy_math::Vec2; @@ -659,7 +659,7 @@ mod test { #[test] fn touch_released() { - use crate::{TouchInput, Touches, touch::TouchPhase}; + use crate::{touch::TouchPhase, TouchInput, Touches}; use bevy_ecs::entity::Entity; use bevy_math::Vec2; @@ -686,7 +686,7 @@ mod test { #[test] fn touch_canceled() { - use crate::{TouchInput, Touches, touch::TouchPhase}; + use crate::{touch::TouchPhase, TouchInput, Touches}; use bevy_ecs::entity::Entity; use bevy_math::Vec2; @@ -712,7 +712,7 @@ mod test { #[test] fn release_touch() { - use crate::{TouchInput, Touches, touch::TouchPhase}; + use crate::{touch::TouchPhase, TouchInput, Touches}; use bevy_ecs::entity::Entity; use bevy_math::Vec2; @@ -738,7 +738,7 @@ mod test { #[test] fn release_all_touches() { - use crate::{TouchInput, Touches, touch::TouchPhase}; + use crate::{touch::TouchPhase, TouchInput, Touches}; use bevy_ecs::entity::Entity; use bevy_math::Vec2; @@ -776,7 +776,7 @@ mod test { #[test] fn clear_touches() { - use crate::{TouchInput, Touches, touch::TouchPhase}; + use crate::{touch::TouchPhase, TouchInput, Touches}; use bevy_ecs::entity::Entity; use bevy_math::Vec2; @@ -826,7 +826,7 @@ mod test { #[test] fn reset_all_touches() { - use crate::{TouchInput, Touches, touch::TouchPhase}; + use crate::{touch::TouchPhase, TouchInput, Touches}; use bevy_ecs::entity::Entity; use bevy_math::Vec2; diff --git a/crates/bevy_input_focus/src/autofocus.rs b/crates/bevy_input_focus/src/autofocus.rs index 8cf4c99f1e2db..dc3b0919d2a7d 100644 --- a/crates/bevy_input_focus/src/autofocus.rs +++ b/crates/bevy_input_focus/src/autofocus.rs @@ -5,7 +5,7 @@ use bevy_ecs::{component::HookContext, prelude::*, world::DeferredWorld}; use crate::InputFocus; #[cfg(feature = "bevy_reflect")] -use bevy_reflect::{Reflect, prelude::*}; +use bevy_reflect::{prelude::*, Reflect}; /// Indicates that this widget should automatically receive [`InputFocus`]. /// diff --git a/crates/bevy_input_focus/src/directional_navigation.rs b/crates/bevy_input_focus/src/directional_navigation.rs index 25f53fbd9d94f..d42b7653f6592 100644 --- a/crates/bevy_input_focus/src/directional_navigation.rs +++ b/crates/bevy_input_focus/src/directional_navigation.rs @@ -27,7 +27,7 @@ use thiserror::Error; use crate::InputFocus; #[cfg(feature = "bevy_reflect")] -use bevy_reflect::{Reflect, prelude::*}; +use bevy_reflect::{prelude::*, Reflect}; /// A plugin that sets up the directional navigation systems and resources. #[derive(Default)] diff --git a/crates/bevy_input_focus/src/lib.rs b/crates/bevy_input_focus/src/lib.rs index 8e232f1808c43..0ec0b428978e9 100644 --- a/crates/bevy_input_focus/src/lib.rs +++ b/crates/bevy_input_focus/src/lib.rs @@ -37,7 +37,7 @@ use bevy_window::{PrimaryWindow, Window}; use core::fmt::Debug; #[cfg(feature = "bevy_reflect")] -use bevy_reflect::{Reflect, prelude::*}; +use bevy_reflect::{prelude::*, Reflect}; /// Resource representing which entity has input focus, if any. Input events (other than pointer-like inputs) will be /// dispatched to the current focus entity, or to the primary window if no entity has focus. @@ -364,8 +364,8 @@ mod tests { component::HookContext, observer::Trigger, system::RunSystemOnce, world::DeferredWorld, }; use bevy_input::{ - ButtonState, InputPlugin, keyboard::{Key, KeyCode}, + ButtonState, InputPlugin, }; use bevy_window::WindowResolution; use smol_str::SmolStr; diff --git a/crates/bevy_input_focus/src/tab_navigation.rs b/crates/bevy_input_focus/src/tab_navigation.rs index f827cb5869456..683e5d12d5fe8 100644 --- a/crates/bevy_input_focus/src/tab_navigation.rs +++ b/crates/bevy_input_focus/src/tab_navigation.rs @@ -35,8 +35,8 @@ use bevy_ecs::{ system::{Commands, Query, Res, ResMut, SystemParam}, }; use bevy_input::{ - ButtonInput, ButtonState, keyboard::{KeyCode, KeyboardInput}, + ButtonInput, ButtonState, }; use bevy_window::PrimaryWindow; use log::warn; @@ -47,7 +47,7 @@ use crate::{FocusedInput, InputFocus, InputFocusVisible}; #[cfg(feature = "bevy_reflect")] use { bevy_ecs::prelude::ReflectComponent, - bevy_reflect::{Reflect, prelude::*}, + bevy_reflect::{prelude::*, Reflect}, }; /// A component which indicates that an entity wants to participate in tab navigation. @@ -135,9 +135,7 @@ pub enum TabNavigationError { #[error("Failed to navigate to next focusable entity")] FailedToNavigateToNextFocusableEntity, /// No tab group for the current focus entity was found. - #[error( - "No tab group found for currently focused entity {previous_focus}. Users will not be able to navigate back to this entity." - )] + #[error("No tab group found for currently focused entity {previous_focus}. Users will not be able to navigate back to this entity.")] NoTabGroupForCurrentFocus { /// The entity that was previously focused, /// and is missing its tab group. diff --git a/crates/bevy_internal/src/default_plugins.rs b/crates/bevy_internal/src/default_plugins.rs index 383da24835e81..d9aee3017a2ee 100644 --- a/crates/bevy_internal/src/default_plugins.rs +++ b/crates/bevy_internal/src/default_plugins.rs @@ -1,4 +1,4 @@ -use bevy_app::{Plugin, plugin_group}; +use bevy_app::{plugin_group, Plugin}; plugin_group! { /// This plugin group will add all the default plugins for a *Bevy* application: diff --git a/crates/bevy_internal/src/prelude.rs b/crates/bevy_internal/src/prelude.rs index 9d79df63e9cb8..1c19c7ccc14a0 100644 --- a/crates/bevy_internal/src/prelude.rs +++ b/crates/bevy_internal/src/prelude.rs @@ -1,8 +1,8 @@ #[doc(hidden)] pub use crate::{ - DefaultPlugins, MinimalPlugins, app::prelude::*, ecs::prelude::*, input::prelude::*, - log::prelude::*, math::prelude::*, reflect::prelude::*, time::prelude::*, - transform::prelude::*, utils::prelude::*, + app::prelude::*, ecs::prelude::*, input::prelude::*, log::prelude::*, math::prelude::*, + reflect::prelude::*, time::prelude::*, transform::prelude::*, utils::prelude::*, + DefaultPlugins, MinimalPlugins, }; #[doc(hidden)] @@ -13,7 +13,7 @@ pub use crate::window::prelude::*; #[cfg(feature = "bevy_image")] pub use crate::image::prelude::*; -pub use bevy_derive::{Deref, DerefMut, bevy_main}; +pub use bevy_derive::{bevy_main, Deref, DerefMut}; #[doc(hidden)] #[cfg(feature = "bevy_asset")] diff --git a/crates/bevy_log/src/android_tracing.rs b/crates/bevy_log/src/android_tracing.rs index 3210d207a23b5..ba0b3b7a27a38 100644 --- a/crates/bevy_log/src/android_tracing.rs +++ b/crates/bevy_log/src/android_tracing.rs @@ -1,11 +1,11 @@ use alloc::ffi::CString; use core::fmt::{Debug, Write}; use tracing::{ - Event, Id, Level, Subscriber, field::Field, span::{Attributes, Record}, + Event, Id, Level, Subscriber, }; -use tracing_subscriber::{Layer, field::Visit, layer::Context, registry::LookupSpan}; +use tracing_subscriber::{field::Visit, layer::Context, registry::LookupSpan, Layer}; #[derive(Default)] pub(crate) struct AndroidLayer; diff --git a/crates/bevy_log/src/lib.rs b/crates/bevy_log/src/lib.rs index 368d9cbccea3b..f0743f022de0f 100644 --- a/crates/bevy_log/src/lib.rs +++ b/crates/bevy_log/src/lib.rs @@ -47,24 +47,24 @@ pub mod prelude { pub use bevy_utils::once; pub use tracing::{ - self, Level, debug, debug_span, error, error_span, info, info_span, trace, trace_span, warn, - warn_span, + self, debug, debug_span, error, error_span, info, info_span, trace, trace_span, warn, + warn_span, Level, }; pub use tracing_subscriber; use bevy_app::{App, Plugin}; use tracing_log::LogTracer; use tracing_subscriber::{ - EnvFilter, Layer, filter::{FromEnvError, ParseError}, prelude::*, registry::Registry, + EnvFilter, Layer, }; #[cfg(feature = "tracing-chrome")] use { bevy_ecs::resource::Resource, bevy_utils::synccell::SyncCell, - tracing_subscriber::fmt::{FormattedFields, format::DefaultFields}, + tracing_subscriber::fmt::{format::DefaultFields, FormattedFields}, }; /// Wrapper resource for `tracing-chrome`'s flush guard. @@ -371,12 +371,8 @@ impl Plugin for LogPlugin { (true, true) => error!( "Could not set global logger and tracing subscriber as they are already set. Consider disabling LogPlugin." ), - (true, false) => error!( - "Could not set global logger as it is already set. Consider disabling LogPlugin." - ), - (false, true) => error!( - "Could not set global tracing subscriber as it is already set. Consider disabling LogPlugin." - ), + (true, false) => error!("Could not set global logger as it is already set. Consider disabling LogPlugin."), + (false, true) => error!("Could not set global tracing subscriber as it is already set. Consider disabling LogPlugin."), (false, false) => (), } } diff --git a/crates/bevy_macro_utils/src/attrs.rs b/crates/bevy_macro_utils/src/attrs.rs index 92fa0056dd1c0..9e000f217bbe3 100644 --- a/crates/bevy_macro_utils/src/attrs.rs +++ b/crates/bevy_macro_utils/src/attrs.rs @@ -28,9 +28,7 @@ pub fn get_lit_bool(attr_name: Symbol, value: &Expr) -> syn::Result { } else { Err(syn::Error::new_spanned( value, - format!( - "expected {attr_name} attribute to be a bool value, `true` or `false`: `{attr_name} = ...`" - ), + format!("expected {attr_name} attribute to be a bool value, `true` or `false`: `{attr_name} = ...`"), ))? } } diff --git a/crates/bevy_macro_utils/src/fq_std.rs b/crates/bevy_macro_utils/src/fq_std.rs index 2a76a2a5dcd34..c350d101ad71a 100644 --- a/crates/bevy_macro_utils/src/fq_std.rs +++ b/crates/bevy_macro_utils/src/fq_std.rs @@ -37,7 +37,7 @@ //! ``` use proc_macro2::TokenStream; -use quote::{ToTokens, quote}; +use quote::{quote, ToTokens}; /// Fully Qualified (FQ) short name for [`std::any::Any`] pub struct FQAny; diff --git a/crates/bevy_macro_utils/src/label.rs b/crates/bevy_macro_utils/src/label.rs index 2ead810073881..1fc540c9c4ea3 100644 --- a/crates/bevy_macro_utils/src/label.rs +++ b/crates/bevy_macro_utils/src/label.rs @@ -1,7 +1,7 @@ use proc_macro::{TokenStream, TokenTree}; use quote::{quote, quote_spanned}; use std::collections::HashSet; -use syn::{Ident, spanned::Spanned}; +use syn::{spanned::Spanned, Ident}; /// Finds an identifier that will not conflict with the specified set of tokens. /// diff --git a/crates/bevy_macro_utils/src/shape.rs b/crates/bevy_macro_utils/src/shape.rs index 1b5d900aefdf0..2d0124d62a8f9 100644 --- a/crates/bevy_macro_utils/src/shape.rs +++ b/crates/bevy_macro_utils/src/shape.rs @@ -1,5 +1,5 @@ use proc_macro::Span; -use syn::{Data, DataStruct, Error, Field, Fields, punctuated::Punctuated, token::Comma}; +use syn::{punctuated::Punctuated, token::Comma, Data, DataStruct, Error, Field, Fields}; /// Get the fields of a data structure if that structure is a struct with named fields; /// otherwise, return a compile error that points to the site of the macro invocation. diff --git a/crates/bevy_math/src/bounding/bounded2d/mod.rs b/crates/bevy_math/src/bounding/bounded2d/mod.rs index 47a012b5d8a29..c5be831a86f86 100644 --- a/crates/bevy_math/src/bounding/bounded2d/mod.rs +++ b/crates/bevy_math/src/bounding/bounded2d/mod.rs @@ -2,8 +2,9 @@ mod primitive_impls; use super::{BoundingVolume, IntersectsVolume}; use crate::{ - FloatPow, Isometry2d, ops, + ops, prelude::{Mat2, Rot2, Vec2}, + FloatPow, Isometry2d, }; #[cfg(feature = "bevy_reflect")] @@ -262,9 +263,8 @@ impl IntersectsVolume for Aabb2d { mod aabb2d_tests { use super::Aabb2d; use crate::{ - Vec2, bounding::{BoundingCircle, BoundingVolume, IntersectsVolume}, - ops, + ops, Vec2, }; #[test] @@ -614,9 +614,8 @@ impl IntersectsVolume for BoundingCircle { mod bounding_circle_tests { use super::BoundingCircle; use crate::{ - Vec2, bounding::{BoundingVolume, IntersectsVolume}, - ops, + ops, Vec2, }; #[test] diff --git a/crates/bevy_math/src/bounding/bounded2d/primitive_impls.rs b/crates/bevy_math/src/bounding/bounded2d/primitive_impls.rs index cf1f2d8f47132..e1fe6afd774d5 100644 --- a/crates/bevy_math/src/bounding/bounded2d/primitive_impls.rs +++ b/crates/bevy_math/src/bounding/bounded2d/primitive_impls.rs @@ -1,13 +1,13 @@ //! Contains [`Bounded2d`] implementations for [geometric primitives](crate::primitives). use crate::{ - Dir2, Isometry2d, Mat2, Rot2, Vec2, bounding::BoundingVolume, ops, primitives::{ Annulus, Arc2d, Capsule2d, Circle, CircularSector, CircularSegment, Ellipse, Line2d, Plane2d, Polygon, Polyline2d, Rectangle, RegularPolygon, Rhombus, Segment2d, Triangle2d, }, + Dir2, Isometry2d, Mat2, Rot2, Vec2, }; use core::f32::consts::{FRAC_PI_2, PI, TAU}; @@ -446,7 +446,6 @@ mod tests { use glam::Vec2; use crate::{ - Dir2, Isometry2d, Rot2, bounding::Bounded2d, ops::{self, FloatPow}, primitives::{ @@ -454,6 +453,7 @@ mod tests { Plane2d, Polygon, Polyline2d, Rectangle, RegularPolygon, Rhombus, Segment2d, Triangle2d, }, + Dir2, Isometry2d, Rot2, }; #[test] diff --git a/crates/bevy_math/src/bounding/bounded3d/extrusion.rs b/crates/bevy_math/src/bounding/bounded3d/extrusion.rs index 98331164e19e0..47d5d6676356a 100644 --- a/crates/bevy_math/src/bounding/bounded3d/extrusion.rs +++ b/crates/bevy_math/src/bounding/bounded3d/extrusion.rs @@ -3,13 +3,13 @@ use core::f32::consts::FRAC_PI_2; use glam::{Vec2, Vec3A, Vec3Swizzles}; use crate::{ - Isometry2d, Isometry3d, Quat, Rot2, bounding::{BoundingCircle, BoundingVolume}, ops, primitives::{ Capsule2d, Cuboid, Cylinder, Ellipse, Extrusion, Line2d, Polygon, Polyline2d, Primitive2d, Rectangle, RegularPolygon, Segment2d, Triangle2d, }, + Isometry2d, Isometry3d, Quat, Rot2, }; #[cfg(feature = "alloc")] @@ -270,13 +270,13 @@ mod tests { use glam::{EulerRot, Quat, Vec2, Vec3, Vec3A}; use crate::{ - Dir2, Isometry3d, bounding::{Bounded3d, BoundingVolume}, ops, primitives::{ Capsule2d, Circle, Ellipse, Extrusion, Line2d, Polygon, Polyline2d, Rectangle, RegularPolygon, Segment2d, Triangle2d, }, + Dir2, Isometry3d, }; #[test] diff --git a/crates/bevy_math/src/bounding/bounded3d/mod.rs b/crates/bevy_math/src/bounding/bounded3d/mod.rs index c5f53b83b137b..c4f3c979f67cb 100644 --- a/crates/bevy_math/src/bounding/bounded3d/mod.rs +++ b/crates/bevy_math/src/bounding/bounded3d/mod.rs @@ -5,8 +5,8 @@ use glam::Mat3; use super::{BoundingVolume, IntersectsVolume}; use crate::{ - Isometry3d, Quat, Vec3A, ops::{self, FloatPow}, + Isometry3d, Quat, Vec3A, }; #[cfg(feature = "bevy_reflect")] @@ -267,9 +267,8 @@ impl IntersectsVolume for Aabb3d { mod aabb3d_tests { use super::Aabb3d; use crate::{ - Quat, Vec3, Vec3A, bounding::{BoundingSphere, BoundingVolume, IntersectsVolume}, - ops, + ops, Quat, Vec3, Vec3A, }; #[test] @@ -647,9 +646,8 @@ mod bounding_sphere_tests { use super::BoundingSphere; use crate::{ - Quat, Vec3, Vec3A, bounding::{BoundingVolume, IntersectsVolume}, - ops, + ops, Quat, Vec3, Vec3A, }; #[test] diff --git a/crates/bevy_math/src/bounding/bounded3d/primitive_impls.rs b/crates/bevy_math/src/bounding/bounded3d/primitive_impls.rs index 7baf43e36f540..1f4e2a1666d17 100644 --- a/crates/bevy_math/src/bounding/bounded3d/primitive_impls.rs +++ b/crates/bevy_math/src/bounding/bounded3d/primitive_impls.rs @@ -1,13 +1,13 @@ //! Contains [`Bounded3d`] implementations for [geometric primitives](crate::primitives). use crate::{ - Isometry2d, Isometry3d, Mat3, Vec2, Vec3, Vec3A, bounding::{Bounded2d, BoundingCircle, BoundingVolume}, ops, primitives::{ Capsule3d, Cone, ConicalFrustum, Cuboid, Cylinder, InfinitePlane3d, Line3d, Polyline3d, Segment3d, Sphere, Torus, Triangle2d, Triangle3d, }, + Isometry2d, Isometry3d, Mat3, Vec2, Vec3, Vec3A, }; #[cfg(feature = "alloc")] @@ -376,16 +376,16 @@ impl Bounded3d for Triangle3d { #[cfg(test)] mod tests { - use crate::{Isometry3d, bounding::BoundingVolume, ops}; + use crate::{bounding::BoundingVolume, ops, Isometry3d}; use glam::{Quat, Vec3, Vec3A}; use crate::{ - Dir3, bounding::Bounded3d, primitives::{ Capsule3d, Cone, ConicalFrustum, Cuboid, Cylinder, InfinitePlane3d, Line3d, Polyline3d, Segment3d, Sphere, Torus, Triangle3d, }, + Dir3, }; #[test] diff --git a/crates/bevy_math/src/bounding/raycast2d.rs b/crates/bevy_math/src/bounding/raycast2d.rs index 5c50875e6447d..3b46bcfba62c3 100644 --- a/crates/bevy_math/src/bounding/raycast2d.rs +++ b/crates/bevy_math/src/bounding/raycast2d.rs @@ -1,7 +1,7 @@ use super::{Aabb2d, BoundingCircle, IntersectsVolume}; use crate::{ - Dir2, Ray2d, Vec2, ops::{self, FloatPow}, + Dir2, Ray2d, Vec2, }; #[cfg(feature = "bevy_reflect")] @@ -67,7 +67,11 @@ impl RayCast2d { let tmin = tmin_x.max(tmin_y).max(0.); let tmax = tmax_y.min(tmax_x).min(self.max); - if tmin <= tmax { Some(tmin) } else { None } + if tmin <= tmax { + Some(tmin) + } else { + None + } } /// Get the distance of an intersection with a [`BoundingCircle`], if any. diff --git a/crates/bevy_math/src/bounding/raycast3d.rs b/crates/bevy_math/src/bounding/raycast3d.rs index 45023edf5b69e..bfd5d17a0dd8c 100644 --- a/crates/bevy_math/src/bounding/raycast3d.rs +++ b/crates/bevy_math/src/bounding/raycast3d.rs @@ -1,7 +1,7 @@ use super::{Aabb3d, BoundingSphere, IntersectsVolume}; use crate::{ - Dir3A, Ray3d, Vec3A, ops::{self, FloatPow}, + Dir3A, Ray3d, Vec3A, }; #[cfg(feature = "bevy_reflect")] @@ -64,7 +64,11 @@ impl RayCast3d { let tmin = tmin.max_element().max(0.); let tmax = tmax.min_element().min(self.max); - if tmin <= tmax { Some(tmin) } else { None } + if tmin <= tmax { + Some(tmin) + } else { + None + } } /// Get the distance of an intersection with a [`BoundingSphere`], if any. diff --git a/crates/bevy_math/src/common_traits.rs b/crates/bevy_math/src/common_traits.rs index 80004a9a35505..a9a8ef910a86e 100644 --- a/crates/bevy_math/src/common_traits.rs +++ b/crates/bevy_math/src/common_traits.rs @@ -1,6 +1,6 @@ //! This module contains abstract mathematical traits shared by types used in `bevy_math`. -use crate::{Dir2, Dir3, Dir3A, Quat, Rot2, Vec2, Vec3, Vec3A, Vec4, ops}; +use crate::{ops, Dir2, Dir3, Dir3A, Quat, Rot2, Vec2, Vec3, Vec3A, Vec4}; use core::{ fmt::Debug, ops::{Add, Div, Mul, Neg, Sub}, diff --git a/crates/bevy_math/src/cubic_splines/curve_impls.rs b/crates/bevy_math/src/cubic_splines/curve_impls.rs index 520ad5aad3287..85fd9fb6adab6 100644 --- a/crates/bevy_math/src/cubic_splines/curve_impls.rs +++ b/crates/bevy_math/src/cubic_splines/curve_impls.rs @@ -1,8 +1,8 @@ use super::{CubicSegment, RationalSegment}; use crate::common_traits::{VectorSpace, WithDerivative, WithTwoDerivatives}; use crate::curve::{ - Curve, Interval, derivatives::{SampleDerivative, SampleTwoDerivatives}, + Curve, Interval, }; #[cfg(feature = "alloc")] diff --git a/crates/bevy_math/src/cubic_splines/mod.rs b/crates/bevy_math/src/cubic_splines/mod.rs index 8e9b12352654c..32e13f6720a92 100644 --- a/crates/bevy_math/src/cubic_splines/mod.rs +++ b/crates/bevy_math/src/cubic_splines/mod.rs @@ -3,11 +3,11 @@ #[cfg(feature = "curve")] mod curve_impls; use crate::{ - Vec2, VectorSpace, ops::{self, FloatPow}, + Vec2, VectorSpace, }; #[cfg(feature = "bevy_reflect")] -use bevy_reflect::{Reflect, std_traits::ReflectDefault}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use thiserror::Error; #[cfg(feature = "alloc")] use {alloc::vec, alloc::vec::Vec, core::iter::once, itertools::Itertools}; @@ -925,9 +925,7 @@ impl CyclicCubicGenerator