Skip to content

Commit 1d897f5

Browse files
aidenfoxiveyk0kubun
authored andcommitted
ZJIT: Elide unnecessary return statements
1 parent 74c3bd7 commit 1d897f5

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

zjit/src/backend/tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ fn test_alloc_regs() {
6363
}
6464

6565
fn setup_asm() -> (Assembler, CodeBlock) {
66-
return (
66+
(
6767
Assembler::new(),
6868
CodeBlock::new_dummy()
69-
);
69+
)
7070
}
7171

7272
// Test full codegen pipeline

zjit/src/cruby_methods.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,7 @@ fn inline_kernel_itself(_fun: &mut hir::Function, _block: hir::BlockId, recv: hi
255255
fn inline_kernel_block_given_p(fun: &mut hir::Function, block: hir::BlockId, _recv: hir::InsnId, args: &[hir::InsnId], _state: hir::InsnId) -> Option<hir::InsnId> {
256256
let &[] = args else { return None; };
257257
// TODO(max): In local iseq types that are not ISEQ_TYPE_METHOD, rewrite to Constant false.
258-
let result = fun.push_insn(block, hir::Insn::IsBlockGiven);
259-
return Some(result);
258+
Some(fun.push_insn(block, hir::Insn::IsBlockGiven))
260259
}
261260

262261
fn inline_array_aref(fun: &mut hir::Function, block: hir::BlockId, recv: hir::InsnId, args: &[hir::InsnId], state: hir::InsnId) -> Option<hir::InsnId> {

zjit/src/hir.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,7 +1428,7 @@ fn iseq_get_return_value(iseq: IseqPtr, captured_opnd: Option<InsnId>, ci_flags:
14281428

14291429
// TODO(max): Support only_kwparam case where the local_idx is a positional parameter
14301430

1431-
return None;
1431+
None
14321432
}
14331433
YARVINSN_putnil => Some(IseqReturn::Value(Qnil)),
14341434
YARVINSN_putobject => Some(IseqReturn::Value(unsafe { *rb_iseq_pc_at_idx(iseq, 1) })),
@@ -2618,16 +2618,16 @@ impl Function {
26182618
blockiseq,
26192619
});
26202620
fun.make_equal_to(send_insn_id, ccall);
2621-
return Ok(());
2621+
Ok(())
26222622
}
26232623
// Variadic method
26242624
-1 => {
26252625
// func(int argc, VALUE *argv, VALUE recv)
2626-
return Err(());
2626+
Err(())
26272627
}
26282628
-2 => {
26292629
// (self, args_ruby_array)
2630-
return Err(());
2630+
Err(())
26312631
}
26322632
_ => unreachable!("unknown cfunc kind: argc={argc}")
26332633
}

0 commit comments

Comments
 (0)