@@ -180,6 +180,15 @@ pub fn parse_document(
180180 . map_err ( |e| anyhow:: Error :: from ( e) . context ( "could not parse input as TOML" ) )
181181}
182182
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+
183192type TomlLibTarget = TomlTarget ;
184193type TomlBinTarget = TomlTarget ;
185194type TomlExampleTarget = TomlTarget ;
@@ -1265,23 +1274,15 @@ impl TomlManifest {
12651274 // Collect the dependencies.
12661275 process_dependencies ( & mut cx, me. dependencies . as_ref ( ) , None ) ?;
12671276 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 ) ;
12731278 }
12741279 let dev_deps = me
12751280 . dev_dependencies
12761281 . as_ref ( )
12771282 . or_else ( || me. dev_dependencies2 . as_ref ( ) ) ;
12781283 process_dependencies ( & mut cx, dev_deps, Some ( DepKind :: Development ) ) ?;
12791284 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 ) ;
12851286 }
12861287 let build_deps = me
12871288 . build_dependencies
@@ -1297,23 +1298,15 @@ impl TomlManifest {
12971298 } ;
12981299 process_dependencies ( & mut cx, platform. dependencies . as_ref ( ) , None ) ?;
12991300 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 ) ;
13051302 }
13061303 let build_deps = platform
13071304 . build_dependencies
13081305 . as_ref ( )
13091306 . or_else ( || platform. build_dependencies2 . as_ref ( ) ) ;
13101307 process_dependencies ( & mut cx, build_deps, Some ( DepKind :: Build ) ) ?;
13111308 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 ) ;
13171310 }
13181311 let dev_deps = platform
13191312 . dev_dependencies
@@ -1937,11 +1930,7 @@ impl<P: ResolveToPath> DetailedTomlDependency<P> {
19371930 let version = self . version . as_deref ( ) ;
19381931 let mut dep = Dependency :: parse ( pkg_name, version, new_source_id) ?;
19391932 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 ) ;
19451934 }
19461935 dep. set_features ( self . features . iter ( ) . flatten ( ) )
19471936 . set_default_features (
@@ -2094,11 +2083,12 @@ impl TomlTarget {
20942083
20952084 fn validate_proc_macro ( & self , warnings : & mut Vec < String > ) {
20962085 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+ ) ;
21022092 }
21032093 }
21042094
@@ -2115,12 +2105,12 @@ impl TomlTarget {
21152105
21162106 fn validate_crate_types ( & self , target_kind_human : & str , warnings : & mut Vec < String > ) {
21172107 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+ ) ;
21242114 }
21252115 }
21262116
0 commit comments