@@ -7,6 +7,7 @@ const DEFAULT_EDITION: crate::core::features::Edition =
77 crate :: core:: features:: Edition :: LATEST_STABLE ;
88const DEFAULT_VERSION : & str = "0.0.0" ;
99const DEFAULT_PUBLISH : bool = false ;
10+ const AUTO_FIELDS : & [ & str ] = & [ "autobins" , "autoexamples" , "autotests" , "autobenches" ] ;
1011
1112pub fn expand_manifest (
1213 content : & str ,
@@ -57,8 +58,11 @@ fn expand_manifest_(
5758 . or_insert_with ( || toml:: Table :: new ( ) . into ( ) )
5859 . as_table_mut ( )
5960 . 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) {
6266 anyhow:: bail!( "`package.{key}` is not allowed in embedded manifests" )
6367 }
6468 }
@@ -86,6 +90,11 @@ fn expand_manifest_(
8690 package
8791 . entry ( "publish" . to_owned ( ) )
8892 . or_insert_with ( || toml:: Value :: Boolean ( DEFAULT_PUBLISH ) ) ;
93+ for field in AUTO_FIELDS {
94+ package
95+ . entry ( field. to_owned ( ) )
96+ . or_insert_with ( || toml:: Value :: Boolean ( false ) ) ;
97+ }
8998
9099 let mut bin = toml:: Table :: new ( ) ;
91100 bin. insert ( "name" . to_owned ( ) , toml:: Value :: String ( bin_name) ) ;
@@ -361,6 +370,10 @@ name = "test_a472c7a31645d310613df407eab80844346938a3b8fe4f392cae059cb181aa85"
361370path = "/home/me/test.rs"
362371
363372[package]
373+ autobenches = false
374+ autobins = false
375+ autoexamples = false
376+ autotests = false
364377edition = "2021"
365378name = "test"
366379publish = false
@@ -386,6 +399,10 @@ path = "/home/me/test.rs"
386399time = "0.1.25"
387400
388401[package]
402+ autobenches = false
403+ autobins = false
404+ autoexamples = false
405+ autotests = false
389406edition = "2021"
390407name = "test"
391408publish = false
0 commit comments