@@ -180,6 +180,15 @@ pub fn parse_document(
180
180
. map_err ( |e| anyhow:: Error :: from ( e) . context ( "could not parse input as TOML" ) )
181
181
}
182
182
183
+ /// Warn about paths that have been deprecated and may conflict.
184
+ fn warn_on_deprecated ( new_path : & str , name : & str , kind : & str , warnings : & mut Vec < String > ) {
185
+ let old_path = new_path. replace ( "-" , "_" ) ;
186
+ warnings. push ( format ! (
187
+ "conflicting between `{new_path}` and `{old_path}` in the `{name}` {kind}.\n
188
+ `{old_path}` is ignored and not recommended for use in the future"
189
+ ) )
190
+ }
191
+
183
192
type TomlLibTarget = TomlTarget ;
184
193
type TomlBinTarget = TomlTarget ;
185
194
type TomlExampleTarget = TomlTarget ;
@@ -1265,23 +1274,15 @@ impl TomlManifest {
1265
1274
// Collect the dependencies.
1266
1275
process_dependencies ( & mut cx, me. dependencies . as_ref ( ) , None ) ?;
1267
1276
if me. dev_dependencies . is_some ( ) && me. dev_dependencies2 . is_some ( ) {
1268
- cx. warnings . push ( format ! (
1269
- "found both `dev-dependencies` and `dev_dependencies` are set \
1270
- in the `{}` package",
1271
- package_name
1272
- ) ) ;
1277
+ warn_on_deprecated ( "dev-dependencies" , package_name, "package" , cx. warnings ) ;
1273
1278
}
1274
1279
let dev_deps = me
1275
1280
. dev_dependencies
1276
1281
. as_ref ( )
1277
1282
. or_else ( || me. dev_dependencies2 . as_ref ( ) ) ;
1278
1283
process_dependencies ( & mut cx, dev_deps, Some ( DepKind :: Development ) ) ?;
1279
1284
if me. build_dependencies . is_some ( ) && me. build_dependencies2 . is_some ( ) {
1280
- cx. warnings . push ( format ! (
1281
- "found both `build-dependencies` and `build_dependencies` are set \
1282
- in the `{}` package",
1283
- package_name
1284
- ) ) ;
1285
+ warn_on_deprecated ( "build-dependencies" , package_name, "package" , cx. warnings ) ;
1285
1286
}
1286
1287
let build_deps = me
1287
1288
. build_dependencies
@@ -1297,23 +1298,15 @@ impl TomlManifest {
1297
1298
} ;
1298
1299
process_dependencies ( & mut cx, platform. dependencies . as_ref ( ) , None ) ?;
1299
1300
if platform. build_dependencies . is_some ( ) && platform. build_dependencies2 . is_some ( ) {
1300
- cx. warnings . push ( format ! (
1301
- "found both `build-dependencies` and `build_dependencies` are set \
1302
- in the `{}` platform target",
1303
- name
1304
- ) ) ;
1301
+ warn_on_deprecated ( "build-dependencies" , name, "platform target" , cx. warnings ) ;
1305
1302
}
1306
1303
let build_deps = platform
1307
1304
. build_dependencies
1308
1305
. as_ref ( )
1309
1306
. or_else ( || platform. build_dependencies2 . as_ref ( ) ) ;
1310
1307
process_dependencies ( & mut cx, build_deps, Some ( DepKind :: Build ) ) ?;
1311
1308
if platform. dev_dependencies . is_some ( ) && platform. dev_dependencies2 . is_some ( ) {
1312
- cx. warnings . push ( format ! (
1313
- "found both `dev-dependencies` and `dev_dependencies` are set \
1314
- in the `{}` platform target",
1315
- name
1316
- ) ) ;
1309
+ warn_on_deprecated ( "dev-dependencies" , name, "platform target" , cx. warnings ) ;
1317
1310
}
1318
1311
let dev_deps = platform
1319
1312
. dev_dependencies
@@ -1937,11 +1930,7 @@ impl<P: ResolveToPath> DetailedTomlDependency<P> {
1937
1930
let version = self . version . as_deref ( ) ;
1938
1931
let mut dep = Dependency :: parse ( pkg_name, version, new_source_id) ?;
1939
1932
if self . default_features . is_some ( ) && self . default_features2 . is_some ( ) {
1940
- cx. warnings . push ( format ! (
1941
- "found both `default-features` and `default_features` are set \
1942
- in the `{}` dependency",
1943
- name_in_toml
1944
- ) ) ;
1933
+ warn_on_deprecated ( "default-features" , name_in_toml, "dependency" , cx. warnings ) ;
1945
1934
}
1946
1935
dep. set_features ( self . features . iter ( ) . flatten ( ) )
1947
1936
. set_default_features (
@@ -2094,11 +2083,12 @@ impl TomlTarget {
2094
2083
2095
2084
fn validate_proc_macro ( & self , warnings : & mut Vec < String > ) {
2096
2085
if self . proc_macro_raw . is_some ( ) && self . proc_macro_raw2 . is_some ( ) {
2097
- warnings. push ( format ! (
2098
- "found both `proc-macro` and `proc_macro` are set \
2099
- in the `{}` library target",
2100
- self . name( )
2101
- ) ) ;
2086
+ warn_on_deprecated (
2087
+ "proc-macro" ,
2088
+ self . name ( ) . as_str ( ) ,
2089
+ "library target" ,
2090
+ warnings,
2091
+ ) ;
2102
2092
}
2103
2093
}
2104
2094
@@ -2115,12 +2105,12 @@ impl TomlTarget {
2115
2105
2116
2106
fn validate_crate_types ( & self , target_kind_human : & str , warnings : & mut Vec < String > ) {
2117
2107
if self . crate_type . is_some ( ) && self . crate_type2 . is_some ( ) {
2118
- warnings . push ( format ! (
2119
- "found both ` crate-type` and `crate_type` are set \
2120
- in the `{}` {} target" ,
2121
- self . name ( ) ,
2122
- target_kind_human
2123
- ) ) ;
2108
+ warn_on_deprecated (
2109
+ "crate-type" ,
2110
+ self . name ( ) . as_str ( ) ,
2111
+ format ! ( "{target_kind_human} target" ) . as_str ( ) ,
2112
+ warnings ,
2113
+ ) ;
2124
2114
}
2125
2115
}
2126
2116
0 commit comments