@@ -2554,7 +2554,7 @@ fn unused_dep_keys(
2554
2554
pub fn prepare_for_publish (
2555
2555
me : & Package ,
2556
2556
ws : & Workspace < ' _ > ,
2557
- included : & [ PathBuf ] ,
2557
+ included : Option < & [ PathBuf ] > ,
2558
2558
) -> CargoResult < Package > {
2559
2559
let contents = me. manifest ( ) . contents ( ) ;
2560
2560
let document = me. manifest ( ) . document ( ) ;
@@ -2591,7 +2591,7 @@ fn prepare_toml_for_publish(
2591
2591
me : & manifest:: TomlManifest ,
2592
2592
ws : & Workspace < ' _ > ,
2593
2593
package_root : & Path ,
2594
- included : & [ PathBuf ] ,
2594
+ included : Option < & [ PathBuf ] > ,
2595
2595
) -> CargoResult < manifest:: TomlManifest > {
2596
2596
let gctx = ws. gctx ( ) ;
2597
2597
@@ -2608,7 +2608,8 @@ fn prepare_toml_for_publish(
2608
2608
package. workspace = None ;
2609
2609
if let Some ( StringOrBool :: String ( path) ) = & package. build {
2610
2610
let path = paths:: normalize_path ( Path :: new ( path) ) ;
2611
- let build = if included. contains ( & path) {
2611
+ let included = included. map ( |i| i. contains ( & path) ) . unwrap_or ( true ) ;
2612
+ let build = if included {
2612
2613
let path = path
2613
2614
. into_os_string ( )
2614
2615
. into_string ( )
@@ -2877,7 +2878,7 @@ fn prepare_toml_for_publish(
2877
2878
2878
2879
fn prepare_targets_for_publish (
2879
2880
targets : Option < & Vec < manifest:: TomlTarget > > ,
2880
- included : & [ PathBuf ] ,
2881
+ included : Option < & [ PathBuf ] > ,
2881
2882
context : & str ,
2882
2883
gctx : & GlobalContext ,
2883
2884
) -> CargoResult < Option < Vec < manifest:: TomlTarget > > > {
@@ -2902,19 +2903,21 @@ fn prepare_targets_for_publish(
2902
2903
2903
2904
fn prepare_target_for_publish (
2904
2905
target : & manifest:: TomlTarget ,
2905
- included : & [ PathBuf ] ,
2906
+ included : Option < & [ PathBuf ] > ,
2906
2907
context : & str ,
2907
2908
gctx : & GlobalContext ,
2908
2909
) -> CargoResult < Option < manifest:: TomlTarget > > {
2909
2910
let path = target. path . as_ref ( ) . expect ( "previously resolved" ) ;
2910
2911
let path = normalize_path ( & path. 0 ) ;
2911
- if !included. contains ( & path) {
2912
- let name = target. name . as_ref ( ) . expect ( "previously resolved" ) ;
2913
- gctx. shell ( ) . warn ( format ! (
2914
- "ignoring {context} `{name}` as `{}` is not included in the published package" ,
2915
- path. display( )
2916
- ) ) ?;
2917
- return Ok ( None ) ;
2912
+ if let Some ( included) = included {
2913
+ if !included. contains ( & path) {
2914
+ let name = target. name . as_ref ( ) . expect ( "previously resolved" ) ;
2915
+ gctx. shell ( ) . warn ( format ! (
2916
+ "ignoring {context} `{name}` as `{}` is not included in the published package" ,
2917
+ path. display( )
2918
+ ) ) ?;
2919
+ return Ok ( None ) ;
2920
+ }
2918
2921
}
2919
2922
2920
2923
let mut target = target. clone ( ) ;
0 commit comments