Skip to content

Commit 606f48e

Browse files
committed
cargo fmt and clippy
1 parent 80d8ac0 commit 606f48e

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

cli/src/debug/function.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ use boa_engine::{
22
builtins::function::OrdinaryFunction,
33
js_string,
44
object::ObjectInitializer,
5-
vm::{flowgraph::{Direction, Graph}, trace::{Tracer, TraceAction}},
5+
vm::{
6+
flowgraph::{Direction, Graph},
7+
trace::{TraceAction, Tracer},
8+
},
69
Context, JsArgs, JsNativeError, JsObject, JsResult, JsValue, NativeFunction,
710
};
811

@@ -130,9 +133,9 @@ impl Tracer for FunctionTracer {
130133
fn should_trace(&self, frame: &boa_engine::vm::CallFrame) -> TraceAction {
131134
if frame.code_block().traceable() {
132135
if frame.code_block().was_traced() {
133-
return TraceAction::Block
136+
return TraceAction::Block;
134137
}
135-
return TraceAction::BlockWithBytecode
138+
return TraceAction::BlockWithBytecode;
136139
}
137140
TraceAction::None
138141
}

core/engine/src/vm/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ impl Context {
389389
}
390390

391391
#[cfg(feature = "trace")]
392-
let result = if self.vm.trace.should_trace(&self.vm.frame()) {
392+
let result = if self.vm.trace.should_trace(self.vm.frame()) {
393393
self.trace_execute_instruction(f)
394394
} else {
395395
self.execute_instruction(f)

core/engine/src/vm/trace.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use std::collections::VecDeque;
44
use std::fmt;
55

6-
use super::{Constant, Vm, CallFrame};
6+
use super::{CallFrame, Constant, Vm};
77

88
// TODO: Build out further, maybe provide more element visiblity and events/outputs
99
/// The `Tracer` trait is a customizable trait that can be provided to `Boa`
@@ -12,7 +12,7 @@ pub trait Tracer: fmt::Debug {
1212
/// Whether the current call frame should trace.
1313
fn should_trace(&self, frame: &CallFrame) -> TraceAction {
1414
if frame.code_block.name().to_std_string_escaped().as_str() == "<main>" {
15-
return TraceAction::BlockWithFullBytecode
15+
return TraceAction::BlockWithFullBytecode;
1616
}
1717
TraceAction::Block
1818
}
@@ -60,14 +60,6 @@ impl Tracer for ActiveTracer {
6060
}
6161
}
6262

63-
impl Default for VmTrace {
64-
fn default() -> Self {
65-
Self {
66-
tracers: Vec::default(),
67-
}
68-
}
69-
}
70-
7163
/// `VmTrace` is a boa spcific structure for running Boa's Virtual Machine trace.
7264
///
7365
/// It holds registered `Tracer` implementations and actions messages depending on
@@ -77,6 +69,7 @@ impl Default for VmTrace {
7769
///
7870
/// After the Global callframe is initially provided. It searches
7971
/// for all possible compiled output
72+
#[derive(Default)]
8073
pub struct VmTrace {
8174
tracers: Vec<Box<dyn Tracer>>,
8275
}
@@ -90,12 +83,16 @@ impl VmTrace {
9083
}
9184

9285
/// Returns whether there is an active trace request.
93-
pub fn should_trace(&self, frame: &CallFrame) -> bool {
86+
#[must_use]
87+
pub(crate) fn should_trace(&self, frame: &CallFrame) -> bool {
9488
self.trace_action(frame) != TraceAction::None
9589
}
9690

91+
/// Returns the folded `TraceAction` of the current `Tracer`s
9792
pub(crate) fn trace_action(&self, frame: &CallFrame) -> TraceAction {
98-
(&self.tracers).into_iter().fold(TraceAction::None, |a, b| a.max(b.should_trace(frame)))
93+
self.tracers
94+
.iter()
95+
.fold(TraceAction::None, |a, b| a.max(b.should_trace(frame)))
9996
}
10097

10198
/// Sets the current `Tracer` of `VmTrace`.

ffi/wasm/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
use boa_engine::{vm::trace::Tracer, Context, Source};
1010
use chrono as _;
1111
use getrandom as _;
12-
use wasm_bindgen::prelude::*;
1312
use std::fmt;
13+
use wasm_bindgen::prelude::*;
1414

1515
#[wasm_bindgen(start)]
1616
fn main() {

0 commit comments

Comments
 (0)