Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions bevy_lint/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion bevy_lint/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion bevy_lint/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.)
Expand Down
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)]
Expand Down
6 changes: 4 additions & 2 deletions bevy_lint/src/lints/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand Down