From 3ead10a3e0ab1c23d8e4b6cc9fa8be1eef8c581f Mon Sep 17 00:00:00 2001 From: JoJoJet <21144246+JoJoJet@users.noreply.github.com> Date: Thu, 6 Apr 2023 17:27:36 -0400 Subject: [PATCH] Suppress the `clippy::type_complexity` lint (#8313) # Objective The clippy lint `type_complexity` is known not to play well with bevy. It frequently triggers when writing complex queries, and taking the lint's advice of using a type alias almost always just obfuscates the code with no benefit. Because of this, this lint is currently ignored in CI, but unfortunately it still shows up when viewing bevy code in an IDE. As someone who's made a fair amount of pull requests to this repo, I will say that this issue has been a consistent thorn in my side. Since bevy code is filled with spurious, ignorable warnings, it can be very difficult to spot the *real* warnings that must be fixed -- most of the time I just ignore all warnings, only to later find out that one of them was real after I'm done when CI runs. ## Solution Suppress this lint in all bevy crates. This was previously attempted in #7050, but the review process ended up making it more complicated than it needs to be and landed on a subpar solution. The discussion in https://github.com/rust-lang/rust-clippy/pull/10571 explores some better long-term solutions to this problem. Since there is no timeline on when these solutions may land, we should resolve this issue in the meantime by locally suppressing these lints. ### Unresolved issues Currently, these lints are not suppressed in our examples, since that would require suppressing the lint in every single source file. They are still ignored in CI. --- crates/bevy_a11y/src/lib.rs | 1 + crates/bevy_animation/src/lib.rs | 1 + crates/bevy_app/src/lib.rs | 1 + crates/bevy_asset/src/lib.rs | 1 + crates/bevy_audio/src/lib.rs | 1 + crates/bevy_core/src/lib.rs | 1 + crates/bevy_core_pipeline/src/lib.rs | 2 ++ crates/bevy_derive/src/lib.rs | 2 ++ crates/bevy_diagnostic/src/lib.rs | 2 ++ crates/bevy_dylib/src/lib.rs | 1 + crates/bevy_dynamic_plugin/src/lib.rs | 2 ++ crates/bevy_ecs/src/lib.rs | 1 + crates/bevy_ecs_compile_fail_tests/src/lib.rs | 2 ++ crates/bevy_encase_derive/src/lib.rs | 2 ++ crates/bevy_gilrs/src/lib.rs | 2 ++ crates/bevy_gizmos/src/lib.rs | 1 + crates/bevy_gltf/src/lib.rs | 2 ++ crates/bevy_hierarchy/src/lib.rs | 1 + crates/bevy_input/src/lib.rs | 2 ++ crates/bevy_internal/src/lib.rs | 1 + crates/bevy_log/src/lib.rs | 1 + crates/bevy_macro_utils/src/lib.rs | 2 ++ crates/bevy_math/src/lib.rs | 1 + crates/bevy_mikktspace/src/lib.rs | 1 + crates/bevy_pbr/src/lib.rs | 2 ++ crates/bevy_ptr/src/lib.rs | 1 + crates/bevy_reflect/src/lib.rs | 1 + crates/bevy_render/src/lib.rs | 2 ++ crates/bevy_scene/src/lib.rs | 2 ++ crates/bevy_sprite/src/lib.rs | 2 ++ crates/bevy_tasks/src/lib.rs | 1 + crates/bevy_text/src/lib.rs | 2 ++ crates/bevy_time/src/lib.rs | 2 ++ crates/bevy_transform/src/lib.rs | 1 + crates/bevy_ui/src/lib.rs | 2 ++ crates/bevy_utils/src/lib.rs | 3 ++- crates/bevy_window/src/lib.rs | 2 ++ crates/bevy_winit/src/lib.rs | 1 + 38 files changed, 57 insertions(+), 1 deletion(-) diff --git a/crates/bevy_a11y/src/lib.rs b/crates/bevy_a11y/src/lib.rs index ed91fe26e0..16808c17da 100644 --- a/crates/bevy_a11y/src/lib.rs +++ b/crates/bevy_a11y/src/lib.rs @@ -1,6 +1,7 @@ //! Accessibility for Bevy #![warn(missing_docs)] +#![allow(clippy::type_complexity)] #![forbid(unsafe_code)] use std::{ diff --git a/crates/bevy_animation/src/lib.rs b/crates/bevy_animation/src/lib.rs index 0e9534d63b..f4fcd3f7ed 100644 --- a/crates/bevy_animation/src/lib.rs +++ b/crates/bevy_animation/src/lib.rs @@ -1,6 +1,7 @@ //! Animation for the game engine Bevy #![warn(missing_docs)] +#![allow(clippy::type_complexity)] use std::ops::Deref; use std::time::Duration; diff --git a/crates/bevy_app/src/lib.rs b/crates/bevy_app/src/lib.rs index 8094d0458e..ee409da3d1 100644 --- a/crates/bevy_app/src/lib.rs +++ b/crates/bevy_app/src/lib.rs @@ -1,6 +1,7 @@ //! This crate is about everything concerning the highest-level, application layer of a Bevy app. #![warn(missing_docs)] +#![allow(clippy::type_complexity)] mod app; mod main_schedule; diff --git a/crates/bevy_asset/src/lib.rs b/crates/bevy_asset/src/lib.rs index 3265690165..412ecad3bc 100644 --- a/crates/bevy_asset/src/lib.rs +++ b/crates/bevy_asset/src/lib.rs @@ -9,6 +9,7 @@ //! [asset storage]: struct.Assets.html #![warn(missing_docs)] +#![allow(clippy::type_complexity)] mod asset_server; mod assets; diff --git a/crates/bevy_audio/src/lib.rs b/crates/bevy_audio/src/lib.rs index 468ff3d622..1ed3b97090 100644 --- a/crates/bevy_audio/src/lib.rs +++ b/crates/bevy_audio/src/lib.rs @@ -20,6 +20,7 @@ //! ``` #![forbid(unsafe_code)] +#![allow(clippy::type_complexity)] #![warn(missing_docs)] mod audio; diff --git a/crates/bevy_core/src/lib.rs b/crates/bevy_core/src/lib.rs index 6e829e26c9..53256befa3 100644 --- a/crates/bevy_core/src/lib.rs +++ b/crates/bevy_core/src/lib.rs @@ -1,4 +1,5 @@ #![warn(missing_docs)] +#![allow(clippy::type_complexity)] //! This crate provides core functionality for Bevy Engine. mod name; diff --git a/crates/bevy_core_pipeline/src/lib.rs b/crates/bevy_core_pipeline/src/lib.rs index d7771ef0c3..f169cdd89e 100644 --- a/crates/bevy_core_pipeline/src/lib.rs +++ b/crates/bevy_core_pipeline/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(clippy::type_complexity)] + pub mod blit; pub mod bloom; pub mod clear_color; diff --git a/crates/bevy_derive/src/lib.rs b/crates/bevy_derive/src/lib.rs index e2088cfe04..7b66edb491 100644 --- a/crates/bevy_derive/src/lib.rs +++ b/crates/bevy_derive/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(clippy::type_complexity)] + extern crate proc_macro; mod app_plugin; diff --git a/crates/bevy_diagnostic/src/lib.rs b/crates/bevy_diagnostic/src/lib.rs index 854f6e74cd..6c30c631a1 100644 --- a/crates/bevy_diagnostic/src/lib.rs +++ b/crates/bevy_diagnostic/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(clippy::type_complexity)] + mod diagnostic; mod entity_count_diagnostics_plugin; mod frame_time_diagnostics_plugin; diff --git a/crates/bevy_dylib/src/lib.rs b/crates/bevy_dylib/src/lib.rs index a950f985d6..2c5d642967 100644 --- a/crates/bevy_dylib/src/lib.rs +++ b/crates/bevy_dylib/src/lib.rs @@ -1,4 +1,5 @@ #![warn(missing_docs)] +#![allow(clippy::type_complexity)] #![allow(clippy::single_component_path_imports)] //! Forces dynamic linking of Bevy. diff --git a/crates/bevy_dynamic_plugin/src/lib.rs b/crates/bevy_dynamic_plugin/src/lib.rs index 4ff6f92606..ee59ff2cb1 100644 --- a/crates/bevy_dynamic_plugin/src/lib.rs +++ b/crates/bevy_dynamic_plugin/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(clippy::type_complexity)] + mod loader; pub use loader::*; diff --git a/crates/bevy_ecs/src/lib.rs b/crates/bevy_ecs/src/lib.rs index c8a4f3d325..a5967a73ab 100644 --- a/crates/bevy_ecs/src/lib.rs +++ b/crates/bevy_ecs/src/lib.rs @@ -1,4 +1,5 @@ #![warn(clippy::undocumented_unsafe_blocks)] +#![allow(clippy::type_complexity)] #![doc = include_str!("../README.md")] #[cfg(target_pointer_width = "16")] diff --git a/crates/bevy_ecs_compile_fail_tests/src/lib.rs b/crates/bevy_ecs_compile_fail_tests/src/lib.rs index d0d1683dd6..e12684f764 100644 --- a/crates/bevy_ecs_compile_fail_tests/src/lib.rs +++ b/crates/bevy_ecs_compile_fail_tests/src/lib.rs @@ -1 +1,3 @@ +#![allow(clippy::type_complexity)] + // Nothing here, check out the integration tests diff --git a/crates/bevy_encase_derive/src/lib.rs b/crates/bevy_encase_derive/src/lib.rs index d57be9f85c..cc81b6edd5 100644 --- a/crates/bevy_encase_derive/src/lib.rs +++ b/crates/bevy_encase_derive/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(clippy::type_complexity)] + use bevy_macro_utils::BevyManifest; use encase_derive_impl::{implement, syn}; diff --git a/crates/bevy_gilrs/src/lib.rs b/crates/bevy_gilrs/src/lib.rs index abbf34307c..1377a0aa79 100644 --- a/crates/bevy_gilrs/src/lib.rs +++ b/crates/bevy_gilrs/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(clippy::type_complexity)] + mod converter; mod gilrs_system; diff --git a/crates/bevy_gizmos/src/lib.rs b/crates/bevy_gizmos/src/lib.rs index 80b9f24e96..c6e0770fc0 100644 --- a/crates/bevy_gizmos/src/lib.rs +++ b/crates/bevy_gizmos/src/lib.rs @@ -1,3 +1,4 @@ +#![allow(clippy::type_complexity)] #![warn(missing_docs)] //! This crate adds an immediate mode drawing api to Bevy for visual debugging. diff --git a/crates/bevy_gltf/src/lib.rs b/crates/bevy_gltf/src/lib.rs index 4522bcf9db..c454255496 100644 --- a/crates/bevy_gltf/src/lib.rs +++ b/crates/bevy_gltf/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(clippy::type_complexity)] + #[cfg(feature = "bevy_animation")] use bevy_animation::AnimationClip; use bevy_utils::HashMap; diff --git a/crates/bevy_hierarchy/src/lib.rs b/crates/bevy_hierarchy/src/lib.rs index f156086b1a..d616e5384a 100644 --- a/crates/bevy_hierarchy/src/lib.rs +++ b/crates/bevy_hierarchy/src/lib.rs @@ -1,3 +1,4 @@ +#![allow(clippy::type_complexity)] #![warn(missing_docs)] //! `bevy_hierarchy` can be used to define hierarchies of entities. //! diff --git a/crates/bevy_input/src/lib.rs b/crates/bevy_input/src/lib.rs index 9da05a2e25..dfa64429f9 100644 --- a/crates/bevy_input/src/lib.rs +++ b/crates/bevy_input/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(clippy::type_complexity)] + mod axis; /// Common run conditions pub mod common_conditions; diff --git a/crates/bevy_internal/src/lib.rs b/crates/bevy_internal/src/lib.rs index be6c704233..723e65afd9 100644 --- a/crates/bevy_internal/src/lib.rs +++ b/crates/bevy_internal/src/lib.rs @@ -1,3 +1,4 @@ +#![allow(clippy::type_complexity)] #![warn(missing_docs)] //! This module is separated into its own crate to enable simple dynamic linking for Bevy, and should not be used directly diff --git a/crates/bevy_log/src/lib.rs b/crates/bevy_log/src/lib.rs index 7265f4fd62..81456df33d 100644 --- a/crates/bevy_log/src/lib.rs +++ b/crates/bevy_log/src/lib.rs @@ -1,3 +1,4 @@ +#![allow(clippy::type_complexity)] #![warn(missing_docs)] //! This crate provides logging functions and configuration for [Bevy](https://bevyengine.org) //! apps, and automatically configures platform specific log handlers (i.e. WASM or Android). diff --git a/crates/bevy_macro_utils/src/lib.rs b/crates/bevy_macro_utils/src/lib.rs index 3a72994510..ee1c1670d6 100644 --- a/crates/bevy_macro_utils/src/lib.rs +++ b/crates/bevy_macro_utils/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(clippy::type_complexity)] + extern crate proc_macro; mod attrs; diff --git a/crates/bevy_math/src/lib.rs b/crates/bevy_math/src/lib.rs index f9786ac792..10915c3df7 100644 --- a/crates/bevy_math/src/lib.rs +++ b/crates/bevy_math/src/lib.rs @@ -4,6 +4,7 @@ //! matrices like [`Mat2`], [`Mat3`] and [`Mat4`] and orientation representations //! like [`Quat`]. +#![allow(clippy::type_complexity)] #![warn(missing_docs)] pub mod cubic_splines; diff --git a/crates/bevy_mikktspace/src/lib.rs b/crates/bevy_mikktspace/src/lib.rs index 89d7b05427..365c273480 100644 --- a/crates/bevy_mikktspace/src/lib.rs +++ b/crates/bevy_mikktspace/src/lib.rs @@ -1,3 +1,4 @@ +#![allow(clippy::type_complexity)] #![allow(clippy::all)] use glam::{Vec2, Vec3}; diff --git a/crates/bevy_pbr/src/lib.rs b/crates/bevy_pbr/src/lib.rs index 4b27f57824..917fd007c3 100644 --- a/crates/bevy_pbr/src/lib.rs +++ b/crates/bevy_pbr/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(clippy::type_complexity)] + pub mod wireframe; mod alpha; diff --git a/crates/bevy_ptr/src/lib.rs b/crates/bevy_ptr/src/lib.rs index b2e9536521..39aada6099 100644 --- a/crates/bevy_ptr/src/lib.rs +++ b/crates/bevy_ptr/src/lib.rs @@ -1,6 +1,7 @@ #![doc = include_str!("../README.md")] #![no_std] #![warn(missing_docs)] +#![allow(clippy::type_complexity)] use core::fmt::{self, Formatter, Pointer}; use core::{ diff --git a/crates/bevy_reflect/src/lib.rs b/crates/bevy_reflect/src/lib.rs index c7d8743670..8b75615963 100644 --- a/crates/bevy_reflect/src/lib.rs +++ b/crates/bevy_reflect/src/lib.rs @@ -435,6 +435,7 @@ //! [orphan rule]: https://doc.rust-lang.org/book/ch10-02-traits.html#implementing-a-trait-on-a-type:~:text=But%20we%20can%E2%80%99t,implementation%20to%20use. //! [`bevy_reflect_derive/documentation`]: bevy_reflect_derive //! [derive `Reflect`]: derive@crate::Reflect +#![allow(clippy::type_complexity)] mod array; mod fields; diff --git a/crates/bevy_render/src/lib.rs b/crates/bevy_render/src/lib.rs index dd47d53212..6c852239c4 100644 --- a/crates/bevy_render/src/lib.rs +++ b/crates/bevy_render/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(clippy::type_complexity)] + #[cfg(target_pointer_width = "16")] compile_error!("bevy_render cannot compile for a 16-bit platform."); diff --git a/crates/bevy_scene/src/lib.rs b/crates/bevy_scene/src/lib.rs index 3488064f10..4185d18862 100644 --- a/crates/bevy_scene/src/lib.rs +++ b/crates/bevy_scene/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(clippy::type_complexity)] + mod bundle; mod dynamic_scene; mod dynamic_scene_builder; diff --git a/crates/bevy_sprite/src/lib.rs b/crates/bevy_sprite/src/lib.rs index b624b7bad8..2d348bc4a4 100644 --- a/crates/bevy_sprite/src/lib.rs +++ b/crates/bevy_sprite/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(clippy::type_complexity)] + mod bundle; mod dynamic_texture_atlas_builder; mod mesh2d; diff --git a/crates/bevy_tasks/src/lib.rs b/crates/bevy_tasks/src/lib.rs index b5e340c2d6..5382228830 100644 --- a/crates/bevy_tasks/src/lib.rs +++ b/crates/bevy_tasks/src/lib.rs @@ -1,4 +1,5 @@ #![warn(missing_docs)] +#![allow(clippy::type_complexity)] #![doc = include_str!("../README.md")] mod slice; diff --git a/crates/bevy_text/src/lib.rs b/crates/bevy_text/src/lib.rs index e740e525a2..d8c22568b0 100644 --- a/crates/bevy_text/src/lib.rs +++ b/crates/bevy_text/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(clippy::type_complexity)] + mod error; mod font; mod font_atlas; diff --git a/crates/bevy_time/src/lib.rs b/crates/bevy_time/src/lib.rs index f82d897f98..ee923f7b96 100644 --- a/crates/bevy_time/src/lib.rs +++ b/crates/bevy_time/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(clippy::type_complexity)] + /// Common run conditions pub mod common_conditions; pub mod fixed_timestep; diff --git a/crates/bevy_transform/src/lib.rs b/crates/bevy_transform/src/lib.rs index 130065e098..45ed286bd8 100644 --- a/crates/bevy_transform/src/lib.rs +++ b/crates/bevy_transform/src/lib.rs @@ -1,3 +1,4 @@ +#![allow(clippy::type_complexity)] #![warn(missing_docs)] #![warn(clippy::undocumented_unsafe_blocks)] #![doc = include_str!("../README.md")] diff --git a/crates/bevy_ui/src/lib.rs b/crates/bevy_ui/src/lib.rs index 1f1408c888..fe63b84670 100644 --- a/crates/bevy_ui/src/lib.rs +++ b/crates/bevy_ui/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(clippy::type_complexity)] + //! This crate contains Bevy's UI system, which can be used to create UI for both 2D and 3D games //! # Basic usage //! Spawn UI elements with [`node_bundles::ButtonBundle`], [`node_bundles::ImageBundle`], [`node_bundles::TextBundle`] and [`node_bundles::NodeBundle`] diff --git a/crates/bevy_utils/src/lib.rs b/crates/bevy_utils/src/lib.rs index b39ba0f540..bac6484d74 100644 --- a/crates/bevy_utils/src/lib.rs +++ b/crates/bevy_utils/src/lib.rs @@ -1,7 +1,8 @@ //! General utilities for first-party [Bevy] engine crates. //! //! [Bevy]: https://bevyengine.org/ - +//! +#![allow(clippy::type_complexity)] #![warn(missing_docs)] #![warn(clippy::undocumented_unsafe_blocks)] diff --git a/crates/bevy_window/src/lib.rs b/crates/bevy_window/src/lib.rs index c08d9e4b6f..a647686aa9 100644 --- a/crates/bevy_window/src/lib.rs +++ b/crates/bevy_window/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(clippy::type_complexity)] + #[warn(missing_docs)] mod cursor; mod event; diff --git a/crates/bevy_winit/src/lib.rs b/crates/bevy_winit/src/lib.rs index 1fb39bc380..f122f4899d 100644 --- a/crates/bevy_winit/src/lib.rs +++ b/crates/bevy_winit/src/lib.rs @@ -1,3 +1,4 @@ +#![allow(clippy::type_complexity)] #![warn(missing_docs)] //! `bevy_winit` provides utilities to handle window creation and the eventloop through [`winit`] //!