Browse Source

clippy fmt

nan-boxing
jedel1043 2 years ago
parent
commit
9217432669
  1. 9
      boa_engine/src/builtins/array/mod.rs
  2. 6
      boa_engine/src/builtins/async_generator/mod.rs
  3. 26
      boa_engine/src/builtins/promise/mod.rs
  4. 20
      boa_engine/src/builtins/promise/promise_job.rs
  5. 3
      boa_engine/src/builtins/reflect/mod.rs
  6. 3
      boa_engine/src/object/jsset.rs
  7. 1
      boa_engine/src/symbol.rs
  8. 2
      boa_engine/src/value/mod.rs
  9. 11
      boa_engine/src/vm/code_block.rs

9
boa_engine/src/builtins/array/mod.rs

@ -423,8 +423,7 @@ impl Array {
// b. Else,
// i. Let A be ? ArrayCreate(0en).
let a = match this.as_constructor() {
Some(constructor) => constructor
.construct(&[], None, context)?,
Some(constructor) => constructor.construct(&[], None, context)?,
_ => Self::array_create(0, None, context)?,
};
@ -497,8 +496,7 @@ impl Array {
// 10. Else,
// a. Let A be ? ArrayCreate(len).
let a = match this.as_constructor() {
Some(constructor) => constructor
.construct(&[len.into()], None, context)?,
Some(constructor) => constructor.construct(&[len.into()], None, context)?,
_ => Self::array_create(len, None, context)?,
};
@ -574,8 +572,7 @@ impl Array {
// 5. Else,
// a. Let A be ? ArrayCreate(len).
let a = match this.as_constructor() {
Some(constructor) => constructor
.construct(&[len.into()], None, context)?,
Some(constructor) => constructor.construct(&[len.into()], None, context)?,
_ => Self::array_create(len as u64, None, context)?,
};

6
boa_engine/src/builtins/async_generator/mod.rs

@ -374,11 +374,7 @@ impl AsyncGenerator {
// a. Perform ! Call(promiseCapability.[[Reject]], undefined, « exception »).
promise_capability
.reject()
.call(
&JsValue::undefined(),
&[args.get_or_undefined(0)],
context,
)
.call(&JsValue::undefined(), &[args.get_or_undefined(0)], context)
.expect("cannot fail per spec");
// b. Return promiseCapability.[[Promise]].

26
boa_engine/src/builtins/promise/mod.rs

@ -1710,11 +1710,7 @@ impl Promise {
// 1. Let promise be the this value.
let promise = this;
// 2. Return ? Invoke(promise, "then", « undefined, onRejected »).
promise.invoke(
"then",
&[JsValue::undefined(), on_rejected],
context,
)
promise.invoke("then", &[JsValue::undefined(), on_rejected], context)
}
/// `Promise.prototype.finally ( onFinally )`
@ -1778,9 +1774,7 @@ impl Promise {
// 1. Return value.
Ok(captures.value.clone())
},
ReturnValueCaptures {
value,
},
ReturnValueCaptures { value },
);
// iv. Let valueThunk be CreateBuiltinFunction(returnValue, 0, "", « »).
@ -1823,9 +1817,7 @@ impl Promise {
// 1. Return ThrowCompletion(reason).
Err(captures.reason.clone())
},
ThrowReasonCaptures {
reason,
},
ThrowReasonCaptures { reason },
);
// iv. Let thrower be CreateBuiltinFunction(throwReason, 0, "", « »).
@ -1834,10 +1826,7 @@ impl Promise {
// v. Return ? Invoke(promise, "then", « thrower »).
promise.invoke("then", &[thrower.into()], context)
},
FinallyCaptures {
on_finally,
c,
},
FinallyCaptures { on_finally, c },
);
// d. Let catchFinally be CreateBuiltinFunction(catchFinallyClosure, 1, "", « »).
@ -1887,7 +1876,12 @@ impl Promise {
promise_obj
.as_promise_mut()
.expect("IsPromise(promise) is false")
.perform_promise_then(&on_fulfilled, &on_rejected, Some(result_capability), context)
.perform_promise_then(
&on_fulfilled,
&on_rejected,
Some(result_capability),
context,
)
.pipe(Ok)
}

20
boa_engine/src/builtins/promise/promise_job.rs

@ -54,9 +54,11 @@ impl PromiseJob {
}
},
// e. Else, let handlerResult be Completion(HostCallJobCallback(handler, undefined, « argument »)).
Some(handler) => {
handler.call_job_callback(&JsValue::undefined(), &[argument.clone()], context)
}
Some(handler) => handler.call_job_callback(
&JsValue::undefined(),
&[argument.clone()],
context,
),
};
match promise_capability {
@ -83,13 +85,21 @@ impl PromiseJob {
// h. If handlerResult is an abrupt completion, then
Err(value) => {
// i. Return ? Call(promiseCapability.[[Reject]], undefined, « handlerResult.[[Value]] »).
context.call(&reject.clone().into(), &JsValue::undefined(), &[value])
context.call(
&reject.clone().into(),
&JsValue::undefined(),
&[value],
)
}
// i. Else,
Ok(value) => {
// i. Return ? Call(promiseCapability.[[Resolve]], undefined, « handlerResult.[[Value]] »).
context.call(&resolve.clone().into(), &JsValue::undefined(), &[value])
context.call(
&resolve.clone().into(),
&JsValue::undefined(),
&[value],
)
}
}
}

3
boa_engine/src/builtins/reflect/mod.rs

@ -104,8 +104,7 @@ impl Reflect {
context: &mut Context,
) -> JsResult<JsValue> {
// 1. If IsConstructor(target) is false, throw a TypeError exception.
let target = args
.get_or_undefined(0);
let target = args.get_or_undefined(0);
let target = target
.as_constructor()
.ok_or_else(|| context.construct_type_error("target must be a constructor"))?;

3
boa_engine/src/object/jsset.rs

@ -5,7 +5,8 @@ use boa_gc::{Finalize, Trace};
use crate::{
builtins::Set,
object::{JsFunction, JsObject, JsObjectType, JsSetIterator},
Context, JsResult, JsValue, value::JsVariant,
value::JsVariant,
Context, JsResult, JsValue,
};
// This is an wrapper for `JsSet`

1
boa_engine/src/symbol.rs

@ -270,7 +270,6 @@ unsafe impl Trace for JsSymbol {
unsafe_empty_trace!();
}
impl JsSymbol {
/// Create a new symbol.
#[inline]

2
boa_engine/src/value/mod.rs

@ -459,7 +459,7 @@ impl JsValue {
JsVariant::Integer32(integer) => integer.into(),
_ => primitive.to_string(context)?.into(),
}
},
}
_ => self.to_string(context)?.into(),
})
}

11
boa_engine/src/vm/code_block.rs

@ -18,9 +18,10 @@ use crate::{
},
property::PropertyDescriptor,
syntax::ast::node::FormalParameterList,
value::JsVariant,
vm::call_frame::GeneratorResumeKind,
vm::{call_frame::FinallyReturn, CallFrame, Opcode},
Context, JsResult, JsValue, value::JsVariant,
Context, JsResult, JsValue,
};
use boa_gc::{Cell, Finalize, Gc, Trace};
use boa_interner::{Interner, Sym, ToInternedString};
@ -1241,7 +1242,9 @@ impl JsObject {
match function(this_target, args, context)?.variant() {
JsVariant::Object(o) => Ok(o.clone()),
val => {
if constructor.expect("hmm").is_base() || matches!(val, JsVariant::Undefined) {
if constructor.expect("hmm").is_base()
|| matches!(val, JsVariant::Undefined)
{
create_this(context)
} else {
context.throw_type_error(
@ -1265,7 +1268,9 @@ impl JsObject {
match (function)(this_target, args, captures, context)?.variant() {
JsVariant::Object(o) => Ok(o.clone()),
val => {
if constructor.expect("hmma").is_base() || matches!(val, JsVariant::Undefined) {
if constructor.expect("hmma").is_base()
|| matches!(val, JsVariant::Undefined)
{
create_this(context)
} else {
context.throw_type_error(

Loading…
Cancel
Save