From e995e2b9dbdea16a7f0763a5a61d1370d94cb90c Mon Sep 17 00:00:00 2001 From: Laurence Tratt Date: Mon, 25 Apr 2022 11:48:38 +0100 Subject: [PATCH] Easy Clippy fixes. --- tests/src/bin/run_trace_compiler_test.rs | 6 +++--- ykrt/src/mt.rs | 18 +++++++++--------- yksgi/src/lib.rs | 10 +++++----- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/tests/src/bin/run_trace_compiler_test.rs b/tests/src/bin/run_trace_compiler_test.rs index db7c7e31b..88b9ecffd 100644 --- a/tests/src/bin/run_trace_compiler_test.rs +++ b/tests/src/bin/run_trace_compiler_test.rs @@ -10,7 +10,7 @@ use yktrace::{IRBlock, IRTrace}; const BBS_ENV: &str = "YKT_TRACE_BBS"; fn parse_bb(bb: &str) -> Result<(CString, usize), Box> { - let mut elems = bb.split(":"); + let mut elems = bb.split(':'); let func = elems.next().ok_or("malformed function name")?; let bb_idx = elems .next() @@ -23,7 +23,7 @@ fn main() -> Result<(), String> { // Build the trace that we are going to have compiled. let mut bbs = vec![IRBlock::unmappable()]; if let Ok(tbbs) = env::var(BBS_ENV) { - for bb in tbbs.split(",") { + for bb in tbbs.split(',') { if let Ok((func, bb_idx)) = parse_bb(bb) { bbs.push(IRBlock::new(func, bb_idx)); } else { @@ -41,7 +41,7 @@ fn main() -> Result<(), String> { // Map the `.ll` file into the address space so that we can give a pointer to it to the trace // compiler. Normally (i.e. outside of testing), the trace compiler wouldn't deal with textual // bitcode format, but it just so happens that LLVM's module loading APIs accept either format. - let ll_path = env::args().skip(1).next().unwrap(); + let ll_path = env::args().nth(1).unwrap(); let ll_file = File::open(ll_path).unwrap(); let mmap = unsafe { memmap2::Mmap::map(&ll_file).unwrap() }; diff --git a/ykrt/src/mt.rs b/ykrt/src/mt.rs index c03467806..f17f3cac6 100644 --- a/ykrt/src/mt.rs +++ b/ykrt/src/mt.rs @@ -219,9 +219,9 @@ impl MT { Ordering::Relaxed, ) .ok(); - return TransitionLocation::NoAction; + TransitionLocation::NoAction } else { - return THREAD_MTTHREAD.with(|mtt| { + THREAD_MTTHREAD.with(|mtt| { if !mtt.tracing.load(Ordering::Relaxed).is_null() { // This thread is already tracing another Location, so either another // thread needs to trace this Location or this thread needs to wait @@ -267,7 +267,7 @@ impl MT { } } } - }); + }) } } else { // There's no point contending with other threads, so in general we don't want to @@ -297,9 +297,9 @@ impl MT { let thread_arc = THREAD_MTTHREAD.with(|mtt| Arc::clone(&mtt.tracing)); if !thread_arc.load(Ordering::Relaxed).is_null() { // FIXME: https://github.com/ykjit/yk/issues/519 - return TransitionLocation::NoAction; + TransitionLocation::NoAction } else { - return TransitionLocation::Execute(*ctr); + TransitionLocation::Execute(*ctr) } } HotLocationKind::Compiling(arcmtx) => { @@ -322,7 +322,7 @@ impl MT { } }; loc.unlock(); - return r; + r } HotLocationKind::Tracing(ref tracing_arc) => { let thread_arc = THREAD_MTTHREAD.with(|mtt| Arc::clone(&mtt.tracing)); @@ -338,7 +338,7 @@ impl MT { let mtx = Arc::new(Mutex::new(None)); hl.kind = HotLocationKind::Compiling(Arc::clone(&mtx)); loc.unlock(); - return TransitionLocation::StopTracing(mtx); + TransitionLocation::StopTracing(mtx) } else { // This thread isn't tracing anything if Arc::strong_count(tracing_arc) == 1 { @@ -359,12 +359,12 @@ impl MT { } } loc.unlock(); - return TransitionLocation::NoAction; + TransitionLocation::NoAction } } HotLocationKind::DontTrace => { loc.unlock(); - return TransitionLocation::NoAction; + TransitionLocation::NoAction } } } diff --git a/yksgi/src/lib.rs b/yksgi/src/lib.rs index 5624f8f87..7813b214b 100644 --- a/yksgi/src/lib.rs +++ b/yksgi/src/lib.rs @@ -326,17 +326,17 @@ impl SGInterp { if ALWAYS_SKIP_FUNCS.contains(&name) { // There's no point calling these functions inside the stopgap interpreter so just skip // them. - return false; + false } else if SKIP_FOR_NOW_FUNCS.contains(&name) { // FIXME: These need to run, but since we can't do calls, just skip them for now. - return false; + false } else if name.starts_with("puts") || name.starts_with("printf") { // FIXME: Until we can handle function calls, simulate prints to make our tests work. // Get format string. let op = self.pc.get_operand(0); let op2 = op.get_operand(0); let op3 = LLVMGetInitializer(op2.get()); - let mut l = 0 as usize; + let mut l = 0; let s = LLVMGetAsString(op3, &mut l); // Get operands let mut ops = Vec::new(); @@ -355,10 +355,10 @@ impl SGInterp { 3 => libc::printf(s, ops[0], ops[1], ops[2]), _ => todo!(), }; - return false; + false } else if name.starts_with(YK_CONTROL_POINT_FUNC) { // FIXME: When we see the control point we are done and can just return. - return true; + true } else { // FIXME: Properly implement calls. todo!("{:?}", self.pc.as_str())