@@ -721,28 +721,33 @@ impl<'a> CrateLocator<'a> {
721
721
return Err ( CrateError :: ExternLocationNotFile ( self . crate_name , loc. clone ( ) ) ) ;
722
722
} ;
723
723
724
- if file. starts_with ( "lib" ) && ( file. ends_with ( ".rlib" ) || file. ends_with ( ".rmeta" ) )
725
- || file. starts_with ( self . target . dll_prefix . as_ref ( ) )
726
- && file. ends_with ( self . target . dll_suffix . as_ref ( ) )
727
- {
724
+ match file. starts_with ( "lib" ) . then_some ( ( ) ) . and_then ( |( ) | {
728
725
// Note to take care and match against the non-canonicalized name:
729
726
// some systems save build artifacts into content-addressed stores
730
727
// that do not preserve extensions, and then link to them using
731
728
// e.g. symbolic links. If we canonicalize too early, we resolve
732
729
// the symlink, the file type is lost and we might treat rlibs and
733
730
// rmetas as dylibs.
734
- let loc_canon = loc_canon. clone ( ) ;
731
+ let dll_prefix = self . target . dll_prefix . as_ref ( ) ;
732
+ let dll_suffix = self . target . dll_suffix . as_ref ( ) ;
735
733
if file. ends_with ( ".rlib" ) {
736
- rlibs . insert ( loc_canon , PathKind :: ExternFlag ) ;
734
+ Some ( & mut rlibs )
737
735
} else if file. ends_with ( ".rmeta" ) {
738
- rmetas. insert ( loc_canon, PathKind :: ExternFlag ) ;
736
+ Some ( & mut rmetas)
737
+ } else if file. starts_with ( dll_prefix) && file. ends_with ( dll_suffix) {
738
+ Some ( & mut dylibs)
739
739
} else {
740
- dylibs. insert ( loc_canon, PathKind :: ExternFlag ) ;
740
+ None
741
+ }
742
+ } ) {
743
+ Some ( dst) => {
744
+ dst. insert ( loc_canon. clone ( ) , PathKind :: ExternFlag ) ;
745
+ }
746
+ None => {
747
+ self . crate_rejections
748
+ . via_filename
749
+ . push ( CrateMismatch { path : loc. clone ( ) , got : String :: new ( ) } ) ;
741
750
}
742
- } else {
743
- self . crate_rejections
744
- . via_filename
745
- . push ( CrateMismatch { path : loc. clone ( ) , got : String :: new ( ) } ) ;
746
751
}
747
752
}
748
753
0 commit comments