Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1,123 changes: 520 additions & 603 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bevy_lint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ toml = { version = "1.1.2", default-features = false, features = [

[dev-dependencies]
# Used when running UI tests.
bevy = { version = "0.18", default-features = false, features = [
bevy = { version = "0.19", default-features = false, features = [
"std",
# used for the `camera_modification_in_fixed_update` lint
"bevy_render",
Expand Down
10 changes: 10 additions & 0 deletions bevy_lint/MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ To actually install the new version of the linter, please see [the docs] and [th
[the releases page]: https://github.com/TheBevyFlock/bevy_cli/releases
[submit an issue]: https://github.com/TheBevyFlock/bevy_cli/issues

## v0.6.0 to v0.7.0

### [Bevy 0.19 Support](https://github.com/TheBevyFlock/bevy_cli/pull/835)

The linter now supports Bevy 0.19, but no longer supports Bevy 0.18.
To migrate your code base to Bevy 0.19, please see the [release post][bevy 0.19 release post] and [migration guide][bevy 0.19 migration guide].

[bevy 0.19 release post]: https://bevy.org/news/bevy-0-19/
[bevy 0.19 migration guide]: https://bevy.org/learn/migration-guides/0-18-to-0-19/

## v0.5.0 to v0.6.0

### [Bevy 0.18 Support](https://github.com/TheBevyFlock/bevy_cli/pull/703)
Expand Down
10 changes: 5 additions & 5 deletions bevy_lint/src/lints/restriction/missing_reflect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,16 @@ impl<'tcx> LateLintPass<'tcx> for MissingReflect {
.filter(|trait_type| !reflected.contains(trait_type))
.collect();

// Finds all non-`Reflect` types that implement `Component` in this crate.
let components: Vec<TraitType> = TraitType::from_local_crate(cx, &crate::paths::COMPONENT)
.filter(|trait_type| !reflected.contains(trait_type))
.collect();

// Finds all non-`Reflect` types that implement `Resource` in this crate.
let resources: Vec<TraitType> = TraitType::from_local_crate(cx, &crate::paths::RESOURCE)
.filter(|trait_type| !reflected.contains(trait_type))
.collect();

// Finds all non-`Reflect` types that implement `Component` but not `Resource`.
let components: Vec<TraitType> = TraitType::from_local_crate(cx, &crate::paths::COMPONENT)
.filter(|trait_type| !reflected.contains(trait_type) && !resources.contains(trait_type))
.collect();

let reflect_trait_def_ids = crate::paths::PARTIAL_REFLECT.get(cx);

// Emit diagnostics for each of these types.
Expand Down
60 changes: 30 additions & 30 deletions bevy_lint/src/paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,66 +21,66 @@ macro_rules! type_path {

// Keep the following list alphabetically sorted :)

/// <https://github.com/bevyengine/bevy/blob/v0.18.0/crates/bevy_app/src/app.rs#L84>
/// <https://github.com/bevyengine/bevy/blob/v0.19.0/crates/bevy_app/src/app.rs#L86>
pub static APP: PathLookup = type_path!(bevy_app::app::App);
/// <https://github.com/bevyengine/bevy/blob/v0.18.0/crates/bevy_ecs/src/bundle/mod.rs#L200>
/// <https://github.com/bevyengine/bevy/blob/v0.19.0/crates/bevy_ecs/src/bundle/mod.rs#L207>
pub static BUNDLE: PathLookup = type_path!(bevy_ecs::bundle::Bundle);
/// <https://github.com/bevyengine/bevy/blob/v0.18.0/crates/bevy_camera/src/camera.rs#L349>
/// <https://github.com/bevyengine/bevy/blob/v0.19.0/crates/bevy_camera/src/camera.rs#L384>
pub static CAMERA: PathLookup = type_path!(bevy_camera::camera::Camera);
/// <https://github.com/bevyengine/bevy/blob/v0.18.0/crates/bevy_ecs/src/system/commands/mod.rs#L105>
/// <https://github.com/bevyengine/bevy/blob/v0.19.0/crates/bevy_ecs/src/system/commands/mod.rs#L105>
pub static COMMANDS: PathLookup = type_path!(bevy_ecs::system::commands::Commands);
/// <https://github.com/bevyengine/bevy/blob/v0.18.0/crates/bevy_ecs/src/component/mod.rs#L509>
/// <https://github.com/bevyengine/bevy/blob/v0.19.0/crates/bevy_ecs/src/component/mod.rs#L511>
pub static COMPONENT: PathLookup = type_path!(bevy_ecs::component::Component);
/// <https://github.com/bevyengine/bevy/blob/v0.18.0/crates/bevy_ecs/src/world/deferred_world.rs#L28>
/// <https://github.com/bevyengine/bevy/blob/v0.19.0/crates/bevy_ecs/src/world/deferred_world.rs#L28>
pub static DEFERRED_WORLD: PathLookup = type_path!(bevy_ecs::world::deferred_world::DeferredWorld);
/// <https://github.com/bevyengine/bevy/blob/v0.18.0/crates/bevy_ecs/src/system/system_param.rs#L1301>
/// <https://github.com/bevyengine/bevy/blob/v0.19.0/crates/bevy_ecs/src/system/system_param.rs#L1184>
pub static DEFERRED: PathLookup = type_path!(bevy_ecs::system::system_param::Deferred);
/// <https://github.com/bevyengine/bevy/blob/v0.18.0/crates/bevy_ecs/src/system/commands/mod.rs#L1282>
/// <https://github.com/bevyengine/bevy/blob/v0.19.0/crates/bevy_ecs/src/system/commands/mod.rs#L1304>
pub static ENTITY_COMMANDS: PathLookup = type_path!(bevy_ecs::system::EntityCommands);
/// <https://github.com/bevyengine/bevy/blob/v0.18.0/crates/bevy_ecs/src/world/entity_access/entity_mut.rs#L42>
/// <https://github.com/bevyengine/bevy/blob/v0.19.0/crates/bevy_ecs/src/world/entity_access/entity_mut.rs#L45>
pub static ENTITY_MUT: PathLookup = type_path!(bevy_ecs::world::entity_access::EntityMut);
/// <https://github.com/bevyengine/bevy/blob/v0.18.0/crates/bevy_ecs/src/event/mod.rs#L88>
/// <https://github.com/bevyengine/bevy/blob/v0.19.0/crates/bevy_ecs/src/event/mod.rs#L88>
pub static EVENT: PathLookup = type_path!(bevy_ecs::event::Event);
/// <https://github.com/bevyengine/bevy/blob/v0.18.0/crates/bevy_ecs/src/world/entity_access/filtered.rs#L358>
/// <https://github.com/bevyengine/bevy/blob/v0.19.0/crates/bevy_ecs/src/world/entity_access/filtered.rs#L365>
pub static FILTERED_ENTITY_MUT: PathLookup =
type_path!(bevy_ecs::world::entity_access::FilteredEntityMut);
/// <https://github.com/bevyengine/bevy/blob/v0.18.0/crates/bevy_app/src/main_schedule.rs#L133>
/// <https://github.com/bevyengine/bevy/blob/v0.19.0/crates/bevy_app/src/main_schedule.rs#L133>
pub static FIXED_UPDATE: PathLookup = type_path!(bevy_app::main_schedule::FixedUpdate);
/// <https://github.com/bevyengine/bevy/blob/v0.18.0/crates/bevy_ecs/src/message/mod.rs#L96>
/// <https://github.com/bevyengine/bevy/blob/v0.19.0/crates/bevy_ecs/src/message/mod.rs#L100>
pub static MESSAGE: PathLookup = type_path!(bevy_ecs::message::Message);
/// <https://githu.com/bevyengine/bevy/blob/v0.18.0/crates/bevy_ecs/src/message/messages.rs#L95>
/// <https://github.com/bevyengine/bevy/blob/v0.19.0/crates/bevy_ecs/src/message/messages.rs#L95>
pub static MESSAGES: PathLookup = type_path!(bevy_ecs::message::Messages);
/// <https://github.com/bevyengine/bevy/blob/v0.18.0/crates/bevy_ecs/src/change_detection/params.rs#L513>
/// <https://github.com/bevyengine/bevy/blob/v0.19.0/crates/bevy_ecs/src/change_detection/params.rs#L1229>
pub static MUT_UNTYPED: PathLookup = type_path!(bevy_ecs::change_detection::params::MutUntyped);
/// <https://github.com/bevyengine/bevy/blob/v0.18.0/crates/bevy_ecs/src/change_detection/params.rs#L415>
/// <https://github.com/bevyengine/bevy/blob/v0.19.0/crates/bevy_ecs/src/change_detection/params.rs#L908>
pub static MUT: PathLookup = type_path!(bevy_ecs::change_detection::params::Mut);
/// <https://github.com/bevyengine/bevy/blob/v0.18.0/crates/bevy_ecs/src/change_detection/params.rs#L257>
/// <https://github.com/bevyengine/bevy/blob/v0.19.0/crates/bevy_ecs/src/change_detection/params.rs#L620>
pub static NON_SEND_MUT: PathLookup = type_path!(bevy_ecs::change_detection::params::NonSendMut);
/// <https://github.com/bevyengine/bevy/blob/v0.18.0/crates/bevy_reflect/src/reflect.rs#L99>
/// <https://github.com/bevyengine/bevy/blob/v0.19.0/crates/bevy_reflect/src/reflect.rs#L101>
pub static PARTIAL_REFLECT: PathLookup = type_path!(bevy_reflect::reflect::PartialReflect);
/// <https://github.com/bevyengine/bevy/blob/v0.18.0/crates/bevy_app/src/plugin.rs#L57>
/// <https://github.com/bevyengine/bevy/blob/v0.19.0/crates/bevy_app/src/plugin.rs#L57>
pub static PLUGIN: PathLookup = type_path!(bevy_app::plugin::Plugin);
/// <https://github.com/bevyengine/bevy/blob/v0.18.0/crates/bevy_ptr/src/lib.rs#L307>
/// <https://github.com/bevyengine/bevy/blob/v0.19.0/crates/bevy_ptr/src/lib.rs#L307>
pub static PTR_MUT: PathLookup = type_path!(bevy_ptr::PtrMut);
/// <https://github.com/bevyengine/bevy/blob/v0.18.0/crates/bevy_ecs/src/system/query.rs#L485>
/// <https://github.com/bevyengine/bevy/blob/v0.19.0/crates/bevy_ecs/src/system/query.rs#L487>
pub static QUERY: PathLookup = type_path!(bevy_ecs::system::query::Query);
/// <https://github.com/bevyengine/bevy/blob/v0.18.0/crates/bevy_reflect/src/reflect.rs#L415>
/// <https://github.com/bevyengine/bevy/blob/v0.19.0/crates/bevy_reflect/src/reflect.rs#L421>
pub static REFLECT: PathLookup = type_path!(bevy_reflect::reflect::Reflect);
/// <https://github.com/bevyengine/bevy/blob/v0.18.0/crates/bevy_ecs/src/relationship/related_methods.rs#L565>
/// <https://github.com/bevyengine/bevy/blob/v0.19.0/crates/bevy_ecs/src/relationship/related_methods.rs#L565>
pub static RELATED_SPAWNER: PathLookup =
type_path!(bevy_ecs::relationship::related_methods::RelatedSpawner);
/// <https://github.com/bevyengine/bevy/blob/v0.18.0/crates/bevy_ecs/src/relationship/related_methods.rs#L611>
/// <https://github.com/bevyengine/bevy/blob/v0.19.0/crates/bevy_ecs/src/relationship/related_methods.rs#L611>
pub static RELATED_SPAWNER_COMMANDS: PathLookup =
type_path!(bevy_ecs::relationship::related_methods::RelatedSpawnerCommands);
/// <https://github.com/bevyengine/bevy/blob/v0.18.0/crates/bevy_ecs/src/change_detection/params.rs#L172>
/// <https://github.com/bevyengine/bevy/blob/v0.19.0/crates/bevy_ecs/src/change_detection/params.rs#L535>
pub static RES_MUT: PathLookup = type_path!(bevy_ecs::change_detection::params::ResMut);
/// <https://github.com/bevyengine/bevy/blob/v0.18.0/crates/bevy_ecs/src/resource.rs#L75>
/// <https://github.com/bevyengine/bevy/blob/v0.19.0/crates/bevy_ecs/src/resource.rs#L87>
pub static RESOURCE: PathLookup = type_path!(bevy_ecs::resource::Resource);
/// <https://github.com/bevyengine/bevy/blob/v0.18.0/crates/bevy_ecs/src/schedule/set.rs#L154>
/// <https://github.com/bevyengine/bevy/blob/v0.19.0/crates/bevy_ecs/src/schedule/set.rs#L154>
pub static SYSTEM_SET: PathLookup = type_path!(bevy_ecs::schedule::set::SystemSet);
/// <https://github.com/bevyengine/bevy/blob/v0.18.0/crates/bevy_app/src/main_schedule.rs#L173>
/// <https://github.com/bevyengine/bevy/blob/v0.19.0/crates/bevy_app/src/main_schedule.rs#L173>
pub static UPDATE: PathLookup = type_path!(bevy_app::main_schedule::Update);
/// <https://github.com/bevyengine/bevy/blob/v0.18.0/crates/bevy_ecs/src/query/filter.rs#L142>
/// <https://github.com/bevyengine/bevy/blob/v0.19.0/crates/bevy_ecs/src/query/filter.rs#L142>
pub static WITH: PathLookup = type_path!(bevy_ecs::query::filter::With);
/// <https://github.com/bevyengine/bevy/blob/v0.18.0/crates/bevy_ecs/src/world/mod.rs#L92>
/// <https://github.com/bevyengine/bevy/blob/v0.19.0/crates/bevy_ecs/src/world/mod.rs#L98>
pub static WORLD: PathLookup = type_path!(bevy_ecs::world::World);
4 changes: 4 additions & 0 deletions bevy_lint/tests/ui/missing_reflect/impl.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ struct MyResource {

//~v NOTE: `Resource` implemented here
impl Resource for MyResource {}
impl Component for MyResource {
const STORAGE_TYPE: StorageType = StorageType::Table;
type Mutability = Mutable;
}

//~| HELP: `Reflect` can be automatically derived
//~v ERROR: defined an event without a `Reflect` implementation
Expand Down
4 changes: 4 additions & 0 deletions bevy_lint/tests/ui/missing_reflect/impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ struct MyResource {

//~v NOTE: `Resource` implemented here
impl Resource for MyResource {}
impl Component for MyResource {
const STORAGE_TYPE: StorageType = StorageType::Table;
type Mutability = Mutable;
}

//~| HELP: `Reflect` can be automatically derived
//~v ERROR: defined an event without a `Reflect` implementation
Expand Down
28 changes: 14 additions & 14 deletions bevy_lint/tests/ui/missing_reflect/impl.stderr
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
error: defined an event without a `Reflect` implementation
--> tests/ui/missing_reflect/impl.rs:42:1
--> tests/ui/missing_reflect/impl.rs:46:1
|
42 | struct MyEvent(String);
46 | struct MyEvent(String);
| ^^^^^^^^^^^^^^^^^^^^^^^
|
note: `Event` implemented here
--> tests/ui/missing_reflect/impl.rs:45:1
--> tests/ui/missing_reflect/impl.rs:49:1
|
45 | / impl Event for MyEvent {
46 | | type Trigger<'a> = GlobalTrigger;
47 | | }
49 | / impl Event for MyEvent {
50 | | type Trigger<'a> = GlobalTrigger;
51 | | }
| |_^
note: the lint level is defined here
--> tests/ui/missing_reflect/impl.rs:8:9
Expand All @@ -18,25 +18,25 @@ note: the lint level is defined here
| ^^^^^^^^^^^^^^^^^^^^^
help: `Reflect` can be automatically derived
|
42 + #[derive(Reflect)]
43 | struct MyEvent(String);
46 + #[derive(Reflect)]
47 | struct MyEvent(String);
|

error: defined a message without a `Reflect` implementation
--> tests/ui/missing_reflect/impl.rs:51:1
--> tests/ui/missing_reflect/impl.rs:55:1
|
51 | struct MyMessage(String);
55 | struct MyMessage(String);
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: `Message` implemented here
--> tests/ui/missing_reflect/impl.rs:54:1
--> tests/ui/missing_reflect/impl.rs:58:1
|
54 | impl Message for MyMessage {}
58 | impl Message for MyMessage {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: `Reflect` can be automatically derived
|
51 + #[derive(Reflect)]
52 | struct MyMessage(String);
55 + #[derive(Reflect)]
56 | struct MyMessage(String);
|

error: defined a component without a `Reflect` implementation
Expand Down
4 changes: 4 additions & 0 deletions bevy_lint/tests/ui/missing_reflect/impl_ref.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ struct MyResource {

//~v NOTE: `Resource` implemented here
impl Resource for &'static &'static MyResource {}
impl Component for &'static &'static MyResource {
const STORAGE_TYPE: StorageType = StorageType::Table;
type Mutability = Mutable;
}

//~| HELP: `Reflect` can be automatically derived
//~v ERROR: defined an event without a `Reflect` implementation
Expand Down
4 changes: 4 additions & 0 deletions bevy_lint/tests/ui/missing_reflect/impl_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ struct MyResource {

//~v NOTE: `Resource` implemented here
impl Resource for &'static &'static MyResource {}
impl Component for &'static &'static MyResource {
const STORAGE_TYPE: StorageType = StorageType::Table;
type Mutability = Mutable;
}

//~| HELP: `Reflect` can be automatically derived
//~v ERROR: defined an event without a `Reflect` implementation
Expand Down
28 changes: 14 additions & 14 deletions bevy_lint/tests/ui/missing_reflect/impl_ref.stderr
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
error: defined an event without a `Reflect` implementation
--> tests/ui/missing_reflect/impl_ref.rs:45:1
--> tests/ui/missing_reflect/impl_ref.rs:49:1
|
45 | struct MyEvent(String);
49 | struct MyEvent(String);
| ^^^^^^^^^^^^^^^^^^^^^^^
|
note: `Event` implemented here
--> tests/ui/missing_reflect/impl_ref.rs:48:1
--> tests/ui/missing_reflect/impl_ref.rs:52:1
|
48 | / impl Event for &'static &'static &'static MyEvent {
49 | | type Trigger<'a> = GlobalTrigger;
50 | | }
52 | / impl Event for &'static &'static &'static MyEvent {
53 | | type Trigger<'a> = GlobalTrigger;
54 | | }
| |_^
note: the lint level is defined here
--> tests/ui/missing_reflect/impl_ref.rs:13:9
Expand All @@ -18,25 +18,25 @@ note: the lint level is defined here
| ^^^^^^^^^^^^^^^^^^^^^
help: `Reflect` can be automatically derived
|
45 + #[derive(Reflect)]
46 | struct MyEvent(String);
49 + #[derive(Reflect)]
50 | struct MyEvent(String);
|

error: defined a message without a `Reflect` implementation
--> tests/ui/missing_reflect/impl_ref.rs:54:1
--> tests/ui/missing_reflect/impl_ref.rs:58:1
|
54 | struct MyMessage(String);
58 | struct MyMessage(String);
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: `Message` implemented here
--> tests/ui/missing_reflect/impl_ref.rs:57:1
--> tests/ui/missing_reflect/impl_ref.rs:61:1
|
57 | impl Message for &'static &'static &'static MyMessage {}
61 | impl Message for &'static &'static &'static MyMessage {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: `Reflect` can be automatically derived
|
54 + #[derive(Reflect)]
55 | struct MyMessage(String);
58 + #[derive(Reflect)]
59 | struct MyMessage(String);
|

error: defined a component without a `Reflect` implementation
Expand Down
16 changes: 16 additions & 0 deletions bevy_lint/tests/ui/panicking_methods/world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,34 @@ fn main() {
//~^ ERROR: called a `World` method that can panic when a non-panicking alternative exists
//~| HELP: use `World::get_resource_ref::<Jeffrey>(&world)`

#[expect(
deprecated,
reason = "While this method is deprecated, we should still check for it while it exists."
)]
world.non_send_resource::<Patrick>();
//~^ ERROR: called a `World` method that can panic when a non-panicking alternative exists
//~| HELP: use `world.get_non_send_resource::<Patrick>()`

#[expect(
deprecated,
reason = "While this method is deprecated, we should still check for it while it exists."
)]
World::non_send_resource::<Patrick>(&world);
//~^ ERROR: called a `World` method that can panic when a non-panicking alternative exists
//~| HELP: use `World::get_non_send_resource::<Patrick>(&world)`

#[expect(
deprecated,
reason = "While this method is deprecated, we should still check for it while it exists."
)]
world.non_send_resource_mut::<Patrick>();
//~^ ERROR: called a `World` method that can panic when a non-panicking alternative exists
//~| HELP: use `world.get_non_send_resource_mut::<Patrick>()`

#[expect(
deprecated,
reason = "While this method is deprecated, we should still check for it while it exists."
)]
World::non_send_resource_mut::<Patrick>(&mut world);
//~^ ERROR: called a `World` method that can panic when a non-panicking alternative exists
//~| HELP: use `World::get_non_send_resource_mut::<Patrick>(&mut world)`
Expand Down
Loading
Loading