diff options
| author | bors <bors@rust-lang.org> | 2025-03-17 07:34:25 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-03-17 07:34:25 +0000 |
| commit | 9bad8ac498985707f29b0bdc0293cc0457a3ab38 (patch) | |
| tree | 0f84864da4d1e6238839a4efb78c6cc327262acc /compiler/rustc_codegen_ssa/src | |
| parent | 10bcdad7df0de3cfb95c7bdb7b16908e73cafc09 (diff) | |
| parent | a3e4dff1839e9ba70953b8a9ac8572a6cdb160b9 (diff) | |
Auto merge of #138566 - yotamofek:pr/strip-prefix, r=nnethercote
Use `strip_{prefix|suffix}` instead of `{starts|ends}_with`+indexing
Randomly scratching an itch 😁
Diffstat (limited to 'compiler/rustc_codegen_ssa/src')
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/back/link.rs | 9 |
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 |
