about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src
diff options
context:
space:
mode:
authorYotam Ofek <yotam.ofek@gmail.com>2025-03-16 15:54:04 +0000
committerYotam Ofek <yotam.ofek@gmail.com>2025-03-17 07:06:10 +0000
commita3e4dff1839e9ba70953b8a9ac8572a6cdb160b9 (patch)
tree3dc7f99626d04ec860bf3f67de0551d5f0fb2d96 /compiler/rustc_codegen_ssa/src
parent8b87fefd76665236a304d3c0998e1021710ce1b0 (diff)
Use `strip_{prefix|suffix}` instead of `{starts|ends}_with`+indexing
Diffstat (limited to 'compiler/rustc_codegen_ssa/src')
-rw-r--r--compiler/rustc_codegen_ssa/src/back/link.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs
index ea961f222db..535f94f6e69 100644
--- a/compiler/rustc_codegen_ssa/src/back/link.rs
+++ b/compiler/rustc_codegen_ssa/src/back/link.rs
@@ -1538,8 +1538,13 @@ fn print_native_static_libs(
         }
         let stem = path.file_stem().unwrap().to_str().unwrap();
         // Convert library file-stem into a cc -l argument.
-        let prefix = if stem.starts_with("lib") && !sess.target.is_like_windows { 3 } else { 0 };
-        let lib = &stem[prefix..];
+        let lib = if let Some(lib) = stem.strip_prefix("lib")
+            && !sess.target.is_like_windows
+        {
+            lib
+        } else {
+            stem
+        };
         let path = parent.unwrap_or_else(|| Path::new(""));
         if sess.target.is_like_msvc {
             // When producing a dll, the MSVC linker may not actually emit a