Upgrade to Rust Edition 2024 (#17967)

# Objective

- Fixes #17960

## Solution

- Followed the [edition upgrade
guide](https://doc.rust-lang.org/edition-guide/editions/transitioning-an-existing-project-to-a-new-edition.html)

## Testing

- CI

---

## Summary of Changes

### Documentation Indentation

When using lists in documentation, proper indentation is now linted for.
This means subsequent lines within the same list item must start at the
same indentation level as the item.

```rust
/* Valid */
/// - Item 1
///   Run-on sentence.
/// - Item 2
struct Foo;

/* Invalid */
/// - Item 1
///     Run-on sentence.
/// - Item 2
struct Foo;
```

### Implicit `!` to `()` Conversion

`!` (the never return type, returned by `panic!`, etc.) no longer
implicitly converts to `()`. This is particularly painful for systems
with `todo!` or `panic!` statements, as they will no longer be functions
returning `()` (or `Result<()>`), making them invalid systems for
functions like `add_systems`. The ideal fix would be to accept functions
returning `!` (or rather, _not_ returning), but this is blocked on the
[stabilisation of the `!` type
itself](https://doc.rust-lang.org/std/primitive.never.html), which is
not done.

The "simple" fix would be to add an explicit `-> ()` to system
signatures (e.g., `|| { todo!() }` becomes `|| -> () { todo!() }`).
However, this is _also_ banned, as there is an existing lint which (IMO,
incorrectly) marks this as an unnecessary annotation.

So, the "fix" (read: workaround) is to put these kinds of `|| -> ! { ...
}` closuers into variables and give the variable an explicit type (e.g.,
`fn()`).

```rust
// Valid
let system: fn() = || todo!("Not implemented yet!");
app.add_systems(..., system);

// Invalid
app.add_systems(..., || todo!("Not implemented yet!"));
```

### Temporary Variable Lifetimes

The order in which temporary variables are dropped has changed. The
simple fix here is _usually_ to just assign temporaries to a named
variable before use.

### `gen` is a keyword

We can no longer use the name `gen` as it is reserved for a future
generator syntax. This involved replacing uses of the name `gen` with
`r#gen` (the raw-identifier syntax).

### Formatting has changed

Use statements have had the order of imports changed, causing a
substantial +/-3,000 diff when applied. For now, I have opted-out of
this change by amending `rustfmt.toml`

```toml
style_edition = "2021"
```

This preserves the original formatting for now, reducing the size of
this PR. It would be a simple followup to update this to 2024 and run
`cargo fmt`.

### New `use<>` Opt-Out Syntax

Lifetimes are now implicitly included in RPIT types. There was a handful
of instances where it needed to be added to satisfy the borrow checker,
but there may be more cases where it _should_ be added to avoid
breakages in user code.

### `MyUnitStruct { .. }` is an invalid pattern

Previously, you could match against unit structs (and unit enum
variants) with a `{ .. }` destructuring. This is no longer valid.

### Pretty much every use of `ref` and `mut` are gone

Pattern binding has changed to the point where these terms are largely
unused now. They still serve a purpose, but it is far more niche now.

### `iter::repeat(...).take(...)` is bad

New lint recommends using the more explicit `iter::repeat_n(..., ...)`
instead.

## Migration Guide

The lifetimes of functions using return-position impl-trait (RPIT) are
likely _more_ conservative than they had been previously. If you
encounter lifetime issues with such a function, please create an issue
to investigate the addition of `+ use<...>`.

## Notes

- Check the individual commits for a clearer breakdown for what
_actually_ changed.

---------

Co-authored-by: François Mockers <francois.mockers@vleue.com>
This commit is contained in:
Zachary Harrold 2025-02-24 14:54:47 +11:00 committed by GitHub
parent 2953db7f8f
commit 5241e09671
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
187 changed files with 596 additions and 592 deletions

View File

@ -335,6 +335,7 @@ jobs:
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: check for missing metadata
id: missing-metadata
run: cargo run -p build-templated-pages -- check-missing examples
@ -369,6 +370,7 @@ jobs:
needs: check-missing-examples-in-docs
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: check for missing features
id: missing-features
run: cargo run -p build-templated-pages -- check-missing features
@ -412,6 +414,7 @@ jobs:
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-msrv-${{ hashFiles('**/Cargo.toml') }}
- uses: dtolnay/rust-toolchain@stable
- name: get MSRV
id: msrv
run: |

View File

@ -1,7 +1,7 @@
[package]
name = "bevy"
version = "0.16.0-dev"
edition = "2021"
edition = "2024"
categories = ["game-engines", "graphics", "gui", "rendering"]
description = "A refreshingly simple data-driven game engine and app framework"
exclude = ["assets/", "tools/", ".github/", "crates/", "examples/wasm/assets/"]
@ -10,7 +10,7 @@ keywords = ["game", "engine", "gamedev", "graphics", "bevy"]
license = "MIT OR Apache-2.0"
repository = "https://github.com/bevyengine/bevy"
documentation = "https://docs.rs/bevy"
rust-version = "1.83.0"
rust-version = "1.85.0"
[workspace]
resolver = "2"

View File

@ -1,6 +1,6 @@
[package]
name = "benches"
edition = "2021"
edition = "2024"
description = "Benchmarks that test Bevy's performance"
publish = false
license = "MIT OR Apache-2.0"

View File

@ -95,7 +95,7 @@ fn all_added_detection_generic<T: Component + Default>(group: &mut BenchGroup, e
let query = generic_filter_query::<Added<T>>(&mut world);
(world, query)
},
|(ref mut world, ref mut query)| {
|(world, query)| {
let mut count = 0;
for entity in query.iter(world) {
black_box(entity);
@ -143,7 +143,7 @@ fn all_changed_detection_generic<T: Component<Mutability = Mutable> + Default +
let query = generic_filter_query::<Changed<T>>(&mut world);
(world, query)
},
|(ref mut world, ref mut query)| {
|(world, query)| {
let mut count = 0;
for entity in query.iter(world) {
black_box(entity);
@ -196,7 +196,7 @@ fn few_changed_detection_generic<T: Component<Mutability = Mutable> + Default +
let query = generic_filter_query::<Changed<T>>(&mut world);
(world, query)
},
|(ref mut world, ref mut query)| {
|(world, query)| {
for entity in query.iter(world) {
black_box(entity);
}
@ -237,7 +237,7 @@ fn none_changed_detection_generic<T: Component<Mutability = Mutable> + Default>(
let query = generic_filter_query::<Changed<T>>(&mut world);
(world, query)
},
|(ref mut world, ref mut query)| {
|(world, query)| {
let mut count = 0;
for entity in query.iter(world) {
black_box(entity);
@ -343,7 +343,7 @@ fn multiple_archetype_none_changed_detection_generic<
let query = generic_filter_query::<Changed<T>>(&mut world);
(world, query)
},
|(ref mut world, ref mut query)| {
|(world, query)| {
let mut count = 0;
for entity in query.iter(world) {
black_box(entity);

View File

@ -12,7 +12,7 @@ impl Benchmark {
let mut world = World::default();
let entities = world
.spawn_batch(core::iter::repeat(A(0.)).take(10000))
.spawn_batch(core::iter::repeat_n(A(0.), 10_000))
.collect();
Self(world, entities)
}

View File

@ -19,15 +19,15 @@ impl<'w> Benchmark<'w> {
pub fn new() -> Self {
let mut world = World::new();
world.spawn_batch(
core::iter::repeat((
world.spawn_batch(core::iter::repeat_n(
(
Transform(Mat4::from_scale(Vec3::ONE)),
Position(Vec3::X),
Rotation(Vec3::X),
Velocity(Vec3::X),
))
.take(10_000),
);
),
10_000,
));
let query = world.query::<(&Velocity, &mut Position)>();
Self(world, query)

View File

@ -19,15 +19,15 @@ impl<'w> Benchmark<'w> {
pub fn new() -> Self {
let mut world = World::new();
world.spawn_batch(
core::iter::repeat((
world.spawn_batch(core::iter::repeat_n(
(
Transform(Mat4::from_scale(Vec3::ONE)),
Position(Vec3::X),
Rotation(Vec3::X),
Velocity(Vec3::X),
))
.take(10_000),
);
),
10_000,
));
let query = world.query::<(&Velocity, &mut Position)>();
Self(world, query)

View File

@ -21,15 +21,15 @@ impl<'w> Benchmark<'w> {
pub fn new() -> Self {
let mut world = World::new();
world.spawn_batch(
core::iter::repeat((
world.spawn_batch(core::iter::repeat_n(
(
Transform(Mat4::from_scale(Vec3::ONE)),
Position(Vec3::X),
Rotation(Vec3::X),
Velocity(Vec3::X),
))
.take(10_000),
);
),
10_000,
));
let query = world.query::<(&Velocity, &mut Position)>();
Self(world, query)

View File

@ -33,8 +33,8 @@ impl<'w> Benchmark<'w> {
pub fn new() -> Self {
let mut world = World::new();
world.spawn_batch(
core::iter::repeat((
world.spawn_batch(core::iter::repeat_n(
(
Transform(Mat4::from_scale(Vec3::ONE)),
Rotation(Vec3::X),
Position::<0>(Vec3::X),
@ -47,9 +47,9 @@ impl<'w> Benchmark<'w> {
Velocity::<3>(Vec3::X),
Position::<4>(Vec3::X),
Velocity::<4>(Vec3::X),
))
.take(10_000),
);
),
10_000,
));
let query = world.query();
Self(world, query)

View File

@ -35,8 +35,8 @@ impl<'w> Benchmark<'w> {
pub fn new() -> Self {
let mut world = World::new();
world.spawn_batch(
core::iter::repeat((
world.spawn_batch(core::iter::repeat_n(
(
Transform(Mat4::from_scale(Vec3::ONE)),
Rotation(Vec3::X),
Position::<0>(Vec3::X),
@ -49,9 +49,9 @@ impl<'w> Benchmark<'w> {
Velocity::<3>(Vec3::X),
Position::<4>(Vec3::X),
Velocity::<4>(Vec3::X),
))
.take(10_000),
);
),
10_000,
));
let query = world.query();
Self(world, query)

View File

@ -21,15 +21,15 @@ impl<'w> Benchmark<'w> {
pub fn new() -> Self {
let mut world = World::new();
world.spawn_batch(
core::iter::repeat((
world.spawn_batch(core::iter::repeat_n(
(
Transform(Mat4::from_scale(Vec3::ONE)),
Position(Vec3::X),
Rotation(Vec3::X),
Velocity(Vec3::X),
))
.take(10_000),
);
),
10_000,
));
let query = world.query::<(&Velocity, &mut Position)>();
Self(world, query)

View File

@ -19,15 +19,15 @@ impl Benchmark {
pub fn new() -> Self {
let mut world = World::new();
world.spawn_batch(
core::iter::repeat((
world.spawn_batch(core::iter::repeat_n(
(
Transform(Mat4::from_scale(Vec3::ONE)),
Position(Vec3::X),
Rotation(Vec3::X),
Velocity(Vec3::X),
))
.take(10_000),
);
),
10_000,
));
fn query_system(mut query: Query<(&Velocity, &mut Position)>) {
for (velocity, mut position) in &mut query {

View File

@ -33,8 +33,8 @@ impl<'w> Benchmark<'w> {
pub fn new() -> Self {
let mut world = World::new();
world.spawn_batch(
core::iter::repeat((
world.spawn_batch(core::iter::repeat_n(
(
Transform(Mat4::from_scale(Vec3::ONE)),
Rotation(Vec3::X),
Position::<0>(Vec3::X),
@ -47,9 +47,9 @@ impl<'w> Benchmark<'w> {
Velocity::<3>(Vec3::X),
Position::<4>(Vec3::X),
Velocity::<4>(Vec3::X),
))
.take(10_000),
);
),
10_000,
));
let query = world.query();
Self(world, query)

View File

@ -35,8 +35,8 @@ impl<'w> Benchmark<'w> {
pub fn new() -> Self {
let mut world = World::new();
world.spawn_batch(
core::iter::repeat((
world.spawn_batch(core::iter::repeat_n(
(
Transform(Mat4::from_scale(Vec3::ONE)),
Rotation(Vec3::X),
Position::<0>(Vec3::X),
@ -49,9 +49,9 @@ impl<'w> Benchmark<'w> {
Velocity::<3>(Vec3::X),
Position::<4>(Vec3::X),
Velocity::<4>(Vec3::X),
))
.take(10_000),
);
),
10_000,
));
let query = world.query();
Self(world, query)

View File

@ -30,15 +30,15 @@ impl<'w> Benchmark<'w> {
let mut world = World::new();
let iter = world.spawn_batch(
core::iter::repeat((
let iter = world.spawn_batch(core::iter::repeat_n(
(
Transform(Mat4::from_scale(Vec3::ONE)),
Position(Vec3::X),
Rotation(Vec3::X),
Velocity(Vec3::X),
))
.take(100_000),
);
),
100_000,
));
let entities = iter.into_iter().collect::<Vec<Entity>>();
for i in 0..fragment {
let mut e = world.entity_mut(entities[i as usize]);

View File

@ -11,16 +11,16 @@ fn make_entity(rng: &mut impl Rng, size: usize) -> Entity {
// * For ids, half are in [0, size), half are unboundedly larger.
// * For generations, half are in [1, 3), half are unboundedly larger.
let x: f64 = rng.gen();
let x: f64 = rng.r#gen();
let id = -(1.0 - x).log2() * (size as f64);
let x: f64 = rng.gen();
let gen = 1.0 + -(1.0 - x).log2() * 2.0;
let x: f64 = rng.r#gen();
let generation = 1.0 + -(1.0 - x).log2() * 2.0;
// this is not reliable, but we're internal so a hack is ok
let bits = ((gen as u64) << 32) | (id as u64);
let bits = ((generation as u64) << 32) | (id as u64);
let e = Entity::from_bits(bits);
assert_eq!(e.index(), id as u32);
assert_eq!(e.generation(), gen as u32);
assert_eq!(e.generation(), generation as u32);
e
}

View File

@ -75,8 +75,8 @@ fn concrete_list_apply(criterion: &mut Criterion) {
let mut group = create_group(criterion, bench!("concrete_list_apply"));
let empty_base = |_: usize| Vec::<u64>::new;
let full_base = |size: usize| move || iter::repeat(0).take(size).collect::<Vec<u64>>();
let patch = |size: usize| iter::repeat(1).take(size).collect::<Vec<u64>>();
let full_base = |size: usize| move || iter::repeat_n(0, size).collect::<Vec<u64>>();
let patch = |size: usize| iter::repeat_n(1, size).collect::<Vec<u64>>();
list_apply(&mut group, "empty_base_concrete_patch", empty_base, patch);
@ -103,7 +103,7 @@ fn concrete_list_clone_dynamic(criterion: &mut Criterion) {
BenchmarkId::from_parameter(size),
&size,
|bencher, &size| {
let v = iter::repeat(0).take(size).collect::<Vec<_>>();
let v = iter::repeat_n(0, size).collect::<Vec<_>>();
bencher.iter(|| black_box(&v).clone_dynamic());
},
@ -123,7 +123,7 @@ fn dynamic_list_push(criterion: &mut Criterion) {
BenchmarkId::from_parameter(size),
&size,
|bencher, &size| {
let src = iter::repeat(()).take(size).collect::<Vec<_>>();
let src = iter::repeat_n((), size).collect::<Vec<_>>();
let dst = DynamicList::default();
bencher.iter_batched(
@ -146,8 +146,8 @@ fn dynamic_list_apply(criterion: &mut Criterion) {
let mut group = create_group(criterion, bench!("dynamic_list_apply"));
let empty_base = |_: usize| || Vec::<u64>::new().clone_dynamic();
let full_base = |size: usize| move || iter::repeat(0).take(size).collect::<Vec<u64>>();
let patch = |size: usize| iter::repeat(1).take(size).collect::<Vec<u64>>();
let full_base = |size: usize| move || iter::repeat_n(0, size).collect::<Vec<u64>>();
let patch = |size: usize| iter::repeat_n(1, size).collect::<Vec<u64>>();
list_apply(&mut group, "empty_base_concrete_patch", empty_base, patch);

View File

@ -145,7 +145,7 @@ fn u64_to_n_byte_key(k: u64, n: usize) -> String {
write!(&mut key, "{}", k).unwrap();
// Pad key to n bytes.
key.extend(iter::repeat('\0').take(n - key.len()));
key.extend(iter::repeat_n('\0', n - key.len()));
key
}

View File

@ -1,7 +1,7 @@
[package]
name = "bevy_a11y"
version = "0.16.0-dev"
edition = "2021"
edition = "2024"
description = "Provides accessibility support for Bevy Engine"
homepage = "https://bevyengine.org"
repository = "https://github.com/bevyengine/bevy"

View File

@ -1,7 +1,7 @@
[package]
name = "bevy_animation"
version = "0.16.0-dev"
edition = "2021"
edition = "2024"
description = "Provides animation functionality for Bevy Engine"
homepage = "https://bevyengine.org"
repository = "https://github.com/bevyengine/bevy"

View File

@ -884,10 +884,10 @@ impl ThreadedAnimationGraph {
self.sorted_edge_ranges.clear();
self.sorted_edge_ranges
.extend(iter::repeat(0..0).take(node_count));
.extend(iter::repeat_n(0..0, node_count));
self.computed_masks.clear();
self.computed_masks.extend(iter::repeat(0).take(node_count));
self.computed_masks.extend(iter::repeat_n(0, node_count));
}
/// Recursively constructs the [`ThreadedAnimationGraph`] for the subtree

View File

@ -1,7 +1,7 @@
[package]
name = "bevy_app"
version = "0.16.0-dev"
edition = "2021"
edition = "2024"
description = "Provides core App functionality for Bevy Engine"
homepage = "https://bevyengine.org"
repository = "https://github.com/bevyengine/bevy"

View File

@ -1435,7 +1435,7 @@ impl Termination for AppExit {
#[cfg(test)]
mod tests {
use core::{iter, marker::PhantomData};
use core::marker::PhantomData;
use std::sync::Mutex;
use bevy_ecs::{
@ -1659,7 +1659,7 @@ mod tests {
struct Foo;
let mut app = App::new();
app.world_mut().spawn_batch(iter::repeat(Foo).take(5));
app.world_mut().spawn_batch(core::iter::repeat_n(Foo, 5));
fn despawn_one_foo(mut commands: Commands, foos: Query<Entity, With<Foo>>) {
if let Some(e) = foos.iter().next() {

View File

@ -1,7 +1,7 @@
[package]
name = "bevy_asset"
version = "0.16.0-dev"
edition = "2021"
edition = "2024"
description = "Provides asset functionality for Bevy Engine"
homepage = "https://bevyengine.org"
repository = "https://github.com/bevyengine/bevy"

View File

@ -1,7 +1,7 @@
[package]
name = "bevy_asset_macros"
version = "0.16.0-dev"
edition = "2021"
edition = "2024"
description = "Derive implementations for bevy_asset"
homepage = "https://bevyengine.org"
repository = "https://github.com/bevyengine/bevy"

View File

@ -552,8 +552,8 @@ impl<'a> LoadContext<'a> {
let path = path.into();
let source = self.asset_server.get_source(path.source())?;
let asset_reader = match self.asset_server.mode() {
AssetServerMode::Unprocessed { .. } => source.reader(),
AssetServerMode::Processed { .. } => source.processed_reader()?,
AssetServerMode::Unprocessed => source.reader(),
AssetServerMode::Processed => source.processed_reader()?,
};
let mut reader = asset_reader.read(path.path()).await?;
let hash = if self.populate_hashes {

View File

@ -207,9 +207,12 @@ impl AssetProcessor {
/// Processes all assets. This will:
/// * For each "processed [`AssetSource`]:
/// * Scan the [`ProcessorTransactionLog`] and recover from any failures detected
/// * Scan the processed [`AssetReader`](crate::io::AssetReader) to build the current view of already processed assets.
/// * Scan the unprocessed [`AssetReader`](crate::io::AssetReader) and remove any final processed assets that are invalid or no longer exist.
/// * For each asset in the unprocessed [`AssetReader`](crate::io::AssetReader), kick off a new "process job", which will process the asset
/// * Scan the processed [`AssetReader`](crate::io::AssetReader) to build the current view of
/// already processed assets.
/// * Scan the unprocessed [`AssetReader`](crate::io::AssetReader) and remove any final
/// processed assets that are invalid or no longer exist.
/// * For each asset in the unprocessed [`AssetReader`](crate::io::AssetReader), kick off a new
/// "process job", which will process the asset
/// (if the latest version of the asset has not been processed).
#[cfg(all(not(target_arch = "wasm32"), feature = "multi_threaded"))]
pub fn process_assets(&self) {

View File

@ -38,12 +38,13 @@ use std::path::{Path, PathBuf};
use thiserror::Error;
use tracing::{error, info};
/// Loads and tracks the state of [`Asset`] values from a configured [`AssetReader`](crate::io::AssetReader). This can be used to kick off new asset loads and
/// retrieve their current load states.
/// Loads and tracks the state of [`Asset`] values from a configured [`AssetReader`](crate::io::AssetReader).
/// This can be used to kick off new asset loads and retrieve their current load states.
///
/// The general process to load an asset is:
/// 1. Initialize a new [`Asset`] type with the [`AssetServer`] via [`AssetApp::init_asset`], which will internally call [`AssetServer::register_asset`]
/// and set up related ECS [`Assets`] storage and systems.
/// 1. Initialize a new [`Asset`] type with the [`AssetServer`] via [`AssetApp::init_asset`], which
/// will internally call [`AssetServer::register_asset`] and set up related ECS [`Assets`]
/// storage and systems.
/// 2. Register one or more [`AssetLoader`]s for that asset with [`AssetApp::init_asset_loader`]
/// 3. Add the asset to your asset folder (defaults to `assets`).
/// 4. Call [`AssetServer::load`] with a path to your asset.
@ -923,8 +924,8 @@ impl AssetServer {
};
let asset_reader = match server.data.mode {
AssetServerMode::Unprocessed { .. } => source.reader(),
AssetServerMode::Processed { .. } => match source.processed_reader() {
AssetServerMode::Unprocessed => source.reader(),
AssetServerMode::Processed => match source.processed_reader() {
Ok(reader) => reader,
Err(_) => {
error!(
@ -1235,8 +1236,8 @@ impl AssetServer {
// Then the meta reader, if meta exists, will correspond to the meta for the current "version" of the asset.
// See ProcessedAssetInfo::file_transaction_lock for more context
let asset_reader = match self.data.mode {
AssetServerMode::Unprocessed { .. } => source.reader(),
AssetServerMode::Processed { .. } => source.processed_reader()?,
AssetServerMode::Unprocessed => source.reader(),
AssetServerMode::Processed => source.processed_reader()?,
};
let reader = asset_reader.read(asset_path.path()).await?;
let read_meta = match &self.data.meta_check {
@ -1584,14 +1585,14 @@ pub fn handle_internal_asset_events(world: &mut World) {
for source in server.data.sources.iter() {
match server.data.mode {
AssetServerMode::Unprocessed { .. } => {
AssetServerMode::Unprocessed => {
if let Some(receiver) = source.event_receiver() {
for event in receiver.try_iter() {
handle_event(source.id(), event);
}
}
}
AssetServerMode::Processed { .. } => {
AssetServerMode::Processed => {
if let Some(receiver) = source.processed_event_receiver() {
for event in receiver.try_iter() {
handle_event(source.id(), event);

View File

@ -1,7 +1,7 @@
[package]
name = "bevy_audio"
version = "0.16.0-dev"
edition = "2021"
edition = "2024"
description = "Provides audio functionality for Bevy Engine"
homepage = "https://bevyengine.org"
repository = "https://github.com/bevyengine/bevy"

View File

@ -1,13 +1,13 @@
[package]
name = "bevy_color"
version = "0.16.0-dev"
edition = "2021"
edition = "2024"
description = "Types for representing and manipulating color values"
homepage = "https://bevyengine.org"
repository = "https://github.com/bevyengine/bevy"
license = "MIT OR Apache-2.0"
keywords = ["bevy", "color"]
rust-version = "1.83.0"
rust-version = "1.85.0"
[dependencies]
bevy_math = { path = "../bevy_math", version = "0.16.0-dev", default-features = false, features = [

View File

@ -1,7 +1,7 @@
[package]
name = "gen_tests"
version = "0.1.0"
edition = "2021"
edition = "2024"
publish = false
[workspace]

View File

@ -1,7 +1,7 @@
[package]
name = "bevy_core_pipeline"
version = "0.16.0-dev"
edition = "2021"
edition = "2024"
authors = [
"Bevy Contributors <bevyengine@gmail.com>",
"Carter Anderson <mcanders1@gmail.com>",

View File

@ -152,7 +152,8 @@ impl ViewNode for BloomNode {
render_context.command_encoder().push_debug_group("bloom");
let diagnostics = render_context.diagnostic_recorder();
let time_span = diagnostics.time_span(render_context.command_encoder(), "bloom");
let command_encoder = render_context.command_encoder();
let time_span = diagnostics.time_span(command_encoder, "bloom");
// First downsample pass
{

View File

@ -1,7 +1,7 @@
[package]
name = "bevy_derive"
version = "0.16.0-dev"
edition = "2021"
edition = "2024"
description = "Provides derive implementations for Bevy Engine"
homepage = "https://bevyengine.org"
repository = "https://github.com/bevyengine/bevy"

View File

@ -1,6 +1,6 @@
[package]
name = "bevy_derive_compile_fail"
edition = "2021"
edition = "2024"
description = "Compile fail tests for Bevy Engine's various macros"
homepage = "https://bevyengine.org"
repository = "https://github.com/bevyengine/bevy"

View File

@ -10,14 +10,20 @@ pub fn bevy_main(_attr: TokenStream, item: TokenStream) -> TokenStream {
);
TokenStream::from(quote! {
#[no_mangle]
// SAFETY: `#[bevy_main]` should only be placed on a single `main` function
// TODO: Potentially make `bevy_main` and unsafe attribute as there is a safety
// guarantee required from the caller.
#[unsafe(no_mangle)]
#[cfg(target_os = "android")]
fn android_main(android_app: bevy::window::android_activity::AndroidApp) {
let _ = bevy::window::ANDROID_APP.set(android_app);
main();
}
#[no_mangle]
// SAFETY: `#[bevy_main]` should only be placed on a single `main` function
// TODO: Potentially make `bevy_main` and unsafe attribute as there is a safety
// guarantee required from the caller.
#[unsafe(no_mangle)]
#[cfg(target_os = "ios")]
extern "C" fn main_rs() {
main();

View File

@ -1,7 +1,7 @@
[package]
name = "bevy_dev_tools"
version = "0.16.0-dev"
edition = "2021"
edition = "2024"
description = "Collection of developer tools for the Bevy Engine"
homepage = "https://bevyengine.org"
repository = "https://github.com/bevyengine/bevy"

View File

@ -1,7 +1,7 @@
[package]
name = "bevy_diagnostic"
version = "0.16.0-dev"
edition = "2021"
edition = "2024"
description = "Provides diagnostic functionality for Bevy Engine"
homepage = "https://bevyengine.org"
repository = "https://github.com/bevyengine/bevy"

View File

@ -1,7 +1,7 @@
[package]
name = "bevy_dylib"
version = "0.16.0-dev"
edition = "2021"
edition = "2024"
description = "Force the Bevy Engine to be dynamically linked for faster linking"
homepage = "https://bevyengine.org"
repository = "https://github.com/bevyengine/bevy"

View File

@ -1,14 +1,14 @@
[package]
name = "bevy_ecs"
version = "0.16.0-dev"
edition = "2021"
edition = "2024"
description = "Bevy Engine's entity component system"
homepage = "https://bevyengine.org"
repository = "https://github.com/bevyengine/bevy"
license = "MIT OR Apache-2.0"
keywords = ["ecs", "game", "bevy"]
categories = ["game-engines", "data-structures"]
rust-version = "1.83.0"
rust-version = "1.85.0"
[features]
default = ["std", "bevy_reflect", "async_executor"]

View File

@ -1,6 +1,6 @@
[package]
name = "bevy_ecs_compile_fail"
edition = "2021"
edition = "2024"
description = "Compile fail tests for Bevy Engine's entity component system"
homepage = "https://bevyengine.org"
repository = "https://github.com/bevyengine/bevy"

View File

@ -2,7 +2,7 @@
name = "bevy_ecs_macros"
version = "0.16.0-dev"
description = "Bevy ECS Macros"
edition = "2021"
edition = "2024"
license = "MIT OR Apache-2.0"
[lib]

View File

@ -257,7 +257,7 @@ pub fn derive_component(input: TokenStream) -> TokenStream {
fn visit_entities(data: &Data, bevy_ecs_path: &Path, is_relationship: bool) -> TokenStream2 {
match data {
Data::Struct(DataStruct { ref fields, .. }) => {
Data::Struct(DataStruct { fields, .. }) => {
let mut visited_fields = Vec::new();
let mut visited_indices = Vec::new();
match fields {
@ -343,8 +343,8 @@ fn visit_entities(data: &Data, bevy_ecs_path: &Path, is_relationship: bool) -> T
let field_member = ident_or_index(field.ident.as_ref(), index);
let field_ident = format_ident!("field_{}", field_member);
variant_fields.push(quote!(#field_member: ref #field_ident));
variant_fields_mut.push(quote!(#field_member: ref mut #field_ident));
variant_fields.push(quote!(#field_member: #field_ident));
variant_fields_mut.push(quote!(#field_member: #field_ident));
visit_variant_fields.push(quote!(#field_ident.visit_entities(&mut func);));
visit_variant_fields_mut

View File

@ -1280,7 +1280,6 @@ impl<T: TrustedEntityBorrow> IndexMut<RangeToInclusive<usize>> for UniqueEntityS
/// the [`IntoIterator`] impls on it and [`UniqueEntityVec`].
///
/// [`iter`]: `UniqueEntitySlice::iter`
/// [`into_iter`]: UniqueEntitySlice::into_iter
pub type Iter<'a, T> = UniqueEntityIter<slice::Iter<'a, T>>;
impl<'a, T: TrustedEntityBorrow> UniqueEntityIter<slice::Iter<'a, T>> {

View File

@ -809,7 +809,7 @@ impl<T: TrustedEntityBorrow> Extend<T> for UniqueEntityVec<T> {
let reserve = if self.is_empty() {
iter.size_hint().0
} else {
(iter.size_hint().0 + 1) / 2
iter.size_hint().0.div_ceil(2)
};
self.reserve(reserve);
// Internal iteration (fold/for_each) is known to result in better code generation
@ -836,7 +836,7 @@ impl<'a, T: TrustedEntityBorrow + Copy + 'a> Extend<&'a T> for UniqueEntityVec<T
let reserve = if self.is_empty() {
iter.size_hint().0
} else {
(iter.size_hint().0 + 1) / 2
iter.size_hint().0.div_ceil(2)
};
self.reserve(reserve);
// Internal iteration (fold/for_each) is known to result in better code generation

View File

@ -2,13 +2,6 @@
unsafe_op_in_unsafe_fn,
reason = "See #11590. To be removed once all applicable unsafe code has an unsafe block with a safety comment."
)]
#![cfg_attr(
test,
expect(
dependency_on_unit_never_type_fallback,
reason = "See #17340. To be removed once Edition 2024 is released"
)
)]
#![doc = include_str!("../README.md")]
#![cfg_attr(
any(docsrs, docsrs_dep),

View File

@ -1115,11 +1115,10 @@ mod tests {
fn observer_despawn() {
let mut world = World::new();
let observer = world
.add_observer(|_: Trigger<OnAdd, A>| {
panic!("Observer triggered after being despawned.")
})
.id();
let system: fn(Trigger<OnAdd, A>) = |_| {
panic!("Observer triggered after being despawned.");
};
let observer = world.add_observer(system).id();
world.despawn(observer);
world.spawn(A).flush();
}
@ -1136,11 +1135,11 @@ mod tests {
res.observed("remove_a");
});
let observer = world
.add_observer(|_: Trigger<OnRemove, B>| {
panic!("Observer triggered after being despawned.")
})
.flush();
let system: fn(Trigger<OnRemove, B>) = |_: Trigger<OnRemove, B>| {
panic!("Observer triggered after being despawned.");
};
let observer = world.add_observer(system).flush();
world.despawn(observer);
world.despawn(entity);
@ -1166,9 +1165,10 @@ mod tests {
let mut world = World::new();
world.init_resource::<Order>();
world
.spawn_empty()
.observe(|_: Trigger<EventA>| panic!("Trigger routed to non-targeted entity."));
let system: fn(Trigger<EventA>) = |_| {
panic!("Trigger routed to non-targeted entity.");
};
world.spawn_empty().observe(system);
world.add_observer(move |obs: Trigger<EventA>, mut res: ResMut<Order>| {
assert_eq!(obs.target(), Entity::PLACEHOLDER);
res.observed("event_a");
@ -1187,9 +1187,11 @@ mod tests {
let mut world = World::new();
world.init_resource::<Order>();
world
.spawn_empty()
.observe(|_: Trigger<EventA>| panic!("Trigger routed to non-targeted entity."));
let system: fn(Trigger<EventA>) = |_| {
panic!("Trigger routed to non-targeted entity.");
};
world.spawn_empty().observe(system);
let entity = world
.spawn_empty()
.observe(|_: Trigger<EventA>, mut res: ResMut<Order>| res.observed("a_1"))

View File

@ -66,9 +66,7 @@ use variadics_please::all_tuples;
/// # bevy_ecs::system::assert_is_system(my_system);
/// ```
///
/// [`matches_component_set`]: Self::matches_component_set
/// [`Query`]: crate::system::Query
/// [`State`]: Self::State
///
/// # Safety
///

View File

@ -276,7 +276,7 @@ pub fn simple_cycles_in_component(graph: &DiGraph, scc: &[NodeId]) -> Vec<Vec<No
stack.clear();
stack.push((root, subgraph.neighbors(root)));
while !stack.is_empty() {
let (ref node, successors) = stack.last_mut().unwrap();
let &mut (ref node, ref mut successors) = stack.last_mut().unwrap();
if let Some(next) = successors.next() {
if next == root {
// found a cycle

View File

@ -1192,7 +1192,7 @@ mod tests {
let mut schedule = Schedule::new(TestSchedule);
schedule
.set_executor_kind($executor)
.add_systems(|| panic!("Executor ignored Stepping"));
.add_systems(|| -> () { panic!("Executor ignored Stepping") });
// Add our schedule to stepping & and enable stepping; this should
// prevent any systems in the schedule from running

View File

@ -2062,12 +2062,12 @@ mod tests {
let mut world = World::new();
let mut schedule = Schedule::default();
let system: fn() = || {
panic!("This system must not run");
};
schedule.configure_sets(Set.run_if(|| false));
schedule.add_systems(
(|| panic!("This system must not run"))
.ambiguous_with(|| ())
.in_set(Set),
);
schedule.add_systems(system.ambiguous_with(|| ()).in_set(Set));
schedule.run(&mut world);
}

View File

@ -1348,7 +1348,9 @@ mod tests {
//
// first system will be configured as `run_if(|| false)`, so it can
// just panic if called
let first_system = move || panic!("first_system should not be run");
let first_system: fn() = move || {
panic!("first_system should not be run");
};
// The second system, we need to know when it has been called, so we'll
// add a resource for tracking if it has been run. The system will

View File

@ -82,7 +82,6 @@ use crate::{
/// // NOTE: type inference fails here, so annotations are required on the closure.
/// commands.queue(|w: &mut World| {
/// // Mutate the world however you want...
/// # todo!();
/// });
/// # }
/// ```

View File

@ -1648,7 +1648,10 @@ mod tests {
#[should_panic]
fn panic_inside_system() {
let mut world = World::new();
run_system(&mut world, || panic!("this system panics"));
let system: fn() = || {
panic!("this system panics");
};
run_system(&mut world, system);
}
#[test]

View File

@ -1,7 +1,7 @@
[package]
name = "bevy_encase_derive"
version = "0.16.0-dev"
edition = "2021"
edition = "2024"
description = "Bevy derive macro for encase"
homepage = "https://bevyengine.org"
repository = "https://github.com/bevyengine/bevy"

View File

@ -1,7 +1,7 @@
[package]
name = "bevy_gilrs"
version = "0.16.0-dev"
edition = "2021"
edition = "2024"
description = "Gamepad system made using Gilrs for Bevy Engine"
homepage = "https://bevyengine.org"
repository = "https://github.com/bevyengine/bevy"

View File

@ -1,7 +1,7 @@
[package]
name = "bevy_gizmos"
version = "0.16.0-dev"
edition = "2021"
edition = "2024"
description = "Provides gizmos for Bevy Engine"
homepage = "https://bevyengine.org"
repository = "https://github.com/bevyengine/bevy"

View File

@ -1,7 +1,7 @@
[package]
name = "bevy_gizmos_macros"
version = "0.16.0-dev"
edition = "2021"
edition = "2024"
description = "Derive implementations for bevy_gizmos"
homepage = "https://bevyengine.org"
repository = "https://github.com/bevyengine/bevy"

View File

@ -820,8 +820,7 @@ where
let polymorphic_color: Color = color.into();
let linear_color = LinearRgba::from(polymorphic_color);
self.list_colors
.extend(iter::repeat(linear_color).take(count));
self.list_colors.extend(iter::repeat_n(linear_color, count));
}
#[inline]

View File

@ -187,9 +187,8 @@ where
///
/// - `isometry` defines the translation and rotation of the grid.
/// - the translation specifies the center of the grid
/// - defines the orientation of the grid, by default
/// we assume the grid is contained in a plane parallel
/// to the XY plane
/// - defines the orientation of the grid, by default we assume the grid is contained in a
/// plane parallel to the XY plane
/// - `cell_count`: defines the amount of cells in the x and y axes
/// - `spacing`: defines the distance between cells along the x and y axes
/// - `color`: color of the grid
@ -242,8 +241,7 @@ where
///
/// - `isometry` defines the translation and rotation of the grid.
/// - the translation specifies the center of the grid
/// - defines the orientation of the grid, by default
/// we assume the grid is aligned with all axes
/// - defines the orientation of the grid, by default we assume the grid is aligned with all axes
/// - `cell_count`: defines the amount of cells in the x, y and z axes
/// - `spacing`: defines the distance between cells along the x, y and z axes
/// - `color`: color of the grid
@ -296,8 +294,7 @@ where
///
/// - `isometry` defines the translation and rotation of the grid.
/// - the translation specifies the center of the grid
/// - defines the orientation of the grid, by default
/// we assume the grid is aligned with all axes
/// - defines the orientation of the grid, by default we assume the grid is aligned with all axes
/// - `cell_count`: defines the amount of cells in the x and y axes
/// - `spacing`: defines the distance between cells along the x and y axes
/// - `color`: color of the grid

View File

@ -239,9 +239,8 @@ where
///
/// - `isometry` defines the translation and rotation of the rectangle.
/// - the translation specifies the center of the rectangle
/// - defines orientation of the rectangle, by default we
/// assume the rectangle is contained in a plane parallel
/// to the XY plane.
/// - defines orientation of the rectangle, by default we assume the rectangle is contained in
/// a plane parallel to the XY plane.
/// - `size`: defines the size of the rectangle. This refers to the 'outer size', similar to a bounding box.
/// - `color`: color of the rectangle
///
@ -294,8 +293,7 @@ where
///
/// - `isometry` defines the translation and rotation of the rectangle.
/// - the translation specifies the center of the rectangle
/// - defines orientation of the rectangle, by default we
/// assume the rectangle aligned with all axes.
/// - defines orientation of the rectangle, by default we assume the rectangle aligned with all axes.
/// - `size`: defines the size of the rectangle. This refers to the 'outer size', similar to a bounding box.
/// - `color`: color of the rectangle
///
@ -352,8 +350,7 @@ where
///
/// - `isometry` defines the translation and rotation of the cuboid.
/// - the translation specifies the center of the cuboid
/// - defines orientation of the cuboid, by default we
/// assume the cuboid aligned with all axes.
/// - defines orientation of the cuboid, by default we assume the cuboid aligned with all axes.
/// - `size`: defines the size of the cuboid. This refers to the 'outer size', similar to a bounding box.
/// - `color`: color of the cuboid
///

View File

@ -1,7 +1,7 @@
[package]
name = "bevy_gltf"
version = "0.16.0-dev"
edition = "2021"
edition = "2024"
description = "Bevy Engine GLTF loading"
homepage = "https://bevyengine.org"
repository = "https://github.com/bevyengine/bevy"

View File

@ -1,7 +1,7 @@
[package]
name = "bevy_image"
version = "0.16.0-dev"
edition = "2021"
edition = "2024"
description = "Provides image types for Bevy Engine"
homepage = "https://bevyengine.org"
repository = "https://github.com/bevyengine/bevy"

View File

@ -1,7 +1,7 @@
[package]
name = "bevy_input"
version = "0.16.0-dev"
edition = "2021"
edition = "2024"
description = "Provides input functionality for Bevy Engine"
homepage = "https://bevyengine.org"
repository = "https://github.com/bevyengine/bevy"

View File

@ -1,13 +1,13 @@
[package]
name = "bevy_input_focus"
version = "0.16.0-dev"
edition = "2021"
edition = "2024"
description = "Keyboard focus management"
homepage = "https://bevyengine.org"
repository = "https://github.com/bevyengine/bevy"
license = "MIT OR Apache-2.0"
keywords = ["bevy"]
rust-version = "1.83.0"
rust-version = "1.85.0"
[features]
default = ["std", "bevy_reflect", "bevy_ecs/async_executor"]

View File

@ -1,7 +1,7 @@
[package]
name = "bevy_internal"
version = "0.16.0-dev"
edition = "2021"
edition = "2024"
description = "An internal Bevy crate used to facilitate optional dynamic linking via the 'dynamic_linking' feature"
homepage = "https://bevyengine.org"
repository = "https://github.com/bevyengine/bevy"

View File

@ -1,7 +1,7 @@
[package]
name = "bevy_log"
version = "0.16.0-dev"
edition = "2021"
edition = "2024"
description = "Provides logging for Bevy Engine"
homepage = "https://bevyengine.org"
repository = "https://github.com/bevyengine/bevy"

View File

@ -117,7 +117,10 @@ pub(crate) struct FlushGuard(SyncCell<tracing_chrome::FlushGuard>);
/// # use bevy_app::{App, NoopPluginGroup as DefaultPlugins, PluginGroup};
/// # use bevy_log::LogPlugin;
/// fn main() {
/// # // SAFETY: Single-threaded
/// # unsafe {
/// std::env::set_var("NO_COLOR", "1");
/// # }
/// App::new()
/// .add_plugins(DefaultPlugins)
/// .run();

View File

@ -1,7 +1,7 @@
[package]
name = "bevy_macro_utils"
version = "0.16.0-dev"
edition = "2021"
edition = "2024"
description = "A collection of utils for Bevy Engine"
homepage = "https://bevyengine.org"
repository = "https://github.com/bevyengine/bevy"

View File

@ -1,13 +1,13 @@
[package]
name = "bevy_math"
version = "0.16.0-dev"
edition = "2021"
edition = "2024"
description = "Provides math functionality for Bevy Engine"
homepage = "https://bevyengine.org"
repository = "https://github.com/bevyengine/bevy"
license = "MIT OR Apache-2.0"
keywords = ["bevy"]
rust-version = "1.83.0"
rust-version = "1.85.0"
[dependencies]
glam = { version = "0.29", default-features = false, features = ["bytemuck"] }

View File

@ -746,10 +746,9 @@ impl<P: VectorSpace> CubicNurbs<P> {
}
let last_knots_value = control_points - 3;
Some(
core::iter::repeat(0.0)
.take(4)
core::iter::repeat_n(0.0, 4)
.chain((1..last_knots_value).map(|v| v as f32))
.chain(core::iter::repeat(last_knots_value as f32).take(4))
.chain(core::iter::repeat_n(last_knots_value as f32, 4))
.collect(),
)
}

View File

@ -234,7 +234,7 @@ impl ShapeSample for Rectangle {
fn sample_boundary<R: Rng + ?Sized>(&self, rng: &mut R) -> Vec2 {
let primary_side = rng.gen_range(-1.0..1.0);
let other_side = if rng.gen() { -1.0 } else { 1.0 };
let other_side = if rng.r#gen() { -1.0 } else { 1.0 };
if self.half_size.x + self.half_size.y > 0.0 {
if rng.gen_bool((self.half_size.x / (self.half_size.x + self.half_size.y)) as f64) {
@ -261,7 +261,7 @@ impl ShapeSample for Cuboid {
fn sample_boundary<R: Rng + ?Sized>(&self, rng: &mut R) -> Vec3 {
let primary_side1 = rng.gen_range(-1.0..1.0);
let primary_side2 = rng.gen_range(-1.0..1.0);
let other_side = if rng.gen() { -1.0 } else { 1.0 };
let other_side = if rng.r#gen() { -1.0 } else { 1.0 };
if let Ok(dist) = WeightedIndex::new([
self.half_size.y * self.half_size.z,
@ -425,7 +425,7 @@ impl ShapeSample for Cylinder {
if self.radius + 2.0 * self.half_height > 0.0 {
if rng.gen_bool((self.radius / (self.radius + 2.0 * self.half_height)) as f64) {
let Vec2 { x, y: z } = self.base().sample_interior(rng);
if rng.gen() {
if rng.r#gen() {
Vec3::new(x, self.half_height, z)
} else {
Vec3::new(x, -self.half_height, z)

View File

@ -12,7 +12,7 @@
//! let random_direction1: Dir3 = random();
//!
//! // Random direction using the rng constructed above
//! let random_direction2: Dir3 = rng.gen();
//! let random_direction2: Dir3 = rng.r#gen();
//!
//! // The same as the previous but with different syntax
//! let random_direction3 = Dir3::from_rng(&mut rng);
@ -49,7 +49,7 @@ where
{
/// Construct a value of this type uniformly at random using `rng` as the source of randomness.
fn from_rng<R: Rng + ?Sized>(rng: &mut R) -> Self {
rng.gen()
rng.r#gen()
}
}

View File

@ -1,7 +1,7 @@
[package]
name = "bevy_mesh"
version = "0.16.0-dev"
edition = "2021"
edition = "2024"
description = "Provides mesh types for Bevy Engine"
homepage = "https://bevyengine.org"
repository = "https://github.com/bevyengine/bevy"

View File

@ -881,7 +881,7 @@ impl Mesh {
"mesh transform scale cannot be zero on more than one axis"
);
if let Some(VertexAttributeValues::Float32x3(ref mut positions)) =
if let Some(VertexAttributeValues::Float32x3(positions)) =
self.attribute_mut(Mesh::ATTRIBUTE_POSITION)
{
// Apply scale, rotation, and translation to vertex positions
@ -898,7 +898,7 @@ impl Mesh {
return;
}
if let Some(VertexAttributeValues::Float32x3(ref mut normals)) =
if let Some(VertexAttributeValues::Float32x3(normals)) =
self.attribute_mut(Mesh::ATTRIBUTE_NORMAL)
{
// Transform normals, taking into account non-uniform scaling and rotation
@ -909,7 +909,7 @@ impl Mesh {
});
}
if let Some(VertexAttributeValues::Float32x3(ref mut tangents)) =
if let Some(VertexAttributeValues::Float32x3(tangents)) =
self.attribute_mut(Mesh::ATTRIBUTE_TANGENT)
{
// Transform tangents, taking into account non-uniform scaling and rotation
@ -936,7 +936,7 @@ impl Mesh {
return;
}
if let Some(VertexAttributeValues::Float32x3(ref mut positions)) =
if let Some(VertexAttributeValues::Float32x3(positions)) =
self.attribute_mut(Mesh::ATTRIBUTE_POSITION)
{
// Apply translation to vertex positions
@ -958,7 +958,7 @@ impl Mesh {
///
/// `Aabb` of entities with modified mesh are not updated automatically.
pub fn rotate_by(&mut self, rotation: Quat) {
if let Some(VertexAttributeValues::Float32x3(ref mut positions)) =
if let Some(VertexAttributeValues::Float32x3(positions)) =
self.attribute_mut(Mesh::ATTRIBUTE_POSITION)
{
// Apply rotation to vertex positions
@ -972,7 +972,7 @@ impl Mesh {
return;
}
if let Some(VertexAttributeValues::Float32x3(ref mut normals)) =
if let Some(VertexAttributeValues::Float32x3(normals)) =
self.attribute_mut(Mesh::ATTRIBUTE_NORMAL)
{
// Transform normals
@ -981,7 +981,7 @@ impl Mesh {
});
}
if let Some(VertexAttributeValues::Float32x3(ref mut tangents)) =
if let Some(VertexAttributeValues::Float32x3(tangents)) =
self.attribute_mut(Mesh::ATTRIBUTE_TANGENT)
{
// Transform tangents
@ -1010,7 +1010,7 @@ impl Mesh {
"mesh transform scale cannot be zero on more than one axis"
);
if let Some(VertexAttributeValues::Float32x3(ref mut positions)) =
if let Some(VertexAttributeValues::Float32x3(positions)) =
self.attribute_mut(Mesh::ATTRIBUTE_POSITION)
{
// Apply scale to vertex positions
@ -1024,7 +1024,7 @@ impl Mesh {
return;
}
if let Some(VertexAttributeValues::Float32x3(ref mut normals)) =
if let Some(VertexAttributeValues::Float32x3(normals)) =
self.attribute_mut(Mesh::ATTRIBUTE_NORMAL)
{
// Transform normals, taking into account non-uniform scaling
@ -1033,7 +1033,7 @@ impl Mesh {
});
}
if let Some(VertexAttributeValues::Float32x3(ref mut tangents)) =
if let Some(VertexAttributeValues::Float32x3(tangents)) =
self.attribute_mut(Mesh::ATTRIBUTE_TANGENT)
{
// Transform tangents, taking into account non-uniform scaling
@ -1096,7 +1096,7 @@ impl Mesh {
/// Normalize joint weights so they sum to 1.
pub fn normalize_joint_weights(&mut self) {
if let Some(joints) = self.attribute_mut(Self::ATTRIBUTE_JOINT_WEIGHT) {
let VertexAttributeValues::Float32x4(ref mut joints) = joints else {
let VertexAttributeValues::Float32x4(joints) = joints else {
panic!("unexpected joint weight format");
};

View File

@ -5,7 +5,6 @@ use bevy_image::Image;
use bevy_math::Vec3;
use bevy_reflect::prelude::*;
use bytemuck::{Pod, Zeroable};
use core::iter;
use thiserror::Error;
use wgpu_types::{Extent3d, TextureDimension, TextureFormat};
@ -77,7 +76,7 @@ impl MorphTargetImage {
buffer.extend_from_slice(bytemuck::bytes_of(&to_add));
}
// Pad each layer so that they fit width * height
buffer.extend(iter::repeat(0).take(padding as usize * size_of::<f32>()));
buffer.extend(core::iter::repeat_n(0, padding as usize * size_of::<f32>()));
debug_assert_eq!(buffer.len(), layer_byte_count);
buffer
})

View File

@ -1,7 +1,7 @@
[package]
name = "bevy_mikktspace"
version = "0.16.0-dev"
edition = "2021"
edition = "2024"
authors = [
"Benjamin Wasty <benny.wasty@gmail.com>",
"David Harvey-Macaulay <alteous@outlook.com>",
@ -13,7 +13,7 @@ homepage = "https://bevyengine.org"
repository = "https://github.com/bevyengine/bevy"
license = "Zlib AND (MIT OR Apache-2.0)"
keywords = ["bevy", "3D", "graphics", "algorithm", "tangent"]
rust-version = "1.76.0"
rust-version = "1.85.0"
[features]
default = ["std"]

View File

@ -1,6 +1,10 @@
//! This example demonstrates how to generate a mesh.
#![allow(clippy::bool_assert_comparison, clippy::useless_conversion)]
#![allow(
clippy::bool_assert_comparison,
clippy::useless_conversion,
reason = "Crate auto-generated with many non-idiomatic decisions. See #7372 for details."
)]
use glam::{Vec2, Vec3};

View File

@ -2,7 +2,8 @@
#![expect(
clippy::bool_assert_comparison,
clippy::semicolon_if_nothing_returned,
clippy::useless_conversion
clippy::useless_conversion,
reason = "Crate auto-generated with many non-idiomatic decisions. See #7372 for details."
)]
use bevy_mikktspace::{generate_tangents, Geometry};

View File

@ -1,7 +1,7 @@
[package]
name = "bevy_pbr"
version = "0.16.0-dev"
edition = "2021"
edition = "2024"
description = "Adds PBR rendering to Bevy Engine"
homepage = "https://bevyengine.org"
repository = "https://github.com/bevyengine/bevy"

View File

@ -496,7 +496,7 @@ pub(crate) fn assign_objects_to_clusters(
// initialize empty cluster bounding spheres
cluster_aabb_spheres.clear();
cluster_aabb_spheres.extend(core::iter::repeat(None).take(cluster_count));
cluster_aabb_spheres.extend(core::iter::repeat_n(None, cluster_count));
// Calculate the x/y/z cluster frustum planes in view space
let mut x_planes = Vec::with_capacity(clusters.dimensions.x as usize + 1);
@ -845,7 +845,7 @@ pub(crate) fn assign_objects_to_clusters(
}
}
ClusterableObjectType::Decal { .. } => {
ClusterableObjectType::Decal => {
// Decals currently affect all clusters in their
// bounding sphere.
//

View File

@ -1229,8 +1229,8 @@ impl<M: Material> RenderAsset for PreparedMaterial<M> {
render_device,
pipeline,
default_opaque_render_method,
ref mut bind_group_allocator,
ref mut render_material_bindings,
bind_group_allocator,
render_material_bindings,
opaque_draw_functions,
alpha_mask_draw_functions,
transmissive_draw_functions,
@ -1239,7 +1239,7 @@ impl<M: Material> RenderAsset for PreparedMaterial<M> {
alpha_mask_prepass_draw_functions,
opaque_deferred_draw_functions,
alpha_mask_deferred_draw_functions,
ref mut material_param,
material_param,
): &mut SystemParamItem<Self::Param>,
) -> Result<Self, PrepareAssetError<Self::SourceAsset>> {
let draw_opaque_pbr = opaque_draw_functions.read().id::<DrawMaterial<M>>();
@ -1394,14 +1394,9 @@ impl<M: Material> RenderAsset for PreparedMaterial<M> {
fn unload_asset(
source_asset: AssetId<Self::SourceAsset>,
(
_,
_,
_,
ref mut bind_group_allocator,
ref mut render_material_bindings,
..,
): &mut SystemParamItem<Self::Param>,
(_, _, _, bind_group_allocator, render_material_bindings, ..): &mut SystemParamItem<
Self::Param,
>,
) {
let Some(material_binding_id) = render_material_bindings.remove(&source_asset.untyped())
else {

View File

@ -102,11 +102,13 @@ impl MeshletMesh {
},
})
.collect::<Vec<_>>();
let mut simplification_errors = iter::repeat(MeshletSimplificationError {
let mut simplification_errors = iter::repeat_n(
MeshletSimplificationError {
group_error: f16::ZERO,
parent_group_error: f16::MAX,
})
.take(meshlets.len())
},
meshlets.len(),
)
.collect::<Vec<_>>();
let mut vertex_locks = vec![false; vertices.vertex_count];
@ -187,13 +189,13 @@ impl MeshletMesh {
},
}
}));
simplification_errors.extend(
iter::repeat(MeshletSimplificationError {
simplification_errors.extend(iter::repeat_n(
MeshletSimplificationError {
group_error,
parent_group_error: f16::MAX,
})
.take(new_meshlet_ids.len()),
);
},
new_meshlet_ids.len(),
));
}
// Set simplification queue to the list of newly created meshlets

View File

@ -455,7 +455,7 @@ pub fn prepare_meshlet_per_frame_resources(
let index = instance_index / 32;
let bit = instance_index - index * 32;
if vec.len() <= index {
vec.extend(iter::repeat(0).take(index - vec.len() + 1));
vec.extend(iter::repeat_n(0, index - vec.len() + 1));
}
vec[index] |= 1 << bit;
}

View File

@ -918,8 +918,8 @@ impl Node for LateGpuPreprocessNode {
..
},
Some(PhasePreprocessBindGroups::IndirectOcclusionCulling {
late_indexed: ref maybe_late_indexed_bind_group,
late_non_indexed: ref maybe_late_non_indexed_bind_group,
late_indexed: maybe_late_indexed_bind_group,
late_non_indexed: maybe_late_non_indexed_bind_group,
..
}),
Some(late_indexed_indirect_parameters_buffer),
@ -1747,9 +1747,9 @@ pub fn prepare_preprocess_bind_groups(
) {
// Grab the `BatchedInstanceBuffers`.
let BatchedInstanceBuffers {
current_input_buffer: ref current_input_buffer_vec,
previous_input_buffer: ref previous_input_buffer_vec,
ref phase_instance_buffers,
current_input_buffer: current_input_buffer_vec,
previous_input_buffer: previous_input_buffer_vec,
phase_instance_buffers,
} = batched_instance_buffers.into_inner();
let (Some(current_input_buffer), Some(previous_input_buffer)) = (

View File

@ -1675,7 +1675,7 @@ pub fn collect_meshes_for_gpu_building(
frame_count: Res<FrameCount>,
mut meshes_to_reextract_next_frame: ResMut<MeshesToReextractNextFrame>,
) {
let RenderMeshInstances::GpuBuilding(ref mut render_mesh_instances) =
let RenderMeshInstances::GpuBuilding(render_mesh_instances) =
render_mesh_instances.into_inner()
else {
return;
@ -1686,8 +1686,8 @@ pub fn collect_meshes_for_gpu_building(
// Collect render mesh instances. Build up the uniform buffer.
let gpu_preprocessing::BatchedInstanceBuffers {
ref mut current_input_buffer,
ref mut previous_input_buffer,
current_input_buffer,
previous_input_buffer,
..
} = batched_instance_buffers.into_inner();

View File

@ -1,7 +1,7 @@
[package]
name = "bevy_picking"
version = "0.16.0-dev"
edition = "2021"
edition = "2024"
description = "Provides screen picking functionality for Bevy Engine"
homepage = "https://bevyengine.org"
repository = "https://github.com/bevyengine/bevy"

View File

@ -1,7 +1,7 @@
[package]
name = "bevy_platform_support"
version = "0.16.0-dev"
edition = "2021"
edition = "2024"
description = "Platform compatibility support for Bevy Engine"
homepage = "https://bevyengine.org"
repository = "https://github.com/bevyengine/bevy"

View File

@ -1,13 +1,13 @@
[package]
name = "bevy_ptr"
version = "0.16.0-dev"
edition = "2021"
edition = "2024"
description = "Utilities for working with untyped pointers in a more safe way"
homepage = "https://bevyengine.org"
repository = "https://github.com/bevyengine/bevy"
license = "MIT OR Apache-2.0"
keywords = ["bevy", "no_std"]
rust-version = "1.81.0"
rust-version = "1.85.0"
[dependencies]

View File

@ -413,9 +413,10 @@ impl<'a> OwningPtr<'a> {
/// Consumes a value and creates an [`OwningPtr`] to it while ensuring a double drop does not happen.
#[inline]
pub fn make<T, F: FnOnce(OwningPtr<'_>) -> R, R>(val: T, f: F) -> R {
let mut val = ManuallyDrop::new(val);
// SAFETY: The value behind the pointer will not get dropped or observed later,
// so it's safe to promote it to an owning pointer.
f(unsafe { Self::make_internal(&mut ManuallyDrop::new(val)) })
f(unsafe { Self::make_internal(&mut val) })
}
}

View File

@ -1,13 +1,13 @@
[package]
name = "bevy_reflect"
version = "0.16.0-dev"
edition = "2021"
edition = "2024"
description = "Dynamically interact with rust types"
homepage = "https://bevyengine.org"
repository = "https://github.com/bevyengine/bevy"
license = "MIT OR Apache-2.0"
keywords = ["bevy"]
rust-version = "1.81.0"
rust-version = "1.85.0"
[features]
default = ["std", "smallvec", "debug"]

View File

@ -1,6 +1,6 @@
[package]
name = "bevy_reflect_compile_fail"
edition = "2021"
edition = "2024"
description = "Compile fail tests for Bevy Engine's reflection system"
homepage = "https://bevyengine.org"
repository = "https://github.com/bevyengine/bevy"

View File

@ -1,7 +1,7 @@
[package]
name = "bevy_reflect_derive"
version = "0.16.0-dev"
edition = "2021"
edition = "2024"
description = "Derive implementations for bevy_reflect"
homepage = "https://bevyengine.org"
repository = "https://github.com/bevyengine/bevy"

View File

@ -206,7 +206,6 @@ macro_rules! hash_error {
),
}
}
.as_str()
}}
}
@ -244,7 +243,7 @@ impl DynamicMap {
}
fn internal_hash(value: &dyn PartialReflect) -> u64 {
value.reflect_hash().expect(hash_error!(value))
value.reflect_hash().expect(&hash_error!(value))
}
fn internal_eq<'a>(

View File

@ -167,7 +167,7 @@ impl DynamicSet {
}
fn internal_hash(value: &dyn PartialReflect) -> u64 {
value.reflect_hash().expect(hash_error!(value))
value.reflect_hash().expect(&hash_error!(value))
}
fn internal_eq(

View File

@ -1,7 +1,7 @@
[package]
name = "bevy_remote"
version = "0.16.0-dev"
edition = "2021"
edition = "2024"
description = "The Bevy Remote Protocol"
homepage = "https://bevyengine.org"
repository = "https://github.com/bevyengine/bevy"

View File

@ -1,7 +1,7 @@
[package]
name = "bevy_render"
version = "0.16.0-dev"
edition = "2021"
edition = "2024"
description = "Provides rendering functionality for Bevy Engine"
homepage = "https://bevyengine.org"
repository = "https://github.com/bevyengine/bevy"

View File

@ -1,7 +1,7 @@
[package]
name = "bevy_render_macros"
version = "0.16.0-dev"
edition = "2021"
edition = "2024"
description = "Derive implementations for bevy_render"
homepage = "https://bevyengine.org"
repository = "https://github.com/bevyengine/bevy"

View File

@ -1580,7 +1580,7 @@ pub fn batch_and_prepare_binned_render_phase<BPI, GFBD>(
}
// Reserve space in the occlusion culling buffers, if necessary.
if let Some(ref mut gpu_occlusion_culling_buffers) = gpu_occlusion_culling_buffers {
if let Some(gpu_occlusion_culling_buffers) = gpu_occlusion_culling_buffers {
gpu_occlusion_culling_buffers
.late_indexed
.add_multiple(indexed_preparer.work_item_count);
@ -1985,9 +1985,9 @@ pub fn write_batched_instance_buffers<GFBD>(
GFBD: GetFullBatchData,
{
let BatchedInstanceBuffers {
ref mut current_input_buffer,
ref mut previous_input_buffer,
ref mut phase_instance_buffers,
current_input_buffer,
previous_input_buffer,
phase_instance_buffers,
} = gpu_array_buffer.into_inner();
current_input_buffer

View File

@ -409,7 +409,7 @@ impl MeshAllocator {
slab_id: SlabId,
) -> Option<MeshBufferSlice> {
match self.slabs.get(&slab_id)? {
Slab::General(ref general_slab) => {
Slab::General(general_slab) => {
let slab_allocation = general_slab.resident_allocations.get(mesh_id)?;
Some(MeshBufferSlice {
buffer: general_slab.buffer.as_ref()?,
@ -420,7 +420,7 @@ impl MeshAllocator {
})
}
Slab::LargeObject(ref large_object_slab) => {
Slab::LargeObject(large_object_slab) => {
let buffer = large_object_slab.buffer.as_ref()?;
Some(MeshBufferSlice {
buffer,
@ -555,7 +555,7 @@ impl MeshAllocator {
match *slab {
Slab::General(ref mut general_slab) => {
let (Some(ref buffer), Some(allocated_range)) = (
let (Some(buffer), Some(allocated_range)) = (
&general_slab.buffer,
general_slab.pending_allocations.remove(mesh_id),
) else {
@ -706,7 +706,7 @@ impl MeshAllocator {
// that succeeds.
let mut mesh_allocation = None;
for &slab_id in &*candidate_slabs {
let Some(Slab::General(ref mut slab)) = self.slabs.get_mut(&slab_id) else {
let Some(Slab::General(slab)) = self.slabs.get_mut(&slab_id) else {
unreachable!("Slab not found")
};
@ -763,9 +763,7 @@ impl MeshAllocator {
// Mark the allocation as pending. Don't copy it in just yet; further
// meshes loaded this frame may result in its final allocation location
// changing.
if let Some(Slab::General(ref mut general_slab)) =
self.slabs.get_mut(&mesh_allocation.slab_id)
{
if let Some(Slab::General(general_slab)) = self.slabs.get_mut(&mesh_allocation.slab_id) {
general_slab
.pending_allocations
.insert(*mesh_id, mesh_allocation.slab_allocation);

Some files were not shown because too many files have changed in this diff Show More