about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorTsukasa OI <floss_rust@irq.a4lg.com>2025-09-17 12:35:21 +0000
committerTsukasa OI <floss_rust@irq.a4lg.com>2025-09-17 12:35:21 +0000
commitd9f67cbb8be4500ba73bb30177c05153cbc9424a (patch)
tree77286e235fe142feab9a97e85c542b707ad2ed2f /compiler
parentea8baccbb15fd58afcde959eed7dc73741dd626d (diff)
downloadrust-d9f67cbb8be4500ba73bb30177c05153cbc9424a.tar.gz
rust-d9f67cbb8be4500ba73bb30177c05153cbc9424a.zip
rustc_codegen_llvm: Simplify `arch` conversion
This commit simplifies construction of `arch` from `sess.target.arch`.
It also preserves a reference to `sess.target.arch` as `raw_arch`
to make this function future proof.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_codegen_llvm/src/llvm_util.rs17
1 files changed, 7 insertions, 10 deletions
diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs
index 393361a1afe..6849cd24164 100644
--- a/compiler/rustc_codegen_llvm/src/llvm_util.rs
+++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs
@@ -217,16 +217,13 @@ impl<'a> IntoIterator for LLVMFeature<'a> {
 /// Rust can also be build with an external precompiled version of LLVM which might lead to failures
 /// if the oldest tested / supported LLVM version doesn't yet support the relevant intrinsics.
 pub(crate) fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> Option<LLVMFeature<'a>> {
-    let arch = if sess.target.arch == "x86_64" {
-        "x86"
-    } else if sess.target.arch == "arm64ec" {
-        "aarch64"
-    } else if sess.target.arch == "sparc64" {
-        "sparc"
-    } else if sess.target.arch == "powerpc64" {
-        "powerpc"
-    } else {
-        &*sess.target.arch
+    let raw_arch = &*sess.target.arch;
+    let arch = match raw_arch {
+        "x86_64" => "x86",
+        "arm64ec" => "aarch64",
+        "sparc64" => "sparc",
+        "powerpc64" => "powerpc",
+        _ => raw_arch,
     };
     let (major, _, _) = get_version();
     match (arch, s) {