Add clippy::manual_let_else at warn level to lints (#10684)
# Objective Related to #10612. Enable the [`clippy::manual_let_else`](https://rust-lang.github.io/rust-clippy/master/#manual_let_else) lint as a warning. The `let else` form seems more idiomatic to me than a `match`/`if else` that either match a pattern or diverge, and from the clippy doc, the lint doesn't seem to have any possible false positive. ## Solution Add the lint as warning in `Cargo.toml`, refactor places where the lint triggers.
This commit is contained in:
parent
3c2cbb88bc
commit
0e9f6e92ea
@ -32,6 +32,7 @@ members = [
|
|||||||
[workspace.lints.clippy]
|
[workspace.lints.clippy]
|
||||||
type_complexity = "allow"
|
type_complexity = "allow"
|
||||||
doc_markdown = "warn"
|
doc_markdown = "warn"
|
||||||
|
manual_let_else = "warn"
|
||||||
undocumented_unsafe_blocks = "warn"
|
undocumented_unsafe_blocks = "warn"
|
||||||
redundant_else = "warn"
|
redundant_else = "warn"
|
||||||
match_same_arms = "warn"
|
match_same_arms = "warn"
|
||||||
|
|||||||
@ -268,13 +268,12 @@ mod tests {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let handle = reflect_asset.add(&mut app.world, &value);
|
let handle = reflect_asset.add(&mut app.world, &value);
|
||||||
let strukt = match reflect_asset
|
let ReflectMut::Struct(strukt) = reflect_asset
|
||||||
.get_mut(&mut app.world, handle)
|
.get_mut(&mut app.world, handle)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.reflect_mut()
|
.reflect_mut()
|
||||||
{
|
else {
|
||||||
ReflectMut::Struct(s) => s,
|
unreachable!();
|
||||||
_ => unreachable!(),
|
|
||||||
};
|
};
|
||||||
strukt
|
strukt
|
||||||
.field_mut("field")
|
.field_mut("field")
|
||||||
|
|||||||
@ -55,9 +55,8 @@ impl Plugin for BloomPlugin {
|
|||||||
UniformComponentPlugin::<BloomUniforms>::default(),
|
UniformComponentPlugin::<BloomUniforms>::default(),
|
||||||
));
|
));
|
||||||
|
|
||||||
let render_app = match app.get_sub_app_mut(RenderApp) {
|
let Ok(render_app) = app.get_sub_app_mut(RenderApp) else {
|
||||||
Ok(render_app) => render_app,
|
return;
|
||||||
Err(_) => return,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
render_app
|
render_app
|
||||||
@ -101,9 +100,8 @@ impl Plugin for BloomPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn finish(&self, app: &mut App) {
|
fn finish(&self, app: &mut App) {
|
||||||
let render_app = match app.get_sub_app_mut(RenderApp) {
|
let Ok(render_app) = app.get_sub_app_mut(RenderApp) else {
|
||||||
Ok(render_app) => render_app,
|
return;
|
||||||
Err(_) => return,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
render_app
|
render_app
|
||||||
|
|||||||
@ -116,9 +116,8 @@ impl Plugin for CASPlugin {
|
|||||||
UniformComponentPlugin::<CASUniform>::default(),
|
UniformComponentPlugin::<CASUniform>::default(),
|
||||||
));
|
));
|
||||||
|
|
||||||
let render_app = match app.get_sub_app_mut(RenderApp) {
|
let Ok(render_app) = app.get_sub_app_mut(RenderApp) else {
|
||||||
Ok(render_app) => render_app,
|
return;
|
||||||
Err(_) => return,
|
|
||||||
};
|
};
|
||||||
render_app
|
render_app
|
||||||
.init_resource::<SpecializedRenderPipelines<CASPipeline>>()
|
.init_resource::<SpecializedRenderPipelines<CASPipeline>>()
|
||||||
@ -155,9 +154,8 @@ impl Plugin for CASPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn finish(&self, app: &mut App) {
|
fn finish(&self, app: &mut App) {
|
||||||
let render_app = match app.get_sub_app_mut(RenderApp) {
|
let Ok(render_app) = app.get_sub_app_mut(RenderApp) else {
|
||||||
Ok(render_app) => render_app,
|
return;
|
||||||
Err(_) => return,
|
|
||||||
};
|
};
|
||||||
render_app.init_resource::<CASPipeline>();
|
render_app.init_resource::<CASPipeline>();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -46,13 +46,12 @@ impl Node for MainPass2dNode {
|
|||||||
world: &World,
|
world: &World,
|
||||||
) -> Result<(), NodeRunError> {
|
) -> Result<(), NodeRunError> {
|
||||||
let view_entity = graph.view_entity();
|
let view_entity = graph.view_entity();
|
||||||
let (camera, transparent_phase, target, camera_2d) =
|
let Ok((camera, transparent_phase, target, camera_2d)) =
|
||||||
if let Ok(result) = self.query.get_manual(world, view_entity) {
|
self.query.get_manual(world, view_entity)
|
||||||
result
|
else {
|
||||||
} else {
|
// no target
|
||||||
// no target
|
return Ok(());
|
||||||
return Ok(());
|
};
|
||||||
};
|
|
||||||
{
|
{
|
||||||
#[cfg(feature = "trace")]
|
#[cfg(feature = "trace")]
|
||||||
let _main_pass_2d = info_span!("main_pass_2d").entered();
|
let _main_pass_2d = info_span!("main_pass_2d").entered();
|
||||||
|
|||||||
@ -48,9 +48,8 @@ impl Plugin for Core2dPlugin {
|
|||||||
app.register_type::<Camera2d>()
|
app.register_type::<Camera2d>()
|
||||||
.add_plugins(ExtractComponentPlugin::<Camera2d>::default());
|
.add_plugins(ExtractComponentPlugin::<Camera2d>::default());
|
||||||
|
|
||||||
let render_app = match app.get_sub_app_mut(RenderApp) {
|
let Ok(render_app) = app.get_sub_app_mut(RenderApp) else {
|
||||||
Ok(render_app) => render_app,
|
return;
|
||||||
Err(_) => return,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
render_app
|
render_app
|
||||||
|
|||||||
@ -86,9 +86,8 @@ impl Plugin for Core3dPlugin {
|
|||||||
.add_plugins((SkyboxPlugin, ExtractComponentPlugin::<Camera3d>::default()))
|
.add_plugins((SkyboxPlugin, ExtractComponentPlugin::<Camera3d>::default()))
|
||||||
.add_systems(PostUpdate, check_msaa);
|
.add_systems(PostUpdate, check_msaa);
|
||||||
|
|
||||||
let render_app = match app.get_sub_app_mut(RenderApp) {
|
let Ok(render_app) = app.get_sub_app_mut(RenderApp) else {
|
||||||
Ok(render_app) => render_app,
|
return;
|
||||||
Err(_) => return,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
render_app
|
render_app
|
||||||
|
|||||||
@ -89,9 +89,8 @@ impl Plugin for FxaaPlugin {
|
|||||||
app.register_type::<Fxaa>();
|
app.register_type::<Fxaa>();
|
||||||
app.add_plugins(ExtractComponentPlugin::<Fxaa>::default());
|
app.add_plugins(ExtractComponentPlugin::<Fxaa>::default());
|
||||||
|
|
||||||
let render_app = match app.get_sub_app_mut(RenderApp) {
|
let Ok(render_app) = app.get_sub_app_mut(RenderApp) else {
|
||||||
Ok(render_app) => render_app,
|
return;
|
||||||
Err(_) => return,
|
|
||||||
};
|
};
|
||||||
render_app
|
render_app
|
||||||
.init_resource::<SpecializedRenderPipelines<FxaaPipeline>>()
|
.init_resource::<SpecializedRenderPipelines<FxaaPipeline>>()
|
||||||
@ -117,9 +116,8 @@ impl Plugin for FxaaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn finish(&self, app: &mut App) {
|
fn finish(&self, app: &mut App) {
|
||||||
let render_app = match app.get_sub_app_mut(RenderApp) {
|
let Ok(render_app) = app.get_sub_app_mut(RenderApp) else {
|
||||||
Ok(render_app) => render_app,
|
return;
|
||||||
Err(_) => return,
|
|
||||||
};
|
};
|
||||||
render_app.init_resource::<FxaaPipeline>();
|
render_app.init_resource::<FxaaPipeline>();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,9 +36,8 @@ impl Plugin for SkyboxPlugin {
|
|||||||
|
|
||||||
app.add_plugins(ExtractComponentPlugin::<Skybox>::default());
|
app.add_plugins(ExtractComponentPlugin::<Skybox>::default());
|
||||||
|
|
||||||
let render_app = match app.get_sub_app_mut(RenderApp) {
|
let Ok(render_app) = app.get_sub_app_mut(RenderApp) else {
|
||||||
Ok(render_app) => render_app,
|
return;
|
||||||
Err(_) => return,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
render_app
|
render_app
|
||||||
@ -53,9 +52,8 @@ impl Plugin for SkyboxPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn finish(&self, app: &mut App) {
|
fn finish(&self, app: &mut App) {
|
||||||
let render_app = match app.get_sub_app_mut(RenderApp) {
|
let Ok(render_app) = app.get_sub_app_mut(RenderApp) else {
|
||||||
Ok(render_app) => render_app,
|
return;
|
||||||
Err(_) => return,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let render_device = render_app.world.resource::<RenderDevice>().clone();
|
let render_device = render_app.world.resource::<RenderDevice>().clone();
|
||||||
|
|||||||
@ -51,9 +51,8 @@ impl ViewNode for TonemappingNode {
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
let pipeline = match pipeline_cache.get_render_pipeline(view_tonemapping_pipeline.0) {
|
let Some(pipeline) = pipeline_cache.get_render_pipeline(view_tonemapping_pipeline.0) else {
|
||||||
Some(pipeline) => pipeline,
|
return Ok(());
|
||||||
None => return Ok(()),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let post_process = target.post_process_write();
|
let post_process = target.post_process_write();
|
||||||
|
|||||||
@ -67,9 +67,8 @@ impl ViewNode for UpscalingNode {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let pipeline = match pipeline_cache.get_render_pipeline(upscaling_target.0) {
|
let Some(pipeline) = pipeline_cache.get_render_pipeline(upscaling_target.0) else {
|
||||||
Some(pipeline) => pipeline,
|
return Ok(());
|
||||||
None => return Ok(()),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let pass_descriptor = RenderPassDescriptor {
|
let pass_descriptor = RenderPassDescriptor {
|
||||||
|
|||||||
@ -124,9 +124,8 @@ where
|
|||||||
unsafe fn fetch_next_aliased_unchecked(&mut self) -> Option<Q::Item<'w>> {
|
unsafe fn fetch_next_aliased_unchecked(&mut self) -> Option<Q::Item<'w>> {
|
||||||
for entity in self.entity_iter.by_ref() {
|
for entity in self.entity_iter.by_ref() {
|
||||||
let entity = *entity.borrow();
|
let entity = *entity.borrow();
|
||||||
let location = match self.entities.get(entity) {
|
let Some(location) = self.entities.get(entity) else {
|
||||||
Some(location) => location,
|
continue;
|
||||||
None => continue,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if !self
|
if !self
|
||||||
|
|||||||
@ -656,9 +656,8 @@ impl<'w> UnsafeEntityCell<'w> {
|
|||||||
/// - If you have a [`ComponentId`] instead of a [`TypeId`], consider using [`Self::contains_id`].
|
/// - If you have a [`ComponentId`] instead of a [`TypeId`], consider using [`Self::contains_id`].
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn contains_type_id(self, type_id: TypeId) -> bool {
|
pub fn contains_type_id(self, type_id: TypeId) -> bool {
|
||||||
let id = match self.world.components().get_id(type_id) {
|
let Some(id) = self.world.components().get_id(type_id) else {
|
||||||
Some(id) => id,
|
return false;
|
||||||
None => return false,
|
|
||||||
};
|
};
|
||||||
self.contains_id(id)
|
self.contains_id(id)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -329,9 +329,8 @@ impl Plugin for PbrPlugin {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
let render_app = match app.get_sub_app_mut(RenderApp) {
|
let Ok(render_app) = app.get_sub_app_mut(RenderApp) else {
|
||||||
Ok(render_app) => render_app,
|
return;
|
||||||
Err(_) => return,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Extract the required data from the main world
|
// Extract the required data from the main world
|
||||||
@ -365,9 +364,8 @@ impl Plugin for PbrPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn finish(&self, app: &mut App) {
|
fn finish(&self, app: &mut App) {
|
||||||
let render_app = match app.get_sub_app_mut(RenderApp) {
|
let Ok(render_app) = app.get_sub_app_mut(RenderApp) else {
|
||||||
Ok(render_app) => render_app,
|
return;
|
||||||
Err(_) => return,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Extract the required data from the main world
|
// Extract the required data from the main world
|
||||||
|
|||||||
@ -1203,9 +1203,8 @@ pub(crate) fn assign_lights_to_clusters(
|
|||||||
mut max_point_lights_warning_emitted: Local<bool>,
|
mut max_point_lights_warning_emitted: Local<bool>,
|
||||||
render_device: Option<Res<RenderDevice>>,
|
render_device: Option<Res<RenderDevice>>,
|
||||||
) {
|
) {
|
||||||
let render_device = match render_device {
|
let Some(render_device) = render_device else {
|
||||||
Some(render_device) => render_device,
|
return;
|
||||||
None => return,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
global_lights.entities.clear();
|
global_lights.entities.clear();
|
||||||
|
|||||||
@ -8,6 +8,8 @@ use uuid::Uuid;
|
|||||||
|
|
||||||
pub(crate) fn type_uuid_derive(input: DeriveInput) -> syn::Result<TokenStream> {
|
pub(crate) fn type_uuid_derive(input: DeriveInput) -> syn::Result<TokenStream> {
|
||||||
let mut uuid = None;
|
let mut uuid = None;
|
||||||
|
|
||||||
|
#[allow(clippy::manual_let_else)]
|
||||||
for attribute in input
|
for attribute in input
|
||||||
.attrs
|
.attrs
|
||||||
.iter()
|
.iter()
|
||||||
|
|||||||
@ -449,9 +449,8 @@ impl Mesh {
|
|||||||
indices.map(|i| values[i]).collect()
|
indices.map(|i| values[i]).collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
let indices = match self.indices.take() {
|
let Some(indices) = self.indices.take() else {
|
||||||
Some(indices) => indices,
|
return;
|
||||||
None => return,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
for attributes in self.attributes.values_mut() {
|
for attributes in self.attributes.values_mut() {
|
||||||
@ -1173,38 +1172,32 @@ fn generate_tangents_for_mesh(mesh: &Mesh) -> Result<Vec<[f32; 4]>, GenerateTang
|
|||||||
other => return Err(GenerateTangentsError::UnsupportedTopology(other)),
|
other => return Err(GenerateTangentsError::UnsupportedTopology(other)),
|
||||||
};
|
};
|
||||||
|
|
||||||
let positions = match mesh.attribute(Mesh::ATTRIBUTE_POSITION).ok_or(
|
let positions = mesh.attribute(Mesh::ATTRIBUTE_POSITION).ok_or(
|
||||||
GenerateTangentsError::MissingVertexAttribute(Mesh::ATTRIBUTE_POSITION.name),
|
GenerateTangentsError::MissingVertexAttribute(Mesh::ATTRIBUTE_POSITION.name),
|
||||||
)? {
|
)?;
|
||||||
VertexAttributeValues::Float32x3(vertices) => vertices,
|
let VertexAttributeValues::Float32x3(positions) = positions else {
|
||||||
_ => {
|
return Err(GenerateTangentsError::InvalidVertexAttributeFormat(
|
||||||
return Err(GenerateTangentsError::InvalidVertexAttributeFormat(
|
Mesh::ATTRIBUTE_POSITION.name,
|
||||||
Mesh::ATTRIBUTE_POSITION.name,
|
VertexFormat::Float32x3,
|
||||||
VertexFormat::Float32x3,
|
));
|
||||||
))
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
let normals = match mesh.attribute(Mesh::ATTRIBUTE_NORMAL).ok_or(
|
let normals = mesh.attribute(Mesh::ATTRIBUTE_NORMAL).ok_or(
|
||||||
GenerateTangentsError::MissingVertexAttribute(Mesh::ATTRIBUTE_NORMAL.name),
|
GenerateTangentsError::MissingVertexAttribute(Mesh::ATTRIBUTE_NORMAL.name),
|
||||||
)? {
|
)?;
|
||||||
VertexAttributeValues::Float32x3(vertices) => vertices,
|
let VertexAttributeValues::Float32x3(normals) = normals else {
|
||||||
_ => {
|
return Err(GenerateTangentsError::InvalidVertexAttributeFormat(
|
||||||
return Err(GenerateTangentsError::InvalidVertexAttributeFormat(
|
Mesh::ATTRIBUTE_NORMAL.name,
|
||||||
Mesh::ATTRIBUTE_NORMAL.name,
|
VertexFormat::Float32x3,
|
||||||
VertexFormat::Float32x3,
|
));
|
||||||
))
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
let uvs = match mesh.attribute(Mesh::ATTRIBUTE_UV_0).ok_or(
|
let uvs = mesh.attribute(Mesh::ATTRIBUTE_UV_0).ok_or(
|
||||||
GenerateTangentsError::MissingVertexAttribute(Mesh::ATTRIBUTE_UV_0.name),
|
GenerateTangentsError::MissingVertexAttribute(Mesh::ATTRIBUTE_UV_0.name),
|
||||||
)? {
|
)?;
|
||||||
VertexAttributeValues::Float32x2(vertices) => vertices,
|
let VertexAttributeValues::Float32x2(uvs) = uvs else {
|
||||||
_ => {
|
return Err(GenerateTangentsError::InvalidVertexAttributeFormat(
|
||||||
return Err(GenerateTangentsError::InvalidVertexAttributeFormat(
|
Mesh::ATTRIBUTE_UV_0.name,
|
||||||
Mesh::ATTRIBUTE_UV_0.name,
|
VertexFormat::Float32x2,
|
||||||
VertexFormat::Float32x2,
|
));
|
||||||
))
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let len = positions.len();
|
let len = positions.len();
|
||||||
|
|||||||
@ -195,9 +195,8 @@ impl Plugin for UiPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn finish(&self, app: &mut App) {
|
fn finish(&self, app: &mut App) {
|
||||||
let render_app = match app.get_sub_app_mut(RenderApp) {
|
let Ok(render_app) = app.get_sub_app_mut(RenderApp) else {
|
||||||
Ok(render_app) => render_app,
|
return;
|
||||||
Err(_) => return,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
render_app.init_resource::<UiPipeline>();
|
render_app.init_resource::<UiPipeline>();
|
||||||
|
|||||||
@ -65,9 +65,8 @@ pub enum RenderUiSystem {
|
|||||||
pub fn build_ui_render(app: &mut App) {
|
pub fn build_ui_render(app: &mut App) {
|
||||||
load_internal_asset!(app, UI_SHADER_HANDLE, "ui.wgsl", Shader::from_wgsl);
|
load_internal_asset!(app, UI_SHADER_HANDLE, "ui.wgsl", Shader::from_wgsl);
|
||||||
|
|
||||||
let render_app = match app.get_sub_app_mut(RenderApp) {
|
let Ok(render_app) = app.get_sub_app_mut(RenderApp) else {
|
||||||
Ok(render_app) => render_app,
|
return;
|
||||||
Err(_) => return,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
render_app
|
render_app
|
||||||
|
|||||||
@ -259,9 +259,8 @@ impl<P: PhaseItem> RenderCommand<P> for DrawMeshInstanced {
|
|||||||
let Some(mesh_instance) = render_mesh_instances.get(&item.entity()) else {
|
let Some(mesh_instance) = render_mesh_instances.get(&item.entity()) else {
|
||||||
return RenderCommandResult::Failure;
|
return RenderCommandResult::Failure;
|
||||||
};
|
};
|
||||||
let gpu_mesh = match meshes.into_inner().get(mesh_instance.mesh_asset_id) {
|
let Some(gpu_mesh) = meshes.into_inner().get(mesh_instance.mesh_asset_id) else {
|
||||||
Some(gpu_mesh) => gpu_mesh,
|
return RenderCommandResult::Failure;
|
||||||
None => return RenderCommandResult::Failure,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pass.set_vertex_buffer(0, gpu_mesh.vertex_buffer.slice(..));
|
pass.set_vertex_buffer(0, gpu_mesh.vertex_buffer.slice(..));
|
||||||
|
|||||||
@ -153,9 +153,8 @@ struct LogVisibleLights;
|
|||||||
|
|
||||||
impl Plugin for LogVisibleLights {
|
impl Plugin for LogVisibleLights {
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
let render_app = match app.get_sub_app_mut(RenderApp) {
|
let Ok(render_app) = app.get_sub_app_mut(RenderApp) else {
|
||||||
Ok(render_app) => render_app,
|
return;
|
||||||
Err(_) => return,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
render_app.add_systems(Render, print_visible_light_count.in_set(RenderSet::Prepare));
|
render_app.add_systems(Render, print_visible_light_count.in_set(RenderSet::Prepare));
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user