From 76003f31f100b96b7c5f6d2414dde5088394b5bd Mon Sep 17 00:00:00 2001 From: LingMan Date: Wed, 30 Dec 2020 18:22:41 +0100 Subject: Use Option::map instead of open-coding it --- compiler/rustc_codegen_llvm/src/llvm_util.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'compiler/rustc_codegen_llvm/src') diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index 6c2a871e520..26843670131 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -254,8 +254,6 @@ pub fn handle_native_features(sess: &Session) -> Vec { } pub fn tune_cpu(sess: &Session) -> Option<&str> { - match sess.opts.debugging_opts.tune_cpu { - Some(ref s) => Some(handle_native(&**s)), - None => None, - } + let name = sess.opts.debugging_opts.tune_cpu.as_ref()?; + Some(handle_native(name)) } -- cgit 1.4.1-3-g733a5 From 5a706cfc49295f67c01fd3d422fa6fa69a018d92 Mon Sep 17 00:00:00 2001 From: LingMan Date: Sat, 16 Jan 2021 20:13:06 +0100 Subject: Use Option::unwrap_or instead of open-coding it --- compiler/rustc_codegen_llvm/src/llvm_util.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'compiler/rustc_codegen_llvm/src') diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index 6c2a871e520..722af496422 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -214,11 +214,7 @@ fn handle_native(name: &str) -> &str { } pub fn target_cpu(sess: &Session) -> &str { - let name = match sess.opts.cg.target_cpu { - Some(ref s) => &**s, - None => &*sess.target.cpu, - }; - + let name = sess.opts.cg.target_cpu.as_ref().unwrap_or(&sess.target.cpu); handle_native(name) } -- cgit 1.4.1-3-g733a5