From 605d7a792846b35c28a85ab3f86ac789d4842048 Mon Sep 17 00:00:00 2001 From: Gino Valente <49806985+MrGVSV@users.noreply.github.com> Date: Sun, 10 Nov 2024 08:45:20 -0700 Subject: [PATCH 1/8] bevy_lint: Add `zst_query` lint (#168) Resolves #130 --- bevy_lint/src/lib.rs | 3 + bevy_lint/src/lints/mod.rs | 3 + bevy_lint/src/lints/zst_query.rs | 145 ++++++++++++++++++++++ bevy_lint/src/utils/hir_parse.rs | 44 +++++++ bevy_lint/src/utils/mod.rs | 1 + bevy_lint/tests/ui/zst_query/query.rs | 89 +++++++++++++ bevy_lint/tests/ui/zst_query/query.stderr | 63 ++++++++++ 7 files changed, 348 insertions(+) create mode 100644 bevy_lint/src/lints/zst_query.rs create mode 100644 bevy_lint/src/utils/hir_parse.rs create mode 100644 bevy_lint/src/utils/mod.rs create mode 100644 bevy_lint/tests/ui/zst_query/query.rs create mode 100644 bevy_lint/tests/ui/zst_query/query.stderr diff --git a/bevy_lint/src/lib.rs b/bevy_lint/src/lib.rs index d141d5ad..7b9f0398 100644 --- a/bevy_lint/src/lib.rs +++ b/bevy_lint/src/lib.rs @@ -14,9 +14,11 @@ // This is a list of every single `rustc` crate used within this library. If you need another, add // it here! +extern crate rustc_abi; extern crate rustc_driver; extern crate rustc_errors; extern crate rustc_hir; +extern crate rustc_hir_analysis; extern crate rustc_interface; extern crate rustc_lint; extern crate rustc_middle; @@ -28,5 +30,6 @@ pub mod groups; mod lint; pub mod lints; mod paths; +mod utils; pub use self::callback::BevyLintCallback; diff --git a/bevy_lint/src/lints/mod.rs b/bevy_lint/src/lints/mod.rs index 01246f3d..d57368c7 100644 --- a/bevy_lint/src/lints/mod.rs +++ b/bevy_lint/src/lints/mod.rs @@ -10,6 +10,7 @@ pub mod main_return_without_appexit; pub mod missing_reflect; pub mod panicking_methods; pub mod plugin_not_ending_in_plugin; +pub mod zst_query; pub(crate) static LINTS: &[&BevyLint] = &[ insert_event_resource::INSERT_EVENT_RESOURCE, @@ -18,6 +19,7 @@ pub(crate) static LINTS: &[&BevyLint] = &[ missing_reflect::MISSING_REFLECT, panicking_methods::PANICKING_WORLD_METHODS, plugin_not_ending_in_plugin::PLUGIN_NOT_ENDING_IN_PLUGIN, + zst_query::ZST_QUERY, ]; pub(crate) fn register_lints(store: &mut LintStore) { @@ -31,4 +33,5 @@ pub(crate) fn register_passes(store: &mut LintStore) { store.register_late_pass(|_| Box::new(missing_reflect::MissingReflect)); store.register_late_pass(|_| Box::new(panicking_methods::PanickingMethods)); store.register_late_pass(|_| Box::new(plugin_not_ending_in_plugin::PluginNotEndingInPlugin)); + store.register_late_pass(|_| Box::new(zst_query::ZstQuery)); } diff --git a/bevy_lint/src/lints/zst_query.rs b/bevy_lint/src/lints/zst_query.rs new file mode 100644 index 00000000..4741f374 --- /dev/null +++ b/bevy_lint/src/lints/zst_query.rs @@ -0,0 +1,145 @@ +//! Checks for queries that query for a zero-sized type. +//! +//! # Motivation +//! +//! Zero-sized types (ZSTs) are types that have no size as a result of containing no runtime data. +//! In Bevy, such types are often used as marker components and are best used as filters. +//! +//! # Example +//! +//! ``` +//! # use bevy::prelude::*; +//! +//! #[derive(Component)] +//! struct Player; +//! +//! fn move_player(mut query: Query<(&mut Transform, &Player)>) { +//! // ... +//! } +//! ``` +//! +//! Use instead: +//! +//! ``` +//! # use bevy::prelude::*; +//! +//! #[derive(Component)] +//! struct Player; +//! +//! fn move_player(query: Query<&mut Transform, With>) { +//! // ... +//! } +//! ``` + +use crate::{ + declare_bevy_lint, + utils::hir_parse::{detuple, generic_type_at}, +}; +use clippy_utils::{ + diagnostics::span_lint_and_help, + ty::{is_normalizable, match_type}, +}; +use rustc_abi::Size; +use rustc_hir_analysis::collect::ItemCtxt; +use rustc_lint::{LateContext, LateLintPass}; +use rustc_middle::ty::{ + layout::{LayoutOf, TyAndLayout}, + Ty, +}; +use rustc_session::declare_lint_pass; + +declare_bevy_lint! { + pub ZST_QUERY, + RESTRICTION, + "query for a zero-sized type" +} + +declare_lint_pass! { + ZstQuery => [ZST_QUERY.lint] +} + +impl<'tcx> LateLintPass<'tcx> for ZstQuery { + fn check_ty(&mut self, cx: &LateContext<'tcx>, hir_ty: &'tcx rustc_hir::Ty<'tcx>) { + let item_cx = ItemCtxt::new(cx.tcx, hir_ty.hir_id.owner.def_id); + let ty = item_cx.lower_ty(hir_ty); + + let Some(query_kind) = QueryKind::try_from_ty(cx, ty) else { + return; + }; + + let Some(query_data_ty) = generic_type_at(cx, hir_ty, 2) else { + return; + }; + + for hir_ty in detuple(*query_data_ty) { + let ty = item_cx.lower_ty(&hir_ty); + + // We want to make sure we're evaluating `Foo` and not `&Foo`/`&mut Foo` + let peeled = ty.peel_refs(); + + if !is_zero_sized(cx, peeled).unwrap_or_default() { + continue; + } + + // TODO: We can also special case `Option<&Foo>`/`Option<&mut Foo>` to + // instead suggest `Has` + span_lint_and_help( + cx, + ZST_QUERY.lint, + hir_ty.span, + ZST_QUERY.lint.desc, + None, + query_kind.help(&peeled), + ); + } + } +} + +enum QueryKind { + Query, +} + +impl QueryKind { + fn try_from_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> Option { + if match_type(cx, ty, &crate::paths::QUERY) { + Some(Self::Query) + } else { + None + } + } + + fn help(&self, ty: &Ty<'_>) -> String { + // It should be noted that `With` is not always the best filter to suggest. + // While it's most often going to be what users want, there's also `Added` + // and `Changed` which might be more appropriate in some cases + // (i.e. users are calling `foo.is_added()` or `foo.is_changed()` in the body of + // the system). + // In the future, we might want to span the usage site of `is_added()`/`is_changed()` + // and suggest to use `Added`/`Changed` instead. + match self { + Self::Query => format!("consider using a filter instead: `With<{ty}>`"), + } + } +} + +/// Checks if a type is zero-sized. +/// +/// Returns: +/// - `Some(true)` if the type is most likely a ZST +/// - `Some(false)` if the type is most likely not a ZST +/// - `None` if we cannot determine the size (e.g., type is not normalizable) +fn is_zero_sized<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> Option { + // `cx.layout_of()` panics if the type is not normalizable. + if !is_normalizable(cx, cx.param_env, ty) { + return None; + } + + // Note: we don't use `approx_ty_size` from `clippy_utils` here + // because it will return `0` as the default value if the type is not + // normalizable, which will put us at risk of emitting more false positives. + if let Ok(TyAndLayout { layout, .. }) = cx.layout_of(ty) { + Some(layout.size() == Size::ZERO) + } else { + None + } +} diff --git a/bevy_lint/src/utils/hir_parse.rs b/bevy_lint/src/utils/hir_parse.rs new file mode 100644 index 00000000..b93aaa20 --- /dev/null +++ b/bevy_lint/src/utils/hir_parse.rs @@ -0,0 +1,44 @@ +//! Utility functions for parsing HIR types. + +use rustc_hir::{GenericArg, Node, QPath, Ty, TyKind}; +use rustc_lint::LateContext; + +/// Returns the list of types inside a tuple type. +/// +/// If the type is not a tuple, returns a list containing the type itself. +/// +/// This function will work for both tuples and references to tuples, +/// such as `(f32, &str)` and `&(f32, &str)`. +pub fn detuple(ty: Ty<'_>) -> Vec> { + if let TyKind::Tup(items) = ty.peel_refs().kind { + items.to_vec() + } else { + vec![ty] + } +} + +/// Gets the [`Ty`] for a generic argument at the specified index. +/// +/// If the generic argument is not a type, returns `None`. +pub fn generic_type_at<'tcx>( + cx: &LateContext<'tcx>, + hir_ty: &'tcx Ty<'tcx>, + index: usize, +) -> Option<&'tcx Ty<'tcx>> { + let generic_arg = generic_at(hir_ty, index)?; + let generic_node = cx.tcx.hir_node(generic_arg.hir_id()); + + if let Node::Ty(ty) = generic_node { + Some(ty) + } else { + None + } +} +/// Returns the [`GenericArg`] at the given index. +pub fn generic_at<'hir>(hir_ty: &'hir Ty<'hir>, index: usize) -> Option<&'hir GenericArg<'hir>> { + let TyKind::Path(QPath::Resolved(_, path)) = hir_ty.kind else { + return None; + }; + + path.segments.last()?.args().args.get(index) +} diff --git a/bevy_lint/src/utils/mod.rs b/bevy_lint/src/utils/mod.rs new file mode 100644 index 00000000..94a682b0 --- /dev/null +++ b/bevy_lint/src/utils/mod.rs @@ -0,0 +1 @@ +pub mod hir_parse; diff --git a/bevy_lint/tests/ui/zst_query/query.rs b/bevy_lint/tests/ui/zst_query/query.rs new file mode 100644 index 00000000..f0567264 --- /dev/null +++ b/bevy_lint/tests/ui/zst_query/query.rs @@ -0,0 +1,89 @@ +//! This tests the `zst_query` lint, specifically when triggered on the `Query` type. + +#![feature(register_tool)] +#![register_tool(bevy)] +#![deny(bevy::zst_query)] + +use bevy::prelude::*; +use std::marker::PhantomData; + +#[derive(Component)] +struct ZST; + +#[derive(Component)] +#[allow(dead_code)] +struct NonZST(u32); + +#[derive(Component)] +#[allow(dead_code)] +struct Generic(T); + +#[derive(Component)] +#[allow(dead_code)] +struct Phantom(PhantomData); + +fn main() { + App::new() + .add_systems( + Startup, + ( + unit_query, + immutable_zst, + mutable_zst, + immutable_zst_tuple, + mutable_zst_tuple, + immutable_query, + mutable_query, + generic_immutable_query::, + generic_immutable_zst, + generic_mutable_zst, + generic_mutable_query::, + immutable_query_tuple, + mutable_query_tuple, + phantom_data_query, + ), + ) + .run(); +} + +fn unit_query(_query: Query<()>) {} + +//~| HELP: consider using a filter instead: `With` +//~v ERROR: query for a zero-sized type +fn immutable_zst(_query: Query<&ZST>) {} + +//~| HELP: consider using a filter instead: `With` +//~v ERROR: query for a zero-sized type +fn mutable_zst(_query: Query<&mut ZST>) {} + +//~| HELP: consider using a filter instead: `With` +//~v ERROR: query for a zero-sized type +fn immutable_zst_tuple(_query: Query<(Entity, &ZST)>) {} + +//~| HELP: consider using a filter instead: `With` +//~v ERROR: query for a zero-sized type +fn mutable_zst_tuple(_query: Query<(Entity, &mut ZST)>) {} + +fn immutable_query(_query: Query<&NonZST>) {} + +fn mutable_query(_query: Query<&mut NonZST>) {} + +fn generic_immutable_query(_query: Query<&Generic>) {} + +fn generic_mutable_query(_query: Query<&mut Generic>) {} + +//~| HELP: consider using a filter instead: `With>` +//~v ERROR: query for a zero-sized type +fn generic_immutable_zst(_query: Query<&Generic>) {} + +//~| HELP: consider using a filter instead: `With>` +//~v ERROR: query for a zero-sized type +fn generic_mutable_zst(_query: Query<&mut Generic>) {} + +fn immutable_query_tuple(_query: Query<(Entity, &NonZST)>) {} + +fn mutable_query_tuple(_query: Query<(Entity, &mut NonZST)>) {} + +//~| HELP: consider using a filter instead: `With>` +//~v ERROR: query for a zero-sized type +fn phantom_data_query(_query: Query<&Phantom>) {} diff --git a/bevy_lint/tests/ui/zst_query/query.stderr b/bevy_lint/tests/ui/zst_query/query.stderr new file mode 100644 index 00000000..b3291dd1 --- /dev/null +++ b/bevy_lint/tests/ui/zst_query/query.stderr @@ -0,0 +1,63 @@ +error: query for a zero-sized type + --> tests/ui/zst_query/query.rs:53:32 + | +53 | fn immutable_zst(_query: Query<&ZST>) {} + | ^^^^ + | + = help: consider using a filter instead: `With` +note: the lint level is defined here + --> tests/ui/zst_query/query.rs:5:9 + | +5 | #![deny(bevy::zst_query)] + | ^^^^^^^^^^^^^^^ + +error: query for a zero-sized type + --> tests/ui/zst_query/query.rs:57:30 + | +57 | fn mutable_zst(_query: Query<&mut ZST>) {} + | ^^^^^^^^ + | + = help: consider using a filter instead: `With` + +error: query for a zero-sized type + --> tests/ui/zst_query/query.rs:61:47 + | +61 | fn immutable_zst_tuple(_query: Query<(Entity, &ZST)>) {} + | ^^^^ + | + = help: consider using a filter instead: `With` + +error: query for a zero-sized type + --> tests/ui/zst_query/query.rs:65:45 + | +65 | fn mutable_zst_tuple(_query: Query<(Entity, &mut ZST)>) {} + | ^^^^^^^^ + | + = help: consider using a filter instead: `With` + +error: query for a zero-sized type + --> tests/ui/zst_query/query.rs:77:40 + | +77 | fn generic_immutable_zst(_query: Query<&Generic>) {} + | ^^^^^^^^^^^^^ + | + = help: consider using a filter instead: `With>` + +error: query for a zero-sized type + --> tests/ui/zst_query/query.rs:81:38 + | +81 | fn generic_mutable_zst(_query: Query<&mut Generic>) {} + | ^^^^^^^^^^^^^^^^^ + | + = help: consider using a filter instead: `With>` + +error: query for a zero-sized type + --> tests/ui/zst_query/query.rs:89:37 + | +89 | fn phantom_data_query(_query: Query<&Phantom>) {} + | ^^^^^^^^^^^^^^^^ + | + = help: consider using a filter instead: `With>` + +error: aborting due to 7 previous errors + From 8691821292922ba3b2ea7f52eb57cd637cfd5cfb Mon Sep 17 00:00:00 2001 From: BD103 <59022059+BD103@users.noreply.github.com> Date: Sun, 17 Nov 2024 11:29:18 -0500 Subject: [PATCH 2/8] Release `bevy_lint` v0.1.0 (#172) As per [the release checklist](https://github.com/TheBevyFlock/bevy_cli/blob/ff952b226f33615f989dec9e0432df3e89606313/bevy_lint/docs/release.md), this PR kicks off the release for `bevy_lint` v0.1.0. Now is the time to assess its current features, review any outstanding changes or bugs, and run tests on real-world projects. Once this pull request is approved by at least one core Bevy maintainer, I will merge it and create the Github release, then open a post-release PR setting up for v0.2.0-dev. Between the time this is merged and the post-release PR is merged there will be a feature freeze, preventing all other PRs related to `bevy_lint` from being merged. While I would appreciate freezing `bevy_cli` PRs as well for aesthetic reasons, it's not a requirement. :) --- Cargo.lock | 480 +++++++++++++++++++++++++++---------- bevy_lint/CHANGELOG.md | 5 +- bevy_lint/Cargo.toml | 6 +- bevy_lint/README.md | 8 +- bevy_lint/docs/index.md | 9 + bevy_lint/src/groups.rs | 15 +- bevy_lint/src/lint.rs | 1 + bevy_lint/src/lints/mod.rs | 4 +- rust-toolchain.toml | 2 +- 9 files changed, 387 insertions(+), 143 deletions(-) create mode 100644 bevy_lint/docs/index.md diff --git a/Cargo.lock b/Cargo.lock index 4a431ad6..9e9733cd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -284,9 +284,9 @@ dependencies = [ [[package]] name = "allocator-api2" -version = "0.2.18" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" +checksum = "45862d1c77f2228b9e10bc609d5bc203d86ebc9b87ad8d5d5167a6c9abf739d9" [[package]] name = "android_log-sys" @@ -301,14 +301,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24e35ed54e5ea7997c14ed4c70ba043478db1112e98263b3b035907aa197d991" dependencies = [ "anstyle", - "unicode-width", + "unicode-width 0.1.14", ] [[package]] name = "anstream" -version = "0.6.17" +version = "0.6.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23a1e53f0f5d86382dafe1cf314783b2044280f406e7e1506368220ad11b1338" +checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b" dependencies = [ "anstyle", "anstyle-parse", @@ -321,9 +321,9 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8365de52b16c035ff4fcafe0092ba9390540e3e352870ac09933bebcaa2c8c56" +checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" [[package]] name = "anstyle-parse" @@ -355,9 +355,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.91" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c042108f3ed77fd83760a5fd79b53be043192bb3b9dba91d8c574c0ada7850c8" +checksum = "4c95c10ba0b00a02636238b814946408b1322d5ac4760326e6fb8ec956d85775" [[package]] name = "anymap2" @@ -497,7 +497,7 @@ dependencies = [ "semver", "serde", "serde_json", - "toml_edit 0.22.22", + "toml_edit", "webbrowser", ] @@ -629,14 +629,14 @@ dependencies = [ [[package]] name = "bevy_lint" -version = "0.1.0-dev" +version = "0.1.0" dependencies = [ "anyhow", "bevy", "clippy_utils", "serde", "serde_json", - "toml_edit 0.22.22", + "toml_edit", "ui_test", ] @@ -664,7 +664,7 @@ dependencies = [ "proc-macro2", "quote", "syn", - "toml_edit 0.22.22", + "toml_edit", ] [[package]] @@ -852,12 +852,12 @@ dependencies = [ [[package]] name = "bstr" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40723b8fb387abc38f4f4a37c09073622e41dd12327033091ef8950659e6dc0c" +checksum = "1a68f1f47cdf0ec8ee4b941b2eee2a80cb796db73118c0dd09ac63fbe405be22" dependencies = [ "memchr", - "regex-automata 0.4.8", + "regex-automata 0.4.9", "serde", ] @@ -941,7 +941,7 @@ dependencies = [ "tempfile", "thiserror", "time", - "toml 0.8.19", + "toml", "walkdir", ] @@ -970,9 +970,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.31" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2e7962b54006dcfcc61cb72735f4d89bb97061dd6a7ed882ec6b8ee53714c6f" +checksum = "fd9de9f2205d5ef3fd67e685b0df337994ddd4495e2a28d185500d0e1edfea47" dependencies = [ "jobserver", "libc", @@ -999,9 +999,9 @@ checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" [[package]] name = "clap" -version = "4.5.20" +version = "4.5.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97f376d85a664d5837dbae44bf546e6477a679ff6610010f17276f686d867e8" +checksum = "fb3b4b9e5a7c7514dfa52869339ee98b3156b0bfb4e8a77c4ff4babb64b1604f" dependencies = [ "clap_builder", "clap_derive", @@ -1009,9 +1009,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.20" +version = "4.5.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19bc80abd44e4bed93ca373a0704ccbd1b710dc5749406201bb018272808dc54" +checksum = "b17a95aa67cc7b5ebd32aa5370189aa0d79069ef1c64ce893bd30fb24bff20ec" dependencies = [ "anstream", "anstyle", @@ -1034,29 +1034,19 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" - -[[package]] -name = "clippy_config" -version = "0.1.83" -source = "git+https://github.com/rust-lang/rust-clippy?rev=dae1be90eeb20d1d5b7b30d3fc4f2a119cee638b#dae1be90eeb20d1d5b7b30d3fc4f2a119cee638b" -dependencies = [ - "itertools 0.12.1", - "serde", - "toml 0.7.8", -] +checksum = "afb84c814227b90d6895e01398aee0d8033c00e7466aca416fb6a8e0eb19d8a7" [[package]] name = "clippy_utils" -version = "0.1.83" -source = "git+https://github.com/rust-lang/rust-clippy?rev=dae1be90eeb20d1d5b7b30d3fc4f2a119cee638b#dae1be90eeb20d1d5b7b30d3fc4f2a119cee638b" +version = "0.1.84" +source = "git+https://github.com/rust-lang/rust-clippy?rev=81dceed8baf324960ea05e9079b749305b16a7cc#81dceed8baf324960ea05e9079b749305b16a7cc" dependencies = [ "arrayvec", - "clippy_config", "itertools 0.12.1", "rustc_apfloat", + "serde", ] [[package]] @@ -1136,7 +1126,7 @@ dependencies = [ "encode_unicode", "lazy_static", "libc", - "unicode-width", + "unicode-width 0.1.14", "windows-sys 0.52.0", ] @@ -1221,9 +1211,9 @@ checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "cpufeatures" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" +checksum = "0ca741a962e1b0bff6d724a1a0958b686406e853bb14061f218562e1896f95e6" dependencies = [ "libc", ] @@ -1362,6 +1352,17 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "doc-comment" version = "0.3.3" @@ -1462,9 +1463,9 @@ checksum = "a2a2b11eda1d40935b26cf18f6833c526845ae8c41e58d09af6adeb6f0269183" [[package]] name = "fastrand" -version = "2.1.1" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" +checksum = "486f806e73c5707928240ddc295403b1b93c96a02038563881c4a2fd84b81ac4" [[package]] name = "fixedbitset" @@ -1480,9 +1481,9 @@ checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" [[package]] name = "flate2" -version = "1.0.34" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1b589b4dc103969ad3cf85c950899926ec64300a1a46d76c03a6072957036f0" +checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c" dependencies = [ "crc32fast", "miniz_oxide 0.8.0", @@ -1565,9 +1566,9 @@ checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" [[package]] name = "futures-lite" -version = "2.3.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52527eb5074e35e9339c6b4e8d12600c7128b68fb25dcb9fa9dec18f7c25f3a5" +checksum = "cef40d21ae2c515b51041df9ed313ed21e572df340ea58a922a0aefe7e8891a1" dependencies = [ "fastrand", "futures-core", @@ -1659,7 +1660,7 @@ dependencies = [ "gix-utils", "itoa", "thiserror", - "winnow 0.6.20", + "winnow", ] [[package]] @@ -1680,7 +1681,7 @@ dependencies = [ "smallvec", "thiserror", "unicode-bom", - "winnow 0.6.20", + "winnow", ] [[package]] @@ -1783,7 +1784,7 @@ dependencies = [ "itoa", "smallvec", "thiserror", - "winnow 0.6.20", + "winnow", ] [[package]] @@ -1817,7 +1818,7 @@ dependencies = [ "gix-validate", "memmap2", "thiserror", - "winnow 0.6.20", + "winnow", ] [[package]] @@ -1891,7 +1892,7 @@ dependencies = [ "aho-corasick", "bstr", "log", - "regex-automata 0.4.8", + "regex-automata 0.4.9", "regex-syntax 0.8.5", ] @@ -1946,9 +1947,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.15.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" +checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3" [[package]] name = "heck" @@ -2112,14 +2113,143 @@ dependencies = [ "tracing", ] +[[package]] +name = "icu_collections" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locid" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_locid_transform" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_locid_transform_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_locid_transform_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e" + +[[package]] +name = "icu_normalizer" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "utf16_iter", + "utf8_iter", + "write16", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516" + +[[package]] +name = "icu_properties" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locid_transform", + "icu_properties_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569" + +[[package]] +name = "icu_provider" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_provider_macros", + "stable_deref_trait", + "tinystr", + "writeable", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_provider_macros" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "idna" -version = "0.5.0" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" dependencies = [ - "unicode-bidi", - "unicode-normalization", + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71" +dependencies = [ + "icu_normalizer", + "icu_properties", ] [[package]] @@ -2132,7 +2262,7 @@ dependencies = [ "globset", "log", "memchr", - "regex-automata 0.4.8", + "regex-automata 0.4.9", "same-file", "walkdir", "winapi-util", @@ -2157,21 +2287,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" dependencies = [ "equivalent", - "hashbrown 0.15.0", + "hashbrown 0.15.1", "serde", ] [[package]] name = "indicatif" -version = "0.17.8" +version = "0.17.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "763a5a8f45087d6bcea4222e7b72c291a054edf80e4ef6efd2a4979878c7bea3" +checksum = "cbf675b85ed934d3c67b5c5469701eec7db22689d0a2139d856e0925fa28b281" dependencies = [ "console", - "instant", "number_prefix", "portable-atomic", - "unicode-width", + "unicode-width 0.2.0", + "web-time", ] [[package]] @@ -2221,9 +2351,9 @@ checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "jiff" -version = "0.1.13" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a45489186a6123c128fdf6016183fcfab7113e1820eb813127e036e287233fb" +checksum = "b9d9d414fc817d3e3d62b2598616733f76c4cc74fbac96069674739b881295c8" dependencies = [ "jiff-tzdb-platform", "windows-sys 0.59.0", @@ -2314,9 +2444,9 @@ checksum = "db13adb97ab515a3691f56e4dbab09283d0b86cb45abd991d8634a9d6f501760" [[package]] name = "libc" -version = "0.2.161" +version = "0.2.164" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" +checksum = "433bfe06b8c75da9b2e3fbea6e5329ff87748f0b144ef75306e674c3f6f7c13f" [[package]] name = "libgit2-sys" @@ -2431,6 +2561,12 @@ dependencies = [ "unicode-segmentation", ] +[[package]] +name = "litemap" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704" + [[package]] name = "local-channel" version = "0.1.5" @@ -2742,7 +2878,7 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2ad9b889f1b12e0b9ee24db044b5129150d5eada288edc800f789928dc8c0e3" dependencies = [ - "unicode-width", + "unicode-width 0.1.14", ] [[package]] @@ -2996,7 +3132,7 @@ checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.8", + "regex-automata 0.4.9", "regex-syntax 0.8.5", ] @@ -3011,9 +3147,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.8" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" dependencies = [ "aho-corasick", "memchr", @@ -3178,9 +3314,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.38" +version = "0.38.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa260229e6538e52293eeb577aabd09945a09d6d9cc0fc550ed7529056c2e32a" +checksum = "99e4ea3e1cdc4b559b8e5650f9c8e5998e3e5c1343b4eaf034565f32318d63c0" dependencies = [ "bitflags 2.6.0", "errno", @@ -3191,9 +3327,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.16" +version = "0.23.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eee87ff5d9b36712a58574e12e9f0ea80f915a5b0ac518d322b24a465617925e" +checksum = "7f1a745511c54ba6d4465e8d5dfbd81b45791756de28d4981af70d6dca128f1e" dependencies = [ "once_cell", "rustls-pki-types", @@ -3283,9 +3419,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.12.0" +version = "2.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea4a292869320c0272d7bc55a5a6aafaff59b4f63404a003887b679a2e05b4b6" +checksum = "fa39c7303dc58b5543c94d22c1766b0d31f2ee58306363ea622b10bbc075eaa2" dependencies = [ "core-foundation-sys", "libc", @@ -3302,18 +3438,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.214" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f55c3193aca71c12ad7890f1785d2b73e1b9f63a0bbc353c08ef26fe03fc56b5" +checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.214" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de523f781f095e28fa605cdce0f8307e451cc0fd14e2eb4cd2e98a355b147766" +checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" dependencies = [ "proc-macro2", "quote", @@ -3322,9 +3458,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.132" +version = "1.0.133" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" +checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377" dependencies = [ "itoa", "memchr", @@ -3498,9 +3634,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "syn" -version = "2.0.85" +version = "2.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5023162dfcd14ef8f32034d8bcd4cc5ddc61ef7a247c024a33e24e1f24d21b56" +checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" dependencies = [ "proc-macro2", "quote", @@ -3516,6 +3652,17 @@ dependencies = [ "futures-core", ] +[[package]] +name = "synstructure" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "system-configuration" version = "0.6.1" @@ -3577,18 +3724,18 @@ checksum = "a38c90d48152c236a3ab59271da4f4ae63d678c5d7ad6b7714d7cb9760be5e4b" [[package]] name = "thiserror" -version = "1.0.65" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d11abd9594d9b38965ef50805c5e469ca9cc6f197f883f717e0269a3057b3d5" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.65" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae71770322cbd277e69d762a16c444af02aa0575ac0d174f0b9562d3b37f8602" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", @@ -3645,6 +3792,16 @@ dependencies = [ "crunchy", ] +[[package]] +name = "tinystr" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" +dependencies = [ + "displaydoc", + "zerovec", +] + [[package]] name = "tinyvec" version = "1.8.0" @@ -3662,9 +3819,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.41.0" +version = "1.41.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "145f3413504347a2be84393cc8a7d2fb4d863b375909ea59f2158261aa258bbb" +checksum = "22cfb5bee7a6a52939ca9224d6ac897bb669134078daa8735560897f69de4d33" dependencies = [ "backtrace", "bytes", @@ -3711,18 +3868,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "toml" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd79e69d3b627db300ff956027cc6c3798cef26d22526befdfcd12feeb6d2257" -dependencies = [ - "serde", - "serde_spanned", - "toml_datetime", - "toml_edit 0.19.15", -] - [[package]] name = "toml" version = "0.8.19" @@ -3733,7 +3878,7 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.22.22", + "toml_edit", ] [[package]] @@ -3745,19 +3890,6 @@ dependencies = [ "serde", ] -[[package]] -name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap", - "serde", - "serde_spanned", - "toml_datetime", - "winnow 0.5.40", -] - [[package]] name = "toml_edit" version = "0.22.22" @@ -3768,7 +3900,7 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "winnow 0.6.20", + "winnow", ] [[package]] @@ -3916,12 +4048,6 @@ version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e51b68083f157f853b6379db119d1c1be0e6e4dec98101079dec41f6f5cf6df" -[[package]] -name = "unicode-bidi" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ab17db44d7388991a428b2ee655ce0c212e862eff1768a455c58f9aad6e7893" - [[package]] name = "unicode-bom" version = "2.0.3" @@ -3955,6 +4081,12 @@ version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" +[[package]] +name = "unicode-width" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd" + [[package]] name = "untrusted" version = "0.9.0" @@ -3963,15 +4095,27 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.5.2" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" +checksum = "8d157f1b96d14500ffdc1f10ba712e780825526c03d9a49b4d0324b0d9113ada" dependencies = [ "form_urlencoded", "idna", "percent-encoding", ] +[[package]] +name = "utf16_iter" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + [[package]] name = "utf8parse" version = "0.2.2" @@ -4418,20 +4562,47 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.5.40" +version = "0.6.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" +checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" dependencies = [ "memchr", ] [[package]] -name = "winnow" -version = "0.6.20" +name = "write16" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" +checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" + +[[package]] +name = "writeable" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" + +[[package]] +name = "yoke" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c5b1314b079b0930c31e3af543d8ee1757b1951ae1e1565ec704403a7240ca5" dependencies = [ - "memchr", + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", ] [[package]] @@ -4455,12 +4626,55 @@ dependencies = [ "syn", ] +[[package]] +name = "zerofrom" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ec111ce797d0e0784a1116d0ddcdbea84322cd79e5d5ad173daeba4f93ab55" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + [[package]] name = "zeroize" version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" +[[package]] +name = "zerovec" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "zstd" version = "0.13.2" diff --git a/bevy_lint/CHANGELOG.md b/bevy_lint/CHANGELOG.md index 4ddb0973..85898957 100644 --- a/bevy_lint/CHANGELOG.md +++ b/bevy_lint/CHANGELOG.md @@ -7,9 +7,9 @@ The format is based on [Keep a Changelog], and this project adheres to [Semantic [Keep a Changelog]: https://keepachangelog.com/en/1.1.0/ [Semantic Versioning]: https://semver.org/spec/v2.0.0.html -## [Unreleased] +## 0.1.0 - 2024-11-DD -**All Changes**: [`17834eb...main`](https://github.com/TheBevyFlock/bevy_cli/compare/17834eb...main) +**All Changes**: [`17834eb...lint-v0.1.0`](https://github.com/TheBevyFlock/bevy_cli/compare/17834eb...lint-v0.1.0) ### Added @@ -20,3 +20,4 @@ The format is based on [Keep a Changelog], and this project adheres to [Semantic - Lints `panicking_query_methods` and `panicking_world_methods` to `restriction` ([#95](https://github.com/TheBevyFlock/bevy_cli/pull/95)) - Lint `plugin_not_ending_in_plugin` to `style` ([#111](https://github.com/TheBevyFlock/bevy_cli/pull/111)) - Lint `missing_reflect` to `restriction` ([#139](https://github.com/TheBevyFlock/bevy_cli/pull/139)) +- Lint `zst_query` to `restriction` ([#168](https://github.com/TheBevyFlock/bevy_cli/pull/168)) diff --git a/bevy_lint/Cargo.toml b/bevy_lint/Cargo.toml index 28a41726..7e3799c5 100644 --- a/bevy_lint/Cargo.toml +++ b/bevy_lint/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bevy_lint" -version = "0.1.0-dev" +version = "0.1.0" authors = ["BD103"] edition = "2021" description = "A collection of lints for the Bevy game engine" @@ -32,9 +32,9 @@ anyhow = "1.0.86" # work with the currently pinned nightly Rust version. When the Rust version changes, this too # needs to be updated! [dependencies.clippy_utils] -version = "=0.1.83" +version = "=0.1.84" git = "https://github.com/rust-lang/rust-clippy" -rev = "dae1be90eeb20d1d5b7b30d3fc4f2a119cee638b" +rev = "81dceed8baf324960ea05e9079b749305b16a7cc" [build-dependencies] # Parse `rust-toolchain.toml` at build time. diff --git a/bevy_lint/README.md b/bevy_lint/README.md index 1471a27e..c3718e76 100644 --- a/bevy_lint/README.md +++ b/bevy_lint/README.md @@ -6,6 +6,10 @@ +- [Documentation](https://thebevyflock.github.io/bevy_cli/bevy_lint/) +- [Repository](https://github.com/TheBevyFlock/bevy_cli) +- [Issue Tracker](https://github.com/TheBevyFlock/bevy_cli/issues?q=is%3Aopen+is%3Aissue+label%3AA-Linter) +
> **Warning** @@ -26,7 +30,7 @@ rustup toolchain install $TOOLCHAIN_VERSION \ --component llvm-tools-preview ``` -For example, you would replace `$TOOLCHAIN_VERSION` with `nightly-2024-10-03` if you were installing `bevy_lint` 0.1.0, based on the [compatibility table](#compatibility). Please be aware that you must keep this toolchain installed for `bevy_lint` to function[^keep-toolchain-installed]. +For example, you would replace `$TOOLCHAIN_VERSION` with `nightly-2024-11-14` if you were installing `bevy_lint` 0.1.0, based on the [compatibility table](#compatibility). Please be aware that you must keep this toolchain installed for `bevy_lint` to function[^keep-toolchain-installed]. [^keep-toolchain-installed]: `bevy_lint` imports internal `rustc` libraries in order to hook into the compiler process. These crates are stored in a [dynamic library](https://en.wikipedia.org/wiki/Dynamic_linker) that is installed with the `rustc-dev` component and loaded by `bevy_lint` at runtime. Uninstalling the nightly toolchain would remove this dynamic library, causing `bevy_lint` to fail. @@ -150,7 +154,7 @@ There are several other ways to toggle lints, but they have varying levels of su |`bevy_lint` Version|Rust Version|Rustup Toolchain|Bevy Version| |-|-|-|-| -|0.1.0-dev|1.83.0|`nightly-2024-10-03`|0.14| +|0.1.0|1.83.0|`nightly-2024-11-14`|0.14| 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.) diff --git a/bevy_lint/docs/index.md b/bevy_lint/docs/index.md new file mode 100644 index 00000000..f21265b7 --- /dev/null +++ b/bevy_lint/docs/index.md @@ -0,0 +1,9 @@ +# Contributor's Guide + +Thanks for your interest in contributing to `bevy_lint`! Please feel free to skim through the following table of contents: + +- [Release Checklist](release.md) + +> [!IMPORTANT] +> +> This is the documentation for _contributing_ to `bevy_lint`. If you want to learn how to _use_ `bevy_lint` instead, please view the live documentation [here](https://thebevyflock.github.io/bevy_cli/bevy_lint/) or see the main [`README.md`](../README.md). diff --git a/bevy_lint/src/groups.rs b/bevy_lint/src/groups.rs index b5dff2b9..85328fe4 100644 --- a/bevy_lint/src/groups.rs +++ b/bevy_lint/src/groups.rs @@ -1,6 +1,19 @@ //! Lint groups that can be toggled together. //! -//! Each lint is organized within a specific category, such as [`PERFORMANCE`] or [`STYLE`]. +//! Each [lint](crate::lints) is organized within a specific category, such as [`PERFORMANCE`] or +//! [`STYLE`]. The following groups are enabled by default: +//! +//! - [`CORRECTNESS`] +//! - [`SUSPICIOUS`] +//! - [`COMPLEXITY`] +//! - [`PERFORMANCE`] +//! - [`STYLE`] +//! +//! The following groups are disabled by default: +//! +//! - [`PEDANTIC`] +//! - [`RESTRICTION`] +//! - [`NURSERY`] use crate::{ lint::{BevyLint, LintGroup}, diff --git a/bevy_lint/src/lint.rs b/bevy_lint/src/lint.rs index f0a204ff..07024787 100644 --- a/bevy_lint/src/lint.rs +++ b/bevy_lint/src/lint.rs @@ -58,6 +58,7 @@ macro_rules! declare_bevy_lint { is_externally_loaded: true, feature_gate: None, crate_level_only: false, + eval_always: false, }, group: &$crate::groups::$group, }; diff --git a/bevy_lint/src/lints/mod.rs b/bevy_lint/src/lints/mod.rs index d57368c7..22b90124 100644 --- a/bevy_lint/src/lints/mod.rs +++ b/bevy_lint/src/lints/mod.rs @@ -1,6 +1,8 @@ //! All lints offered by `bevy_lint`. //! -//! Click on each module to learn more about individual lints. +//! Click on each module to learn more about individual lints. Within each module is a static that +//! documents a lint's name, group, and short description, such as +//! [`missing_reflect::MISSING_REFLECT`]. use crate::lint::BevyLint; use rustc_lint::{Lint, LintStore}; diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 47e50c6b..5a58b053 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -4,6 +4,6 @@ [toolchain] # Writing custom lints requires using nightly Rust. We pin to a specific version of nightly version # so that builds are reproducible. -channel = "nightly-2024-10-03" +channel = "nightly-2024-11-14" # These components are required to use `rustc` crates. components = ["rustc-dev", "llvm-tools-preview"] From 663298e1e24a6422abd001b6142dc53f371c3bcd Mon Sep 17 00:00:00 2001 From: BD103 <59022059+BD103@users.noreply.github.com> Date: Sun, 17 Nov 2024 11:42:50 -0500 Subject: [PATCH 3/8] Final fixes for v0.1.0 (#179) I missed these two changes in #172, I was too excited to press the merge button! --- bevy_lint/CHANGELOG.md | 2 +- bevy_lint/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bevy_lint/CHANGELOG.md b/bevy_lint/CHANGELOG.md index 85898957..5094fc02 100644 --- a/bevy_lint/CHANGELOG.md +++ b/bevy_lint/CHANGELOG.md @@ -7,7 +7,7 @@ The format is based on [Keep a Changelog], and this project adheres to [Semantic [Keep a Changelog]: https://keepachangelog.com/en/1.1.0/ [Semantic Versioning]: https://semver.org/spec/v2.0.0.html -## 0.1.0 - 2024-11-DD +## 0.1.0 - 2024-11-17 **All Changes**: [`17834eb...lint-v0.1.0`](https://github.com/TheBevyFlock/bevy_cli/compare/17834eb...lint-v0.1.0) diff --git a/bevy_lint/README.md b/bevy_lint/README.md index c3718e76..6087aded 100644 --- a/bevy_lint/README.md +++ b/bevy_lint/README.md @@ -154,7 +154,7 @@ There are several other ways to toggle lints, but they have varying levels of su |`bevy_lint` Version|Rust Version|Rustup Toolchain|Bevy Version| |-|-|-|-| -|0.1.0|1.83.0|`nightly-2024-11-14`|0.14| +|0.1.0|1.84.0|`nightly-2024-11-14`|0.14| 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.) From 00d3bd7a00ae87b07cc6c0ca4424a93f4d8da776 Mon Sep 17 00:00:00 2001 From: BD103 <59022059+BD103@users.noreply.github.com> Date: Sun, 17 Nov 2024 17:34:27 -0500 Subject: [PATCH 4/8] v0.1.0 post-release (#180) This, following the [release checklist](https://github.com/TheBevyFlock/bevy_cli/blob/663298e1e24a6422abd001b6142dc53f371c3bcd/bevy_lint/docs/release.md), updates `bevy_lint` to v0.2.0-dev. I also added some missing information to the release checklist, based off of my experience releasing v0.1.0. Once this is merged, the feature freeze will be lifted, letting #164 and #173 be merged. --- Cargo.lock | 2 +- bevy_lint/CHANGELOG.md | 4 ++++ bevy_lint/Cargo.toml | 2 +- bevy_lint/README.md | 1 + bevy_lint/docs/release.md | 13 ++++++++++--- 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9e9733cd..eed809e0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -629,7 +629,7 @@ dependencies = [ [[package]] name = "bevy_lint" -version = "0.1.0" +version = "0.2.0-dev" dependencies = [ "anyhow", "bevy", diff --git a/bevy_lint/CHANGELOG.md b/bevy_lint/CHANGELOG.md index 5094fc02..c2c2f906 100644 --- a/bevy_lint/CHANGELOG.md +++ b/bevy_lint/CHANGELOG.md @@ -7,6 +7,10 @@ The format is based on [Keep a Changelog], and this project adheres to [Semantic [Keep a Changelog]: https://keepachangelog.com/en/1.1.0/ [Semantic Versioning]: https://semver.org/spec/v2.0.0.html +## [Unreleased] + +**All Changes**: [`lint-v0.1.0...main`](https://github.com/TheBevyFlock/bevy_cli/compare/lint-v0.1.0...main) + ## 0.1.0 - 2024-11-17 **All Changes**: [`17834eb...lint-v0.1.0`](https://github.com/TheBevyFlock/bevy_cli/compare/17834eb...lint-v0.1.0) diff --git a/bevy_lint/Cargo.toml b/bevy_lint/Cargo.toml index 7e3799c5..8f350469 100644 --- a/bevy_lint/Cargo.toml +++ b/bevy_lint/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bevy_lint" -version = "0.1.0" +version = "0.2.0-dev" authors = ["BD103"] edition = "2021" description = "A collection of lints for the Bevy game engine" diff --git a/bevy_lint/README.md b/bevy_lint/README.md index 6087aded..b28e6656 100644 --- a/bevy_lint/README.md +++ b/bevy_lint/README.md @@ -154,6 +154,7 @@ There are several other ways to toggle lints, but they have varying levels of su |`bevy_lint` Version|Rust Version|Rustup Toolchain|Bevy Version| |-|-|-|-| +|0.2.0-dev|1.84.0|`nightly-2024-11-14`|0.14| |0.1.0|1.84.0|`nightly-2024-11-14`|0.14| 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.) diff --git a/bevy_lint/docs/release.md b/bevy_lint/docs/release.md index 698df0cc..943871ae 100644 --- a/bevy_lint/docs/release.md +++ b/bevy_lint/docs/release.md @@ -21,6 +21,12 @@ ````markdown +You can find the live documentation for this release [here](https://thebevyflock.github.io/bevy_cli/bevy_lint/). + +> [!WARNING] +> +> This is an unofficial community project, hacked upon by the Bevy CLI working group until it is eventually upstreamed into the main [Bevy Engine organization](https://github.com/bevyengine). Pardon our rough edges, and please consider [submitting an issue](https://github.com/TheBevyFlock/bevy_cli/issues) if you run into trouble! + This release uses the toolchain, based on Rust . You can install it from Git with the following commands: @@ -39,7 +45,7 @@ rustup run nightly-YYYY-MM-DD cargo install \ bevy_lint ``` - + ```` 5. Check the pre-release box if this is an alpha release, then click "Publish release"! @@ -58,5 +64,6 @@ rustup run nightly-YYYY-MM-DD cargo install \ ``` 2. Bump the version in [`Cargo.toml`](../Cargo.toml) to the next `-dev` version, and ensure [`Cargo.lock`](../../Cargo.lock) also updates. -3. Commit all of these changes and open a pull request. -4. Merge the PR after it has been approved, unblocking frozen pull requests. +3. Add a new row to the compatibility table for the new `-dev` version in [`README.md`](../README.md). +4. Commit all of these changes and open a pull request. +5. Merge the PR after it has been approved, unblocking frozen pull requests. From 458e4169c7201806b8ac4b7041b6a6f1e5a98a7b Mon Sep 17 00:00:00 2001 From: BD103 <59022059+BD103@users.noreply.github.com> Date: Wed, 20 Nov 2024 08:51:24 -0500 Subject: [PATCH 5/8] Use `cargo doc-lints` when building Github Pages (#173) This is a change I forgot to add in #161. It fixes the alerts so instead of looking like: ![image](https://github.com/user-attachments/assets/fcb68295-07b6-4173-94fc-dea13be18d1e) They look like: ![image](https://github.com/user-attachments/assets/04983c8c-5284-4b14-8b68-af81fba813e5) While this fix is not necessary for v0.1.0's release, I would like to get it in sooner rather than later! :) --- .github/workflows/docs.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 4b7d06a6..43092c06 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -37,10 +37,9 @@ jobs: sweep-cache: true - name: Build with `rustdoc` - # We don't need to document dependencies since this is not intended to be consumed as a - # library. Furthermore, we pass `--lib` to prevent it from documenting binaries - # automatically. - run: cargo doc --package bevy_lint --no-deps --lib + # This alias calls `cargo rustdoc` with additional arguments, as specified by + # `.cargo/config.toml`. + run: cargo doc-lints - name: Finalize documentation run: | From dbfb6fc075a0027d161f39e744f8b7f33a8ec193 Mon Sep 17 00:00:00 2001 From: BD103 <59022059+BD103@users.noreply.github.com> Date: Fri, 29 Nov 2024 18:32:52 -0500 Subject: [PATCH 6/8] Switch to `clippy_utils` on crates.io (#186) `clippy_utils` used to be a Git dependency, but thanks to https://github.com/rust-lang/rust-clippy/issues/13556 it is now being published on ! This PR switches to the crates.io version, and bumps the pinned nightly toolchain to match it (as specified [here](https://lib.rs/crates/clippy_utils)). We still want to pin a specific version of `clippy_utils`, since it does not follow semantic versioning, but now we have the ability to publish ourselves to crates.io! Closes #150. --- Cargo.lock | 277 +++++++++++++++++++++++-------------------- bevy_lint/Cargo.toml | 13 +- bevy_lint/README.md | 2 +- rust-toolchain.toml | 2 +- 4 files changed, 153 insertions(+), 141 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index eed809e0..69ccdf3f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14,7 +14,7 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f7b0a21988c1bf877cf4759ef5ddaac04c1c9fe808c9142ecb78ba97d97a28a" dependencies = [ - "bitflags 2.6.0", + "bitflags", "bytes", "futures-core", "futures-sink", @@ -35,7 +35,7 @@ dependencies = [ "actix-service", "actix-utils", "actix-web", - "bitflags 2.6.0", + "bitflags", "bytes", "derive_more", "futures-core", @@ -60,7 +60,7 @@ dependencies = [ "actix-utils", "ahash", "base64", - "bitflags 2.6.0", + "bitflags", "brotli", "bytes", "bytestring", @@ -477,7 +477,7 @@ dependencies = [ "bevy_utils", "console_error_panic_hook", "downcast-rs", - "thiserror", + "thiserror 1.0.69", "wasm-bindgen", "web-sys", ] @@ -552,13 +552,13 @@ dependencies = [ "bevy_reflect", "bevy_tasks", "bevy_utils", - "bitflags 2.6.0", + "bitflags", "concurrent-queue", "fixedbitset 0.5.7", "nonmax", "petgraph", "serde", - "thiserror", + "thiserror 1.0.69", ] [[package]] @@ -599,7 +599,7 @@ dependencies = [ "bevy_reflect", "bevy_utils", "smol_str", - "thiserror", + "thiserror 1.0.69", ] [[package]] @@ -678,7 +678,7 @@ dependencies = [ "rand", "serde", "smallvec", - "thiserror", + "thiserror 1.0.69", ] [[package]] @@ -702,7 +702,7 @@ dependencies = [ "serde", "smallvec", "smol_str", - "thiserror", + "thiserror 1.0.69", ] [[package]] @@ -740,7 +740,7 @@ dependencies = [ "bevy_reflect", "bevy_utils", "crossbeam-channel", - "thiserror", + "thiserror 1.0.69", ] [[package]] @@ -754,7 +754,7 @@ dependencies = [ "bevy_hierarchy", "bevy_math", "bevy_reflect", - "thiserror", + "thiserror 1.0.69", ] [[package]] @@ -799,12 +799,6 @@ dependencies = [ "smol_str", ] -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - [[package]] name = "bitflags" version = "2.6.0" @@ -869,9 +863,9 @@ checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "bytemuck" -version = "1.19.0" +version = "1.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8334215b81e418a0a7bdb8ef0849474f40bb10c8b71f1c4ed315cff49f32494d" +checksum = "8b37c88a63ffd85d15b406896cc343916d7cf57838a847b3a6f2ca5d39a5695a" [[package]] name = "byteorder" @@ -881,15 +875,15 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da" +checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b" [[package]] name = "bytestring" -version = "1.3.1" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74d80203ea6b29df88012294f62733de21cfeab47f17b41af3a38bc30a03ee72" +checksum = "e465647ae23b2823b0753f50decb2d5a86d2bb2cac04788fafd1f80e45378e5f" dependencies = [ "bytes", ] @@ -939,7 +933,7 @@ dependencies = [ "semver", "serde", "tempfile", - "thiserror", + "thiserror 1.0.69", "time", "toml", "walkdir", @@ -947,9 +941,9 @@ dependencies = [ [[package]] name = "cargo-platform" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24b1f0365a6c6bb4020cd05806fd0d33c44d38046b8bd7f0e40814b9763cabfc" +checksum = "e35af189006b9c0f00a064685c727031e3ed2d8020f7ba284d78cc2671bd36ea" dependencies = [ "serde", ] @@ -965,14 +959,14 @@ dependencies = [ "semver", "serde", "serde_json", - "thiserror", + "thiserror 1.0.69", ] [[package]] name = "cc" -version = "1.2.1" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd9de9f2205d5ef3fd67e685b0df337994ddd4495e2a28d185500d0e1edfea47" +checksum = "f34d93e62b03caf570cccc334cbc6c2fceca82f39211051345108adcba3eebdc" dependencies = [ "jobserver", "libc", @@ -1040,8 +1034,9 @@ checksum = "afb84c814227b90d6895e01398aee0d8033c00e7466aca416fb6a8e0eb19d8a7" [[package]] name = "clippy_utils" -version = "0.1.84" -source = "git+https://github.com/rust-lang/rust-clippy?rev=81dceed8baf324960ea05e9079b749305b16a7cc#81dceed8baf324960ea05e9079b749305b16a7cc" +version = "0.1.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f7bc44cade8ee3453cbb02297635ac506c6ea9eda9e5ed85c7eee8649f56bbc" dependencies = [ "arrayvec", "itertools 0.12.1", @@ -1211,9 +1206,9 @@ checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "cpufeatures" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ca741a962e1b0bff6d724a1a0958b686406e853bb14061f218562e1896f95e6" +checksum = "16b80225097f2e5ae4e7179dd2266824648f3e2f49d9134d584b76389d31c4c3" dependencies = [ "libc", ] @@ -1317,7 +1312,7 @@ dependencies = [ "console", "shell-words", "tempfile", - "thiserror", + "thiserror 1.0.69", "zeroize", ] @@ -1437,12 +1432,12 @@ dependencies = [ [[package]] name = "errno" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -1640,7 +1635,7 @@ version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b903b73e45dc0c6c596f2d37eccece7c1c8bb6e4407b001096387c63d0d93724" dependencies = [ - "bitflags 2.6.0", + "bitflags", "libc", "libgit2-sys", "log", @@ -1659,7 +1654,7 @@ dependencies = [ "gix-date", "gix-utils", "itoa", - "thiserror", + "thiserror 1.0.69", "winnow", ] @@ -1679,34 +1674,34 @@ dependencies = [ "memchr", "once_cell", "smallvec", - "thiserror", + "thiserror 1.0.69", "unicode-bom", "winnow", ] [[package]] name = "gix-config-value" -version = "0.14.9" +version = "0.14.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3de3fdca9c75fa4b83a76583d265fa49b1de6b088ebcd210749c24ceeb74660" +checksum = "49aaeef5d98390a3bcf9dbc6440b520b793d1bf3ed99317dc407b02be995b28e" dependencies = [ - "bitflags 2.6.0", + "bitflags", "bstr", "gix-path", "libc", - "thiserror", + "thiserror 2.0.3", ] [[package]] name = "gix-date" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d10d543ac13c97292a15e8e8b7889cd006faf739777437ed95362504b8fe81a0" +checksum = "691142b1a34d18e8ed6e6114bc1a2736516c5ad60ef3aa9bd1b694886e3ca92d" dependencies = [ "bstr", "itoa", "jiff", - "thiserror", + "thiserror 2.0.3", ] [[package]] @@ -1741,7 +1736,7 @@ version = "0.16.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74908b4bbc0a0a40852737e5d7889f676f081e340d5451a16e5b4c50d592f111" dependencies = [ - "bitflags 2.6.0", + "bitflags", "bstr", "gix-features", "gix-path", @@ -1754,7 +1749,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f93d7df7366121b5018f947a04d37f034717e113dcf9ccd85c34b58e57a74d5e" dependencies = [ "faster-hex", - "thiserror", + "thiserror 1.0.69", ] [[package]] @@ -1765,7 +1760,7 @@ checksum = "e3bc7fe297f1f4614774989c00ec8b1add59571dc9b024b4c00acb7dedd4e19d" dependencies = [ "gix-tempfile", "gix-utils", - "thiserror", + "thiserror 1.0.69", ] [[package]] @@ -1783,21 +1778,21 @@ dependencies = [ "gix-validate", "itoa", "smallvec", - "thiserror", + "thiserror 1.0.69", "winnow", ] [[package]] name = "gix-path" -version = "0.10.12" +version = "0.10.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c04e5a94fdb56b1e91eb7df2658ad16832428b8eeda24ff1a0f0288de2bce554" +checksum = "afc292ef1a51e340aeb0e720800338c805975724c1dfbd243185452efd8645b7" dependencies = [ "bstr", "gix-trace", "home", "once_cell", - "thiserror", + "thiserror 2.0.3", ] [[package]] @@ -1817,17 +1812,17 @@ dependencies = [ "gix-utils", "gix-validate", "memmap2", - "thiserror", + "thiserror 1.0.69", "winnow", ] [[package]] name = "gix-sec" -version = "0.10.9" +version = "0.10.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2007538eda296445c07949cf04f4a767307d887184d6b3e83e2d636533ddc6e" +checksum = "a8b876ef997a955397809a2ec398d6a45b7a55b4918f2446344330f778d14fd6" dependencies = [ - "bitflags 2.6.0", + "bitflags", "gix-path", "libc", "windows-sys 0.52.0", @@ -1864,12 +1859,12 @@ dependencies = [ [[package]] name = "gix-validate" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e187b263461bc36cea17650141567753bc6207d036cedd1de6e81a52f277ff68" +checksum = "cd520d09f9f585b34b32aba1d0b36ada89ab7fefb54a8ca3fe37fc482a750937" dependencies = [ "bstr", - "thiserror", + "thiserror 2.0.3", ] [[package]] @@ -1917,9 +1912,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524e8ac6999421f49a846c2d4411f337e53497d8ec55d67753beffa43c5d9205" +checksum = "ccae279728d634d083c00f6099cb58f01cc99c145b84b8be2f6c74618d79922e" dependencies = [ "atomic-waker", "bytes", @@ -1947,9 +1942,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.15.1" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" [[package]] name = "heck" @@ -2043,14 +2038,14 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "1.5.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbbff0a806a4728c99295b254c8838933b5b082d75e3cb70c8dab21fdfbcfa9a" +checksum = "97818827ef4f364230e16705d4706e2897df2bb60617d6ca15d598025a3c481f" dependencies = [ "bytes", "futures-channel", "futures-util", - "h2 0.4.6", + "h2 0.4.7", "http 1.1.0", "http-body", "httparse", @@ -2287,7 +2282,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" dependencies = [ "equivalent", - "hashbrown 0.15.1", + "hashbrown 0.15.2", "serde", ] @@ -2345,9 +2340,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.11" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" [[package]] name = "jiff" @@ -2385,7 +2380,7 @@ dependencies = [ "combine", "jni-sys", "log", - "thiserror", + "thiserror 1.0.69", "walkdir", "windows-sys 0.45.0", ] @@ -2444,9 +2439,9 @@ checksum = "db13adb97ab515a3691f56e4dbab09283d0b86cb45abd991d8634a9d6f501760" [[package]] name = "libc" -version = "0.2.164" +version = "0.2.167" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "433bfe06b8c75da9b2e3fbea6e5329ff87748f0b144ef75306e674c3f6f7c13f" +checksum = "09d6582e104315a817dff97f75133544b2e094ee22447d2acf4a74e189ba06fc" [[package]] name = "libgit2-sys" @@ -2468,7 +2463,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags 2.6.0", + "bitflags", "libc", ] @@ -2563,9 +2558,9 @@ dependencies = [ [[package]] name = "litemap" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704" +checksum = "4ee93343901ab17bd981295f2cf0026d4ad018c7c31ba84549a4ddbb47a45104" [[package]] name = "local-channel" @@ -2709,7 +2704,7 @@ version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46" dependencies = [ - "bitflags 2.6.0", + "bitflags", "cfg-if", "cfg_aliases", "libc", @@ -2789,7 +2784,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ee638a5da3799329310ad4cfa62fbf045d5f56e3ef5ba4149e7452dcf89d5a8" dependencies = [ - "bitflags 2.6.0", + "bitflags", "block2", "libc", "objc2", @@ -2816,7 +2811,7 @@ version = "0.10.68" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6174bc48f102d208783c2c84bf931bb75927a617866870de8a4ea85597f871f5" dependencies = [ - "bitflags 2.6.0", + "bitflags", "cfg-if", "foreign-types", "libc", @@ -2947,7 +2942,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "879952a81a83930934cbf1786752d6dedc3b1f29e8f8fb2ad1d0a36f377cf442" dependencies = [ "memchr", - "thiserror", + "thiserror 1.0.69", "ucd-trie", ] @@ -3015,9 +3010,9 @@ checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" [[package]] name = "portable-atomic" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2" +checksum = "280dc24453071f1b63954171985a0b0d30058d287960968b9b2aca264c8d4ee6" [[package]] name = "powerfmt" @@ -3046,9 +3041,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.89" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" +checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" dependencies = [ "unicode-ident", ] @@ -3110,7 +3105,7 @@ version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" dependencies = [ - "bitflags 2.6.0", + "bitflags", ] [[package]] @@ -3121,7 +3116,7 @@ checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" dependencies = [ "getrandom", "libredox", - "thiserror", + "thiserror 1.0.69", ] [[package]] @@ -3200,7 +3195,7 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", - "h2 0.4.6", + "h2 0.4.7", "http 1.1.0", "http-body", "http-body-util", @@ -3239,7 +3234,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61797318be89b1a268a018a92a7657096d83f3ecb31418b9e9c16dcbb043b702" dependencies = [ "ahash", - "bitflags 2.6.0", + "bitflags", "instant", "num-traits", "once_cell", @@ -3283,11 +3278,11 @@ checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustc_apfloat" -version = "0.2.1+llvm-462a31f5a5ab" +version = "0.2.2+llvm-462a31f5a5ab" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "886d94c63c812a8037c4faca2607453a0fa4cf82f734665266876b022244543f" +checksum = "121e2195ff969977a4e2b5c9965ea867fce7e4cb5aee5b09dee698a7932d574f" dependencies = [ - "bitflags 1.3.2", + "bitflags", "smallvec", ] @@ -3302,23 +3297,23 @@ dependencies = [ [[package]] name = "rustfix" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fb2b066405a6d48a1b39c0022270503e352ae84da0c24e1d5f8ffc38e97a325" +checksum = "82fa69b198d894d84e23afde8e9ab2af4400b2cba20d6bf2b428a8b01c222c5a" dependencies = [ "serde", "serde_json", - "thiserror", + "thiserror 1.0.69", "tracing", ] [[package]] name = "rustix" -version = "0.38.40" +version = "0.38.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99e4ea3e1cdc4b559b8e5650f9c8e5998e3e5c1343b4eaf034565f32318d63c0" +checksum = "d7f649912bc1495e167a6edee79151c84b1bad49748cb4f1f1167f459f6224f6" dependencies = [ - "bitflags 2.6.0", + "bitflags", "errno", "libc", "linux-raw-sys", @@ -3327,9 +3322,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.17" +version = "0.23.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f1a745511c54ba6d4465e8d5dfbd81b45791756de28d4981af70d6dca128f1e" +checksum = "934b404430bb06b3fae2cba809eb45a1ab1aecd64491213d7c3301b88393f8d1" dependencies = [ "once_cell", "rustls-pki-types", @@ -3391,9 +3386,9 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.26" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01227be5826fa0690321a2ba6c5cd57a19cf3f6a09e76973b58e61de6ab9d1c1" +checksum = "1f29ebaa345f945cec9fbbc532eb307f0fdad8161f281b6369539c8d84876b3d" dependencies = [ "windows-sys 0.59.0", ] @@ -3410,7 +3405,7 @@ version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" dependencies = [ - "bitflags 2.6.0", + "bitflags", "core-foundation 0.9.4", "core-foundation-sys", "libc", @@ -3584,9 +3579,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.7" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" +checksum = "c970269d99b64e60ec3bd6ad27270092a5394c4e309314b18ae3fe575695fbe8" dependencies = [ "libc", "windows-sys 0.52.0", @@ -3634,9 +3629,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "syn" -version = "2.0.87" +version = "2.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" +checksum = "44d46482f1c1c87acd84dea20c1bf5ebff4c757009ed6bf19cfd36fb10e92c4e" dependencies = [ "proc-macro2", "quote", @@ -3645,9 +3640,9 @@ dependencies = [ [[package]] name = "sync_wrapper" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" dependencies = [ "futures-core", ] @@ -3669,7 +3664,7 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" dependencies = [ - "bitflags 2.6.0", + "bitflags", "core-foundation 0.9.4", "system-configuration-sys", ] @@ -3728,7 +3723,16 @@ version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" dependencies = [ - "thiserror-impl", + "thiserror-impl 1.0.69", +] + +[[package]] +name = "thiserror" +version = "2.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c006c85c7651b3cf2ada4584faa36773bd07bac24acfb39f3c431b36d7e667aa" +dependencies = [ + "thiserror-impl 2.0.3", ] [[package]] @@ -3742,6 +3746,17 @@ dependencies = [ "syn", ] +[[package]] +name = "thiserror-impl" +version = "2.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f077553d607adc1caf65430528a576c757a71ed73944b66ebb58ef2bbd243568" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "thread_local" version = "1.1.8" @@ -3911,9 +3926,9 @@ checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" [[package]] name = "tracing" -version = "0.1.40" +version = "0.1.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" dependencies = [ "log", "pin-project-lite", @@ -3923,9 +3938,9 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.27" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" dependencies = [ "proc-macro2", "quote", @@ -3934,9 +3949,9 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.32" +version = "0.1.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" dependencies = [ "once_cell", "valuable", @@ -4056,9 +4071,9 @@ checksum = "7eec5d1121208364f6793f7d2e222bf75a915c19557537745b195b253dd64217" [[package]] name = "unicode-ident" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" +checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" [[package]] name = "unicode-normalization" @@ -4095,9 +4110,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.5.3" +version = "2.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d157f1b96d14500ffdc1f10ba712e780825526c03d9a49b4d0324b0d9113ada" +checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60" dependencies = [ "form_urlencoded", "idna", @@ -4269,9 +4284,9 @@ dependencies = [ [[package]] name = "webbrowser" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e5f07fb9bc8de2ddfe6b24a71a75430673fd679e568c48b52716cef1cfae923" +checksum = "ea9fe1ebb156110ff855242c1101df158b822487e4957b0556d9ffce9db0f535" dependencies = [ "block2", "core-foundation 0.10.0", @@ -4583,9 +4598,9 @@ checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" [[package]] name = "yoke" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c5b1314b079b0930c31e3af543d8ee1757b1951ae1e1565ec704403a7240ca5" +checksum = "120e6aef9aa629e3d4f52dc8cc43a015c7724194c97dfaf45180d2daf2b77f40" dependencies = [ "serde", "stable_deref_trait", @@ -4595,9 +4610,9 @@ dependencies = [ [[package]] name = "yoke-derive" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" +checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" dependencies = [ "proc-macro2", "quote", @@ -4628,18 +4643,18 @@ dependencies = [ [[package]] name = "zerofrom" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ec111ce797d0e0784a1116d0ddcdbea84322cd79e5d5ad173daeba4f93ab55" +checksum = "cff3ee08c995dee1859d998dea82f7374f2826091dd9cd47def953cae446cd2e" dependencies = [ "zerofrom-derive", ] [[package]] name = "zerofrom-derive" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" +checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" dependencies = [ "proc-macro2", "quote", diff --git a/bevy_lint/Cargo.toml b/bevy_lint/Cargo.toml index 8f350469..c43040f5 100644 --- a/bevy_lint/Cargo.toml +++ b/bevy_lint/Cargo.toml @@ -25,17 +25,14 @@ name = "ui" harness = false [dependencies] +# Contains a series of useful utilities when writing lints. The version is chosen to work with the +# currently pinned nightly Rust version. When the Rust version changes, this too needs to be +# updated! +clippy_utils = "=0.1.85" + # Easy error propagation and contexts. anyhow = "1.0.86" -# Contains a series of useful utilities when writing lints. The version and commit were chosen to -# work with the currently pinned nightly Rust version. When the Rust version changes, this too -# needs to be updated! -[dependencies.clippy_utils] -version = "=0.1.84" -git = "https://github.com/rust-lang/rust-clippy" -rev = "81dceed8baf324960ea05e9079b749305b16a7cc" - [build-dependencies] # Parse `rust-toolchain.toml` at build time. toml_edit = { version = "0.22.22", default-features = false, features = [ diff --git a/bevy_lint/README.md b/bevy_lint/README.md index b28e6656..3b6477b3 100644 --- a/bevy_lint/README.md +++ b/bevy_lint/README.md @@ -154,7 +154,7 @@ There are several other ways to toggle lints, but they have varying levels of su |`bevy_lint` Version|Rust Version|Rustup Toolchain|Bevy Version| |-|-|-|-| -|0.2.0-dev|1.84.0|`nightly-2024-11-14`|0.14| +|0.2.0-dev|1.84.0|`nightly-2024-11-28`|0.14| |0.1.0|1.84.0|`nightly-2024-11-14`|0.14| 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.) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 5a58b053..94b224bd 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -4,6 +4,6 @@ [toolchain] # Writing custom lints requires using nightly Rust. We pin to a specific version of nightly version # so that builds are reproducible. -channel = "nightly-2024-11-14" +channel = "nightly-2024-11-28" # These components are required to use `rustc` crates. components = ["rustc-dev", "llvm-tools-preview"] From 4439e83be5639ec40cd38ab8404cc57dce66d3b5 Mon Sep 17 00:00:00 2001 From: TimJentzsch Date: Tue, 3 Dec 2024 13:55:06 +0100 Subject: [PATCH 7/8] Rework binary detection (#169) # Objective Rework the detection of binaries again, aligning it closer to how Cargo works and enabling several new features / fixing several bugs. - Support multiple binaries in a single package - Support running examples (closes #69) - Fix detection of `target` folder location (closes #145) With this PR, we can now just run `bevy run --example breakout web` in the Bevy repo and it works without any additional configuration! # Solution The code previously made the wrong assumption that we want to run packages with a binary target. Instead, we want to run the binary targets itself. A package can even have multiple of them. Additionally, examples need to be considered as binary targets. The `--example` argument now needs to be factored into the detection algorithm and the different path for examples must be considered in the bundling step. ## Note for Reviewers The crux of the changes is contained in `run/mod.rs` in the `select_run_binary` function. This implements the new algorithm to select the correct binary to run. In `serve.rs`, the `index.html` file now needs to be generated dynamically, in order to pick the path to the correct binary. Because the `index.html` needs to be a _static_ string, it needs to be leaked to create a static reference. --- Cargo.lock | 1 - Cargo.toml | 5 - src/build/args.rs | 5 + src/build/mod.rs | 14 ++- src/external_cli/cargo/metadata.rs | 14 +++ src/external_cli/cargo/mod.rs | 8 ++ src/external_cli/wasm_bindgen.rs | 37 ++---- src/lib.rs | 1 - src/manifest.rs | 24 ---- src/run/args.rs | 5 + src/run/mod.rs | 185 ++++++++++++++++++++--------- src/run/serve.rs | 53 ++++++--- 12 files changed, 227 insertions(+), 125 deletions(-) delete mode 100644 src/manifest.rs diff --git a/Cargo.lock b/Cargo.lock index 69ccdf3f..a933dfaf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -497,7 +497,6 @@ dependencies = [ "semver", "serde", "serde_json", - "toml_edit", "webbrowser", ] diff --git a/Cargo.toml b/Cargo.toml index 0300397f..36ae76d0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,11 +33,6 @@ serde_json = "1.0.128" reqwest = { features = ["blocking", "json"], version = "0.12.7" } regex = "1.10.6" -# Understanding Cargo.toml -toml_edit = { version = "0.22.21", default-features = false, features = [ - "parse", -] } - # Understanding package versions semver = { version = "1.0.23", features = ["serde"] } diff --git a/src/build/args.rs b/src/build/args.rs index 5fc7c061..06efcad7 100644 --- a/src/build/args.rs +++ b/src/build/args.rs @@ -24,6 +24,11 @@ impl BuildArgs { self.cargo_args.compilation_args.profile() } + /// The targeted platform. + pub(crate) fn target(&self) -> Option { + self.cargo_args.compilation_args.target(self.is_web()) + } + /// Generate arguments to forward to `cargo build`. pub(crate) fn cargo_args_builder(&self) -> ArgBuilder { self.cargo_args.args_builder(self.is_web()) diff --git a/src/build/mod.rs b/src/build/mod.rs index 3a6d9915..55f4ceb9 100644 --- a/src/build/mod.rs +++ b/src/build/mod.rs @@ -1,6 +1,6 @@ use crate::{ external_cli::{cargo, rustup, wasm_bindgen, CommandHelpers}, - manifest::package_name, + run::select_run_binary, }; pub use self::args::BuildArgs; @@ -13,11 +13,21 @@ pub fn build(args: &BuildArgs) -> anyhow::Result<()> { if args.is_web() { ensure_web_setup()?; + let metadata = cargo::metadata::metadata_with_args(["--no-deps"])?; + println!("Compiling to WebAssembly..."); cargo::build::command().args(cargo_args).ensure_status()?; println!("Bundling JavaScript bindings..."); - wasm_bindgen::bundle(&package_name()?, args.profile())?; + let bin_target = select_run_binary( + &metadata, + args.cargo_args.package_args.package.as_deref(), + args.cargo_args.target_args.bin.as_deref(), + args.cargo_args.target_args.example.as_deref(), + args.target().as_deref(), + args.profile(), + )?; + wasm_bindgen::bundle(&bin_target)?; } else { cargo::build::command().args(cargo_args).ensure_status()?; } diff --git a/src/external_cli/cargo/metadata.rs b/src/external_cli/cargo/metadata.rs index af696958..9b800e6f 100644 --- a/src/external_cli/cargo/metadata.rs +++ b/src/external_cli/cargo/metadata.rs @@ -83,6 +83,20 @@ impl Package { .any(|target_kind| *target_kind == TargetKind::Bin) }) } + + /// An iterator over all binary targets contained in this package. + pub fn bin_targets(&self) -> impl Iterator { + self.targets + .iter() + .filter(|target| target.kind.iter().any(|kind| *kind == TargetKind::Bin)) + } + + /// An iterator over all example targets contained in this package. + pub fn example_targets(&self) -> impl Iterator { + self.targets + .iter() + .filter(|target| target.kind.iter().any(|kind| *kind == TargetKind::Example)) + } } #[derive(Debug, Deserialize)] diff --git a/src/external_cli/cargo/mod.rs b/src/external_cli/cargo/mod.rs index 1199d230..a128864c 100644 --- a/src/external_cli/cargo/mod.rs +++ b/src/external_cli/cargo/mod.rs @@ -80,6 +80,14 @@ impl CargoCompilationArgs { } } + pub(crate) fn target(&self, is_web: bool) -> Option { + if is_web { + Some("wasm32-unknown-unknown".to_string()) + } else { + self.target.clone() + } + } + pub(crate) fn args_builder(&self, is_web: bool) -> ArgBuilder { // web takes precedence over --target let target = if is_web { diff --git a/src/external_cli/wasm_bindgen.rs b/src/external_cli/wasm_bindgen.rs index 46738a18..088bbbdc 100644 --- a/src/external_cli/wasm_bindgen.rs +++ b/src/external_cli/wasm_bindgen.rs @@ -1,40 +1,29 @@ -use std::{path::Path, process::Command}; +use std::process::Command; + +use crate::{external_cli::CommandHelpers, run::BinTarget}; use super::arg_builder::ArgBuilder; pub(crate) const PACKAGE: &str = "wasm-bindgen-cli"; pub(crate) const PROGRAM: &str = "wasm-bindgen"; -/// Determine the path to the folder where the Wasm build artifacts are stored. -pub(crate) fn get_target_folder(profile: &str) -> String { - format!("target/wasm32-unknown-unknown/{profile}") -} - /// Bundle the Wasm build for the web. -pub(crate) fn bundle(package_name: &str, profile: &str) -> anyhow::Result<()> { - let target_folder = get_target_folder(profile); +pub(crate) fn bundle(bin_target: &BinTarget) -> anyhow::Result<()> { + let original_wasm = bin_target + .artifact_directory + .clone() + .join(format!("{}.wasm", bin_target.bin_name)); - let status = Command::new(PROGRAM) + Command::new(PROGRAM) .args( ArgBuilder::new() .arg("--no-typescript") - .add_with_value("--out-name", "bevy_app") - .add_with_value("--out-dir", &target_folder) + .add_with_value("--out-name", &bin_target.bin_name) + .add_with_value("--out-dir", bin_target.artifact_directory.to_string_lossy()) .add_with_value("--target", "web") - .arg(format!("{target_folder}/{package_name}.wasm")), + .arg(original_wasm.to_string_lossy()), ) - .status()?; + .ensure_status()?; - anyhow::ensure!(status.success(), "Failed to bundle project for the web."); Ok(()) } - -/// Determine if a file path in the target folder is an artifact generated by wasm-bindgen. -pub(crate) fn is_bindgen_artifact(path: &Path) -> bool { - // The JS interface wrapping the WASM binary - let js_path = Path::new("bevy_app.js"); - // The WASM bindgen - let wasm_path = Path::new("bevy_app_bg.wasm"); - - path == js_path || path == wasm_path -} diff --git a/src/lib.rs b/src/lib.rs index fd57a5b7..c56abc86 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,6 +3,5 @@ pub mod build; pub mod external_cli; pub mod lint; -pub mod manifest; pub mod run; pub mod template; diff --git a/src/manifest.rs b/src/manifest.rs deleted file mode 100644 index 3d08c0ef..00000000 --- a/src/manifest.rs +++ /dev/null @@ -1,24 +0,0 @@ -use std::{fs::File, io::Read as _}; - -use toml_edit::{DocumentMut, Item, Value}; - -/// Get the contents of the manifest file. -fn get_cargo_toml(folder_name: &str) -> anyhow::Result { - let mut file = File::open(format!("{folder_name}/Cargo.toml"))?; - - let mut content = String::new(); - file.read_to_string(&mut content)?; - - Ok(content.parse()?) -} - -/// Determine the name of the cargo package. -pub(crate) fn package_name() -> anyhow::Result { - let cargo_toml = get_cargo_toml("./")?; - - if let Item::Value(Value::String(name)) = &cargo_toml["package"]["name"] { - Ok(name.value().clone()) - } else { - Err(anyhow::anyhow!("No package name defined in Cargo.toml")) - } -} diff --git a/src/run/args.rs b/src/run/args.rs index 47233303..b358f815 100644 --- a/src/run/args.rs +++ b/src/run/args.rs @@ -24,6 +24,11 @@ impl RunArgs { self.cargo_args.compilation_args.profile() } + /// The targeted platform. + pub(crate) fn target(&self) -> Option { + self.cargo_args.compilation_args.target(self.is_web()) + } + /// Generate arguments for `cargo`. pub(crate) fn cargo_args_builder(&self) -> ArgBuilder { self.cargo_args.args_builder(self.is_web()) diff --git a/src/run/mod.rs b/src/run/mod.rs index 369427ed..a202ef27 100644 --- a/src/run/mod.rs +++ b/src/run/mod.rs @@ -1,13 +1,11 @@ +use std::path::PathBuf; + use args::RunSubcommands; use crate::{ build::ensure_web_setup, external_cli::{ - cargo::{ - self, - metadata::{Metadata, Package}, - run::CargoRunArgs, - }, + cargo::{self, metadata::Metadata}, wasm_bindgen, CommandHelpers, }, }; @@ -30,10 +28,15 @@ pub fn run(args: &RunArgs) -> anyhow::Result<()> { cargo::build::command().args(cargo_args).ensure_status()?; println!("Bundling JavaScript bindings..."); - let package_name = select_run_package(&metadata, &args.cargo_args)? - .name - .clone(); - wasm_bindgen::bundle(&package_name, args.profile())?; + let bin_target = select_run_binary( + &metadata, + args.cargo_args.package_args.package.as_deref(), + args.cargo_args.target_args.bin.as_deref(), + args.cargo_args.target_args.example.as_deref(), + args.target().as_deref(), + args.profile(), + )?; + wasm_bindgen::bundle(&bin_target)?; let port = web_args.port; let url = format!("http://localhost:{port}"); @@ -50,7 +53,7 @@ pub fn run(args: &RunArgs) -> anyhow::Result<()> { println!("Open your app at <{url}>!"); } - serve::serve(port, args.profile())?; + serve::serve(bin_target, port)?; } else { // For native builds, wrap `cargo run` cargo::run::command().args(cargo_args).ensure_status()?; @@ -59,60 +62,134 @@ pub fn run(args: &RunArgs) -> anyhow::Result<()> { Ok(()) } -/// Determine which package should be run. +#[derive(Debug, Clone)] +pub(crate) struct BinTarget { + /// The path to the directory in `target` which contains the binary. + pub(crate) artifact_directory: PathBuf, + /// The name of the binary (without any extensions). + pub(crate) bin_name: String, +} + +/// Determine which binary target should be run. /// -/// We first take a look at the `--bin` and `--package` args. -/// If they are not defined, we try to determine the package automatically with the information -/// provided by cargo metadata. -/// We first look for the `default_run` definition and otherwise check if there is only a single -/// binary package that could be run. -fn select_run_package<'a>( - metadata: &'a Metadata, - args: &CargoRunArgs, -) -> anyhow::Result<&'a Package> { - let package_name = if let Some(bin) = &args.target_args.bin { - bin.clone() - } else if let Some(package) = &args.package_args.package { - package.clone() - } else { - // Try to determine the run package automatically - let default_runs: Vec<_> = metadata +/// The `--package` arg narrows down the search space to the given package, +/// while the `--bin` and `--example` args determine the binary target within the selected packages. +/// +/// If the search couldn't be narrowed down to a single binary, +/// the `default_run` option is taken into account. +/// +/// The path to the compiled binary is determined via the compilation target and profile. +pub(crate) fn select_run_binary( + metadata: &Metadata, + package_name: Option<&str>, + bin_name: Option<&str>, + example_name: Option<&str>, + compile_target: Option<&str>, + compile_profile: &str, +) -> anyhow::Result { + // Determine which packages the binary could be in + let packages = if let Some(package_name) = package_name { + let package = metadata .packages .iter() - .filter_map(|package| package.default_run.clone()) + .find(|package| package.name == *package_name) + .ok_or_else(|| anyhow::anyhow!("Failed to find package {package_name}"))?; + vec![package] + } else { + metadata.packages.iter().collect() + }; + + let mut is_example = false; + + let target = if let Some(bin_name) = bin_name { + // The user specified a concrete binary + let bins: Vec<_> = packages + .iter() + .flat_map(|package| { + package + .bin_targets() + .filter(|target| target.name == *bin_name) + }) + .collect(); + + if bins.is_empty() { + anyhow::bail!("No binary with name {bin_name} available!"); + } else if bins.len() > 1 { + anyhow::bail!("Multiple binaries with name {bin_name} available!"); + } + + bins[0] + } else if let Some(example_name) = example_name { + // The user specified a concrete example + let examples: Vec<_> = packages + .iter() + .flat_map(|package| { + package + .example_targets() + .filter(|target| target.name == *example_name) + }) + .collect(); + + if examples.is_empty() { + anyhow::bail!("No example with name {example_name} available!"); + } else if examples.len() > 1 { + anyhow::bail!("Multiple examples with name {example_name} available!"); + } + + is_example = true; + examples[0] + } else { + // Nothing concrete specified, try to pick one automatically + + // If there is only one binary, pick that one + let bins: Vec<_> = packages + .iter() + .flat_map(|package| package.bin_targets()) .collect(); - anyhow::ensure!(default_runs.len() <= 1, "More than one default run target"); - if let Some(default_run) = default_runs.into_iter().next() { - default_run + if bins.is_empty() { + anyhow::bail!("No binaries available!"); + } else if bins.len() == 1 { + bins[0] } else { - // If there is only one package with binary target, use that - let bin_packages: Vec<_> = metadata - .packages + // Otherwise, check if there is a default run target defined + let default_runs: Vec<_> = packages .iter() - .filter(|package| package.has_bin()) + .filter_map(|package| package.default_run.as_ref()) .collect(); - anyhow::ensure!( - bin_packages.len() <= 1, - "Multiple binary targets found: {}\nPlease select one with the `--bin` argument", - bin_packages - .iter() - .map(|package| package.name.clone()) - .collect::>() - .join(", ") - ); - - anyhow::ensure!(bin_packages.len() == 1, "No binary target found"); - bin_packages[0].name.clone() + + if default_runs.is_empty() { + anyhow::bail!("There are multiple binaries available, try specifying one with --bin or define `default_run` in the Cargo.toml"); + } else if default_runs.len() > 1 { + anyhow::bail!( + "Found multiple `default_run` definitions, I don't know which one to pick!" + ); + } else { + let default_run = default_runs[0]; + bins.iter() + .find(|bin| bin.name == *default_run) + .ok_or_else(|| { + anyhow::anyhow!("Didn't find `default_run` binary {default_run}") + })? + } } }; - match metadata - .packages - .iter() - .find(|package| package.name == package_name) - { - Some(package) => Ok(package), - None => Err(anyhow::anyhow!("Didn't find package {package_name}")), + // Assemble the path where the binary will be put + let mut artifact_directory = metadata.target_directory.clone(); + + if let Some(target) = compile_target { + artifact_directory.push(target); } + + artifact_directory.push(compile_profile); + + if is_example { + artifact_directory.push("examples"); + } + + Ok(BinTarget { + bin_name: target.name.clone(), + artifact_directory, + }) } diff --git a/src/run/serve.rs b/src/run/serve.rs index 9f2752a8..5ca53433 100644 --- a/src/run/serve.rs +++ b/src/run/serve.rs @@ -2,15 +2,10 @@ use actix_web::{rt, web, App, HttpResponse, HttpServer, Responder}; use std::path::Path; -use crate::external_cli::wasm_bindgen; - -/// If the user didn't provide an `index.html`, serve a default one. -async fn serve_default_index() -> impl Responder { - let content = include_str!(concat!( - env!("CARGO_MANIFEST_DIR"), - "/assets/web/index.html" - )); +use super::BinTarget; +/// Serve a static HTML file with the given content. +async fn serve_static_html(content: &'static str) -> impl Responder { // Build the HTTP response with appropriate headers to serve the content as a file HttpResponse::Ok() .insert_header(( @@ -20,19 +15,49 @@ async fn serve_default_index() -> impl Responder { .body(content) } +/// Create the default `index.html` if the user didn't provide one. +fn default_index(bin_target: &BinTarget) -> &'static str { + let template = include_str!(concat!( + env!("CARGO_MANIFEST_DIR"), + "/assets/web/index.html" + )); + + // Insert correct path to JS bindings + let index = template.replace( + "./build/bevy_app.js", + format!("./build/{}.js", bin_target.bin_name).as_str(), + ); + + // Only static strings can be served in the web app, + // so we leak the string memory to convert it to a static reference. + // PERF: This is assumed to be used only once and is needed for the rest of the app running + // time, making the memory leak acceptable. + Box::leak(index.into_boxed_str()) +} + /// Launch a web server running the Bevy app. -pub(crate) fn serve(port: u16, profile: &str) -> anyhow::Result<()> { - let profile = profile.to_string(); +pub(crate) fn serve(bin_target: BinTarget, port: u16) -> anyhow::Result<()> { + let index_html = default_index(&bin_target); rt::System::new().block_on( HttpServer::new(move || { let mut app = App::new(); + let bin_target = bin_target.clone(); // Serve the build artifacts at the `/build/*` route - // A custom `index.html` will have to call `/build/bevy_app.js` + // A custom `index.html` will have to call `/build/{bin_name}.js` app = app.service( - actix_files::Files::new("/build", wasm_bindgen::get_target_folder(&profile)) - .path_filter(|path, _| wasm_bindgen::is_bindgen_artifact(path)), + actix_files::Files::new("/build", bin_target.artifact_directory.clone()) + // This potentially includes artifacts which we will not need, + // but we can't add the bin name to the check due to lifetime requirements + .path_filter(move |path, _| { + path.file_stem().is_some_and(|stem| { + // Using `.starts_with` instead of equality, because of the `_bg` suffix + // of the WASM bindings + stem.to_string_lossy().starts_with(&bin_target.bin_name) + }) && (path.extension().is_some_and(|ext| ext == "js") + || path.extension().is_some_and(|ext| ext == "wasm")) + }), ); // If the app has an assets folder, serve it under `/assets` @@ -45,7 +70,7 @@ pub(crate) fn serve(port: u16, profile: &str) -> anyhow::Result<()> { app = app.service(actix_files::Files::new("/", "./web").index_file("index.html")); } else { // If the user doesn't provide a custom web setup, serve a default `index.html` - app = app.route("/", web::get().to(serve_default_index)) + app = app.route("/", web::get().to(|| serve_static_html(index_html))) } app From ed3ad6d11d7f35985c29c58034ec3cd13b5a0320 Mon Sep 17 00:00:00 2001 From: BD103 <59022059+BD103@users.noreply.github.com> Date: Sun, 8 Dec 2024 16:52:11 -0500 Subject: [PATCH 8/8] Linter: Restructure contributing guide + add section on types (#190) [View the changes live!](https://github.com/TheBevyFlock/bevy_cli/tree/contributing-guide/bevy_lint/docs) Closes #157. --- This PR fleshes out the contributing guide for `bevy_lint` a bit more, following [Divio's 4-category documentation system](https://docs.divio.com/documentation-system/). (I've seen it thrown around the Bevy Discord a bit, and was pleasantly surprised by what I found!) Now, the contributing guide will be split into 4 categories: - Tutorials (zero-to-hero guides, such as creating a lint and submitting a pull request) - How-to Guides (short, clear guides on accomplishing a specific _thing_, such as checking a type) - References (descriptive reference material for people familiar with the linter already, I'm not sure if this has a clear benefit over pure Rustdoc) - Explanations (design decisions, broad concepts, such as how `bevy_lint` differs from Clippy) I'm not sure how much mileage we'll get out of some of these, but it's still an improvement over our old, non-existent system! I also included a large list of additional resources, curated with what I found useful. @MrGVSV and @DaAlbrecht, do you both have anything to contribute to this list? Any additional resources that you found useful? --------- Co-authored-by: DAA <42379074+DaAlbrecht@users.noreply.github.com> Co-authored-by: Rich Churcher --- bevy_lint/docs/README.md | 65 +++++++++++++++ bevy_lint/docs/how-to/editor.md | 28 +++++++ bevy_lint/docs/{ => how-to}/release.md | 14 ++-- bevy_lint/docs/how-to/types.md | 107 +++++++++++++++++++++++++ bevy_lint/docs/index.md | 9 --- 5 files changed, 207 insertions(+), 16 deletions(-) create mode 100644 bevy_lint/docs/README.md create mode 100644 bevy_lint/docs/how-to/editor.md rename bevy_lint/docs/{ => how-to}/release.md (85%) create mode 100644 bevy_lint/docs/how-to/types.md delete mode 100644 bevy_lint/docs/index.md diff --git a/bevy_lint/docs/README.md b/bevy_lint/docs/README.md new file mode 100644 index 00000000..debfd44d --- /dev/null +++ b/bevy_lint/docs/README.md @@ -0,0 +1,65 @@ +# Contributor's Guide + +Thanks for your interest in contributing to `bevy_lint`! Please feel free to skim through the following table of contents: + +- [Tutorials](tutorials/) +- [How-to](how-to/) + - [Setting up your Editor](how-to/editor.md) + - [How to Work with Types](how-to/types.md) + - [How to Release `bevy_lint`](how-to/release.md) +- [Reference](reference/) +- [Explanations](explanations/) + +These docs follow [Divio's Documentation System](https://docs.divio.com/documentation-system/). + +> [!IMPORTANT] +> +> This is the documentation for _contributing_ to `bevy_lint`. If you want to learn how to _use_ `bevy_lint` instead, please view the live documentation [here](https://thebevyflock.github.io/bevy_cli/bevy_lint/) or see the main [`README.md`](../README.md). + +## Additional Resources + +⭐️ = Recommended Reading + +- [Rust Compiler Development Guide](https://rustc-dev-guide.rust-lang.org/) + - [Debugging the compiler](https://rustc-dev-guide.rust-lang.org/compiler-debugging.html) (not all sections apply) + - [Overview of the compiler](https://rustc-dev-guide.rust-lang.org/overview.html) + - [Queries: demand-driven compilation](https://rustc-dev-guide.rust-lang.org/query.html) + - [Memory Management in Rustc](https://rustc-dev-guide.rust-lang.org/memory.html) + - ⭐️ [The HIR](https://rustc-dev-guide.rust-lang.org/hir.html) + - [`rustc_driver` and `rustc_interface`](https://rustc-dev-guide.rust-lang.org/rustc-driver/intro.html) + - ⭐️ [Errors and Lints](https://rustc-dev-guide.rust-lang.org/rustc-driver/intro.html) + - ⭐️ [The `ty` module: representing types](https://rustc-dev-guide.rust-lang.org/ty.html) + - [Glossary](https://rustc-dev-guide.rust-lang.org/appendix/glossary.html) + - [Code Index](https://rustc-dev-guide.rust-lang.org/appendix/code-index.html) + - [Humor in Rust](https://rustc-dev-guide.rust-lang.org/appendix/humorust.html) (not actually relevant) +- [`rustc` API Docs](https://doc.rust-lang.org/nightly/nightly-rustc/) + - ⭐️ [`clippy_utils`](https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/index.html) + - ⭐️ [`match_type()`](https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/ty/fn.match_type.html) + - ⭐️ [`span_lint()`](https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/diagnostics/fn.span_lint.html) + - ⭐️ [`snippet()`](https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/source/fn.snippet.html) + - [`rustc_driver`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_driver/index.html) + - [`RunCompiler`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_driver/struct.RunCompiler.html) + - [`Callbacks`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_driver/trait.Callbacks.html) + - [`rustc_hir`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/index.html) + - ⭐️ [`DefId`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/def_id/struct.DefId.html) + - [`LocalDefId`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/def_id/struct.LocalDefId.html) + - [`HirId`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/hir_id/struct.HirId.html) + - ⭐️ [`Expr`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/hir/struct.Expr.html) + - [`Item`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/hir/struct.Item.html) + - [`Path`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/hir/struct.Path.html) + - [`Ty`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/hir/struct.Ty.html) (Not to be confused with `rustc_middle::ty::Ty`) + - [`rustc_span`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_span/index.html) + - [`rustc_lint`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint/index.html) + - ⭐️ [`LateLintPass`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint/trait.LateLintPass.html) + - ⭐️ [`LateContext`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint/struct.LateContext.html) + - [`rustc_lint_defs`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint_defs/index.html) + - [`rustc_middle`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/index.html) + - ⭐️ [`TyCtxt`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html) + - ⭐️ [`Ty`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.Ty.html) (Not to be confused with HIR `Ty`) + - [`Map`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/hir/map/struct.Map.html) (HIR) +- [Clippy Development](https://doc.rust-lang.org/stable/clippy/development/index.html) + - ⭐️ [Lint passes](https://doc.rust-lang.org/stable/clippy/development/lint_passes.html) + - ⭐️ [Emitting a lint](https://doc.rust-lang.org/stable/clippy/development/emitting_lints.html) + - ⭐️ [Type Checking](https://doc.rust-lang.org/stable/clippy/development/type_checking.html) + - ⭐️ [Dealing with macros and expansions](https://doc.rust-lang.org/stable/clippy/development/macro_expansions.html) + - [Common tools for writing lints](https://doc.rust-lang.org/stable/clippy/development/common_tools_writing_lints.html) diff --git a/bevy_lint/docs/how-to/editor.md b/bevy_lint/docs/how-to/editor.md new file mode 100644 index 00000000..b7c518d0 --- /dev/null +++ b/bevy_lint/docs/how-to/editor.md @@ -0,0 +1,28 @@ +# Setting up your Editor + +There can be a few extra steps required to get code completion and syntax highlighting setup with your editor. + +> [!NOTE] +> +> Can't find your editor here? Open [an issue here][issue tracker]! The [`rustc` Development Guide] may be a useful starting point, though several points won't apply to `bevy_lint`. + +[issue tracker]: https://github.com/TheBevyFlock/bevy_cli/issues +[`rustc` Development Guide]: https://rustc-dev-guide.rust-lang.org/building/suggested.html#configuring-rust-analyzer-for-rustc + +## VSCode + +`bevy_lint` works out-of-the-box with [VSCode's `rust-analyzer` extension]. The settings are specified in [`.vscode/settings.json`]. + +[VSCode's `rust-analyzer` extension]: https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer +[`.vscode/settings.json`]: ../../../.vscode/settings.json + +## Neovim + +First, setup `rust-analyzer` by following [the instructions here][rust-analyzer neovim instructions]. Next, install the [`neoconf.nvim`] plugin, which will automatically import the settings from [`.vscode/settings.json`]. + +[rust-analyzer neovim instructions]: https://rust-analyzer.github.io/manual.html#vimneovim +[`neoconf.nvim`]: https://github.com/folke/neoconf.nvim/ + +## RustRover + +As of December 2024, RustRover and the JetBrains Rust plugin do not work with `rustc`'s internal crates. If you manage to get it working, make sure to [submit an issue][issue tracker]! diff --git a/bevy_lint/docs/release.md b/bevy_lint/docs/how-to/release.md similarity index 85% rename from bevy_lint/docs/release.md rename to bevy_lint/docs/how-to/release.md index 943871ae..e5938de2 100644 --- a/bevy_lint/docs/release.md +++ b/bevy_lint/docs/how-to/release.md @@ -1,12 +1,12 @@ -# Release Checklist +# How to Release `bevy_lint` ## Kick-off Pull Request -1. Review the [changelog](../CHANGELOG.md) and ensure that all notable changes have been documented. +1. Review the [changelog](../../CHANGELOG.md) and ensure that all notable changes have been documented. 2. Replace `[Unreleased]` heading with the version with the format `[X.Y.Z] - YYYY-MM-DD`. 3. Update the `**All Changes**` link to compare from `main` to the new tag `lint-vX.Y.Z`. (E.g. `lint-v0.1.0...main` to `lint-v0.1.0...lint-v0.2.0`.) -4. Remove the `-dev` suffix from the version in [`Cargo.toml`](../Cargo.toml) and the compatibility table in [`README.md`](../README.md). - - Please ensure that [`Cargo.lock`](../../Cargo.lock) also updates! +4. Remove the `-dev` suffix from the version in [`Cargo.toml`](../../Cargo.toml) and the compatibility table in [`README.md`](../../README.md). + - Please ensure that [`Cargo.lock`](../../../Cargo.lock) also updates! 6. Commit all of these changes and open a pull request. 7. Merge the PR once a core Bevy maintainer approves it with no outstanding issues from other contributors. - This starts the release process, enacting a freeze on all other changes until the release has finished. While maintainers need to be aware of this so they do not merge PRs during this time, the release process should take less than an hour, so it's unlikely to ever be an issue. @@ -53,7 +53,7 @@ rustup run nightly-YYYY-MM-DD cargo install \ ## Post-Release -1. Add a new unreleased section to the top of the [changelog](../CHANGELOG.md) from the following template: +1. Add a new unreleased section to the top of the [changelog](../../CHANGELOG.md) from the following template: ```markdown ## [Unreleased] @@ -63,7 +63,7 @@ rustup run nightly-YYYY-MM-DD cargo install \ **All Changes**: [`lint-vX.Y.Z...main`](https://github.com/TheBevyFlock/bevy_cli/compare/lint-vX.Y.Z...main) ``` -2. Bump the version in [`Cargo.toml`](../Cargo.toml) to the next `-dev` version, and ensure [`Cargo.lock`](../../Cargo.lock) also updates. -3. Add a new row to the compatibility table for the new `-dev` version in [`README.md`](../README.md). +2. Bump the version in [`Cargo.toml`](../../Cargo.toml) to the next `-dev` version, and ensure [`Cargo.lock`](../../../Cargo.lock) also updates. +3. Add a new row to the compatibility table for the new `-dev` version in [`README.md`](../../README.md). 4. Commit all of these changes and open a pull request. 5. Merge the PR after it has been approved, unblocking frozen pull requests. diff --git a/bevy_lint/docs/how-to/types.md b/bevy_lint/docs/how-to/types.md new file mode 100644 index 00000000..b6be9449 --- /dev/null +++ b/bevy_lint/docs/how-to/types.md @@ -0,0 +1,107 @@ +# How to Work with Types + +> [!NOTE] +> +> This document assumes you are working with [`ty::Ty`], not [`rustc_hir::Ty`], unless explicitly stated otherwise. +> +> [`ty::Ty`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.Ty.html +> [`rustc_hir::Ty`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/hir/struct.Ty.html + +## Getting the Type of an Expression + +It is possible to get the type of an expression ([`Expr`]) through [`TypeckResults`]: + +```rust +fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &Expr<'tcx>) { + let ty = cx.typeck_results().expr_ty(expr); +} +``` + +[`Expr`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/hir/struct.Expr.html +[`TypeckResults`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/typeck_results/struct.TypeckResults.html + +## Peeling References + +Often you have the type that may be behind one or more references, such as `&&str` or `*mut [T]`, but you need to extract the underlying type (`str` and `[T]` in this case). You can do this by "peeling" references: + +```rust +let peeled_ty = ty.peel_refs(); +``` + +See [`Ty::peel_refs()`] for more information. + +[`Ty::peel_refs()`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.Ty.html#method.peel_refs + +## Checking for a Specific Type + +Often you have a `Ty`, and want to check if it matches a specific hardcoded type, such as Bevy's [`App`]. You can do this with `clippy_utils`'s [`match_type()`] function: + +```rust +use clippy_utils::ty::match_type; + +// The absolute path to `App`'s definition. +const APP: [&str; 3] = ["bevy_app", "app", "App"]; + +if match_type(cx, ty, &APP) { + // ... +} +``` + +All path constants are defined in [`paths.rs`](../../src/paths.rs). If you add a new constant, place it there. + +> [!IMPORTANT] +> +> `bevy_app::app` is a [private module], but we still have to refer to it by name because [`struct App`] is within `bevy_app/src/app.rs`. Do not be tricked by re-exported types, such as `bevy::prelude::App`! +> +> [private module]: https://docs.rs/bevy_app/0.15.0/src/bevy_app/lib.rs.html#14 +> [`struct App`]: https://docs.rs/bevy_app/0.15.0/src/bevy_app/app.rs.html#67-77 + +[`App`]: https://docs.rs/bevy/latest/bevy/app/struct.App.html +[`match_type()`]: https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/ty/fn.match_type.html + +## Getting `ty::Ty` from `rustc_hir::Ty` + +Often you'll have an [`rustc_hir::Ty`], but you need [`ty::Ty`]. This is a process known as _lowering_, and it is accomplished through two different structures: + +- [`FnCtxt`]: Used to type-check bodies of functions, closures, and `const`s. (Anything with expressions and statements.) +- [`ItemCtxt`]: Used to type-check item signatures. + +It is important to use the right context for the right situation, or the compiler may panic! + +Also note that this conversion is one-directional and cannot be easily reversed. While [`rustc_hir::Ty`]s are associated with a specific span of code, [`ty::Ty`]s are not. For more information, please see [`rustc_hir::Ty` vs `ty::Ty`] from the `rustc` Dev Guide. + +[`rustc_hir::Ty`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/hir/struct.Ty.html +[`ty::Ty`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.Ty.html +[`FnCtxt`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir_typeck/fn_ctxt/struct.FnCtxt.html +[`ItemCtxt`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir_analysis/collect/struct.ItemCtxt.html +[`rustc_hir::Ty` vs `ty::Ty`]: https://rustc-dev-guide.rust-lang.org/ty.html#rustc_hirty-vs-tyty + +### Within Bodies + +Instead of manually constructing a [`FnCtxt`], it is easier to go through [`TypeckResults::node_type()`]: + +```rust +fn check_local(&mut self, cx: &LateContext<'tcx>, let_stmt: &LetStmt<'tcx>) { + // Extract the type `T` from `let name: T = ...`, if it is specified. + if let Some(hir_ty) = let_stmt.ty { + // Find the `ty::Ty` for this `rustc_hir::Ty`. The reason this does not panic + // is because the type is from a `let` statement, which must be within a body. + let ty = cx.typeck_results().node_type(hir_ty.hir_id); + } +} +``` + +[`TypeckResults::node_type()`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/typeck_results/struct.TypeckResults.html#method.node_type + +### Outside Bodies + +When outside of a body, you must construct an [`ItemCtxt`]: + +```rust +fn check_ty(&mut self, cx: &LateContext<'tcx>, hir_ty: &rustc_hir::Ty<'tcx>) { + // `ItemCtxt` needs a ` LocalDefId` of the item that this type is within, which we access + // through the the type's `HirId`'s owner. + let item_cx = ItemCtxt::new(cx.tcx, hir_ty.hir_id.owner.def_id); + let ty = item_cx.lower_ty(hir_ty); +} +``` diff --git a/bevy_lint/docs/index.md b/bevy_lint/docs/index.md deleted file mode 100644 index f21265b7..00000000 --- a/bevy_lint/docs/index.md +++ /dev/null @@ -1,9 +0,0 @@ -# Contributor's Guide - -Thanks for your interest in contributing to `bevy_lint`! Please feel free to skim through the following table of contents: - -- [Release Checklist](release.md) - -> [!IMPORTANT] -> -> This is the documentation for _contributing_ to `bevy_lint`. If you want to learn how to _use_ `bevy_lint` instead, please view the live documentation [here](https://thebevyflock.github.io/bevy_cli/bevy_lint/) or see the main [`README.md`](../README.md).