diff --git a/Cargo.lock b/Cargo.lock index 29cef9f2..277b3efe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -473,7 +473,7 @@ dependencies = [ [[package]] name = "bevy_lint" -version = "0.2.0-dev" +version = "0.2.0" dependencies = [ "anyhow", "bevy", diff --git a/bevy_lint/CHANGELOG.md b/bevy_lint/CHANGELOG.md index b9947ecd..ee300e79 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] +## [v0.2.0] - 2025-03-19 -**All Changes**: [`lint-v0.1.0...main`](https://github.com/TheBevyFlock/bevy_cli/compare/lint-v0.1.0...main) +**All Changes**: [`lint-v0.1.0...lint-v0.2.0`](https://github.com/TheBevyFlock/bevy_cli/compare/lint-v0.1.0...lint-v0.2.0) ### Added diff --git a/bevy_lint/Cargo.toml b/bevy_lint/Cargo.toml index f3153173..d162ac20 100644 --- a/bevy_lint/Cargo.toml +++ b/bevy_lint/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bevy_lint" -version = "0.2.0-dev" +version = "0.2.0" authors = ["BD103"] edition = "2024" description = "A collection of lints for the Bevy game engine" diff --git a/bevy_lint/README.md b/bevy_lint/README.md index ea2a29a7..9e3cf267 100644 --- a/bevy_lint/README.md +++ b/bevy_lint/README.md @@ -176,7 +176,7 @@ There are several other ways to toggle lints, although some have varying levels |`bevy_lint` Version|Rust Version|Rustup Toolchain|Bevy Version| |-|-|-|-| -|0.2.0-dev|1.84.0|`nightly-2025-02-20`|0.15| +|0.2.0|1.84.0|`nightly-2025-02-20`|0.15| |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/src/lints/cargo/mod.rs b/bevy_lint/src/lints/cargo.rs similarity index 89% rename from bevy_lint/src/lints/cargo/mod.rs rename to bevy_lint/src/lints/cargo.rs index e9becc11..8e3654ae 100644 --- a/bevy_lint/src/lints/cargo/mod.rs +++ b/bevy_lint/src/lints/cargo.rs @@ -1,15 +1,13 @@ //! Lints that check over `Cargo.toml` instead of your code. +use super::duplicate_bevy_dependencies::DUPLICATE_BEVY_DEPENDENCIES; use crate::declare_bevy_lint_pass; use cargo_metadata::MetadataCommand; use clippy_utils::sym; -use duplicate_bevy_dependencies::DUPLICATE_BEVY_DEPENDENCIES; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{config::Input, utils::was_invoked_from_cargo}; use rustc_span::Symbol; -pub mod duplicate_bevy_dependencies; - declare_bevy_lint_pass! { pub Cargo => [DUPLICATE_BEVY_DEPENDENCIES.lint], @default = { @@ -37,7 +35,7 @@ impl LateLintPass<'_> for Cargo { .exec() { Ok(metadata) => { - duplicate_bevy_dependencies::check(cx, &metadata, self.bevy); + super::duplicate_bevy_dependencies::check(cx, &metadata, self.bevy); } Err(e) => { cx.tcx diff --git a/bevy_lint/src/lints/cargo/duplicate_bevy_dependencies.rs b/bevy_lint/src/lints/duplicate_bevy_dependencies.rs similarity index 91% rename from bevy_lint/src/lints/cargo/duplicate_bevy_dependencies.rs rename to bevy_lint/src/lints/duplicate_bevy_dependencies.rs index e87057c6..7a6a157c 100644 --- a/bevy_lint/src/lints/cargo/duplicate_bevy_dependencies.rs +++ b/bevy_lint/src/lints/duplicate_bevy_dependencies.rs @@ -1,11 +1,20 @@ //! Checks for multiple versions of the `bevy` crate in your project's dependencies. //! +//! This lint will prevent you from accidentally using multiple versions of the Bevy game engine at +//! the same time by scanning your dependency tree for the `bevy` crate. If your project or its +//! dependencies use different versions of `bevy`, this lint will emit a warning. +//! +//! You may also be interested in [`cargo-deny`], which can detect duplicate dependencies as well, +//! and is far more powerful and configurable. +//! +//! [`cargo-deny`]: https://github.com/EmbarkStudios/cargo-deny +//! //! # Motivation //! //! Cargo allows there to be multiple major versions of a crate in your project's dependency -//! tree[^semver-compatibility]. Though the two crates and their types are _named_ the same, they -//! are treated as distinct by the compiler. This can lead to confusing error messages that only -//! appear if you try to mix the types from the two versions of the crate. +//! tree[^semver-compatibility]. Although the crates and their types are _named_ the same, they are +//! treated as distinct by the compiler. This can lead to confusing error messages that only appear +//! if you try to mix the types from the two versions of the crate. //! //! With Bevy, these errors become particularly easy to encounter when you add a plugin that pulls //! in a different version of the Bevy engine. (This isn't immediately obvious, however, unless you @@ -78,6 +87,7 @@ declare_bevy_lint! { pub DUPLICATE_BEVY_DEPENDENCIES, NURSERY, "multiple versions of the `bevy` crate found", + @crate_level_only = true, } #[derive(Deserialize, Debug)] diff --git a/bevy_lint/src/lints/mod.rs b/bevy_lint/src/lints/mod.rs index ea5d591b..f9b783ef 100644 --- a/bevy_lint/src/lints/mod.rs +++ b/bevy_lint/src/lints/mod.rs @@ -7,8 +7,10 @@ use crate::lint::BevyLint; use rustc_lint::{Lint, LintStore}; +mod cargo; + pub mod borrowed_reborrowable; -pub mod cargo; +pub mod duplicate_bevy_dependencies; pub mod insert_event_resource; pub mod insert_unit_bundle; pub mod main_return_without_appexit; @@ -19,7 +21,7 @@ pub mod zst_query; pub(crate) static LINTS: &[&BevyLint] = &[ borrowed_reborrowable::BORROWED_REBORROWABLE, - cargo::duplicate_bevy_dependencies::DUPLICATE_BEVY_DEPENDENCIES, + duplicate_bevy_dependencies::DUPLICATE_BEVY_DEPENDENCIES, insert_event_resource::INSERT_EVENT_RESOURCE, insert_unit_bundle::INSERT_UNIT_BUNDLE, main_return_without_appexit::MAIN_RETURN_WITHOUT_APPEXIT,