You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Auto merge of #13606 - dvdhrm:pr/initlib, r=weihanglo
cargo/init: avoid target.name assignments if possible
Make `cargo init` skip `target.name` assignments if the default value is suitable.
Currently, all paths of `cargo init` will set target-names to the package-name, ensuring that a suitable target-name is set. This is required for all targets but libraries. Unfortunately, library-names have more restrictions than other targets. For example, creating a library with dashes will lead to errors:
mkdir foo-bar
cd foo-bar
touch foo-bar.rs
cargo init --lib
Fortunately, target-names for libraries are inferred from the package-name. Hence, by omitting the target-name, a valid configuration will be produced.
Instead of adjusting `SourceFileInformation::target_name` to use `Option<String>`, this commit strips the field completely, since all callers set it to the package-name.
Fixes: #11259
0 commit comments