summaryrefslogtreecommitdiff
path: root/yjit/src/core.rs
diff options
context:
space:
mode:
authorAlan Wu <XrXr@users.noreply.github.com>2022-04-27 14:08:52 -0400
committerAlan Wu <XrXr@users.noreply.github.com>2022-04-29 15:03:45 -0400
commitfead7107abc494ef051fd26357c21a546b49c7d9 (patch)
tree8605fc5e827abb03f2020193ba3f28ca2108147c /yjit/src/core.rs
parentf8e4488e5e01c07cc8c139e6030a5dfca45b824c (diff)
YJIT: Adopt Clippy suggestions we like
This adopts most suggestions that rust-clippy is confident enough to auto apply. The manual changes mostly fix manual if-lets and take opportunities to use the `Default` trait on standard collections. Co-authored-by: Kevin Newton <kddnewton@gmail.com> Co-authored-by: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com>
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/5853
Diffstat (limited to 'yjit/src/core.rs')
-rw-r--r--yjit/src/core.rs15
1 files changed, 7 insertions, 8 deletions
diff --git a/yjit/src/core.rs b/yjit/src/core.rs
index b8229167ed..918930fe56 100644
--- a/yjit/src/core.rs
+++ b/yjit/src/core.rs
@@ -402,7 +402,7 @@ impl IseqPayload {
let version_map = mem::take(&mut self.version_map);
// Turn it into an iterator that owns the blocks and return
- version_map.into_iter().flat_map(|versions| versions)
+ version_map.into_iter().flatten()
}
}
@@ -1718,8 +1718,8 @@ pub fn gen_branch(
// Get the branch targets or stubs
let dst_addr0 = get_branch_target(target0, ctx0, &branchref, 0, ocb);
- let dst_addr1 = if ctx1.is_some() {
- get_branch_target(target1.unwrap(), ctx1.unwrap(), &branchref, 1, ocb)
+ let dst_addr1 = if let Some(ctx) = ctx1 {
+ get_branch_target(target1.unwrap(), ctx, &branchref, 1, ocb)
} else {
None
};
@@ -1733,8 +1733,8 @@ pub fn gen_branch(
branch.targets[0] = Some(target0);
branch.targets[1] = target1;
branch.target_ctxs[0] = *ctx0;
- branch.target_ctxs[1] = if ctx1.is_some() {
- *ctx1.unwrap()
+ branch.target_ctxs[1] = if let Some(&ctx) = ctx1 {
+ ctx
} else {
Context::default()
};
@@ -1803,12 +1803,11 @@ pub fn defer_compilation(
panic!("Double defer!");
}
- let mut next_ctx = cur_ctx.clone();
+ let mut next_ctx = *cur_ctx;
- if next_ctx.chain_depth >= u8::MAX {
+ if next_ctx.chain_depth == u8::MAX {
panic!("max block version chain depth reached!");
}
-
next_ctx.chain_depth += 1;
let block_rc = jit.get_block();