@@ -904,9 +904,14 @@ fn inner_dependency_inherit_with<'a>(
904
904
this could become a hard error in the future"
905
905
) )
906
906
}
907
- if dependency. default_features . is_some ( ) && dependency. default_features2 . is_some ( ) {
908
- warn_on_deprecated ( "default-features" , name, "dependency" , warnings) ;
909
- }
907
+ deprecated_underscore (
908
+ & dependency. default_features2 ,
909
+ & dependency. default_features ,
910
+ "default-features" ,
911
+ name,
912
+ "dependency" ,
913
+ warnings,
914
+ ) ;
910
915
inherit ( ) ?. get_dependency ( name, package_root) . map ( |d| {
911
916
match d {
912
917
manifest:: TomlDependency :: Simple ( s) => {
@@ -1157,18 +1162,28 @@ fn to_real_manifest(
1157
1162
}
1158
1163
1159
1164
validate_dependencies ( original_toml. dependencies . as_ref ( ) , None , None , warnings) ?;
1160
- if original_toml. dev_dependencies . is_some ( ) && original_toml. dev_dependencies2 . is_some ( ) {
1161
- warn_on_deprecated ( "dev-dependencies" , package_name, "package" , warnings) ;
1162
- }
1165
+ deprecated_underscore (
1166
+ & original_toml. dev_dependencies2 ,
1167
+ & original_toml. dev_dependencies ,
1168
+ "dev-dependencies" ,
1169
+ package_name,
1170
+ "package" ,
1171
+ warnings,
1172
+ ) ;
1163
1173
validate_dependencies (
1164
1174
original_toml. dev_dependencies ( ) ,
1165
1175
None ,
1166
1176
Some ( DepKind :: Development ) ,
1167
1177
warnings,
1168
1178
) ?;
1169
- if original_toml. build_dependencies . is_some ( ) && original_toml. build_dependencies2 . is_some ( ) {
1170
- warn_on_deprecated ( "build-dependencies" , package_name, "package" , warnings) ;
1171
- }
1179
+ deprecated_underscore (
1180
+ & original_toml. build_dependencies2 ,
1181
+ & original_toml. build_dependencies ,
1182
+ "build-dependencies" ,
1183
+ package_name,
1184
+ "package" ,
1185
+ warnings,
1186
+ ) ;
1172
1187
validate_dependencies (
1173
1188
original_toml. build_dependencies ( ) ,
1174
1189
None ,
@@ -1185,18 +1200,28 @@ fn to_real_manifest(
1185
1200
None ,
1186
1201
warnings,
1187
1202
) ?;
1188
- if platform. build_dependencies . is_some ( ) && platform. build_dependencies2 . is_some ( ) {
1189
- warn_on_deprecated ( "build-dependencies" , name, "platform target" , warnings) ;
1190
- }
1203
+ deprecated_underscore (
1204
+ & platform. build_dependencies2 ,
1205
+ & platform. build_dependencies ,
1206
+ "build-dependencies" ,
1207
+ name,
1208
+ "platform target" ,
1209
+ warnings,
1210
+ ) ;
1191
1211
validate_dependencies (
1192
1212
platform. build_dependencies ( ) ,
1193
1213
platform_kind. as_ref ( ) ,
1194
1214
Some ( DepKind :: Build ) ,
1195
1215
warnings,
1196
1216
) ?;
1197
- if platform. dev_dependencies . is_some ( ) && platform. dev_dependencies2 . is_some ( ) {
1198
- warn_on_deprecated ( "dev-dependencies" , name, "platform target" , warnings) ;
1199
- }
1217
+ deprecated_underscore (
1218
+ & platform. dev_dependencies2 ,
1219
+ & platform. dev_dependencies ,
1220
+ "dev-dependencies" ,
1221
+ name,
1222
+ "platform target" ,
1223
+ warnings,
1224
+ ) ;
1200
1225
validate_dependencies (
1201
1226
platform. dev_dependencies ( ) ,
1202
1227
platform_kind. as_ref ( ) ,
@@ -1885,14 +1910,14 @@ fn detailed_dep_to_dependency<P: ResolveToPath + Clone>(
1885
1910
1886
1911
let version = orig. version . as_deref ( ) ;
1887
1912
let mut dep = Dependency :: parse ( pkg_name, version, new_source_id) ?;
1888
- if orig . default_features . is_some ( ) && orig . default_features2 . is_some ( ) {
1889
- warn_on_deprecated (
1890
- "default-features" ,
1891
- name_in_toml ,
1892
- "dependency" ,
1893
- manifest_ctx . warnings ,
1894
- ) ;
1895
- }
1913
+ deprecated_underscore (
1914
+ & orig . default_features2 ,
1915
+ & orig . default_features ,
1916
+ "default-features" ,
1917
+ name_in_toml ,
1918
+ "dependency" ,
1919
+ manifest_ctx . warnings ,
1920
+ ) ;
1896
1921
dep. set_features ( orig. features . iter ( ) . flatten ( ) )
1897
1922
. set_default_features ( orig. default_features ( ) . unwrap_or ( true ) )
1898
1923
. set_optional ( orig. optional . unwrap_or ( false ) )
@@ -2304,12 +2329,25 @@ fn emit_diagnostic(
2304
2329
}
2305
2330
2306
2331
/// Warn about paths that have been deprecated and may conflict.
2307
- fn warn_on_deprecated ( new_path : & str , name : & str , kind : & str , warnings : & mut Vec < String > ) {
2308
- let old_path = new_path. replace ( "-" , "_" ) ;
2309
- warnings. push ( format ! (
2310
- "conflicting between `{new_path}` and `{old_path}` in the `{name}` {kind}.\n
2311
- `{old_path}` is ignored and not recommended for use in the future"
2312
- ) )
2332
+ fn deprecated_underscore < T > (
2333
+ old : & Option < T > ,
2334
+ new : & Option < T > ,
2335
+ new_path : & str ,
2336
+ name : & str ,
2337
+ kind : & str ,
2338
+ warnings : & mut Vec < String > ,
2339
+ ) {
2340
+ if old. is_some ( ) && new. is_some ( ) {
2341
+ let old_path = new_path. replace ( "-" , "_" ) ;
2342
+ warnings. push ( format ! (
2343
+ "unused manifest key `{old_path}` in the `{name}` {kind}"
2344
+ ) )
2345
+ } else if old. is_some ( ) {
2346
+ let old_path = new_path. replace ( "-" , "_" ) ;
2347
+ warnings. push ( format ! (
2348
+ "`{old_path}` is deprecated in favor of `{new_path}` and will not work in the 2024 edition\n (in the `{name}` {kind})"
2349
+ ) )
2350
+ }
2313
2351
}
2314
2352
2315
2353
fn warn_on_unused ( unused : & BTreeSet < String > , warnings : & mut Vec < String > ) {
0 commit comments