@@ -709,23 +709,16 @@ 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 = loc. original ( ) ;
714
+ if !loc_canon. exists ( ) {
715
+ return Err ( CrateError :: ExternLocationNotExist ( self . crate_name , loc. 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. is_file ( ) {
718
+ return Err ( CrateError :: ExternLocationNotFile ( self . crate_name , loc. 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
+ let Some ( file) = loc. file_name ( ) . and_then ( |s| s. to_str ( ) ) else {
721
+ return Err ( CrateError :: ExternLocationNotFile ( self . crate_name , loc. clone ( ) ) ) ;
729
722
} ;
730
723
731
724
if file. starts_with ( "lib" ) && ( file. ends_with ( ".rlib" ) || file. ends_with ( ".rmeta" ) )
@@ -738,19 +731,18 @@ impl<'a> CrateLocator<'a> {
738
731
// e.g. symbolic links. If we canonicalize too early, we resolve
739
732
// the symlink, the file type is lost and we might treat rlibs and
740
733
// 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" ) {
734
+ let loc_canon = loc_canon. clone ( ) ;
735
+ if file. ends_with ( ".rlib" ) {
744
736
rlibs. insert ( loc_canon, PathKind :: ExternFlag ) ;
745
- } else if loc . file_name ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) . ends_with ( ".rmeta" ) {
737
+ } else if file . ends_with ( ".rmeta" ) {
746
738
rmetas. insert ( loc_canon, PathKind :: ExternFlag ) ;
747
739
} else {
748
740
dylibs. insert ( loc_canon, PathKind :: ExternFlag ) ;
749
741
}
750
742
} else {
751
743
self . crate_rejections
752
744
. via_filename
753
- . push ( CrateMismatch { path : loc. original ( ) . clone ( ) , got : String :: new ( ) } ) ;
745
+ . push ( CrateMismatch { path : loc. clone ( ) , got : String :: new ( ) } ) ;
754
746
}
755
747
}
756
748
0 commit comments