Skip to content

Commit

Permalink
Rephrase message of restricted crate name
Browse files Browse the repository at this point in the history
  • Loading branch information
weihanglo committed Sep 10, 2020
1 parent c00ad79 commit 2fbce89
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/cargo/ops/cargo_new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ fn check_name(
// If --name is already used to override, no point in suggesting it
// again as a fix.
let name_help = if show_name_help {
"\nuse --name to override crate name"
"\nIf you need a crate name to not match the directory name, consider using --name flag."
} else {
""
};
Expand Down
5 changes: 3 additions & 2 deletions tests/testsuite/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,8 @@ fn invalid_dir_name() {
.with_stderr(
"\
[ERROR] invalid character `.` in crate name: `foo.bar`, [..]
use --name to override crate name",
If you need a crate name to not match the directory name, consider using --name flag.
",
)
.run();

Expand All @@ -323,7 +324,7 @@ fn reserved_name() {
.with_stderr(
"\
[ERROR] the name `test` cannot be used as a crate name, it conflicts [..]\n\
use --name to override crate name
If you need a crate name to not match the directory name, consider using --name flag.
",
)
.run();
Expand Down
22 changes: 15 additions & 7 deletions tests/testsuite/new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ fn invalid_characters() {
.with_stderr(
"\
[ERROR] invalid character `.` in crate name: `foo.rs`, [..]
use --name to override crate name",
If you need a crate name to not match the directory name, consider using --name flag.
",
)
.run();
}
Expand All @@ -131,7 +132,8 @@ fn reserved_name() {
.with_stderr(
"\
[ERROR] the name `test` cannot be used as a crate name, it conflicts [..]
use --name to override crate name",
If you need a crate name to not match the directory name, consider using --name flag.
",
)
.run();
}
Expand All @@ -143,7 +145,8 @@ fn reserved_binary_name() {
.with_stderr(
"\
[ERROR] the name `incremental` cannot be used as a crate name, it conflicts [..]
use --name to override crate name",
If you need a crate name to not match the directory name, consider using --name flag.
",
)
.run();

Expand All @@ -166,7 +169,8 @@ fn keyword_name() {
.with_stderr(
"\
[ERROR] the name `pub` cannot be used as a crate name, it is a Rust keyword
use --name to override crate name",
If you need a crate name to not match the directory name, consider using --name flag.
",
)
.run();
}
Expand Down Expand Up @@ -539,7 +543,9 @@ fn restricted_windows_name() {
.with_stderr(
"\
[ERROR] cannot use name `nul`, it is a reserved Windows filename
use --name to override crate name",
If you need a crate name to not match the directory name, consider using --name fla
g.
",
)
.run();
} else {
Expand Down Expand Up @@ -580,7 +586,8 @@ fn non_ascii_name_invalid() {
"\
[ERROR] invalid character `Ⓐ` in crate name: `ⒶⒷⒸ`, \
the first character must be a Unicode XID start character (most letters or `_`)
use --name to override crate name",
If you need a crate name to not match the directory name, consider using --name flag.
",
)
.run();

Expand All @@ -591,7 +598,8 @@ use --name to override crate name",
"\
[ERROR] invalid character `¼` in crate name: `a¼`, \
characters must be Unicode XID characters (numbers, `-`, `_`, or most letters)
use --name to override crate name",
If you need a crate name to not match the directory name, consider using --name flag.
",
)
.run();
}

0 comments on commit 2fbce89

Please sign in to comment.