Skip to content

Commit 5f8f3b5

Browse files
Check cfg during CI and fix feature typos (#12103)
# Objective - Add the new `-Zcheck-cfg` checks to catch more warnings - Fixes #12091 ## Solution - Create a new `cfg-check` to the CI that runs `cargo check -Zcheck-cfg --workspace` using cargo nightly (and fails if there are warnings) - Fix all warnings generated by the new check --- ## Changelog - Remove all redundant imports - Fix cfg wasm32 targets - Add 3 dead code exceptions (should StandardColor be unused?) - Convert ios_simulator to a feature (I'm not sure if this is the right way to do it, but the check complained before) ## Migration Guide No breaking changes --------- Co-authored-by: Alice Cecile <[email protected]>
1 parent c0a52d9 commit 5f8f3b5

File tree

36 files changed

+78
-122
lines changed

36 files changed

+78
-122
lines changed

.github/workflows/ci.yml

+23-1
Original file line numberDiff line numberDiff line change
@@ -375,4 +375,26 @@ jobs:
375375
echo " Fix the issue by replacing 'bevy_internal' with 'bevy'"
376376
echo " Example: 'use bevy::sprite::MaterialMesh2dBundle;' instead of 'bevy_internal::sprite::MaterialMesh2dBundle;'"
377377
exit 1
378-
fi
378+
fi
379+
check-cfg:
380+
runs-on: ubuntu-latest
381+
timeout-minutes: 30
382+
steps:
383+
- uses: actions/checkout@v4
384+
- uses: actions/cache@v4
385+
with:
386+
path: |
387+
~/.cargo/bin/
388+
~/.cargo/registry/index/
389+
~/.cargo/registry/cache/
390+
~/.cargo/git/db/
391+
target/
392+
key: ${{ runner.os }}-check-doc-${{ hashFiles('**/Cargo.toml') }}
393+
- uses: dtolnay/rust-toolchain@master
394+
with:
395+
toolchain: ${{ env.NIGHTLY_TOOLCHAIN }}
396+
- name: Install alsa and udev
397+
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev
398+
- name: Build and check cfg typos
399+
# See tools/ci/src/main.rs for the commands this runs
400+
run: cargo run -p ci -- cfg-check

crates/bevy_app/src/app.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ pub use bevy_derive::AppLabel;
33
use bevy_ecs::{
44
prelude::*,
55
schedule::{
6-
apply_state_transition, common_conditions::run_once as run_once_condition,
7-
run_enter_schedule, InternedScheduleLabel, IntoSystemConfigs, IntoSystemSetConfigs,
8-
ScheduleBuildSettings, ScheduleLabel, StateTransitionEvent,
6+
common_conditions::run_once as run_once_condition, run_enter_schedule,
7+
InternedScheduleLabel, ScheduleBuildSettings, ScheduleLabel,
98
},
109
};
1110
use bevy_utils::{intern::Interned, thiserror::Error, tracing::debug, HashMap, HashSet};

crates/bevy_color/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ pub use xyza::*;
9898
use bevy_render::color::LegacyColor;
9999

100100
/// Describes the traits that a color should implement for consistency.
101+
#[allow(dead_code)] // This is an internal marker trait used to ensure that our color types impl the required traits
101102
pub(crate) trait StandardColor
102103
where
103104
Self: core::fmt::Debug,

crates/bevy_core/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ mod name;
55
mod serde;
66
mod task_pool_options;
77

8-
use bevy_ecs::system::{ResMut, Resource};
8+
use bevy_ecs::system::Resource;
99
pub use bytemuck::{bytes_of, cast_slice, Pod, Zeroable};
1010
pub use name::*;
1111
pub use task_pool_options::*;

crates/bevy_core_pipeline/src/contrast_adaptive_sharpening/node.rs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use std::sync::Mutex;
22

33
use crate::contrast_adaptive_sharpening::ViewCASPipeline;
44
use bevy_ecs::prelude::*;
5-
use bevy_ecs::query::QueryState;
65
use bevy_render::{
76
extract_component::{ComponentUniforms, DynamicUniformIndex},
87
render_graph::{Node, NodeRunError, RenderGraphContext},

crates/bevy_core_pipeline/src/deferred/copy_lighting_id.rs

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ use bevy_render::{
1818
use bevy_ecs::query::QueryItem;
1919
use bevy_render::{
2020
render_graph::{NodeRunError, RenderGraphContext, ViewNode},
21-
render_resource::{Operations, PipelineCache, RenderPassDescriptor},
2221
renderer::RenderContext,
2322
};
2423

crates/bevy_core_pipeline/src/msaa_writeback.rs

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use bevy_render::{
99
camera::ExtractedCamera,
1010
color::LegacyColor,
1111
render_graph::{Node, NodeRunError, RenderGraphApp, RenderGraphContext},
12-
render_resource::BindGroupEntries,
1312
renderer::RenderContext,
1413
view::{Msaa, ViewTarget},
1514
Render, RenderSet,

crates/bevy_ecs/src/entity/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ use crate::{
5656
storage::{SparseSetIndex, TableId, TableRow},
5757
};
5858
use serde::{Deserialize, Serialize};
59-
use std::{convert::TryFrom, fmt, hash::Hash, mem, num::NonZeroU32, sync::atomic::Ordering};
59+
use std::{fmt, hash::Hash, mem, num::NonZeroU32, sync::atomic::Ordering};
6060

6161
#[cfg(target_has_atomic = "64")]
6262
use std::sync::atomic::AtomicI64 as AtomicIdCursor;

crates/bevy_ecs/src/query/iter.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl<'w, 's, D: QueryData, F: QueryFilter> QueryIter<'w, 's, D, F> {
4949
/// - `table` must match D and F
5050
/// - Both `D::IS_DENSE` and `F::IS_DENSE` must be true.
5151
#[inline]
52-
#[cfg(all(not(target = "wasm32"), feature = "multi-threaded"))]
52+
#[cfg(all(not(target_arch = "wasm32"), feature = "multi-threaded"))]
5353
pub(super) unsafe fn for_each_in_table_range<Func>(
5454
&mut self,
5555
func: &mut Func,
@@ -73,7 +73,7 @@ impl<'w, 's, D: QueryData, F: QueryFilter> QueryIter<'w, 's, D, F> {
7373
/// - `archetype` must match D and F
7474
/// - Either `D::IS_DENSE` or `F::IS_DENSE` must be false.
7575
#[inline]
76-
#[cfg(all(not(target = "wasm32"), feature = "multi-threaded"))]
76+
#[cfg(all(not(target_arch = "wasm32"), feature = "multi-threaded"))]
7777
pub(super) unsafe fn for_each_in_archetype_range<Func>(
7878
&mut self,
7979
func: &mut Func,

crates/bevy_ecs/src/query/par_iter.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ impl<'w, 's, D: QueryData, F: QueryFilter> QueryParIter<'w, 's, D, F> {
109109
/// [`ComputeTaskPool`]: bevy_tasks::ComputeTaskPool
110110
#[inline]
111111
pub fn for_each<FN: Fn(QueryItem<'w, D>) + Send + Sync + Clone>(self, func: FN) {
112-
#[cfg(any(target = "wasm32", not(feature = "multi-threaded")))]
112+
#[cfg(any(target_arch = "wasm32", not(feature = "multi-threaded")))]
113113
{
114114
// SAFETY:
115115
// This method can only be called once per instance of QueryParIter,
@@ -123,7 +123,7 @@ impl<'w, 's, D: QueryData, F: QueryFilter> QueryParIter<'w, 's, D, F> {
123123
.for_each(func);
124124
}
125125
}
126-
#[cfg(all(not(target = "wasm32"), feature = "multi-threaded"))]
126+
#[cfg(all(not(target_arch = "wasm32"), feature = "multi-threaded"))]
127127
{
128128
let thread_count = bevy_tasks::ComputeTaskPool::get().thread_num();
129129
if thread_count <= 1 {
@@ -150,7 +150,7 @@ impl<'w, 's, D: QueryData, F: QueryFilter> QueryParIter<'w, 's, D, F> {
150150
}
151151
}
152152

153-
#[cfg(all(not(target = "wasm32"), feature = "multi-threaded"))]
153+
#[cfg(all(not(target_arch = "wasm32"), feature = "multi-threaded"))]
154154
fn get_batch_size(&self, thread_count: usize) -> usize {
155155
if self.batching_strategy.batch_size_limits.is_empty() {
156156
return self.batching_strategy.batch_size_limits.start;

crates/bevy_ecs/src/query/state.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1117,7 +1117,7 @@ impl<D: QueryData, F: QueryFilter> QueryState<D, F> {
11171117
/// with a mismatched [`WorldId`] is unsound.
11181118
///
11191119
/// [`ComputeTaskPool`]: bevy_tasks::ComputeTaskPool
1120-
#[cfg(all(not(target = "wasm32"), feature = "multi-threaded"))]
1120+
#[cfg(all(not(target_arch = "wasm32"), feature = "multi-threaded"))]
11211121
pub(crate) unsafe fn par_for_each_unchecked_manual<
11221122
'w,
11231123
FN: Fn(D::Item<'w>) + Send + Sync + Clone,

crates/bevy_ecs/src/schedule/schedule.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use std::{
22
collections::BTreeSet,
33
fmt::{Debug, Write},
4-
result::Result,
54
};
65

76
#[cfg(feature = "trace")]

crates/bevy_pbr/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ keywords = ["bevy"]
1212
webgl = []
1313
webgpu = []
1414
pbr_transmission_textures = []
15+
shader_format_glsl = ["bevy_render/shader_format_glsl"]
16+
trace = ["bevy_render/trace"]
17+
ios_simulator = ["bevy_render/ios_simulator"]
1518

1619
[dependencies]
1720
# bevy

crates/bevy_pbr/src/fog.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use crate::ReflectComponent;
21
use bevy_ecs::prelude::*;
32
use bevy_math::Vec3;
43
use bevy_reflect::{std_traits::ReflectDefault, Reflect};

crates/bevy_pbr/src/light.rs

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use bevy_math::{
88
use bevy_reflect::prelude::*;
99
use bevy_render::{
1010
camera::{Camera, CameraProjection},
11-
color::LegacyColor,
1211
extract_component::ExtractComponent,
1312
extract_resource::ExtractResource,
1413
primitives::{Aabb, CascadesFrusta, CubemapFrusta, Frustum, HalfSpace, Sphere},

crates/bevy_pbr/src/material.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use crate::*;
2-
use bevy_app::{App, Plugin};
3-
use bevy_asset::{Asset, AssetApp, AssetEvent, AssetId, AssetServer, Assets, Handle};
2+
use bevy_asset::{Asset, AssetEvent, AssetId, AssetServer};
43
use bevy_core_pipeline::{
54
core_3d::{
65
AlphaMask3d, Camera3d, Opaque3d, ScreenSpaceTransmissionQuality, Transmissive3d,
@@ -16,19 +15,17 @@ use bevy_ecs::{
1615
};
1716
use bevy_reflect::Reflect;
1817
use bevy_render::{
19-
camera::Projection,
2018
camera::TemporalJitter,
2119
extract_instances::{ExtractInstancesPlugin, ExtractedInstances},
2220
extract_resource::ExtractResource,
2321
mesh::{Mesh, MeshVertexBufferLayout},
24-
prelude::Image,
25-
render_asset::{prepare_assets, RenderAssets},
22+
render_asset::RenderAssets,
2623
render_phase::*,
2724
render_resource::*,
2825
renderer::RenderDevice,
2926
texture::FallbackImage,
3027
view::{ExtractedView, Msaa, VisibleEntities},
31-
Extract, ExtractSchedule, Render, RenderApp, RenderSet,
28+
Extract,
3229
};
3330
use bevy_utils::{tracing::error, HashMap, HashSet};
3431
use std::marker::PhantomData;

crates/bevy_pbr/src/pbr_material.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
use bevy_asset::{Asset, Handle};
1+
use bevy_asset::Asset;
22
use bevy_math::{Affine2, Vec2, Vec4};
33
use bevy_reflect::{std_traits::ReflectDefault, Reflect};
4-
use bevy_render::{
5-
color::LegacyColor, mesh::MeshVertexBufferLayout, render_asset::RenderAssets,
6-
render_resource::*, texture::Image,
7-
};
4+
use bevy_render::{mesh::MeshVertexBufferLayout, render_asset::RenderAssets, render_resource::*};
85

96
use crate::deferred::DEFAULT_PBR_DEFERRED_LIGHTING_PASS_ID;
107
use crate::*;

crates/bevy_pbr/src/prepass/mod.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ mod prepass_bindings;
33
use bevy_render::render_resource::binding_types::uniform_buffer;
44
pub use prepass_bindings::*;
55

6-
use bevy_app::{Plugin, PreUpdate};
7-
use bevy_asset::{load_internal_asset, AssetServer, Handle};
6+
use bevy_asset::{load_internal_asset, AssetServer};
87
use bevy_core_pipeline::{core_3d::CORE_3D_DEPTH_FORMAT, prelude::Camera3d};
98
use bevy_core_pipeline::{deferred::*, prepass::*};
109
use bevy_ecs::{
@@ -25,7 +24,7 @@ use bevy_render::{
2524
render_resource::*,
2625
renderer::{RenderDevice, RenderQueue},
2726
view::{ExtractedView, Msaa, ViewUniform, ViewUniformOffset, ViewUniforms, VisibleEntities},
28-
Extract, ExtractSchedule, Render, RenderApp, RenderSet,
27+
Extract,
2928
};
3029
use bevy_transform::prelude::GlobalTransform;
3130
use bevy_utils::tracing::error;

crates/bevy_pbr/src/render/light.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use bevy_ecs::prelude::*;
44
use bevy_math::{Mat4, UVec3, UVec4, Vec2, Vec3, Vec3Swizzles, Vec4, Vec4Swizzles};
55
use bevy_render::{
66
camera::Camera,
7-
color::LegacyColor,
87
mesh::Mesh,
98
primitives::{CascadesFrusta, CubemapFrusta, Frustum},
109
render_asset::RenderAssets,
@@ -1213,7 +1212,7 @@ pub fn prepare_lights(
12131212
// NOTE: iOS Simulator is missing CubeArray support so we use Cube instead.
12141213
// See https://github.com/bevyengine/bevy/pull/12052 - remove if support is added.
12151214
#[cfg(all(
1216-
not(ios_simulator),
1215+
not(feature = "ios_simulator"),
12171216
any(
12181217
not(feature = "webgl"),
12191218
not(target_arch = "wasm32"),
@@ -1222,7 +1221,7 @@ pub fn prepare_lights(
12221221
))]
12231222
dimension: Some(TextureViewDimension::CubeArray),
12241223
#[cfg(any(
1225-
ios_simulator,
1224+
feature = "ios_simulator",
12261225
all(feature = "webgl", target_arch = "wasm32", not(feature = "webgpu"))
12271226
))]
12281227
dimension: Some(TextureViewDimension::Cube),

crates/bevy_pbr/src/render/mesh.rs

+4-14
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
use crate::{
2-
AtomicMaterialBindGroupId, MaterialBindGroupId, NotShadowCaster, NotShadowReceiver,
3-
PreviousGlobalTransform, Shadow, ViewFogUniformOffset, ViewLightProbesUniformOffset,
4-
ViewLightsUniformOffset, CLUSTERED_FORWARD_STORAGE_BUFFER_COUNT, MAX_CASCADES_PER_LIGHT,
5-
MAX_DIRECTIONAL_LIGHTS,
6-
};
7-
use bevy_app::{Plugin, PostUpdate};
8-
use bevy_asset::{load_internal_asset, AssetId, Handle};
1+
use bevy_asset::{load_internal_asset, AssetId};
92
use bevy_core_pipeline::{
103
core_3d::{AlphaMask3d, Opaque3d, Transmissive3d, Transparent3d, CORE_3D_DEPTH_FORMAT},
114
deferred::{AlphaMask3dDeferred, Opaque3dDeferred},
@@ -28,11 +21,9 @@ use bevy_render::{
2821
render_phase::{PhaseItem, RenderCommand, RenderCommandResult, TrackedRenderPass},
2922
render_resource::*,
3023
renderer::{RenderDevice, RenderQueue},
31-
texture::{
32-
BevyDefault, DefaultImageSampler, GpuImage, Image, ImageSampler, TextureFormatPixelInfo,
33-
},
24+
texture::{BevyDefault, DefaultImageSampler, GpuImage, ImageSampler, TextureFormatPixelInfo},
3425
view::{ViewTarget, ViewUniformOffset, ViewVisibility},
35-
Extract, ExtractSchedule, Render, RenderApp, RenderSet,
26+
Extract,
3627
};
3728
use bevy_transform::components::GlobalTransform;
3829
use bevy_utils::{tracing::error, Entry, HashMap, Hashed};
@@ -46,8 +37,7 @@ use crate::render::{
4637
morph::{
4738
extract_morphs, no_automatic_morph_batching, prepare_morphs, MorphIndices, MorphUniform,
4839
},
49-
skin::{extract_skins, no_automatic_skin_batching, prepare_skins, SkinUniform},
50-
MeshLayouts,
40+
skin::no_automatic_skin_batching,
5141
};
5242
use crate::*;
5343

crates/bevy_pbr/src/render/mesh_view_bindings.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,6 @@ use bevy_render::{
2323

2424
#[cfg(all(feature = "webgl", target_arch = "wasm32", not(feature = "webgpu")))]
2525
use bevy_render::render_resource::binding_types::texture_cube;
26-
#[cfg(any(
27-
not(feature = "webgl"),
28-
not(target_arch = "wasm32"),
29-
feature = "webgpu"
30-
))]
31-
use bevy_render::render_resource::binding_types::{texture_2d_array, texture_cube_array};
3226
use environment_map::EnvironmentMapLight;
3327

3428
use crate::{
@@ -192,7 +186,7 @@ fn layout_entries(
192186
(
193187
2,
194188
#[cfg(all(
195-
not(ios_simulator),
189+
not(feature = "ios_simulator"),
196190
any(
197191
not(feature = "webgl"),
198192
not(target_arch = "wasm32"),
@@ -201,7 +195,7 @@ fn layout_entries(
201195
))]
202196
texture_cube_array(TextureSampleType::Depth),
203197
#[cfg(any(
204-
ios_simulator,
198+
feature = "ios_simulator",
205199
all(feature = "webgl", target_arch = "wasm32", not(feature = "webgpu"))
206200
))]
207201
texture_cube(TextureSampleType::Depth),

crates/bevy_pbr/src/wireframe.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@ use bevy_asset::{load_internal_asset, Asset, Assets, Handle};
44
use bevy_ecs::prelude::*;
55
use bevy_reflect::{std_traits::ReflectDefault, Reflect, TypePath};
66
use bevy_render::{
7-
color::LegacyColor,
8-
extract_resource::ExtractResource,
9-
mesh::{Mesh, MeshVertexBufferLayout},
10-
prelude::*,
11-
render_resource::*,
7+
extract_resource::ExtractResource, mesh::MeshVertexBufferLayout, prelude::*, render_resource::*,
128
};
139

1410
pub const WIREFRAME_SHADER_HANDLE: Handle<Shader> = Handle::weak_from_u128(192598014480025766);

0 commit comments

Comments
 (0)