Skip to content

Commit e88f042

Browse files
committed
Fix new clippy warnings.
1 parent 8ab84c7 commit e88f042

File tree

2 files changed

+30
-36
lines changed

2 files changed

+30
-36
lines changed

crates/rustc_codegen_spirv/src/builder/builder_methods.rs

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -879,36 +879,33 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
879879
// Search the current function's instructions...
880880
// FIXME(eddyb) this could get ridiculously expensive, at the very least
881881
// it could use `.rev()`, hoping the base pointer was recently defined?
882-
let search_result = {
883-
let emit = self.emit();
884-
let module = emit.module_ref();
885-
emit.selected_function().and_then(|func_idx| {
886-
module.functions.get(func_idx).and_then(|func| {
887-
// Find the instruction that defined our base pointer `ptr_id`.
888-
func.all_inst_iter()
889-
.find(|inst| inst.result_id == Some(ptr_id))
890-
.and_then(|ptr_def_inst| {
891-
// Check if that instruction was an `AccessChain` or `InBoundsAccessChain`.
892-
if matches!(
893-
ptr_def_inst.class.opcode,
894-
Op::AccessChain | Op::InBoundsAccessChain
895-
) {
896-
// If yes, extract its base pointer and its indices.
897-
let base_ptr = ptr_def_inst.operands[0].unwrap_id_ref();
898-
let indices = ptr_def_inst.operands[1..]
899-
.iter()
900-
.map(|op| op.unwrap_id_ref())
901-
.collect::<Vec<_>>();
902-
Some((base_ptr, indices))
903-
} else {
904-
// The instruction defining ptr was not an `AccessChain`.
905-
None
906-
}
907-
})
908-
})
882+
let emit = self.emit();
883+
let module = emit.module_ref();
884+
emit.selected_function().and_then(|func_idx| {
885+
module.functions.get(func_idx).and_then(|func| {
886+
// Find the instruction that defined our base pointer `ptr_id`.
887+
func.all_inst_iter()
888+
.find(|inst| inst.result_id == Some(ptr_id))
889+
.and_then(|ptr_def_inst| {
890+
// Check if that instruction was an `AccessChain` or `InBoundsAccessChain`.
891+
if matches!(
892+
ptr_def_inst.class.opcode,
893+
Op::AccessChain | Op::InBoundsAccessChain
894+
) {
895+
// If yes, extract its base pointer and its indices.
896+
let base_ptr = ptr_def_inst.operands[0].unwrap_id_ref();
897+
let indices = ptr_def_inst.operands[1..]
898+
.iter()
899+
.map(|op| op.unwrap_id_ref())
900+
.collect::<Vec<_>>();
901+
Some((base_ptr, indices))
902+
} else {
903+
// The instruction defining ptr was not an `AccessChain`.
904+
None
905+
}
906+
})
909907
})
910-
};
911-
search_result
908+
})
912909
} else {
913910
// Input type `ty` doesn't match the pointer's actual type, cannot safely merge.
914911
None

tests/src/main.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -391,13 +391,10 @@ fn rust_flags(codegen_backend_path: &Path) -> String {
391391
fn map_status_to_result(status: std::process::ExitStatus) -> io::Result<()> {
392392
match status.success() {
393393
true => Ok(()),
394-
false => Err(io::Error::new(
395-
io::ErrorKind::Other,
396-
format!(
397-
"process terminated with non-zero code: {}",
398-
status.code().unwrap_or(0)
399-
),
400-
)),
394+
false => Err(io::Error::other(format!(
395+
"process terminated with non-zero code: {}",
396+
status.code().unwrap_or(0)
397+
))),
401398
}
402399
}
403400

0 commit comments

Comments
 (0)