File tree 1 file changed +12
-6
lines changed
compiler/rustc_metadata/src
1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -414,12 +414,18 @@ impl<'a> CrateLocator<'a> {
414
414
debug ! ( "testing {}" , spf. path. display( ) ) ;
415
415
416
416
let f = & spf. file_name_str ;
417
- let ( hash, kind) = if f. starts_with ( rlib_prefix) && f. ends_with ( rlib_suffix) {
418
- ( & f[ rlib_prefix. len ( ) ..( f. len ( ) - rlib_suffix. len ( ) ) ] , CrateFlavor :: Rlib )
419
- } else if f. starts_with ( rmeta_prefix) && f. ends_with ( rmeta_suffix) {
420
- ( & f[ rmeta_prefix. len ( ) ..( f. len ( ) - rmeta_suffix. len ( ) ) ] , CrateFlavor :: Rmeta )
421
- } else if f. starts_with ( dylib_prefix) && f. ends_with ( dylib_suffix. as_ref ( ) ) {
422
- ( & f[ dylib_prefix. len ( ) ..( f. len ( ) - dylib_suffix. len ( ) ) ] , CrateFlavor :: Dylib )
417
+ let ( hash, kind) = if let Some ( f) = f. strip_prefix ( rlib_prefix)
418
+ && let Some ( f) = f. strip_suffix ( rlib_suffix)
419
+ {
420
+ ( f, CrateFlavor :: Rlib )
421
+ } else if let Some ( f) = f. strip_prefix ( rmeta_prefix)
422
+ && let Some ( f) = f. strip_suffix ( rmeta_suffix)
423
+ {
424
+ ( f, CrateFlavor :: Rmeta )
425
+ } else if let Some ( f) = f. strip_prefix ( dylib_prefix)
426
+ && let Some ( f) = f. strip_suffix ( dylib_suffix. as_ref ( ) )
427
+ {
428
+ ( f, CrateFlavor :: Dylib )
423
429
} else {
424
430
if f. starts_with ( staticlib_prefix) && f. ends_with ( staticlib_suffix. as_ref ( ) ) {
425
431
self . crate_rejections . via_kind . push ( CrateMismatch {
You can’t perform that action at this time.
0 commit comments