|
1 | | -//! A collection of hardcoded types and functions that the linter uses. |
| 1 | +//! A collection of hardcoded type and function paths that the linter uses. |
2 | 2 | //! |
3 | 3 | //! Since Bevy is a 3rd-party crate, we cannot easily add diagnostic items to it. In lieu of this, |
4 | 4 | //! we hardcode the paths to the items we need here, for easy referencing. |
5 | | -//! |
6 | | -//! Also see: [`match_type()`](clippy_utils::ty::match_type), |
7 | | -//! [`match_def_path()`](clippy_utils::match_def_path). |
8 | 5 |
|
9 | | -/// <https://github.com/bevyengine/bevy/blob/release-0.16.0/crates/bevy_app/src/app.rs#L78> |
10 | | -pub const APP: [&str; 3] = ["bevy_app", "app", "App"]; |
11 | | -/// <https://github.com/bevyengine/bevy/blob/release-0.16.0/crates/bevy_ecs/src/system/commands/command.rs#L48> |
12 | | -pub const COMMANDS: [&str; 4] = ["bevy_ecs", "system", "commands", "Commands"]; |
13 | | -/// <https://github.com/bevyengine/bevy/blob/release-0.16.0/crates/bevy_ecs/src/component.rs#L456> |
14 | | -pub const COMPONENT: [&str; 3] = ["bevy_ecs", "component", "Component"]; |
15 | | -/// <https://github.com/bevyengine/bevy/blob/release-0.16.0/crates/bevy_ecs/src/system/system_param.rs#L1378> |
16 | | -pub const DEFERRED: [&str; 4] = ["bevy_ecs", "system", "system_param", "Deferred"]; |
17 | | -/// <https://github.com/bevyengine/bevy/blob/release-0.16.0/crates/bevy_ecs/src/world/deferred_world.rs#L23> |
18 | | -pub const DEFERRED_WORLD: [&str; 4] = ["bevy_ecs", "world", "deferred_world", "DeferredWorld"]; |
19 | | -/// <https://github.com/bevyengine/bevy/blob/release-0.16.0/crates/bevy_ecs/src/system/commands/mod.rs#L1167> |
20 | | -pub const ENTITY_COMMANDS: [&str; 4] = ["bevy_ecs", "system", "commands", "EntityCommands"]; |
21 | | -/// <https://github.com/bevyengine/bevy/blob/release-0.16.0/crates/bevy_ecs/src/world/entity_ref.rs#L448> |
22 | | -pub const ENTITY_MUT: [&str; 4] = ["bevy_ecs", "world", "entity_ref", "EntityMut"]; |
23 | | -/// <https://github.com/bevyengine/bevy/blob/release-0.16.0/crates/bevy_ecs/src/event/base.rs#L48> |
24 | | -pub const EVENT: [&str; 4] = ["bevy_ecs", "event", "base", "Event"]; |
25 | | -/// <https://github.com/bevyengine/bevy/blob/release-0.16.0/crates/bevy_ecs/src/event/collections.rs#L94> |
26 | | -pub const EVENTS: [&str; 4] = ["bevy_ecs", "event", "collections", "Events"]; |
27 | | -/// <https://github.com/bevyengine/bevy/blob/release-0.16.0/crates/bevy_ecs/src/world/entity_ref.rs#L3687> |
28 | | -pub const FILTERED_ENTITY_MUT: [&str; 4] = ["bevy_ecs", "world", "entity_ref", "FilteredEntityMut"]; |
29 | | -/// <https://github.com/bevyengine/bevy/blob/release-0.16.0/crates/bevy_ecs/src/change_detection.rs#L920> |
30 | | -pub const MUT: [&str; 3] = ["bevy_ecs", "change_detection", "Mut"]; |
31 | | -/// <https://github.com/bevyengine/bevy/blob/release-0.16.0/crates/bevy_ecs/src/change_detection.rs#L1020> |
32 | | -pub const MUT_UNTYPED: [&str; 3] = ["bevy_ecs", "change_detection", "MutUntyped"]; |
33 | | -/// <https://github.com/bevyengine/bevy/blob/release-0.16.0/crates/bevy_ecs/src/change_detection.rs#L734> |
34 | | -pub const NON_SEND_MUT: [&str; 3] = ["bevy_ecs", "change_detection", "NonSendMut"]; |
| 6 | +use clippy_utils::paths::{PathLookup, PathNS}; |
| 7 | + |
| 8 | +use crate::sym; |
| 9 | + |
| 10 | +/// Returns a new [`PathLookup`] in the [type namespace](PathNS::Type) for a given path. |
| 11 | +/// |
| 12 | +/// `type_path!()` takes a `::`-separated list of identifiers. Each identifier should correspond to |
| 13 | +/// a [`Symbol`](rustc_span::Symbol) in [`crate::sym`]. For example, |
| 14 | +/// `type_path!(bevy_app::app::App)` creates a [`PathLookup`] in the [`PathNS::Type`] namespace |
| 15 | +/// with the path `[sym::bevy_app, sym::app, sym::App]`. |
| 16 | +macro_rules! type_path { |
| 17 | + ($first:ident $(:: $remaining:ident)*) => { |
| 18 | + PathLookup::new(PathNS::Type, &[sym::$first, $(sym::$remaining),*]) |
| 19 | + }; |
| 20 | +} |
| 21 | + |
| 22 | +// Keep the following list alphabetically sorted :) |
| 23 | + |
| 24 | +/// <https://github.com/bevyengine/bevy/blob/v0.16.0/crates/bevy_app/src/app.rs#L78> |
| 25 | +pub static APP: PathLookup = type_path!(bevy_app::app::App); |
| 26 | +/// <https://github.com/bevyengine/bevy/blob/v0.16.0/crates/bevy_ecs/src/system/commands/mod.rs#L101> |
| 27 | +pub static COMMANDS: PathLookup = type_path!(bevy_ecs::system::commands::Commands); |
| 28 | +/// <https://github.com/bevyengine/bevy/blob/v0.16.0/crates/bevy_ecs/src/component.rs#L485> |
| 29 | +pub static COMPONENT: PathLookup = type_path!(bevy_ecs::component::Component); |
| 30 | +/// <https://github.com/bevyengine/bevy/blob/v0.16.0/crates/bevy_ecs/src/world/deferred_world.rs#L23> |
| 31 | +pub static DEFERRED_WORLD: PathLookup = type_path!(bevy_ecs::world::deferred_world::DeferredWorld); |
| 32 | +/// <https://github.com/bevyengine/bevy/blob/v0.16.0/crates/bevy_ecs/src/system/system_param.rs#L1415> |
| 33 | +pub static DEFERRED: PathLookup = type_path!(bevy_ecs::system::system_param::Deferred); |
| 34 | +/// <https://github.com/bevyengine/bevy/blob/v0.16.0/crates/bevy_ecs/src/system/commands/mod.rs#L1233> |
| 35 | +pub static ENTITY_COMMANDS: PathLookup = type_path!(bevy_ecs::system::commands::EntityCommands); |
| 36 | +/// <https://github.com/bevyengine/bevy/blob/v0.16.0/crates/bevy_ecs/src/world/entity_ref.rs#L448> |
| 37 | +pub static ENTITY_MUT: PathLookup = type_path!(bevy_ecs::world::entity_ref::EntityMut); |
| 38 | +/// <https://github.com/bevyengine/bevy/blob/v0.16.0/crates/bevy_ecs/src/event/base.rs#L48> |
| 39 | +pub static EVENT: PathLookup = type_path!(bevy_ecs::event::base::Event); |
| 40 | +/// <https://github.com/bevyengine/bevy/blob/v0.16.0/crates/bevy_ecs/src/event/collections.rs#L94> |
| 41 | +pub static EVENTS: PathLookup = type_path!(bevy_ecs::event::collections::Events); |
| 42 | +/// <https://github.com/bevyengine/bevy/blob/v0.16.0/crates/bevy_ecs/src/world/entity_ref.rs#L3687> |
| 43 | +pub static FILTERED_ENTITY_MUT: PathLookup = type_path!(bevy_ecs::world::entity_ref::FilteredEntityMut); |
| 44 | +/// <https://github.com/bevyengine/bevy/blob/v0.16.0/crates/bevy_ecs/src/change_detection.rs#L1059> |
| 45 | +pub static MUT_UNTYPED: PathLookup = type_path!(bevy_ecs::change_detection::MutUntyped); |
| 46 | +/// <https://github.com/bevyengine/bevy/blob/v0.16.0/crates/bevy_ecs/src/change_detection.rs#L959> |
| 47 | +pub static MUT: PathLookup = type_path!(bevy_ecs::change_detection::Mut); |
| 48 | +/// <https://github.com/bevyengine/bevy/blob/v0.16.0/crates/bevy_ecs/src/change_detection.rs#L773> |
| 49 | +pub static NON_SEND_MUT: PathLookup = type_path!(bevy_ecs::change_detection::NonSendMut); |
35 | 50 | /// <https://github.com/bevyengine/bevy/blob/v0.16.0/crates/bevy_reflect/src/reflect.rs#L84> |
36 | | -pub const PARTIAL_REFLECT: [&str; 3] = ["bevy_reflect", "reflect", "PartialReflect"]; |
37 | | -/// <https://github.com/bevyengine/bevy/blob/release-0.16.0/crates/bevy_app/src/plugin.rs#L57> |
38 | | -pub const PLUGIN: [&str; 3] = ["bevy_app", "plugin", "Plugin"]; |
39 | | -/// <https://github.com/bevyengine/bevy/blob/release-0.16.0/crates/bevy_ptr/src/lib.rs#L178> |
40 | | -pub const PTR_MUT: [&str; 2] = ["bevy_ptr", "PtrMut"]; |
41 | | -/// <https://github.com/bevyengine/bevy/blob/release-0.16.0/crates/bevy_ecs/src/system/query.rs#L379> |
42 | | -pub const QUERY: [&str; 4] = ["bevy_ecs", "system", "query", "Query"]; |
43 | | -/// <https://github.com/bevyengine/bevy/blob/release-0.16.0/crates/bevy_reflect/src/reflect.rs#L413> |
44 | | -pub const REFLECT: [&str; 3] = ["bevy_reflect", "reflect", "Reflect"]; |
45 | | -/// <https://github.com/bevyengine/bevy/blob/release-0.16.0/crates/bevy_ecs/src/change_detection.rs#L675> |
46 | | -pub const RES_MUT: [&str; 3] = ["bevy_ecs", "change_detection", "ResMut"]; |
47 | | -/// <https://github.com/bevyengine/bevy/blob/release-0.16.0/crates/bevy_ecs/src/resource.rs#L75> |
48 | | -pub const RESOURCE: [&str; 3] = ["bevy_ecs", "resource", "Resource"]; |
49 | | -/// <https://github.com/bevyengine/bevy/blob/release-0.16.0/crates/bevy_ecs/src/schedule/set.rs> |
50 | | -pub const SYSTEM_SET: [&str; 4] = ["bevy_ecs", "schedule", "set", "SystemSet"]; |
51 | | -/// <https://github.com/bevyengine/bevy/blob/release-0.16.0/crates/bevy_ecs/src/world/mod.rs#L94> |
52 | | -pub const WORLD: [&str; 3] = ["bevy_ecs", "world", "World"]; |
| 51 | +pub static PARTIAL_REFLECT: PathLookup = type_path!(bevy_reflect::reflect::PartialReflect); |
| 52 | +/// <https://github.com/bevyengine/bevy/blob/v0.16.0/crates/bevy_app/src/plugin.rs#L57> |
| 53 | +pub static PLUGIN: PathLookup = type_path!(bevy_app::plugin::Plugin); |
| 54 | +/// <https://github.com/bevyengine/bevy/blob/v0.16.0/crates/bevy_ptr/src/lib.rs#L178> |
| 55 | +pub static PTR_MUT: PathLookup = type_path!(bevy_ptr::PtrMut); |
| 56 | +/// <https://github.com/bevyengine/bevy/blob/v0.16.0/crates/bevy_ecs/src/system/query.rs#L482> |
| 57 | +pub static QUERY: PathLookup = type_path!(bevy_ecs::system::query::Query); |
| 58 | +/// <https://github.com/bevyengine/bevy/blob/v0.16.0/crates/bevy_reflect/src/reflect.rs#L413> |
| 59 | +pub static REFLECT: PathLookup = type_path!(bevy_reflect::reflect::Reflect); |
| 60 | +/// <https://github.com/bevyengine/bevy/blob/v0.16.0/crates/bevy_ecs/src/change_detection.rs#L714> |
| 61 | +pub static RES_MUT: PathLookup = type_path!(bevy_ecs::change_detection::ResMut); |
| 62 | +/// <https://github.com/bevyengine/bevy/blob/v0.16.0/crates/bevy_ecs/src/resource.rs#L75> |
| 63 | +pub static RESOURCE: PathLookup = type_path!(bevy_ecs::resource::Resource); |
| 64 | +/// <https://github.com/bevyengine/bevy/blob/v0.16.0/crates/bevy_ecs/src/schedule/set.rs#L35> |
| 65 | +pub static SYSTEM_SET: PathLookup = type_path!(bevy_ecs::schedule::set::SystemSet); |
| 66 | +/// <https://github.com/bevyengine/bevy/blob/v0.16.0/crates/bevy_ecs/src/world/mod.rs#L94> |
| 67 | +pub static WORLD: PathLookup = type_path!(bevy_ecs::world::World); |
0 commit comments