Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multiple_crate_versions doesn't report when name contains a dash #12145

Closed
kristof-mattei opened this issue Jan 14, 2024 · 0 comments · Fixed by #12146
Closed

multiple_crate_versions doesn't report when name contains a dash #12145

kristof-mattei opened this issue Jan 14, 2024 · 0 comments · Fixed by #12146
Labels
C-bug Category: Clippy is not doing the correct thing

Comments

@kristof-mattei
Copy link
Contributor

kristof-mattei commented Jan 14, 2024

Summary

When using multiple_crate_versions on a crate with an dash in the name the multiple_crate_versions does not trip.

If you use multiple_crate_versions on a crate without a -, so either a _ or just no - at all, the lint works as expected.

Is it because LOCAL_CRATE (link) is normalized, i.e. - is replaced by _. Further down, comparing it to p.name (link) that is an issue as p.name has the package name (with - intact), not the normalized name.

Fix: #12146

Reproducer

Setup 1 (with dash in name):

cargo new with-dash
cd with-dash
cargo add regex stubr --quiet
cargo tree --depth 1
cargo clippy --quiet -- --deny clippy::multiple_crate_versions

Output 1:

kristof in ~/__SOURCES/temp
❯ cargo new with-dash
     Created binary (application) `with-dash` package

kristof in ~/__SOURCES/temp
❯ cd with-dash

kristof in with-dash on  main [?] is 📦 v0.1.0 via 🦀 v1.75.0
❯ cargo add regex stubr --quiet

kristof in with-dash on  main [?] is 📦 v0.1.0 via 🦀 v1.75.0
❯ cargo tree --depth 1
with-dash v0.1.0 (/home/kristof/__SOURCES/temp/with-dash)
├── regex v1.10.2
└── stubr v0.6.2
    [build-dependencies]

Setup 2 (with underscore in name):

cargo new with_underscore
cd with_underscore
cargo add regex stubr --quiet
cargo tree --depth 1
cargo clippy --quiet -- --deny clippy::multiple_crate_versions

Output 2:

kristof in ~/__SOURCES/temp
❯ cargo new with_underscore
     Created binary (application) `with_underscore` package

kristof in ~/__SOURCES/temp
❯ cd with_underscore

kristof in with_underscore on  main [?] is 📦 v0.1.0 via 🦀 v1.75.0
❯ cargo add regex stubr --quiet

kristof in with_underscore on  main [?] is 📦 v0.1.0 via 🦀 v1.75.0
❯ cargo tree --depth 1
with_underscore v0.1.0 (/home/kristof/__SOURCES/temp/with_underscore)
├── regex v1.10.2
└── stubr v0.6.2
    [build-dependencies]

kristof in with_underscore on  main [?] is 📦 v0.1.0 via 🦀 v1.75.0
❯ cargo clippy --quiet -- --deny clippy::multiple_crate_versions
error: multiple versions for dependency `async-channel`: 1.9.0, 2.1.1
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions
  = note: requested on the command line with `-D clippy::multiple-crate-versions`

error: multiple versions for dependency `async-io`: 1.13.0, 2.2.2
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: multiple versions for dependency `async-lock`: 2.8.0, 3.3.0
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: multiple versions for dependency `base64`: 0.13.1, 0.21.7
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: multiple versions for dependency `bitflags`: 1.3.2, 2.4.1
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: multiple versions for dependency `event-listener`: 2.5.3, 4.0.3
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: multiple versions for dependency `fastrand`: 1.9.0, 2.0.1
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: multiple versions for dependency `futures-lite`: 1.13.0, 2.2.0
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: multiple versions for dependency `getrandom`: 0.1.16, 0.2.12
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: multiple versions for dependency `linux-raw-sys`: 0.3.8, 0.4.12
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: multiple versions for dependency `polling`: 2.8.0, 3.3.1
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: multiple versions for dependency `rand`: 0.7.3, 0.8.5
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: multiple versions for dependency `rand_chacha`: 0.2.2, 0.3.1
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: multiple versions for dependency `rand_core`: 0.5.1, 0.6.4
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: multiple versions for dependency `regex-syntax`: 0.6.29, 0.8.2
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: multiple versions for dependency `rustix`: 0.37.27, 0.38.30
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: multiple versions for dependency `socket2`: 0.4.10, 0.5.5
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: multiple versions for dependency `syn`: 1.0.109, 2.0.48
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: multiple versions for dependency `wasi`: 0.9.0+wasi-snapshot-preview1, 0.11.0+wasi-snapshot-preview1
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: multiple versions for dependency `windows-sys`: 0.48.0, 0.52.0
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: multiple versions for dependency `windows-targets`: 0.48.5, 0.52.0
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: multiple versions for dependency `windows_aarch64_gnullvm`: 0.48.5, 0.52.0
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: multiple versions for dependency `windows_aarch64_msvc`: 0.48.5, 0.52.0
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: multiple versions for dependency `windows_i686_gnu`: 0.48.5, 0.52.0
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: multiple versions for dependency `windows_i686_msvc`: 0.48.5, 0.52.0
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: multiple versions for dependency `windows_x86_64_gnu`: 0.48.5, 0.52.0
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: multiple versions for dependency `windows_x86_64_gnullvm`: 0.48.5, 0.52.0
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: multiple versions for dependency `windows_x86_64_msvc`: 0.48.5, 0.52.0
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: could not compile `with_underscore` (bin "with_underscore") due to 28 previous errors

Setup 3 (with nothing in the name, just one word):

cargo new justoneword
cd justoneword
cargo add regex stubr --quiet
cargo tree --depth 1
cargo clippy --quiet -- --deny clippy::multiple_crate_versions

Output 3:

kristof in ~/__SOURCES/temp
❯ cargo new justoneword
     Created binary (application) `justoneword` package

kristof in ~/__SOURCES/temp
❯ cd justoneword

kristof in justoneword on  main [?] is 📦 v0.1.0 via 🦀 v1.75.0
❯ cargo add regex stubr --quiet

kristof in justoneword on  main [?] is 📦 v0.1.0 via 🦀 v1.75.0
❯ cargo tree --depth 1
justoneword v0.1.0 (/home/kristof/__SOURCES/temp/justoneword)
├── regex v1.10.2
└── stubr v0.6.2
    [build-dependencies]

kristof in justoneword on  main [?] is 📦 v0.1.0 via 🦀 v1.75.0
❯ cargo clippy --quiet -- --deny clippy::multiple_crate_versions
error: multiple versions for dependency `async-channel`: 1.9.0, 2.1.1
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions
  = note: requested on the command line with `-D clippy::multiple-crate-versions`

error: multiple versions for dependency `async-io`: 1.13.0, 2.2.2
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: multiple versions for dependency `async-lock`: 2.8.0, 3.3.0
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: multiple versions for dependency `base64`: 0.13.1, 0.21.7
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: multiple versions for dependency `bitflags`: 1.3.2, 2.4.1
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: multiple versions for dependency `event-listener`: 2.5.3, 4.0.3
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: multiple versions for dependency `fastrand`: 1.9.0, 2.0.1
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: multiple versions for dependency `futures-lite`: 1.13.0, 2.2.0
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: multiple versions for dependency `getrandom`: 0.1.16, 0.2.12
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: multiple versions for dependency `linux-raw-sys`: 0.3.8, 0.4.12
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: multiple versions for dependency `polling`: 2.8.0, 3.3.1
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: multiple versions for dependency `rand`: 0.7.3, 0.8.5
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: multiple versions for dependency `rand_chacha`: 0.2.2, 0.3.1
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: multiple versions for dependency `rand_core`: 0.5.1, 0.6.4
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: multiple versions for dependency `regex-syntax`: 0.6.29, 0.8.2
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: multiple versions for dependency `rustix`: 0.37.27, 0.38.30
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: multiple versions for dependency `socket2`: 0.4.10, 0.5.5
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: multiple versions for dependency `syn`: 1.0.109, 2.0.48
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: multiple versions for dependency `wasi`: 0.9.0+wasi-snapshot-preview1, 0.11.0+wasi-snapshot-preview1
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: multiple versions for dependency `windows-sys`: 0.48.0, 0.52.0
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: multiple versions for dependency `windows-targets`: 0.48.5, 0.52.0
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: multiple versions for dependency `windows_aarch64_gnullvm`: 0.48.5, 0.52.0
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: multiple versions for dependency `windows_aarch64_msvc`: 0.48.5, 0.52.0
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: multiple versions for dependency `windows_i686_gnu`: 0.48.5, 0.52.0
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: multiple versions for dependency `windows_i686_msvc`: 0.48.5, 0.52.0
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: multiple versions for dependency `windows_x86_64_gnu`: 0.48.5, 0.52.0
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: multiple versions for dependency `windows_x86_64_gnullvm`: 0.48.5, 0.52.0
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: multiple versions for dependency `windows_x86_64_msvc`: 0.48.5, 0.52.0
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions

error: could not compile `justoneword` (bin "justoneword") due to 28 previous errors

Version

❯ rustc -Vv
rustc 1.75.0 (82e1608df 2023-12-21)
binary: rustc
commit-hash: 82e1608dfa6e0b5569232559e3d385fea5a93112
commit-date: 2023-12-21
host: x86_64-unknown-linux-gnu
release: 1.75.0
LLVM version: 17.0.6

Additional Labels

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing
Projects
None yet
1 participant