diff --git a/src/librustc_codegen_llvm/debuginfo/create_scope_map.rs b/src/librustc_codegen_llvm/debuginfo/create_scope_map.rs index 0484837a48d..56352ae963f 100644 --- a/src/librustc_codegen_llvm/debuginfo/create_scope_map.rs +++ b/src/librustc_codegen_llvm/debuginfo/create_scope_map.rs @@ -37,7 +37,7 @@ pub struct MirDebugScope<'ll> { impl MirDebugScope<'ll> { pub fn is_valid(&self) -> bool { - !self.scope_metadata.is_none() + self.scope_metadata.is_some() } } diff --git a/src/librustc_codegen_llvm/debuginfo/metadata.rs b/src/librustc_codegen_llvm/debuginfo/metadata.rs index 34e770c845c..5383d5fbebe 100644 --- a/src/librustc_codegen_llvm/debuginfo/metadata.rs +++ b/src/librustc_codegen_llvm/debuginfo/metadata.rs @@ -163,10 +163,10 @@ impl TypeMap<'ll, 'tcx> { fn get_unique_type_id_of_type<'a>(&mut self, cx: &CodegenCx<'a, 'tcx>, type_: Ty<'tcx>) -> UniqueTypeId { // Let's see if we already have something in the cache - match self.type_to_unique_id.get(&type_).cloned() { - Some(unique_type_id) => return unique_type_id, - None => { /* generate one */} - }; + if let Some(unique_type_id) = self.type_to_unique_id.get(&type_).cloned() { + return unique_type_id + } + // if not, generate one // The hasher we are using to generate the UniqueTypeId. We want // something that provides more than the 64 bits of the DefaultHasher. @@ -286,11 +286,11 @@ impl RecursiveTypeDescription<'ll, 'tcx> { // unique id can be found in the type map macro_rules! return_if_metadata_created_in_meantime { ($cx: expr, $unique_type_id: expr) => ( - match debug_context($cx).type_map - .borrow() - .find_metadata_for_unique_id($unique_type_id) { - Some(metadata) => return MetadataCreationResult::new(metadata, true), - None => { /* proceed normally */ } + if let Some(metadata) = debug_context($cx).type_map + .borrow() + .find_metadata_for_unique_id($unique_type_id) + { + return MetadataCreationResult::new(metadata, true) } ) } @@ -548,12 +548,12 @@ pub fn type_metadata( _ => { let pointee_metadata = type_metadata(cx, ty, usage_site_span); - match debug_context(cx).type_map - .borrow() - .find_metadata_for_unique_id(unique_type_id) { - Some(metadata) => return Err(metadata), - None => { /* proceed normally */ } - }; + if let Some(metadata) = debug_context(cx).type_map + .borrow() + .find_metadata_for_unique_id(unique_type_id) + { + return Err(metadata) + } Ok(MetadataCreationResult::new(pointer_type_metadata(cx, t, pointee_metadata), false)) @@ -608,12 +608,12 @@ pub fn type_metadata( unique_type_id, t.fn_sig(cx.tcx), usage_site_span).metadata; - match debug_context(cx).type_map - .borrow() - .find_metadata_for_unique_id(unique_type_id) { - Some(metadata) => return metadata, - None => { /* proceed normally */ } - }; + if let Some(metadata) = debug_context(cx).type_map + .borrow() + .find_metadata_for_unique_id(unique_type_id) + { + return metadata + } // This is actually a function pointer, so wrap it in pointer DI MetadataCreationResult::new(pointer_type_metadata(cx, t, fn_metadata), false) @@ -1476,9 +1476,8 @@ fn prepare_enum_metadata( } }; - match (&layout.abi, discriminant_type_metadata) { - (&layout::Abi::Scalar(_), Some(discr)) => return FinalMetadata(discr), - _ => {} + if let (&layout::Abi::Scalar(_), Some(discr)) = (&layout.abi, discriminant_type_metadata) { + return FinalMetadata(discr) } let (enum_type_size, enum_type_align) = layout.size_and_align(); diff --git a/src/librustc_codegen_llvm/debuginfo/mod.rs b/src/librustc_codegen_llvm/debuginfo/mod.rs index 417b34cef4c..acb79d6f568 100644 --- a/src/librustc_codegen_llvm/debuginfo/mod.rs +++ b/src/librustc_codegen_llvm/debuginfo/mod.rs @@ -271,16 +271,14 @@ pub fn create_function_debug_context( let mut flags = DIFlags::FlagPrototyped; let local_id = cx.tcx.hir.as_local_node_id(def_id); - match *cx.sess().entry_fn.borrow() { - Some((id, _, _)) => { - if local_id == Some(id) { - flags = flags | DIFlags::FlagMainSubprogram; - } + if let Some((id, _, _)) = *cx.sess().entry_fn.borrow() { + if local_id == Some(id) { + flags |= DIFlags::FlagMainSubprogram; } - None => {} - }; + } + if cx.layout_of(sig.output()).abi.is_uninhabited() { - flags = flags | DIFlags::FlagNoReturn; + flags |= DIFlags::FlagNoReturn; } let fn_metadata = unsafe { diff --git a/src/librustc_codegen_llvm/debuginfo/source_loc.rs b/src/librustc_codegen_llvm/debuginfo/source_loc.rs index c59b5e2b8f5..405cffdefa2 100644 --- a/src/librustc_codegen_llvm/debuginfo/source_loc.rs +++ b/src/librustc_codegen_llvm/debuginfo/source_loc.rs @@ -56,11 +56,8 @@ pub fn set_source_location( /// switches source location emitting on and must therefore be called before the /// first real statement/expression of the function is codegened. pub fn start_emitting_source_locations(dbg_context: &FunctionDebugContext<'ll>) { - match *dbg_context { - FunctionDebugContext::RegularContext(ref data) => { - data.source_locations_enabled.set(true) - }, - _ => { /* safe to ignore */ } + if let FunctionDebugContext::RegularContext(ref data) = *dbg_context { + data.source_locations_enabled.set(true) } }