From 921743266997cd3bde77b0ce3a12eac20574a116 Mon Sep 17 00:00:00 2001 From: jedel1043 Date: Thu, 8 Sep 2022 16:45:36 -0500 Subject: [PATCH] clippy fmt --- boa_engine/src/builtins/array/mod.rs | 9 +++---- .../src/builtins/async_generator/mod.rs | 6 +---- boa_engine/src/builtins/promise/mod.rs | 26 +++++++------------ .../src/builtins/promise/promise_job.rs | 20 ++++++++++---- boa_engine/src/builtins/reflect/mod.rs | 3 +-- boa_engine/src/object/jsset.rs | 5 ++-- boa_engine/src/symbol.rs | 1 - boa_engine/src/value/mod.rs | 10 +++---- boa_engine/src/vm/code_block.rs | 11 +++++--- 9 files changed, 46 insertions(+), 45 deletions(-) diff --git a/boa_engine/src/builtins/array/mod.rs b/boa_engine/src/builtins/array/mod.rs index 4887f3e2dd..c5ecaf1a86 100644 --- a/boa_engine/src/builtins/array/mod.rs +++ b/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)?, }; diff --git a/boa_engine/src/builtins/async_generator/mod.rs b/boa_engine/src/builtins/async_generator/mod.rs index 75a9aeb666..d3a05feb91 100644 --- a/boa_engine/src/builtins/async_generator/mod.rs +++ b/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]]. diff --git a/boa_engine/src/builtins/promise/mod.rs b/boa_engine/src/builtins/promise/mod.rs index 2350054365..6eb6327f57 100644 --- a/boa_engine/src/builtins/promise/mod.rs +++ b/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) } diff --git a/boa_engine/src/builtins/promise/promise_job.rs b/boa_engine/src/builtins/promise/promise_job.rs index f065b0ee95..480bb5b556 100644 --- a/boa_engine/src/builtins/promise/promise_job.rs +++ b/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], + ) } } } diff --git a/boa_engine/src/builtins/reflect/mod.rs b/boa_engine/src/builtins/reflect/mod.rs index 1d7f869199..776129bb73 100644 --- a/boa_engine/src/builtins/reflect/mod.rs +++ b/boa_engine/src/builtins/reflect/mod.rs @@ -104,8 +104,7 @@ impl Reflect { context: &mut Context, ) -> JsResult { // 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"))?; diff --git a/boa_engine/src/object/jsset.rs b/boa_engine/src/object/jsset.rs index 663cc9b280..254dd5a1a7 100644 --- a/boa_engine/src/object/jsset.rs +++ b/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` @@ -89,7 +90,7 @@ impl JsSet { where T: Into, { - match Set::has(&self.inner.clone().into(), &[value.into()], context)?.variant() { + match Set::has(&self.inner.clone().into(), &[value.into()], context)?.variant() { JsVariant::Boolean(bool) => Ok(bool), _ => Err(JsValue::undefined()), } diff --git a/boa_engine/src/symbol.rs b/boa_engine/src/symbol.rs index 3c13f359c2..af02bf3a74 100644 --- a/boa_engine/src/symbol.rs +++ b/boa_engine/src/symbol.rs @@ -270,7 +270,6 @@ unsafe impl Trace for JsSymbol { unsafe_empty_trace!(); } - impl JsSymbol { /// Create a new symbol. #[inline] diff --git a/boa_engine/src/value/mod.rs b/boa_engine/src/value/mod.rs index fae8a3a1ca..cf98bbf5ec 100644 --- a/boa_engine/src/value/mod.rs +++ b/boa_engine/src/value/mod.rs @@ -454,12 +454,12 @@ impl JsValue { JsVariant::Object(_) => { let primitive = self.to_primitive(context, PreferredType::String)?; match primitive.variant() { - JsVariant::String(string) => string.clone().into(), - JsVariant::Symbol(symbol) => symbol.clone().into(), - JsVariant::Integer32(integer) => integer.into(), - _ => primitive.to_string(context)?.into(), + JsVariant::String(string) => string.clone().into(), + JsVariant::Symbol(symbol) => symbol.clone().into(), + JsVariant::Integer32(integer) => integer.into(), + _ => primitive.to_string(context)?.into(), + } } - }, _ => self.to_string(context)?.into(), }) } diff --git a/boa_engine/src/vm/code_block.rs b/boa_engine/src/vm/code_block.rs index 76bfbafc0c..e2b497a231 100644 --- a/boa_engine/src/vm/code_block.rs +++ b/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(