@@ -7,6 +7,7 @@ const DEFAULT_EDITION: crate::core::features::Edition =
7
7
crate :: core:: features:: Edition :: LATEST_STABLE ;
8
8
const DEFAULT_VERSION : & str = "0.0.0" ;
9
9
const DEFAULT_PUBLISH : bool = false ;
10
+ const AUTO_FIELDS : & [ & str ] = & [ "autobins" , "autoexamples" , "autotests" , "autobenches" ] ;
10
11
11
12
pub fn expand_manifest (
12
13
content : & str ,
@@ -56,8 +57,11 @@ fn expand_manifest_(
56
57
. or_insert_with ( || toml:: Table :: new ( ) . into ( ) )
57
58
. as_table_mut ( )
58
59
. ok_or_else ( || anyhow:: format_err!( "`package` must be a table" ) ) ?;
59
- for key in [ "workspace" , "build" , "links" ] {
60
- if package. contains_key ( key) {
60
+ for key in [ "workspace" , "build" , "links" ]
61
+ . iter ( )
62
+ . chain ( AUTO_FIELDS . iter ( ) )
63
+ {
64
+ if package. contains_key ( * key) {
61
65
anyhow:: bail!( "`package.{key}` is not allowed in embedded manifests" )
62
66
}
63
67
}
@@ -84,6 +88,11 @@ fn expand_manifest_(
84
88
package
85
89
. entry ( "publish" . to_owned ( ) )
86
90
. or_insert_with ( || toml:: Value :: Boolean ( DEFAULT_PUBLISH ) ) ;
91
+ for field in AUTO_FIELDS {
92
+ package
93
+ . entry ( field. to_owned ( ) )
94
+ . or_insert_with ( || toml:: Value :: Boolean ( false ) ) ;
95
+ }
87
96
88
97
let mut bin = toml:: Table :: new ( ) ;
89
98
bin. insert ( "name" . to_owned ( ) , toml:: Value :: String ( bin_name) ) ;
@@ -355,6 +364,10 @@ name = "test"
355
364
path = "/home/me/test.rs"
356
365
357
366
[package]
367
+ autobenches = false
368
+ autobins = false
369
+ autoexamples = false
370
+ autotests = false
358
371
edition = "2021"
359
372
name = "test"
360
373
publish = false
@@ -380,6 +393,10 @@ path = "/home/me/test.rs"
380
393
time = "0.1.25"
381
394
382
395
[package]
396
+ autobenches = false
397
+ autobins = false
398
+ autoexamples = false
399
+ autotests = false
383
400
edition = "2021"
384
401
name = "test"
385
402
publish = false
0 commit comments