@@ -2575,7 +2575,7 @@ fn unused_dep_keys(
2575
2575
pub fn prepare_for_publish (
2576
2576
me : & Package ,
2577
2577
ws : & Workspace < ' _ > ,
2578
- included : & [ PathBuf ] ,
2578
+ included : Option < & [ PathBuf ] > ,
2579
2579
) -> CargoResult < Package > {
2580
2580
let contents = me. manifest ( ) . contents ( ) ;
2581
2581
let document = me. manifest ( ) . document ( ) ;
@@ -2612,7 +2612,7 @@ fn prepare_toml_for_publish(
2612
2612
me : & manifest:: TomlManifest ,
2613
2613
ws : & Workspace < ' _ > ,
2614
2614
package_root : & Path ,
2615
- included : & [ PathBuf ] ,
2615
+ included : Option < & [ PathBuf ] > ,
2616
2616
) -> CargoResult < manifest:: TomlManifest > {
2617
2617
let gctx = ws. gctx ( ) ;
2618
2618
@@ -2629,7 +2629,8 @@ fn prepare_toml_for_publish(
2629
2629
package. workspace = None ;
2630
2630
if let Some ( StringOrBool :: String ( path) ) = & package. build {
2631
2631
let path = paths:: normalize_path ( Path :: new ( path) ) ;
2632
- let build = if included. contains ( & path) {
2632
+ let included = included. map ( |i| i. contains ( & path) ) . unwrap_or ( true ) ;
2633
+ let build = if included {
2633
2634
let path = path
2634
2635
. into_os_string ( )
2635
2636
. into_string ( )
@@ -2898,7 +2899,7 @@ fn prepare_toml_for_publish(
2898
2899
2899
2900
fn prepare_targets_for_publish (
2900
2901
targets : Option < & Vec < manifest:: TomlTarget > > ,
2901
- included : & [ PathBuf ] ,
2902
+ included : Option < & [ PathBuf ] > ,
2902
2903
context : & str ,
2903
2904
gctx : & GlobalContext ,
2904
2905
) -> CargoResult < Option < Vec < manifest:: TomlTarget > > > {
@@ -2923,19 +2924,21 @@ fn prepare_targets_for_publish(
2923
2924
2924
2925
fn prepare_target_for_publish (
2925
2926
target : & manifest:: TomlTarget ,
2926
- included : & [ PathBuf ] ,
2927
+ included : Option < & [ PathBuf ] > ,
2927
2928
context : & str ,
2928
2929
gctx : & GlobalContext ,
2929
2930
) -> CargoResult < Option < manifest:: TomlTarget > > {
2930
2931
let path = target. path . as_ref ( ) . expect ( "previously resolved" ) ;
2931
2932
let path = normalize_path ( & path. 0 ) ;
2932
- if !included. contains ( & path) {
2933
- let name = target. name . as_ref ( ) . expect ( "previously resolved" ) ;
2934
- gctx. shell ( ) . warn ( format ! (
2935
- "ignoring {context} `{name}` as `{}` is not included in the published package" ,
2936
- path. display( )
2937
- ) ) ?;
2938
- return Ok ( None ) ;
2933
+ if let Some ( included) = included {
2934
+ if !included. contains ( & path) {
2935
+ let name = target. name . as_ref ( ) . expect ( "previously resolved" ) ;
2936
+ gctx. shell ( ) . warn ( format ! (
2937
+ "ignoring {context} `{name}` as `{}` is not included in the published package" ,
2938
+ path. display( )
2939
+ ) ) ?;
2940
+ return Ok ( None ) ;
2941
+ }
2939
2942
}
2940
2943
2941
2944
let mut target = target. clone ( ) ;
0 commit comments