Add test for multiple_crate_versions

Make the output of the lint deterministic by sorting the versions
This commit is contained in:
Eduardo Broto 2020-05-18 20:58:02 +02:00
parent bc93f7052e
commit 7a0eccbd8a
6 changed files with 29 additions and 1 deletions

View file

@ -54,7 +54,9 @@ impl LateLintPass<'_, '_> for MultipleCrateVersions {
let group: Vec<cargo_metadata::Package> = group.collect();
if group.len() > 1 {
let versions = group.into_iter().map(|p| p.version).join(", ");
let mut versions: Vec<_> = group.into_iter().map(|p| p.version).collect();
versions.sort();
let versions = versions.iter().join(", ");
span_lint(
cx,

View file

@ -0,0 +1,7 @@
[package]
name = "multiple_crate_versions"
version = "0.1.0"
[dependencies]
ctrlc = "=3.1.0"
ansi_term = "=0.11.0"

View file

@ -0,0 +1,3 @@
#![warn(clippy::multiple_crate_versions)]
fn main() {}

View file

@ -0,0 +1,6 @@
error: multiple versions for dependency `winapi`: 0.2.8, 0.3.8
|
= note: `-D clippy::multiple-crate-versions` implied by `-D warnings`
error: aborting due to previous error

View file

@ -0,0 +1,7 @@
[package]
name = "cargo_common_metadata"
version = "0.1.0"
[dependencies]
regex = "1.3.7"
serde = "1.0.110"

View file

@ -0,0 +1,3 @@
#![warn(clippy::multiple_crate_versions)]
fn main() {}