@@ -709,48 +709,39 @@ impl<'a> CrateLocator<'a> {
709
709
let mut rmetas = FxIndexMap :: default ( ) ;
710
710
let mut dylibs = FxIndexMap :: default ( ) ;
711
711
for loc in & self . exact_paths {
712
- if !loc. canonicalized ( ) . exists ( ) {
713
- return Err ( CrateError :: ExternLocationNotExist (
714
- self . crate_name ,
715
- loc. original ( ) . clone ( ) ,
716
- ) ) ;
712
+ let loc_canon = loc. canonicalized ( ) ;
713
+ let loc_orig = loc. original ( ) ;
714
+ if !loc_canon. exists ( ) {
715
+ return Err ( CrateError :: ExternLocationNotExist ( self . crate_name , loc_orig. clone ( ) ) ) ;
717
716
}
718
- if !loc. original ( ) . is_file ( ) {
719
- return Err ( CrateError :: ExternLocationNotFile (
720
- self . crate_name ,
721
- loc. original ( ) . clone ( ) ,
722
- ) ) ;
717
+ if !loc_orig. is_file ( ) {
718
+ return Err ( CrateError :: ExternLocationNotFile ( self . crate_name , loc_orig. clone ( ) ) ) ;
723
719
}
724
- let Some ( file) = loc. original ( ) . file_name ( ) . and_then ( |s| s. to_str ( ) ) else {
725
- return Err ( CrateError :: ExternLocationNotFile (
726
- self . crate_name ,
727
- loc. original ( ) . clone ( ) ,
728
- ) ) ;
720
+ // Note to take care and match against the non-canonicalized name:
721
+ // some systems save build artifacts into content-addressed stores
722
+ // that do not preserve extensions, and then link to them using
723
+ // e.g. symbolic links. If we canonicalize too early, we resolve
724
+ // the symlink, the file type is lost and we might treat rlibs and
725
+ // rmetas as dylibs.
726
+ let Some ( file) = loc_orig. file_name ( ) . and_then ( |s| s. to_str ( ) ) else {
727
+ return Err ( CrateError :: ExternLocationNotFile ( self . crate_name , loc_orig. clone ( ) ) ) ;
729
728
} ;
730
-
731
729
if file. starts_with ( "lib" ) && ( file. ends_with ( ".rlib" ) || file. ends_with ( ".rmeta" ) )
732
730
|| file. starts_with ( self . target . dll_prefix . as_ref ( ) )
733
731
&& file. ends_with ( self . target . dll_suffix . as_ref ( ) )
734
732
{
735
- // Note to take care and match against the non-canonicalized name:
736
- // some systems save build artifacts into content-addressed stores
737
- // that do not preserve extensions, and then link to them using
738
- // e.g. symbolic links. If we canonicalize too early, we resolve
739
- // the symlink, the file type is lost and we might treat rlibs and
740
- // rmetas as dylibs.
741
- let loc_canon = loc. canonicalized ( ) . clone ( ) ;
742
- let loc = loc. original ( ) ;
743
- if loc. file_name ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) . ends_with ( ".rlib" ) {
733
+ let loc_canon = loc_canon. clone ( ) ;
734
+ if file. ends_with ( ".rlib" ) {
744
735
rlibs. insert ( loc_canon, PathKind :: ExternFlag ) ;
745
- } else if loc . file_name ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) . ends_with ( ".rmeta" ) {
736
+ } else if file . ends_with ( ".rmeta" ) {
746
737
rmetas. insert ( loc_canon, PathKind :: ExternFlag ) ;
747
738
} else {
748
739
dylibs. insert ( loc_canon, PathKind :: ExternFlag ) ;
749
740
}
750
741
} else {
751
742
self . crate_rejections
752
743
. via_filename
753
- . push ( CrateMismatch { path : loc . original ( ) . clone ( ) , got : String :: new ( ) } ) ;
744
+ . push ( CrateMismatch { path : loc_orig . clone ( ) , got : String :: new ( ) } ) ;
754
745
}
755
746
}
756
747
0 commit comments