Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Rust Edition 2024 #17967

Merged
merged 37 commits into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
4c20239
WIP
bushrat011899 Feb 21, 2025
468fd12
Switch to Edition 2024
bushrat011899 Feb 21, 2025
c260f13
bevy_ptr
bushrat011899 Feb 21, 2025
c82e1fa
bevy_tasks
bushrat011899 Feb 21, 2025
19c84dd
bevy_reflect
bushrat011899 Feb 21, 2025
7307a59
bevy_ecs_macros
bushrat011899 Feb 21, 2025
044d557
bevy_math
bushrat011899 Feb 21, 2025
de9ab7b
bevy_ecs
bushrat011899 Feb 21, 2025
d3638cd
bevy_mesh
bushrat011899 Feb 21, 2025
d6d9ace
bevy_window
bushrat011899 Feb 21, 2025
f85712b
benches
bushrat011899 Feb 21, 2025
f8396dd
bevy_core_pipeline
bushrat011899 Feb 21, 2025
7b44419
bevy_ecs_macros
bushrat011899 Feb 21, 2025
8c20f88
bevy_ecs
bushrat011899 Feb 21, 2025
e1ec187
bevy_pbr
bushrat011899 Feb 21, 2025
b93109e
bevy_render
bushrat011899 Feb 21, 2025
c8bd66e
bevy_transform
bushrat011899 Feb 21, 2025
0519702
bevy_ui
bushrat011899 Feb 21, 2025
1984e6c
cargo fmt
bushrat011899 Feb 21, 2025
d0b5271
Revert "cargo fmt"
bushrat011899 Feb 21, 2025
32a0ad2
Use 2021 formatting style explicitly
bushrat011899 Feb 21, 2025
3a3d98a
Fix Rust version for templated pages CI
bushrat011899 Feb 21, 2025
7da43d1
Fix check-missing-features-in-docs
bushrat011899 Feb 21, 2025
069108e
Fix docs
bushrat011899 Feb 21, 2025
1de3916
Fix bevy_log doc tests
bushrat011899 Feb 21, 2025
d4ed647
Fix all doc tests
bushrat011899 Feb 22, 2025
d2da9fe
Clippy has hands
bushrat011899 Feb 22, 2025
4ff84aa
Attempt to resolve `msrv` CI issue
bushrat011899 Feb 22, 2025
6403379
Revert "Attempt to resolve `msrv` CI issue"
bushrat011899 Feb 22, 2025
1b73897
Merge remote-tracking branch 'upstream/main' into UpgradeTo2024
bushrat011899 Feb 22, 2025
501909a
Use `generation` instead of `r#gen`
bushrat011899 Feb 22, 2025
d1ab443
Revert changes to `asset_loading` example
bushrat011899 Feb 22, 2025
011ae5e
Revert `alien_cake_addict`
bushrat011899 Feb 22, 2025
d2a6de3
Possible fix for `msrv` CI task
bushrat011899 Feb 22, 2025
1ab9b12
Merge remote-tracking branch 'upstream/main' into UpgradeTo2024
bushrat011899 Feb 23, 2025
bb80270
Wrap `no_mangle` in `unsafe`
bushrat011899 Feb 23, 2025
0f244fc
Merge remote-tracking branch 'upstream/main' into UpgradeTo2024
bushrat011899 Feb 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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: |
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -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/"]
Expand All @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion benches/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
10 changes: 5 additions & 5 deletions benches/benches/bevy_ecs/change_detection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion benches/benches/bevy_ecs/components/add_remove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
10 changes: 5 additions & 5 deletions benches/benches/bevy_ecs/iteration/iter_simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions benches/benches/bevy_ecs/iteration/iter_simple_foreach.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions benches/benches/bevy_ecs/iteration/iter_simple_foreach_wide.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions benches/benches/bevy_ecs/iteration/iter_simple_sparse_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions benches/benches/bevy_ecs/iteration/iter_simple_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 5 additions & 5 deletions benches/benches/bevy_ecs/iteration/iter_simple_wide.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions benches/benches/bevy_ecs/iteration/par_iter_simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
10 changes: 5 additions & 5 deletions benches/benches/bevy_ecs/world/entity_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
12 changes: 6 additions & 6 deletions benches/benches/bevy_reflect/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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());
},
Expand All @@ -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(
Expand All @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion benches/benches/bevy_reflect/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Loading