Adopt let else in more places
This commit is contained in:
parent
b8c56fa8c3
commit
2ef8af6619
132 changed files with 539 additions and 881 deletions
|
@ -310,10 +310,7 @@ impl<'a> LlvmArchiveBuilder<'a> {
|
|||
if let Some(archive) = self.src_archive() {
|
||||
for child in archive.iter() {
|
||||
let child = child.map_err(string_to_io_error)?;
|
||||
let child_name = match child.name() {
|
||||
Some(s) => s,
|
||||
None => continue,
|
||||
};
|
||||
let Some(child_name) = child.name() else { continue };
|
||||
if removals.iter().any(|r| r == child_name) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -826,20 +826,14 @@ pub(crate) unsafe fn codegen(
|
|||
let input =
|
||||
unsafe { slice::from_raw_parts(input_ptr as *const u8, input_len as usize) };
|
||||
|
||||
let input = match str::from_utf8(input) {
|
||||
Ok(s) => s,
|
||||
Err(_) => return 0,
|
||||
};
|
||||
let Ok(input) = str::from_utf8(input) else { return 0 };
|
||||
|
||||
let output = unsafe {
|
||||
slice::from_raw_parts_mut(output_ptr as *mut u8, output_len as usize)
|
||||
};
|
||||
let mut cursor = io::Cursor::new(output);
|
||||
|
||||
let demangled = match rustc_demangle::try_demangle(input) {
|
||||
Ok(d) => d,
|
||||
Err(_) => return 0,
|
||||
};
|
||||
let Ok(demangled) = rustc_demangle::try_demangle(input) else { return 0 };
|
||||
|
||||
if write!(cursor, "{:#}", demangled).is_err() {
|
||||
// Possible only if provided buffer is not big enough
|
||||
|
|
|
@ -138,10 +138,7 @@ pub fn compile_codegen_unit(tcx: TyCtxt<'_>, cgu_name: Symbol) -> (ModuleCodegen
|
|||
}
|
||||
|
||||
pub fn set_link_section(llval: &Value, attrs: &CodegenFnAttrs) {
|
||||
let sect = match attrs.link_section {
|
||||
Some(name) => name,
|
||||
None => return,
|
||||
};
|
||||
let Some(sect) = attrs.link_section else { return };
|
||||
unsafe {
|
||||
let buf = SmallCStr::new(sect.as_str());
|
||||
llvm::LLVMSetSection(llval, buf.as_ptr());
|
||||
|
|
|
@ -369,10 +369,9 @@ impl<'ll> StaticMethods for CodegenCx<'ll, '_> {
|
|||
unsafe {
|
||||
let attrs = self.tcx.codegen_fn_attrs(def_id);
|
||||
|
||||
let (v, alloc) = match codegen_static_initializer(self, def_id) {
|
||||
Ok(v) => v,
|
||||
let Ok((v, alloc)) = codegen_static_initializer(self, def_id) else {
|
||||
// Error has already been reported
|
||||
Err(_) => return,
|
||||
return;
|
||||
};
|
||||
|
||||
let g = self.get_static(def_id);
|
||||
|
|
|
@ -766,18 +766,15 @@ pub fn type_metadata<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'ll
|
|||
|
||||
if already_stored_in_typemap {
|
||||
// Also make sure that we already have a `TypeMap` entry for the unique type ID.
|
||||
let metadata_for_uid = match type_map.find_metadata_for_unique_id(unique_type_id) {
|
||||
Some(metadata) => metadata,
|
||||
None => {
|
||||
bug!(
|
||||
"expected type metadata for unique \
|
||||
type ID '{}' to already be in \
|
||||
the `debuginfo::TypeMap` but it \
|
||||
was not. (Ty = {})",
|
||||
type_map.get_unique_type_id_as_string(unique_type_id),
|
||||
t
|
||||
);
|
||||
}
|
||||
let Some(metadata_for_uid) = type_map.find_metadata_for_unique_id(unique_type_id) else {
|
||||
bug!(
|
||||
"expected type metadata for unique \
|
||||
type ID '{}' to already be in \
|
||||
the `debuginfo::TypeMap` but it \
|
||||
was not. (Ty = {})",
|
||||
type_map.get_unique_type_id_as_string(unique_type_id),
|
||||
t
|
||||
);
|
||||
};
|
||||
|
||||
match type_map.find_metadata_for_type(t) {
|
||||
|
|
|
@ -88,9 +88,8 @@ impl<'ll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'_, 'll, 'tcx> {
|
|||
let tcx = self.tcx;
|
||||
let callee_ty = instance.ty(tcx, ty::ParamEnv::reveal_all());
|
||||
|
||||
let (def_id, substs) = match *callee_ty.kind() {
|
||||
ty::FnDef(def_id, substs) => (def_id, substs),
|
||||
_ => bug!("expected fn item type, found {}", callee_ty),
|
||||
let ty::FnDef(def_id, substs) = *callee_ty.kind() else {
|
||||
bug!("expected fn item type, found {}", callee_ty);
|
||||
};
|
||||
|
||||
let sig = callee_ty.fn_sig(tcx);
|
||||
|
@ -1000,9 +999,8 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
|
|||
}
|
||||
})
|
||||
.collect();
|
||||
let indices = match indices {
|
||||
Some(i) => i,
|
||||
None => return Ok(bx.const_null(llret_ty)),
|
||||
let Some(indices) = indices else {
|
||||
return Ok(bx.const_null(llret_ty));
|
||||
};
|
||||
|
||||
return Ok(bx.shuffle_vector(
|
||||
|
|
|
@ -339,9 +339,8 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> {
|
|||
_ => {}
|
||||
}
|
||||
|
||||
let (a, b) = match self.abi {
|
||||
Abi::ScalarPair(a, b) => (a, b),
|
||||
_ => bug!("TyAndLayout::scalar_pair_element_llty({:?}): not applicable", self),
|
||||
let Abi::ScalarPair(a, b) = self.abi else {
|
||||
bug!("TyAndLayout::scalar_pair_element_llty({:?}): not applicable", self);
|
||||
};
|
||||
let scalar = [a, b][index];
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue