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

Crate renaming allows for invalid characters without a warning #6656

Closed
shepmaster opened this issue Feb 13, 2019 · 4 comments · Fixed by #8090
Closed

Crate renaming allows for invalid characters without a warning #6656

shepmaster opened this issue Feb 13, 2019 · 4 comments · Fixed by #8090
Labels
A-diagnostics Area: Error and warning messages generated by Cargo itself. C-bug Category: bug E-easy Experience: Easy

Comments

@shepmaster
Copy link
Member

Problem

[package]
name = "example"
version = "0.1.0"
edition = "2018"

[dependencies]
"haha this isn't a valid name 🐛" = { package = "libc", version = "0.1" }
$ cargo build --verbose
       Fresh libc v0.1.12
   Compiling xz v0.1.0 (/private/tmp/xz)
     Running `rustc --edition=2018 --crate-name xz src/main.rs --color always --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=7ea0f6c7f3b6b365 -C extra-filename=-7ea0f6c7f3b6b365 --out-dir /private/tmp/xz/target/debug/deps -C incremental=/private/tmp/xz/target/debug/incremental -L dependency=/private/tmp/xz/target/debug/deps --extern 'haha this isn'\''t a valid name 🐛=/private/tmp/xz/target/debug/deps/liblibc-aee2768e37366de4.rlib'`

Possible Solution(s)

I'd expect a warning when the key names are not valid Rust identifiers.

Notes

$ cargo --version --verbose
cargo 1.32.0 (8610973aa 2019-01-02)
release: 1.32.0
commit-hash: 8610973aaf48615ba7dc9a38a9a2795ba6f36a31
commit-date: 2019-01-02
@shepmaster shepmaster added the C-bug Category: bug label Feb 13, 2019
@alexcrichton
Copy link
Member

Oh dear, that's definitely a bug!

@lukaslueg
Copy link
Contributor

Is it too heavy handed to add a call to valid_package_name() here? We actually allow dependencies named "!", only failing to resolve.

@ehuss
Copy link
Contributor

ehuss commented Feb 13, 2019

I would probably validate during toml parsing (somewhere like here).

@ehuss ehuss added A-diagnostics Area: Error and warning messages generated by Cargo itself. E-easy Experience: Easy labels Apr 6, 2020
@mbStavola
Copy link
Contributor

I'd like to take this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Error and warning messages generated by Cargo itself. C-bug Category: bug E-easy Experience: Easy
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants