Skip to content

Commit cb34db6

Browse files
authored
Fix latest lints for rust beta (#20516)
# Objective - Fix #19679 ## Solution - fix lints
1 parent 41c41bf commit cb34db6

File tree

12 files changed

+20
-14
lines changed

12 files changed

+20
-14
lines changed

crates/bevy_animation/src/gltf_curves.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ impl<T> WideCubicKeyframeCurve<T> {
353353
let values: Vec<T> = values.into_iter().collect();
354354
let divisor = times.len() * 3;
355355

356-
if values.len() % divisor != 0 {
356+
if !values.len().is_multiple_of(divisor) {
357357
return Err(WideKeyframeCurveError::LengthMismatch {
358358
values_given: values.len(),
359359
divisor,

crates/bevy_anti_aliasing/src/taa/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ fn prepare_taa_history_textures(
439439
texture_descriptor.label = Some("taa_history_2_texture");
440440
let history_2_texture = texture_cache.get(&render_device, texture_descriptor);
441441

442-
let textures = if frame_count.0 % 2 == 0 {
442+
let textures = if frame_count.0.is_multiple_of(2) {
443443
TemporalAntiAliasHistoryTextures {
444444
write: history_1_texture,
445445
read: history_2_texture,

crates/bevy_image/src/basis.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub fn basis_buffer_to_image(
4545

4646
let image_count = transcoder.image_count(buffer);
4747
let texture_type = transcoder.basis_texture_type(buffer);
48-
if texture_type == BasisTextureType::TextureTypeCubemapArray && image_count % 6 != 0 {
48+
if texture_type == BasisTextureType::TextureTypeCubemapArray && !image_count.is_multiple_of(6) {
4949
return Err(TextureError::InvalidData(format!(
5050
"Basis file with cube map array texture with non-modulo 6 number of images: {image_count}",
5151
)));

crates/bevy_mesh/src/mesh.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ impl Mesh {
606606
match topology {
607607
PrimitiveTopology::TriangleList => {
608608
// Early return if the index count doesn't match
609-
if indices.len() % 3 != 0 {
609+
if !indices.len().is_multiple_of(3) {
610610
return Err(MeshWindingInvertError::AbruptIndicesEnd);
611611
}
612612
for chunk in indices.chunks_mut(3) {
@@ -620,7 +620,7 @@ impl Mesh {
620620
}
621621
PrimitiveTopology::LineList => {
622622
// Early return if the index count doesn't match
623-
if indices.len() % 2 != 0 {
623+
if !indices.len().is_multiple_of(2) {
624624
return Err(MeshWindingInvertError::AbruptIndicesEnd);
625625
}
626626
indices.reverse();

crates/bevy_mesh/src/primitives/dim2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1111,7 +1111,7 @@ impl MeshBuilder for Capsule2dMeshBuilder {
11111111

11121112
// If the vertex count is even, offset starting angle of top semicircle by half a step
11131113
// to position the vertices evenly.
1114-
let start_angle = if vertex_count % 2 == 0 {
1114+
let start_angle = if vertex_count.is_multiple_of(2) {
11151115
step / 2.0
11161116
} else {
11171117
0.0

crates/bevy_pbr/src/meshlet/persistent_buffer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl<T: PersistentGpuBufferable> PersistentGpuBuffer<T> {
3939
/// Queue an item of type T to be added to the buffer, returning the byte range within the buffer that it will be located at.
4040
pub fn queue_write(&mut self, data: T, metadata: T::Metadata) -> Range<BufferAddress> {
4141
let data_size = data.size_in_bytes() as u64;
42-
debug_assert!(data_size % COPY_BUFFER_ALIGNMENT == 0);
42+
debug_assert!(data_size.is_multiple_of(COPY_BUFFER_ALIGNMENT));
4343
if let Ok(buffer_slice) = self.allocation_planner.allocate_range(data_size) {
4444
self.write_queue
4545
.push((data, metadata, buffer_slice.clone()));

crates/bevy_pbr/src/render/morph.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ pub fn prepare_morphs(
7575
}
7676

7777
const fn can_align(step: usize, target: usize) -> bool {
78-
step % target == 0 || target % step == 0
78+
step.is_multiple_of(target) || target.is_multiple_of(step)
7979
}
8080

8181
const WGPU_MIN_ALIGN: usize = 256;

crates/bevy_render/src/render_resource/bind_group_entries.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,12 @@ pub struct DynamicBindGroupEntries<'b> {
244244
entries: Vec<BindGroupEntry<'b>>,
245245
}
246246

247+
impl<'b> Default for DynamicBindGroupEntries<'b> {
248+
fn default() -> Self {
249+
Self::new()
250+
}
251+
}
252+
247253
impl<'b> DynamicBindGroupEntries<'b> {
248254
pub fn sequential<const N: usize>(entries: impl IntoBindingArray<'b, N>) -> Self {
249255
Self {

crates/bevy_tasks/src/task_pool.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -384,12 +384,12 @@ impl TaskPool {
384384
unsafe { mem::transmute(external_executor) };
385385
// SAFETY: As above, all futures must complete in this function so we can change the lifetime
386386
let scope_executor: &'env ThreadExecutor<'env> = unsafe { mem::transmute(scope_executor) };
387-
let spawned: ConcurrentQueue<FallibleTask<Result<T, Box<(dyn core::any::Any + Send)>>>> =
387+
let spawned: ConcurrentQueue<FallibleTask<Result<T, Box<dyn core::any::Any + Send>>>> =
388388
ConcurrentQueue::unbounded();
389389
// shadow the variable so that the owned value cannot be used for the rest of the function
390390
// SAFETY: As above, all futures must complete in this function so we can change the lifetime
391391
let spawned: &'env ConcurrentQueue<
392-
FallibleTask<Result<T, Box<(dyn core::any::Any + Send)>>>,
392+
FallibleTask<Result<T, Box<dyn core::any::Any + Send>>>,
393393
> = unsafe { mem::transmute(&spawned) };
394394

395395
let scope = Scope {
@@ -628,7 +628,7 @@ pub struct Scope<'scope, 'env: 'scope, T> {
628628
executor: &'scope crate::executor::Executor<'scope>,
629629
external_executor: &'scope ThreadExecutor<'scope>,
630630
scope_executor: &'scope ThreadExecutor<'scope>,
631-
spawned: &'scope ConcurrentQueue<FallibleTask<Result<T, Box<(dyn core::any::Any + Send)>>>>,
631+
spawned: &'scope ConcurrentQueue<FallibleTask<Result<T, Box<dyn core::any::Any + Send>>>>,
632632
// make `Scope` invariant over 'scope and 'env
633633
scope: PhantomData<&'scope mut &'scope ()>,
634634
env: PhantomData<&'env mut &'env ()>,

examples/app/headless.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ fn hello_world_system() {
5050
}
5151

5252
fn counter(mut state: Local<CounterState>) {
53-
if state.count % 60 == 0 {
53+
if state.count.is_multiple_of(60) {
5454
println!("{}", state.count);
5555
}
5656
state.count += 1;

0 commit comments

Comments
 (0)