Skip to content

Commit

Permalink
Suppress the clippy::type_complexity lint (#8313)
Browse files Browse the repository at this point in the history
# 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 rust-lang/rust-clippy#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.
  • Loading branch information
JoJoJet authored Apr 6, 2023
1 parent b8b0942 commit 3ead10a
Show file tree
Hide file tree
Showing 38 changed files with 57 additions and 1 deletion.
1 change: 1 addition & 0 deletions crates/bevy_a11y/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Accessibility for Bevy
#![warn(missing_docs)]
#![allow(clippy::type_complexity)]
#![forbid(unsafe_code)]

use std::{
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_animation/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_app/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_asset/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
//! [asset storage]: struct.Assets.html
#![warn(missing_docs)]
#![allow(clippy::type_complexity)]

mod asset_server;
mod assets;
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_audio/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
//! ```
#![forbid(unsafe_code)]
#![allow(clippy::type_complexity)]
#![warn(missing_docs)]

mod audio;
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![warn(missing_docs)]
#![allow(clippy::type_complexity)]
//! This crate provides core functionality for Bevy Engine.
mod name;
Expand Down
2 changes: 2 additions & 0 deletions crates/bevy_core_pipeline/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::type_complexity)]

pub mod blit;
pub mod bloom;
pub mod clear_color;
Expand Down
2 changes: 2 additions & 0 deletions crates/bevy_derive/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::type_complexity)]

extern crate proc_macro;

mod app_plugin;
Expand Down
2 changes: 2 additions & 0 deletions crates/bevy_diagnostic/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::type_complexity)]

mod diagnostic;
mod entity_count_diagnostics_plugin;
mod frame_time_diagnostics_plugin;
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_dylib/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![warn(missing_docs)]
#![allow(clippy::type_complexity)]
#![allow(clippy::single_component_path_imports)]

//! Forces dynamic linking of Bevy.
Expand Down
2 changes: 2 additions & 0 deletions crates/bevy_dynamic_plugin/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::type_complexity)]

mod loader;

pub use loader::*;
1 change: 1 addition & 0 deletions crates/bevy_ecs/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![warn(clippy::undocumented_unsafe_blocks)]
#![allow(clippy::type_complexity)]
#![doc = include_str!("../README.md")]

#[cfg(target_pointer_width = "16")]
Expand Down
2 changes: 2 additions & 0 deletions crates/bevy_ecs_compile_fail_tests/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
#![allow(clippy::type_complexity)]

// Nothing here, check out the integration tests
2 changes: 2 additions & 0 deletions crates/bevy_encase_derive/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::type_complexity)]

use bevy_macro_utils::BevyManifest;
use encase_derive_impl::{implement, syn};

Expand Down
2 changes: 2 additions & 0 deletions crates/bevy_gilrs/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::type_complexity)]

mod converter;
mod gilrs_system;

Expand Down
1 change: 1 addition & 0 deletions crates/bevy_gizmos/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(clippy::type_complexity)]
#![warn(missing_docs)]

//! This crate adds an immediate mode drawing api to Bevy for visual debugging.
Expand Down
2 changes: 2 additions & 0 deletions crates/bevy_gltf/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::type_complexity)]

#[cfg(feature = "bevy_animation")]
use bevy_animation::AnimationClip;
use bevy_utils::HashMap;
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_hierarchy/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(clippy::type_complexity)]
#![warn(missing_docs)]
//! `bevy_hierarchy` can be used to define hierarchies of entities.
//!
Expand Down
2 changes: 2 additions & 0 deletions crates/bevy_input/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::type_complexity)]

mod axis;
/// Common run conditions
pub mod common_conditions;
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_internal/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_log/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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).
Expand Down
2 changes: 2 additions & 0 deletions crates/bevy_macro_utils/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::type_complexity)]

extern crate proc_macro;

mod attrs;
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_math/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_mikktspace/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(clippy::type_complexity)]
#![allow(clippy::all)]

use glam::{Vec2, Vec3};
Expand Down
2 changes: 2 additions & 0 deletions crates/bevy_pbr/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::type_complexity)]

pub mod wireframe;

mod alpha;
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_ptr/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_reflect/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions crates/bevy_render/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::type_complexity)]

#[cfg(target_pointer_width = "16")]
compile_error!("bevy_render cannot compile for a 16-bit platform.");

Expand Down
2 changes: 2 additions & 0 deletions crates/bevy_scene/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::type_complexity)]

mod bundle;
mod dynamic_scene;
mod dynamic_scene_builder;
Expand Down
2 changes: 2 additions & 0 deletions crates/bevy_sprite/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::type_complexity)]

mod bundle;
mod dynamic_texture_atlas_builder;
mod mesh2d;
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_tasks/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![warn(missing_docs)]
#![allow(clippy::type_complexity)]
#![doc = include_str!("../README.md")]

mod slice;
Expand Down
2 changes: 2 additions & 0 deletions crates/bevy_text/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::type_complexity)]

mod error;
mod font;
mod font_atlas;
Expand Down
2 changes: 2 additions & 0 deletions crates/bevy_time/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::type_complexity)]

/// Common run conditions
pub mod common_conditions;
pub mod fixed_timestep;
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_transform/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(clippy::type_complexity)]
#![warn(missing_docs)]
#![warn(clippy::undocumented_unsafe_blocks)]
#![doc = include_str!("../README.md")]
Expand Down
2 changes: 2 additions & 0 deletions crates/bevy_ui/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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`]
Expand Down
3 changes: 2 additions & 1 deletion crates/bevy_utils/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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)]

Expand Down
2 changes: 2 additions & 0 deletions crates/bevy_window/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::type_complexity)]

#[warn(missing_docs)]
mod cursor;
mod event;
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_winit/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(clippy::type_complexity)]
#![warn(missing_docs)]
//! `bevy_winit` provides utilities to handle window creation and the eventloop through [`winit`]
//!
Expand Down

0 comments on commit 3ead10a

Please sign in to comment.