From e7df0a4b549e5d3b4aec0cc79c4262c5a2dfef13 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Wed, 4 May 2022 21:53:22 -0400 Subject: [PATCH] Simplify get() after contains() --- src/declare.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/declare.rs b/src/declare.rs index 8b2146c5aa84..a619e2f77125 100644 --- a/src/declare.rs +++ b/src/declare.rs @@ -11,8 +11,7 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> { pub fn get_or_insert_global(&self, name: &str, ty: Type<'gcc>, is_tls: bool, link_section: Option) -> LValue<'gcc> { if self.globals.borrow().contains_key(name) { - // TODO: use [] instead of .get().expect()? - let typ = self.globals.borrow().get(name).expect("global").get_type(); + let typ = self.globals.borrow()[name].get_type(); let global = self.context.new_global(None, GlobalKind::Imported, typ, name); if is_tls { global.set_tls_model(self.tls_model); @@ -110,7 +109,7 @@ fn declare_raw_fn<'gcc>(cx: &CodegenCx<'gcc, '_>, name: &str, _callconv: () /*ll } let func = if cx.functions.borrow().contains_key(name) { - *cx.functions.borrow().get(name).expect("function") + cx.functions.borrow()[name] } else { let params: Vec<_> = param_types.into_iter().enumerate()