-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
458e416
commit 8d8b851
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
//! Checks for multiple versions of `bevy` in the dependencies. | ||
//! | ||
//! # Motivation | ||
//! | ||
//! When different third party crates use incompatible versions of Bevy, it can lead to confusing | ||
//! errors and type incompatibilities. | ||
use crate::declare_bevy_lint; | ||
use clippy_utils::{diagnostics::span_lint, find_crates}; | ||
use rustc_lint::{LateContext, LateLintPass}; | ||
use rustc_session::declare_lint_pass; | ||
use rustc_span::Symbol; | ||
|
||
declare_bevy_lint! { | ||
pub DUPLICATE_BEVY_DEPENDENCIES, | ||
CORRECTNESS, | ||
"duplicate bevy dependencies", | ||
} | ||
|
||
declare_lint_pass! { | ||
DuplicateBevyDependencies => [DUPLICATE_BEVY_DEPENDENCIES.lint] | ||
} | ||
|
||
impl<'tcx> LateLintPass<'tcx> for DuplicateBevyDependencies { | ||
fn check_crate(&mut self, cx: &LateContext<'tcx>) { | ||
let bevy_crates = find_crates(cx.tcx, Symbol::intern("bevy")); | ||
|
||
if bevy_crates.len() > 1 { | ||
let span = cx.tcx.def_span(bevy_crates[1].def_id()); | ||
span_lint( | ||
cx, | ||
DUPLICATE_BEVY_DEPENDENCIES.lint, | ||
span, | ||
"Multiple versions of `bevy` found", | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters