Adopt let else in more places
This commit is contained in:
@@ -674,9 +674,8 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>(
|
||||
loop {
|
||||
i += 1;
|
||||
prog = sess.time("run_linker", || exec_linker(sess, &cmd, out_filename, tmpdir));
|
||||
let output = match prog {
|
||||
Ok(ref output) => output,
|
||||
Err(_) => break,
|
||||
let Ok(ref output) = prog else {
|
||||
break;
|
||||
};
|
||||
if output.status.success() {
|
||||
break;
|
||||
@@ -2025,9 +2024,8 @@ fn add_local_native_libraries(
|
||||
let search_path = OnceCell::new();
|
||||
let mut last = (NativeLibKind::Unspecified, None);
|
||||
for lib in relevant_libs {
|
||||
let name = match lib.name {
|
||||
Some(l) => l,
|
||||
None => continue,
|
||||
let Some(name) = lib.name else {
|
||||
continue;
|
||||
};
|
||||
|
||||
// Skip if this library is the same as the last.
|
||||
@@ -2382,9 +2380,8 @@ fn add_upstream_native_libraries(
|
||||
let mut last = (NativeLibKind::Unspecified, None);
|
||||
for &cnum in &codegen_results.crate_info.used_crates {
|
||||
for lib in codegen_results.crate_info.native_libraries[&cnum].iter() {
|
||||
let name = match lib.name {
|
||||
Some(l) => l,
|
||||
None => continue,
|
||||
let Some(name) = lib.name else {
|
||||
continue;
|
||||
};
|
||||
if !relevant_lib(sess, &lib) {
|
||||
continue;
|
||||
|
||||
@@ -79,15 +79,14 @@ fn search_for_metadata<'a>(
|
||||
bytes: &'a [u8],
|
||||
section: &str,
|
||||
) -> Result<&'a [u8], String> {
|
||||
let file = match object::File::parse(bytes) {
|
||||
Ok(f) => f,
|
||||
let Ok(file) = object::File::parse(bytes) else {
|
||||
// The parse above could fail for odd reasons like corruption, but for
|
||||
// now we just interpret it as this target doesn't support metadata
|
||||
// emission in object files so the entire byte slice itself is probably
|
||||
// a metadata file. Ideally though if necessary we could at least check
|
||||
// the prefix of bytes to see if it's an actual metadata object and if
|
||||
// not forward the error along here.
|
||||
Err(_) => return Ok(bytes),
|
||||
return Ok(bytes);
|
||||
};
|
||||
file.section_by_name(section)
|
||||
.ok_or_else(|| format!("no `{}` section in '{}'", section, path.display()))?
|
||||
|
||||
@@ -448,10 +448,7 @@ fn wasm_import_module_map(tcx: TyCtxt<'_>, cnum: CrateNum) -> FxHashMap<DefId, S
|
||||
let mut ret = FxHashMap::default();
|
||||
for (def_id, lib) in tcx.foreign_modules(cnum).iter() {
|
||||
let module = def_id_to_native_lib.get(&def_id).and_then(|s| s.wasm_import_module);
|
||||
let module = match module {
|
||||
Some(s) => s,
|
||||
None => continue,
|
||||
};
|
||||
let Some(module) = module else { continue };
|
||||
ret.extend(lib.foreign_items.iter().map(|id| {
|
||||
assert_eq!(id.krate, cnum);
|
||||
(*id, module.to_string())
|
||||
|
||||
Reference in New Issue
Block a user