@@ -32,7 +32,13 @@ pub fn targets(
3232
3333 let has_lib;
3434
35- if let Some ( target) = clean_lib ( manifest. lib . as_ref ( ) , package_root, package_name, warnings) ? {
35+ if let Some ( target) = clean_lib (
36+ manifest. lib . as_ref ( ) ,
37+ package_root,
38+ package_name,
39+ edition,
40+ warnings,
41+ ) ? {
3642 targets. push ( target) ;
3743 has_lib = true ;
3844 } else {
@@ -105,6 +111,7 @@ fn clean_lib(
105111 toml_lib : Option < & TomlLibTarget > ,
106112 package_root : & Path ,
107113 package_name : & str ,
114+ edition : Edition ,
108115 warnings : & mut Vec < String > ,
109116) -> CargoResult < Option < Target > > {
110117 let inferred = inferred_lib ( package_root) ;
@@ -140,7 +147,7 @@ fn clean_lib(
140147 ( None , Some ( path) ) => path,
141148 ( None , None ) => {
142149 let legacy_path = package_root. join ( "src" ) . join ( format ! ( "{}.rs" , lib. name( ) ) ) ;
143- if legacy_path. exists ( ) {
150+ if edition < Edition :: Edition2018 && legacy_path. exists ( ) {
144151 warnings. push ( format ! (
145152 "path `{}` was erroneously implicitly accepted for library `{}`,\n \
146153 please rename the file to `src/lib.rs` or set lib.path in Cargo.toml",
@@ -237,7 +244,7 @@ fn clean_bins(
237244
238245 let mut result = Vec :: new ( ) ;
239246 for bin in & bins {
240- let path = target_path ( bin, & inferred, "bin" , package_root, & mut |_| {
247+ let path = target_path ( bin, & inferred, "bin" , package_root, edition , & mut |_| {
241248 if let Some ( legacy_path) = legacy_bin_path ( package_root, & bin. name ( ) , has_lib) {
242249 warnings. push ( format ! (
243250 "path `{}` was erroneously implicitly accepted for binary `{}`,\n \
@@ -469,7 +476,7 @@ fn clean_targets_with_legacy_path(
469476 validate_unique_names ( & toml_targets, target_kind) ?;
470477 let mut result = Vec :: new ( ) ;
471478 for target in toml_targets {
472- let path = target_path ( & target, inferred, target_kind, package_root, legacy_path) ;
479+ let path = target_path ( & target, inferred, target_kind, package_root, edition , legacy_path) ;
473480 let path = match path {
474481 Ok ( path) => path,
475482 Err ( e) => {
@@ -695,6 +702,7 @@ fn target_path(
695702 inferred : & [ ( String , PathBuf ) ] ,
696703 target_kind : & str ,
697704 package_root : & Path ,
705+ edition : Edition ,
698706 legacy_path : & mut FnMut ( & TomlTarget ) -> Option < PathBuf > ,
699707) -> Result < PathBuf , String > {
700708 if let Some ( ref path) = target. path {
@@ -713,8 +721,10 @@ fn target_path(
713721 match ( first, second) {
714722 ( Some ( path) , None ) => Ok ( path) ,
715723 ( None , None ) | ( Some ( _) , Some ( _) ) => {
716- if let Some ( path) = legacy_path ( target) {
717- return Ok ( path) ;
724+ if edition < Edition :: Edition2018 {
725+ if let Some ( path) = legacy_path ( target) {
726+ return Ok ( path) ;
727+ }
718728 }
719729 Err ( format ! (
720730 "can't find `{name}` {target_kind}, specify {target_kind}.path" ,
0 commit comments