From e026ad584d99c88af335edef96b93d1a0d7a071c Mon Sep 17 00:00:00 2001 From: hyd-dev Date: Sun, 30 May 2021 21:01:40 +0800 Subject: [PATCH] Use `unwrap_or_else()` --- src/shims/foreign_items.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/shims/foreign_items.rs b/src/shims/foreign_items.rs index 27f4bafdb0cb..c838c136c3f4 100644 --- a/src/shims/foreign_items.rs +++ b/src/shims/foreign_items.rs @@ -213,11 +213,11 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx ) -> InterpResult<'tcx, Option<&'mir mir::Body<'tcx>>> { let this = self.eval_context_mut(); let attrs = this.tcx.get_attrs(def_id); - let link_name_sym = match this.tcx.sess.first_attr_value_str_by_name(&attrs, sym::link_name) - { - Some(name) => name, - None => this.tcx.item_name(def_id), - }; + let link_name_sym = this + .tcx + .sess + .first_attr_value_str_by_name(&attrs, sym::link_name) + .unwrap_or_else(|| this.tcx.item_name(def_id)); let link_name = link_name_sym.as_str(); // Strip linker suffixes (seen on 32-bit macOS). let link_name = link_name.trim_end_matches("$UNIX2003");