@@ -1014,9 +1014,33 @@ enum ExtractRootCargoTomlError {
10141014fn adapt_cargo_toml_to_index_entry (
10151015 global : & Global ,
10161016 config : & ConfigV1 ,
1017- cargo_toml : cargo_toml:: Root ,
1017+ mut cargo_toml : cargo_toml:: Root ,
10181018 checksum_hex : String ,
10191019) -> index_entry:: Root {
1020+ // Remove features that refer to dev-dependencies as we don't
1021+ // track those anyway.
1022+ {
1023+ // Ignore dependencies that also occur as a regular or build
1024+ // dependency, as we *do* track those.
1025+ let reg_dep_names = cargo_toml. dependencies . keys ( ) ;
1026+ let build_dep_names = cargo_toml. build_dependencies . keys ( ) ;
1027+ let mut only_dev_dep_names = cargo_toml. dev_dependencies . keys ( ) . collect :: < BTreeSet < _ > > ( ) ;
1028+ for name in reg_dep_names. chain ( build_dep_names) {
1029+ only_dev_dep_names. remove ( name) ;
1030+ }
1031+
1032+ for name in only_dev_dep_names {
1033+ // We don't care about the official package name here as the
1034+ // feature syntax has to match the user-specified dependency
1035+ // name.
1036+ let prefix = format ! ( "{name}/" ) ;
1037+
1038+ for enabled in cargo_toml. features . values_mut ( ) {
1039+ enabled. retain ( |enable| !enable. starts_with ( & prefix) ) ;
1040+ }
1041+ }
1042+ }
1043+
10201044 let mut deps: Vec < _ > = cargo_toml
10211045 . dependencies
10221046 . into_iter ( )
@@ -1126,6 +1150,9 @@ mod cargo_toml {
11261150 #[ serde( default ) ]
11271151 pub build_dependencies : Dependencies ,
11281152
1153+ #[ serde( default ) ]
1154+ pub dev_dependencies : Dependencies ,
1155+
11291156 #[ serde( default ) ]
11301157 pub target : BTreeMap < String , Target > ,
11311158 }
0 commit comments