@@ -8,6 +8,7 @@ const DEFAULT_EDITION: crate::core::features::Edition =
8
8
crate :: core:: features:: Edition :: LATEST_STABLE ;
9
9
const DEFAULT_VERSION : & str = "0.0.0" ;
10
10
const DEFAULT_PUBLISH : bool = false ;
11
+ const AUTO_FIELDS : & [ & str ] = & [ "autobins" , "autoexamples" , "autotests" , "autobenches" ] ;
11
12
12
13
pub fn expand_manifest (
13
14
content : & str ,
@@ -57,8 +58,11 @@ fn expand_manifest_(
57
58
. or_insert_with ( || toml:: Table :: new ( ) . into ( ) )
58
59
. as_table_mut ( )
59
60
. ok_or_else ( || anyhow:: format_err!( "`package` must be a table" ) ) ?;
60
- for key in [ "workspace" , "build" , "links" ] {
61
- if package. contains_key ( key) {
61
+ for key in [ "workspace" , "build" , "links" ]
62
+ . iter ( )
63
+ . chain ( AUTO_FIELDS . iter ( ) )
64
+ {
65
+ if package. contains_key ( * key) {
62
66
anyhow:: bail!( "`package.{key}` is not allowed in embedded manifests" )
63
67
}
64
68
}
@@ -88,6 +92,11 @@ fn expand_manifest_(
88
92
package
89
93
. entry ( "publish" . to_owned ( ) )
90
94
. or_insert_with ( || toml:: Value :: Boolean ( DEFAULT_PUBLISH ) ) ;
95
+ for field in AUTO_FIELDS {
96
+ package
97
+ . entry ( field. to_owned ( ) )
98
+ . or_insert_with ( || toml:: Value :: Boolean ( false ) ) ;
99
+ }
91
100
92
101
let mut bin = toml:: Table :: new ( ) ;
93
102
bin. insert ( "name" . to_owned ( ) , toml:: Value :: String ( bin_name) ) ;
@@ -363,6 +372,10 @@ name = "test-"
363
372
path = "test.rs"
364
373
365
374
[package]
375
+ autobenches = false
376
+ autobins = false
377
+ autoexamples = false
378
+ autotests = false
366
379
edition = "2021"
367
380
name = "test-"
368
381
publish = false
@@ -388,6 +401,10 @@ path = "test.rs"
388
401
time = "0.1.25"
389
402
390
403
[package]
404
+ autobenches = false
405
+ autobins = false
406
+ autoexamples = false
407
+ autotests = false
391
408
edition = "2021"
392
409
name = "test-"
393
410
publish = false
0 commit comments