Use unwrap_or_else()

This commit is contained in:
hyd-dev
2021-05-30 21:01:40 +08:00
parent b054a19f94
commit e026ad584d
+5 -5
View File
@@ -213,11 +213,11 @@ fn emulate_foreign_item(
) -> 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");