# Objective
Resolve all clippy lints currently warning in one way or another. They
were annoying me while contributing, especially having to find the lints
i caused in the ~50 of them which this PR resolves.
## Solution
Most of them were fixes that were reasonable to apply.
`std_instead_of_core` currently has false hits on `std::io`: because
`core::io` is unstable we don't want to apply those. So ive decided to
disable this lint for now. This was already "allow" in `[lints.clippy]`,
i made it "allow" in `[workspace.lints.clippy]` as well.
## Testing
- [x] `cargo test --all` passes, except for
`error::bevy_error::tests::filtered_backtrace_test` which fails on
`main` in the same way for me
- [x] `bevy_city` example works
---------
Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
Co-authored-by: Mike <mike.hsu@gmail.com>
Co-authored-by: Mira <specificprotagonist@posteo.org>
# Objective
Fix typos and other small issues in the documentation. I can drop the
changes to `bevy_reflect`'s and `bevy_anti_alias`'s crate descriptions
if it's a problem.
# Objective
Ratatui is used by the `tools/export-content` crate. Update it to its
latest stable version.
This PR supersedes #22351 which is a dependabot PR that got stuck on
some breaking changes in ratatui 0.30.
## Solution
Ratatui's `Backend` type now has an associated `Error` type that does
not specify `Send + Sync`,
which is a bit awkward because `miette` requires those. Fixed by adding
the requirements locally,
and changing `init_terminal()` to return its specific backend type so
that the compiler can verify its `Error` type.
## Testing
Ran the tool before and after and it looked the same.
## Error
During `$ cargo run -p ci -- compile`
```text
$ cargo check --benches --target-dir ../target --manifest-path ./benches/Cargo.toml
error: failed to create directory `D:\bevy\..`
Caused by:
Access is denied. (os error 5)
thread 'main' (16628) panicked at tools\ci\src\ci.rs:62:13:
One or more CI commands failed:
bench-check: Failed to check the benches.
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```
## Solution
- Instead of accessing ../target access ./target
## Testing
- Now the command works on my device.
I was initially using `MessageReader<WindowResized>` in my system for my
app but once my system grew to use more and more window events, I
refactored to using `MessageReader<WindowEvent>` and matching on its
variants. This is where I ran into the issue of the
`WindowEvent::WindowResized` case never matching.
When making this PR, I noticed
`WindowEvent::WindowBackendScaleFactorChanged` and
`WindowEvent::WindowScaleFactorChanged` had the same issue.
# Objective
Fixes#15268
## Solution
Instead of writing into `MessageWriter<WindowResized>`,
`MessageWriter<WindowBackendScaleFactorChanged>` and
`MessageWriter<WindowScaleFactorChanged>`, push into
`bevy_window_events` where it gets sent to the `forward_bevy_events`
function for syncing the messages.
## Testing
I made local modifications to the `window_resizing` example to use a
`MessageReader<WindowEvent>` instead of `MessageReader<WindowResized>`
like so:
```rs
fn on_resize_system(
mut text: Single<&mut Text, With<ResolutionText>>,
mut resize_reader: MessageReader<WindowEvent>,
) {
for e in resize_reader.read() {
if let WindowEvent::WindowResized(e) = e {
// When resolution is being changed
text.0 = format!("{:.1} x {:.1}", e.width, e.height);
}
}
}
```
I ran this example on linux wayland.
# Objective
Add constructors for making `BevyError`s with a specific severity.
Closes#23676.
## Solution
Add a `new` constructor plus 1 constructor for every possible
`Severity`.
## Testing
My eyes and a simple test case that constructs an error and tests if the
downcasting works.
---
## Showcase
A `BevyError` now has multiple constructor to create one with an
expected severity
```rust
use bevy::ecs::error::{BevyError, Severity};
let debug_error = BevyError::new(Severity::Debug, "This works with strings");
let warn_error = BevyError::warn("There's a constructor for each severity level");
```
---------
Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
Co-authored-by: Ben Frankel <ben.frankel7@gmail.com>
# Objective
- All Bevy programs with bevy_audio print a line to stderr when they
exit:
```
Dropping DeviceSink, audio playing through this sink will stop, to prevent this message from appearing use tracing or call `.log_on_drop(false)` on this DeviceSink
```
- This is an expected print by rodio:
https://github.com/RustAudio/rodio/blob/7e9ba6dd017abb88a1de8c287849c89c3624437d/src/stream.rs#L99-L108
## Solution
- Enable the tracing feature so that it's logged instead of printed
- set `log_on_drop(false)` on the audio sink created by Bevy. It's
expected to stop playing sound when it's dropped
# Objective
- Closes#19672
## Solution
- Updated both `cpal` and `rodio` to their latest versions.
- Updated code to address `rodio`'s breaking changes.
- Reworked audio related feature flags. NOTE: `symphonia` will only be
the default backend for formats with no alternative fallback.
- Added `audio-all-formats` feature collection to easily enable all the
available audio formats using their default backends.
- Replaced `aarch64-apple-ios-sim` target with
`arm64-apple-ios-simulator`.
## Testing
- Tested audio related examples.
- CI checks passing.
---------
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Rob Parrett <robparrett@gmail.com>
# Objective
Make release notes and migration guides show up first when viewing PRs
in github.
## Solution
Prefix the release-content directory with `_` so it sorts first.
## Testing
See for yourself.
# Objective
- Make it easier to understand what each feature collection is enabling.
## Solution
- Added the list of features that a collection will enable on its
description. These are located in the "cargo_features" templated doc
page.
## Testing
- Running the templated page generator for "features" and checking the
resulting markdown.
---
## Showcase
<img width="996" height="373" alt="image"
src="https://github.com/user-attachments/assets/9b31de60-ef33-4291-bd5f-2d1583467447"
/>
# Objective
CI is currently failing
## Solution
Fix the lints (and work around all the rustc lint bugs that are
apparently included)
---------
Co-authored-by: MichiRecRoom <1008889+LikeLakers2@users.noreply.github.com>
# Objective
This PR is a sister PR necessary for the website to have
`required_features` data.
You will find more information on the motivations there:
https://github.com/bevyengine/bevy-website/pull/2313
## Solution
- Add the required_features data to the examples docs export
## Testing
I tested both together and it worked fine
## Objective
Users of the `bevy` crate currently live one of two lifestyles:
1. Use all of Bevy's default features, potentially compiling many
features you don't need or don't want. If there is a feature you _cannot
have_ in your app, you must move on to option (2)
2. Disable Bevy's default features, and compose the complete list of
features yourself.
Living in the world of (2) is an exercise in frustration, as the list of
required features to accomplish a given task changes regularly across
releases as we add and change features. This is an _expert level_ task
that requires intimate knowledge of engine internals to get right. Even
I, Bevy's lead developer, would struggle here. To the point that I would
never voluntarily choose to disable Bevy's default features.
Most games/apps are 2D-only, 3D-only, or UI-only and don't require the
full set of features. We cannot currently in good conscience recommend
that those developers live in the "no default features" world. That is a
fast track to pain, suffering, and perhaps a quick exit from the Bevy
ecosystem.
The same problem exists for developers that want to build their own Bevy
renderer or replace Bevy UI with their own framework. Once again, we
_cannot_ recommend that those developers manage every Bevy feature
themselves.
Fixes: #21369
Alternative to: #20741#21236
## Solution
Define a "standalone" set of features that enable Bevy developers to
disable default features, then opt in to the funtionality they want. The
"default" `bevy` feature set is now just:
```toml
default = ["2d", "3d", "ui"]
```
This enables developers to select only the features they need. For
example, a UI-only app would look like this:
```toml
bevy = { version = "0.17", default-features = false, features = [ "ui" ] }
```
"2d", "3d", and "ui" each contain the "full" Bevy experience for that
domain. This also includes:
- `default_platform`: the default "platform support" features (see docs)
- `default_app`: the default "app framework" features (see docs)
For developers that do not want the default bevy render / platform / app
functionality, this breaks down further into:
- `common_api`: common / core backend-less user-facing Bevy render api
- `2d_api`: common / core backend-less user-facing Bevy 2d api
- `3d_api`: common / core backend-less user-facing Bevy 3d api
- `ui_api`: common / core backend-less user-facing Bevy ui api
(and many others)
I've also added the `dev` feature to this PR, which enables the
recommended "dev only" features like dynamic linking, asset watching /
hot reloading, and dev / debug tools. Including dynamic linking is a bit
controversial here given that it doesn't work everywhere. But I'd like
to aggressively push people into the dynamic linking workflow wherever
possible, as developing without it is signficantly worse. And removing a
single `dev` feature is a much simpler release workflow.
---------
Co-authored-by: atlv <email@atlasdostal.com>
# Objective
- `bevy_asset` needs more tests! This adds three related to asset
processing.
## Solution
- Create a new `MemoryAssetWriter` to pair with `MemoryAssetReader`.
- Adds a way to override whether the asset processor is created or not.
- Make `Data::value` and `Data::path` `pub` so that we can actually see
what is written to the processed dir. Note: `Dir::get_asset` returns
`Data` already, but it isn't usable.
- Add three tests: one to test that assets are copied to the processed
dir for no-processing assets, one to test that using a default processor
works, and one to test that an asset meta file works.
## Testing
- This adds testing! :D
# Objective
Fixes#21293Fixes#17314 to ensure that this is tested correctly.
## Solution
when despawning an entity, previously the swapped in (archetype) or
moved in entity (table) (which both require extra bookkeeping to update
archetype or table rows) were marked as `spawned_or_despawned` by the
location and tick that the to-be-removed entity was meant to be marked,
while the to-be-removed entity wasn't marked.
As pointed out by @akimakinai in
[#19047](https://github.com/bevyengine/bevy/pull/19047), I've re-added
the correct `mark_spawn_despawn` call to `despawn_with_caller`.
## Testing
I've added a test `spawned_after_swap_remove` that ensures that
despawning an entity by swapping doesn't effect other entities
`spawned_or_despawned` location, and that it does effect the despawned
entity's index's `spawned_or_despawned` location.
Co-Authored By: waterwhisperer24@qq.com
---------
Co-authored-by: WaterWhisperer <waterwhisperer24@qq.com>
# Objective
- Fail PRs that add a release content that fails parsing
## Solution
- Add a check mode to the exporter tool
- Run it in CI
## Testing
- Should fail on this PR before
https://github.com/bevyengine/bevy/pull/21065 is merged
# Objective
- the publish script didn't actually work, it was just a vague
instruction on how to get something working
- it needed manual adaptation for each version to have the correct crate
order
- it was not fun to do
## Solution
- `cargo +nightly publish --workspace` now works, use that instead
# Objective
use the latest hashbrown, and foldhash version (foldhash went from 0.1.5
to 0.2.0)
small performance improvement in foldhash.
# Notes
`FoldHasher` now takes a lifetime, had to specify it.
# Objective
Adds a simple tool to order and merge release notes and migration
guides.
To use, go to `tools/export-content` and use `cargo run`.
The output formatting may need to be tweaked, and we will probably want
to add/change the zola shortcodes a bit.
---------
Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
Co-authored-by: DAA <42379074+DaAlbrecht@users.noreply.github.com>
# Objective
New `rand` version, which means updating `glam` and `encase` to support
the newer ecosystem update. Does mean that this changes how WASM builds
need to be done in order to configure `getrandom` correctly, but this
can be remedied with updated docs.
## Solution
Updating all needed dependencies to their compatible versions. ~~This PR
is currently blocked by `encase`, which is waiting on [this
PR](https://github.com/teoxoy/encase/pull/88) to be merged and then a
new version published.~~ ~~This PR is no longer blocked~~,
~~`hexasphere` is blocking this PR now due to not yet having a new
release with the latest `glam` version support~~, The PR is all good to
go now, everything in order across glam/rand deps.
## Testing
- Must pass CI for all checks, tests, not introduce breaking changes.
---
## Migration Guide
With newer versions of `glam` & `encase`, the updated versions don't
seem to have introduced breakages, though as always, best to consult
their docs [1](https://docs.rs/glam/latest/glam/)
[2](https://docs.rs/encase/0.11.0/encase/) for any changes.
`rand` changes are more extensive, with changes such as `thread_rng()`
-> `rng()`, `from_entropy()` -> `from_os_rng()`, and so forth. `RngCore`
is now split into infallible `RngCore` and fallible `TryRngCore`, and
the `distributions` module has been renamed to `distr`. Most of this
affects only internals, and doesn't directly affect Bevy's APIs. For the
full set of changes, see `rand` [migration
notes](https://rust-random.github.io/book/update-0.9.html).
`getrandom` is also updated, and will require additional configuration
when building Bevy for WASM/Web (if also using `rand`). The full details
of how to do this is in the `getrandom` docs
[1](https://github.com/rust-random/getrandom?tab=readme-ov-file#opt-in-backends)
[2](https://github.com/rust-random/getrandom?tab=readme-ov-file#webassembly-support).
---------
Co-authored-by: François Mockers <francois.mockers@vleue.com>
# Objective
- Closes#20410
## Solution
- Updated a deprecated type alias name (`ImDocument` -> `Document`).
## Testing
- CI checks
---------
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: James Liu <contact@jamessliu.com>
Adopted from #20456
Notes:
* The origin of the `dead_code` lints were coming from the `ShaderType `
derive macro. This has been reported as
https://github.com/teoxoy/encase/issues/102, and a temporary
workspace-wide `allow` added to the top level Cargo.toml.
* One of the lints pointed out that `PartialEq` and `Eq` may not work as
expected for function pointers, so `CloneBehavior` no longer implements
either trait, and pattern matching is used in instead.
Original PR Description:
># Objective
>
>Unbreak CI.
>
> ## Solution
>
> Fix the lints.
>
>I've opted for anonymous lifetimes in every revealed case so far;
please let me know if you think I should used named lifetimes in
specific cases and why.
>
>## Testing
>
>Is CI green?
>
>## Context
>
> This lint originally had a much larger splash damage, with fairly
negative effects on Bevy. See
https://github.com/rust-lang/rust/issues/131725.
>
> The more restricted former is much more helpful, despite the large
diff in this PR. Bevy is a large code base!
>
>## TODO
>
>- [x] discuss proposed lifetime lint fixes
>,- [x] use cargo clippy --fix to fix newly uncovered docs misformatting
>- [x] fix newly revealed dead code issues
>- [x] ensure CI is green
---------
Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
Co-authored-by: Mike <mike.hsu@gmail.com>
# Objective
Remove unneeded dependencies.
## Solution
Found using `cargo-shear`, `cargo-machete`, and `cargo-udeps`. They all
do the same thing (identify unused dependencies), they are all so-so at
it (with lots of false negatives and positives) but the combination of
all three is enough to get a useful outcome.
## Testing
- I double-checked all the removals by grepping for each removed
dependency's name within the affected crate, to make sure there weren't
any uses remaining. I think they're all ok.
- `cargo run -p ci`
Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
Co-authored-by: James Liu <contact@jamessliu.com>
# Objective
`ci` tool fails if you run with `--test-threads` because `cargo test
--benches` does not take `--test-threads`
## Solution
Split the command that call `cargo test` into one for `--benches` and
other for `--lib --bins --tests`.
## Testing
Ran `cargo run -p ci -- --build-jobs 4 --test-threads 4`
## Note
This is a cherry-pick of a commit that was added to #19011 but was
unrelated to the PR
# Objective
- make lights usable without bevy_render
## Solution
- make a new crate for lights to live in
## Testing
- 3d_scene, lighting, volumetric_fog, ssr, transmission, pcss,
light_textures
Note: no breaking changes because of re-exports, except for light
textures, which were introduced this cycle so it doesn't matter anyways
# Objective
- Fixes#19670
## Solution
- Updated breaking code to be able to upgrade `ui_test` to the latest
version.
## Testing
- CI checks.
---------
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
# Objective
- Currently, CI tests take a screenshot at frame X and exits at frame Y
with X < Y, and both number fixed
- This means tests can take longer than they actually need when taking
the screenshot is fast, and can fail to take the screenshot when it's
taking too long
## Solution
- Add a new event `ScreenshotAndExit` that exit directly after the
screenshot is saved
# Objective
- Fixes#19627
- Tackles part of #19644
- Supersedes #19629
- `Window` has become a very very very big component
- As such, our change detection does not *really* work on it, as e.g.
moving the mouse will cause a change for the entire window
- We circumvented this with a cache
- But, some things *shouldn't* be cached as they can be changed from
outside the user's control, notably the cursor grab mode on web
- So, we need to disable the cache for that
- But because change detection is broken, that would result in the
cursor grab mode being set every frame the mouse is moved
- That is usually *not* what a dev wants, as it forces the cursor to be
locked even when the end-user is trying to free the cursor on the
browser
- the cache in this situation is invalid due to #8949
## Solution
- Split `Window` into multiple components, each with working change
detection
- Disable caching of the cursor grab mode
- This will only attempt to force the grab mode when the `CursorOptions`
were touched by the user, which is *much* rarer than simply moving the
mouse.
- If this PR is merged, I'll do the exact same for the other
constituents of `Window` as a follow-up
## Testing
- Ran all the changed examples
# Objective
Fixes#16051Closes#16145
## Solution
Allow passing `--build-jobs` and `--test-threads` to `ci`
i.e.
```
cargo run -p ci -- --build-jobs 4 --test-threads 4
```
## Testing
running ci locally
---------
Co-authored-by: Benjamin Brienen <Benjamin.Brienen@outlook.com>
# Objective
- Update ron to the latest version.
- This is blocking changes to AnimationGraph (as some valid structs are
not capable of being deserialized).
## Solution
- Bump ron!
## Testing
- The particular issue I was blocked by seems to be resolved!
# Objective
There are several uninlined format args (seems to be in more formatting
macros and in more crates) that are not detected on stable, but are on
nightly.
## Solution
Fix them.
# Objective
Currently the `compile_fail_utils` crate fails to compile (ironic) when
the `RUSTUP_HOME` env var isn't set. This has been the case for a long
time, but I only noticed it recently due to rust-analyzer starting to
show the error.
## Solution
Only filter the logs for the `RUSTUP_HOME` variable if it's set.
# Objective
- Publishing takes a long time
- There's a 20 second wait between crates to not hit the rate limit on
crates.io
## Solution
- Our rate limit has been increased by the crates.io team, don't wait
anymore!
# Objective
Separate example explanation (file docblock) and the code so they can be
layout differently in the website and we can give a higher importance to
the explanation on the [website search
tool](https://github.com/bevyengine/bevy-website/pull/1935). This would
also allow us to improve the examples so they become even more like a
cookbook.
## Solution
Update the `example-showcase` tool to extract the example file docblock
and write it as the example markdown content. This allows us to access
the explanation via `page.content` in Zola.
## Testing
I've checked that the output is correct after running the tool and it
doesn't throw any error. I've also validated that the approach will work
on the website.
## Showcase
This is a quick and dirty example of what we could do in the web
examples after the change. When we implement the real thing we can put
the explanation on a sidebar or explore other layout options.
<img width="1362" alt="image"
src="https://github.com/user-attachments/assets/6738542e-31c3-41cd-972a-7fa2e942e85d"
/>
# Objective
- Some examples are now build as lib to be usable in other examples
since https://github.com/bevyengine/bevy/pull/18288
- Those examples are not correctly handled in the showcase as it tries
to run them
## Solution
- Ignore lib examples in showcase when taking screenshots or building
for the website
# Objective
- Fixes#18223.
## Solution
- Updated ui_test requirement from 0.23.0 to 0.29.1.
- Updated code to use the new APIs.
## Testing
- Ran CI locally.
---------
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
# Objective
- Prevent usage of `println!`, `eprintln!` and the like because they
require `std`
- Fixes#17446
## Solution
- Enable the `print_stdout` and `print_stderr` clippy lints
- Replace all `println!` and `eprintln!` occurrences with `log::*` where
applicable or alternatively ignore the warnings
## Testing
- Run `cargo clippy --workspace` to ensure that there are no warnings
relating to printing to `stdout` or `stderr`
# Objective
Correct spelling
## Solution
Fix typos, specifically ones that I found in folders other than /crates
## Testing
CI
---------
Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>