-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
cargo init --bin creates a lib crate when crate source file is present #9333
Comments
Apparently
and get a binary crate. This is a reasonable heuristic, but I think the |
What if we have a file with I'm ready to fix this one if we have an answer |
I think an error would be fine, with hopefully a clear message that describes the conflict and maybe a suggestion on how to resolve it. |
A warning would be best, I think. It's conceivable that a particularly obdurate user intends to have a function named |
A warning would fine, too! I don't feel strongly one way or the other. |
Thank you! |
Problem
cargo init
has a nice feature, in that if the filefoo.rs
exists in the directoryfoo
that is being initialized, nosrc
directory will be created and insteadname = "foo"
andpath = "foo.rs"
will be placed inCargo.toml
.Unfortunately,
cargo init --bin
still produces alib
crate in this case.Steps
mkdir foo
cd foo
touch foo.rs
cargo init --bin
The resulting
Cargo.toml
isI would strongly prefer getting
[[bin]]
instead of[lib]
here.Notes
Output of
cargo version
:cargo 1.51.0 (43b129a20 2021-03-16)
The text was updated successfully, but these errors were encountered: