@@ -32,7 +32,13 @@ pub fn targets(
32
32
33
33
let has_lib;
34
34
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
+ ) ? {
36
42
targets. push ( target) ;
37
43
has_lib = true ;
38
44
} else {
@@ -105,6 +111,7 @@ fn clean_lib(
105
111
toml_lib : Option < & TomlLibTarget > ,
106
112
package_root : & Path ,
107
113
package_name : & str ,
114
+ edition : Edition ,
108
115
warnings : & mut Vec < String > ,
109
116
) -> CargoResult < Option < Target > > {
110
117
let inferred = inferred_lib ( package_root) ;
@@ -140,7 +147,7 @@ fn clean_lib(
140
147
( None , Some ( path) ) => path,
141
148
( None , None ) => {
142
149
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 ( ) {
144
151
warnings. push ( format ! (
145
152
"path `{}` was erroneously implicitly accepted for library `{}`,\n \
146
153
please rename the file to `src/lib.rs` or set lib.path in Cargo.toml",
@@ -237,7 +244,7 @@ fn clean_bins(
237
244
238
245
let mut result = Vec :: new ( ) ;
239
246
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 |_| {
241
248
if let Some ( legacy_path) = legacy_bin_path ( package_root, & bin. name ( ) , has_lib) {
242
249
warnings. push ( format ! (
243
250
"path `{}` was erroneously implicitly accepted for binary `{}`,\n \
@@ -469,7 +476,7 @@ fn clean_targets_with_legacy_path(
469
476
validate_unique_names ( & toml_targets, target_kind) ?;
470
477
let mut result = Vec :: new ( ) ;
471
478
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) ;
473
480
let path = match path {
474
481
Ok ( path) => path,
475
482
Err ( e) => {
@@ -695,6 +702,7 @@ fn target_path(
695
702
inferred : & [ ( String , PathBuf ) ] ,
696
703
target_kind : & str ,
697
704
package_root : & Path ,
705
+ edition : Edition ,
698
706
legacy_path : & mut FnMut ( & TomlTarget ) -> Option < PathBuf > ,
699
707
) -> Result < PathBuf , String > {
700
708
if let Some ( ref path) = target. path {
@@ -713,8 +721,10 @@ fn target_path(
713
721
match ( first, second) {
714
722
( Some ( path) , None ) => Ok ( path) ,
715
723
( 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
+ }
718
728
}
719
729
Err ( format ! (
720
730
"can't find `{name}` {target_kind}, specify {target_kind}.path" ,
0 commit comments