mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 13:13:34 +00:00
Add test for multiple_crate_versions
Make the output of the lint deterministic by sorting the versions
This commit is contained in:
parent
bc93f7052e
commit
7a0eccbd8a
6 changed files with 29 additions and 1 deletions
|
@ -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,
|
||||
|
|
7
tests/ui-cargo/multiple_crate_versions/fail/Cargo.toml
Normal file
7
tests/ui-cargo/multiple_crate_versions/fail/Cargo.toml
Normal file
|
@ -0,0 +1,7 @@
|
|||
[package]
|
||||
name = "multiple_crate_versions"
|
||||
version = "0.1.0"
|
||||
|
||||
[dependencies]
|
||||
ctrlc = "=3.1.0"
|
||||
ansi_term = "=0.11.0"
|
3
tests/ui-cargo/multiple_crate_versions/fail/src/main.rs
Normal file
3
tests/ui-cargo/multiple_crate_versions/fail/src/main.rs
Normal file
|
@ -0,0 +1,3 @@
|
|||
#![warn(clippy::multiple_crate_versions)]
|
||||
|
||||
fn main() {}
|
|
@ -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
|
||||
|
7
tests/ui-cargo/multiple_crate_versions/pass/Cargo.toml
Normal file
7
tests/ui-cargo/multiple_crate_versions/pass/Cargo.toml
Normal file
|
@ -0,0 +1,7 @@
|
|||
[package]
|
||||
name = "cargo_common_metadata"
|
||||
version = "0.1.0"
|
||||
|
||||
[dependencies]
|
||||
regex = "1.3.7"
|
||||
serde = "1.0.110"
|
3
tests/ui-cargo/multiple_crate_versions/pass/src/main.rs
Normal file
3
tests/ui-cargo/multiple_crate_versions/pass/src/main.rs
Normal file
|
@ -0,0 +1,3 @@
|
|||
#![warn(clippy::multiple_crate_versions)]
|
||||
|
||||
fn main() {}
|
Loading…
Reference in a new issue