Move #![warn(clippy::allow_attributes, clippy::allow_attributes_without_reason)] to the workspace Cargo.toml (#17374)

# Objective
Fixes https://github.com/bevyengine/bevy/issues/17111

## Solution
Move `#![warn(clippy::allow_attributes,
clippy::allow_attributes_without_reason)]` to the workspace `Cargo.toml`

## Testing
Lots of CI testing, and local testing too.

---------

Co-authored-by: Benjamin Brienen <benjamin.brienen@outlook.com>
This commit is contained in:
MichiRecRoom 2025-01-14 20:14:58 -05:00 committed by GitHub
parent 0756a19f28
commit 26bb0b40d2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
55 changed files with 73 additions and 221 deletions

View File

@ -54,6 +54,9 @@ std_instead_of_core = "warn"
std_instead_of_alloc = "warn"
alloc_instead_of_core = "warn"
allow_attributes = "warn"
allow_attributes_without_reason = "warn"
[workspace.lints.rust]
missing_docs = "warn"
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(docsrs_dep)'] }
@ -95,6 +98,9 @@ std_instead_of_core = "allow"
std_instead_of_alloc = "allow"
alloc_instead_of_core = "allow"
allow_attributes = "warn"
allow_attributes_without_reason = "warn"
[lints.rust]
missing_docs = "warn"
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(docsrs_dep)'] }

View File

@ -56,6 +56,9 @@ ref_as_ptr = "warn"
# see: https://github.com/bevyengine/bevy/pull/15375#issuecomment-2366966219
too_long_first_doc_paragraph = "allow"
allow_attributes = "warn"
allow_attributes_without_reason = "warn"
[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(docsrs_dep)'] }
unsafe_op_in_unsafe_fn = "warn"

View File

@ -1,4 +1,7 @@
#![allow(dead_code)]
#![expect(
dead_code,
reason = "The `Mat4`s in the structs are used to bloat the size of the structs for benchmarking purposes."
)]
use bevy_ecs::prelude::*;
use glam::*;

View File

@ -1,9 +1,4 @@
#![forbid(unsafe_code)]
#![warn(
clippy::allow_attributes,
clippy::allow_attributes_without_reason,
reason = "See #17111; To be removed once all crates are in-line with these attributes"
)]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![doc(
html_logo_url = "https://bevyengine.org/assets/icon.png",

View File

@ -1,10 +1,5 @@
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![forbid(unsafe_code)]
#![warn(
clippy::allow_attributes,
clippy::allow_attributes_without_reason,
reason = "See #17111; To be removed once all crates are in-line with these attributes"
)]
#![doc(
html_logo_url = "https://bevyengine.org/assets/icon.png",
html_favicon_url = "https://bevyengine.org/assets/icon.png"

View File

@ -7,11 +7,6 @@
)]
#![cfg_attr(any(docsrs, docsrs_dep), feature(doc_auto_cfg, rustdoc_internals))]
#![forbid(unsafe_code)]
#![warn(
clippy::allow_attributes,
clippy::allow_attributes_without_reason,
reason = "See #17111; To be removed once all crates are in-line with these attributes"
)]
#![doc(
html_logo_url = "https://bevyengine.org/assets/icon.png",
html_favicon_url = "https://bevyengine.org/assets/icon.png"

View File

@ -139,11 +139,6 @@
//! This trait mirrors [`AssetLoader`] in structure, and works in tandem with [`AssetWriter`](io::AssetWriter), which mirrors [`AssetReader`](io::AssetReader).
#![expect(missing_docs, reason = "Not all docs are written yet, see #3492.")]
#![warn(
clippy::allow_attributes,
clippy::allow_attributes_without_reason,
reason = "See #17111; To be removed once all crates are in-line with these attributes"
)]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![doc(
html_logo_url = "https://bevyengine.org/assets/icon.png",

View File

@ -1,9 +1,4 @@
#![forbid(unsafe_code)]
#![warn(
clippy::allow_attributes,
clippy::allow_attributes_without_reason,
reason = "See #17111; To be removed once all crates are in-line with these attributes"
)]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![doc(
html_logo_url = "https://bevyengine.org/assets/icon.png",

View File

@ -1,10 +1,5 @@
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![forbid(unsafe_code)]
#![warn(
clippy::allow_attributes,
clippy::allow_attributes_without_reason,
reason = "See #17111; To be removed once all crates are in-line with these attributes"
)]
#![doc(
html_logo_url = "https://bevyengine.org/assets/icon.png",
html_favicon_url = "https://bevyengine.org/assets/icon.png"

View File

@ -1,10 +1,5 @@
#![expect(missing_docs, reason = "Not all docs are written yet, see #3492.")]
#![forbid(unsafe_code)]
#![warn(
clippy::allow_attributes,
clippy::allow_attributes_without_reason,
reason = "See #17111; To be removed once all crates are in-line with these attributes"
)]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![doc(
html_logo_url = "https://bevyengine.org/assets/icon.png",

View File

@ -1,10 +1,5 @@
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![forbid(unsafe_code)]
#![warn(
clippy::allow_attributes,
clippy::allow_attributes_without_reason,
reason = "See #17111; To be removed once all crates are in-line with these attributes"
)]
#![doc(
html_logo_url = "https://bevyengine.org/assets/icon.png",
html_favicon_url = "https://bevyengine.org/assets/icon.png"

View File

@ -1,11 +1,6 @@
#![expect(missing_docs, reason = "Not all docs are written yet, see #3492.")]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![forbid(unsafe_code)]
#![warn(
clippy::allow_attributes,
clippy::allow_attributes_without_reason,
reason = "See #17111; To be removed once all crates are in-line with these attributes"
)]
#![doc(
html_logo_url = "https://bevyengine.org/assets/icon.png",
html_favicon_url = "https://bevyengine.org/assets/icon.png"

View File

@ -1,9 +1,4 @@
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![warn(
clippy::allow_attributes,
clippy::allow_attributes_without_reason,
reason = "See #17111; To be removed once all crates are in-line with these attributes"
)]
#![doc(
html_logo_url = "https://bevyengine.org/assets/icon.png",
html_favicon_url = "https://bevyengine.org/assets/icon.png"

View File

@ -6,7 +6,10 @@
//! To demonstrate change detection, there are some console outputs based on changes in
//! the `EntityCounter` resource and updated Age components
#![expect(clippy::std_instead_of_core)]
#![expect(
clippy::std_instead_of_core,
reason = "Examples should not follow this lint"
)]
use bevy_ecs::prelude::*;
use rand::Rng;

View File

@ -1,7 +1,10 @@
//! In this example we add a counter resource and increase its value in one system,
//! while a different system prints the current count to the console.
#![expect(clippy::std_instead_of_core)]
#![expect(
clippy::std_instead_of_core,
reason = "Examples should not follow this lint"
)]
use bevy_ecs::prelude::*;
use rand::Rng;

View File

@ -19,11 +19,6 @@
)]
#![cfg_attr(any(docsrs, docsrs_dep), feature(doc_auto_cfg, rustdoc_internals))]
#![expect(unsafe_code, reason = "Unsafe code is used to improve performance.")]
#![warn(
clippy::allow_attributes,
clippy::allow_attributes_without_reason,
reason = "See #17111; To be removed once all crates are in-line with these attributes"
)]
#![doc(
html_logo_url = "https://bevyengine.org/assets/icon.png",
html_favicon_url = "https://bevyengine.org/assets/icon.png"

View File

@ -1,10 +1,5 @@
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![forbid(unsafe_code)]
#![warn(
clippy::allow_attributes,
clippy::allow_attributes_without_reason,
reason = "See #17111; To be removed once all crates are in-line with these attributes"
)]
#![doc(
html_logo_url = "https://bevyengine.org/assets/icon.png",
html_favicon_url = "https://bevyengine.org/assets/icon.png"

View File

@ -1,9 +1,4 @@
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![warn(
clippy::allow_attributes,
clippy::allow_attributes_without_reason,
reason = "See #17111; To be removed once all crates are in-line with these attributes"
)]
#![doc(
html_logo_url = "https://bevyengine.org/assets/icon.png",
html_favicon_url = "https://bevyengine.org/assets/icon.png"

View File

@ -1,10 +1,5 @@
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![forbid(unsafe_code)]
#![warn(
clippy::allow_attributes,
clippy::allow_attributes_without_reason,
reason = "See #17111; To be removed once all crates are in-line with these attributes"
)]
#![doc(
html_logo_url = "https://bevyengine.org/assets/icon.png",
html_favicon_url = "https://bevyengine.org/assets/icon.png"

View File

@ -1,10 +1,5 @@
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![forbid(unsafe_code)]
#![warn(
clippy::allow_attributes,
clippy::allow_attributes_without_reason,
reason = "See #17111; To be removed once all crates are in-line with these attributes"
)]
#![doc(
html_logo_url = "https://bevyengine.org/assets/icon.png",
html_favicon_url = "https://bevyengine.org/assets/icon.png"

View File

@ -1,9 +1,4 @@
#![expect(missing_docs, reason = "Not all docs are written yet, see #3492.")]
#![warn(
clippy::allow_attributes,
clippy::allow_attributes_without_reason,
reason = "See #17111; To be removed once all crates are in-line with these attributes"
)]
extern crate alloc;

View File

@ -1,10 +1,5 @@
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![forbid(unsafe_code)]
#![warn(
clippy::allow_attributes,
clippy::allow_attributes_without_reason,
reason = "See #17111; To be removed once all crates are in-line with these attributes"
)]
#![doc(
html_logo_url = "https://bevyengine.org/assets/icon.png",
html_favicon_url = "https://bevyengine.org/assets/icon.png"

View File

@ -1,10 +1,5 @@
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![forbid(unsafe_code)]
#![warn(
clippy::allow_attributes,
clippy::allow_attributes_without_reason,
reason = "See #17111; To be removed once all crates are in-line with these attributes"
)]
#![doc(
html_logo_url = "https://bevyengine.org/assets/icon.png",
html_favicon_url = "https://bevyengine.org/assets/icon.png"

View File

@ -1,10 +1,5 @@
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![forbid(unsafe_code)]
#![warn(
clippy::allow_attributes,
clippy::allow_attributes_without_reason,
reason = "See #17111; To be removed once all crates are in-line with these attributes"
)]
#![doc(
html_logo_url = "https://bevyengine.org/assets/icon.png",
html_favicon_url = "https://bevyengine.org/assets/icon.png"

View File

@ -1,9 +1,4 @@
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![warn(
clippy::allow_attributes,
clippy::allow_attributes_without_reason,
reason = "See #17111; To be removed once all crates are in-line with these attributes"
)]
#![doc(
html_logo_url = "https://bevyengine.org/assets/icon.png",
html_favicon_url = "https://bevyengine.org/assets/icon.png"

View File

@ -1,9 +1,4 @@
#![forbid(unsafe_code)]
#![warn(
clippy::allow_attributes,
clippy::allow_attributes_without_reason,
reason = "See #17111; To be removed once all crates are in-line with these attributes"
)]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![doc(
html_logo_url = "https://bevyengine.org/assets/icon.png",

View File

@ -1,9 +1,4 @@
#![forbid(unsafe_code)]
#![warn(
clippy::allow_attributes,
clippy::allow_attributes_without_reason,
reason = "See #17111; To be removed once all crates are in-line with these attributes"
)]
#![cfg_attr(
any(docsrs, docsrs_dep),
expect(

View File

@ -1,9 +1,4 @@
#![expect(missing_docs, reason = "Not all docs are written yet, see #3492.")]
#![warn(
clippy::allow_attributes,
clippy::allow_attributes_without_reason,
reason = "See #17111; To be removed once all crates are in-line with these attributes"
)]
extern crate alloc;
extern crate core;

View File

@ -1,3 +1,8 @@
#![allow(
clippy::allow_attributes,
clippy::allow_attributes_without_reason,
reason = "Much of the code here is still code that's been transpiled from C; we want to save 'fixing' this crate until after it's ported to safe rust."
)]
#![allow(
unsafe_op_in_unsafe_fn,
clippy::all,

View File

@ -1,11 +1,6 @@
#![expect(missing_docs, reason = "Not all docs are written yet, see #3492.")]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![forbid(unsafe_code)]
#![warn(
clippy::allow_attributes,
clippy::allow_attributes_without_reason,
reason = "See #17111; To be removed once all crates are in-line with these attributes"
)]
#![doc(
html_logo_url = "https://bevyengine.org/assets/icon.png",
html_favicon_url = "https://bevyengine.org/assets/icon.png"

View File

@ -155,11 +155,6 @@
//! the plugin with arbitrary backends and input methods, yet still use all the high level features.
#![deny(missing_docs)]
#![warn(
clippy::allow_attributes,
clippy::allow_attributes_without_reason,
reason = "See #17111; To be removed once all crates are in-line with these attributes"
)]
extern crate alloc;

View File

@ -2,11 +2,6 @@
#![no_std]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![expect(unsafe_code, reason = "Raw pointers are inherently unsafe.")]
#![warn(
clippy::allow_attributes,
clippy::allow_attributes_without_reason,
reason = "See #17111; To be removed once all crates are in-line with these attributes"
)]
#![doc(
html_logo_url = "https://bevyengine.org/assets/icon.png",
html_favicon_url = "https://bevyengine.org/assets/icon.png"

View File

@ -1,9 +1,4 @@
#![expect(missing_docs, reason = "Not all docs are written yet, see #3492.")]
#![warn(
clippy::allow_attributes,
clippy::allow_attributes_without_reason,
reason = "See #17111; To be removed once all crates are in-line with these attributes"
)]
#![cfg_attr(
any(docsrs, docsrs_dep),
expect(

View File

@ -318,12 +318,6 @@
//! [fully-qualified type names]: bevy_reflect::TypePath::type_path
//! [fully-qualified type name]: bevy_reflect::TypePath::type_path
#![warn(
clippy::allow_attributes,
clippy::allow_attributes_without_reason,
reason = "See #17111; To be removed once all crates are in-line with these attributes"
)]
use async_channel::{Receiver, Sender};
use bevy_app::{prelude::*, MainScheduleOrder};
use bevy_derive::{Deref, DerefMut};

View File

@ -1,10 +1,5 @@
#![expect(missing_docs, reason = "Not all docs are written yet, see #3492.")]
#![expect(unsafe_code, reason = "Unsafe code is used to improve performance.")]
#![warn(
clippy::allow_attributes,
clippy::allow_attributes_without_reason,
reason = "See #17111; To be removed once all crates are in-line with these attributes"
)]
#![cfg_attr(
any(docsrs, docsrs_dep),
expect(

View File

@ -1,10 +1,5 @@
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![forbid(unsafe_code)]
#![warn(
clippy::allow_attributes,
clippy::allow_attributes_without_reason,
reason = "See #17111; To be removed once all crates are in-line with these attributes"
)]
#![doc(
html_logo_url = "https://bevyengine.org/assets/icon.png",
html_favicon_url = "https://bevyengine.org/assets/icon.png"

View File

@ -1,11 +1,6 @@
#![expect(missing_docs, reason = "Not all docs are written yet, see #3492.")]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![forbid(unsafe_code)]
#![warn(
clippy::allow_attributes,
clippy::allow_attributes_without_reason,
reason = "See #17111; To be removed once all crates are in-line with these attributes"
)]
#![doc(
html_logo_url = "https://bevyengine.org/assets/icon.png",
html_favicon_url = "https://bevyengine.org/assets/icon.png"

View File

@ -37,11 +37,6 @@
)
)]
#![cfg_attr(any(docsrs, docsrs_dep), feature(rustdoc_internals))]
#![warn(
clippy::allow_attributes,
clippy::allow_attributes_without_reason,
reason = "See #17111; To be removed once all crates are in-line with these attributes"
)]
#[cfg(feature = "std")]
extern crate std;

View File

@ -4,11 +4,6 @@
html_logo_url = "https://bevyengine.org/assets/icon.png",
html_favicon_url = "https://bevyengine.org/assets/icon.png"
)]
#![warn(
clippy::allow_attributes,
clippy::allow_attributes_without_reason,
reason = "See #17111; To be removed once all crates are in-line with these attributes"
)]
#![no_std]
#[cfg(feature = "std")]

View File

@ -28,11 +28,6 @@
//! retrieving glyphs from the cache, or rasterizing to a [`FontAtlas`] if necessary.
//! 3. [`PositionedGlyph`]s are stored in a [`TextLayoutInfo`],
//! which contains all the information that downstream systems need for rendering.
#![warn(
clippy::allow_attributes,
clippy::allow_attributes_without_reason,
reason = "See #17111; To be removed once all crates are in-line with these attributes"
)]
extern crate alloc;

View File

@ -1,11 +1,6 @@
#![doc = include_str!("../README.md")]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![forbid(unsafe_code)]
#![warn(
clippy::allow_attributes,
clippy::allow_attributes_without_reason,
reason = "See #17111; To be removed once all crates are in-line with these attributes"
)]
#![doc(
html_logo_url = "https://bevyengine.org/assets/icon.png",
html_favicon_url = "https://bevyengine.org/assets/icon.png"

View File

@ -1,10 +1,5 @@
#![doc = include_str!("../README.md")]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![warn(
clippy::allow_attributes,
clippy::allow_attributes_without_reason,
reason = "See #17111; To be removed once all crates are in-line with these attributes"
)]
#![doc(
html_logo_url = "https://bevyengine.org/assets/icon.png",
html_favicon_url = "https://bevyengine.org/assets/icon.png"

View File

@ -1,9 +1,4 @@
#![expect(missing_docs, reason = "Not all docs are written yet, see #3492.")]
#![warn(
clippy::allow_attributes,
clippy::allow_attributes_without_reason,
reason = "See #17111; To be removed once all crates are in-line with these attributes"
)]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![doc(
html_logo_url = "https://bevyengine.org/assets/icon.png",

View File

@ -1,8 +1,3 @@
#![warn(
clippy::allow_attributes,
clippy::allow_attributes_without_reason,
reason = "See #17111; To be removed once all crates are in-line with these attributes"
)]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![doc(
html_logo_url = "https://bevyengine.org/assets/icon.png",

View File

@ -1,9 +1,4 @@
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![warn(
clippy::allow_attributes,
clippy::allow_attributes_without_reason,
reason = "See #17111; To be removed once all crates are in-line with these attributes"
)]
#![doc(
html_logo_url = "https://bevyengine.org/assets/icon.png",
html_favicon_url = "https://bevyengine.org/assets/icon.png"

View File

@ -1,10 +1,5 @@
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![forbid(unsafe_code)]
#![warn(
clippy::allow_attributes,
clippy::allow_attributes_without_reason,
reason = "See #17111; To be removed once all crates are in-line with these attributes"
)]
#![doc(
html_logo_url = "https://bevyengine.org/assets/icon.png",
html_favicon_url = "https://bevyengine.org/assets/icon.png"

View File

@ -10,7 +10,10 @@ use thiserror::Error;
#[derive(Asset, TypePath, Debug, Deserialize)]
struct CustomAsset {
#[allow(dead_code)]
#[expect(
dead_code,
reason = "Used to show how the data inside an asset file will be loaded into the struct"
)]
value: i32,
}

View File

@ -113,7 +113,10 @@ struct CoolTextRon {
#[derive(Asset, TypePath, Debug)]
struct CoolText {
text: String,
#[allow(unused)]
#[expect(
dead_code,
reason = "Used to show that our assets can hold handles to other assets"
)]
dependencies: Vec<Handle<Text>>,
}

View File

@ -1,4 +1,7 @@
#![allow(unsafe_code)]
#![expect(
unsafe_code,
reason = "Unsafe code is needed to work with dynamic components"
)]
//! This example show how you can create components dynamically, spawn entities with those components
//! as well as query for entities with those components.

View File

@ -127,7 +127,10 @@ fn demo_2(world: &mut World) {
}
/// This example demonstrates how to work with _dynamic_ immutable components.
#[allow(unsafe_code)]
#[expect(
unsafe_code,
reason = "Unsafe code is needed to work with dynamic components"
)]
fn demo_3(world: &mut World) {
// This is a list of dynamic components we will create.
// The first item is the name of the component, and the second is the size

View File

@ -1,6 +1,5 @@
//! This example demonstrates how each of Bevy's math primitives look like in 2D and 3D with meshes
//! and with gizmos
#![allow(clippy::match_same_arms)]
use bevy::{input::common_conditions::input_just_pressed, math::Isometry2d, prelude::*};
@ -441,6 +440,10 @@ fn draw_gizmos_2d(mut gizmos: Gizmos, state: Res<State<PrimitiveSelected>>, time
let isometry = Isometry2d::new(POSITION, Rot2::radians(angle));
let color = Color::WHITE;
#[expect(
clippy::match_same_arms,
reason = "Certain primitives don't have any 2D rendering support yet."
)]
match state.get() {
PrimitiveSelected::RectangleAndCuboid => {
gizmos.primitive_2d(&RECTANGLE, isometry, color);
@ -652,6 +655,10 @@ fn draw_gizmos_3d(mut gizmos: Gizmos, state: Res<State<PrimitiveSelected>>, time
let color = Color::WHITE;
let resolution = 10;
#[expect(
clippy::match_same_arms,
reason = "Certain primitives don't have any 3D rendering support yet."
)]
match state.get() {
PrimitiveSelected::RectangleAndCuboid => {
gizmos.primitive_3d(&CUBOID, isometry, color);

View File

@ -1,4 +1,3 @@
#![allow(clippy::match_same_arms)]
//! This example illustrates how reflection works for simple data structures, like
//! structs, tuples and vectors.
@ -34,7 +33,6 @@ pub struct C(usize);
/// Deriving reflect on an enum will implement the `Reflect` and `Enum` traits
#[derive(Reflect)]
#[allow(dead_code)]
enum D {
A,
B(usize),
@ -61,7 +59,6 @@ pub struct E {
#[derive(Reflect, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[reflect(opaque)]
#[reflect(PartialEq, Serialize, Deserialize)]
#[allow(dead_code)]
enum F {
X,
Y,
@ -124,6 +121,10 @@ fn setup() {
// implementation. Opaque is implemented for opaque types like String and Instant,
// but also include primitive types like i32, usize, and f32 (despite not technically being opaque).
ReflectRef::Opaque(_) => {}
#[expect(
clippy::allow_attributes,
reason = "`unreachable_patterns` is not always linted"
)]
#[allow(
unreachable_patterns,
reason = "This example cannot always detect when `bevy_reflect/functions` is enabled."

View File

@ -45,7 +45,10 @@ fn base_system(access_components: In<Vec<ComponentId>>, mut query: Query<Filtere
// find the value of the component
let ptr = filtered_entity.get_by_id(*component_id).unwrap();
#[expect(unsafe_code)]
#[expect(
unsafe_code,
reason = "Used to calculate Faulhaber's formula, per the comment above"
)]
// SAFETY: All components have a u8 layout
let value: u8 = unsafe { *ptr.deref::<u8>() };
@ -62,7 +65,10 @@ fn base_system(access_components: In<Vec<ComponentId>>, mut query: Query<Filtere
// we assign this value to all the components we can write to
for component_id in &access_components.0 {
if let Some(ptr) = filtered_entity.get_mut_by_id(*component_id) {
#[expect(unsafe_code)]
#[expect(
unsafe_code,
reason = "Used to write a value to every component that we can write to."
)]
// SAFETY: All components have a u8 layout
unsafe {
let mut value = ptr.with_type::<u8>();
@ -82,7 +88,7 @@ fn stress_test(num_entities: u32, num_components: u32, num_systems: u32) {
let component_ids: Vec<ComponentId> = (1..=num_components)
.map(|i| {
world.register_component_with_descriptor(
#[allow(unsafe_code)]
#[expect(unsafe_code, reason = "Used to register a bunch of fake components")]
// SAFETY:
// we don't implement a drop function
// u8 is Sync and Send
@ -130,7 +136,10 @@ fn stress_test(num_entities: u32, num_components: u32, num_systems: u32) {
for &component_id in components {
let value: u8 = rng.gen_range(0..255);
OwningPtr::make(value, |ptr| {
#[allow(unsafe_code)]
#[expect(
unsafe_code,
reason = "Used to write to a fake component that we previously set up"
)]
// SAFETY:
// component_id is from the same world
// value is u8, so ptr is a valid reference for component_id
@ -153,8 +162,7 @@ fn stress_test(num_entities: u32, num_components: u32, num_systems: u32) {
app.run();
}
#[expect(missing_docs)]
pub fn main() {
fn main() {
const DEFAULT_NUM_ENTITIES: u32 = 50000;
const DEFAULT_NUM_COMPONENTS: u32 = 1000;
const DEFAULT_NUM_SYSTEMS: u32 = 800;

View File

@ -212,7 +212,6 @@ struct Cfg {
update_filter: UpdateFilter,
}
#[allow(unused)]
#[derive(Debug, Clone)]
enum TestCase {
/// a uniform tree, exponentially growing with depth

View File

@ -1,4 +1,3 @@
#![allow(clippy::single_component_path_imports)]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
//! [![Bevy Logo](https://bevyengine.org/assets/bevy_logo_docs.svg)](https://bevyengine.org)
@ -50,5 +49,9 @@ pub use bevy_internal::*;
// Wasm does not support dynamic linking.
#[cfg(all(feature = "dynamic_linking", not(target_family = "wasm")))]
#[allow(unused_imports)]
#[expect(
unused_imports,
clippy::single_component_path_imports,
reason = "This causes bevy to be compiled as a dylib when using dynamic linking, and as such cannot be removed or changed without affecting dynamic linking."
)]
use bevy_dylib;