@@ -23,6 +23,7 @@ use crate::core::compiler::CrateType;
2323use crate :: core:: { Edition , Feature , Features , Target } ;
2424use crate :: util:: errors:: CargoResult ;
2525use crate :: util:: restricted_names;
26+ use crate :: util:: toml:: warn_on_deprecated;
2627
2728use anyhow:: Context as _;
2829
@@ -172,8 +173,8 @@ fn clean_lib(
172173 } ;
173174
174175 let Some ( ref lib) = lib else { return Ok ( None ) } ;
175- lib . validate_proc_macro ( warnings) ;
176- lib . validate_crate_types ( "library" , warnings) ;
176+ validate_proc_macro ( lib , "library" , warnings) ;
177+ validate_crate_types ( lib , "library" , warnings) ;
177178
178179 validate_target_name ( lib, "library" , "lib" , warnings) ?;
179180
@@ -398,7 +399,7 @@ fn clean_examples(
398399
399400 let mut result = Vec :: new ( ) ;
400401 for ( path, toml) in targets {
401- toml . validate_crate_types ( "example" , warnings) ;
402+ validate_crate_types ( & toml , "example" , warnings) ;
402403 let crate_types = match toml. crate_types ( ) {
403404 Some ( kinds) => kinds. iter ( ) . map ( |s| s. into ( ) ) . collect ( ) ,
404405 None => Vec :: new ( ) ,
@@ -984,3 +985,25 @@ fn maybe_custom_build(build: &Option<StringOrBool>, package_root: &Path) -> Opti
984985 }
985986 }
986987}
988+
989+ fn validate_proc_macro ( target : & TomlTarget , kind : & str , warnings : & mut Vec < String > ) {
990+ if target. proc_macro_raw . is_some ( ) && target. proc_macro_raw2 . is_some ( ) {
991+ warn_on_deprecated (
992+ "proc-macro" ,
993+ target. name ( ) . as_str ( ) ,
994+ format ! ( "{kind} target" ) . as_str ( ) ,
995+ warnings,
996+ ) ;
997+ }
998+ }
999+
1000+ fn validate_crate_types ( target : & TomlTarget , kind : & str , warnings : & mut Vec < String > ) {
1001+ if target. crate_type . is_some ( ) && target. crate_type2 . is_some ( ) {
1002+ warn_on_deprecated (
1003+ "crate-type" ,
1004+ target. name ( ) . as_str ( ) ,
1005+ format ! ( "{kind} target" ) . as_str ( ) ,
1006+ warnings,
1007+ ) ;
1008+ }
1009+ }
0 commit comments