Skip to content

Commit e885b87

Browse files
authored
Linter: Support Bevy 0.15 (#191)
This updates the linter to support Bevy 0.15. As #138 has not yet been implemented, Bevy 0.14 support is being dropped.[^0] Overall, it was surprisingly simple. I bumped the version of Bevy we use in testing, then fixed any errors. The UI tests are so rigid that even the slightest quiver could cause them to fail, which in this case is a good thing! The one thing of note is that I'm keeping support for `World::many_entities()` and `many_entities_mut()` in `bevy::panicking_world_methods` even though they are deprecated. Since `panicking_methods` is likely a lint that would be denied in projects, I don't want panicking methods to slip by just because someone added `#[allow(deprecated)]` while migration their project. Once these methods are completely removed from Bevy, we'll remove them from the linter. [^0]: I hope this won't be permanent, though. If all goes to plan, support for 0.14 will be re-added before the next release of `bevy_lint`!
1 parent d5f6bf7 commit e885b87

File tree

11 files changed

+571
-320
lines changed

11 files changed

+571
-320
lines changed

Cargo.lock

Lines changed: 531 additions & 289 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bevy_lint/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ toml_edit = { version = "0.22.22", default-features = false, features = [
4141

4242
[dev-dependencies]
4343
# Used when running UI tests.
44-
bevy = { version = "0.14.2", default-features = false }
44+
bevy = { version = "0.15.0", default-features = false }
4545

4646
# Used to deserialize `--message-format=json` messages from Cargo.
4747
serde = { version = "1.0.210", features = ["derive"] }

bevy_lint/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ There are several other ways to toggle lints, but they have varying levels of su
154154

155155
|`bevy_lint` Version|Rust Version|Rustup Toolchain|Bevy Version|
156156
|-|-|-|-|
157-
|0.2.0-dev|1.84.0|`nightly-2024-11-28`|0.14|
157+
|0.2.0-dev|1.84.0|`nightly-2024-11-28`|0.15|
158158
|0.1.0|1.84.0|`nightly-2024-11-14`|0.14|
159159

160160
The Rust version in the above table specifies what [version of the Rust language](https://github.com/rust-lang/rust/releases) can be compiled with `bevy_lint`. Code written for a later version of Rust may not compile. (This is not usually an issue, though, because `bevy_lint`'s Rust version is kept 1 to 2 releases ahead of stable Rust.)

bevy_lint/src/paths.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ pub const DEFERRED: [&str; 4] = ["bevy_ecs", "system", "system_param", "Deferred
1313
pub const DEFERRED_WORLD: [&str; 4] = ["bevy_ecs", "world", "deferred_world", "DeferredWorld"];
1414
pub const ENTITY_COMMANDS: [&str; 4] = ["bevy_ecs", "system", "commands", "EntityCommands"];
1515
pub const ENTITY_MUT: [&str; 4] = ["bevy_ecs", "world", "entity_ref", "EntityMut"];
16-
// Note that this moves to `bevy_ecs::event::base::Event` in 0.15.
17-
pub const EVENT: [&str; 3] = ["bevy_ecs", "event", "Event"];
18-
pub const EVENTS: [&str; 3] = ["bevy_ecs", "event", "Events"];
16+
pub const EVENT: [&str; 4] = ["bevy_ecs", "event", "base", "Event"];
17+
pub const EVENTS: [&str; 4] = ["bevy_ecs", "event", "collections", "Events"];
1918
pub const FILTERED_ENTITY_MUT: [&str; 4] = ["bevy_ecs", "world", "entity_ref", "FilteredEntityMut"];
2019
pub const MUT: [&str; 3] = ["bevy_ecs", "change_detection", "Mut"];
2120
pub const MUT_UNTYPED: [&str; 3] = ["bevy_ecs", "change_detection", "MutUntyped"];

bevy_lint/tests/ui/borrowed_reborrowable/entity_commands.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: parameter takes `&mut EntityCommands` instead of a re-borrowed `EntityCom
22
--> tests/ui/borrowed_reborrowable/entity_commands.rs:17:22
33
|
44
17 | fn mutable_reference(_param: &mut EntityCommands) {
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `EntityCommands` instead: `mut _param: bevy::bevy_ecs::system::EntityCommands<'_>`
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `EntityCommands` instead: `mut _param: bevy::prelude::EntityCommands<'_>`
66
|
77
note: the lint level is defined here
88
--> tests/ui/borrowed_reborrowable/entity_commands.rs:5:9
@@ -14,7 +14,7 @@ error: parameter takes `&mut EntityCommands` instead of a re-borrowed `EntityCom
1414
--> tests/ui/borrowed_reborrowable/entity_commands.rs:23:33
1515
|
1616
23 | fn mutable_reference_return<'a>(_param: &'a mut EntityCommands) -> usize {
17-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `EntityCommands` instead: `mut _param: bevy::bevy_ecs::system::EntityCommands<'_>`
17+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `EntityCommands` instead: `mut _param: bevy::prelude::EntityCommands<'_>`
1818

1919
error: aborting due to 2 previous errors
2020

bevy_lint/tests/ui/missing_reflect/impl.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,6 @@ impl Component for MyEvent {
3737
}
3838

3939
//~v NOTE: `Event` implemented here
40-
impl Event for MyEvent {}
40+
impl Event for MyEvent {
41+
type Traversal = ();
42+
}

bevy_lint/tests/ui/missing_reflect/impl.stderr

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ error: defined an event without a `Reflect` implementation
77
note: `Event` implemented here
88
--> tests/ui/missing_reflect/impl.rs:40:1
99
|
10-
40 | impl Event for MyEvent {}
11-
| ^^^^^^^^^^^^^^^^^^^^^^^^^
10+
40 | / impl Event for MyEvent {
11+
41 | | type Traversal = ();
12+
42 | | }
13+
| |_^
1214
note: the lint level is defined here
1315
--> tests/ui/missing_reflect/impl.rs:8:9
1416
|

bevy_lint/tests/ui/missing_reflect/impl_ref.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,6 @@ impl Component for &'static &'static &'static MyEvent {
4242
}
4343

4444
//~v NOTE: `Event` implemented here
45-
impl Event for &'static &'static &'static MyEvent {}
45+
impl Event for &'static &'static &'static MyEvent {
46+
type Traversal = ();
47+
}

bevy_lint/tests/ui/missing_reflect/impl_ref.stderr

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ error: defined an event without a `Reflect` implementation
77
note: `Event` implemented here
88
--> tests/ui/missing_reflect/impl_ref.rs:45:1
99
|
10-
45 | impl Event for &'static &'static &'static MyEvent {}
11-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10+
45 | / impl Event for &'static &'static &'static MyEvent {
11+
46 | | type Traversal = ();
12+
47 | | }
13+
| |_^
1214
note: the lint level is defined here
1315
--> tests/ui/missing_reflect/impl_ref.rs:13:9
1416
|

bevy_lint/tests/ui/panicking_methods/world.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@ fn main() {
2828
//~^ ERROR: called a `World` method that can panic when a non-panicking alternative exists
2929
//~| HELP: use `world.get_entity_mut(bob)`
3030

31+
#[expect(deprecated, reason = "While this method is deprecated, we should still check for it while it exists.")]
3132
world.many_entities([bob]);
3233
//~^ ERROR: called a `World` method that can panic when a non-panicking alternative exists
3334
//~| HELP: use `world.get_many_entities([bob])`
3435

36+
#[expect(deprecated, reason = "While this method is deprecated, we should still check for it while it exists.")]
3537
world.many_entities_mut([bob]);
3638
//~^ ERROR: called a `World` method that can panic when a non-panicking alternative exists
3739
//~| HELP: use `world.get_many_entities_mut([bob])`

0 commit comments

Comments
 (0)