cargo init
no longer handles pre-existing source files nicely #3722
Closed
Description
opened on Feb 17, 2017
#3004 broken it a bit.
Previously Cargo looked for files like main.rs
, src/main.rs
, lib.rs
, src/lib.rs
, projectname.rs
and src/projectname.rs
and created [[bin]]
and/or [lib]
sections in Cargo.toml
automatically if source files located unusually.
Now it does look for those files, but fails to use this information meaningfully and just creates src/main.rs
or src/lib.rs
instead of using sections in Cargo.toml even if a usable source file outside src
already exists, making the "hello world" lib or app while previously it used pre-existing source code.
What shall be done? Options:
- Remove any auto-detection code. Rely only on explicit
--lib
/--bin
. Don't look at any files except ofsrc/{main,lib}.rs
- Implement insertion of
[[bin]]
and[lib]
again (when--template
is not in use) - Make Cargo move pre-existing source file to the appropriate location in
cargo init
, e.gmyapp/myapp.rs
becomesmyapp/src/main.rs
.
Metadata
Assignees
Labels
No labels
Activity