Skip to content

Commit

Permalink
Merge branch 'main' into lint/deny_allow_and_without_reason/bevy_core…
Browse files Browse the repository at this point in the history
…_pipeline
  • Loading branch information
LikeLakers2 authored Jan 9, 2025
2 parents 8175aaf + 3742e62 commit 421c1e5
Show file tree
Hide file tree
Showing 157 changed files with 2,503 additions and 1,055 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ jobs:
build-wasm:
runs-on: ubuntu-latest
timeout-minutes: 30
needs: build
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
Expand All @@ -175,6 +176,7 @@ jobs:
build-wasm-atomics:
runs-on: ubuntu-latest
timeout-minutes: 30
needs: build
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
Expand Down Expand Up @@ -397,6 +399,7 @@ jobs:
msrv:
runs-on: ubuntu-latest
timeout-minutes: 30
needs: build
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
Expand Down
44 changes: 40 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type_complexity = "allow"
undocumented_unsafe_blocks = "warn"
unwrap_or_default = "warn"
needless_lifetimes = "allow"
too_many_arguments = "allow"

ptr_as_ptr = "warn"
ptr_cast_constness = "warn"
Expand Down Expand Up @@ -82,6 +83,7 @@ type_complexity = "allow"
undocumented_unsafe_blocks = "warn"
unwrap_or_default = "warn"
needless_lifetimes = "allow"
too_many_arguments = "allow"

ptr_as_ptr = "warn"
ptr_cast_constness = "warn"
Expand Down Expand Up @@ -1281,16 +1283,38 @@ category = "Animation"
wasm = true

[[example]]
name = "animated_fox"
path = "examples/animation/animated_fox.rs"
name = "animated_mesh"
path = "examples/animation/animated_mesh.rs"
doc-scrape-examples = true

[package.metadata.example.animated_fox]
name = "Animated Fox"
[package.metadata.example.animated_mesh]
name = "Animated Mesh"
description = "Plays an animation from a skinned glTF"
category = "Animation"
wasm = true

[[example]]
name = "animated_mesh_control"
path = "examples/animation/animated_mesh_control.rs"
doc-scrape-examples = true

[package.metadata.example.animated_mesh_control]
name = "Animated Mesh Control"
description = "Plays an animation from a skinned glTF with keyboard controls"
category = "Animation"
wasm = true

[[example]]
name = "animated_mesh_events"
path = "examples/animation/animated_mesh_events.rs"
doc-scrape-examples = true

[package.metadata.example.animated_mesh_events]
name = "Animated Mesh Events"
description = "Plays an animation from a skinned glTF with events"
category = "Animation"
wasm = true

[[example]]
name = "animation_graph"
path = "examples/animation/animation_graph.rs"
Expand Down Expand Up @@ -3849,6 +3873,18 @@ category = "Picking"
wasm = true
required-features = ["bevy_sprite_picking_backend"]

[[example]]
name = "debug_picking"
path = "examples/picking/debug_picking.rs"
doc-scrape-examples = true
required-features = ["bevy_dev_tools"]

[package.metadata.example.debug_picking]
name = "Picking Debug Tools"
description = "Demonstrates picking debug overlay"
category = "Picking"
wasm = true

[[example]]
name = "animation_masks"
path = "examples/animation/animation_masks.rs"
Expand Down
8 changes: 8 additions & 0 deletions benches/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ type_complexity = "allow"
undocumented_unsafe_blocks = "warn"
unwrap_or_default = "warn"
needless_lifetimes = "allow"
too_many_arguments = "allow"

ptr_as_ptr = "warn"
ptr_cast_constness = "warn"
Expand All @@ -60,6 +61,13 @@ unexpected_cfgs = { level = "warn", check-cfg = ['cfg(docsrs_dep)'] }
unsafe_op_in_unsafe_fn = "warn"
unused_qualifications = "warn"

[lib]
# This fixes the "Unrecognized Option" error when running commands like
# `cargo bench -- --save-baseline before` by disabling the default benchmark harness.
# See <https://bheisler.github.io/criterion.rs/book/faq.html#cargo-bench-gives-unrecognized-option-errors-for-valid-command-line-options>
# for more information.
bench = false

[[bench]]
name = "ecs"
path = "benches/bevy_ecs/main.rs"
Expand Down
1 change: 0 additions & 1 deletion benches/benches/bevy_ecs/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
dead_code,
reason = "Many fields are unused/unread as they are just for benchmarking purposes."
)]
#![expect(clippy::type_complexity)]

use criterion::criterion_main;

Expand Down
14 changes: 9 additions & 5 deletions benches/benches/bevy_ecs/world/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ use core::hint::black_box;

use bevy_ecs::{
component::Component,
system::Commands,
world::{Command, CommandQueue, World},
result::Result,
system::{Command, Commands},
world::{CommandQueue, World},
};
use criterion::Criterion;

Expand Down Expand Up @@ -136,16 +137,18 @@ struct FakeCommandA;
struct FakeCommandB(u64);

impl Command for FakeCommandA {
fn apply(self, world: &mut World) {
fn apply(self, world: &mut World) -> Result {
black_box(self);
black_box(world);
Ok(())
}
}

impl Command for FakeCommandB {
fn apply(self, world: &mut World) {
fn apply(self, world: &mut World) -> Result {
black_box(self);
black_box(world);
Ok(())
}
}

Expand Down Expand Up @@ -180,9 +183,10 @@ pub fn fake_commands(criterion: &mut Criterion) {
struct SizedCommand<T: Default + Send + Sync + 'static>(T);

impl<T: Default + Send + Sync + 'static> Command for SizedCommand<T> {
fn apply(self, world: &mut World) {
fn apply(self, world: &mut World) -> Result {
black_box(self);
black_box(world);
Ok(())
}
}

Expand Down
1 change: 0 additions & 1 deletion benches/benches/bevy_reflect/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ fn simple<T: std::ops::Add<Output = T>>(a: T, b: T) -> T {
a + b
}

#[expect(clippy::too_many_arguments)]
fn complex<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>(
_: T0,
_: T1,
Expand Down
2 changes: 0 additions & 2 deletions benches/benches/bevy_reflect/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![expect(clippy::type_complexity)]

use criterion::criterion_main;

mod function;
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_animation/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ petgraph = { version = "0.6", features = ["serde-1"] }
ron = "0.8"
serde = "1"
blake3 = { version = "1.0" }
downcast-rs = "1.2.0"
downcast-rs = { version = "2", default-features = false, features = ["std"] }
thiserror = { version = "2", default-features = false }
derive_more = { version = "1", default-features = false, features = ["from"] }
either = "1.13"
Expand Down
8 changes: 7 additions & 1 deletion crates/bevy_animation/src/animation_curves.rs
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,7 @@ where
///
/// ```
/// # use bevy_animation::{animation_curves::AnimatedField, animated_field};
/// # use bevy_color::Srgba;
/// # use bevy_ecs::component::Component;
/// # use bevy_math::Vec3;
/// # use bevy_reflect::Reflect;
Expand All @@ -993,10 +994,15 @@ where
/// }
///
/// let field = animated_field!(Transform::translation);
///
/// #[derive(Component, Reflect)]
/// struct Color(Srgba);
///
/// let tuple_field = animated_field!(Color::0);
/// ```
#[macro_export]
macro_rules! animated_field {
($component:ident::$field:ident) => {
($component:ident::$field:tt) => {
AnimatedField::new_unchecked(stringify!($field), |component: &mut $component| {
&mut component.$field
})
Expand Down
9 changes: 3 additions & 6 deletions crates/bevy_app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ license = "MIT OR Apache-2.0"
keywords = ["bevy"]

[features]
default = ["std", "bevy_reflect", "bevy_tasks", "bevy_ecs/default", "downcast"]
default = ["std", "bevy_reflect", "bevy_tasks", "bevy_ecs/default"]

# Functionality

Expand All @@ -26,9 +26,6 @@ reflect_functions = [
## Adds support for running async background tasks
bevy_tasks = ["dep:bevy_tasks"]

## Adds `downcast-rs` integration for `Plugin`
downcast = ["dep:downcast-rs"]

# Debugging Features

## Enables `tracing` integration, allowing spans and other metrics to be reported
Expand All @@ -48,7 +45,7 @@ std = [
"bevy_reflect?/std",
"bevy_ecs/std",
"dep:ctrlc",
"downcast-rs?/std",
"downcast-rs/std",
"bevy_utils/std",
"bevy_tasks?/std",
]
Expand Down Expand Up @@ -81,7 +78,7 @@ bevy_utils = { path = "../bevy_utils", version = "0.16.0-dev", default-features
bevy_tasks = { path = "../bevy_tasks", version = "0.16.0-dev", default-features = false, optional = true }

# other
downcast-rs = { version = "1.2.0", default-features = false, optional = true }
downcast-rs = { version = "2", default-features = false }
thiserror = { version = "2", default-features = false }
variadics_please = "1.1"
tracing = { version = "0.1", default-features = false, optional = true }
Expand Down
5 changes: 1 addition & 4 deletions crates/bevy_app/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use crate::{
use alloc::{
boxed::Box,
string::{String, ToString},
vec::Vec,
};
pub use bevy_derive::AppLabel;
use bevy_ecs::{
Expand All @@ -29,9 +30,6 @@ use std::{
process::{ExitCode, Termination},
};

#[cfg(feature = "downcast")]
use alloc::vec::Vec;

bevy_ecs::define_label!(
/// A strongly-typed class of labels used to identify an [`App`].
AppLabel,
Expand Down Expand Up @@ -522,7 +520,6 @@ impl App {
/// # app.add_plugins(ImagePlugin::default());
/// let default_sampler = app.get_added_plugins::<ImagePlugin>()[0].default_sampler;
/// ```
#[cfg(feature = "downcast")]
pub fn get_added_plugins<T>(&self) -> Vec<&T>
where
T: Plugin,
Expand Down
17 changes: 1 addition & 16 deletions crates/bevy_app/src/plugin.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,6 @@
// TODO: Upstream `portable-atomic` support to `downcast_rs` and unconditionally
// include it as a dependency.
// See https://github.com/marcianx/downcast-rs/pull/22 for details
#[cfg(feature = "downcast")]
use downcast_rs::{impl_downcast, Downcast};

use crate::App;
use core::any::Any;

/// Dummy trait with the same name as `downcast_rs::Downcast`. This is to ensure
/// the `Plugin: Downcast` bound can remain even when `downcast` isn't enabled.
#[cfg(not(feature = "downcast"))]
#[doc(hidden)]
pub trait Downcast {}

#[cfg(not(feature = "downcast"))]
impl<T: ?Sized> Downcast for T {}
use downcast_rs::{impl_downcast, Downcast};

/// A collection of Bevy app logic and configuration.
///
Expand Down Expand Up @@ -105,7 +91,6 @@ pub trait Plugin: Downcast + Any + Send + Sync {
}
}

#[cfg(feature = "downcast")]
impl_downcast!(Plugin);

impl<T: Fn(&mut App) + Send + Sync + 'static> Plugin for T {
Expand Down
1 change: 0 additions & 1 deletion crates/bevy_app/src/sub_app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,6 @@ impl SubApp {
}

/// See [`App::get_added_plugins`].
#[cfg(feature = "downcast")]
pub fn get_added_plugins<T>(&self) -> Vec<&T>
where
T: Plugin,
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_asset/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async-fs = "2.0"
async-lock = "3.0"
bitflags = { version = "2.3", features = ["serde"] }
crossbeam-channel = "0.5"
downcast-rs = "1.2"
downcast-rs = { version = "2", default-features = false, features = ["std"] }
disqualified = "1.0"
either = "1.13"
futures-io = "0.3"
Expand Down
4 changes: 0 additions & 4 deletions crates/bevy_asset/src/server/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,6 @@ impl AssetInfos {
.unwrap()
}

#[expect(
clippy::too_many_arguments,
reason = "Arguments needed so that both `create_loading_handle_untyped()` and `get_or_create_path_handle_internal()` may share code."
)]
fn create_handle_internal(
infos: &mut HashMap<UntypedAssetId, AssetInfo>,
handle_providers: &TypeIdMap<AssetHandleProvider>,
Expand Down
8 changes: 4 additions & 4 deletions crates/bevy_color/src/oklaba.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ impl From<LinearRgba> for Oklaba {
blue,
alpha,
} = value;
// From https://github.com/DougLau/pix
// Floats literals are truncated from the source code above, to avoid excessive precision.
// From https://bottosson.github.io/posts/oklab/#converting-from-linear-srgb-to-oklab
// Float literals are truncated to avoid excessive precision.
let l = 0.41222146 * red + 0.53633255 * green + 0.051445995 * blue;
let m = 0.2119035 * red + 0.6806995 * green + 0.10739696 * blue;
let s = 0.08830246 * red + 0.28171885 * green + 0.6299787 * blue;
Expand All @@ -248,8 +248,8 @@ impl From<Oklaba> for LinearRgba {
alpha,
} = value;

// From https://github.com/Ogeon/palette/blob/e75eab2fb21af579353f51f6229a510d0d50a311/palette/src/oklab.rs#L312-L332
// Floats literals are truncated from the source code above, to avoid excessive precision.
// From https://bottosson.github.io/posts/oklab/#converting-from-linear-srgb-to-oklab
// Float literals are truncated to avoid excessive precision.
let l_ = lightness + 0.39633778 * a + 0.21580376 * b;
let m_ = lightness - 0.105561346 * a - 0.06385417 * b;
let s_ = lightness - 0.08948418 * a - 1.2914855 * b;
Expand Down
Loading

0 comments on commit 421c1e5

Please sign in to comment.