@@ -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 ,
@@ -56,8 +57,11 @@ fn expand_manifest_(
5657 . or_insert_with ( || toml:: Table :: new ( ) . into ( ) )
5758 . as_table_mut ( )
5859 . 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) {
6165 anyhow:: bail!( "`package.{key}` is not allowed in embedded manifests" )
6266 }
6367 }
@@ -88,6 +92,11 @@ fn expand_manifest_(
8892 package
8993 . entry ( "publish" . to_owned ( ) )
9094 . 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+ }
91100
92101 let mut bin = toml:: Table :: new ( ) ;
93102 bin. insert ( "name" . to_owned ( ) , toml:: Value :: String ( bin_name) ) ;
@@ -355,6 +364,10 @@ name = "test"
355364path = "test.rs"
356365
357366[package]
367+ autobenches = false
368+ autobins = false
369+ autoexamples = false
370+ autotests = false
358371edition = "2021"
359372name = "test"
360373publish = false
@@ -380,6 +393,10 @@ path = "test.rs"
380393time = "0.1.25"
381394
382395[package]
396+ autobenches = false
397+ autobins = false
398+ autoexamples = false
399+ autotests = false
383400edition = "2021"
384401name = "test"
385402publish = false
0 commit comments