@@ -10,6 +10,7 @@ use git2::Config as GitConfig;
10
10
use term:: color:: BLACK ;
11
11
12
12
use core:: Workspace ;
13
+ use ops:: is_bad_artifact_name;
13
14
use util:: { GitRepo , HgRepo , PijulRepo , CargoResult , human, ChainError , internal} ;
14
15
use util:: { Config , paths} ;
15
16
@@ -115,7 +116,7 @@ fn get_name<'a>(path: &'a Path, opts: &'a NewOptions, config: &Config) -> CargoR
115
116
}
116
117
}
117
118
118
- fn check_name ( name : & str ) -> CargoResult < ( ) > {
119
+ fn check_name ( name : & str , is_bin : bool ) -> CargoResult < ( ) > {
119
120
120
121
// Ban keywords + test list found at
121
122
// https://doc.rust-lang.org/grammar.html#keywords
@@ -130,7 +131,7 @@ fn check_name(name: &str) -> CargoResult<()> {
130
131
"super" , "test" , "trait" , "true" , "type" , "typeof" ,
131
132
"unsafe" , "unsized" , "use" , "virtual" , "where" ,
132
133
"while" , "yield" ] ;
133
- if blacklist. contains ( & name) {
134
+ if blacklist. contains ( & name) || ( is_bin && is_bad_artifact_name ( name ) ) {
134
135
bail ! ( "The name `{}` cannot be used as a crate name\n \
135
136
use --name to override crate name",
136
137
name)
@@ -274,7 +275,7 @@ pub fn new(opts: NewOptions, config: &Config) -> CargoResult<()> {
274
275
}
275
276
276
277
let name = get_name ( & path, & opts, config) ?;
277
- check_name ( name) ?;
278
+ check_name ( name, opts . bin ) ?;
278
279
279
280
let mkopts = MkOptions {
280
281
version_control : opts. version_control ,
@@ -303,7 +304,7 @@ pub fn init(opts: NewOptions, config: &Config) -> CargoResult<()> {
303
304
}
304
305
305
306
let name = get_name ( & path, & opts, config) ?;
306
- check_name ( name) ?;
307
+ check_name ( name, opts . bin ) ?;
307
308
308
309
let mut src_paths_types = vec ! [ ] ;
309
310
0 commit comments