diff options
| author | Antoni Boucher <bouanto@zoho.com> | 2022-05-04 21:53:22 -0400 |
|---|---|---|
| committer | Antoni Boucher <bouanto@zoho.com> | 2022-05-04 21:53:22 -0400 |
| commit | e7df0a4b549e5d3b4aec0cc79c4262c5a2dfef13 (patch) | |
| tree | e93c40ab6de00a0e2c53f57db41bf59dcfd31ded | |
| parent | 603d342e00719fdba6691d6bed65e66ae817d46e (diff) | |
| download | rust-e7df0a4b549e5d3b4aec0cc79c4262c5a2dfef13.tar.gz rust-e7df0a4b549e5d3b4aec0cc79c4262c5a2dfef13.zip | |
Simplify get() after contains()
| -rw-r--r-- | src/declare.rs | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/declare.rs b/src/declare.rs index 8b2146c5aa8..a619e2f7712 100644 --- a/src/declare.rs +++ b/src/declare.rs @@ -11,8 +11,7 @@ use crate::intrinsic::llvm; impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> { pub fn get_or_insert_global(&self, name: &str, ty: Type<'gcc>, is_tls: bool, link_section: Option<Symbol>) -> 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() |
