Skip to content

Commit 2fbce89

Browse files
committed
Rephrase message of restricted crate name
1 parent c00ad79 commit 2fbce89

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

src/cargo/ops/cargo_new.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ fn check_name(
163163
// If --name is already used to override, no point in suggesting it
164164
// again as a fix.
165165
let name_help = if show_name_help {
166-
"\nuse --name to override crate name"
166+
"\nIf you need a crate name to not match the directory name, consider using --name flag."
167167
} else {
168168
""
169169
};

tests/testsuite/init.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,8 @@ fn invalid_dir_name() {
305305
.with_stderr(
306306
"\
307307
[ERROR] invalid character `.` in crate name: `foo.bar`, [..]
308-
use --name to override crate name",
308+
If you need a crate name to not match the directory name, consider using --name flag.
309+
",
309310
)
310311
.run();
311312

@@ -323,7 +324,7 @@ fn reserved_name() {
323324
.with_stderr(
324325
"\
325326
[ERROR] the name `test` cannot be used as a crate name, it conflicts [..]\n\
326-
use --name to override crate name
327+
If you need a crate name to not match the directory name, consider using --name flag.
327328
",
328329
)
329330
.run();

tests/testsuite/new.rs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ fn invalid_characters() {
119119
.with_stderr(
120120
"\
121121
[ERROR] invalid character `.` in crate name: `foo.rs`, [..]
122-
use --name to override crate name",
122+
If you need a crate name to not match the directory name, consider using --name flag.
123+
",
123124
)
124125
.run();
125126
}
@@ -131,7 +132,8 @@ fn reserved_name() {
131132
.with_stderr(
132133
"\
133134
[ERROR] the name `test` cannot be used as a crate name, it conflicts [..]
134-
use --name to override crate name",
135+
If you need a crate name to not match the directory name, consider using --name flag.
136+
",
135137
)
136138
.run();
137139
}
@@ -143,7 +145,8 @@ fn reserved_binary_name() {
143145
.with_stderr(
144146
"\
145147
[ERROR] the name `incremental` cannot be used as a crate name, it conflicts [..]
146-
use --name to override crate name",
148+
If you need a crate name to not match the directory name, consider using --name flag.
149+
",
147150
)
148151
.run();
149152

@@ -166,7 +169,8 @@ fn keyword_name() {
166169
.with_stderr(
167170
"\
168171
[ERROR] the name `pub` cannot be used as a crate name, it is a Rust keyword
169-
use --name to override crate name",
172+
If you need a crate name to not match the directory name, consider using --name flag.
173+
",
170174
)
171175
.run();
172176
}
@@ -539,7 +543,9 @@ fn restricted_windows_name() {
539543
.with_stderr(
540544
"\
541545
[ERROR] cannot use name `nul`, it is a reserved Windows filename
542-
use --name to override crate name",
546+
If you need a crate name to not match the directory name, consider using --name fla
547+
g.
548+
",
543549
)
544550
.run();
545551
} else {
@@ -580,7 +586,8 @@ fn non_ascii_name_invalid() {
580586
"\
581587
[ERROR] invalid character `Ⓐ` in crate name: `ⒶⒷⒸ`, \
582588
the first character must be a Unicode XID start character (most letters or `_`)
583-
use --name to override crate name",
589+
If you need a crate name to not match the directory name, consider using --name flag.
590+
",
584591
)
585592
.run();
586593

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

0 commit comments

Comments
 (0)