From d975e267b951475647c54fa3905f5ff83cb64ae7 Mon Sep 17 00:00:00 2001 From: Kristof Mattei <864376+Kristof-Mattei@users.noreply.github.com> Date: Sat, 13 Jan 2024 17:44:27 -0700 Subject: [PATCH] fix: add fix for bug, fix test name --- clippy_lints/src/cargo/multiple_crate_versions.rs | 2 +- .../multiple_crate_versions/12145_with_dashes/Cargo.stderr | 2 +- .../multiple_crate_versions/12145_with_dashes/Cargo.toml | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/clippy_lints/src/cargo/multiple_crate_versions.rs b/clippy_lints/src/cargo/multiple_crate_versions.rs index ec681adb7..a28934266 100644 --- a/clippy_lints/src/cargo/multiple_crate_versions.rs +++ b/clippy_lints/src/cargo/multiple_crate_versions.rs @@ -16,7 +16,7 @@ pub(super) fn check(cx: &LateContext<'_>, metadata: &Metadata) { if let Some(resolve) = &metadata.resolve && let Some(local_id) = packages.iter().find_map(|p| { - if p.name == local_name.as_str() { + if p.name.replace('-', "_") == local_name.as_str() { Some(&p.id) } else { None diff --git a/tests/ui-cargo/multiple_crate_versions/12145_with_dashes/Cargo.stderr b/tests/ui-cargo/multiple_crate_versions/12145_with_dashes/Cargo.stderr index 24a5402f5..8f0ca7649 100644 --- a/tests/ui-cargo/multiple_crate_versions/12145_with_dashes/Cargo.stderr +++ b/tests/ui-cargo/multiple_crate_versions/12145_with_dashes/Cargo.stderr @@ -3,4 +3,4 @@ error: multiple versions for dependency `winapi`: 0.2.8, 0.3.9 = note: `-D clippy::multiple-crate-versions` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::multiple_crate_versions)]` -error: could not compile `multiple-crate-versions-with-dashes` (bin "multiple-crate-versions-with-dashes") due to 1 previous error +error: could not compile `multiple-crate-versions` (bin "multiple-crate-versions") due to 1 previous error diff --git a/tests/ui-cargo/multiple_crate_versions/12145_with_dashes/Cargo.toml b/tests/ui-cargo/multiple_crate_versions/12145_with_dashes/Cargo.toml index 8ce6b0d5e..d39ad6c90 100644 --- a/tests/ui-cargo/multiple_crate_versions/12145_with_dashes/Cargo.toml +++ b/tests/ui-cargo/multiple_crate_versions/12145_with_dashes/Cargo.toml @@ -1,7 +1,8 @@ # Should not lint for dev or build dependencies. See issue 5041. [package] -name = "multiple-crate-versions-with-dashes" +# purposefully separated by - instead of _ +name = "multiple-crate-versions" version = "0.1.0" publish = false