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.
This commit is contained in:
JoJoJet 2023-04-06 17:27:36 -04:00 committed by GitHub
parent b8b0942f49
commit 3ead10a3e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
38 changed files with 57 additions and 1 deletions

View File

@ -1,6 +1,7 @@
//! Accessibility for Bevy //! Accessibility for Bevy
#![warn(missing_docs)] #![warn(missing_docs)]
#![allow(clippy::type_complexity)]
#![forbid(unsafe_code)] #![forbid(unsafe_code)]
use std::{ use std::{

View File

@ -1,6 +1,7 @@
//! Animation for the game engine Bevy //! Animation for the game engine Bevy
#![warn(missing_docs)] #![warn(missing_docs)]
#![allow(clippy::type_complexity)]
use std::ops::Deref; use std::ops::Deref;
use std::time::Duration; use std::time::Duration;

View File

@ -1,6 +1,7 @@
//! This crate is about everything concerning the highest-level, application layer of a Bevy app. //! This crate is about everything concerning the highest-level, application layer of a Bevy app.
#![warn(missing_docs)] #![warn(missing_docs)]
#![allow(clippy::type_complexity)]
mod app; mod app;
mod main_schedule; mod main_schedule;

View File

@ -9,6 +9,7 @@
//! [asset storage]: struct.Assets.html //! [asset storage]: struct.Assets.html
#![warn(missing_docs)] #![warn(missing_docs)]
#![allow(clippy::type_complexity)]
mod asset_server; mod asset_server;
mod assets; mod assets;

View File

@ -20,6 +20,7 @@
//! ``` //! ```
#![forbid(unsafe_code)] #![forbid(unsafe_code)]
#![allow(clippy::type_complexity)]
#![warn(missing_docs)] #![warn(missing_docs)]
mod audio; mod audio;

View File

@ -1,4 +1,5 @@
#![warn(missing_docs)] #![warn(missing_docs)]
#![allow(clippy::type_complexity)]
//! This crate provides core functionality for Bevy Engine. //! This crate provides core functionality for Bevy Engine.
mod name; mod name;

View File

@ -1,3 +1,5 @@
#![allow(clippy::type_complexity)]
pub mod blit; pub mod blit;
pub mod bloom; pub mod bloom;
pub mod clear_color; pub mod clear_color;

View File

@ -1,3 +1,5 @@
#![allow(clippy::type_complexity)]
extern crate proc_macro; extern crate proc_macro;
mod app_plugin; mod app_plugin;

View File

@ -1,3 +1,5 @@
#![allow(clippy::type_complexity)]
mod diagnostic; mod diagnostic;
mod entity_count_diagnostics_plugin; mod entity_count_diagnostics_plugin;
mod frame_time_diagnostics_plugin; mod frame_time_diagnostics_plugin;

View File

@ -1,4 +1,5 @@
#![warn(missing_docs)] #![warn(missing_docs)]
#![allow(clippy::type_complexity)]
#![allow(clippy::single_component_path_imports)] #![allow(clippy::single_component_path_imports)]
//! Forces dynamic linking of Bevy. //! Forces dynamic linking of Bevy.

View File

@ -1,3 +1,5 @@
#![allow(clippy::type_complexity)]
mod loader; mod loader;
pub use loader::*; pub use loader::*;

View File

@ -1,4 +1,5 @@
#![warn(clippy::undocumented_unsafe_blocks)] #![warn(clippy::undocumented_unsafe_blocks)]
#![allow(clippy::type_complexity)]
#![doc = include_str!("../README.md")] #![doc = include_str!("../README.md")]
#[cfg(target_pointer_width = "16")] #[cfg(target_pointer_width = "16")]

View File

@ -1 +1,3 @@
#![allow(clippy::type_complexity)]
// Nothing here, check out the integration tests // Nothing here, check out the integration tests

View File

@ -1,3 +1,5 @@
#![allow(clippy::type_complexity)]
use bevy_macro_utils::BevyManifest; use bevy_macro_utils::BevyManifest;
use encase_derive_impl::{implement, syn}; use encase_derive_impl::{implement, syn};

View File

@ -1,3 +1,5 @@
#![allow(clippy::type_complexity)]
mod converter; mod converter;
mod gilrs_system; mod gilrs_system;

View File

@ -1,3 +1,4 @@
#![allow(clippy::type_complexity)]
#![warn(missing_docs)] #![warn(missing_docs)]
//! This crate adds an immediate mode drawing api to Bevy for visual debugging. //! This crate adds an immediate mode drawing api to Bevy for visual debugging.

View File

@ -1,3 +1,5 @@
#![allow(clippy::type_complexity)]
#[cfg(feature = "bevy_animation")] #[cfg(feature = "bevy_animation")]
use bevy_animation::AnimationClip; use bevy_animation::AnimationClip;
use bevy_utils::HashMap; use bevy_utils::HashMap;

View File

@ -1,3 +1,4 @@
#![allow(clippy::type_complexity)]
#![warn(missing_docs)] #![warn(missing_docs)]
//! `bevy_hierarchy` can be used to define hierarchies of entities. //! `bevy_hierarchy` can be used to define hierarchies of entities.
//! //!

View File

@ -1,3 +1,5 @@
#![allow(clippy::type_complexity)]
mod axis; mod axis;
/// Common run conditions /// Common run conditions
pub mod common_conditions; pub mod common_conditions;

View File

@ -1,3 +1,4 @@
#![allow(clippy::type_complexity)]
#![warn(missing_docs)] #![warn(missing_docs)]
//! This module is separated into its own crate to enable simple dynamic linking for Bevy, and should not be used directly //! This module is separated into its own crate to enable simple dynamic linking for Bevy, and should not be used directly

View File

@ -1,3 +1,4 @@
#![allow(clippy::type_complexity)]
#![warn(missing_docs)] #![warn(missing_docs)]
//! This crate provides logging functions and configuration for [Bevy](https://bevyengine.org) //! 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). //! apps, and automatically configures platform specific log handlers (i.e. WASM or Android).

View File

@ -1,3 +1,5 @@
#![allow(clippy::type_complexity)]
extern crate proc_macro; extern crate proc_macro;
mod attrs; mod attrs;

View File

@ -4,6 +4,7 @@
//! matrices like [`Mat2`], [`Mat3`] and [`Mat4`] and orientation representations //! matrices like [`Mat2`], [`Mat3`] and [`Mat4`] and orientation representations
//! like [`Quat`]. //! like [`Quat`].
#![allow(clippy::type_complexity)]
#![warn(missing_docs)] #![warn(missing_docs)]
pub mod cubic_splines; pub mod cubic_splines;

View File

@ -1,3 +1,4 @@
#![allow(clippy::type_complexity)]
#![allow(clippy::all)] #![allow(clippy::all)]
use glam::{Vec2, Vec3}; use glam::{Vec2, Vec3};

View File

@ -1,3 +1,5 @@
#![allow(clippy::type_complexity)]
pub mod wireframe; pub mod wireframe;
mod alpha; mod alpha;

View File

@ -1,6 +1,7 @@
#![doc = include_str!("../README.md")] #![doc = include_str!("../README.md")]
#![no_std] #![no_std]
#![warn(missing_docs)] #![warn(missing_docs)]
#![allow(clippy::type_complexity)]
use core::fmt::{self, Formatter, Pointer}; use core::fmt::{self, Formatter, Pointer};
use core::{ use core::{

View File

@ -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. //! [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 //! [`bevy_reflect_derive/documentation`]: bevy_reflect_derive
//! [derive `Reflect`]: derive@crate::Reflect //! [derive `Reflect`]: derive@crate::Reflect
#![allow(clippy::type_complexity)]
mod array; mod array;
mod fields; mod fields;

View File

@ -1,3 +1,5 @@
#![allow(clippy::type_complexity)]
#[cfg(target_pointer_width = "16")] #[cfg(target_pointer_width = "16")]
compile_error!("bevy_render cannot compile for a 16-bit platform."); compile_error!("bevy_render cannot compile for a 16-bit platform.");

View File

@ -1,3 +1,5 @@
#![allow(clippy::type_complexity)]
mod bundle; mod bundle;
mod dynamic_scene; mod dynamic_scene;
mod dynamic_scene_builder; mod dynamic_scene_builder;

View File

@ -1,3 +1,5 @@
#![allow(clippy::type_complexity)]
mod bundle; mod bundle;
mod dynamic_texture_atlas_builder; mod dynamic_texture_atlas_builder;
mod mesh2d; mod mesh2d;

View File

@ -1,4 +1,5 @@
#![warn(missing_docs)] #![warn(missing_docs)]
#![allow(clippy::type_complexity)]
#![doc = include_str!("../README.md")] #![doc = include_str!("../README.md")]
mod slice; mod slice;

View File

@ -1,3 +1,5 @@
#![allow(clippy::type_complexity)]
mod error; mod error;
mod font; mod font;
mod font_atlas; mod font_atlas;

View File

@ -1,3 +1,5 @@
#![allow(clippy::type_complexity)]
/// Common run conditions /// Common run conditions
pub mod common_conditions; pub mod common_conditions;
pub mod fixed_timestep; pub mod fixed_timestep;

View File

@ -1,3 +1,4 @@
#![allow(clippy::type_complexity)]
#![warn(missing_docs)] #![warn(missing_docs)]
#![warn(clippy::undocumented_unsafe_blocks)] #![warn(clippy::undocumented_unsafe_blocks)]
#![doc = include_str!("../README.md")] #![doc = include_str!("../README.md")]

View File

@ -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 //! This crate contains Bevy's UI system, which can be used to create UI for both 2D and 3D games
//! # Basic usage //! # Basic usage
//! Spawn UI elements with [`node_bundles::ButtonBundle`], [`node_bundles::ImageBundle`], [`node_bundles::TextBundle`] and [`node_bundles::NodeBundle`] //! Spawn UI elements with [`node_bundles::ButtonBundle`], [`node_bundles::ImageBundle`], [`node_bundles::TextBundle`] and [`node_bundles::NodeBundle`]

View File

@ -1,7 +1,8 @@
//! General utilities for first-party [Bevy] engine crates. //! General utilities for first-party [Bevy] engine crates.
//! //!
//! [Bevy]: https://bevyengine.org/ //! [Bevy]: https://bevyengine.org/
//!
#![allow(clippy::type_complexity)]
#![warn(missing_docs)] #![warn(missing_docs)]
#![warn(clippy::undocumented_unsafe_blocks)] #![warn(clippy::undocumented_unsafe_blocks)]

View File

@ -1,3 +1,5 @@
#![allow(clippy::type_complexity)]
#[warn(missing_docs)] #[warn(missing_docs)]
mod cursor; mod cursor;
mod event; mod event;

View File

@ -1,3 +1,4 @@
#![allow(clippy::type_complexity)]
#![warn(missing_docs)] #![warn(missing_docs)]
//! `bevy_winit` provides utilities to handle window creation and the eventloop through [`winit`] //! `bevy_winit` provides utilities to handle window creation and the eventloop through [`winit`]
//! //!