From baa4f9893ba097f2f052dacdacf4dedde0edf1dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Juli=C3=A1n=20Espina?= Date: Wed, 8 Nov 2023 19:34:56 -0600 Subject: [PATCH] Simplify all extensions APIs of `Context` (#3456) --- boa_cli/src/debug/function.rs | 10 +- boa_cli/src/debug/gc.rs | 4 +- boa_cli/src/debug/limits.rs | 14 +- boa_cli/src/debug/mod.rs | 4 +- boa_cli/src/debug/object.rs | 4 +- boa_cli/src/debug/optimizer.rs | 18 +- boa_cli/src/debug/realm.rs | 4 +- boa_cli/src/debug/shape.rs | 8 +- boa_cli/src/main.rs | 31 +-- .../src/builtins/array/array_iterator.rs | 8 +- boa_engine/src/builtins/array/mod.rs | 140 +++++------- boa_engine/src/builtins/array/tests.rs | 4 +- boa_engine/src/builtins/array_buffer/mod.rs | 18 +- .../src/builtins/array_buffer/shared.rs | 14 +- boa_engine/src/builtins/array_buffer/utils.rs | 2 +- boa_engine/src/builtins/async_function/mod.rs | 2 +- .../src/builtins/async_generator/mod.rs | 14 +- .../builtins/async_generator_function/mod.rs | 2 +- boa_engine/src/builtins/atomics/mod.rs | 20 +- boa_engine/src/builtins/bigint/mod.rs | 19 +- boa_engine/src/builtins/boolean/mod.rs | 14 +- boa_engine/src/builtins/dataview/mod.rs | 52 ++--- boa_engine/src/builtins/date/mod.rs | 98 ++++----- boa_engine/src/builtins/error/aggregate.rs | 2 +- boa_engine/src/builtins/error/eval.rs | 2 +- boa_engine/src/builtins/error/mod.rs | 6 +- boa_engine/src/builtins/error/range.rs | 2 +- boa_engine/src/builtins/error/reference.rs | 2 +- boa_engine/src/builtins/error/syntax.rs | 2 +- boa_engine/src/builtins/error/type.rs | 2 +- boa_engine/src/builtins/error/uri.rs | 2 +- boa_engine/src/builtins/escape/mod.rs | 4 +- boa_engine/src/builtins/eval/mod.rs | 4 +- boa_engine/src/builtins/function/arguments.rs | 4 +- boa_engine/src/builtins/function/mod.rs | 24 +-- boa_engine/src/builtins/generator/mod.rs | 14 +- .../src/builtins/generator_function/mod.rs | 2 +- boa_engine/src/builtins/intl/collator/mod.rs | 20 +- .../src/builtins/intl/collator/options.rs | 2 +- .../src/builtins/intl/date_time_format.rs | 6 +- .../src/builtins/intl/list_format/mod.rs | 25 +-- .../src/builtins/intl/list_format/options.rs | 2 +- boa_engine/src/builtins/intl/locale/mod.rs | 56 ++--- .../src/builtins/intl/locale/options.rs | 8 +- boa_engine/src/builtins/intl/locale/tests.rs | 16 +- boa_engine/src/builtins/intl/locale/utils.rs | 46 ++-- boa_engine/src/builtins/intl/mod.rs | 4 +- .../src/builtins/intl/number_format/utils.rs | 2 +- boa_engine/src/builtins/intl/options.rs | 6 +- .../src/builtins/intl/plural_rules/mod.rs | 16 +- .../src/builtins/intl/plural_rules/options.rs | 2 +- .../src/builtins/intl/segmenter/iterator.rs | 8 +- boa_engine/src/builtins/intl/segmenter/mod.rs | 20 +- .../src/builtins/intl/segmenter/segments.rs | 14 +- .../iterable/async_from_sync_iterator.rs | 10 +- boa_engine/src/builtins/iterable/mod.rs | 24 +-- boa_engine/src/builtins/json/mod.rs | 16 +- boa_engine/src/builtins/map/map_iterator.rs | 8 +- boa_engine/src/builtins/map/mod.rs | 40 ++-- boa_engine/src/builtins/math/mod.rs | 202 +++--------------- boa_engine/src/builtins/mod.rs | 6 +- boa_engine/src/builtins/number/globals.rs | 16 +- boa_engine/src/builtins/number/mod.rs | 26 +-- .../src/builtins/object/for_in_iterator.rs | 8 +- boa_engine/src/builtins/object/mod.rs | 94 ++++---- boa_engine/src/builtins/options.rs | 10 +- boa_engine/src/builtins/promise/mod.rs | 62 +++--- boa_engine/src/builtins/proxy/mod.rs | 8 +- boa_engine/src/builtins/reflect/mod.rs | 42 ++-- boa_engine/src/builtins/regexp/mod.rs | 58 +++-- .../builtins/regexp/regexp_string_iterator.rs | 4 +- boa_engine/src/builtins/set/mod.rs | 28 ++- boa_engine/src/builtins/set/set_iterator.rs | 8 +- boa_engine/src/builtins/string/mod.rs | 156 +++++--------- .../src/builtins/string/string_iterator.rs | 4 +- boa_engine/src/builtins/symbol/mod.rs | 26 +-- .../src/builtins/temporal/calendar/mod.rs | 132 ++++-------- .../src/builtins/temporal/duration/mod.rs | 60 +++--- .../src/builtins/temporal/duration/record.rs | 12 +- boa_engine/src/builtins/temporal/fields.rs | 32 +-- .../src/builtins/temporal/instant/mod.rs | 38 ++-- boa_engine/src/builtins/temporal/mod.rs | 19 +- boa_engine/src/builtins/temporal/now.rs | 22 +- boa_engine/src/builtins/temporal/options.rs | 4 +- .../src/builtins/temporal/plain_date/mod.rs | 66 +++--- .../builtins/temporal/plain_date_time/mod.rs | 28 +-- .../builtins/temporal/plain_month_day/mod.rs | 4 +- .../src/builtins/temporal/plain_time/mod.rs | 2 +- .../builtins/temporal/plain_year_month/mod.rs | 36 ++-- .../src/builtins/temporal/time_zone/mod.rs | 30 ++- .../builtins/temporal/zoned_date_time/mod.rs | 2 +- .../src/builtins/typed_array/builtin.rs | 130 +++++------ .../src/builtins/typed_array/element/mod.rs | 4 +- boa_engine/src/builtins/typed_array/mod.rs | 4 +- boa_engine/src/builtins/uri/mod.rs | 8 +- boa_engine/src/builtins/weak/weak_ref.rs | 8 +- boa_engine/src/builtins/weak_map/mod.rs | 10 +- boa_engine/src/builtins/weak_set/mod.rs | 8 +- boa_engine/src/bytecompiler/class.rs | 2 +- .../declaration/declaration_pattern.rs | 2 +- boa_engine/src/bytecompiler/declarations.rs | 2 +- boa_engine/src/bytecompiler/env.rs | 2 +- .../src/bytecompiler/expression/assign.rs | 2 +- .../src/bytecompiler/expression/binary.rs | 2 +- boa_engine/src/bytecompiler/expression/mod.rs | 2 +- .../bytecompiler/expression/object_literal.rs | 2 +- .../src/bytecompiler/expression/unary.rs | 2 +- .../src/bytecompiler/expression/update.rs | 2 +- boa_engine/src/bytecompiler/function.rs | 2 +- boa_engine/src/bytecompiler/jump_control.rs | 8 +- boa_engine/src/bytecompiler/mod.rs | 14 +- boa_engine/src/bytecompiler/module.rs | 2 +- .../src/bytecompiler/statement/block.rs | 2 +- .../src/bytecompiler/statement/break.rs | 2 +- .../src/bytecompiler/statement/continue.rs | 2 +- boa_engine/src/bytecompiler/statement/if.rs | 2 +- .../src/bytecompiler/statement/labelled.rs | 2 +- boa_engine/src/bytecompiler/statement/loop.rs | 2 +- boa_engine/src/bytecompiler/statement/mod.rs | 2 +- .../src/bytecompiler/statement/switch.rs | 2 +- boa_engine/src/bytecompiler/statement/try.rs | 2 +- boa_engine/src/bytecompiler/statement/with.rs | 2 +- boa_engine/src/bytecompiler/utils.rs | 2 +- boa_engine/src/class.rs | 18 +- boa_engine/src/context/hooks.rs | 28 +-- boa_engine/src/context/icu.rs | 50 +++-- boa_engine/src/context/maybe_shared.rs | 42 ---- boa_engine/src/context/mod.rs | 190 ++++++---------- boa_engine/src/environments/runtime/mod.rs | 2 +- boa_engine/src/error.rs | 10 +- boa_engine/src/job.rs | 42 ++-- boa_engine/src/lib.rs | 16 +- boa_engine/src/module/loader.rs | 20 +- boa_engine/src/module/mod.rs | 29 ++- boa_engine/src/module/source.rs | 20 +- boa_engine/src/module/synthetic.rs | 26 +-- boa_engine/src/native_function.rs | 38 ++-- boa_engine/src/object/builtins/jsarray.rs | 66 +++--- .../src/object/builtins/jsarraybuffer.rs | 8 +- boa_engine/src/object/builtins/jsdataview.rs | 50 ++--- boa_engine/src/object/builtins/jsdate.rs | 126 +++++------ boa_engine/src/object/builtins/jsfunction.rs | 2 +- boa_engine/src/object/builtins/jsgenerator.rs | 8 +- boa_engine/src/object/builtins/jsmap.rs | 28 +-- .../src/object/builtins/jsmap_iterator.rs | 4 +- boa_engine/src/object/builtins/jspromise.rs | 30 +-- boa_engine/src/object/builtins/jsproxy.rs | 8 +- boa_engine/src/object/builtins/jsregexp.rs | 28 +-- boa_engine/src/object/builtins/jsset.rs | 22 +- .../src/object/builtins/jsset_iterator.rs | 4 +- .../object/builtins/jssharedarraybuffer.rs | 6 +- .../src/object/builtins/jstypedarray.rs | 60 +++--- .../src/object/internal_methods/arguments.rs | 10 +- .../src/object/internal_methods/array.rs | 4 +- .../object/internal_methods/bound_function.rs | 4 +- .../src/object/internal_methods/function.rs | 8 +- .../internal_methods/immutable_prototype.rs | 2 +- .../internal_methods/integer_indexed.rs | 16 +- boa_engine/src/object/internal_methods/mod.rs | 85 ++++---- .../internal_methods/module_namespace.rs | 22 +- .../src/object/internal_methods/proxy.rs | 29 ++- .../src/object/internal_methods/string.rs | 6 +- boa_engine/src/object/jsobject.rs | 9 +- boa_engine/src/object/mod.rs | 25 +-- boa_engine/src/object/operations.rs | 84 +++----- boa_engine/src/optimizer/mod.rs | 10 +- .../src/optimizer/pass/constant_folding.rs | 10 +- boa_engine/src/script.rs | 12 +- .../src/value/conversions/serde_json.rs | 4 +- .../src/value/conversions/try_from_js.rs | 40 ++-- boa_engine/src/value/equality.rs | 2 +- boa_engine/src/value/mod.rs | 47 ++-- boa_engine/src/value/operations.rs | 38 ++-- boa_engine/src/vm/code_block.rs | 7 +- boa_engine/src/vm/mod.rs | 10 +- boa_engine/src/vm/opcode/arguments.rs | 4 +- boa_engine/src/vm/opcode/await/mod.rs | 6 +- .../src/vm/opcode/binary_ops/logical.rs | 6 +- .../src/vm/opcode/binary_ops/macro_defined.rs | 2 +- boa_engine/src/vm/opcode/binary_ops/mod.rs | 18 +- boa_engine/src/vm/opcode/call/mod.rs | 22 +- boa_engine/src/vm/opcode/concat/mod.rs | 8 +- boa_engine/src/vm/opcode/control_flow/jump.rs | 12 +- .../src/vm/opcode/control_flow/return.rs | 8 +- .../src/vm/opcode/control_flow/throw.rs | 16 +- boa_engine/src/vm/opcode/copy/mod.rs | 8 +- .../src/vm/opcode/define/class/getter.rs | 20 +- .../src/vm/opcode/define/class/method.rs | 20 +- .../src/vm/opcode/define/class/setter.rs | 20 +- boa_engine/src/vm/opcode/define/mod.rs | 32 +-- .../src/vm/opcode/define/own_property.rs | 10 +- boa_engine/src/vm/opcode/delete/mod.rs | 20 +- boa_engine/src/vm/opcode/dup/mod.rs | 2 +- boa_engine/src/vm/opcode/environment/mod.rs | 20 +- boa_engine/src/vm/opcode/generator/mod.rs | 12 +- .../src/vm/opcode/generator/yield_stm.rs | 4 +- boa_engine/src/vm/opcode/get/argument.rs | 8 +- boa_engine/src/vm/opcode/get/function.rs | 8 +- boa_engine/src/vm/opcode/get/name.rs | 32 +-- boa_engine/src/vm/opcode/get/private.rs | 8 +- boa_engine/src/vm/opcode/get/property.rs | 12 +- boa_engine/src/vm/opcode/iteration/for_in.rs | 2 +- boa_engine/src/vm/opcode/iteration/get.rs | 4 +- .../src/vm/opcode/iteration/iterator.rs | 24 +-- .../src/vm/opcode/iteration/loop_ops.rs | 2 +- boa_engine/src/vm/opcode/meta/mod.rs | 4 +- boa_engine/src/vm/opcode/mod.rs | 16 +- boa_engine/src/vm/opcode/modifier.rs | 8 +- boa_engine/src/vm/opcode/new/mod.rs | 10 +- boa_engine/src/vm/opcode/nop/mod.rs | 8 +- boa_engine/src/vm/opcode/pop/mod.rs | 4 +- boa_engine/src/vm/opcode/push/array.rs | 8 +- boa_engine/src/vm/opcode/push/class/field.rs | 10 +- boa_engine/src/vm/opcode/push/class/mod.rs | 2 +- .../src/vm/opcode/push/class/private.rs | 24 +-- boa_engine/src/vm/opcode/push/environment.rs | 14 +- boa_engine/src/vm/opcode/push/literal.rs | 16 +- boa_engine/src/vm/opcode/push/mod.rs | 2 +- boa_engine/src/vm/opcode/push/numbers.rs | 4 +- boa_engine/src/vm/opcode/push/object.rs | 2 +- boa_engine/src/vm/opcode/require/mod.rs | 2 +- .../src/vm/opcode/rest_parameter/mod.rs | 2 +- .../src/vm/opcode/set/class_prototype.rs | 2 +- boa_engine/src/vm/opcode/set/home_object.rs | 2 +- boa_engine/src/vm/opcode/set/name.rs | 20 +- boa_engine/src/vm/opcode/set/private.rs | 40 ++-- boa_engine/src/vm/opcode/set/property.rs | 32 +-- boa_engine/src/vm/opcode/set/prototype.rs | 2 +- boa_engine/src/vm/opcode/swap/mod.rs | 6 +- boa_engine/src/vm/opcode/switch/mod.rs | 4 +- boa_engine/src/vm/opcode/templates/mod.rs | 10 +- boa_engine/src/vm/opcode/to/mod.rs | 4 +- .../src/vm/opcode/unary_ops/decrement.rs | 4 +- .../src/vm/opcode/unary_ops/increment.rs | 4 +- boa_engine/src/vm/opcode/unary_ops/logical.rs | 2 +- boa_engine/src/vm/opcode/unary_ops/mod.rs | 8 +- boa_engine/src/vm/opcode/unary_ops/void.rs | 2 +- boa_engine/src/vm/opcode/value/mod.rs | 4 +- boa_examples/src/bin/classes.rs | 6 +- boa_examples/src/bin/futures.rs | 18 +- boa_examples/src/bin/jsdate.rs | 6 +- boa_examples/src/bin/loadfile.rs | 2 +- boa_examples/src/bin/modulehandler.rs | 4 +- boa_examples/src/bin/modules.rs | 13 +- boa_examples/src/bin/synthetic.rs | 10 +- boa_runtime/src/console/mod.rs | 50 ++--- boa_runtime/src/lib.rs | 12 +- boa_tester/src/exec/js262.rs | 18 +- boa_tester/src/exec/mod.rs | 47 ++-- 249 files changed, 2014 insertions(+), 2701 deletions(-) delete mode 100644 boa_engine/src/context/maybe_shared.rs diff --git a/boa_cli/src/debug/function.rs b/boa_cli/src/debug/function.rs index 9bb2c8ee0f0..2f3212e8112 100644 --- a/boa_cli/src/debug/function.rs +++ b/boa_cli/src/debug/function.rs @@ -51,7 +51,7 @@ fn flowgraph_parse_direction_option(value: &JsValue) -> JsResult { } /// Get functions instruction flowgraph -fn flowgraph(_this: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult { +fn flowgraph(_this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let Some(value) = args.get(0) else { return Err(JsNativeError::typ() .with_message("expected function argument") @@ -101,7 +101,7 @@ fn flowgraph(_this: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> Js Ok(JsValue::new(js_string!(result))) } -fn bytecode(_: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult { +fn bytecode(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let Some(value) = args.get(0) else { return Err(JsNativeError::typ() .with_message("expected function argument") @@ -137,7 +137,7 @@ fn set_trace_flag_in_function_object(object: &JsObject, value: bool) -> JsResult } /// Trace function. -fn trace(_: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult { +fn trace(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let value = args.get_or_undefined(0); let this = args.get_or_undefined(1); @@ -156,7 +156,7 @@ fn trace(_: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult) -> JsResult { +fn traceable(_: &JsValue, args: &[JsValue], _: &mut Context) -> JsResult { let value = args.get_or_undefined(0); let traceable = args.get_or_undefined(1).to_boolean(); @@ -171,7 +171,7 @@ fn traceable(_: &JsValue, args: &[JsValue], _: &mut Context<'_>) -> JsResult) -> JsObject { +pub(super) fn create_object(context: &mut Context) -> JsObject { ObjectInitializer::new(context) .function( NativeFunction::from_fn_ptr(flowgraph), diff --git a/boa_cli/src/debug/gc.rs b/boa_cli/src/debug/gc.rs index 69f3a08cdc7..746fd899403 100644 --- a/boa_cli/src/debug/gc.rs +++ b/boa_cli/src/debug/gc.rs @@ -3,12 +3,12 @@ use boa_engine::{ }; /// Trigger garbage collection. -fn collect(_: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { +fn collect(_: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { boa_gc::force_collect(); Ok(JsValue::undefined()) } -pub(super) fn create_object(context: &mut Context<'_>) -> JsObject { +pub(super) fn create_object(context: &mut Context) -> JsObject { ObjectInitializer::new(context) .function( NativeFunction::from_fn_ptr(collect), diff --git a/boa_cli/src/debug/limits.rs b/boa_cli/src/debug/limits.rs index b0dfe8beaaa..1f1868454e9 100644 --- a/boa_cli/src/debug/limits.rs +++ b/boa_cli/src/debug/limits.rs @@ -5,23 +5,23 @@ use boa_engine::{ Context, JsArgs, JsNativeError, JsObject, JsResult, JsValue, NativeFunction, }; -fn get_loop(_: &JsValue, _: &[JsValue], context: &mut Context<'_>) -> JsResult { +fn get_loop(_: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { let max = context.runtime_limits().loop_iteration_limit(); Ok(JsValue::from(max)) } -fn set_loop(_: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult { +fn set_loop(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let value = args.get_or_undefined(0).to_length(context)?; context.runtime_limits_mut().set_loop_iteration_limit(value); Ok(JsValue::undefined()) } -fn get_stack(_: &JsValue, _: &[JsValue], context: &mut Context<'_>) -> JsResult { +fn get_stack(_: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { let max = context.runtime_limits().stack_size_limit(); Ok(JsValue::from(max)) } -fn set_stack(_: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult { +fn set_stack(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let value = args.get_or_undefined(0).to_length(context)?; let Ok(value) = value.try_into() else { return Err(JsNativeError::range() @@ -32,12 +32,12 @@ fn set_stack(_: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResu Ok(JsValue::undefined()) } -fn get_recursion(_: &JsValue, _: &[JsValue], context: &mut Context<'_>) -> JsResult { +fn get_recursion(_: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { let max = context.runtime_limits().recursion_limit(); Ok(JsValue::from(max)) } -fn set_recursion(_: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult { +fn set_recursion(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let value = args.get_or_undefined(0).to_length(context)?; let Ok(value) = value.try_into() else { return Err(JsNativeError::range() @@ -48,7 +48,7 @@ fn set_recursion(_: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> Js Ok(JsValue::undefined()) } -pub(super) fn create_object(context: &mut Context<'_>) -> JsObject { +pub(super) fn create_object(context: &mut Context) -> JsObject { let get_loop = FunctionObjectBuilder::new(context.realm(), NativeFunction::from_fn_ptr(get_loop)) .name("get loop") diff --git a/boa_cli/src/debug/mod.rs b/boa_cli/src/debug/mod.rs index 34e82a0ee0d..0e62caf3c8e 100644 --- a/boa_cli/src/debug/mod.rs +++ b/boa_cli/src/debug/mod.rs @@ -11,7 +11,7 @@ mod optimizer; mod realm; mod shape; -fn create_boa_object(context: &mut Context<'_>) -> JsObject { +fn create_boa_object(context: &mut Context) -> JsObject { let function_module = function::create_object(context); let object_module = object::create_object(context); let shape_module = shape::create_object(context); @@ -60,7 +60,7 @@ fn create_boa_object(context: &mut Context<'_>) -> JsObject { } #[allow(clippy::redundant_pub_crate)] -pub(crate) fn init_boa_debug_object(context: &mut Context<'_>) { +pub(crate) fn init_boa_debug_object(context: &mut Context) { let boa_object = create_boa_object(context); context .register_global_property( diff --git a/boa_cli/src/debug/object.rs b/boa_cli/src/debug/object.rs index 441d89b5acb..882f513b16d 100644 --- a/boa_cli/src/debug/object.rs +++ b/boa_cli/src/debug/object.rs @@ -4,7 +4,7 @@ use boa_engine::{ }; /// Returns objects pointer in memory. -fn id(_: &JsValue, args: &[JsValue], _: &mut Context<'_>) -> JsResult { +fn id(_: &JsValue, args: &[JsValue], _: &mut Context) -> JsResult { let Some(value) = args.get(0) else { return Err(JsNativeError::typ() .with_message("expected object argument") @@ -21,7 +21,7 @@ fn id(_: &JsValue, args: &[JsValue], _: &mut Context<'_>) -> JsResult { Ok(js_string!(format!("0x{:X}", ptr as usize)).into()) } -pub(super) fn create_object(context: &mut Context<'_>) -> JsObject { +pub(super) fn create_object(context: &mut Context) -> JsObject { ObjectInitializer::new(context) .function(NativeFunction::from_fn_ptr(id), js_string!("id"), 1) .build() diff --git a/boa_cli/src/debug/optimizer.rs b/boa_cli/src/debug/optimizer.rs index e7e2679c870..92793e93ba0 100644 --- a/boa_cli/src/debug/optimizer.rs +++ b/boa_cli/src/debug/optimizer.rs @@ -6,22 +6,14 @@ use boa_engine::{ Context, JsArgs, JsObject, JsResult, JsValue, NativeFunction, }; -fn get_constant_folding( - _: &JsValue, - _: &[JsValue], - context: &mut Context<'_>, -) -> JsResult { +fn get_constant_folding(_: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { Ok(context .optimizer_options() .contains(OptimizerOptions::CONSTANT_FOLDING) .into()) } -fn set_constant_folding( - _: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, -) -> JsResult { +fn set_constant_folding(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let value = args.get_or_undefined(0).to_boolean(); let mut options = context.optimizer_options(); options.set(OptimizerOptions::CONSTANT_FOLDING, value); @@ -29,14 +21,14 @@ fn set_constant_folding( Ok(JsValue::undefined()) } -fn get_statistics(_: &JsValue, _: &[JsValue], context: &mut Context<'_>) -> JsResult { +fn get_statistics(_: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { Ok(context .optimizer_options() .contains(OptimizerOptions::STATISTICS) .into()) } -fn set_statistics(_: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult { +fn set_statistics(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let value = args.get_or_undefined(0).to_boolean(); let mut options = context.optimizer_options(); options.set(OptimizerOptions::STATISTICS, value); @@ -44,7 +36,7 @@ fn set_statistics(_: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> J Ok(JsValue::undefined()) } -pub(super) fn create_object(context: &mut Context<'_>) -> JsObject { +pub(super) fn create_object(context: &mut Context) -> JsObject { let get_constant_folding = FunctionObjectBuilder::new( context.realm(), NativeFunction::from_fn_ptr(get_constant_folding), diff --git a/boa_cli/src/debug/realm.rs b/boa_cli/src/debug/realm.rs index efe5ccbbddb..9b429e45fc5 100644 --- a/boa_cli/src/debug/realm.rs +++ b/boa_cli/src/debug/realm.rs @@ -3,13 +3,13 @@ use boa_engine::{ }; /// Creates a new ECMAScript Realm and returns the global object of the realm. -fn create(_: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { +fn create(_: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { let context = &mut Context::default(); Ok(context.global_object().into()) } -pub(super) fn create_object(context: &mut Context<'_>) -> JsObject { +pub(super) fn create_object(context: &mut Context) -> JsObject { ObjectInitializer::new(context) .function(NativeFunction::from_fn_ptr(create), js_string!("create"), 0) .build() diff --git a/boa_cli/src/debug/shape.rs b/boa_cli/src/debug/shape.rs index 90844415a6a..24a6ff14d45 100644 --- a/boa_cli/src/debug/shape.rs +++ b/boa_cli/src/debug/shape.rs @@ -19,7 +19,7 @@ fn get_object(args: &[JsValue], position: usize) -> JsResult<&JsObject> { } /// Returns object's shape pointer in memory. -fn id(_: &JsValue, args: &[JsValue], _: &mut Context<'_>) -> JsResult { +fn id(_: &JsValue, args: &[JsValue], _: &mut Context) -> JsResult { let object = get_object(args, 0)?; let object = object.borrow(); let shape = object.shape(); @@ -27,7 +27,7 @@ fn id(_: &JsValue, args: &[JsValue], _: &mut Context<'_>) -> JsResult { } /// Returns object's shape type. -fn r#type(_: &JsValue, args: &[JsValue], _: &mut Context<'_>) -> JsResult { +fn r#type(_: &JsValue, args: &[JsValue], _: &mut Context) -> JsResult { let object = get_object(args, 0)?; let object = object.borrow(); let shape = object.shape(); @@ -41,7 +41,7 @@ fn r#type(_: &JsValue, args: &[JsValue], _: &mut Context<'_>) -> JsResult) -> JsResult { +fn same(_: &JsValue, args: &[JsValue], _: &mut Context) -> JsResult { let lhs = get_object(args, 0)?; let rhs = get_object(args, 1)?; @@ -60,7 +60,7 @@ fn same(_: &JsValue, args: &[JsValue], _: &mut Context<'_>) -> JsResult Ok(JsValue::new(lhs_shape_ptr == rhs_shape_ptr)) } -pub(super) fn create_object(context: &mut Context<'_>) -> JsObject { +pub(super) fn create_object(context: &mut Context) -> JsObject { ObjectInitializer::new(context) .function(NativeFunction::from_fn_ptr(id), js_string!("id"), 1) .function(NativeFunction::from_fn_ptr(r#type), js_string!("type"), 1) diff --git a/boa_cli/src/main.rs b/boa_cli/src/main.rs index 073613eafe6..a8187739c07 100644 --- a/boa_cli/src/main.rs +++ b/boa_cli/src/main.rs @@ -67,7 +67,7 @@ use boa_engine::{ context::ContextBuilder, job::{FutureJob, JobQueue, NativeJob}, js_string, - module::{Module, ModuleLoader, SimpleModuleLoader}, + module::{Module, SimpleModuleLoader}, optimizer::OptimizerOptions, property::Attribute, script::Script, @@ -81,7 +81,7 @@ use debug::init_boa_debug_object; use rustyline::{config::Config, error::ReadlineError, EditMode, Editor}; use std::{ cell::RefCell, collections::VecDeque, eprintln, fs::read, fs::OpenOptions, io, path::PathBuf, - println, + println, rc::Rc, }; #[cfg(all( @@ -233,7 +233,7 @@ enum FlowgraphDirection { /// /// Returns a error of type String with a error message, /// if the source has a syntax or parsing error. -fn dump(src: &S, args: &Opt, context: &mut Context<'_>) -> Result<(), String> +fn dump(src: &S, args: &Opt, context: &mut Context) -> Result<(), String> where S: AsRef<[u8]> + ?Sized, { @@ -278,7 +278,7 @@ where } fn generate_flowgraph( - context: &mut Context<'_>, + context: &mut Context, src: &[u8], format: FlowgraphFormat, direction: Option, @@ -304,8 +304,8 @@ fn generate_flowgraph( fn evaluate_files( args: &Opt, - context: &mut Context<'_>, - loader: &SimpleModuleLoader, + context: &mut Context, + loader: Rc, ) -> Result<(), io::Error> { for file in &args.files { let buffer = read(file)?; @@ -382,13 +382,14 @@ fn main() -> Result<(), io::Error> { let args = Opt::parse(); - let queue: &dyn JobQueue = &Jobs::default(); - let loader = &SimpleModuleLoader::new(&args.root) - .map_err(|e| io::Error::new(io::ErrorKind::Other, e.to_string()))?; - let dyn_loader: &dyn ModuleLoader = loader; + let queue = Rc::new(Jobs::default()); + let loader = Rc::new( + SimpleModuleLoader::new(&args.root) + .map_err(|e| io::Error::new(io::ErrorKind::Other, e.to_string()))?, + ); let mut context = ContextBuilder::new() .job_queue(queue) - .module_loader(dyn_loader) + .module_loader(loader.clone()) .build() .expect("cannot fail with default global object"); @@ -491,7 +492,7 @@ fn main() -> Result<(), io::Error> { } /// Adds the CLI runtime to the context. -fn add_runtime(context: &mut Context<'_>) { +fn add_runtime(context: &mut Context) { let console = Console::init(context); context .register_global_property(js_string!(Console::NAME), console, Attribute::all()) @@ -502,11 +503,11 @@ fn add_runtime(context: &mut Context<'_>) { struct Jobs(RefCell>); impl JobQueue for Jobs { - fn enqueue_promise_job(&self, job: NativeJob, _: &mut Context<'_>) { + fn enqueue_promise_job(&self, job: NativeJob, _: &mut Context) { self.0.borrow_mut().push_back(job); } - fn run_jobs(&self, context: &mut Context<'_>) { + fn run_jobs(&self, context: &mut Context) { loop { let jobs = std::mem::take(&mut *self.0.borrow_mut()); if jobs.is_empty() { @@ -520,7 +521,7 @@ impl JobQueue for Jobs { } } - fn enqueue_future_job(&self, future: FutureJob, _: &mut Context<'_>) { + fn enqueue_future_job(&self, future: FutureJob, _: &mut Context) { let job = pollster::block_on(future); self.0.borrow_mut().push_back(job); } diff --git a/boa_engine/src/builtins/array/array_iterator.rs b/boa_engine/src/builtins/array/array_iterator.rs index bd8196b5220..ca78d810170 100644 --- a/boa_engine/src/builtins/array/array_iterator.rs +++ b/boa_engine/src/builtins/array/array_iterator.rs @@ -83,7 +83,7 @@ impl ArrayIterator { pub(crate) fn create_array_iterator( array: JsObject, kind: PropertyNameKind, - context: &Context<'_>, + context: &Context, ) -> JsValue { let array_iterator = JsObject::from_proto_and_data_with_shared_shape( context.root_shape(), @@ -101,11 +101,7 @@ impl ArrayIterator { /// - [ECMA reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-%arrayiteratorprototype%.next - pub(crate) fn next( - this: &JsValue, - _: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn next(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { let mut array_iterator = this.as_object().map(JsObject::borrow_mut); let array_iterator = array_iterator .as_mut() diff --git a/boa_engine/src/builtins/array/mod.rs b/boa_engine/src/builtins/array/mod.rs index ba1efc4a0f5..c54ef3e4488 100644 --- a/boa_engine/src/builtins/array/mod.rs +++ b/boa_engine/src/builtins/array/mod.rs @@ -174,7 +174,7 @@ impl BuiltInConstructor for Array { fn constructor( new_target: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // If NewTarget is undefined, let newTarget be the active function object; else let newTarget be NewTarget. let new_target = &if new_target.is_undefined() { @@ -263,7 +263,7 @@ impl BuiltInConstructor for Array { impl Array { /// Optimized helper function, that sets the length of the array. - fn set_length(o: &JsObject, len: u64, context: &mut Context<'_>) -> JsResult<()> { + fn set_length(o: &JsObject, len: u64, context: &mut Context) -> JsResult<()> { if o.is_array() && len < (2u64.pow(32) - 1) { let mut borrowed_object = o.borrow_mut(); if borrowed_object.properties().shape.to_addr_usize() @@ -293,7 +293,7 @@ impl Array { pub(crate) fn array_create( length: u64, prototype: Option, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If length > 2^32 - 1, throw a RangeError exception. if length > 2u64.pow(32) - 1 { @@ -361,7 +361,7 @@ impl Array { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-createarrayfromlist - pub(crate) fn create_array_from_list(elements: I, context: &mut Context<'_>) -> JsObject + pub(crate) fn create_array_from_list(elements: I, context: &mut Context) -> JsObject where I: IntoIterator, { @@ -392,7 +392,7 @@ impl Array { /// Returns a Boolean valued property that if `true` indicates that /// an object should be flattened to its array elements /// by `Array.prototype.concat`. - fn is_concat_spreadable(o: &JsValue, context: &mut Context<'_>) -> JsResult { + fn is_concat_spreadable(o: &JsValue, context: &mut Context) -> JsResult { // 1. If Type(O) is not Object, return false. let Some(o) = o.as_object() else { return Ok(false); @@ -421,7 +421,7 @@ impl Array { /// [spec]: https://tc39.es/ecma262/#sec-get-array-@@species /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/@@species #[allow(clippy::unnecessary_wraps)] - fn get_species(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn get_species(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { // 1. Return the this value. Ok(this.clone()) } @@ -433,7 +433,7 @@ impl Array { pub(crate) fn array_species_create( original_array: &JsObject, length: u64, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let isArray be ? IsArray(originalArray). // 2. If isArray is false, return ? ArrayCreate(length). @@ -504,7 +504,7 @@ impl Array { pub(crate) fn from( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let items = args.get_or_undefined(0); let mapfn = args.get_or_undefined(1); @@ -653,7 +653,7 @@ impl Array { pub(crate) fn is_array( _: &JsValue, args: &[JsValue], - _context: &mut Context<'_>, + _context: &mut Context, ) -> JsResult { // 1. Return ? IsArray(arg). args.get_or_undefined(0).is_array().map(Into::into) @@ -670,11 +670,7 @@ impl Array { /// /// [spec]: https://tc39.es/ecma262/#sec-array.of /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of - pub(crate) fn of( - this: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn of(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let len be the number of elements in items. // 2. Let lenNumber be 𝔽(len). let len = args.len(); @@ -718,11 +714,7 @@ impl Array { /// /// [spec]: https://tc39.es/ecma262/#sec-array.prototype.at /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at - pub(crate) fn at( - this: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn at(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { //1. let O be ? ToObject(this value) let obj = this.to_object(context)?; //2. let len be ? LengthOfArrayLike(O) @@ -762,7 +754,7 @@ impl Array { pub(crate) fn concat( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? ToObject(this value). let obj = this.to_object(context)?; @@ -845,7 +837,7 @@ impl Array { pub(crate) fn push( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? ToObject(this value). let o = this.to_object(context)?; @@ -885,11 +877,7 @@ impl Array { /// /// [spec]: https://tc39.es/ecma262/#sec-array.prototype.pop /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/pop - pub(crate) fn pop( - this: &JsValue, - _: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn pop(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be ? ToObject(this value). let o = this.to_object(context)?; // 2. Let len be ? LengthOfArrayLike(O). @@ -932,7 +920,7 @@ impl Array { pub(crate) fn for_each( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? ToObject(this value). let o = this.to_object(context)?; @@ -978,7 +966,7 @@ impl Array { pub(crate) fn join( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? ToObject(this value). let o = this.to_object(context)?; @@ -1034,7 +1022,7 @@ impl Array { pub(crate) fn to_string( this: &JsValue, _: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let array be ? ToObject(this value). let array = this.to_object(context)?; @@ -1064,7 +1052,7 @@ impl Array { pub(crate) fn reverse( this: &JsValue, _: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? ToObject(this value). let o = this.to_object(context)?; @@ -1142,7 +1130,7 @@ impl Array { pub(crate) fn to_reversed( this: &JsValue, _: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? ToObject(this value). let o = this.to_object(context)?; @@ -1184,11 +1172,7 @@ impl Array { /// /// [spec]: https://tc39.es/ecma262/#sec-array.prototype.shift /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/shift - pub(crate) fn shift( - this: &JsValue, - _: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn shift(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be ? ToObject(this value). let o = this.to_object(context)?; // 2. Let len be ? LengthOfArrayLike(O). @@ -1265,7 +1249,7 @@ impl Array { pub(crate) fn unshift( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? ToObject(this value). let o = this.to_object(context)?; @@ -1337,7 +1321,7 @@ impl Array { pub(crate) fn every( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? ToObject(this value). let o = this.to_object(context)?; @@ -1389,7 +1373,7 @@ impl Array { pub(crate) fn map( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? ToObject(this value). let o = this.to_object(context)?; @@ -1438,7 +1422,7 @@ impl Array { pub(crate) fn index_of( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? ToObject(this value). let o = this.to_object(context)?; @@ -1525,7 +1509,7 @@ impl Array { pub(crate) fn last_index_of( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? ToObject(this value). let o = this.to_object(context)?; @@ -1595,7 +1579,7 @@ impl Array { pub(crate) fn find( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? ToObject(this value). let o = this.to_object(context)?; @@ -1636,7 +1620,7 @@ impl Array { pub(crate) fn find_index( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? ToObject(this value). let o = this.to_object(context)?; @@ -1675,7 +1659,7 @@ impl Array { pub(crate) fn find_last( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? ToObject(this value). let o = this.to_object(context)?; @@ -1714,7 +1698,7 @@ impl Array { pub(crate) fn find_last_index( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? ToObject(this value). let o = this.to_object(context)?; @@ -1754,7 +1738,7 @@ impl Array { pub(crate) fn flat( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ToObject(this value) let o = this.to_object(context)?; @@ -1810,7 +1794,7 @@ impl Array { pub(crate) fn flat_map( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ToObject(this value) let o = this.to_object(context)?; @@ -1857,7 +1841,7 @@ impl Array { depth: u64, mapper_function: Option<&JsObject>, this_arg: &JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Assert target is Object // 2. Assert source is Object @@ -1970,7 +1954,7 @@ impl Array { pub(crate) fn fill( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? ToObject(this value). let o = this.to_object(context)?; @@ -2018,7 +2002,7 @@ impl Array { pub(crate) fn includes_value( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? ToObject(this value). let o = this.to_object(context)?; @@ -2095,7 +2079,7 @@ impl Array { pub(crate) fn slice( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? ToObject(this value). let o = this.to_object(context)?; @@ -2163,7 +2147,7 @@ impl Array { pub(crate) fn to_locale_string( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let array be ? ToObject(this value). let array = this.to_object(context)?; @@ -2221,7 +2205,7 @@ impl Array { actual_start: u64, start: Option<&JsValue>, delete_count: Option<&JsValue>, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 8. If start is not present, then let actual_delete_count = if start.is_none() { @@ -2260,7 +2244,7 @@ impl Array { pub(crate) fn splice( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? ToObject(this value). let o = this.to_object(context)?; @@ -2400,11 +2384,7 @@ impl Array { /// Splices the target array, returning the result as a new array. /// /// [spec]: https://tc39.es/ecma262/#sec-array.prototype.tospliced - fn to_spliced( - this: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + fn to_spliced(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be ? ToObject(this value). let o = this.to_object(context)?; @@ -2506,7 +2486,7 @@ impl Array { pub(crate) fn filter( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? ToObject(this value). let o = this.to_object(context)?; @@ -2572,7 +2552,7 @@ impl Array { pub(crate) fn some( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? ToObject(this value). let o = this.to_object(context)?; @@ -2617,10 +2597,10 @@ impl Array { len: u64, sort_compare: F, skip_holes: bool, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult> where - F: Fn(&JsValue, &JsValue, &mut Context<'_>) -> JsResult, + F: Fn(&JsValue, &JsValue, &mut Context) -> JsResult, { // 1. Let items be a new empty List. // doesn't matter if it clamps since it's just a best-effort optimization @@ -2683,7 +2663,7 @@ impl Array { pub(crate) fn sort( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If comparefn is not undefined and IsCallable(comparefn) is false, throw a TypeError exception. let comparefn = match args.get_or_undefined(0) { @@ -2704,7 +2684,7 @@ impl Array { // 4. Let SortCompare be a new Abstract Closure with parameters (x, y) that captures comparefn and performs the following steps when called: let sort_compare = - |x: &JsValue, y: &JsValue, context: &mut Context<'_>| -> JsResult { + |x: &JsValue, y: &JsValue, context: &mut Context| -> JsResult { // a. Return ? CompareArrayElements(x, y, comparefn). compare_array_elements(x, y, comparefn, context) }; @@ -2746,7 +2726,7 @@ impl Array { pub(crate) fn to_sorted( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If comparefn is not undefined and IsCallable(comparefn) is false, throw a TypeError exception. let comparefn = match args.get_or_undefined(0) { @@ -2770,7 +2750,7 @@ impl Array { // 5. Let SortCompare be a new Abstract Closure with parameters (x, y) that captures comparefn and performs the following steps when called: let sort_compare = - |x: &JsValue, y: &JsValue, context: &mut Context<'_>| -> JsResult { + |x: &JsValue, y: &JsValue, context: &mut Context| -> JsResult { // a. Return ? CompareArrayElements(x, y, comparefn). compare_array_elements(x, y, comparefn, context) }; @@ -2803,7 +2783,7 @@ impl Array { pub(crate) fn reduce( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? ToObject(this value). let o = this.to_object(context)?; @@ -2900,7 +2880,7 @@ impl Array { pub(crate) fn reduce_right( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? ToObject(this value). let o = this.to_object(context)?; @@ -2994,7 +2974,7 @@ impl Array { pub(crate) fn copy_within( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? ToObject(this value). let o = this.to_object(context)?; @@ -3084,7 +3064,7 @@ impl Array { pub(crate) fn values( this: &JsValue, _: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? ToObject(this value). let o = this.to_object(context)?; @@ -3107,11 +3087,7 @@ impl Array { /// /// [spec]: https://tc39.es/ecma262/#sec-array.prototype.keys /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/values - pub(crate) fn keys( - this: &JsValue, - _: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn keys(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be ? ToObject(this value). let o = this.to_object(context)?; @@ -3136,7 +3112,7 @@ impl Array { pub(crate) fn entries( this: &JsValue, _: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? ToObject(this value). let o = this.to_object(context)?; @@ -3155,7 +3131,7 @@ impl Array { pub(crate) fn with( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? ToObject(this value). let o = this.to_object(context)?; @@ -3215,7 +3191,7 @@ impl Array { /// Represents the algorithm to calculate `relativeStart` (or `k`) in array functions. pub(super) fn get_relative_start( - context: &mut Context<'_>, + context: &mut Context, arg: &JsValue, len: u64, ) -> JsResult { @@ -3237,7 +3213,7 @@ impl Array { /// Represents the algorithm to calculate `relativeEnd` (or `final`) in array functions. pub(super) fn get_relative_end( - context: &mut Context<'_>, + context: &mut Context, value: &JsValue, len: u64, ) -> JsResult { @@ -3326,7 +3302,7 @@ fn compare_array_elements( x: &JsValue, y: &JsValue, comparefn: Option<&JsObject>, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { match (x.is_undefined(), y.is_undefined()) { // 1. If x and y are both undefined, return +0𝔽. @@ -3378,7 +3354,7 @@ pub(crate) fn find_via_predicate( direction: Direction, predicate: &JsValue, this_arg: &JsValue, - context: &mut Context<'_>, + context: &mut Context, caller_name: &str, ) -> JsResult<(JsValue, JsValue)> { // 1. If IsCallable(predicate) is false, throw a TypeError exception. diff --git a/boa_engine/src/builtins/array/tests.rs b/boa_engine/src/builtins/array/tests.rs index bef707afeb1..9f883439f54 100644 --- a/boa_engine/src/builtins/array/tests.rs +++ b/boa_engine/src/builtins/array/tests.rs @@ -873,7 +873,7 @@ fn array_spread_non_iterable() { #[test] fn get_relative_start() { #[track_caller] - fn assert(context: &mut Context<'_>, arg: Option<&JsValue>, len: u64, expected: u64) { + fn assert(context: &mut Context, arg: Option<&JsValue>, len: u64, expected: u64) { let arg = arg.unwrap_or(&JsValue::Undefined); assert_eq!( Array::get_relative_start(context, arg, len).unwrap(), @@ -900,7 +900,7 @@ fn get_relative_start() { #[test] fn get_relative_end() { #[track_caller] - fn assert(context: &mut Context<'_>, arg: Option<&JsValue>, len: u64, expected: u64) { + fn assert(context: &mut Context, arg: Option<&JsValue>, len: u64, expected: u64) { let arg = arg.unwrap_or(&JsValue::Undefined); assert_eq!( Array::get_relative_end(context, arg, len).unwrap(), diff --git a/boa_engine/src/builtins/array_buffer/mod.rs b/boa_engine/src/builtins/array_buffer/mod.rs index ede5583529c..00979161f79 100644 --- a/boa_engine/src/builtins/array_buffer/mod.rs +++ b/boa_engine/src/builtins/array_buffer/mod.rs @@ -192,7 +192,7 @@ impl BuiltInConstructor for ArrayBuffer { fn constructor( new_target: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If NewTarget is undefined, throw a TypeError exception. if new_target.is_undefined() { @@ -217,7 +217,7 @@ impl ArrayBuffer { /// /// [spec]: https://tc39.es/ecma262/#sec-get-arraybuffer-@@species #[allow(clippy::unnecessary_wraps)] - fn get_species(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn get_species(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { // 1. Return the this value. Ok(this.clone()) } @@ -229,7 +229,7 @@ impl ArrayBuffer { /// /// [spec]: https://tc39.es/ecma262/#sec-arraybuffer.isview #[allow(clippy::unnecessary_wraps)] - fn is_view(_: &JsValue, args: &[JsValue], _context: &mut Context<'_>) -> JsResult { + fn is_view(_: &JsValue, args: &[JsValue], _context: &mut Context) -> JsResult { // 1. If Type(arg) is not Object, return false. // 2. If arg has a [[ViewedArrayBuffer]] internal slot, return true. // 3. Return false. @@ -250,7 +250,7 @@ impl ArrayBuffer { pub(crate) fn get_byte_length( this: &JsValue, _args: &[JsValue], - _: &mut Context<'_>, + _: &mut Context, ) -> JsResult { // 1. Let O be the this value. // 2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]). @@ -275,7 +275,7 @@ impl ArrayBuffer { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-arraybuffer.prototype.slice - fn slice(this: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult { + fn slice(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be the this value. // 2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]). let obj = this.as_object().ok_or_else(|| { @@ -384,7 +384,7 @@ impl ArrayBuffer { pub(crate) fn allocate( constructor: &JsValue, byte_length: u64, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%ArrayBuffer.prototype%", « [[ArrayBufferData]], [[ArrayBufferByteLength]], [[ArrayBufferDetachKey]] »). let prototype = get_prototype_from_constructor( @@ -424,7 +424,7 @@ fn get_slice_range( len: u64, relative_start: &JsValue, end: &JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 5. Let len be O.[[ArrayBufferByteLength]]. @@ -471,8 +471,8 @@ fn get_slice_range( /// integer). For more information, check the [spec][spec]. /// /// [spec]: https://tc39.es/ecma262/#sec-createbytedatablock -pub(crate) fn create_byte_data_block(size: u64, context: &mut Context<'_>) -> JsResult> { - if size > context.host_hooks().max_buffer_size() { +pub(crate) fn create_byte_data_block(size: u64, context: &mut Context) -> JsResult> { + if size > context.host_hooks().max_buffer_size(context) { return Err(JsNativeError::range() .with_message( "cannot allocate a buffer that exceeds the maximum buffer size".to_string(), diff --git a/boa_engine/src/builtins/array_buffer/shared.rs b/boa_engine/src/builtins/array_buffer/shared.rs index 71238b45354..a40abcdfa1d 100644 --- a/boa_engine/src/builtins/array_buffer/shared.rs +++ b/boa_engine/src/builtins/array_buffer/shared.rs @@ -112,7 +112,7 @@ impl BuiltInConstructor for SharedArrayBuffer { fn constructor( new_target: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If NewTarget is undefined, throw a TypeError exception. if new_target.is_undefined() { @@ -137,7 +137,7 @@ impl SharedArrayBuffer { /// /// [spec]: https://tc39.es/ecma262/#sec-sharedarraybuffer-@@species #[allow(clippy::unnecessary_wraps)] - fn get_species(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn get_species(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { // 1. Return the this value. Ok(this.clone()) } @@ -151,7 +151,7 @@ impl SharedArrayBuffer { pub(crate) fn get_byte_length( this: &JsValue, _args: &[JsValue], - _: &mut Context<'_>, + _: &mut Context, ) -> JsResult { // 1. Let O be the this value. // 2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]). @@ -178,7 +178,7 @@ impl SharedArrayBuffer { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-sharedarraybuffer.prototype.slice - fn slice(this: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult { + fn slice(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be the this value. // 2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]). let obj = this.as_object().ok_or_else(|| { @@ -259,7 +259,7 @@ impl SharedArrayBuffer { pub(crate) fn allocate( constructor: &JsValue, byte_length: u64, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // TODO: // 1. Let slots be « [[ArrayBufferData]] ». @@ -315,9 +315,9 @@ impl SharedArrayBuffer { /// [spec]: https://tc39.es/ecma262/#sec-createsharedbytedatablock pub(crate) fn create_shared_byte_data_block( size: u64, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult>> { - if size > context.host_hooks().max_buffer_size() { + if size > context.host_hooks().max_buffer_size(context) { return Err(JsNativeError::range() .with_message( "cannot allocate a buffer that exceeds the maximum buffer size".to_string(), diff --git a/boa_engine/src/builtins/array_buffer/utils.rs b/boa_engine/src/builtins/array_buffer/utils.rs index e63a931a1bc..7a472b5a354 100644 --- a/boa_engine/src/builtins/array_buffer/utils.rs +++ b/boa_engine/src/builtins/array_buffer/utils.rs @@ -120,7 +120,7 @@ impl SliceRef<'_> { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-clonearraybuffer - pub(crate) fn clone(&self, context: &mut Context<'_>) -> JsResult { + pub(crate) fn clone(&self, context: &mut Context) -> JsResult { // 1. Assert: IsDetachedBuffer(srcBuffer) is false. // 2. Let targetBuffer be ? AllocateArrayBuffer(%ArrayBuffer%, srcLength). diff --git a/boa_engine/src/builtins/async_function/mod.rs b/boa_engine/src/builtins/async_function/mod.rs index 16674dec764..865510b4ea0 100644 --- a/boa_engine/src/builtins/async_function/mod.rs +++ b/boa_engine/src/builtins/async_function/mod.rs @@ -65,7 +65,7 @@ impl BuiltInConstructor for AsyncFunction { fn constructor( new_target: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let active_function = context.active_function_object().unwrap_or_else(|| { context diff --git a/boa_engine/src/builtins/async_generator/mod.rs b/boa_engine/src/builtins/async_generator/mod.rs index 74af1438a48..38fe1e3ed9a 100644 --- a/boa_engine/src/builtins/async_generator/mod.rs +++ b/boa_engine/src/builtins/async_generator/mod.rs @@ -117,7 +117,7 @@ impl AsyncGenerator { pub(crate) fn next( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let generator be the this value. let generator = this; @@ -205,7 +205,7 @@ impl AsyncGenerator { pub(crate) fn r#return( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let generator be the this value. let generator = this; @@ -283,7 +283,7 @@ impl AsyncGenerator { pub(crate) fn throw( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let generator be the this value. let generator = this; @@ -403,7 +403,7 @@ impl AsyncGenerator { completion: JsResult, done: bool, realm: Option, - context: &mut Context<'_>, + context: &mut Context, ) { // 1. Let queue be generator.[[AsyncGeneratorQueue]]. // 2. Assert: queue is not empty. @@ -465,7 +465,7 @@ impl AsyncGenerator { state: AsyncGeneratorState, mut generator_context: GeneratorContext, completion: CompletionRecord, - context: &mut Context<'_>, + context: &mut Context, ) { // 1. Assert: generator.[[AsyncGeneratorState]] is either suspendedStart or suspendedYield. assert!( @@ -516,7 +516,7 @@ impl AsyncGenerator { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-asyncgeneratorawaitreturn - pub(crate) fn await_return(generator: JsObject, value: JsValue, context: &mut Context<'_>) { + pub(crate) fn await_return(generator: JsObject, value: JsValue, context: &mut Context) { // 1. Let queue be generator.[[AsyncGeneratorQueue]]. // 2. Assert: queue is not empty. // 3. Let next be the first element of queue. @@ -639,7 +639,7 @@ impl AsyncGenerator { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-asyncgeneratordrainqueue - pub(crate) fn drain_queue(generator: &JsObject, context: &mut Context<'_>) { + pub(crate) fn drain_queue(generator: &JsObject, context: &mut Context) { let mut generator_borrow_mut = generator.borrow_mut(); let gen = generator_borrow_mut .as_async_generator_mut() diff --git a/boa_engine/src/builtins/async_generator_function/mod.rs b/boa_engine/src/builtins/async_generator_function/mod.rs index 8dd373bc2a6..975bb842cd3 100644 --- a/boa_engine/src/builtins/async_generator_function/mod.rs +++ b/boa_engine/src/builtins/async_generator_function/mod.rs @@ -70,7 +70,7 @@ impl BuiltInConstructor for AsyncGeneratorFunction { fn constructor( new_target: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let active_function = context.active_function_object().unwrap_or_else(|| { context diff --git a/boa_engine/src/builtins/atomics/mod.rs b/boa_engine/src/builtins/atomics/mod.rs index f3299b0fba6..1bf57715a80 100644 --- a/boa_engine/src/builtins/atomics/mod.rs +++ b/boa_engine/src/builtins/atomics/mod.rs @@ -78,7 +78,7 @@ impl BuiltInObject for Atomics { macro_rules! atomic_op { ($(#[$attr:meta])* $name:ident) => { - $(#[$attr])* fn $name(_: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult { + $(#[$attr])* fn $name(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let array = args.get_or_undefined(0); let index = args.get_or_undefined(1); @@ -145,7 +145,7 @@ impl Atomics { /// [`Atomics.isLockFree ( size )`][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-atomics.islockfree - fn is_lock_free(_: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult { + fn is_lock_free(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let n be ? ToIntegerOrInfinity(size). let n = args.get_or_undefined(0).to_integer_or_infinity(context)?; @@ -168,7 +168,7 @@ impl Atomics { /// [`Atomics.load ( typedArray, index )`][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-atomics.load - fn load(_: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult { + fn load(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let array = args.get_or_undefined(0); let index = args.get_or_undefined(1); @@ -201,7 +201,7 @@ impl Atomics { /// [`Atomics.store ( typedArray, index, value )`][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-atomics.store - fn store(_: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult { + fn store(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let array = args.get_or_undefined(0); let index = args.get_or_undefined(1); let value = args.get_or_undefined(2); @@ -253,11 +253,7 @@ impl Atomics { /// [`Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue )`][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-atomics.compareexchange - fn compare_exchange( - _: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + fn compare_exchange(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let array = args.get_or_undefined(0); let index = args.get_or_undefined(1); let expected = args.get_or_undefined(2); @@ -408,7 +404,7 @@ impl Atomics { /// [`Atomics.wait ( typedArray, index, value, timeout )`][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-atomics.wait - fn wait(_: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult { + fn wait(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let array = args.get_or_undefined(0); let index = args.get_or_undefined(1); let value = args.get_or_undefined(2); @@ -482,7 +478,7 @@ impl Atomics { /// [`Atomics.notify ( typedArray, index, count )`][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-atomics.notify - fn notify(_: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult { + fn notify(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let array = args.get_or_undefined(0); let index = args.get_or_undefined(1); let count = args.get_or_undefined(2); @@ -576,7 +572,7 @@ fn validate_integer_typed_array( fn validate_atomic_access( array: &IntegerIndexed, request_index: &JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let length be typedArray.[[ArrayLength]]. let length = array.array_length(); diff --git a/boa_engine/src/builtins/bigint/mod.rs b/boa_engine/src/builtins/bigint/mod.rs index 78d1b70a423..50132544bef 100644 --- a/boa_engine/src/builtins/bigint/mod.rs +++ b/boa_engine/src/builtins/bigint/mod.rs @@ -82,7 +82,7 @@ impl BuiltInConstructor for BigInt { fn constructor( new_target: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If NewTarget is not undefined, throw a TypeError exception. if !new_target.is_undefined() { @@ -170,7 +170,7 @@ impl BigInt { pub(crate) fn to_string( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let x be ? thisBigIntValue(this value). let x = Self::this_bigint_value(this)?; @@ -219,11 +219,7 @@ impl BigInt { /// /// [spec]: https://tc39.es/ecma262/#sec-bigint.prototype.valueof /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/valueOf - pub(crate) fn value_of( - this: &JsValue, - _: &[JsValue], - _: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn value_of(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Ok(JsValue::new(Self::this_bigint_value(this)?)) } @@ -237,7 +233,7 @@ impl BigInt { pub(crate) fn as_int_n( _: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let (modulo, bits) = Self::calculate_as_uint_n(args, context)?; @@ -263,7 +259,7 @@ impl BigInt { pub(crate) fn as_uint_n( _: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let (modulo, _) = Self::calculate_as_uint_n(args, context)?; @@ -275,10 +271,7 @@ impl BigInt { /// This function expects the same arguments as `as_uint_n` and wraps the value of a `BigInt`. /// Additionally to the wrapped unsigned value it returns the converted `bits` argument, so it /// can be reused from the `as_int_n` method. - fn calculate_as_uint_n( - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult<(JsBigInt, u32)> { + fn calculate_as_uint_n(args: &[JsValue], context: &mut Context) -> JsResult<(JsBigInt, u32)> { let bits_arg = args.get_or_undefined(0); let bigint_arg = args.get_or_undefined(1); diff --git a/boa_engine/src/builtins/boolean/mod.rs b/boa_engine/src/builtins/boolean/mod.rs index fcae01bb373..5325baca5ff 100644 --- a/boa_engine/src/builtins/boolean/mod.rs +++ b/boa_engine/src/builtins/boolean/mod.rs @@ -61,7 +61,7 @@ impl BuiltInConstructor for Boolean { fn constructor( new_target: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // Get the argument, if any let data = args.get(0).map_or(false, JsValue::to_boolean); @@ -107,11 +107,7 @@ impl Boolean { /// [spec]: https://tc39.es/ecma262/#sec-boolean-object /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean/toString #[allow(clippy::wrong_self_convention)] - pub(crate) fn to_string( - this: &JsValue, - _: &[JsValue], - _: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn to_string(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { let boolean = Self::this_boolean_value(this)?; Ok(JsValue::new(js_string!(boolean.to_string()))) } @@ -124,11 +120,7 @@ impl Boolean { /// /// [spec]: https://tc39.es/ecma262/#sec-boolean.prototype.valueof /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean/valueOf - pub(crate) fn value_of( - this: &JsValue, - _: &[JsValue], - _: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn value_of(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Ok(JsValue::new(Self::this_boolean_value(this)?)) } } diff --git a/boa_engine/src/builtins/dataview/mod.rs b/boa_engine/src/builtins/dataview/mod.rs index 92856fa2866..0d37c5a0188 100644 --- a/boa_engine/src/builtins/dataview/mod.rs +++ b/boa_engine/src/builtins/dataview/mod.rs @@ -131,7 +131,7 @@ impl BuiltInConstructor for DataView { fn constructor( new_target: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let byte_length = args.get_or_undefined(2); @@ -239,7 +239,7 @@ impl DataView { pub(crate) fn get_buffer( this: &JsValue, _args: &[JsValue], - _: &mut Context<'_>, + _: &mut Context, ) -> JsResult { // 1. Let O be the this value. // 2. Perform ? RequireInternalSlot(O, [[DataView]]). @@ -268,7 +268,7 @@ impl DataView { pub(crate) fn get_byte_length( this: &JsValue, _args: &[JsValue], - _: &mut Context<'_>, + _: &mut Context, ) -> JsResult { // 1. Let O be the this value. // 2. Perform ? RequireInternalSlot(O, [[DataView]]). @@ -309,7 +309,7 @@ impl DataView { pub(crate) fn get_byte_offset( this: &JsValue, _args: &[JsValue], - _: &mut Context<'_>, + _: &mut Context, ) -> JsResult { // 1. Let O be the this value. // 2. Perform ? RequireInternalSlot(O, [[DataView]]). @@ -350,7 +350,7 @@ impl DataView { view: &JsValue, request_index: &JsValue, is_little_endian: &JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Perform ? RequireInternalSlot(view, [[DataView]]). // 2. Assert: view has a [[ViewedArrayBuffer]] internal slot. @@ -431,7 +431,7 @@ impl DataView { pub(crate) fn get_big_int64( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let byte_offset = args.get_or_undefined(0); let is_little_endian = args.get_or_undefined(1); @@ -454,7 +454,7 @@ impl DataView { pub(crate) fn get_big_uint64( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let byte_offset = args.get_or_undefined(0); let is_little_endian = args.get_or_undefined(1); @@ -477,7 +477,7 @@ impl DataView { pub(crate) fn get_float32( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let byte_offset = args.get_or_undefined(0); let is_little_endian = args.get_or_undefined(1); @@ -500,7 +500,7 @@ impl DataView { pub(crate) fn get_float64( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let byte_offset = args.get_or_undefined(0); let is_little_endian = args.get_or_undefined(1); @@ -523,7 +523,7 @@ impl DataView { pub(crate) fn get_int8( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let byte_offset = args.get_or_undefined(0); let is_little_endian = args.get_or_undefined(1); @@ -546,7 +546,7 @@ impl DataView { pub(crate) fn get_int16( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let byte_offset = args.get_or_undefined(0); let is_little_endian = args.get_or_undefined(1); @@ -569,7 +569,7 @@ impl DataView { pub(crate) fn get_int32( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let byte_offset = args.get_or_undefined(0); let is_little_endian = args.get_or_undefined(1); @@ -592,7 +592,7 @@ impl DataView { pub(crate) fn get_uint8( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let byte_offset = args.get_or_undefined(0); let is_little_endian = args.get_or_undefined(1); @@ -615,7 +615,7 @@ impl DataView { pub(crate) fn get_uint16( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let byte_offset = args.get_or_undefined(0); let is_little_endian = args.get_or_undefined(1); @@ -638,7 +638,7 @@ impl DataView { pub(crate) fn get_uint32( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let byte_offset = args.get_or_undefined(0); let is_little_endian = args.get_or_undefined(1); @@ -662,7 +662,7 @@ impl DataView { request_index: &JsValue, is_little_endian: &JsValue, value: &JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Perform ? RequireInternalSlot(view, [[DataView]]). // 2. Assert: view has a [[ViewedArrayBuffer]] internal slot. @@ -745,7 +745,7 @@ impl DataView { pub(crate) fn set_big_int64( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let byte_offset = args.get_or_undefined(0); let value = args.get_or_undefined(1); @@ -769,7 +769,7 @@ impl DataView { pub(crate) fn set_big_uint64( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let byte_offset = args.get_or_undefined(0); let value = args.get_or_undefined(1); @@ -793,7 +793,7 @@ impl DataView { pub(crate) fn set_float32( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let byte_offset = args.get_or_undefined(0); let value = args.get_or_undefined(1); @@ -817,7 +817,7 @@ impl DataView { pub(crate) fn set_float64( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let byte_offset = args.get_or_undefined(0); let value = args.get_or_undefined(1); @@ -841,7 +841,7 @@ impl DataView { pub(crate) fn set_int8( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let byte_offset = args.get_or_undefined(0); let value = args.get_or_undefined(1); @@ -865,7 +865,7 @@ impl DataView { pub(crate) fn set_int16( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let byte_offset = args.get_or_undefined(0); let value = args.get_or_undefined(1); @@ -889,7 +889,7 @@ impl DataView { pub(crate) fn set_int32( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let byte_offset = args.get_or_undefined(0); let value = args.get_or_undefined(1); @@ -913,7 +913,7 @@ impl DataView { pub(crate) fn set_uint8( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let byte_offset = args.get_or_undefined(0); let value = args.get_or_undefined(1); @@ -937,7 +937,7 @@ impl DataView { pub(crate) fn set_uint16( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let byte_offset = args.get_or_undefined(0); let value = args.get_or_undefined(1); @@ -961,7 +961,7 @@ impl DataView { pub(crate) fn set_uint32( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let byte_offset = args.get_or_undefined(0); let value = args.get_or_undefined(1); diff --git a/boa_engine/src/builtins/date/mod.rs b/boa_engine/src/builtins/date/mod.rs index b25ddcc2960..c1f8c99e362 100644 --- a/boa_engine/src/builtins/date/mod.rs +++ b/boa_engine/src/builtins/date/mod.rs @@ -235,7 +235,7 @@ impl BuiltInConstructor for Date { fn constructor( new_target: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If NewTarget is undefined, then if new_target.is_undefined() { @@ -252,7 +252,7 @@ impl BuiltInConstructor for Date { // 3. If numberOfArgs = 0, then [] => { // a. Let dv be the time value (UTC) identifying the current time. - Self::utc_now(&*context.host_hooks()) + Self::utc_now(context.host_hooks()) } // 4. Else if numberOfArgs = 1, then // a. Let value be values[0]. @@ -328,7 +328,7 @@ impl Date { /// Gets the timestamp from a list of component values. fn construct_date( values: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult> { // 1. Let y be ? ToNumber(year). let Some(mut year) = values @@ -431,7 +431,7 @@ impl Date { /// [spec]: https://tc39.es/ecma262/#sec-date.now /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now #[allow(clippy::unnecessary_wraps)] - pub(crate) fn now(_: &JsValue, _: &[JsValue], context: &mut Context<'_>) -> JsResult { + pub(crate) fn now(_: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { Ok(JsValue::new( context.host_hooks().utc_now().timestamp_millis(), )) @@ -449,11 +449,7 @@ impl Date { /// /// [spec]: https://tc39.es/ecma262/#sec-date.parse /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse - pub(crate) fn parse( - _: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn parse(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // This method is implementation-defined and discouraged, so we just require the same format as the string // constructor. @@ -479,11 +475,7 @@ impl Date { /// /// [spec]: https://tc39.es/ecma262/#sec-date.utc /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/UTC - pub(crate) fn utc( - _: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn utc(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let t = some_or_nan!(Self::construct_date(args, context)?); Ok(JsValue::from(t.timestamp_millis())) @@ -499,7 +491,7 @@ impl Date { pub(crate) fn get_date( this: &JsValue, _args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let t be ? thisTimeValue(this value). let t = this_time_value(this)?; @@ -528,7 +520,7 @@ impl Date { pub(crate) fn get_day( this: &JsValue, _args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let t be ? thisTimeValue(this value). let t = this_time_value(this)?; @@ -560,7 +552,7 @@ impl Date { pub(crate) fn get_year( this: &JsValue, _args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let t be ? thisTimeValue(this value). let t = this_time_value(this)?; @@ -583,7 +575,7 @@ impl Date { pub(crate) fn get_full_year( this: &JsValue, _args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let t be ? thisTimeValue(this value). let t = this_time_value(this)?; @@ -611,7 +603,7 @@ impl Date { pub(crate) fn get_hours( this: &JsValue, _args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let t be ? thisTimeValue(this value). let t = this_time_value(this)?; @@ -639,7 +631,7 @@ impl Date { pub(crate) fn get_milliseconds( this: &JsValue, _args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let t be ? thisTimeValue(this value). let t = this_time_value(this)?; @@ -667,7 +659,7 @@ impl Date { pub(crate) fn get_minutes( this: &JsValue, _args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let t be ? thisTimeValue(this value). let t = this_time_value(this)?; @@ -696,7 +688,7 @@ impl Date { pub(crate) fn get_month( this: &JsValue, _args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let t be ? thisTimeValue(this value). let t = this_time_value(this)?; @@ -724,7 +716,7 @@ impl Date { pub(crate) fn get_seconds( this: &JsValue, _args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let t be ? thisTimeValue(this value). let t = this_time_value(this)?; @@ -755,7 +747,7 @@ impl Date { pub(crate) fn get_time( this: &JsValue, _args: &[JsValue], - _context: &mut Context<'_>, + _context: &mut Context, ) -> JsResult { // 1. Return ? thisTimeValue(this value). Ok(this_time_value(this)?.map_or(JsValue::nan(), JsValue::from)) @@ -775,7 +767,7 @@ impl Date { pub(crate) fn get_timezone_offset( this: &JsValue, _: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let t be ? thisTimeValue(this value). // 2. If t is NaN, return NaN. @@ -803,7 +795,7 @@ impl Date { pub(crate) fn set_date( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let t be LocalTime(? thisTimeValue(this value)). get_mut_date!(let t = this); @@ -823,7 +815,7 @@ impl Date { date: Some(date), ..Default::default() }, - &*context.host_hooks(), + context.host_hooks(), ); // 7. Set the [[DateValue]] internal slot of this Date object to u. @@ -844,7 +836,7 @@ impl Date { pub(crate) fn set_full_year( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let t be ? thisTimeValue(this value). get_mut_date!(let t = this); @@ -890,7 +882,7 @@ impl Date { date, ..Default::default() }, - &*context.host_hooks(), + context.host_hooks(), ); // 8. Set the [[DateValue]] internal slot of this Date object to u. @@ -912,7 +904,7 @@ impl Date { pub(crate) fn set_hours( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let t be ? thisTimeValue(this value). get_mut_date!(let t = this); @@ -956,7 +948,7 @@ impl Date { millisecond, ..Default::default() }, - &*context.host_hooks(), + context.host_hooks(), ); // 13. Set the [[DateValue]] internal slot of this Date object to u. @@ -976,7 +968,7 @@ impl Date { pub(crate) fn set_milliseconds( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let t be ? thisTimeValue(this value). // 1. Let t be LocalTime(? thisTimeValue(this value)). @@ -997,7 +989,7 @@ impl Date { millisecond: Some(ms), ..Default::default() }, - &*context.host_hooks(), + context.host_hooks(), ); // 7. Set the [[DateValue]] internal slot of this Date object to u. @@ -1017,7 +1009,7 @@ impl Date { pub(crate) fn set_minutes( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let t be ? thisTimeValue(this value). get_mut_date!(let t = this); @@ -1053,7 +1045,7 @@ impl Date { millisecond, ..Default::default() }, - &*context.host_hooks(), + context.host_hooks(), ); // 11. Set the [[DateValue]] internal slot of this Date object to u. @@ -1074,7 +1066,7 @@ impl Date { pub(crate) fn set_month( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let t be ? thisTimeValue(this value). get_mut_date!(let t = this); @@ -1102,7 +1094,7 @@ impl Date { date, ..Default::default() }, - &*context.host_hooks(), + context.host_hooks(), ); // 9. Set the [[DateValue]] internal slot of this Date object to u. @@ -1122,7 +1114,7 @@ impl Date { pub(crate) fn set_seconds( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let t be ? thisTimeValue(this value). get_mut_date!(let t = this); @@ -1150,7 +1142,7 @@ impl Date { millisecond, ..Default::default() }, - &*context.host_hooks(), + context.host_hooks(), ); // 9. Set the [[DateValue]] internal slot of this Date object to u. @@ -1177,7 +1169,7 @@ impl Date { pub(crate) fn set_year( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let t be ? thisTimeValue(this value). get_mut_date!(let t = this); @@ -1221,7 +1213,7 @@ impl Date { year: Some(IntegerOrNan::Integer(year)), ..Default::default() }, - &*context.host_hooks(), + context.host_hooks(), ); // 10. Set the [[DateValue]] internal slot of this Date object to TimeClip(date). @@ -1244,7 +1236,7 @@ impl Date { pub(crate) fn set_time( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Perform ? thisTimeValue(this value). get_mut_date!(let t = this); @@ -1276,7 +1268,7 @@ impl Date { pub(crate) fn to_date_string( this: &JsValue, _: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be this Date object. // 2. Let tv be ? thisTimeValue(O). @@ -1309,7 +1301,7 @@ impl Date { pub(crate) fn to_iso_string( this: &JsValue, _: &[JsValue], - _: &mut Context<'_>, + _: &mut Context, ) -> JsResult { let t = this_time_value(this)? .and_then(NaiveDateTime::from_timestamp_millis) @@ -1333,7 +1325,7 @@ impl Date { pub(crate) fn to_json( this: &JsValue, _: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? ToObject(this value). let o = this.to_object(context)?; @@ -1366,7 +1358,7 @@ impl Date { pub(crate) fn to_locale_date_string( _this: &JsValue, _args: &[JsValue], - _context: &mut Context<'_>, + _context: &mut Context, ) -> JsResult { Err(JsError::from_opaque(JsValue::new(js_string!( "Function Unimplemented" @@ -1385,7 +1377,7 @@ impl Date { pub(crate) fn to_locale_string( _this: &JsValue, _: &[JsValue], - _context: &mut Context<'_>, + _context: &mut Context, ) -> JsResult { Err(JsError::from_opaque(JsValue::new(js_string!( "Function Unimplemented]" @@ -1405,7 +1397,7 @@ impl Date { pub(crate) fn to_locale_time_string( _this: &JsValue, _args: &[JsValue], - _context: &mut Context<'_>, + _context: &mut Context, ) -> JsResult { Err(JsError::from_opaque(JsValue::new(js_string!( "Function Unimplemented]" @@ -1424,7 +1416,7 @@ impl Date { pub(crate) fn to_string( this: &JsValue, _: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let tv be ? thisTimeValue(this value). // 2. Return ToDateString(tv). @@ -1452,7 +1444,7 @@ impl Date { pub(crate) fn to_time_string( this: &JsValue, _: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be this Date object. // 2. Let tv be ? thisTimeValue(O). @@ -1483,7 +1475,7 @@ impl Date { pub(crate) fn to_utc_string( this: &JsValue, _args: &[JsValue], - _context: &mut Context<'_>, + _context: &mut Context, ) -> JsResult { // 1. Let O be this Date object. let Some(t) = this_time_value(this)?.and_then(NaiveDateTime::from_timestamp_millis) else { @@ -1517,7 +1509,7 @@ impl Date { pub(crate) fn value_of( this: &JsValue, _args: &[JsValue], - _context: &mut Context<'_>, + _context: &mut Context, ) -> JsResult { // 1. Return ? thisTimeValue(this value). Ok(Self::new(this_time_value(this)?).as_value()) @@ -1535,7 +1527,7 @@ impl Date { pub(crate) fn to_primitive( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be the this value. // 2. If Type(O) is not Object, throw a TypeError exception. diff --git a/boa_engine/src/builtins/error/aggregate.rs b/boa_engine/src/builtins/error/aggregate.rs index 8daf6862246..d34176fec85 100644 --- a/boa_engine/src/builtins/error/aggregate.rs +++ b/boa_engine/src/builtins/error/aggregate.rs @@ -59,7 +59,7 @@ impl BuiltInConstructor for AggregateError { fn constructor( new_target: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If NewTarget is undefined, let newTarget be the active function object; else let newTarget be NewTarget. let new_target = &if new_target.is_undefined() { diff --git a/boa_engine/src/builtins/error/eval.rs b/boa_engine/src/builtins/error/eval.rs index fe8d417a84c..d10629a882c 100644 --- a/boa_engine/src/builtins/error/eval.rs +++ b/boa_engine/src/builtins/error/eval.rs @@ -61,7 +61,7 @@ impl BuiltInConstructor for EvalError { fn constructor( new_target: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If NewTarget is undefined, let newTarget be the active function object; else let newTarget be NewTarget. let new_target = &if new_target.is_undefined() { diff --git a/boa_engine/src/builtins/error/mod.rs b/boa_engine/src/builtins/error/mod.rs index e28c4d6fbfc..21a7a0aa291 100644 --- a/boa_engine/src/builtins/error/mod.rs +++ b/boa_engine/src/builtins/error/mod.rs @@ -160,7 +160,7 @@ impl BuiltInConstructor for Error { fn constructor( new_target: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If NewTarget is undefined, let newTarget be the active function object; else let newTarget be NewTarget. let new_target = &if new_target.is_undefined() { @@ -203,7 +203,7 @@ impl Error { pub(crate) fn install_error_cause( o: &JsObject, options: &JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult<()> { // 1. If Type(options) is Object and ? HasProperty(options, "cause") is true, then if let Some(options) = options.as_object() { @@ -234,7 +234,7 @@ impl Error { pub(crate) fn to_string( this: &JsValue, _: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be the this value. // 2. If Type(O) is not Object, throw a TypeError exception. diff --git a/boa_engine/src/builtins/error/range.rs b/boa_engine/src/builtins/error/range.rs index 972392d0a2c..c57f2de3fe6 100644 --- a/boa_engine/src/builtins/error/range.rs +++ b/boa_engine/src/builtins/error/range.rs @@ -59,7 +59,7 @@ impl BuiltInConstructor for RangeError { fn constructor( new_target: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If NewTarget is undefined, let newTarget be the active function object; else let newTarget be NewTarget. let new_target = &if new_target.is_undefined() { diff --git a/boa_engine/src/builtins/error/reference.rs b/boa_engine/src/builtins/error/reference.rs index 4ddd5abd7d8..28906c7d728 100644 --- a/boa_engine/src/builtins/error/reference.rs +++ b/boa_engine/src/builtins/error/reference.rs @@ -58,7 +58,7 @@ impl BuiltInConstructor for ReferenceError { fn constructor( new_target: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If NewTarget is undefined, let newTarget be the active function object; else let newTarget be NewTarget. let new_target = &if new_target.is_undefined() { diff --git a/boa_engine/src/builtins/error/syntax.rs b/boa_engine/src/builtins/error/syntax.rs index 91b9f1a6380..93df4836ca6 100644 --- a/boa_engine/src/builtins/error/syntax.rs +++ b/boa_engine/src/builtins/error/syntax.rs @@ -61,7 +61,7 @@ impl BuiltInConstructor for SyntaxError { fn constructor( new_target: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If NewTarget is undefined, let newTarget be the active function object; else let newTarget be NewTarget. let new_target = &if new_target.is_undefined() { diff --git a/boa_engine/src/builtins/error/type.rs b/boa_engine/src/builtins/error/type.rs index aab6c9c40ad..eeee6010e09 100644 --- a/boa_engine/src/builtins/error/type.rs +++ b/boa_engine/src/builtins/error/type.rs @@ -67,7 +67,7 @@ impl BuiltInConstructor for TypeError { fn constructor( new_target: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If NewTarget is undefined, let newTarget be the active function object; else let newTarget be NewTarget. let new_target = &if new_target.is_undefined() { diff --git a/boa_engine/src/builtins/error/uri.rs b/boa_engine/src/builtins/error/uri.rs index df27792f0d6..174fef61d2a 100644 --- a/boa_engine/src/builtins/error/uri.rs +++ b/boa_engine/src/builtins/error/uri.rs @@ -60,7 +60,7 @@ impl BuiltInConstructor for UriError { fn constructor( new_target: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If NewTarget is undefined, let newTarget be the active function object; else let newTarget be NewTarget. let new_target = &if new_target.is_undefined() { diff --git a/boa_engine/src/builtins/escape/mod.rs b/boa_engine/src/builtins/escape/mod.rs index ea2c07f7bf5..fa8c8552041 100644 --- a/boa_engine/src/builtins/escape/mod.rs +++ b/boa_engine/src/builtins/escape/mod.rs @@ -38,7 +38,7 @@ impl BuiltInObject for Escape { } /// Builtin JavaScript `escape ( string )` function. -fn escape(_: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult { +fn escape(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { /// Returns `true` if the codepoint `cp` is part of the `unescapedSet`. fn is_unescaped(cp: u16) -> bool { let Ok(cp) = TryInto::::try_into(cp) else { @@ -110,7 +110,7 @@ impl BuiltInObject for Unescape { } /// Builtin JavaScript `unescape ( string )` function. -fn unescape(_: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult { +fn unescape(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { /// Converts a char `cp` to its corresponding hex digit value. fn to_hex_digit(cp: u16) -> Option { char::from_u32(u32::from(cp)) diff --git a/boa_engine/src/builtins/eval/mod.rs b/boa_engine/src/builtins/eval/mod.rs index 0a35c2cabab..3a239f3be3e 100644 --- a/boa_engine/src/builtins/eval/mod.rs +++ b/boa_engine/src/builtins/eval/mod.rs @@ -58,7 +58,7 @@ impl Eval { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-eval-x - fn eval(_: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult { + fn eval(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Return ? PerformEval(x, false, false). Self::perform_eval(args.get_or_undefined(0), false, false, context) } @@ -73,7 +73,7 @@ impl Eval { x: &JsValue, direct: bool, mut strict: bool, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { bitflags::bitflags! { /// Flags used to throw early errors on invalid `eval` calls. diff --git a/boa_engine/src/builtins/function/arguments.rs b/boa_engine/src/builtins/function/arguments.rs index 307e77c5d3d..ceb3c33b573 100644 --- a/boa_engine/src/builtins/function/arguments.rs +++ b/boa_engine/src/builtins/function/arguments.rs @@ -71,7 +71,7 @@ impl Arguments { /// [spec]: https://tc39.es/ecma262/#sec-createunmappedargumentsobject pub(crate) fn create_unmapped_arguments_object( arguments_list: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsObject { // 1. Let len be the number of elements in argumentsList. let len = arguments_list.len(); @@ -125,7 +125,7 @@ impl Arguments { formals: &FormalParameterList, arguments_list: &[JsValue], env: &Gc, - context: &mut Context<'_>, + context: &mut Context, ) -> JsObject { // 1. Assert: formals does not contain a rest parameter, any binding patterns, or any initializers. // It may contain duplicate identifiers. diff --git a/boa_engine/src/builtins/function/mod.rs b/boa_engine/src/builtins/function/mod.rs index e6c13559501..3fdaef9bf32 100644 --- a/boa_engine/src/builtins/function/mod.rs +++ b/boa_engine/src/builtins/function/mod.rs @@ -333,7 +333,7 @@ impl BuiltInConstructor for BuiltInFunctionObject { fn constructor( new_target: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let active_function = context .active_function_object() @@ -356,7 +356,7 @@ impl BuiltInFunctionObject { args: &[JsValue], r#async: bool, generator: bool, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let currentRealm be the current Realm Record. // 2. Perform ? HostEnsureCanCompileStrings(currentRealm). @@ -586,7 +586,7 @@ impl BuiltInFunctionObject { /// /// [spec]: https://tc39.es/ecma262/#sec-function.prototype.apply /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply - fn apply(this: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult { + fn apply(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let func be the this value. // 2. If IsCallable(func) is false, throw a TypeError exception. let func = this.as_callable().ok_or_else(|| { @@ -626,7 +626,7 @@ impl BuiltInFunctionObject { /// /// [spec]: https://tc39.es/ecma262/#sec-function.prototype.bind /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_objects/Function/bind - fn bind(this: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult { + fn bind(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let Target be the this value. // 2. If IsCallable(Target) is false, throw a TypeError exception. let target = this.as_callable().ok_or_else(|| { @@ -708,7 +708,7 @@ impl BuiltInFunctionObject { /// /// [spec]: https://tc39.es/ecma262/#sec-function.prototype.call /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call - fn call(this: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult { + fn call(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let func be the this value. // 2. If IsCallable(func) is false, throw a TypeError exception. let func = this.as_callable().ok_or_else(|| { @@ -732,7 +732,7 @@ impl BuiltInFunctionObject { /// [spec]: https://tc39.es/ecma262/#sec-function.prototype.tostring /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/toString #[allow(clippy::wrong_self_convention)] - fn to_string(this: &JsValue, _: &[JsValue], context: &mut Context<'_>) -> JsResult { + fn to_string(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Let func be the this value. let func = this; @@ -794,18 +794,14 @@ impl BuiltInFunctionObject { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-function.prototype-@@hasinstance - fn has_instance( - this: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + fn has_instance(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let F be the this value. // 2. Return ? OrdinaryHasInstance(F, V). Ok(JsValue::ordinary_has_instance(this, args.get_or_undefined(0), context)?.into()) } #[allow(clippy::unnecessary_wraps)] - fn prototype(_: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn prototype(_: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Ok(JsValue::undefined()) } } @@ -820,7 +816,7 @@ pub(crate) fn set_function_name( function: &JsObject, name: &PropertyKey, prefix: Option, - context: &mut Context<'_>, + context: &mut Context, ) { // 1. Assert: F is an extensible object that does not have a "name" own property. // 2. If Type(name) is Symbol, then @@ -888,7 +884,7 @@ impl BoundFunction { target_function: JsObject, this: JsValue, args: Vec, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let proto be ? targetFunction.[[GetPrototypeOf]](). let proto = target_function.__get_prototype_of__(context)?; diff --git a/boa_engine/src/builtins/generator/mod.rs b/boa_engine/src/builtins/generator/mod.rs index 945efd68562..1b26793e9bf 100644 --- a/boa_engine/src/builtins/generator/mod.rs +++ b/boa_engine/src/builtins/generator/mod.rs @@ -73,7 +73,7 @@ impl GeneratorContext { } /// Creates a new `GeneratorContext` from the current `Context` state. - pub(crate) fn from_current(context: &mut Context<'_>) -> Self { + pub(crate) fn from_current(context: &mut Context) -> Self { let mut frame = context.vm.frame().clone(); frame.environments = context.vm.environments.clone(); frame.realm = context.realm().clone(); @@ -93,7 +93,7 @@ impl GeneratorContext { &mut self, value: Option, resume_kind: GeneratorResumeKind, - context: &mut Context<'_>, + context: &mut Context, ) -> CompletionRecord { std::mem::swap(&mut context.vm.stack, &mut self.stack); context @@ -178,7 +178,7 @@ impl Generator { pub(crate) fn next( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Return ? GeneratorResume(this value, value, empty). Self::generator_resume(this, args.get_or_undefined(0).clone(), context) @@ -197,7 +197,7 @@ impl Generator { pub(crate) fn r#return( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let g be the this value. // 2. Let C be Completion { [[Type]]: return, [[Value]]: value, [[Target]]: empty }. @@ -219,7 +219,7 @@ impl Generator { pub(crate) fn throw( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let g be the this value. // 2. Let C be ThrowCompletion(exception). @@ -240,7 +240,7 @@ impl Generator { pub(crate) fn generator_resume( gen: &JsValue, value: JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let state be ? GeneratorValidate(generator, generatorBrand). let Some(generator_obj) = gen.as_object() else { @@ -324,7 +324,7 @@ impl Generator { pub(crate) fn generator_resume_abrupt( gen: &JsValue, abrupt_completion: JsResult, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let state be ? GeneratorValidate(generator, generatorBrand). let Some(generator_obj) = gen.as_object() else { diff --git a/boa_engine/src/builtins/generator_function/mod.rs b/boa_engine/src/builtins/generator_function/mod.rs index 5b7fe93fce1..300600d1ec9 100644 --- a/boa_engine/src/builtins/generator_function/mod.rs +++ b/boa_engine/src/builtins/generator_function/mod.rs @@ -75,7 +75,7 @@ impl BuiltInConstructor for GeneratorFunction { fn constructor( new_target: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let active_function = context.active_function_object().unwrap_or_else(|| { context diff --git a/boa_engine/src/builtins/intl/collator/mod.rs b/boa_engine/src/builtins/intl/collator/mod.rs index 61f10b900b9..77d55e9a6a4 100644 --- a/boa_engine/src/builtins/intl/collator/mod.rs +++ b/boa_engine/src/builtins/intl/collator/mod.rs @@ -80,12 +80,12 @@ impl Service for Collator { type LocaleOptions = CollatorLocaleOptions; - fn resolve(locale: &mut Locale, options: &mut Self::LocaleOptions, provider: BoaProvider<'_>) { + fn resolve(locale: &mut Locale, options: &mut Self::LocaleOptions, provider: &BoaProvider) { let collation = options .collation .take() .filter(|co| { - validate_extension::(locale.id.clone(), key!("co"), co, &provider) + validate_extension::(locale.id.clone(), key!("co"), co, provider) }) .or_else(|| { locale @@ -99,7 +99,7 @@ impl Service for Collator { locale.id.clone(), key!("co"), co, - &provider, + provider, ) }) }) @@ -204,7 +204,7 @@ impl BuiltInConstructor for Collator { fn constructor( new_target: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If NewTarget is undefined, let newTarget be the active function object, else let newTarget be NewTarget. let new_target = &if new_target.is_undefined() { @@ -333,7 +333,7 @@ impl BuiltInConstructor for Collator { .unzip(); let collator = - NativeCollator::try_new_unstable(&context.icu().provider(), &collator_locale, { + NativeCollator::try_new_unstable(context.icu().provider(), &collator_locale, { let mut options = icu_collator::CollatorOptions::new(); options.strength = strength; options.case_level = case_level; @@ -382,7 +382,7 @@ impl Collator { fn supported_locales_of( _: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let locales = args.get_or_undefined(0); let options = args.get_or_undefined(1); @@ -405,7 +405,7 @@ impl Collator { /// /// [spec]: https://tc39.es/ecma402/#sec-intl.collator.prototype.compare /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Collator/compare - fn compare(this: &JsValue, _: &[JsValue], context: &mut Context<'_>) -> JsResult { + fn compare(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Let collator be the this value. // 2. Perform ? RequireInternalSlot(collator, [[InitializedCollator]]). let this = this.as_object().ok_or_else(|| { @@ -476,11 +476,7 @@ impl Collator { /// /// [spec]: https://tc39.es/ecma402/#sec-intl.collator.prototype.resolvedoptions /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Collator/resolvedOptions - fn resolved_options( - this: &JsValue, - _: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + fn resolved_options(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Let collator be the this value. // 2. Perform ? RequireInternalSlot(collator, [[InitializedCollator]]). let collator = this.as_object().map(JsObject::borrow).ok_or_else(|| { diff --git a/boa_engine/src/builtins/intl/collator/options.rs b/boa_engine/src/builtins/intl/collator/options.rs index 8cdcbde0b98..aefe82e5c40 100644 --- a/boa_engine/src/builtins/intl/collator/options.rs +++ b/boa_engine/src/builtins/intl/collator/options.rs @@ -83,7 +83,7 @@ impl FromStr for Usage { impl ParsableOptionType for Usage {} impl OptionType for CaseFirst { - fn from_value(value: JsValue, context: &mut Context<'_>) -> JsResult { + fn from_value(value: JsValue, context: &mut Context) -> JsResult { match value.to_string(context)?.to_std_string_escaped().as_str() { "upper" => Ok(Self::UpperFirst), "lower" => Ok(Self::LowerFirst), diff --git a/boa_engine/src/builtins/intl/date_time_format.rs b/boa_engine/src/builtins/intl/date_time_format.rs index 1cad2c007b0..2ae6c8b0a8e 100644 --- a/boa_engine/src/builtins/intl/date_time_format.rs +++ b/boa_engine/src/builtins/intl/date_time_format.rs @@ -25,7 +25,7 @@ use boa_profiler::Profiler; use icu_datetime::options::preferences::HourCycle; impl OptionType for HourCycle { - fn from_value(value: JsValue, context: &mut Context<'_>) -> JsResult { + fn from_value(value: JsValue, context: &mut Context) -> JsResult { match value.to_string(context)?.to_std_string_escaped().as_str() { "h11" => Ok(Self::H11), "h12" => Ok(Self::H12), @@ -94,7 +94,7 @@ impl BuiltInConstructor for DateTimeFormat { fn constructor( new_target: &JsValue, _args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If NewTarget is undefined, let newTarget be the active function object, else let newTarget be NewTarget. let new_target = &if new_target.is_undefined() { @@ -181,7 +181,7 @@ pub(crate) fn to_date_time_options( options: &JsValue, required: &DateTimeReqs, defaults: &DateTimeReqs, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If options is undefined, let options be null; // otherwise let options be ? ToObject(options). diff --git a/boa_engine/src/builtins/intl/list_format/mod.rs b/boa_engine/src/builtins/intl/list_format/mod.rs index 59e114ab3b9..e3cfe0cd7bc 100644 --- a/boa_engine/src/builtins/intl/list_format/mod.rs +++ b/boa_engine/src/builtins/intl/list_format/mod.rs @@ -91,7 +91,7 @@ impl BuiltInConstructor for ListFormat { fn constructor( new_target: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If NewTarget is undefined, throw a TypeError exception. if new_target.is_undefined() { @@ -141,17 +141,17 @@ impl BuiltInConstructor for ListFormat { let data_locale = DataLocale::from(&locale); let formatter = match typ { ListFormatType::Conjunction => ListFormatter::try_new_and_with_length_unstable( - &context.icu().provider(), + context.icu().provider(), &data_locale, style, ), ListFormatType::Disjunction => ListFormatter::try_new_or_with_length_unstable( - &context.icu().provider(), + context.icu().provider(), &data_locale, style, ), ListFormatType::Unit => ListFormatter::try_new_unit_with_length_unstable( - &context.icu().provider(), + context.icu().provider(), &data_locale, style, ), @@ -191,7 +191,7 @@ impl ListFormat { fn supported_locales_of( _: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let locales = args.get_or_undefined(0); let options = args.get_or_undefined(1); @@ -214,7 +214,7 @@ impl ListFormat { /// /// [spec]: https://tc39.es/ecma402/#sec-Intl.ListFormat.prototype.format /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/format - fn format(this: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult { + fn format(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let lf be the this value. // 2. Perform ? RequireInternalSlot(lf, [[InitializedListFormat]]). let lf = this.as_object().map(JsObject::borrow).ok_or_else(|| { @@ -250,7 +250,7 @@ impl ListFormat { fn format_to_parts( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // TODO: maybe try to move this into icu4x? use writeable::{PartsWrite, Writeable}; @@ -406,11 +406,7 @@ impl ListFormat { /// /// [spec]: https://tc39.es/ecma402/#sec-Intl.ListFormat.prototype.resolvedoptions /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/resolvedOptions - fn resolved_options( - this: &JsValue, - _: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + fn resolved_options(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Let lf be the this value. // 2. Perform ? RequireInternalSlot(lf, [[InitializedListFormat]]). let lf = this.as_object().map(JsObject::borrow).ok_or_else(|| { @@ -473,10 +469,7 @@ impl ListFormat { /// Abstract operation [`StringListFromIterable ( iterable )`][spec] /// /// [spec]: https://tc39.es/ecma402/#sec-createstringlistfromiterable -fn string_list_from_iterable( - iterable: &JsValue, - context: &mut Context<'_>, -) -> JsResult> { +fn string_list_from_iterable(iterable: &JsValue, context: &mut Context) -> JsResult> { // 1. If iterable is undefined, then if iterable.is_undefined() { // a. Return a new empty List. diff --git a/boa_engine/src/builtins/intl/list_format/options.rs b/boa_engine/src/builtins/intl/list_format/options.rs index 9d1fdad1622..123b82c4ee6 100644 --- a/boa_engine/src/builtins/intl/list_format/options.rs +++ b/boa_engine/src/builtins/intl/list_format/options.rs @@ -40,7 +40,7 @@ impl FromStr for ListFormatType { impl ParsableOptionType for ListFormatType {} impl OptionType for ListLength { - fn from_value(value: JsValue, context: &mut Context<'_>) -> JsResult { + fn from_value(value: JsValue, context: &mut Context) -> JsResult { match value.to_string(context)?.to_std_string_escaped().as_str() { "long" => Ok(Self::Wide), "short" => Ok(Self::Short), diff --git a/boa_engine/src/builtins/intl/locale/mod.rs b/boa_engine/src/builtins/intl/locale/mod.rs index 3af04a84568..81cece4ad10 100644 --- a/boa_engine/src/builtins/intl/locale/mod.rs +++ b/boa_engine/src/builtins/intl/locale/mod.rs @@ -176,7 +176,7 @@ impl BuiltInConstructor for Locale { fn constructor( new_target: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If NewTarget is undefined, throw a TypeError exception. if new_target.is_undefined() { @@ -390,7 +390,7 @@ impl Locale { pub(crate) fn maximize( this: &JsValue, _: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let loc be the this value. // 2. Perform ? RequireInternalSlot(loc, [[InitializedLocale]]). @@ -428,7 +428,7 @@ impl Locale { pub(crate) fn minimize( this: &JsValue, _: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let loc be the this value. // 2. Perform ? RequireInternalSlot(loc, [[InitializedLocale]]). @@ -463,11 +463,7 @@ impl Locale { /// /// [spec]: https://tc39.es/ecma402/#sec-Intl.Locale.prototype.toString /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/toString - pub(crate) fn to_string( - this: &JsValue, - _: &[JsValue], - _: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn to_string(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { // 1. Let loc be the this value. // 2. Perform ? RequireInternalSlot(loc, [[InitializedLocale]]). let loc = this.as_object().map(JsObject::borrow).ok_or_else(|| { @@ -488,11 +484,7 @@ impl Locale { /// /// [spec]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/baseName /// [mdn]: https://tc39.es/ecma402/#sec-Intl.Locale.prototype.baseName - pub(crate) fn base_name( - this: &JsValue, - _: &[JsValue], - _: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn base_name(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { // 1. Let loc be the this value. // 2. Perform ? RequireInternalSlot(loc, [[InitializedLocale]]). let loc = this.as_object().map(JsObject::borrow).ok_or_else(|| { @@ -516,11 +508,7 @@ impl Locale { /// /// [spec]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/calendar /// [mdn]: https://tc39.es/ecma402/#sec-Intl.Locale.prototype.calendar - pub(crate) fn calendar( - this: &JsValue, - _: &[JsValue], - _: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn calendar(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { // 1. Let loc be the this value. // 2. Perform ? RequireInternalSlot(loc, [[InitializedLocale]]). let loc = this.as_object().map(JsObject::borrow).ok_or_else(|| { @@ -549,11 +537,7 @@ impl Locale { /// /// [spec]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/calendar /// [mdn]: https://tc39.es/ecma402/#sec-Intl.Locale.prototype.calendar - pub(crate) fn case_first( - this: &JsValue, - _: &[JsValue], - _: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn case_first(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { // 1. Let loc be the this value. // 2. Perform ? RequireInternalSlot(loc, [[InitializedLocale]]). let loc = this.as_object().map(JsObject::borrow).ok_or_else(|| { @@ -582,11 +566,7 @@ impl Locale { /// /// [spec]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/collation /// [mdn]: https://tc39.es/ecma402/#sec-Intl.Locale.prototype.collation - pub(crate) fn collation( - this: &JsValue, - _: &[JsValue], - _: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn collation(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { // 1. Let loc be the this value. // 2. Perform ? RequireInternalSlot(loc, [[InitializedLocale]]). let loc = this.as_object().map(JsObject::borrow).ok_or_else(|| { @@ -615,11 +595,7 @@ impl Locale { /// /// [spec]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/hourCycle /// [mdn]: https://tc39.es/ecma402/#sec-Intl.Locale.prototype.hourCycle - pub(crate) fn hour_cycle( - this: &JsValue, - _: &[JsValue], - _: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn hour_cycle(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { // 1. Let loc be the this value. // 2. Perform ? RequireInternalSlot(loc, [[InitializedLocale]]). let loc = this.as_object().map(JsObject::borrow).ok_or_else(|| { @@ -648,7 +624,7 @@ impl Locale { /// /// [spec]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/numeric /// [mdn]: https://tc39.es/ecma402/#sec-Intl.Locale.prototype.numeric - pub(crate) fn numeric(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + pub(crate) fn numeric(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { // 1. Let loc be the this value. // 2. Perform ? RequireInternalSlot(loc, [[InitializedLocale]]). let loc = this.as_object().map(JsObject::borrow).ok_or_else(|| { @@ -684,7 +660,7 @@ impl Locale { pub(crate) fn numbering_system( this: &JsValue, _: &[JsValue], - _: &mut Context<'_>, + _: &mut Context, ) -> JsResult { // 1. Let loc be the this value. // 2. Perform ? RequireInternalSlot(loc, [[InitializedLocale]]). @@ -714,11 +690,7 @@ impl Locale { /// /// [spec]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/language /// [mdn]: https://tc39.es/ecma402/#sec-Intl.Locale.prototype.language - pub(crate) fn language( - this: &JsValue, - _: &[JsValue], - _: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn language(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { // 1. Let loc be the this value. // 2. Perform ? RequireInternalSlot(loc, [[InitializedLocale]]). let loc = this.as_object().map(JsObject::borrow).ok_or_else(|| { @@ -743,7 +715,7 @@ impl Locale { /// /// [spec]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/script /// [mdn]: https://tc39.es/ecma402/#sec-Intl.Locale.prototype.script - pub(crate) fn script(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + pub(crate) fn script(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { // 1. Let loc be the this value. // 2. Perform ? RequireInternalSlot(loc, [[InitializedLocale]]). let loc = this.as_object().map(JsObject::borrow).ok_or_else(|| { @@ -773,7 +745,7 @@ impl Locale { /// /// [spec]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/region /// [mdn]: https://tc39.es/ecma402/#sec-Intl.Locale.prototype.region - pub(crate) fn region(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + pub(crate) fn region(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { // 1. Let loc be the this value. // 2. Perform ? RequireInternalSlot(loc, [[InitializedLocale]]). let loc = this.as_object().map(JsObject::borrow).ok_or_else(|| { diff --git a/boa_engine/src/builtins/intl/locale/options.rs b/boa_engine/src/builtins/intl/locale/options.rs index 68e2aeea646..10bd8cc05b3 100644 --- a/boa_engine/src/builtins/intl/locale/options.rs +++ b/boa_engine/src/builtins/intl/locale/options.rs @@ -6,7 +6,7 @@ use icu_locid::{ use crate::{builtins::options::OptionType, Context, JsNativeError}; impl OptionType for Value { - fn from_value(value: crate::JsValue, context: &mut Context<'_>) -> crate::JsResult { + fn from_value(value: crate::JsValue, context: &mut Context) -> crate::JsResult { let val = value.to_string(context)?.to_std_string_escaped(); if val.len() < 3 { @@ -21,7 +21,7 @@ impl OptionType for Value { } impl OptionType for Language { - fn from_value(value: crate::JsValue, context: &mut Context<'_>) -> crate::JsResult { + fn from_value(value: crate::JsValue, context: &mut Context) -> crate::JsResult { value .to_string(context)? .to_std_string_escaped() @@ -31,7 +31,7 @@ impl OptionType for Language { } impl OptionType for Script { - fn from_value(value: crate::JsValue, context: &mut Context<'_>) -> crate::JsResult { + fn from_value(value: crate::JsValue, context: &mut Context) -> crate::JsResult { value .to_string(context)? .to_std_string_escaped() @@ -41,7 +41,7 @@ impl OptionType for Script { } impl OptionType for Region { - fn from_value(value: crate::JsValue, context: &mut Context<'_>) -> crate::JsResult { + fn from_value(value: crate::JsValue, context: &mut Context) -> crate::JsResult { value .to_string(context)? .to_std_string_escaped() diff --git a/boa_engine/src/builtins/intl/locale/tests.rs b/boa_engine/src/builtins/intl/locale/tests.rs index 0643cd10894..7c200786e1c 100644 --- a/boa_engine/src/builtins/intl/locale/tests.rs +++ b/boa_engine/src/builtins/intl/locale/tests.rs @@ -7,7 +7,7 @@ use icu_locid::{ locale, Locale, }; use icu_plurals::provider::CardinalV1Marker; -use icu_provider::{BufferProvider, DataLocale, DataProvider, DataRequest, DataRequestMetadata}; +use icu_provider::{DataLocale, DataProvider, DataRequest, DataRequestMetadata}; use crate::{ builtins::intl::{ @@ -15,7 +15,7 @@ use crate::{ options::{IntlOptions, LocaleMatcher}, Service, }, - context::icu::{BoaProvider, Icu}, + context::icu::{BoaProvider, Icu, StaticProviderAdapter}, }; #[derive(Debug)] @@ -30,7 +30,7 @@ impl Service for TestService { type LocaleOptions = TestOptions; - fn resolve(locale: &mut Locale, options: &mut Self::LocaleOptions, provider: BoaProvider<'_>) { + fn resolve(locale: &mut Locale, options: &mut Self::LocaleOptions, provider: &BoaProvider) { let loc_hc = locale .extensions .unicode @@ -49,7 +49,7 @@ impl Service for TestService { locale: &DataLocale::from(&*locale), metadata: DataRequestMetadata::default(), }; - let preferred = DataProvider::::load(&provider, req) + let preferred = DataProvider::::load(provider, req) .unwrap() .take_payload() .unwrap() @@ -73,8 +73,10 @@ impl Service for TestService { #[test] fn locale_resolution() { - let provider: &dyn BufferProvider = boa_icu_provider::buffer(); - let icu = Icu::new(BoaProvider::Buffer(provider)).unwrap(); + let icu = Icu::new(BoaProvider::Buffer(Box::new(StaticProviderAdapter( + boa_icu_provider::buffer(), + )))) + .unwrap(); let mut default = default_locale(icu.locale_canonicalizer()); default .extensions @@ -103,7 +105,7 @@ fn locale_resolution() { let locale = resolve_locale::(&[], &mut options, &icu); let best = best_locale_for_provider::<::LangMarker>( default.id.clone(), - &icu.provider(), + icu.provider(), ) .unwrap(); let mut best = Locale::from(best); diff --git a/boa_engine/src/builtins/intl/locale/utils.rs b/boa_engine/src/builtins/intl/locale/utils.rs index 33d8766507e..e2879c22786 100644 --- a/boa_engine/src/builtins/intl/locale/utils.rs +++ b/boa_engine/src/builtins/intl/locale/utils.rs @@ -65,7 +65,7 @@ pub(crate) fn default_locale(canonicalizer: &LocaleCanonicalizer) -> Locale { /// [canon]: https://unicode.org/reports/tr35/#LocaleId_Canonicalization pub(crate) fn canonicalize_locale_list( locales: &JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult> { // 1. If locales is undefined, then if locales.is_undefined() { @@ -314,12 +314,9 @@ pub(crate) fn best_locale_for_provider( /// in order to see if a certain [`Locale`] is supported. /// /// [spec]: https://tc39.es/ecma402/#sec-lookupmatcher -fn lookup_matcher<'provider, M: KeyedDataMarker>( - requested_locales: &[Locale], - icu: &Icu<'provider>, -) -> Locale +fn lookup_matcher(requested_locales: &[Locale], icu: &Icu) -> Locale where - BoaProvider<'provider>: DataProvider, + BoaProvider: DataProvider, { // 1. Let result be a new Record. // 2. For each element locale of requestedLocales, do @@ -330,7 +327,7 @@ where let id = std::mem::take(&mut locale.id); // b. Let availableLocale be ! BestAvailableLocale(availableLocales, noExtensionsLocale). - let available_locale = best_available_locale::(id, &icu.provider()); + let available_locale = best_available_locale::(id, icu.provider()); // c. If availableLocale is not undefined, then if let Some(available_locale) = available_locale { @@ -362,12 +359,9 @@ where /// produced by the `LookupMatcher` abstract operation. /// /// [spec]: https://tc39.es/ecma402/#sec-bestfitmatcher -fn best_fit_matcher<'provider, M: KeyedDataMarker>( - requested_locales: &[Locale], - icu: &Icu<'provider>, -) -> Locale +fn best_fit_matcher(requested_locales: &[Locale], icu: &Icu) -> Locale where - BoaProvider<'provider>: DataProvider, + BoaProvider: DataProvider, { for mut locale in requested_locales .iter() @@ -378,7 +372,7 @@ where { let id = std::mem::take(&mut locale.id); - if let Some(available) = best_locale_for_provider(id, &icu.provider()) { + if let Some(available) = best_locale_for_provider(id, icu.provider()) { locale.id = available; return locale; @@ -398,14 +392,14 @@ where /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma402/#sec-resolvelocale -pub(in crate::builtins::intl) fn resolve_locale<'provider, S>( +pub(in crate::builtins::intl) fn resolve_locale( requested_locales: &[Locale], options: &mut IntlOptions, - icu: &Icu<'provider>, + icu: &Icu, ) -> Locale where S: Service, - BoaProvider<'provider>: DataProvider, + BoaProvider: DataProvider, { // 1. Let matcher be options.[[localeMatcher]]. // 2. If matcher is "lookup", then @@ -534,13 +528,13 @@ fn best_fit_supported_locales( /// availableLocales has a matching locale /// /// [spec]: https://tc39.es/ecma402/#sec-supportedlocales -pub(in crate::builtins::intl) fn supported_locales<'ctx, 'icu: 'ctx, M: KeyedDataMarker>( +pub(in crate::builtins::intl) fn supported_locales( requested_locales: &[Locale], options: &JsValue, - context: &'ctx mut Context<'icu>, + context: &mut Context, ) -> JsResult where - BoaProvider<'icu>: DataProvider, + BoaProvider: DataProvider, { // 1. Set options to ? CoerceOptionsToObject(options). let options = coerce_options_to_object(options, context)?; @@ -552,12 +546,12 @@ where // 4. Else, // a. Let supportedLocales be LookupSupportedLocales(availableLocales, requestedLocales). LocaleMatcher::Lookup => { - lookup_supported_locales(requested_locales, &context.icu().provider()) + lookup_supported_locales(requested_locales, context.icu().provider()) } // 3. If matcher is "best fit", then // a. Let supportedLocales be BestFitSupportedLocales(availableLocales, requestedLocales). LocaleMatcher::BestFit => { - best_fit_supported_locales(requested_locales, &context.icu().provider()) + best_fit_supported_locales(requested_locales, context.icu().provider()) } }; @@ -596,13 +590,13 @@ pub(in crate::builtins::intl) fn validate_extension( mod tests { use icu_locid::{langid, locale, Locale}; use icu_plurals::provider::CardinalV1Marker; - use icu_provider::{AsDeserializingBufferProvider, BufferProvider}; + use icu_provider::AsDeserializingBufferProvider; use crate::{ builtins::intl::locale::utils::{ best_available_locale, best_fit_matcher, default_locale, lookup_matcher, }, - context::icu::{BoaProvider, Icu}, + context::icu::{BoaProvider, Icu, StaticProviderAdapter}, }; #[test] @@ -628,8 +622,10 @@ mod tests { #[test] fn lookup_match() { - let provider: &dyn BufferProvider = boa_icu_provider::buffer(); - let icu = Icu::new(BoaProvider::Buffer(provider)).unwrap(); + let icu = Icu::new(BoaProvider::Buffer(Box::new(StaticProviderAdapter( + boa_icu_provider::buffer(), + )))) + .unwrap(); // requested: [] diff --git a/boa_engine/src/builtins/intl/mod.rs b/boa_engine/src/builtins/intl/mod.rs index 9592b6914a9..92c85e98c23 100644 --- a/boa_engine/src/builtins/intl/mod.rs +++ b/boa_engine/src/builtins/intl/mod.rs @@ -130,7 +130,7 @@ impl Intl { pub(crate) fn get_canonical_locales( _: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let locales = args.get_or_undefined(0); @@ -172,7 +172,7 @@ trait Service { fn resolve( _locale: &mut icu_locid::Locale, _options: &mut Self::LocaleOptions, - _provider: BoaProvider<'_>, + _provider: &BoaProvider, ) { } } diff --git a/boa_engine/src/builtins/intl/number_format/utils.rs b/boa_engine/src/builtins/intl/number_format/utils.rs index ac6670bff95..7dd82927bd9 100644 --- a/boa_engine/src/builtins/intl/number_format/utils.rs +++ b/boa_engine/src/builtins/intl/number_format/utils.rs @@ -24,7 +24,7 @@ pub(crate) fn get_digit_format_options( min_float_digits_default: u8, mut max_float_digits_default: u8, notation: Notation, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { const VALID_ROUNDING_INCREMENTS: [u16; 15] = [ 1, 2, 5, 10, 20, 25, 50, 100, 200, 250, 500, 1000, 2000, 2500, 5000, diff --git a/boa_engine/src/builtins/intl/options.rs b/boa_engine/src/builtins/intl/options.rs index 73168d4e888..2a9f17d9d7b 100644 --- a/boa_engine/src/builtins/intl/options.rs +++ b/boa_engine/src/builtins/intl/options.rs @@ -63,7 +63,7 @@ pub(super) fn get_number_option( property: &[u16], minimum: T, maximum: T, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult> where T: Into + FromPrimitive, @@ -86,7 +86,7 @@ pub(super) fn default_number_option( value: &JsValue, minimum: T, maximum: T, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult> where T: Into + FromPrimitive, @@ -123,7 +123,7 @@ where /// [`get_options_object`]: crate::builtins::options::get_options_object pub(super) fn coerce_options_to_object( options: &JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // If options is undefined, then if options.is_undefined() { diff --git a/boa_engine/src/builtins/intl/plural_rules/mod.rs b/boa_engine/src/builtins/intl/plural_rules/mod.rs index ac8bfae8ebf..1ae32277079 100644 --- a/boa_engine/src/builtins/intl/plural_rules/mod.rs +++ b/boa_engine/src/builtins/intl/plural_rules/mod.rs @@ -85,7 +85,7 @@ impl BuiltInConstructor for PluralRules { fn constructor( new_target: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If NewTarget is undefined, throw a TypeError exception. if new_target.is_undefined() { @@ -137,11 +137,11 @@ impl BuiltInConstructor for PluralRules { let native = match rule_type { PluralRuleType::Cardinal => NativePluralRules::try_new_cardinal_unstable( - &context.icu().provider(), + context.icu().provider(), &DataLocale::from(&locale), ), PluralRuleType::Ordinal => NativePluralRules::try_new_ordinal_unstable( - &context.icu().provider(), + context.icu().provider(), &DataLocale::from(&locale), ), _ => { @@ -183,7 +183,7 @@ impl PluralRules { /// /// [spec]: https://tc39.es/ecma402/#sec-intl.pluralrules.prototype.select /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/PluralRules/select - fn select(this: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult { + fn select(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let pr be the this value. // 2. Perform ? RequireInternalSlot(pr, [[InitializedPluralRules]]). let plural_rules = this.as_object().map(JsObject::borrow).ok_or_else(|| { @@ -214,7 +214,7 @@ impl PluralRules { fn supported_locales_of( _: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let locales = args.get_or_undefined(0); let options = args.get_or_undefined(1); @@ -238,11 +238,7 @@ impl PluralRules { /// /// [spec]: https://tc39.es/ecma402/#sec-intl.pluralrules.prototype.resolvedoptions /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/PluralRules/resolvedOptions - fn resolved_options( - this: &JsValue, - _: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + fn resolved_options(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Let pr be the this value. // 2. Perform ? RequireInternalSlot(pr, [[InitializedPluralRules]]). let plural_rules = this.as_object().map(JsObject::borrow).ok_or_else(|| { diff --git a/boa_engine/src/builtins/intl/plural_rules/options.rs b/boa_engine/src/builtins/intl/plural_rules/options.rs index 6c8341bce96..0481a75bd0c 100644 --- a/boa_engine/src/builtins/intl/plural_rules/options.rs +++ b/boa_engine/src/builtins/intl/plural_rules/options.rs @@ -3,7 +3,7 @@ use icu_plurals::PluralRuleType; use crate::{builtins::options::OptionType, Context, JsNativeError, JsResult, JsValue}; impl OptionType for PluralRuleType { - fn from_value(value: JsValue, context: &mut Context<'_>) -> JsResult { + fn from_value(value: JsValue, context: &mut Context) -> JsResult { match value.to_string(context)?.to_std_string_escaped().as_str() { "cardinal" => Ok(Self::Cardinal), "ordinal" => Ok(Self::Ordinal), diff --git a/boa_engine/src/builtins/intl/segmenter/iterator.rs b/boa_engine/src/builtins/intl/segmenter/iterator.rs index 5045c911b5c..32615e5c308 100644 --- a/boa_engine/src/builtins/intl/segmenter/iterator.rs +++ b/boa_engine/src/builtins/intl/segmenter/iterator.rs @@ -76,11 +76,7 @@ impl SegmentIterator { /// [`CreateSegmentIterator ( segmenter, string )`][spec] /// /// [spec]: https://tc39.es/ecma402/#sec-createsegmentiterator - pub(crate) fn create( - segmenter: JsObject, - string: JsString, - context: &mut Context<'_>, - ) -> JsObject { + pub(crate) fn create(segmenter: JsObject, string: JsString, context: &mut Context) -> JsObject { // 1. Let internalSlotsList be « [[IteratingSegmenter]], [[IteratedString]], [[IteratedStringNextSegmentCodeUnitIndex]] ». // 2. Let iterator be OrdinaryObjectCreate(%SegmentIteratorPrototype%, internalSlotsList). // 3. Set iterator.[[IteratingSegmenter]] to segmenter. @@ -104,7 +100,7 @@ impl SegmentIterator { /// [`%SegmentIteratorPrototype%.next ( )`][spec] /// /// [spec]: https://tc39.es/ecma402/#sec-%segmentiteratorprototype%.next - fn next(this: &JsValue, _: &[JsValue], context: &mut Context<'_>) -> JsResult { + fn next(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Let iterator be the this value. // 2. Perform ? RequireInternalSlot(iterator, [[IteratingSegmenter]]). let mut iter = this.as_object().map(JsObject::borrow_mut).ok_or_else(|| { diff --git a/boa_engine/src/builtins/intl/segmenter/mod.rs b/boa_engine/src/builtins/intl/segmenter/mod.rs index c70741dafce..1ea1f6d2f7d 100644 --- a/boa_engine/src/builtins/intl/segmenter/mod.rs +++ b/boa_engine/src/builtins/intl/segmenter/mod.rs @@ -114,7 +114,7 @@ impl BuiltInConstructor for Segmenter { fn constructor( new_target: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If NewTarget is undefined, throw a TypeError exception. if new_target.is_undefined() { @@ -154,14 +154,14 @@ impl BuiltInConstructor for Segmenter { let native = match granularity { Granularity::Grapheme => { - GraphemeClusterSegmenter::try_new_unstable(&context.icu().provider()) + GraphemeClusterSegmenter::try_new_unstable(context.icu().provider()) .map(|s| NativeSegmenter::Grapheme(Box::new(s))) } - Granularity::Word => WordSegmenter::try_new_auto_unstable(&context.icu().provider()) + Granularity::Word => WordSegmenter::try_new_auto_unstable(context.icu().provider()) .map(|s| NativeSegmenter::Word(Box::new(s))), - Granularity::Sentence => SentenceSegmenter::try_new_unstable(&context.icu().provider()) + Granularity::Sentence => SentenceSegmenter::try_new_unstable(context.icu().provider()) .map(|s| NativeSegmenter::Sentence(Box::new(s))), } .map_err(|err| JsNativeError::typ().with_message(err.to_string()))?; @@ -199,7 +199,7 @@ impl Segmenter { fn supported_locales_of( _: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let locales = args.get_or_undefined(0); let options = args.get_or_undefined(1); @@ -223,11 +223,7 @@ impl Segmenter { /// /// [spec]: https://tc39.es/ecma402/#sec-Intl.Segmenter.prototype.resolvedoptions /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/resolvedOptions - fn resolved_options( - this: &JsValue, - _: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + fn resolved_options(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Let segmenter be the this value. // 2. Perform ? RequireInternalSlot(segmenter, [[InitializedSegmenter]]). let segmenter = this.as_object().map(JsObject::borrow).ok_or_else(|| { @@ -267,7 +263,7 @@ impl Segmenter { /// Segments a string according to the locale and granularity of this `Intl.Segmenter` object. /// /// [spec]: https://tc39.es/ecma402/#sec-intl.segmenter.prototype.segment - fn segment(this: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult { + fn segment(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let segmenter be the this value. // 2. Perform ? RequireInternalSlot(segmenter, [[InitializedSegmenter]]). let segmenter = this @@ -294,7 +290,7 @@ fn create_segment_data_object( string: JsString, range: Range, is_word_like: Option, - context: &mut Context<'_>, + context: &mut Context, ) -> JsObject { // 1. Let len be the length of string. // 2. Assert: startIndex ≥ 0. diff --git a/boa_engine/src/builtins/intl/segmenter/segments.rs b/boa_engine/src/builtins/intl/segmenter/segments.rs index e7fb671f775..ef7d4bbc9f8 100644 --- a/boa_engine/src/builtins/intl/segmenter/segments.rs +++ b/boa_engine/src/builtins/intl/segmenter/segments.rs @@ -38,11 +38,7 @@ impl Segments { /// [`CreateSegmentsObject ( segmenter, string )`][spec] /// /// [spec]: https://tc39.es/ecma402/#sec-createsegmentsobject - pub(crate) fn create( - segmenter: JsObject, - string: JsString, - context: &mut Context<'_>, - ) -> JsObject { + pub(crate) fn create(segmenter: JsObject, string: JsString, context: &mut Context) -> JsObject { // 1. Let internalSlotsList be « [[SegmentsSegmenter]], [[SegmentsString]] ». // 2. Let segments be OrdinaryObjectCreate(%SegmentsPrototype%, internalSlotsList). // 3. Set segments.[[SegmentsSegmenter]] to segmenter. @@ -57,11 +53,7 @@ impl Segments { /// [`%SegmentsPrototype%.containing ( index )`][spec] /// /// [spec]: https://tc39.es/ecma402/#sec-%segmentsprototype%.containing - fn containing( - this: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + fn containing(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let segments be the this value. // 2. Perform ? RequireInternalSlot(segments, [[SegmentsSegmenter]]). let segments = this.as_object().map(JsObject::borrow).ok_or_else(|| { @@ -116,7 +108,7 @@ impl Segments { /// [`%SegmentsPrototype% [ @@iterator ] ( )`][spec] /// /// [spec]: https://tc39.es/ecma402/#sec-%segmentsprototype%-@@iterator - fn iterator(this: &JsValue, _: &[JsValue], context: &mut Context<'_>) -> JsResult { + fn iterator(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Let segments be the this value. // 2. Perform ? RequireInternalSlot(segments, [[SegmentsSegmenter]]). let segments = this.as_object().map(JsObject::borrow).ok_or_else(|| { diff --git a/boa_engine/src/builtins/iterable/async_from_sync_iterator.rs b/boa_engine/src/builtins/iterable/async_from_sync_iterator.rs index 4bf413e78f7..7f6ab6e0c58 100644 --- a/boa_engine/src/builtins/iterable/async_from_sync_iterator.rs +++ b/boa_engine/src/builtins/iterable/async_from_sync_iterator.rs @@ -62,7 +62,7 @@ impl AsyncFromSyncIterator { /// [spec]: https://tc39.es/ecma262/#sec-createasyncfromsynciterator pub(crate) fn create( sync_iterator_record: IteratorRecord, - context: &mut Context<'_>, + context: &mut Context, ) -> IteratorRecord { // 1. Let asyncIterator be OrdinaryObjectCreate(%AsyncFromSyncIteratorPrototype%, « [[SyncIteratorRecord]] »). // 2. Set asyncIterator.[[SyncIteratorRecord]] to syncIteratorRecord. @@ -94,7 +94,7 @@ impl AsyncFromSyncIterator { /// - [ECMA reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-%asyncfromsynciteratorprototype%.next - fn next(this: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult { + fn next(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be the this value. // 2. Assert: O is an Object that has a [[SyncIteratorRecord]] internal slot. // 4. Let syncIteratorRecord be O.[[SyncIteratorRecord]]. @@ -141,7 +141,7 @@ impl AsyncFromSyncIterator { /// - [ECMA reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-%asyncfromsynciteratorprototype%.return - fn r#return(this: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult { + fn r#return(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be the this value. // 2. Assert: O is an Object that has a [[SyncIteratorRecord]] internal slot. // 4. Let syncIterator be O.[[SyncIteratorRecord]].[[Iterator]]. @@ -213,7 +213,7 @@ impl AsyncFromSyncIterator { /// - [ECMA reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-%asyncfromsynciteratorprototype%.throw - fn throw(this: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult { + fn throw(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be the this value. // 2. Assert: O is an Object that has a [[SyncIteratorRecord]] internal slot. // 4. Let syncIterator be O.[[SyncIteratorRecord]].[[Iterator]]. @@ -288,7 +288,7 @@ impl AsyncFromSyncIterator { fn continuation( result: &IteratorResult, promise_capability: &PromiseCapability, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. NOTE: Because promiseCapability is derived from the intrinsic %Promise%, // the calls to promiseCapability.[[Reject]] entailed by the diff --git a/boa_engine/src/builtins/iterable/mod.rs b/boa_engine/src/builtins/iterable/mod.rs index 0074ea2db14..6b0c723063c 100644 --- a/boa_engine/src/builtins/iterable/mod.rs +++ b/boa_engine/src/builtins/iterable/mod.rs @@ -195,7 +195,7 @@ impl IntrinsicObject for AsyncIterator { /// `CreateIterResultObject( value, done )` /// /// Generates an object supporting the `IteratorResult` interface. -pub fn create_iter_result_object(value: JsValue, done: bool, context: &mut Context<'_>) -> JsValue { +pub fn create_iter_result_object(value: JsValue, done: bool, context: &mut Context) -> JsValue { let _timer = Profiler::global().start_event("create_iter_result_object", "init"); // 1. Assert: Type(done) is Boolean. @@ -231,7 +231,7 @@ impl JsValue { /// [spec]: https://tc39.es/ecma262/#sec-getiterator pub fn get_iterator( &self, - context: &mut Context<'_>, + context: &mut Context, hint: Option, method: Option, ) -> JsResult { @@ -322,7 +322,7 @@ impl IteratorResult { /// /// [spec]: https://tc39.es/ecma262/#sec-iteratorcomplete #[inline] - pub fn complete(&self, context: &mut Context<'_>) -> JsResult { + pub fn complete(&self, context: &mut Context) -> JsResult { // 1. Return ToBoolean(? Get(iterResult, "done")). Ok(self.object.get(js_string!("done"), context)?.to_boolean()) } @@ -338,7 +338,7 @@ impl IteratorResult { /// /// [spec]: https://tc39.es/ecma262/#sec-iteratorvalue #[inline] - pub fn value(&self, context: &mut Context<'_>) -> JsResult { + pub fn value(&self, context: &mut Context) -> JsResult { // 1. Return ? Get(iterResult, "value"). self.object.get(js_string!("value"), context) } @@ -418,7 +418,7 @@ impl IteratorRecord { } /// Gets the current value of the `IteratorRecord`. - pub(crate) fn value(&mut self, context: &mut Context<'_>) -> JsResult { + pub(crate) fn value(&mut self, context: &mut Context) -> JsResult { self.set_done_on_err(|iter| iter.last_result.value(context)) } @@ -428,11 +428,7 @@ impl IteratorRecord { } /// Updates the current result value of this iterator record. - pub(crate) fn update_result( - &mut self, - result: JsValue, - context: &mut Context<'_>, - ) -> JsResult<()> { + pub(crate) fn update_result(&mut self, result: JsValue, context: &mut Context) -> JsResult<()> { self.set_done_on_err(|iter| { // 3. If Type(result) is not Object, throw a TypeError exception. // 4. Return result. @@ -466,7 +462,7 @@ impl IteratorRecord { pub(crate) fn step_with( &mut self, value: Option<&JsValue>, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let _timer = Profiler::global().start_event("IteratorRecord::step_with", "iterator"); @@ -498,7 +494,7 @@ impl IteratorRecord { /// - [ECMA reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-iteratorstep - pub(crate) fn step(&mut self, context: &mut Context<'_>) -> JsResult { + pub(crate) fn step(&mut self, context: &mut Context) -> JsResult { self.step_with(None, context) } @@ -516,7 +512,7 @@ impl IteratorRecord { pub(crate) fn close( &self, completion: JsResult, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let _timer = Profiler::global().start_event("IteratorRecord::close", "iterator"); @@ -576,7 +572,7 @@ impl IteratorRecord { /// /// [spec]: https://tc39.es/ecma262/#sec-iterabletolist pub(crate) fn iterable_to_list( - context: &mut Context<'_>, + context: &mut Context, items: &JsValue, method: Option, ) -> JsResult> { diff --git a/boa_engine/src/builtins/json/mod.rs b/boa_engine/src/builtins/json/mod.rs index 565718166c7..5902987a6e5 100644 --- a/boa_engine/src/builtins/json/mod.rs +++ b/boa_engine/src/builtins/json/mod.rs @@ -82,11 +82,7 @@ impl Json { /// /// [spec]: https://tc39.es/ecma262/#sec-json.parse /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse - pub(crate) fn parse( - _: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn parse(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let jsonString be ? ToString(text). let json_string = args .get(0) @@ -175,7 +171,7 @@ impl Json { holder: &JsObject, name: JsString, reviver: &JsObject, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let val be ? Get(holder, name). let val = holder.get(name.clone(), context)?; @@ -265,7 +261,7 @@ impl Json { pub(crate) fn stringify( _: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let stack be a new empty List. let stack = Vec::new(); @@ -415,7 +411,7 @@ impl Json { state: &mut StateRecord, key: JsString, holder: &JsObject, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult> { // 1. Let value be ? Get(holder, key). let mut value = holder.get(key.clone(), context)?; @@ -586,7 +582,7 @@ impl Json { fn serialize_json_object( state: &mut StateRecord, value: &JsObject, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If state.[[Stack]] contains value, throw a TypeError exception because the structure is cyclical. if state.stack.contains(value) { @@ -719,7 +715,7 @@ impl Json { fn serialize_json_array( state: &mut StateRecord, value: &JsObject, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If state.[[Stack]] contains value, throw a TypeError exception because the structure is cyclical. if state.stack.contains(value) { diff --git a/boa_engine/src/builtins/map/map_iterator.rs b/boa_engine/src/builtins/map/map_iterator.rs index 0eeb58ea308..5a694742903 100644 --- a/boa_engine/src/builtins/map/map_iterator.rs +++ b/boa_engine/src/builtins/map/map_iterator.rs @@ -75,7 +75,7 @@ impl MapIterator { pub(crate) fn create_map_iterator( map: &JsValue, kind: PropertyNameKind, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { if let Some(map_obj) = map.as_object() { if let Some(map) = map_obj.borrow_mut().as_map_mut() { @@ -107,11 +107,7 @@ impl MapIterator { /// - [ECMA reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-%mapiteratorprototype%.next - pub(crate) fn next( - this: &JsValue, - _: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn next(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { let mut map_iterator = this.as_object().map(JsObject::borrow_mut); let map_iterator = map_iterator .as_mut() diff --git a/boa_engine/src/builtins/map/mod.rs b/boa_engine/src/builtins/map/mod.rs index 19011fa290e..6efd04acaa4 100644 --- a/boa_engine/src/builtins/map/mod.rs +++ b/boa_engine/src/builtins/map/mod.rs @@ -125,7 +125,7 @@ impl BuiltInConstructor for Map { fn constructor( new_target: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If NewTarget is undefined, throw a TypeError exception. if new_target.is_undefined() { @@ -170,7 +170,7 @@ impl Map { /// [spec]: https://tc39.es/ecma262/#sec-get-map-@@species /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/@@species #[allow(clippy::unnecessary_wraps)] - fn get_species(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn get_species(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { // 1. Return the this value. Ok(this.clone()) } @@ -188,7 +188,7 @@ impl Map { pub(crate) fn entries( this: &JsValue, _: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let M be the this value. // 2. Return ? CreateMapIterator(M, key+value). @@ -205,11 +205,7 @@ impl Map { /// /// [spec]: https://tc39.es/ecma262/#sec-map.prototype.keys /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/keys - pub(crate) fn keys( - this: &JsValue, - _: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn keys(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Let M be the this value. // 2. Return ? CreateMapIterator(M, key). MapIterator::create_map_iterator(this, PropertyNameKind::Key, context) @@ -225,7 +221,7 @@ impl Map { /// /// [spec]: https://tc39.es/ecma262/#sec-map.prototype.set /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/set - pub(crate) fn set(this: &JsValue, args: &[JsValue], _: &mut Context<'_>) -> JsResult { + pub(crate) fn set(this: &JsValue, args: &[JsValue], _: &mut Context) -> JsResult { let key = args.get_or_undefined(0); let value = args.get_or_undefined(1); @@ -272,11 +268,7 @@ impl Map { /// /// [spec]: https://tc39.es/ecma262/#sec-get-map.prototype.size /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/size - pub(crate) fn get_size( - this: &JsValue, - _: &[JsValue], - _: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn get_size(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { // 1. Let M be the this value. if let Some(object) = this.as_object() { // 2. Perform ? RequireInternalSlot(M, [[MapData]]). @@ -305,11 +297,7 @@ impl Map { /// /// [spec]: https://tc39.es/ecma262/#sec-map.prototype.delete /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/delete - pub(crate) fn delete( - this: &JsValue, - args: &[JsValue], - _: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn delete(this: &JsValue, args: &[JsValue], _: &mut Context) -> JsResult { const JS_ZERO: &JsValue = &JsValue::Integer(0); let key = args.get_or_undefined(0); let key = match key.as_number() { @@ -345,7 +333,7 @@ impl Map { /// /// [spec]: https://tc39.es/ecma262/#sec-map.prototype.get /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get - pub(crate) fn get(this: &JsValue, args: &[JsValue], _: &mut Context<'_>) -> JsResult { + pub(crate) fn get(this: &JsValue, args: &[JsValue], _: &mut Context) -> JsResult { const JS_ZERO: &JsValue = &JsValue::Integer(0); let key = args.get_or_undefined(0); let key = match key.as_number() { @@ -380,7 +368,7 @@ impl Map { /// /// [spec]: https://tc39.es/ecma262/#sec-map.prototype.clear /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/clear - pub(crate) fn clear(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + pub(crate) fn clear(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { // 1. Let M be the this value. // 2. Perform ? RequireInternalSlot(M, [[MapData]]). if let Some(object) = this.as_object() { @@ -410,7 +398,7 @@ impl Map { /// /// [spec]: https://tc39.es/ecma262/#sec-map.prototype.has /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/has - pub(crate) fn has(this: &JsValue, args: &[JsValue], _: &mut Context<'_>) -> JsResult { + pub(crate) fn has(this: &JsValue, args: &[JsValue], _: &mut Context) -> JsResult { const JS_ZERO: &JsValue = &JsValue::Integer(0); let key = args.get_or_undefined(0); let key = match key.as_number() { @@ -448,7 +436,7 @@ impl Map { pub(crate) fn for_each( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let M be the this value. // 2. Perform ? RequireInternalSlot(M, [[MapData]]). @@ -519,7 +507,7 @@ impl Map { pub(crate) fn values( this: &JsValue, _: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let M be the this value. // 2. Return ? CreateMapIterator(M, value). @@ -533,7 +521,7 @@ impl Map { pub(crate) fn group_by( _: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { use std::hash::BuildHasherDefault; @@ -650,7 +638,7 @@ pub(crate) fn add_entries_from_iterable( target: &JsObject, iterable: &JsValue, adder: &JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If IsCallable(adder) is false, throw a TypeError exception. let adder = adder.as_callable().ok_or_else(|| { diff --git a/boa_engine/src/builtins/math/mod.rs b/boa_engine/src/builtins/math/mod.rs index 6d0693b2ac5..5bd7805bd87 100644 --- a/boa_engine/src/builtins/math/mod.rs +++ b/boa_engine/src/builtins/math/mod.rs @@ -106,11 +106,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.abs /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/abs - pub(crate) fn abs( - _: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn abs(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { Ok(args .get_or_undefined(0) // 1. Let n be ? ToNumber(x). @@ -132,11 +128,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.acos /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/acos - pub(crate) fn acos( - _: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn acos(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { Ok(args .get_or_undefined(0) // 1. Let n be ? ToNumber(x). @@ -156,11 +148,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.acosh /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/acosh - pub(crate) fn acosh( - _: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn acosh(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { Ok(args .get_or_undefined(0) // 1. Let n be ? ToNumber(x). @@ -181,11 +169,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.asin /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/asin - pub(crate) fn asin( - _: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn asin(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { Ok(args .get_or_undefined(0) // 1. Let n be ? ToNumber(x). @@ -205,11 +189,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.asinh /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/asinh - pub(crate) fn asinh( - _: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn asinh(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { Ok(args .get_or_undefined(0) // 1. Let n be ? ToNumber(x). @@ -228,11 +208,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.atan /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atan - pub(crate) fn atan( - _: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn atan(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { Ok(args .get_or_undefined(0) // 1. Let n be ? ToNumber(x). @@ -253,11 +229,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.atanh /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atanh - pub(crate) fn atanh( - _: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn atanh(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { Ok(args .get_or_undefined(0) // 1. Let n be ? ToNumber(x). @@ -279,11 +251,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.atan2 /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atan2 - pub(crate) fn atan2( - _: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn atan2(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let ny be ? ToNumber(y). let y = args.get_or_undefined(0).to_number(context)?; @@ -326,11 +294,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.cbrt /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cbrt - pub(crate) fn cbrt( - _: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn cbrt(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { Ok(args .get_or_undefined(0) // 1. Let n be ? ToNumber(x). @@ -349,11 +313,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.ceil /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/ceil - pub(crate) fn ceil( - _: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn ceil(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { Ok(args .get_or_undefined(0) // 1. Let n be ? ToNumber(x). @@ -374,11 +334,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.clz32 /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32 - pub(crate) fn clz32( - _: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn clz32(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { Ok(args .get_or_undefined(0) // 1. Let n be ? ToUint32(x). @@ -397,11 +353,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.cos /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cos - pub(crate) fn cos( - _: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn cos(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { Ok(args .get_or_undefined(0) // 1. Let n be ? ToNumber(x). @@ -421,11 +373,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.cosh /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cosh - pub(crate) fn cosh( - _: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn cosh(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { Ok(args .get_or_undefined(0) // 1. Let n be ? ToNumber(x). @@ -446,11 +394,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.exp /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/exp - pub(crate) fn exp( - _: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn exp(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { Ok(args .get_or_undefined(0) // 1. Let n be ? ToNumber(x). @@ -473,11 +417,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.expm1 /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/expm1 - pub(crate) fn expm1( - _: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn expm1(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { Ok(args .get_or_undefined(0) // 1. Let n be ? ToNumber(x). @@ -497,11 +437,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.floor /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/floor - pub(crate) fn floor( - _: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn floor(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { Ok(args .get_or_undefined(0) // 1. Let n be ? ToNumber(x). @@ -525,7 +461,7 @@ impl Math { pub(crate) fn fround( _: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let n be ? ToNumber(x). let x = args.get_or_undefined(0).to_number(context)?; @@ -546,11 +482,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.hypot /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/hypot - pub(crate) fn hypot( - _: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn hypot(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let coerced be a new empty List. // 2. For each element arg of args, do // a. Let n be ? ToNumber(arg). @@ -580,11 +512,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.imul /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul - pub(crate) fn imul( - _: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn imul(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let a be ℝ(? ToUint32(x)). let x = args.get_or_undefined(0).to_u32(context)?; @@ -604,11 +532,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.log /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log - pub(crate) fn log( - _: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn log(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { Ok(args .get_or_undefined(0) // 1. Let n be ? ToNumber(x). @@ -630,11 +554,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.log1p /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log1p - pub(crate) fn log1p( - _: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn log1p(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { Ok(args .get_or_undefined(0) // 1. Let n be ? ToNumber(x). @@ -655,11 +575,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.log10 /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log10 - pub(crate) fn log10( - _: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn log10(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { Ok(args .get_or_undefined(0) // 1. Let n be ? ToNumber(x). @@ -681,11 +597,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.log2 /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log2 - pub(crate) fn log2( - _: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn log2(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { Ok(args .get_or_undefined(0) // 1. Let n be ? ToNumber(x). @@ -707,11 +619,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.max /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/max - pub(crate) fn max( - _: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn max(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let coerced be a new empty List. // 2. For each element arg of args, do // b. Append n to coerced. @@ -749,11 +657,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.min /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/min - pub(crate) fn min( - _: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn min(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let coerced be a new empty List. // 2. For each element arg of args, do // b. Append n to coerced. @@ -792,11 +696,7 @@ impl Math { /// [spec]: https://tc39.es/ecma262/#sec-math.pow /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/pow #[allow(clippy::float_cmp)] - pub(crate) fn pow( - _: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn pow(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Set base to ? ToNumber(base). let x = args.get_or_undefined(0).to_number(context)?; @@ -821,7 +721,7 @@ impl Math { /// [spec]: https://tc39.es/ecma262/#sec-math.random /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random #[allow(clippy::unnecessary_wraps)] - pub(crate) fn random(_: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + pub(crate) fn random(_: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { // NOTE: Each Math.random function created for distinct realms must produce a distinct sequence of values from successive calls. Ok(rand::random::().into()) } @@ -835,11 +735,7 @@ impl Math { /// [spec]: https://tc39.es/ecma262/#sec-math.round /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/round #[allow(clippy::float_cmp)] - pub(crate) fn round( - _: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn round(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let num = args .get_or_undefined(0) //1. Let n be ? ToNumber(x). @@ -865,11 +761,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.sign /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign - pub(crate) fn sign( - _: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn sign(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let n be ? ToNumber(x). let n = args.get_or_undefined(0).to_number(context)?; @@ -890,11 +782,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.sin /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sin - pub(crate) fn sin( - _: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn sin(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { Ok(args .get_or_undefined(0) // 1. Let n be ? ToNumber(x). @@ -914,11 +802,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.sinh /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sinh - pub(crate) fn sinh( - _: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn sinh(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { Ok(args .get_or_undefined(0) // 1. Let n be ? ToNumber(x). @@ -937,11 +821,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.sqrt /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sqrt - pub(crate) fn sqrt( - _: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn sqrt(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { Ok(args .get_or_undefined(0) // 1. Let n be ? ToNumber(x). @@ -961,11 +841,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.tan /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/tan - pub(crate) fn tan( - _: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn tan(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { Ok(args .get_or_undefined(0) // 1. Let n be ? ToNumber(x). @@ -985,11 +861,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.tanh /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/tanh - pub(crate) fn tanh( - _: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn tanh(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { Ok(args .get_or_undefined(0) // 1. Let n be ? ToNumber(x). @@ -1010,11 +882,7 @@ impl Math { /// /// [spec]: https://tc39.es/ecma262/#sec-math.trunc /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc - pub(crate) fn trunc( - _: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn trunc(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { Ok(args .get_or_undefined(0) // 1. Let n be ? ToNumber(x). diff --git a/boa_engine/src/builtins/mod.rs b/boa_engine/src/builtins/mod.rs index 2240401737a..239eb87b519 100644 --- a/boa_engine/src/builtins/mod.rs +++ b/boa_engine/src/builtins/mod.rs @@ -170,11 +170,11 @@ pub(crate) trait BuiltInConstructor: BuiltInObject { fn constructor( new_target: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult; } -fn global_binding(context: &mut Context<'_>) -> JsResult<()> { +fn global_binding(context: &mut Context) -> JsResult<()> { let name = B::NAME; let attr = B::ATTRIBUTE; let intrinsic = B::get(context.intrinsics()); @@ -307,7 +307,7 @@ impl Realm { /// Abstract operation [`SetDefaultGlobalBindings ( realmRec )`][spec]. /// /// [spec]: https://tc39.es/ecma262/#sec-setdefaultglobalbindings -pub(crate) fn set_default_global_bindings(context: &mut Context<'_>) -> JsResult<()> { +pub(crate) fn set_default_global_bindings(context: &mut Context) -> JsResult<()> { let global_object = context.global_object(); global_object.define_property_or_throw( diff --git a/boa_engine/src/builtins/number/globals.rs b/boa_engine/src/builtins/number/globals.rs index 62ac94104ce..7e8127228e4 100644 --- a/boa_engine/src/builtins/number/globals.rs +++ b/boa_engine/src/builtins/number/globals.rs @@ -25,7 +25,7 @@ use num_traits::Num; /// /// [spec]: https://tc39.es/ecma262/#sec-isfinite-number /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isFinite -fn is_finite(_: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult { +fn is_finite(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { if let Some(value) = args.get(0) { let number = value.to_number(context)?; Ok(number.is_finite().into()) @@ -67,11 +67,7 @@ impl BuiltInObject for IsFinite { /// /// [spec]: https://tc39.es/ecma262/#sec-isnan-number /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isNaN -pub(crate) fn is_nan( - _: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, -) -> JsResult { +pub(crate) fn is_nan(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { if let Some(value) = args.get(0) { let number = value.to_number(context)?; Ok(number.is_nan().into()) @@ -113,11 +109,7 @@ impl BuiltInObject for IsNaN { /// /// [spec]: https://tc39.es/ecma262/#sec-parseint-string-radix /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt -pub(crate) fn parse_int( - _: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, -) -> JsResult { +pub(crate) fn parse_int(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { if let (Some(val), radix) = (args.get(0), args.get_or_undefined(1)) { // 1. Let inputString be ? ToString(string). let input_string = val.to_string(context)?; @@ -258,7 +250,7 @@ impl BuiltInObject for ParseInt { pub(crate) fn parse_float( _: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { if let Some(val) = args.get(0) { // TODO: parse float with optimal utf16 algorithm diff --git a/boa_engine/src/builtins/number/mod.rs b/boa_engine/src/builtins/number/mod.rs index 4598df87958..5999f2aa6a6 100644 --- a/boa_engine/src/builtins/number/mod.rs +++ b/boa_engine/src/builtins/number/mod.rs @@ -115,7 +115,7 @@ impl BuiltInConstructor for Number { fn constructor( new_target: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let data = match args.get(0) { Some(value) => value.to_numeric_number(context)?, @@ -216,7 +216,7 @@ impl Number { pub(crate) fn to_exponential( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let x be ? thisNumberValue(this value). let this_num = Self::this_number_value(this)?; @@ -261,7 +261,7 @@ impl Number { pub(crate) fn to_fixed( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let this_num be ? thisNumberValue(this value). let this_num = Self::this_number_value(this)?; @@ -302,7 +302,7 @@ impl Number { pub(crate) fn to_locale_string( this: &JsValue, _: &[JsValue], - _: &mut Context<'_>, + _: &mut Context, ) -> JsResult { let this_num = Self::this_number_value(this)?; let this_str_num = this_num.to_string(); @@ -410,7 +410,7 @@ impl Number { pub(crate) fn to_precision( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let precision = args.get_or_undefined(0); @@ -661,7 +661,7 @@ impl Number { pub(crate) fn to_string( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let x be ? thisNumberValue(this value). let x = Self::this_number_value(this)?; @@ -720,11 +720,7 @@ impl Number { /// /// [spec]: https://tc39.es/ecma262/#sec-number.prototype.valueof /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/valueOf - pub(crate) fn value_of( - this: &JsValue, - _: &[JsValue], - _: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn value_of(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Ok(JsValue::new(Self::this_number_value(this)?)) } @@ -746,7 +742,7 @@ impl Number { pub(crate) fn number_is_finite( _: &JsValue, args: &[JsValue], - _ctx: &mut Context<'_>, + _ctx: &mut Context, ) -> JsResult { // 1. If number is not a Number, return false. // 2. If number is not finite, return false. @@ -772,7 +768,7 @@ impl Number { pub(crate) fn number_is_integer( _: &JsValue, args: &[JsValue], - _ctx: &mut Context<'_>, + _ctx: &mut Context, ) -> JsResult { Ok(args.get(0).map_or(false, Self::is_integer).into()) } @@ -795,7 +791,7 @@ impl Number { pub(crate) fn number_is_nan( _: &JsValue, args: &[JsValue], - _ctx: &mut Context<'_>, + _ctx: &mut Context, ) -> JsResult { Ok(JsValue::new( if let Some(&JsValue::Rational(number)) = args.get(0) { @@ -824,7 +820,7 @@ impl Number { pub(crate) fn is_safe_integer( _: &JsValue, args: &[JsValue], - _ctx: &mut Context<'_>, + _ctx: &mut Context, ) -> JsResult { Ok(JsValue::new(match args.get(0) { Some(JsValue::Integer(_)) => true, diff --git a/boa_engine/src/builtins/object/for_in_iterator.rs b/boa_engine/src/builtins/object/for_in_iterator.rs index 95cb76b71cb..f0098d19feb 100644 --- a/boa_engine/src/builtins/object/for_in_iterator.rs +++ b/boa_engine/src/builtins/object/for_in_iterator.rs @@ -77,7 +77,7 @@ impl ForInIterator { /// - [ECMA reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-createforiniterator - pub(crate) fn create_for_in_iterator(object: JsValue, context: &Context<'_>) -> JsObject { + pub(crate) fn create_for_in_iterator(object: JsValue, context: &Context) -> JsObject { JsObject::from_proto_and_data_with_shared_shape( context.root_shape(), context @@ -97,11 +97,7 @@ impl ForInIterator { /// - [ECMA reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-%foriniteratorprototype%.next - pub(crate) fn next( - this: &JsValue, - _: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn next(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { let mut iterator = this.as_object().map(JsObject::borrow_mut); let iterator = iterator .as_mut() diff --git a/boa_engine/src/builtins/object/mod.rs b/boa_engine/src/builtins/object/mod.rs index 51430c5cd08..86560efa7e5 100644 --- a/boa_engine/src/builtins/object/mod.rs +++ b/boa_engine/src/builtins/object/mod.rs @@ -157,7 +157,7 @@ impl BuiltInConstructor for Object { fn constructor( new_target: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If NewTarget is neither undefined nor the active function object, then if !new_target.is_undefined() @@ -205,7 +205,7 @@ impl Object { pub fn legacy_proto_getter( this: &JsValue, _: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? ToObject(this value). let obj = this.to_object(context)?; @@ -230,7 +230,7 @@ impl Object { pub fn legacy_proto_setter( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? RequireObjectCoercible(this value). let this = this.require_object_coercible()?; @@ -274,7 +274,7 @@ impl Object { pub fn legacy_define_getter( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let getter = args.get_or_undefined(1); @@ -317,7 +317,7 @@ impl Object { pub fn legacy_define_setter( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let setter = args.get_or_undefined(1); @@ -360,7 +360,7 @@ impl Object { pub fn legacy_lookup_getter( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? ToObject(this value). let mut obj = this.to_object(context)?; @@ -404,7 +404,7 @@ impl Object { pub fn legacy_lookup_setter( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? ToObject(this value). let mut obj = this.to_object(context)?; @@ -446,7 +446,7 @@ impl Object { /// /// [spec]: https://tc39.es/ecma262/#sec-object.create /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create - pub fn create(_: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult { + pub fn create(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let prototype = args.get_or_undefined(0); let properties = args.get_or_undefined(1); @@ -487,7 +487,7 @@ impl Object { pub fn get_own_property_descriptor( _: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let obj be ? ToObject(O). let obj = args.get_or_undefined(0).to_object(context)?; @@ -515,7 +515,7 @@ impl Object { pub fn get_own_property_descriptors( _: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let obj be ? ToObject(O). let obj = args.get_or_undefined(0).to_object(context)?; @@ -554,7 +554,7 @@ impl Object { /// [spec]: https://tc39.es/ecma262/#sec-frompropertydescriptor pub(crate) fn from_property_descriptor( desc: Option, - context: &mut Context<'_>, + context: &mut Context, ) -> JsValue { // 1. If Desc is undefined, return undefined. let Some(desc) = desc else { @@ -612,7 +612,7 @@ impl Object { } /// Uses the `SameValue` algorithm to check equality of objects - pub fn is(_: &JsValue, args: &[JsValue], _: &mut Context<'_>) -> JsResult { + pub fn is(_: &JsValue, args: &[JsValue], _: &mut Context) -> JsResult { let x = args.get_or_undefined(0); let y = args.get_or_undefined(1); @@ -627,7 +627,7 @@ impl Object { pub fn get_prototype_of( _: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { if args.is_empty() { return Err(JsNativeError::typ() @@ -654,7 +654,7 @@ impl Object { pub fn set_prototype_of( _: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { if args.len() < 2 { return Err(JsNativeError::typ() @@ -719,7 +719,7 @@ impl Object { pub fn is_prototype_of( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let v = args.get_or_undefined(0); if !v.is_object() { @@ -742,7 +742,7 @@ impl Object { pub fn define_property( _: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let object = args.get_or_undefined(0); if let JsValue::Object(object) = object { @@ -778,7 +778,7 @@ impl Object { pub fn define_properties( _: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let arg = args.get_or_undefined(0); if let JsValue::Object(obj) = arg { @@ -800,7 +800,7 @@ impl Object { /// /// [spec]: https://tc39.es/ecma262/#sec-object.prototype.valueof /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/valueOf - pub fn value_of(this: &JsValue, _: &[JsValue], context: &mut Context<'_>) -> JsResult { + pub fn value_of(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Return ? ToObject(this value). Ok(this.to_object(context)?.into()) } @@ -816,11 +816,7 @@ impl Object { /// [spec]: https://tc39.es/ecma262/#sec-object.prototype.tostring /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString #[allow(clippy::wrong_self_convention)] - pub fn to_string( - this: &JsValue, - _: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub fn to_string(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. If the this value is undefined, return "[object Undefined]". if this.is_undefined() { return Ok(js_string!("[object Undefined]").into()); @@ -881,7 +877,7 @@ impl Object { pub fn to_locale_string( this: &JsValue, _: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be the this value. // 2. Return ? Invoke(O, "toString"). @@ -902,7 +898,7 @@ impl Object { pub fn has_own_property( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let P be ? ToPropertyKey(V). let key = args.get_or_undefined(0).to_property_key(context)?; @@ -928,7 +924,7 @@ impl Object { pub fn property_is_enumerable( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let Some(key) = args.get(0) else { return Ok(JsValue::new(false)); @@ -958,7 +954,7 @@ impl Object { /// /// [spec]: https://tc39.es/ecma262/#sec-object.assign /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign - pub fn assign(_: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult { + pub fn assign(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let to be ? ToObject(target). let to = args.get_or_undefined(0).to_object(context)?; @@ -1008,7 +1004,7 @@ impl Object { /// /// [spec]: https://tc39.es/ecma262/#sec-object.keys /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys - pub fn keys(_: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult { + pub fn keys(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let obj be ? ToObject(target). let obj = args .get(0) @@ -1033,7 +1029,7 @@ impl Object { /// /// [spec]: https://tc39.es/ecma262/#sec-object.values /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/values - pub fn values(_: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult { + pub fn values(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let obj be ? ToObject(target). let obj = args .get(0) @@ -1062,7 +1058,7 @@ impl Object { /// /// [spec]: https://tc39.es/ecma262/#sec-object.entries /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries - pub fn entries(_: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult { + pub fn entries(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let obj be ? ToObject(target). let obj = args .get(0) @@ -1088,7 +1084,7 @@ impl Object { /// /// [spec]: https://tc39.es/ecma262/#sec-object.seal /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/seal - pub fn seal(_: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult { + pub fn seal(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let o = args.get_or_undefined(0); if let Some(o) = o.as_object() { @@ -1114,11 +1110,7 @@ impl Object { /// /// [spec]: https://tc39.es/ecma262/#sec-object.issealed /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isSealed - pub fn is_sealed( - _: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub fn is_sealed(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let o = args.get_or_undefined(0); // 1. If Type(O) is not Object, return true. @@ -1139,7 +1131,7 @@ impl Object { /// /// [spec]: https://tc39.es/ecma262/#sec-object.freeze /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze - pub fn freeze(_: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult { + pub fn freeze(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let o = args.get_or_undefined(0); if let Some(o) = o.as_object() { @@ -1165,11 +1157,7 @@ impl Object { /// /// [spec]: https://tc39.es/ecma262/#sec-object.isfrozen /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isFrozen - pub fn is_frozen( - _: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub fn is_frozen(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let o = args.get_or_undefined(0); // 1. If Type(O) is not Object, return true. @@ -1193,7 +1181,7 @@ impl Object { pub fn prevent_extensions( _: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let o = args.get_or_undefined(0); @@ -1223,7 +1211,7 @@ impl Object { pub fn is_extensible( _: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let o = args.get_or_undefined(0); // 1. If Type(O) is not Object, return false. @@ -1246,7 +1234,7 @@ impl Object { pub fn get_own_property_names( _: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Return ? GetOwnPropertyKeys(O, string). let o = args.get_or_undefined(0); @@ -1264,7 +1252,7 @@ impl Object { pub fn get_own_property_symbols( _: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Return ? GetOwnPropertyKeys(O, symbol). let o = args.get_or_undefined(0); @@ -1279,7 +1267,7 @@ impl Object { /// /// [spec]: https://tc39.es/ecma262/#sec-object.hasown /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwn - pub fn has_own(_: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult { + pub fn has_own(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let obj be ? ToObject(O). let obj = args.get_or_undefined(0).to_object(context)?; @@ -1298,11 +1286,7 @@ impl Object { /// /// [spec]: https://tc39.es/ecma262/#sec-object.fromentries /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/fromEntries - pub fn from_entries( - _: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub fn from_entries(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Perform ? RequireObjectCoercible(iterable). let iterable = args.get_or_undefined(0).require_object_coercible()?; @@ -1346,7 +1330,7 @@ impl Object { pub(crate) fn group_by( _: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { use std::hash::BuildHasherDefault; @@ -1453,7 +1437,7 @@ impl Object { fn object_define_properties( object: &JsObject, props: &JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult<()> { // 1. Assert: Type(O) is Object. // 2. Let props be ? ToObject(Properties). @@ -1511,7 +1495,7 @@ enum PropertyKeyType { fn get_own_property_keys( o: &JsValue, r#type: PropertyKeyType, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let obj be ? ToObject(o). let obj = o.to_object(context)?; diff --git a/boa_engine/src/builtins/options.rs b/boa_engine/src/builtins/options.rs index 004682246ec..b2a99f5559a 100644 --- a/boa_engine/src/builtins/options.rs +++ b/boa_engine/src/builtins/options.rs @@ -12,7 +12,7 @@ pub(crate) trait OptionType: Sized { /// steps instead of returning a pure string, number or boolean. /// /// [spec]: https://tc39.es/ecma402/#sec-getoption - fn from_value(value: JsValue, context: &mut Context<'_>) -> JsResult; + fn from_value(value: JsValue, context: &mut Context) -> JsResult; } /// A type that implements [`OptionType`] by parsing a string. @@ -24,7 +24,7 @@ impl OptionType for T where T::Err: fmt::Display, { - fn from_value(value: JsValue, context: &mut Context<'_>) -> JsResult { + fn from_value(value: JsValue, context: &mut Context) -> JsResult { value .to_string(context)? .to_std_string_escaped() @@ -51,7 +51,7 @@ where pub(crate) fn get_option( options: &JsObject, property: &[u16], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult> { // 1. Let value be ? Get(options, property). let value = options.get(property, context)?; @@ -95,7 +95,7 @@ pub(crate) fn get_options_object(options: &JsValue) -> JsResult { // Common options used in several builtins impl OptionType for bool { - fn from_value(value: JsValue, _: &mut Context<'_>) -> JsResult { + fn from_value(value: JsValue, _: &mut Context) -> JsResult { // 5. If type is "boolean", then // a. Set value to ! ToBoolean(value). Ok(value.to_boolean()) @@ -103,7 +103,7 @@ impl OptionType for bool { } impl OptionType for JsString { - fn from_value(value: JsValue, context: &mut Context<'_>) -> JsResult { + fn from_value(value: JsValue, context: &mut Context) -> JsResult { // 6. If type is "string", then // a. Set value to ? ToString(value). value.to_string(context) diff --git a/boa_engine/src/builtins/promise/mod.rs b/boa_engine/src/builtins/promise/mod.rs index 01cb74f4d70..4526726e959 100644 --- a/boa_engine/src/builtins/promise/mod.rs +++ b/boa_engine/src/builtins/promise/mod.rs @@ -219,7 +219,7 @@ impl PromiseCapability { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-newpromisecapability - pub(crate) fn new(c: &JsObject, context: &mut Context<'_>) -> JsResult { + pub(crate) fn new(c: &JsObject, context: &mut Context) -> JsResult { #[derive(Debug, Clone, Trace, Finalize)] struct RejectResolve { reject: JsValue, @@ -393,7 +393,7 @@ impl BuiltInConstructor for Promise { fn constructor( new_target: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If NewTarget is undefined, throw a TypeError exception. if new_target.is_undefined() { @@ -475,7 +475,7 @@ impl Promise { pub(crate) fn with_resolvers( this: &JsValue, _args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let C be the this value. let c = this.as_object().ok_or_else(|| { @@ -512,7 +512,7 @@ impl Promise { pub(crate) fn all( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let C be the this value. let c = this.as_object().ok_or_else(|| { @@ -573,7 +573,7 @@ impl Promise { constructor: &JsObject, result_capability: &PromiseCapability, promise_resolve: &JsObject, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { #[derive(Debug, Trace, Finalize)] struct ResolveElementCaptures { @@ -739,7 +739,7 @@ impl Promise { pub(crate) fn all_settled( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let C be the this value. let c = this.as_object().ok_or_else(|| { @@ -800,7 +800,7 @@ impl Promise { constructor: &JsObject, result_capability: &PromiseCapability, promise_resolve: &JsObject, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { #[derive(Debug, Trace, Finalize)] struct ResolveRejectElementCaptures { @@ -1074,7 +1074,7 @@ impl Promise { pub(crate) fn any( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let C be the this value. let c = this.as_object().ok_or_else(|| { @@ -1135,7 +1135,7 @@ impl Promise { constructor: &JsObject, result_capability: &PromiseCapability, promise_resolve: &JsObject, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { #[derive(Debug, Trace, Finalize)] struct RejectElementCaptures { @@ -1315,7 +1315,7 @@ impl Promise { pub(crate) fn race( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let iterable = args.get_or_undefined(0); @@ -1383,7 +1383,7 @@ impl Promise { constructor: &JsObject, result_capability: &PromiseCapability, promise_resolve: &JsObject, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let constructor = constructor.clone().into(); // 1. Repeat, @@ -1431,7 +1431,7 @@ impl Promise { pub(crate) fn reject( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let r = args.get_or_undefined(0).clone(); @@ -1447,7 +1447,7 @@ impl Promise { pub(crate) fn promise_reject( c: &JsObject, e: &JsError, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let e = e.to_opaque(context); @@ -1475,7 +1475,7 @@ impl Promise { pub(crate) fn resolve( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let x = args.get_or_undefined(0); @@ -1502,7 +1502,7 @@ impl Promise { pub(crate) fn promise_resolve( c: &JsObject, x: JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If IsPromise(x) is true, then if let Some(x) = x.as_promise() { @@ -1541,7 +1541,7 @@ impl Promise { /// [spec]: https://tc39.es/ecma262/#sec-get-promise-@@species /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/@@species #[allow(clippy::unnecessary_wraps)] - fn get_species(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn get_species(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { // 1. Return the this value. Ok(this.clone()) } @@ -1557,7 +1557,7 @@ impl Promise { pub(crate) fn catch( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let on_rejected = args.get_or_undefined(0); @@ -1582,7 +1582,7 @@ impl Promise { pub(crate) fn finally( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let promise be the this value. let promise = this; @@ -1626,7 +1626,7 @@ impl Promise { pub(crate) fn then_catch_finally_closures( c: JsObject, on_finally: JsFunction, - context: &mut Context<'_>, + context: &mut Context, ) -> (JsFunction, JsFunction) { /// Capture object for the `thenFinallyClosure` abstract closure. #[derive(Debug, Trace, Finalize)] @@ -1748,7 +1748,7 @@ impl Promise { pub(crate) fn then( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let promise be the this value. let promise = this; @@ -1779,7 +1779,7 @@ impl Promise { promise: &JsObject, on_fulfilled: Option, on_rejected: Option, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 3. Let C be ? SpeciesConstructor(promise, %Promise%). let c = promise.species_constructor(StandardConstructors::promise, context)?; @@ -1811,7 +1811,7 @@ impl Promise { on_fulfilled: Option, on_rejected: Option, result_capability: Option, - context: &mut Context<'_>, + context: &mut Context, ) { // 1. Assert: IsPromise(promise) is true. @@ -1928,7 +1928,7 @@ impl Promise { /// [spec]: https://tc39.es/ecma262/#sec-getpromiseresolve pub(crate) fn get_promise_resolve( promise_constructor: &JsObject, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let promiseResolve be ? Get(promiseConstructor, "resolve"). let promise_resolve = promise_constructor.get(utf16!("resolve"), context)?; @@ -1949,7 +1949,7 @@ impl Promise { /// [spec]: https://tc39.es/ecma262/#sec-createresolvingfunctions pub(crate) fn create_resolving_functions( promise: &JsObject, - context: &mut Context<'_>, + context: &mut Context, ) -> ResolvingFunctions { /// `TriggerPromiseReactions ( reactions, argument )` /// @@ -1967,7 +1967,7 @@ impl Promise { fn trigger_promise_reactions( reactions: Vec, argument: &JsValue, - context: &mut Context<'_>, + context: &mut Context, ) { // 1. For each element reaction of reactions, do for reaction in reactions { @@ -1993,7 +1993,7 @@ impl Promise { /// # Panics /// /// Panics if `Promise` is not pending. - fn fulfill_promise(promise: &JsObject, value: JsValue, context: &mut Context<'_>) { + fn fulfill_promise(promise: &JsObject, value: JsValue, context: &mut Context) { let mut promise = promise.borrow_mut(); let promise = promise .as_promise_mut() @@ -2037,7 +2037,7 @@ impl Promise { /// # Panics /// /// Panics if `Promise` is not pending. - fn reject_promise(promise: &JsObject, reason: JsValue, context: &mut Context<'_>) { + fn reject_promise(promise: &JsObject, reason: JsValue, context: &mut Context) { let handled = { let mut promise = promise.borrow_mut(); let promise = promise @@ -2230,7 +2230,7 @@ impl Promise { fn new_promise_reaction_job( mut reaction: ReactionRecord, argument: JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> NativeJob { // Inverting order since `job` captures `reaction` by value. @@ -2248,7 +2248,7 @@ fn new_promise_reaction_job( .unwrap_or_else(|| context.realm().clone()); // 1. Let job be a new Job Abstract Closure with no parameters that captures reaction and argument and performs the following steps when called: - let job = move |context: &mut Context<'_>| { + let job = move |context: &mut Context| { // a. Let promiseCapability be reaction.[[Capability]]. let promise_capability = reaction.promise_capability.take(); // b. Let type be reaction.[[Type]]. @@ -2323,7 +2323,7 @@ fn new_promise_resolve_thenable_job( promise_to_resolve: JsObject, thenable: JsValue, then: JobCallback, - context: &mut Context<'_>, + context: &mut Context, ) -> NativeJob { // Inverting order since `job` captures variables by value. @@ -2337,7 +2337,7 @@ fn new_promise_resolve_thenable_job( .unwrap_or_else(|_| context.realm().clone()); // 1. Let job be a new Job Abstract Closure with no parameters that captures promiseToResolve, thenable, and then and performs the following steps when called: - let job = move |context: &mut Context<'_>| { + let job = move |context: &mut Context| { // a. Let resolvingFunctions be CreateResolvingFunctions(promiseToResolve). let resolving_functions = Promise::create_resolving_functions(&promise_to_resolve, context); diff --git a/boa_engine/src/builtins/proxy/mod.rs b/boa_engine/src/builtins/proxy/mod.rs index cffdc4d84e7..e546ac0cc11 100644 --- a/boa_engine/src/builtins/proxy/mod.rs +++ b/boa_engine/src/builtins/proxy/mod.rs @@ -65,7 +65,7 @@ impl BuiltInConstructor for Proxy { fn constructor( new_target: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If NewTarget is undefined, throw a TypeError exception. if new_target.is_undefined() { @@ -106,7 +106,7 @@ impl Proxy { pub(crate) fn create( target: &JsValue, handler: &JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If Type(target) is not Object, throw a TypeError exception. let target = target.as_object().ok_or_else(|| { @@ -140,7 +140,7 @@ impl Proxy { Ok(p) } - pub(crate) fn revoker(proxy: JsObject, context: &mut Context<'_>) -> JsFunction { + pub(crate) fn revoker(proxy: JsObject, context: &mut Context) -> JsFunction { // 3. Let revoker be ! CreateBuiltinFunction(revokerClosure, 0, "", « [[RevocableProxy]] »). // 4. Set revoker.[[RevocableProxy]] to p. FunctionObjectBuilder::new( @@ -176,7 +176,7 @@ impl Proxy { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-proxy.revocable - fn revocable(_: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult { + fn revocable(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let p be ? ProxyCreate(target, handler). let p = Self::create(args.get_or_undefined(0), args.get_or_undefined(1), context)?; diff --git a/boa_engine/src/builtins/reflect/mod.rs b/boa_engine/src/builtins/reflect/mod.rs index 761573d8d07..50e9e8196fb 100644 --- a/boa_engine/src/builtins/reflect/mod.rs +++ b/boa_engine/src/builtins/reflect/mod.rs @@ -82,11 +82,7 @@ impl Reflect { /// /// [spec]: https://tc39.es/ecma262/#sec-reflect.apply /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/apply - pub(crate) fn apply( - _: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn apply(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let target = args .get(0) .and_then(JsValue::as_object) @@ -114,7 +110,7 @@ impl Reflect { pub(crate) fn construct( _: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If IsConstructor(target) is false, throw a TypeError exception. let target = args @@ -154,7 +150,7 @@ impl Reflect { pub(crate) fn define_property( _: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let target = args .get(0) @@ -185,7 +181,7 @@ impl Reflect { pub(crate) fn delete_property( _: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let target = args .get(0) @@ -204,11 +200,7 @@ impl Reflect { /// /// [spec]: https://tc39.es/ecma262/#sec-reflect.get /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/get - pub(crate) fn get( - _: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn get(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. If Type(target) is not Object, throw a TypeError exception. let target = args .get(0) @@ -237,7 +229,7 @@ impl Reflect { pub(crate) fn get_own_property_descriptor( _: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { if args.get_or_undefined(0).is_object() { // This function is the same as Object.prototype.getOwnPropertyDescriptor, that why @@ -265,7 +257,7 @@ impl Reflect { pub(crate) fn get_prototype_of( _: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let target = args .get(0) @@ -284,11 +276,7 @@ impl Reflect { /// /// [spec]: https://tc39.es/ecma262/#sec-reflect.has /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/has - pub(crate) fn has( - _: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn has(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let target = args .get(0) .and_then(JsValue::as_object) @@ -311,7 +299,7 @@ impl Reflect { pub(crate) fn is_extensible( _: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let target = args .get(0) @@ -331,7 +319,7 @@ impl Reflect { pub(crate) fn own_keys( _: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let target = args .get(0) @@ -358,7 +346,7 @@ impl Reflect { pub(crate) fn prevent_extensions( _: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let target = args .get(0) @@ -376,11 +364,7 @@ impl Reflect { /// /// [spec]: https://tc39.es/ecma262/#sec-reflect.set /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/set - pub(crate) fn set( - _: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn set(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let target = args .get(0) .and_then(JsValue::as_object) @@ -407,7 +391,7 @@ impl Reflect { pub(crate) fn set_prototype_of( _: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let target = args .get(0) diff --git a/boa_engine/src/builtins/regexp/mod.rs b/boa_engine/src/builtins/regexp/mod.rs index 966acc672ae..c8b1c6f915e 100644 --- a/boa_engine/src/builtins/regexp/mod.rs +++ b/boa_engine/src/builtins/regexp/mod.rs @@ -179,7 +179,7 @@ impl BuiltInConstructor for RegExp { fn constructor( new_target: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let pattern = args.get_or_undefined(0); let flags = args.get_or_undefined(1); @@ -270,7 +270,7 @@ impl RegExp { /// [spec]: https://tc39.es/ecma262/#sec-isregexp pub(crate) fn is_reg_exp<'a>( argument: &'a JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult> { // 1. If argument is not an Object, return false. let Some(argument) = argument.as_object() else { @@ -302,7 +302,7 @@ impl RegExp { fn compile_native_regexp( pattern: &JsValue, flags: &JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If pattern is undefined, let P be the empty String. // 2. Else, let P be ? ToString(pattern). @@ -364,7 +364,7 @@ impl RegExp { prototype: Option, pattern: &JsValue, flags: &JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // Has the steps of `RegExpInitialize`. let regexp = Self::compile_native_regexp(pattern, flags, context)?; @@ -397,7 +397,7 @@ impl RegExp { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-regexpcreate - pub(crate) fn create(p: &JsValue, f: &JsValue, context: &mut Context<'_>) -> JsResult { + pub(crate) fn create(p: &JsValue, f: &JsValue, context: &mut Context) -> JsResult { // 1. Let obj be ? RegExpAlloc(%RegExp%). // 2. Return ? RegExpInitialize(obj, P, F). Self::initialize(None, p, f, context) @@ -414,12 +414,12 @@ impl RegExp { /// [spec]: https://tc39.es/ecma262/#sec-get-regexp-@@species /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/@@species #[allow(clippy::unnecessary_wraps)] - fn get_species(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn get_species(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { // 1. Return the this value. Ok(this.clone()) } - fn regexp_has_flag(this: &JsValue, flag: u8, context: &mut Context<'_>) -> JsResult { + fn regexp_has_flag(this: &JsValue, flag: u8, context: &mut Context) -> JsResult { if let Some(object) = this.as_object() { if let Some(regexp) = object.borrow().as_regexp() { return Ok(JsValue::new(match flag { @@ -471,7 +471,7 @@ impl RegExp { pub(crate) fn get_has_indices( this: &JsValue, _: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { Self::regexp_has_flag(this, b'd', context) } @@ -489,7 +489,7 @@ impl RegExp { pub(crate) fn get_global( this: &JsValue, _: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { Self::regexp_has_flag(this, b'g', context) } @@ -507,7 +507,7 @@ impl RegExp { pub(crate) fn get_ignore_case( this: &JsValue, _: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { Self::regexp_has_flag(this, b'i', context) } @@ -525,7 +525,7 @@ impl RegExp { pub(crate) fn get_multiline( this: &JsValue, _: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { Self::regexp_has_flag(this, b'm', context) } @@ -543,7 +543,7 @@ impl RegExp { pub(crate) fn get_dot_all( this: &JsValue, _: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { Self::regexp_has_flag(this, b's', context) } @@ -562,7 +562,7 @@ impl RegExp { pub(crate) fn get_unicode( this: &JsValue, _: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { Self::regexp_has_flag(this, b'u', context) } @@ -581,7 +581,7 @@ impl RegExp { pub(crate) fn get_sticky( this: &JsValue, _: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { Self::regexp_has_flag(this, b'y', context) } @@ -600,7 +600,7 @@ impl RegExp { pub(crate) fn get_flags( this: &JsValue, _: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let R be the this value. // 2. If Type(R) is not Object, throw a TypeError exception. @@ -671,7 +671,7 @@ impl RegExp { pub(crate) fn get_source( this: &JsValue, _: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let R be the this value. // 2. If Type(R) is not Object, throw a TypeError exception. @@ -753,7 +753,7 @@ impl RegExp { pub(crate) fn test( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let R be the this value. // 2. If Type(R) is not Object, throw a TypeError exception. @@ -795,7 +795,7 @@ impl RegExp { pub(crate) fn exec( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let R be the this value. // 2. Perform ? RequireInternalSlot(R, [[RegExpMatcher]]). @@ -823,7 +823,7 @@ impl RegExp { pub(crate) fn abstract_exec( this: &JsObject, input: JsString, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult> { // 1. Assert: Type(R) is Object. // 2. Assert: Type(S) is String. @@ -867,7 +867,7 @@ impl RegExp { pub(crate) fn abstract_builtin_exec( this: &JsObject, input: &JsString, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult> { let rx = { let obj = this.borrow(); @@ -1187,7 +1187,7 @@ impl RegExp { pub(crate) fn r#match( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let rx be the this value. // 2. If Type(rx) is not Object, throw a TypeError exception. @@ -1278,11 +1278,7 @@ impl RegExp { /// [spec]: https://tc39.es/ecma262/#sec-regexp.prototype.tostring /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/toString #[allow(clippy::wrong_self_convention)] - pub(crate) fn to_string( - this: &JsValue, - _: &[JsValue], - _: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn to_string(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { let (body, flags) = if let Some(object) = this.as_object() { let object = object.borrow(); let regex = object.as_regexp().ok_or_else(|| { @@ -1316,7 +1312,7 @@ impl RegExp { pub(crate) fn match_all( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let R be the this value. // 2. If Type(R) is not Object, throw a TypeError exception. @@ -1378,7 +1374,7 @@ impl RegExp { pub(crate) fn replace( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // Helper enum. enum CallableOrString<'a> { @@ -1617,7 +1613,7 @@ impl RegExp { pub(crate) fn search( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let rx be the this value. // 2. If Type(rx) is not Object, throw a TypeError exception. @@ -1671,7 +1667,7 @@ impl RegExp { pub(crate) fn split( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let rx be the this value. // 2. If Type(rx) is not Object, throw a TypeError exception. @@ -1843,7 +1839,7 @@ impl RegExp { /// /// [spec]: https://tc39.es/ecma262/#sec-regexp.prototype.compile #[cfg(feature = "annex-b")] - fn compile(this: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult { + fn compile(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be the this value. // 2. Perform ? RequireInternalSlot(O, [[RegExpMatcher]]). diff --git a/boa_engine/src/builtins/regexp/regexp_string_iterator.rs b/boa_engine/src/builtins/regexp/regexp_string_iterator.rs index 10d668acba6..171a737a3f1 100644 --- a/boa_engine/src/builtins/regexp/regexp_string_iterator.rs +++ b/boa_engine/src/builtins/regexp/regexp_string_iterator.rs @@ -90,7 +90,7 @@ impl RegExpStringIterator { string: JsString, global: bool, unicode: bool, - context: &mut Context<'_>, + context: &mut Context, ) -> JsValue { // TODO: Implement this with closures and generators. // For now all values of the closure are stored in RegExpStringIterator and the actual closure execution is in `.next()`. @@ -123,7 +123,7 @@ impl RegExpStringIterator { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-%regexpstringiteratorprototype%.next - pub fn next(this: &JsValue, _: &[JsValue], context: &mut Context<'_>) -> JsResult { + pub fn next(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { let mut iterator = this.as_object().map(JsObject::borrow_mut); let iterator = iterator .as_mut() diff --git a/boa_engine/src/builtins/set/mod.rs b/boa_engine/src/builtins/set/mod.rs index 908cd668219..a1cc628b711 100644 --- a/boa_engine/src/builtins/set/mod.rs +++ b/boa_engine/src/builtins/set/mod.rs @@ -112,7 +112,7 @@ impl BuiltInConstructor for Set { fn constructor( new_target: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If NewTarget is undefined, throw a TypeError exception. if new_target.is_undefined() { @@ -171,7 +171,7 @@ impl BuiltInConstructor for Set { impl Set { /// Utility for constructing `Set` objects. - pub(crate) fn set_create(prototype: Option, context: &mut Context<'_>) -> JsObject { + pub(crate) fn set_create(prototype: Option, context: &mut Context) -> JsObject { let prototype = prototype.unwrap_or_else(|| context.intrinsics().constructors().set().prototype()); @@ -183,7 +183,7 @@ impl Set { } /// Utility for constructing `Set` objects from an iterator of `JsValue`'s. - pub(crate) fn create_set_from_list(elements: I, context: &mut Context<'_>) -> JsObject + pub(crate) fn create_set_from_list(elements: I, context: &mut Context) -> JsObject where I: IntoIterator, { @@ -209,7 +209,7 @@ impl Set { /// [spec]: https://tc39.es/ecma262/#sec-get-set-@@species /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/@@species #[allow(clippy::unnecessary_wraps)] - fn get_species(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn get_species(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { // 1. Return the this value. Ok(this.clone()) } @@ -224,7 +224,7 @@ impl Set { /// /// [spec]: https://tc39.es/ecma262/#sec-set.prototype.add /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/add - pub(crate) fn add(this: &JsValue, args: &[JsValue], _: &mut Context<'_>) -> JsResult { + pub(crate) fn add(this: &JsValue, args: &[JsValue], _: &mut Context) -> JsResult { const JS_ZERO: &JsValue = &JsValue::Integer(0); // 1. Let S be the this value. @@ -267,7 +267,7 @@ impl Set { /// /// [spec]: https://tc39.es/ecma262/#sec-set.prototype.clear /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/clear - pub(crate) fn clear(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + pub(crate) fn clear(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { let mut object = this .as_object() .map(JsObject::borrow_mut) @@ -293,11 +293,7 @@ impl Set { /// /// [spec]: https://tc39.es/ecma262/#sec-set.prototype.delete /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/delete - pub(crate) fn delete( - this: &JsValue, - args: &[JsValue], - _: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn delete(this: &JsValue, args: &[JsValue], _: &mut Context) -> JsResult { const JS_ZERO: &JsValue = &JsValue::Integer(0); // 1. Let S be the this value. @@ -340,7 +336,7 @@ impl Set { pub(crate) fn entries( this: &JsValue, _: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let Some(lock) = this .as_object() @@ -372,7 +368,7 @@ impl Set { pub(crate) fn for_each( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let S be the this value. // 2. Perform ? RequireInternalSlot(S, [[SetData]]). @@ -443,7 +439,7 @@ impl Set { /// /// [spec]: https://tc39.es/ecma262/#sec-map.prototype.has /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/has - pub(crate) fn has(this: &JsValue, args: &[JsValue], _: &mut Context<'_>) -> JsResult { + pub(crate) fn has(this: &JsValue, args: &[JsValue], _: &mut Context) -> JsResult { const JS_ZERO: &JsValue = &JsValue::Integer(0); // 1. Let S be the this value. @@ -484,7 +480,7 @@ impl Set { pub(crate) fn values( this: &JsValue, _: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let Some(lock) = this .as_object() @@ -503,7 +499,7 @@ impl Set { )) } - fn size_getter(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn size_getter(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Self::get_size(this).map(JsValue::from) } diff --git a/boa_engine/src/builtins/set/set_iterator.rs b/boa_engine/src/builtins/set/set_iterator.rs index 30de1cfe029..16fab5d6304 100644 --- a/boa_engine/src/builtins/set/set_iterator.rs +++ b/boa_engine/src/builtins/set/set_iterator.rs @@ -86,7 +86,7 @@ impl SetIterator { set: JsValue, kind: PropertyNameKind, lock: SetLock, - context: &Context<'_>, + context: &Context, ) -> JsValue { let set_iterator = JsObject::from_proto_and_data_with_shared_shape( context.root_shape(), @@ -104,11 +104,7 @@ impl SetIterator { /// - [ECMA reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-%setiteratorprototype%.next - pub(crate) fn next( - this: &JsValue, - _: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn next(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { let mut set_iterator = this.as_object().map(JsObject::borrow_mut); let set_iterator = set_iterator diff --git a/boa_engine/src/builtins/string/mod.rs b/boa_engine/src/builtins/string/mod.rs index 6f476b2b125..2e8c9f0f6c6 100644 --- a/boa_engine/src/builtins/string/mod.rs +++ b/boa_engine/src/builtins/string/mod.rs @@ -205,7 +205,7 @@ impl BuiltInConstructor for String { fn constructor( new_target: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // This value is used by console.log and other routines to match Object type // to its Javascript Identifier (global constructor method name) @@ -249,7 +249,7 @@ impl String { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-stringcreate - fn string_create(value: JsString, prototype: JsObject, context: &mut Context<'_>) -> JsObject { + fn string_create(value: JsString, prototype: JsObject, context: &mut Context) -> JsObject { // 7. Let length be the number of code unit elements in value. let len = value.len(); @@ -318,7 +318,7 @@ impl String { pub(crate) fn from_code_point( _: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let result be the empty String. let mut result = Vec::with_capacity(args.len()); @@ -372,11 +372,7 @@ impl String { /// /// [spec]: https://tc39.es/ecma262/#sec-string.raw /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw - pub(crate) fn raw( - _: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn raw(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let substitutions = args.get(1..).unwrap_or_default(); // 1. Let numberOfSubstitutions be the number of elements in substitutions. @@ -450,7 +446,7 @@ impl String { pub(crate) fn from_char_code( _: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let result be the empty String. let mut result = Vec::new(); @@ -475,11 +471,7 @@ impl String { /// /// [spec]: https://tc39.es/ecma262/#sec-string.prototype.tostring #[allow(clippy::wrong_self_convention)] - pub(crate) fn to_string( - this: &JsValue, - _: &[JsValue], - _: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn to_string(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { // 1. Return ? thisStringValue(this value). Ok(Self::this_string_value(this)?.into()) } @@ -503,7 +495,7 @@ impl String { pub(crate) fn char_at( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? RequireObjectCoercible(this value). let this = this.require_object_coercible()?; @@ -537,11 +529,7 @@ impl String { /// /// [spec]: https://tc39.es/proposal-relative-indexing-method/#sec-string.prototype.at /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/at - pub(crate) fn at( - this: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn at(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be ? RequireObjectCoercible(this value). let this = this.require_object_coercible()?; @@ -585,7 +573,7 @@ impl String { pub(crate) fn code_point_at( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? RequireObjectCoercible(this value). let this = this.require_object_coercible()?; @@ -628,7 +616,7 @@ impl String { pub(crate) fn char_code_at( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? RequireObjectCoercible(this value). let this = this.require_object_coercible()?; @@ -667,7 +655,7 @@ impl String { pub(crate) fn concat( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? RequireObjectCoercible(this value). let this = this.require_object_coercible()?; @@ -701,7 +689,7 @@ impl String { pub(crate) fn repeat( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? RequireObjectCoercible(this value). let this = this.require_object_coercible()?; @@ -754,7 +742,7 @@ impl String { pub(crate) fn slice( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? RequireObjectCoercible(this value). let this = this.require_object_coercible()?; @@ -819,7 +807,7 @@ impl String { pub(crate) fn starts_with( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? RequireObjectCoercible(this value). let this = this.require_object_coercible()?; @@ -888,7 +876,7 @@ impl String { pub(crate) fn ends_with( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? RequireObjectCoercible(this value). let this = this.require_object_coercible()?; @@ -954,7 +942,7 @@ impl String { pub(crate) fn includes( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? RequireObjectCoercible(this value). let this = this.require_object_coercible()?; @@ -1006,7 +994,7 @@ impl String { pub(crate) fn replace( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // Helper enum. enum CallableOrString<'a> { @@ -1115,7 +1103,7 @@ impl String { pub(crate) fn replace_all( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? RequireObjectCoercible(this value). let o = this.require_object_coercible()?; @@ -1267,7 +1255,7 @@ impl String { pub(crate) fn index_of( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? RequireObjectCoercible(this value). let this = this.require_object_coercible()?; @@ -1306,7 +1294,7 @@ impl String { pub(crate) fn is_well_formed( this: &JsValue, _: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? RequireObjectCoercible(this value). let o = this.require_object_coercible()?; @@ -1339,7 +1327,7 @@ impl String { pub(crate) fn last_index_of( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? RequireObjectCoercible(this value). let this = this.require_object_coercible()?; @@ -1406,7 +1394,7 @@ impl String { pub(crate) fn locale_compare( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? RequireObjectCoercible(this value). let o = this.require_object_coercible()?; @@ -1469,7 +1457,7 @@ impl String { pub(crate) fn r#match( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? RequireObjectCoercible(this value). let o = this.require_object_coercible()?; @@ -1509,7 +1497,7 @@ impl String { max_length: &JsValue, fill_string: &JsValue, placement: Placement, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let S be ? ToString(O). let string = object.to_string(context)?; @@ -1581,7 +1569,7 @@ impl String { pub(crate) fn pad_end( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? RequireObjectCoercible(this value). let this = this.require_object_coercible()?; @@ -1608,7 +1596,7 @@ impl String { pub(crate) fn pad_start( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? RequireObjectCoercible(this value). let this = this.require_object_coercible()?; @@ -1632,11 +1620,7 @@ impl String { /// /// [spec]: https://tc39.es/ecma262/#sec-string.prototype.trim /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trim - pub(crate) fn trim( - this: &JsValue, - _: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn trim(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Let S be the this value. // 2. Return ? TrimString(S, start+end). let object = this.require_object_coercible()?; @@ -1659,7 +1643,7 @@ impl String { pub(crate) fn trim_start( this: &JsValue, _: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let S be the this value. // 2. Return ? TrimString(S, start). @@ -1683,7 +1667,7 @@ impl String { pub(crate) fn trim_end( this: &JsValue, _: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let S be the this value. // 2. Return ? TrimString(S, end). @@ -1707,7 +1691,7 @@ impl String { pub(crate) fn to_case( this: &JsValue, _: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? RequireObjectCoercible(this value). let this = this.require_object_coercible()?; @@ -1739,7 +1723,7 @@ impl String { pub(crate) fn to_locale_case( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { #[cfg(feature = "intl")] { @@ -1774,7 +1758,7 @@ impl String { // 5. Let availableLocales be a List with language tags that includes the languages for which the Unicode Character Database contains language sensitive case mappings. Implementations may add additional language tags if they support case mapping for additional locales. // 6. Let locale be ! BestAvailableLocale(availableLocales, noExtensionsLocale). // 7. If locale is undefined, set locale to "und". - let lang = best_available_locale::(lang, &context.icu().provider()) + let lang = best_available_locale::(lang, context.icu().provider()) .unwrap_or(LanguageIdentifier::UND); let casemapper = context.icu().case_mapper(); @@ -1814,7 +1798,7 @@ impl String { pub(crate) fn to_well_formed( this: &JsValue, _: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? RequireObjectCoercible(this value). let o = this.require_object_coercible()?; @@ -1857,7 +1841,7 @@ impl String { pub(crate) fn substring( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? RequireObjectCoercible(this value). let this = this.require_object_coercible()?; @@ -1907,7 +1891,7 @@ impl String { pub(crate) fn split( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? RequireObjectCoercible(this value). let this = this.require_object_coercible()?; @@ -2026,7 +2010,7 @@ impl String { pub(crate) fn value_of( this: &JsValue, _args: &[JsValue], - _context: &mut Context<'_>, + _context: &mut Context, ) -> JsResult { // 1. Return ? thisStringValue(this value). Self::this_string_value(this).map(JsValue::from) @@ -2047,7 +2031,7 @@ impl String { pub(crate) fn match_all( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? RequireObjectCoercible(this value). let o = this.require_object_coercible()?; @@ -2104,7 +2088,7 @@ impl String { pub(crate) fn normalize( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { /// Represents the type of normalization applied to a [`JsString`] #[derive(Clone, Copy)] @@ -2185,7 +2169,7 @@ impl String { pub(crate) fn search( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? RequireObjectCoercible(this value). let o = this.require_object_coercible()?; @@ -2215,7 +2199,7 @@ impl String { pub(crate) fn iterator( this: &JsValue, _: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? RequireObjectCoercible(this value). let o = this.require_object_coercible()?; @@ -2242,7 +2226,7 @@ impl String { pub(crate) fn substr( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be ? RequireObjectCoercible(this value). let o = this.require_object_coercible()?; @@ -2306,7 +2290,7 @@ impl String { string: &JsValue, tag: &[u16], attribute_and_value: Option<(&[u16], &JsValue)>, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let str be ? RequireObjectCoercible(string). let str = string.require_object_coercible()?; @@ -2379,7 +2363,7 @@ impl String { pub(crate) fn anchor( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let name = args.get_or_undefined(0); @@ -2397,11 +2381,7 @@ impl String { /// /// [spec]: https://tc39.es/ecma262/#sec-string.prototype.big /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/big - pub(crate) fn big( - this: &JsValue, - _: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn big(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Let S be the this value. let s = this; // 2. Return ? CreateHTML(S, "big", "", ""). @@ -2416,11 +2396,7 @@ impl String { /// /// [spec]: https://tc39.es/ecma262/#sec-string.prototype.blink /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/blink - pub(crate) fn blink( - this: &JsValue, - _: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn blink(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Let S be the this value. let s = this; // 2. Return ? CreateHTML(S, "blink", "", ""). @@ -2435,11 +2411,7 @@ impl String { /// /// [spec]: https://tc39.es/ecma262/#sec-string.prototype.bold /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/bold - pub(crate) fn bold( - this: &JsValue, - _: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn bold(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Let S be the this value. let s = this; // 2. Return ? CreateHTML(S, "b", "", ""). @@ -2454,11 +2426,7 @@ impl String { /// /// [spec]: https://tc39.es/ecma262/#sec-string.prototype.fixed /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fixed - pub(crate) fn fixed( - this: &JsValue, - _: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn fixed(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Let S be the this value. let s = this; // 2. Return ? CreateHTML(S, "big", "", ""). @@ -2476,7 +2444,7 @@ impl String { pub(crate) fn fontcolor( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let color = args.get_or_undefined(0); @@ -2497,7 +2465,7 @@ impl String { pub(crate) fn fontsize( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let size = args.get_or_undefined(0); @@ -2518,7 +2486,7 @@ impl String { pub(crate) fn italics( this: &JsValue, _: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let S be the this value. let s = this; @@ -2537,7 +2505,7 @@ impl String { pub(crate) fn link( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let url = args.get_or_undefined(0); @@ -2555,11 +2523,7 @@ impl String { /// /// [spec]: https://tc39.es/ecma262/#sec-string.prototype.small /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/small - pub(crate) fn small( - this: &JsValue, - _: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn small(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Let S be the this value. let s = this; // 2. Return ? CreateHTML(S, "small", "", ""). @@ -2577,7 +2541,7 @@ impl String { pub(crate) fn strike( this: &JsValue, _: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let S be the this value. let s = this; @@ -2593,11 +2557,7 @@ impl String { /// /// [spec]: https://tc39.es/ecma262/#sec-string.prototype.sub /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/sub - pub(crate) fn sub( - this: &JsValue, - _: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn sub(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Let S be the this value. let s = this; // 2. Return ? CreateHTML(S, "sub", "", ""). @@ -2612,11 +2572,7 @@ impl String { /// /// [spec]: https://tc39.es/ecma262/#sec-string.prototype.sup /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/sup - pub(crate) fn sup( - this: &JsValue, - _: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn sup(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Let S be the this value. let s = this; // 2. Return ? CreateHTML(S, "sup", "", ""). @@ -2637,7 +2593,7 @@ pub(crate) fn get_substitution( captures: &[JsValue], named_captures: &JsValue, replacement: &JsString, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let mut buf = [0; 2]; // 1. Assert: Type(matched) is String. diff --git a/boa_engine/src/builtins/string/string_iterator.rs b/boa_engine/src/builtins/string/string_iterator.rs index 129e60257d1..9ae8426ad83 100644 --- a/boa_engine/src/builtins/string/string_iterator.rs +++ b/boa_engine/src/builtins/string/string_iterator.rs @@ -59,7 +59,7 @@ impl IntrinsicObject for StringIterator { impl StringIterator { /// Create a new `StringIterator`. - pub fn create_string_iterator(string: JsString, context: &mut Context<'_>) -> JsObject { + pub fn create_string_iterator(string: JsString, context: &mut Context) -> JsObject { JsObject::from_proto_and_data_with_shared_shape( context.root_shape(), context @@ -75,7 +75,7 @@ impl StringIterator { } /// `StringIterator.prototype.next( )` - pub fn next(this: &JsValue, _: &[JsValue], context: &mut Context<'_>) -> JsResult { + pub fn next(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { let mut string_iterator = this.as_object().map(JsObject::borrow_mut); let string_iterator = string_iterator .as_mut() diff --git a/boa_engine/src/builtins/symbol/mod.rs b/boa_engine/src/builtins/symbol/mod.rs index ebc5efe9b80..fd51ced250d 100644 --- a/boa_engine/src/builtins/symbol/mod.rs +++ b/boa_engine/src/builtins/symbol/mod.rs @@ -202,7 +202,7 @@ impl BuiltInConstructor for Symbol { fn constructor( new_target: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If NewTarget is not undefined, throw a TypeError exception. if !new_target.is_undefined() { @@ -251,11 +251,7 @@ impl Symbol { /// [spec]: https://tc39.es/ecma262/#sec-symbol.prototype.tostring /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toString #[allow(clippy::wrong_self_convention)] - pub(crate) fn to_string( - this: &JsValue, - _: &[JsValue], - _: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn to_string(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { // 1. Let sym be ? thisSymbolValue(this value). let symbol = Self::this_symbol_value(this)?; @@ -273,11 +269,7 @@ impl Symbol { /// /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/valueOf /// [spec]: https://tc39.es/ecma262/#sec-symbol.prototype.valueof - pub(crate) fn value_of( - this: &JsValue, - _: &[JsValue], - _: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn value_of(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { // 1. Return ? thisSymbolValue(this value). let symbol = Self::this_symbol_value(this)?; Ok(JsValue::Symbol(symbol)) @@ -296,7 +288,7 @@ impl Symbol { pub(crate) fn get_description( this: &JsValue, _: &[JsValue], - _: &mut Context<'_>, + _: &mut Context, ) -> JsResult { // 1. Let s be the this value. // 2. Let sym be ? thisSymbolValue(s). @@ -316,11 +308,7 @@ impl Symbol { /// /// [spec]: https://tc39.es/ecma262/#sec-symbol.prototype.for /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/for - pub(crate) fn for_( - _: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn for_(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let stringKey be ? ToString(key). let string_key = args .get(0) @@ -347,7 +335,7 @@ impl Symbol { /// /// [spec]: https://tc39.es/ecma262/#sec-symbol.prototype.keyfor /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/keyFor - pub(crate) fn key_for(_: &JsValue, args: &[JsValue], _: &mut Context<'_>) -> JsResult { + pub(crate) fn key_for(_: &JsValue, args: &[JsValue], _: &mut Context) -> JsResult { // 1. If Type(sym) is not Symbol, throw a TypeError exception. let sym = args.get_or_undefined(0).as_symbol().ok_or_else(|| { JsNativeError::typ().with_message("Symbol.keyFor: sym is not a symbol") @@ -378,7 +366,7 @@ impl Symbol { pub(crate) fn to_primitive( this: &JsValue, _: &[JsValue], - _: &mut Context<'_>, + _: &mut Context, ) -> JsResult { let sym = Self::this_symbol_value(this)?; // 1. Return ? thisSymbolValue(this value). diff --git a/boa_engine/src/builtins/temporal/calendar/mod.rs b/boa_engine/src/builtins/temporal/calendar/mod.rs index 61d14189b9f..f1e39422fc2 100644 --- a/boa_engine/src/builtins/temporal/calendar/mod.rs +++ b/boa_engine/src/builtins/temporal/calendar/mod.rs @@ -235,7 +235,7 @@ impl BuiltInConstructor for Calendar { fn constructor( new_target: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If NewTarget is undefined, then if new_target.is_undefined() { @@ -270,7 +270,7 @@ impl BuiltInConstructor for Calendar { } impl Calendar { - fn get_id(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn get_id(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { let o = this.as_object().ok_or_else(|| { JsNativeError::typ().with_message("this value of Calendar must be an object.") })?; @@ -287,7 +287,7 @@ impl Calendar { fn date_from_fields( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let calendar be the this value. // 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). @@ -373,7 +373,7 @@ impl Calendar { fn year_month_from_fields( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let o = this.as_object().map(JsObject::borrow).ok_or_else(|| { JsNativeError::typ().with_message("this value of Calendar must be an object.") @@ -448,7 +448,7 @@ impl Calendar { fn month_day_from_fields( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let calendar be the this value. // 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). @@ -523,7 +523,7 @@ impl Calendar { } /// 15.8.2.4 `Temporal.Calendar.prototype.dateAdd ( date, duration [ , options ] )` - supercedes 12.5.7 - fn date_add(this: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult { + fn date_add(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let calendar be the this value. // 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). // 3. Assert: calendar.[[Identifier]] is "iso8601". @@ -567,11 +567,7 @@ impl Calendar { } ///15.8.2.5 `Temporal.Calendar.prototype.dateUntil ( one, two [ , options ] )` - Supercedes 12.5.8 - fn date_until( - this: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + fn date_until(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let calendar be the this value. // 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). // 3. Assert: calendar.[[Identifier]] is "iso8601". @@ -614,7 +610,7 @@ impl Calendar { } /// 15.8.2.6 `Temporal.Calendar.prototype.era ( temporalDateLike )` - fn era(this: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult { + fn era(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let o = this.as_object().map(JsObject::borrow).ok_or_else(|| { JsNativeError::typ().with_message("this value of Calendar must be an object.") })?; @@ -662,7 +658,7 @@ impl Calendar { } /// 15.8.2.7 `Temporal.Calendar.prototype.eraYear ( temporalDateLike )` - fn era_year(this: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult { + fn era_year(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let o = this.as_object().map(JsObject::borrow).ok_or_else(|| { JsNativeError::typ().with_message("this value of Calendar must be an object.") })?; @@ -710,7 +706,7 @@ impl Calendar { } /// 15.8.2.8 `Temporal.Calendar.prototype.year ( temporalDateLike )` - fn year(this: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult { + fn year(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let o = this.as_object().map(JsObject::borrow).ok_or_else(|| { JsNativeError::typ().with_message("this value of Calendar must be an object.") })?; @@ -756,7 +752,7 @@ impl Calendar { } /// 15.8.2.9 `Temporal.Calendar.prototype.month ( temporalDateLike )` - fn month(this: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult { + fn month(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let o = this.as_object().map(JsObject::borrow).ok_or_else(|| { JsNativeError::typ().with_message("this value of Calendar must be an object.") })?; @@ -811,11 +807,7 @@ impl Calendar { } /// 15.8.2.10 `Temporal.Calendar.prototype.monthCode ( temporalDateLike )` - fn month_code( - this: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + fn month_code(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let o = this.as_object().map(JsObject::borrow).ok_or_else(|| { JsNativeError::typ().with_message("this value of Calendar must be an object.") })?; @@ -867,7 +859,7 @@ impl Calendar { } /// 15.8.2.11 `Temporal.Calendar.prototype.day ( temporalDateLike )` - fn day(this: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult { + fn day(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let o = this.as_object().map(JsObject::borrow).ok_or_else(|| { JsNativeError::typ().with_message("this value of Calendar must be an object.") })?; @@ -913,11 +905,7 @@ impl Calendar { } /// 15.8.2.12 `Temporal.Calendar.prototype.dayOfWeek ( dateOrDateTime )` - fn day_of_week( - this: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + fn day_of_week(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let calendar be the this value. // 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). let o = this.as_object().map(JsObject::borrow).ok_or_else(|| { @@ -943,11 +931,7 @@ impl Calendar { } /// 15.8.2.13 `Temporal.Calendar.prototype.dayOfYear ( temporalDateLike )` - fn day_of_year( - this: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + fn day_of_year(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let o = this.as_object().ok_or_else(|| { JsNativeError::typ().with_message("this value of Calendar must be an object.") })?; @@ -972,11 +956,7 @@ impl Calendar { } /// 15.8.2.14 `Temporal.Calendar.prototype.weekOfYear ( temporalDateLike )` - fn week_of_year( - this: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + fn week_of_year(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let o = this.as_object().map(JsObject::borrow).ok_or_else(|| { JsNativeError::typ().with_message("this value of Calendar must be an object.") })?; @@ -1000,11 +980,7 @@ impl Calendar { } /// 15.8.2.15 `Temporal.Calendar.prototype.yearOfWeek ( temporalDateLike )` - fn year_of_week( - this: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + fn year_of_week(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let o = this.as_object().map(JsObject::borrow).ok_or_else(|| { JsNativeError::typ().with_message("this value of Calendar must be an object.") })?; @@ -1028,11 +1004,7 @@ impl Calendar { } /// 15.8.2.16 `Temporal.Calendar.prototype.daysInWeek ( temporalDateLike )` - fn days_in_week( - this: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + fn days_in_week(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let o = this.as_object().map(JsObject::borrow).ok_or_else(|| { JsNativeError::typ().with_message("this value of Calendar must be an object.") })?; @@ -1056,11 +1028,7 @@ impl Calendar { } /// 15.8.2.17 `Temporal.Calendar.prototype.daysInMonth ( temporalDateLike )` - fn days_in_month( - this: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + fn days_in_month(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let o = this.as_object().map(JsObject::borrow).ok_or_else(|| { JsNativeError::typ().with_message("this value of Calendar must be an object.") })?; @@ -1108,11 +1076,7 @@ impl Calendar { } /// 15.8.2.18 `Temporal.Calendar.prototype.daysInYear ( temporalDateLike )` - fn days_in_year( - this: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + fn days_in_year(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let o = this.as_object().map(JsObject::borrow).ok_or_else(|| { JsNativeError::typ().with_message("this value of Calendar must be an object.") })?; @@ -1163,7 +1127,7 @@ impl Calendar { fn months_in_year( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let o = this.as_object().map(JsObject::borrow).ok_or_else(|| { JsNativeError::typ().with_message("this value of Calendar must be an object.") @@ -1212,11 +1176,7 @@ impl Calendar { } /// 15.8.2.20 `Temporal.Calendar.prototype.inLeapYear ( temporalDateLike )` - fn in_leap_year( - this: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + fn in_leap_year(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let o = this.as_object().map(JsObject::borrow).ok_or_else(|| { JsNativeError::typ().with_message("this value of Calendar must be an object.") })?; @@ -1264,7 +1224,7 @@ impl Calendar { } /// 15.8.2.21 `Temporal.Calendar.prototype.fields ( fields )` - fn fields(this: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult { + fn fields(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let calendar be the this value. // 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). let o = this.as_object().map(JsObject::borrow).ok_or_else(|| { @@ -1349,11 +1309,7 @@ impl Calendar { } /// 15.8.2.22 `Temporal.Calendar.prototype.mergeFields ( fields, additionalFields )` - fn merge_fields( - this: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + fn merge_fields(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let calendar be the this value. // 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). let o = this.as_object().map(JsObject::borrow).ok_or_else(|| { @@ -1455,7 +1411,7 @@ impl Calendar { pub(crate) fn create_temporal_calendar( identifier: &JsString, new_target: Option, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Assert: IsBuiltinCalendar(identifier) is true. assert!(is_builtin_calendar(identifier)); @@ -1489,7 +1445,7 @@ pub(crate) fn create_temporal_calendar( #[allow(unused)] pub(crate) fn get_temporal_calendar_slot_value_with_default( item: &JsObject, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If item has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then // a. Return item.[[Calendar]]. @@ -1627,7 +1583,7 @@ fn call_method_on_abstract_calendar( calendar: &JsValue, method: &JsString, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // If Calendar is a string let this_calendar = match calendar { @@ -1651,7 +1607,7 @@ fn call_method_on_abstract_calendar( pub(crate) fn calendar_fields( calendar: &JsValue, field_names: Vec, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult> { let field_names = Array::create_array_from_list(field_names, context); // 1. If calendar is a String, then @@ -1680,7 +1636,7 @@ pub(crate) fn calendar_merge_fields( calendar: &JsValue, fields: &TemporalFields, additional_fields: &JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If calendar is a String, then // a. Set calendar to ! CreateTemporalCalendar(calendar). @@ -1712,7 +1668,7 @@ pub(crate) fn calendar_date_add( date: &PlainDate, duration: &DurationRecord, options: &JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // NOTE: The specification never calls CalendarDateAdd without an options argument provided. // 1. If options is not present, set options to undefined. @@ -1755,7 +1711,7 @@ pub(crate) fn calendar_date_until( one: &PlainDate, two: &PlainDate, options: &JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If calendar is a String, then // a. Set calendar to ! CreateTemporalCalendar(calendar). @@ -1798,7 +1754,7 @@ pub(crate) fn calendar_date_until( pub(crate) fn calendar_year( calendar: &JsValue, datelike: &JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If calendar is a String, then // a. Set calendar to ! CreateTemporalCalendar(calendar). @@ -1834,7 +1790,7 @@ pub(crate) fn calendar_year( pub(crate) fn calendar_month( calendar: &JsValue, datelike: &JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If calendar is a String, then // a. Set calendar to ! CreateTemporalCalendar(calendar). @@ -1877,7 +1833,7 @@ pub(crate) fn calendar_month( pub(crate) fn calendar_month_code( calendar: &JsValue, datelike: &JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If calendar is a String, then // a. Set calendar to ! CreateTemporalCalendar(calendar). @@ -1905,7 +1861,7 @@ pub(crate) fn calendar_month_code( pub(crate) fn calendar_day( calendar: &JsValue, datelike: &JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If calendar is a String, then // a. Set calendar to ! CreateTemporalCalendar(calendar). @@ -1948,7 +1904,7 @@ pub(crate) fn calendar_day( pub(crate) fn calendar_day_of_week( calendar: &JsValue, datelike: &JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If calendar is a String, then // a. Set calendar to ! CreateTemporalCalendar(calendar). @@ -2008,7 +1964,7 @@ pub(crate) fn calendar_day_of_week( pub(crate) fn calendar_day_of_year( calendar: &JsValue, datelike: &JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If calendar is a String, then // a. Set calendar to ! CreateTemporalCalendar(calendar). @@ -2051,7 +2007,7 @@ pub(crate) fn calendar_day_of_year( pub(crate) fn calendar_week_of_year( calendar: &JsValue, datelike: &JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If calendar is a String, then // a. Set calendar to ! CreateTemporalCalendar(calendar). @@ -2094,7 +2050,7 @@ pub(crate) fn calendar_week_of_year( pub(crate) fn calendar_year_of_week( calendar: &JsValue, datelike: &JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If calendar is a String, then // a. Set calendar to ! CreateTemporalCalendar(calendar). @@ -2130,7 +2086,7 @@ pub(crate) fn calendar_year_of_week( pub(crate) fn calendar_days_in_week( calendar: &JsValue, datelike: &JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If calendar is a String, then // a. Set calendar to ! CreateTemporalCalendar(calendar). @@ -2173,7 +2129,7 @@ pub(crate) fn calendar_days_in_week( pub(crate) fn calendar_days_in_month( calendar: &JsValue, datelike: &JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If calendar is a String, then // a. Set calendar to ! CreateTemporalCalendar(calendar). @@ -2216,7 +2172,7 @@ pub(crate) fn calendar_days_in_month( pub(crate) fn calendar_days_in_year( calendar: &JsValue, datelike: &JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If calendar is a String, then // a. Set calendar to ! CreateTemporalCalendar(calendar). @@ -2259,7 +2215,7 @@ pub(crate) fn calendar_days_in_year( pub(crate) fn calendar_months_in_year( calendar: &JsValue, datelike: &JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If calendar is a String, then // a. Set calendar to ! CreateTemporalCalendar(calendar). @@ -2302,7 +2258,7 @@ pub(crate) fn calendar_months_in_year( pub(crate) fn calendar_in_lear_year( calendar: &JsValue, datelike: &JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If calendar is a String, then // a. Set calendar to ! CreateTemporalCalendar(calendar). diff --git a/boa_engine/src/builtins/temporal/duration/mod.rs b/boa_engine/src/builtins/temporal/duration/mod.rs index f72cf59261a..cf67023e51e 100644 --- a/boa_engine/src/builtins/temporal/duration/mod.rs +++ b/boa_engine/src/builtins/temporal/duration/mod.rs @@ -171,7 +171,7 @@ impl BuiltInConstructor for Duration { fn constructor( new_target: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If NewTarget is undefined, then if new_target.is_undefined() { @@ -288,57 +288,57 @@ impl Duration { } /// 7.3.3 get Temporal.Duration.prototype.years - fn get_years(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn get_years(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Self::get_internal_field(this, &DateTimeValues::Year) } // 7.3.4 get Temporal.Duration.prototype.months - fn get_months(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn get_months(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Self::get_internal_field(this, &DateTimeValues::Month) } /// 7.3.5 get Temporal.Duration.prototype.weeks - fn get_weeks(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn get_weeks(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Self::get_internal_field(this, &DateTimeValues::Week) } /// 7.3.6 get Temporal.Duration.prototype.days - fn get_days(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn get_days(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Self::get_internal_field(this, &DateTimeValues::Day) } /// 7.3.7 get Temporal.Duration.prototype.hours - fn get_hours(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn get_hours(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Self::get_internal_field(this, &DateTimeValues::Hour) } /// 7.3.8 get Temporal.Duration.prototype.minutes - fn get_minutes(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn get_minutes(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Self::get_internal_field(this, &DateTimeValues::Minute) } /// 7.3.9 get Temporal.Duration.prototype.seconds - fn get_seconds(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn get_seconds(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Self::get_internal_field(this, &DateTimeValues::Second) } /// 7.3.10 get Temporal.Duration.prototype.milliseconds - fn get_milliseconds(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn get_milliseconds(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Self::get_internal_field(this, &DateTimeValues::Millisecond) } /// 7.3.11 get Temporal.Duration.prototype.microseconds - fn get_microseconds(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn get_microseconds(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Self::get_internal_field(this, &DateTimeValues::Microsecond) } /// 7.3.12 get Temporal.Duration.prototype.nanoseconds - fn get_nanoseconds(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn get_nanoseconds(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Self::get_internal_field(this, &DateTimeValues::Nanosecond) } /// 7.3.13 get Temporal.Duration.prototype.sign - fn get_sign(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn get_sign(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { // 1. Let duration be the this value. // 2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]). let o = this.as_object().map(JsObject::borrow).ok_or_else(|| { @@ -355,7 +355,7 @@ impl Duration { } /// 7.3.14 get Temporal.Duration.prototype.blank - fn get_blank(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn get_blank(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { // 1. Let duration be the this value. // 2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]). let o = this.as_object().map(JsObject::borrow).ok_or_else(|| { @@ -386,7 +386,7 @@ impl Duration { pub(crate) fn with( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let duration be the this value. // 2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]). @@ -518,7 +518,7 @@ impl Duration { } /// 7.3.16 `Temporal.Duration.prototype.negated ( )` - pub(crate) fn negated(_: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + pub(crate) fn negated(_: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { // 1. Let duration be the this value. // 2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]). // 3. Return ! CreateNegatedTemporalDuration(duration). @@ -529,11 +529,7 @@ impl Duration { } /// 7.3.17 `Temporal.Duration.prototype.abs ( )` - pub(crate) fn abs( - this: &JsValue, - _: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn abs(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Let duration be the this value. // 2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]). // 3. Return ! CreateTemporalDuration(abs(duration.[[Years]]), abs(duration.[[Months]]), @@ -552,14 +548,14 @@ impl Duration { } /// 7.3.18 `Temporal.Duration.prototype.add ( other [ , options ] )` - pub(crate) fn add(_: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + pub(crate) fn add(_: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::range() .with_message("not yet implemented.") .into()) } /// 7.3.19 `Temporal.Duration.prototype.subtract ( other [ , options ] )` - pub(crate) fn subtract(_: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + pub(crate) fn subtract(_: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::range() .with_message("not yet implemented.") .into()) @@ -570,7 +566,7 @@ impl Duration { pub(crate) fn round( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let duration be the this value. // 2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]). @@ -809,7 +805,7 @@ impl Duration { pub(crate) fn total( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let duration be the this value. // 2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]). @@ -874,22 +870,14 @@ impl Duration { } /// 7.3.22 `Temporal.Duration.prototype.toString ( [ options ] )` - pub(crate) fn to_string( - _this: &JsValue, - _: &[JsValue], - _: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn to_string(_this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::range() .with_message("not yet implemented.") .into()) } /// 7.3.23 `Temporal.Duration.prototype.toJSON ( )` - pub(crate) fn to_json( - _this: &JsValue, - _: &[JsValue], - _: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn to_json(_this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::range() .with_message("not yet implemented.") .into()) @@ -933,7 +921,7 @@ pub(crate) fn to_temporal_duration_record( pub(crate) fn create_temporal_duration( record: DurationRecord, new_target: Option<&JsValue>, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If ! IsValidDuration(years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds) is false, throw a RangeError exception. if !record.is_valid_duration() { @@ -993,7 +981,7 @@ fn move_relative_date( calendar: &JsValue, relative_to: &PlainDate, duration: &DurationRecord, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult<(PlainDate, f64)> { let new_date = plain_date::add_date( calendar, diff --git a/boa_engine/src/builtins/temporal/duration/record.rs b/boa_engine/src/builtins/temporal/duration/record.rs index 5c62456bb1d..18266c1e7ef 100644 --- a/boa_engine/src/builtins/temporal/duration/record.rs +++ b/boa_engine/src/builtins/temporal/duration/record.rs @@ -260,7 +260,7 @@ impl DurationRecord { /// Takes an unknown `JsObject` and attempts to create a partial duration pub(crate) fn from_partial_js_object( duration_like: &JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If Type(temporalDurationLike) is not Object, then let JsValue::Object(unknown_object) = duration_like else { @@ -588,7 +588,7 @@ impl DurationRecord { // Trace current callers and check whether the value // can be fed a native `DurationRecord` instead. /// Creates a `Duration` object from the current `DurationRecord`. - pub(crate) fn as_object(&self, context: &mut Context<'_>) -> JsResult { + pub(crate) fn as_object(&self, context: &mut Context) -> JsResult { super::create_temporal_duration(*self, None, context) } @@ -905,7 +905,7 @@ impl DurationRecord { &self, largest_unit: TemporalUnit, plain_relative_to: Option<&PlainDate>, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let allZero be false. // 2. If years = 0, and months = 0, and weeks = 0, and days = 0, set allZero to true. @@ -1152,7 +1152,7 @@ impl DurationRecord { &mut self, largest_unit: TemporalUnit, relative_to: &JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult<()> { // 1. Let allZero be false. // 2. If years = 0, and months = 0, and weeks = 0, and days = 0, set allZero to true. @@ -1416,7 +1416,7 @@ impl DurationRecord { Option<&ZonedDateTime>, Option<&PlainDateTime>, ), - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult<(Self, f64)> { let mut result = DurationRecord::new(unbalance_date_duration, self.time()); @@ -1909,7 +1909,7 @@ impl DurationRecord { unit: TemporalUnit, rounding_mode: RoundingMode, relative_to: Option<&JsValue>, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult<()> { // 1. If Type(relativeTo) is not Object; or relativeTo does not have an [[InitializedTemporalZonedDateTime]] // internal slot; or unit is one of "year", "month", "week", or "day"; or unit is "nanosecond" and increment is 1, then diff --git a/boa_engine/src/builtins/temporal/fields.rs b/boa_engine/src/builtins/temporal/fields.rs index 3d03a0cb334..e3fc21e76d0 100644 --- a/boa_engine/src/builtins/temporal/fields.rs +++ b/boa_engine/src/builtins/temporal/fields.rs @@ -116,7 +116,7 @@ impl TemporalFields { &mut self, field: &JsString, value: &JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult<()> { match field.to_std_string_escaped().as_str() { "year" => self.set_year(value, context)?, @@ -140,7 +140,7 @@ impl TemporalFields { } #[inline] - fn set_year(&mut self, value: &JsValue, context: &mut Context<'_>) -> JsResult<()> { + fn set_year(&mut self, value: &JsValue, context: &mut Context) -> JsResult<()> { let y = super::to_integer_with_truncation(value, context)?; self.year = Some(y); self.bit_map.set(FieldMap::YEAR, true); @@ -148,7 +148,7 @@ impl TemporalFields { } #[inline] - fn set_month(&mut self, value: &JsValue, context: &mut Context<'_>) -> JsResult<()> { + fn set_month(&mut self, value: &JsValue, context: &mut Context) -> JsResult<()> { let mo = super::to_positive_integer_with_trunc(value, context)?; self.year = Some(mo); self.bit_map.set(FieldMap::MONTH, true); @@ -156,7 +156,7 @@ impl TemporalFields { } #[inline] - fn set_month_code(&mut self, value: &JsValue, context: &mut Context<'_>) -> JsResult<()> { + fn set_month_code(&mut self, value: &JsValue, context: &mut Context) -> JsResult<()> { let mc = value.to_primitive(context, PreferredType::String)?; if let Some(string) = mc.as_string() { self.month_code = Some(string.clone()); @@ -172,7 +172,7 @@ impl TemporalFields { } #[inline] - fn set_day(&mut self, value: &JsValue, context: &mut Context<'_>) -> JsResult<()> { + fn set_day(&mut self, value: &JsValue, context: &mut Context) -> JsResult<()> { let d = super::to_positive_integer_with_trunc(value, context)?; self.day = Some(d); self.bit_map.set(FieldMap::DAY, true); @@ -180,7 +180,7 @@ impl TemporalFields { } #[inline] - fn set_hour(&mut self, value: &JsValue, context: &mut Context<'_>) -> JsResult<()> { + fn set_hour(&mut self, value: &JsValue, context: &mut Context) -> JsResult<()> { let h = super::to_integer_with_truncation(value, context)?; self.hour = h; self.bit_map.set(FieldMap::HOUR, true); @@ -188,7 +188,7 @@ impl TemporalFields { } #[inline] - fn set_minute(&mut self, value: &JsValue, context: &mut Context<'_>) -> JsResult<()> { + fn set_minute(&mut self, value: &JsValue, context: &mut Context) -> JsResult<()> { let m = super::to_integer_with_truncation(value, context)?; self.minute = m; self.bit_map.set(FieldMap::MINUTE, true); @@ -196,7 +196,7 @@ impl TemporalFields { } #[inline] - fn set_second(&mut self, value: &JsValue, context: &mut Context<'_>) -> JsResult<()> { + fn set_second(&mut self, value: &JsValue, context: &mut Context) -> JsResult<()> { let sec = super::to_integer_with_truncation(value, context)?; self.second = sec; self.bit_map.set(FieldMap::SECOND, true); @@ -204,7 +204,7 @@ impl TemporalFields { } #[inline] - fn set_milli(&mut self, value: &JsValue, context: &mut Context<'_>) -> JsResult<()> { + fn set_milli(&mut self, value: &JsValue, context: &mut Context) -> JsResult<()> { let milli = super::to_integer_with_truncation(value, context)?; self.millisecond = milli; self.bit_map.set(FieldMap::MILLISECOND, true); @@ -212,7 +212,7 @@ impl TemporalFields { } #[inline] - fn set_micro(&mut self, value: &JsValue, context: &mut Context<'_>) -> JsResult<()> { + fn set_micro(&mut self, value: &JsValue, context: &mut Context) -> JsResult<()> { let micro = super::to_integer_with_truncation(value, context)?; self.microsecond = micro; self.bit_map.set(FieldMap::MICROSECOND, true); @@ -220,7 +220,7 @@ impl TemporalFields { } #[inline] - fn set_nano(&mut self, value: &JsValue, context: &mut Context<'_>) -> JsResult<()> { + fn set_nano(&mut self, value: &JsValue, context: &mut Context) -> JsResult<()> { let nano = super::to_integer_with_truncation(value, context)?; self.nanosecond = nano; self.bit_map.set(FieldMap::NANOSECOND, true); @@ -228,7 +228,7 @@ impl TemporalFields { } #[inline] - fn set_offset(&mut self, value: &JsValue, context: &mut Context<'_>) -> JsResult<()> { + fn set_offset(&mut self, value: &JsValue, context: &mut Context) -> JsResult<()> { let mc = value.to_primitive(context, PreferredType::String)?; if let Some(string) = mc.as_string() { self.offset = Some(string.clone()); @@ -243,7 +243,7 @@ impl TemporalFields { } #[inline] - fn set_era(&mut self, value: &JsValue, context: &mut Context<'_>) -> JsResult<()> { + fn set_era(&mut self, value: &JsValue, context: &mut Context) -> JsResult<()> { let mc = value.to_primitive(context, PreferredType::String)?; if let Some(string) = mc.as_string() { self.era = Some(string.clone()); @@ -258,7 +258,7 @@ impl TemporalFields { } #[inline] - fn set_era_year(&mut self, value: &JsValue, context: &mut Context<'_>) -> JsResult<()> { + fn set_era_year(&mut self, value: &JsValue, context: &mut Context) -> JsResult<()> { let ey = super::to_integer_with_truncation(value, context)?; self.era_year = Some(ey); self.bit_map.set(FieldMap::ERA_YEAR, true); @@ -286,7 +286,7 @@ impl TemporalFields { extended_fields: Option>, partial: bool, dup_behaviour: Option, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If duplicateBehaviour is not present, set duplicateBehaviour to throw. let dup_option = dup_behaviour.unwrap_or_else(|| js_string!("throw")); @@ -392,7 +392,7 @@ impl TemporalFields { } /// Convert a `TemporalFields` struct into a `JsObject`. - pub(crate) fn as_object(&self, context: &mut Context<'_>) -> JsResult { + pub(crate) fn as_object(&self, context: &mut Context) -> JsResult { let obj = JsObject::with_null_proto(); for bit in self.bit_map.iter() { diff --git a/boa_engine/src/builtins/temporal/instant/mod.rs b/boa_engine/src/builtins/temporal/instant/mod.rs index 7bd093961fc..4d3e8b6e653 100644 --- a/boa_engine/src/builtins/temporal/instant/mod.rs +++ b/boa_engine/src/builtins/temporal/instant/mod.rs @@ -117,7 +117,7 @@ impl BuiltInConstructor for Instant { fn constructor( new_target: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If NewTarget is undefined, then if new_target.is_undefined() { @@ -148,7 +148,7 @@ impl Instant { pub(crate) fn get_epoc_seconds( this: &JsValue, _: &[JsValue], - _: &mut Context<'_>, + _: &mut Context, ) -> JsResult { // 1. Let instant be the this value. // 2. Perform ? RequireInternalSlot(instant, [[InitializedTemporalInstant]]). @@ -170,7 +170,7 @@ impl Instant { pub(crate) fn get_epoc_milliseconds( this: &JsValue, _: &[JsValue], - _: &mut Context<'_>, + _: &mut Context, ) -> JsResult { // 1. Let instant be the this value. // 2. Perform ? RequireInternalSlot(instant, [[InitializedTemporalInstant]]). @@ -192,7 +192,7 @@ impl Instant { pub(crate) fn get_epoc_microseconds( this: &JsValue, _: &[JsValue], - _: &mut Context<'_>, + _: &mut Context, ) -> JsResult { // 1. Let instant be the this value. // 2. Perform ? RequireInternalSlot(instant, [[InitializedTemporalInstant]]). @@ -217,7 +217,7 @@ impl Instant { pub(crate) fn get_epoc_nanoseconds( this: &JsValue, _: &[JsValue], - _: &mut Context<'_>, + _: &mut Context, ) -> JsResult { // 1. Let instant be the this value. // 2. Perform ? RequireInternalSlot(instant, [[InitializedTemporalInstant]]). @@ -237,7 +237,7 @@ impl Instant { pub(crate) fn add( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let instant be the this value. // 2. Perform ? RequireInternalSlot(instant, [[InitializedTemporalInstant]]). @@ -257,7 +257,7 @@ impl Instant { pub(crate) fn subtract( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let instant be the this value. // 2. Perform ? RequireInternalSlot(instant, [[InitializedTemporalInstant]]). @@ -277,7 +277,7 @@ impl Instant { pub(crate) fn until( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let instant be the this value. // 2. Perform ? RequireInternalSlot(instant, [[InitializedTemporalInstant]]). @@ -298,7 +298,7 @@ impl Instant { pub(crate) fn since( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let instant be the this value. // 2. Perform ? RequireInternalSlot(instant, [[InitializedTemporalInstant]]). @@ -319,7 +319,7 @@ impl Instant { pub(crate) fn round( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let instant be the this value. // 2. Perform ? RequireInternalSlot(instant, [[InitializedTemporalInstant]]). @@ -418,11 +418,7 @@ impl Instant { } /// 8.3.12 `Temporal.Instant.prototype.equals ( other )` - pub(crate) fn equals( - this: &JsValue, - args: &[JsValue], - _: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn equals(this: &JsValue, args: &[JsValue], _: &mut Context) -> JsResult { // 1. Let instant be the this value. // 2. Perform ? RequireInternalSlot(instant, [[InitializedTemporalInstant]]). // 4. If instant.[[Nanoseconds]] ≠ other.[[Nanoseconds]], return false. @@ -448,7 +444,7 @@ impl Instant { pub(crate) fn to_zoned_date_time( _: &JsValue, _: &[JsValue], - _: &mut Context<'_>, + _: &mut Context, ) -> JsResult { // TODO: Complete Err(JsNativeError::error() @@ -460,7 +456,7 @@ impl Instant { pub(crate) fn to_zoned_date_time_iso( _: &JsValue, _: &[JsValue], - _: &mut Context<'_>, + _: &mut Context, ) -> JsResult { // TODO Complete Err(JsNativeError::error() @@ -491,7 +487,7 @@ fn is_valid_epoch_nanos(epoch_nanos: &JsBigInt) -> bool { fn create_temporal_instant( epoch_nanos: JsBigInt, new_target: Option, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Assert: ! IsValidEpochNanoseconds(epochNanoseconds) is true. assert!(is_valid_epoch_nanos(&epoch_nanos)); @@ -575,7 +571,7 @@ fn diff_instant( smallest_unit: TemporalUnit, largest_unit: TemporalUnit, rounding_mode: RoundingMode, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let difference be ℝ(ns2) - ℝ(ns1). let difference = JsBigInt::sub(ns1, ns2); @@ -692,7 +688,7 @@ fn diff_temporal_instant( instant: &Instant, other: &JsValue, options: &JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If operation is since, let sign be -1. Otherwise, let sign be 1. let sign = if op { 1_f64 } else { -1_f64 }; @@ -749,7 +745,7 @@ fn add_or_subtract_duration_from_instant( op: bool, instant: &Instant, temporal_duration_like: &JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If operation is subtract, let sign be -1. Otherwise, let sign be 1. let sign = if op { 1 } else { -1 }; diff --git a/boa_engine/src/builtins/temporal/mod.rs b/boa_engine/src/builtins/temporal/mod.rs index d6617da2e23..ecc28d60199 100644 --- a/boa_engine/src/builtins/temporal/mod.rs +++ b/boa_engine/src/builtins/temporal/mod.rs @@ -195,7 +195,7 @@ fn to_zero_padded_decimal_string(n: u64, min_length: usize) -> String { pub(crate) fn iterator_to_list_of_types( iterator: &mut IteratorRecord, element_types: &[Type], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult> { // 1. Let values be a new empty List. let mut values = Vec::new(); @@ -293,7 +293,7 @@ pub(crate) fn validate_temporal_rounding_increment( /// 13.21 `ToRelativeTemporalObject ( options )` pub(crate) fn to_relative_temporal_object( _options: &JsObject, - _context: &mut Context<'_>, + _context: &mut Context, ) -> JsResult<(Option, Option)> { Err(JsNativeError::range() .with_message("not yet implemented.") @@ -435,7 +435,7 @@ pub(crate) fn round_to_increment_as_if_positive( #[inline] pub(crate) fn to_positive_integer_with_trunc( value: &JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let integer be ? ToIntegerWithTruncation(argument). let int = to_integer_with_truncation(value, context)?; @@ -451,10 +451,7 @@ pub(crate) fn to_positive_integer_with_trunc( /// 13.44 `ToIntegerWithTruncation ( argument )` #[inline] -pub(crate) fn to_integer_with_truncation( - value: &JsValue, - context: &mut Context<'_>, -) -> JsResult { +pub(crate) fn to_integer_with_truncation(value: &JsValue, context: &mut Context) -> JsResult { // 1. Let number be ? ToNumber(argument). let number = value.to_number(context)?; // 2. If number is NaN, +∞𝔽 or -∞𝔽, throw a RangeError exception. @@ -469,7 +466,7 @@ pub(crate) fn to_integer_with_truncation( /// Abstract operation 13.45 `ToIntegerIfIntegral( argument )` #[inline] -pub(crate) fn to_integer_if_integral(arg: &JsValue, context: &mut Context<'_>) -> JsResult { +pub(crate) fn to_integer_if_integral(arg: &JsValue, context: &mut Context) -> JsResult { // 1. Let number be ? ToNumber(argument). // 2. If IsIntegralNumber(number) is false, throw a RangeError exception. // 3. Return ℝ(number). @@ -495,7 +492,7 @@ pub(crate) fn get_diff_settings( disallowed_units: &[TemporalUnit], fallback_smallest_unit: TemporalUnit, smallest_largest_default_unit: TemporalUnit, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult<(TemporalUnit, TemporalUnit, RoundingMode, f64)> { // 1. NOTE: The following steps read options and perform independent validation in alphabetical order (ToTemporalRoundingIncrement reads "roundingIncrement" and ToTemporalRoundingMode reads "roundingMode"). // 2. Let largestUnit be ? GetTemporalUnit(options, "largestUnit", unitGroup, "auto"). @@ -574,7 +571,7 @@ pub(crate) fn copy_data_properties( source: &JsValue, excluded_keys: &Vec, excluded_values: Option<&Vec>, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult<()> { // 1. If source is undefined or null, return unused. if source.is_null_or_undefined() { @@ -644,7 +641,7 @@ fn snapshot_own_properties( source: &JsObject, excluded_keys: Option>, excluded_values: Option>, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let copy be OrdinaryObjectCreate(proto). let copy = JsObject::with_null_proto(); diff --git a/boa_engine/src/builtins/temporal/now.rs b/boa_engine/src/builtins/temporal/now.rs index 567823249db..d628884bf31 100644 --- a/boa_engine/src/builtins/temporal/now.rs +++ b/boa_engine/src/builtins/temporal/now.rs @@ -65,59 +65,55 @@ impl Now { /// /// [spec]: https://tc39.es/proposal-temporal/#sec-temporal.now.timezone #[allow(clippy::unnecessary_wraps)] - fn time_zone_id( - _: &JsValue, - _args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + fn time_zone_id(_: &JsValue, _args: &[JsValue], context: &mut Context) -> JsResult { // 1. Return ! SystemTimeZone(). Ok(system_time_zone(context).expect("retrieving the system timezone must not fail")) } /// `Temporal.Now.instant()` - fn instant(_: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn instant(_: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::error() .with_message("not yet implemented.") .into()) } /// `Temporal.Now.plainDateTime()` - fn plain_date_time(_: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn plain_date_time(_: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::error() .with_message("not yet implemented.") .into()) } /// `Temporal.Now.plainDateTimeISO` - fn plain_date_time_iso(_: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn plain_date_time_iso(_: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::error() .with_message("not yet implemented.") .into()) } /// `Temporal.Now.zonedDateTime` - fn zoned_date_time(_: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn zoned_date_time(_: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::error() .with_message("not yet implemented.") .into()) } /// `Temporal.Now.zonedDateTimeISO` - fn zoned_date_time_iso(_: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn zoned_date_time_iso(_: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::error() .with_message("not yet implemented.") .into()) } /// `Temporal.Now.plainDate()` - fn plain_date(_: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn plain_date(_: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::error() .with_message("not yet implemented.") .into()) } /// `Temporal.Now.plainDateISO` - fn plain_date_iso(_: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn plain_date_iso(_: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::error() .with_message("not yet implemented.") .into()) @@ -180,7 +176,7 @@ fn system_zoned_date_time() { /// /// [spec]: https://tc39.es/proposal-temporal/#sec-temporal-systemtimezone #[allow(unused)] -fn system_time_zone(context: &mut Context<'_>) -> JsResult { +fn system_time_zone(context: &mut Context) -> JsResult { // 1. Let identifier be ! DefaultTimeZone(). let identifier = default_time_zone(context); // 2. Return ! CreateTemporalTimeZone(identifier). diff --git a/boa_engine/src/builtins/temporal/options.rs b/boa_engine/src/builtins/temporal/options.rs index d66462ec74c..92f1cf45f24 100644 --- a/boa_engine/src/builtins/temporal/options.rs +++ b/boa_engine/src/builtins/temporal/options.rs @@ -19,7 +19,7 @@ use std::{fmt, str::FromStr}; #[inline] pub(crate) fn get_temporal_rounding_increment( options: &JsObject, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let increment be ? GetOption(normalizedOptions, "roundingIncrement", "number", undefined, 1𝔽). let value = options.get(js_string!("roundingIncrement"), context)?; @@ -58,7 +58,7 @@ pub(crate) fn get_temporal_unit( key: &[u16], unit_group: TemporalUnitGroup, extra_values: Option>, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult> { let extra = extra_values.unwrap_or_default(); let mut unit_values = unit_group.group(); diff --git a/boa_engine/src/builtins/temporal/plain_date/mod.rs b/boa_engine/src/builtins/temporal/plain_date/mod.rs index 441be37ee0e..d43245cec46 100644 --- a/boa_engine/src/builtins/temporal/plain_date/mod.rs +++ b/boa_engine/src/builtins/temporal/plain_date/mod.rs @@ -208,7 +208,7 @@ impl BuiltInConstructor for PlainDate { fn constructor( new_target: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { if new_target.is_undefined() { return Err(JsNativeError::typ() @@ -230,85 +230,85 @@ impl BuiltInConstructor for PlainDate { // -- `PlainDate` getter methods -- impl PlainDate { - fn get_calendar_id(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn get_calendar_id(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::error() .with_message("calendars not yet implemented.") .into()) } - fn get_year(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn get_year(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::error() .with_message("not yet implemented.") .into()) } - fn get_month(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn get_month(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::error() .with_message("not yet implemented.") .into()) } - fn get_month_code(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn get_month_code(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::error() .with_message("not yet implemented.") .into()) } - fn get_day(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn get_day(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::error() .with_message("not yet implemented.") .into()) } - fn get_day_of_week(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn get_day_of_week(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::error() .with_message("not yet implemented.") .into()) } - fn get_day_of_year(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn get_day_of_year(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::error() .with_message("not yet implemented.") .into()) } - fn get_week_of_year(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn get_week_of_year(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::error() .with_message("not yet implemented.") .into()) } - fn get_year_of_week(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn get_year_of_week(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::error() .with_message("not yet implemented.") .into()) } - fn get_days_in_week(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn get_days_in_week(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::error() .with_message("not yet implemented.") .into()) } - fn get_days_in_month(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn get_days_in_month(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::error() .with_message("not yet implemented.") .into()) } - fn get_days_in_year(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn get_days_in_year(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::error() .with_message("not yet implemented.") .into()) } - fn get_months_in_year(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn get_months_in_year(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::error() .with_message("not yet implemented.") .into()) } - fn get_in_leap_year(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn get_in_leap_year(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::error() .with_message("not yet implemented.") .into()) @@ -318,71 +318,67 @@ impl PlainDate { // ==== `PlainDate.prototype` method implementation ==== impl PlainDate { - fn to_plain_year_month( - this: &JsValue, - _: &[JsValue], - _: &mut Context<'_>, - ) -> JsResult { + fn to_plain_year_month(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::error() .with_message("not yet implemented.") .into()) } - fn to_plain_month_day(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn to_plain_month_day(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::error() .with_message("not yet implemented.") .into()) } - fn get_iso_fields(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn get_iso_fields(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::error() .with_message("not yet implemented.") .into()) } - fn get_calendar(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn get_calendar(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::error() .with_message("not yet implemented.") .into()) } - fn add(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn add(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::error() .with_message("not yet implemented.") .into()) } - fn subtract(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn subtract(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::error() .with_message("not yet implemented.") .into()) } - fn with(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn with(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::error() .with_message("not yet implemented.") .into()) } - fn with_calendar(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn with_calendar(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::error() .with_message("not yet implemented.") .into()) } - fn until(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn until(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::error() .with_message("not yet implemented.") .into()) } - fn since(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn since(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::error() .with_message("not yet implemented.") .into()) } - fn equals(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn equals(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::error() .with_message("not yet implemented.") .into()) @@ -393,7 +389,7 @@ impl PlainDate { impl PlainDate { /// Utitily function for translating a `Temporal.PlainDate` into a `JsObject`. - pub(crate) fn as_object(&self, context: &mut Context<'_>) -> JsResult { + pub(crate) fn as_object(&self, context: &mut Context) -> JsResult { create_temporal_date(self.inner, self.calendar.clone(), None, context) } } @@ -406,7 +402,7 @@ pub(crate) fn create_temporal_date( iso_date: IsoDateRecord, calendar: JsValue, new_target: Option<&JsValue>, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If IsValidISODate(isoYear, isoMonth, isoDay) is false, throw a RangeError exception. if !iso_date.is_valid() { @@ -462,7 +458,7 @@ pub(crate) fn create_temporal_date( pub(crate) fn to_temporal_date( item: &JsValue, options: Option, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If options is not present, set options to undefined. let options = options.unwrap_or(JsValue::undefined()); @@ -577,7 +573,7 @@ pub(crate) fn difference_date( one: &PlainDate, two: &PlainDate, largest_unit: TemporalUnit, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Assert: one.[[Calendar]] and two.[[Calendar]] have been determined to be equivalent as with CalendarEquals. // 2. Assert: options is an ordinary Object. @@ -633,7 +629,7 @@ pub(crate) fn add_date( plain_date: &PlainDate, duration: &DurationRecord, options: &JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If options is not present, set options to undefined. // 2. If duration.[[Years]] ≠ 0, or duration.[[Months]] ≠ 0, or duration.[[Weeks]] ≠ 0, then diff --git a/boa_engine/src/builtins/temporal/plain_date_time/mod.rs b/boa_engine/src/builtins/temporal/plain_date_time/mod.rs index e3e5bf938f1..83aa5b4c80b 100644 --- a/boa_engine/src/builtins/temporal/plain_date_time/mod.rs +++ b/boa_engine/src/builtins/temporal/plain_date_time/mod.rs @@ -53,7 +53,7 @@ impl BuiltInConstructor for PlainDateTime { fn constructor( new_target: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { Err(JsNativeError::range() .with_message("Not yet implemented.") @@ -64,79 +64,79 @@ impl BuiltInConstructor for PlainDateTime { // ==== `PlainDateTime` Accessor Properties ==== impl PlainDateTime { - fn calendar_id(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn calendar_id(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::error() .with_message("calendars not yet implemented.") .into()) } - fn year(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn year(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::error() .with_message("calendars not yet implemented.") .into()) } - fn month(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn month(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::error() .with_message("calendars not yet implemented.") .into()) } - fn month_code(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn month_code(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::error() .with_message("calendars not yet implemented.") .into()) } - fn day(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn day(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::error() .with_message("calendars not yet implemented.") .into()) } - fn hour(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn hour(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::error() .with_message("calendars not yet implemented.") .into()) } - fn minute(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn minute(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::error() .with_message("calendars not yet implemented.") .into()) } - fn second(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn second(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::error() .with_message("calendars not yet implemented.") .into()) } - fn millisecond(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn millisecond(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::error() .with_message("calendars not yet implemented.") .into()) } - fn microsecond(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn microsecond(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::error() .with_message("calendars not yet implemented.") .into()) } - fn nanosecond(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn nanosecond(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::error() .with_message("calendars not yet implemented.") .into()) } - fn era(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn era(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::error() .with_message("calendars not yet implemented.") .into()) } - fn era_year(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn era_year(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::error() .with_message("calendars not yet implemented.") .into()) diff --git a/boa_engine/src/builtins/temporal/plain_month_day/mod.rs b/boa_engine/src/builtins/temporal/plain_month_day/mod.rs index a970fc26f23..4571914311c 100644 --- a/boa_engine/src/builtins/temporal/plain_month_day/mod.rs +++ b/boa_engine/src/builtins/temporal/plain_month_day/mod.rs @@ -51,7 +51,7 @@ impl BuiltInConstructor for PlainMonthDay { fn constructor( new_target: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { Err(JsNativeError::range() .with_message("Not yet implemented.") @@ -65,7 +65,7 @@ pub(crate) fn create_temporal_month_day( iso: IsoDateRecord, calendar: JsValue, new_target: Option<&JsValue>, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If IsValidISODate(referenceISOYear, isoMonth, isoDay) is false, throw a RangeError exception. if iso.is_valid() { diff --git a/boa_engine/src/builtins/temporal/plain_time/mod.rs b/boa_engine/src/builtins/temporal/plain_time/mod.rs index 245fbbd0084..895365bede3 100644 --- a/boa_engine/src/builtins/temporal/plain_time/mod.rs +++ b/boa_engine/src/builtins/temporal/plain_time/mod.rs @@ -53,7 +53,7 @@ impl BuiltInConstructor for PlainTime { fn constructor( new_target: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { Err(JsNativeError::range() .with_message("Not yet implemented.") diff --git a/boa_engine/src/builtins/temporal/plain_year_month/mod.rs b/boa_engine/src/builtins/temporal/plain_year_month/mod.rs index d5c6ead7bdf..885cf1a8171 100644 --- a/boa_engine/src/builtins/temporal/plain_year_month/mod.rs +++ b/boa_engine/src/builtins/temporal/plain_year_month/mod.rs @@ -128,7 +128,7 @@ impl BuiltInConstructor for PlainYearMonth { fn constructor( new_target: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If NewTarget is undefined, then if new_target.is_undefined() { @@ -170,53 +170,49 @@ impl BuiltInConstructor for PlainYearMonth { // ==== `PlainYearMonth` Accessor Implementations ==== impl PlainYearMonth { - fn get_calendar_id(_this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn get_calendar_id(_this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::error() .with_message("not yet implemented.") .into()) } - fn get_year(_this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn get_year(_this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::error() .with_message("not yet implemented.") .into()) } - fn get_month(_this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn get_month(_this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::error() .with_message("not yet implemented.") .into()) } - fn get_month_code(_this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn get_month_code(_this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::error() .with_message("not yet implemented.") .into()) } - fn get_days_in_year(_this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn get_days_in_year(_this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::error() .with_message("not yet implemented.") .into()) } - fn get_days_in_month(_this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn get_days_in_month(_this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::error() .with_message("not yet implemented.") .into()) } - fn get_months_in_year( - _this: &JsValue, - _: &[JsValue], - _: &mut Context<'_>, - ) -> JsResult { + fn get_months_in_year(_this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::error() .with_message("not yet implemented.") .into()) } - fn get_in_leap_year(_this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn get_in_leap_year(_this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::error() .with_message("not yet implemented.") .into()) @@ -226,37 +222,37 @@ impl PlainYearMonth { // ==== `PlainYearMonth` Method Implementations ==== impl PlainYearMonth { - fn with(_this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn with(_this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::typ() .with_message("not yet implemented.") .into()) } - fn add(_this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn add(_this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::typ() .with_message("not yet implemented.") .into()) } - fn subtract(_this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn subtract(_this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::typ() .with_message("not yet implemented.") .into()) } - fn until(_this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn until(_this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::typ() .with_message("not yet implemented.") .into()) } - fn since(_this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn since(_this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::typ() .with_message("not yet implemented.") .into()) } - fn equals(_this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn equals(_this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Err(JsNativeError::typ() .with_message("not yet implemented.") .into()) @@ -273,7 +269,7 @@ pub(crate) fn create_temporal_year_month( year_month_record: IsoDateRecord, calendar: JsValue, new_target: Option<&JsValue>, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If IsValidISODate(isoYear, isoMonth, referenceISODay) is false, throw a RangeError exception. if !year_month_record.is_valid() { diff --git a/boa_engine/src/builtins/temporal/time_zone/mod.rs b/boa_engine/src/builtins/temporal/time_zone/mod.rs index 1f053ade575..2cf188c8c1c 100644 --- a/boa_engine/src/builtins/temporal/time_zone/mod.rs +++ b/boa_engine/src/builtins/temporal/time_zone/mod.rs @@ -97,7 +97,7 @@ impl BuiltInConstructor for TimeZone { fn constructor( new_target: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If NewTarget is undefined, then // 1a. Throw a TypeError exception. @@ -130,7 +130,7 @@ impl BuiltInConstructor for TimeZone { impl TimeZone { // NOTE: id, toJSON, toString currently share the exact same implementation -> Consolidate into one function and define multiple accesors? - pub(crate) fn get_id(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + pub(crate) fn get_id(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { let o = this.as_object().map(JsObject::borrow).ok_or_else(|| { JsNativeError::typ().with_message("this value must be a Temporal.TimeZone") })?; @@ -143,7 +143,7 @@ impl TimeZone { pub(crate) fn get_offset_nanoseconds_for( this: &JsValue, args: &[JsValue], - _: &mut Context<'_>, + _: &mut Context, ) -> JsResult { // 1. Let timeZone be the this value. // 2. Perform ? RequireInternalSlot(timeZone, [[InitializedTemporalTimeZone]]). @@ -172,7 +172,7 @@ impl TimeZone { pub(crate) fn get_offset_string_for( this: &JsValue, args: &[JsValue], - _: &mut Context<'_>, + _: &mut Context, ) -> JsResult { // 1. Let timeZone be the this value. // 2. Perform ? RequireInternalSlot(timeZone, [[InitializedTemporalTimeZone]]). @@ -200,7 +200,7 @@ impl TimeZone { pub(crate) fn get_plain_date_time_for( _: &JsValue, _: &[JsValue], - _: &mut Context<'_>, + _: &mut Context, ) -> JsResult { Err(JsNativeError::error() .with_message("not yet implemented.") @@ -210,7 +210,7 @@ impl TimeZone { pub(crate) fn get_instant_for( _: &JsValue, _: &[JsValue], - _: &mut Context<'_>, + _: &mut Context, ) -> JsResult { Err(JsNativeError::error() .with_message("not yet implemented.") @@ -220,7 +220,7 @@ impl TimeZone { pub(crate) fn get_possible_instants_for( _: &JsValue, _: &[JsValue], - _: &mut Context<'_>, + _: &mut Context, ) -> JsResult { Err(JsNativeError::error() .with_message("not yet implemented.") @@ -230,7 +230,7 @@ impl TimeZone { pub(crate) fn get_next_transition( _: &JsValue, _: &[JsValue], - _: &mut Context<'_>, + _: &mut Context, ) -> JsResult { Err(JsNativeError::error() .with_message("not yet implemented.") @@ -240,18 +240,14 @@ impl TimeZone { pub(crate) fn get_previous_transition( _: &JsValue, _: &[JsValue], - _: &mut Context<'_>, + _: &mut Context, ) -> JsResult { Err(JsNativeError::error() .with_message("not yet implemented.") .into()) } - pub(crate) fn to_string( - this: &JsValue, - _: &[JsValue], - _: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn to_string(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { // 1. Let timeZone be the this value. // 2. Perform ? RequireInternalSlot(timeZone, [[InitializedTemporalTimeZone]]). let o = this.as_object().ok_or_else(|| { @@ -283,7 +279,7 @@ impl TimeZone { /// /// [spec]: https://tc39.es/proposal-temporal/#sec-defaulttimezone #[allow(unused)] -pub(super) fn default_time_zone(context: &mut Context<'_>) -> String { +pub(super) fn default_time_zone(context: &mut Context) -> String { // The minimum implementation of DefaultTimeZone for ECMAScript implementations that do not // include the ECMA-402 API, supporting only the "UTC" time zone, performs the following steps // when called: @@ -304,7 +300,7 @@ pub(super) fn default_time_zone(context: &mut Context<'_>) -> String { pub(super) fn create_temporal_time_zone( identifier: String, new_target: Option, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If newTarget is not present, set newTarget to %Temporal.TimeZone%. let new_target = new_target.unwrap_or_else(|| { @@ -367,7 +363,7 @@ pub(super) fn create_temporal_time_zone( /// /// [spec]: https://tc39.es/ecma262/#sec-parsetimezoneoffsetstring #[allow(clippy::unnecessary_wraps, unused)] -fn parse_timezone_offset_string(offset_string: &str, context: &mut Context<'_>) -> JsResult { +fn parse_timezone_offset_string(offset_string: &str, context: &mut Context) -> JsResult { use boa_parser::temporal::{IsoCursor, TemporalTimeZoneString}; // 1. Let parseResult be ParseText(StringToCodePoints(offsetString), UTCOffset). diff --git a/boa_engine/src/builtins/temporal/zoned_date_time/mod.rs b/boa_engine/src/builtins/temporal/zoned_date_time/mod.rs index 6034dec9f3f..98be2226e09 100644 --- a/boa_engine/src/builtins/temporal/zoned_date_time/mod.rs +++ b/boa_engine/src/builtins/temporal/zoned_date_time/mod.rs @@ -48,7 +48,7 @@ impl BuiltInConstructor for ZonedDateTime { fn constructor( new_target: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // TODO: Implement ZonedDateTime. Err(JsNativeError::error() diff --git a/boa_engine/src/builtins/typed_array/builtin.rs b/boa_engine/src/builtins/typed_array/builtin.rs index 9780f01b5fd..27b93867459 100644 --- a/boa_engine/src/builtins/typed_array/builtin.rs +++ b/boa_engine/src/builtins/typed_array/builtin.rs @@ -176,7 +176,7 @@ impl BuiltInConstructor for BuiltinTypedArray { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-%typedarray% - fn constructor(_: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn constructor(_: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { // 1. Throw a TypeError exception. Err(JsNativeError::typ() .with_message("the TypedArray constructor should never be called directly") @@ -191,7 +191,7 @@ impl BuiltinTypedArray { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-%typedarray%.from - fn from(this: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult { + fn from(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let C be the this value. // 2. If IsConstructor(C) is false, throw a TypeError exception. let constructor = match this.as_object() { @@ -301,7 +301,7 @@ impl BuiltinTypedArray { fn from_kind_and_length( kind: TypedArrayKind, length: u64, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let constructor = kind.standard_constructor()(context.intrinsics().constructors()).constructor(); @@ -315,7 +315,7 @@ impl BuiltinTypedArray { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-%typedarray%.of - fn of(this: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult { + fn of(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let len be the number of elements in items. // 2. Let C be the this value. @@ -352,11 +352,7 @@ impl BuiltinTypedArray { /// /// [spec]: https://tc39.es/ecma262/#sec-get-%typedarray%-@@species #[allow(clippy::unnecessary_wraps)] - pub(super) fn get_species( - this: &JsValue, - _: &[JsValue], - _: &mut Context<'_>, - ) -> JsResult { + pub(super) fn get_species(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { // 1. Return the this value. Ok(this.clone()) } @@ -367,11 +363,7 @@ impl BuiltinTypedArray { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-%typedarray%.prototype.at - pub(crate) fn at( - this: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn at(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be the this value. // 2. Perform ? ValidateTypedArray(O). let obj = this.as_object().ok_or_else(|| { @@ -423,7 +415,7 @@ impl BuiltinTypedArray { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-get-%typedarray%.prototype.buffer - fn buffer(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn buffer(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { // 1. Let O be the this value. // 2. Perform ? RequireInternalSlot(O, [[TypedArrayName]]). // 3. Assert: O has a [[ViewedArrayBuffer]] internal slot. @@ -446,11 +438,7 @@ impl BuiltinTypedArray { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-get-%typedarray%.prototype.bytelength - pub(crate) fn byte_length( - this: &JsValue, - _: &[JsValue], - _: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn byte_length(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { // 1. Let O be the this value. // 2. Perform ? RequireInternalSlot(O, [[TypedArrayName]]). // 3. Assert: O has a [[ViewedArrayBuffer]] internal slot. @@ -479,11 +467,7 @@ impl BuiltinTypedArray { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-get-%typedarray%.prototype.byteoffset - pub(crate) fn byte_offset( - this: &JsValue, - _: &[JsValue], - _: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn byte_offset(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { // 1. Let O be the this value. // 2. Perform ? RequireInternalSlot(O, [[TypedArrayName]]). // 3. Assert: O has a [[ViewedArrayBuffer]] internal slot. @@ -512,11 +496,7 @@ impl BuiltinTypedArray { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-%typedarray%.prototype.copywithin - fn copy_within( - this: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + fn copy_within(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be the this value. let obj = this.as_object().ok_or_else(|| { JsNativeError::typ().with_message("Value is not a typed array object") @@ -658,7 +638,7 @@ impl BuiltinTypedArray { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-%typedarray%.prototype.entries - fn entries(this: &JsValue, _: &[JsValue], context: &mut Context<'_>) -> JsResult { + fn entries(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be the this value. // 2. Perform ? ValidateTypedArray(O). let o = this.as_object().ok_or_else(|| { @@ -691,7 +671,7 @@ impl BuiltinTypedArray { pub(crate) fn every( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be the this value. // 2. Perform ? ValidateTypedArray(O). @@ -760,7 +740,7 @@ impl BuiltinTypedArray { pub(crate) fn fill( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be the this value. // 2. Perform ? ValidateTypedArray(O). @@ -850,7 +830,7 @@ impl BuiltinTypedArray { pub(crate) fn filter( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be the this value. // 2. Perform ? ValidateTypedArray(O). @@ -942,7 +922,7 @@ impl BuiltinTypedArray { pub(crate) fn find( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be the this value. // 2. Perform ? ValidateTypedArray(O). @@ -991,7 +971,7 @@ impl BuiltinTypedArray { pub(crate) fn find_index( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be the this value. // 2. Perform ? ValidateTypedArray(O). @@ -1040,7 +1020,7 @@ impl BuiltinTypedArray { pub(crate) fn find_last( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be the this value. // 2. Perform ? ValidateTypedArray(O). @@ -1087,7 +1067,7 @@ impl BuiltinTypedArray { pub(crate) fn find_last_index( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be the this value. // 2. Perform ? ValidateTypedArray(O). @@ -1134,7 +1114,7 @@ impl BuiltinTypedArray { pub(crate) fn foreach( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be the this value. // 2. Perform ? ValidateTypedArray(O). @@ -1195,7 +1175,7 @@ impl BuiltinTypedArray { pub(crate) fn includes( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be the this value. // 2. Perform ? ValidateTypedArray(O). @@ -1276,7 +1256,7 @@ impl BuiltinTypedArray { pub(crate) fn index_of( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be the this value. // 2. Perform ? ValidateTypedArray(O). @@ -1366,7 +1346,7 @@ impl BuiltinTypedArray { pub(crate) fn join( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be the this value. // 2. Perform ? ValidateTypedArray(O). @@ -1428,11 +1408,7 @@ impl BuiltinTypedArray { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-%typedarray%.prototype.keys - pub(crate) fn keys( - this: &JsValue, - _: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn keys(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be the this value. // 2. Perform ? ValidateTypedArray(O). let o = this.as_object().ok_or_else(|| { @@ -1465,7 +1441,7 @@ impl BuiltinTypedArray { pub(crate) fn last_index_of( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be the this value. // 2. Perform ? ValidateTypedArray(O). @@ -1544,7 +1520,7 @@ impl BuiltinTypedArray { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-get-%typedarray%.prototype.length - pub(crate) fn length(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + pub(crate) fn length(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { // 1. Let O be the this value. // 2. Perform ? RequireInternalSlot(O, [[TypedArrayName]]). // 3. Assert: O has [[ViewedArrayBuffer]] and [[ArrayLength]] internal slots. @@ -1576,7 +1552,7 @@ impl BuiltinTypedArray { pub(crate) fn map( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be the this value. // 2. Perform ? ValidateTypedArray(O). @@ -1646,7 +1622,7 @@ impl BuiltinTypedArray { pub(crate) fn reduce( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be the this value. // 2. Perform ? ValidateTypedArray(O). @@ -1733,7 +1709,7 @@ impl BuiltinTypedArray { pub(crate) fn reduceright( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be the this value. // 2. Perform ? ValidateTypedArray(O). @@ -1823,7 +1799,7 @@ impl BuiltinTypedArray { pub(crate) fn reverse( this: &JsValue, _: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be the this value. // 2. Perform ? ValidateTypedArray(O). @@ -1883,7 +1859,7 @@ impl BuiltinTypedArray { pub(crate) fn to_reversed( this: &JsValue, _: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be the this value. // 2. Let iieoRecord be ? ValidateTypedArray(O, seq-cst). @@ -1937,7 +1913,7 @@ impl BuiltinTypedArray { pub(crate) fn set( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let target be the this value. // 2. Perform ? RequireInternalSlot(target, [[TypedArrayName]]). @@ -1998,7 +1974,7 @@ impl BuiltinTypedArray { target: &JsObject, target_offset: &U64OrPositiveInfinity, source: &JsObject, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult<()> { let target_borrow = target.borrow(); let target_array = target_borrow @@ -2232,7 +2208,7 @@ impl BuiltinTypedArray { target: &JsObject, target_offset: &U64OrPositiveInfinity, source: &JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult<()> { let target_length = { let target_borrow = target.borrow(); @@ -2304,7 +2280,7 @@ impl BuiltinTypedArray { pub(crate) fn slice( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be the this value. // 2. Perform ? ValidateTypedArray(O). @@ -2477,7 +2453,7 @@ impl BuiltinTypedArray { pub(crate) fn some( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be the this value. // 2. Perform ? ValidateTypedArray(O). @@ -2545,7 +2521,7 @@ impl BuiltinTypedArray { pub(crate) fn sort( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If comparefn is not undefined and IsCallable(comparefn) is false, throw a TypeError exception. let compare_fn = match args.get(0) { @@ -2585,7 +2561,7 @@ impl BuiltinTypedArray { // 5. NOTE: The following closure performs a numeric comparison rather than the string comparison used in 23.1.3.30. // 6. Let SortCompare be a new Abstract Closure with parameters (x, y) that captures comparefn and performs the following steps when called: let sort_compare = - |x: &JsValue, y: &JsValue, context: &mut Context<'_>| -> JsResult { + |x: &JsValue, y: &JsValue, context: &mut Context| -> JsResult { // a. Return ? CompareTypedArrayElements(x, y, comparefn). compare_typed_array_elements(x, y, compare_fn, context) }; @@ -2613,7 +2589,7 @@ impl BuiltinTypedArray { pub(crate) fn to_sorted( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If comparefn is not undefined and IsCallable(comparefn) is false, throw a TypeError exception. let compare_fn = match args.get(0) { @@ -2653,7 +2629,7 @@ impl BuiltinTypedArray { // 6. NOTE: The following closure performs a numeric comparison rather than the string comparison used in 23.1.3.34. // 7. Let SortCompare be a new Abstract Closure with parameters (x, y) that captures comparefn and performs the following steps when called: let sort_compare = - |x: &JsValue, y: &JsValue, context: &mut Context<'_>| -> JsResult { + |x: &JsValue, y: &JsValue, context: &mut Context| -> JsResult { // a. Return ? CompareTypedArrayElements(x, y, comparefn). compare_typed_array_elements(x, y, compare_fn, context) }; @@ -2684,7 +2660,7 @@ impl BuiltinTypedArray { pub(crate) fn subarray( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be the this value. // 2. Perform ? RequireInternalSlot(O, [[TypedArrayName]]). @@ -2772,7 +2748,7 @@ impl BuiltinTypedArray { fn to_locale_string( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let array be ? ToObject(this value). // Note: ValidateTypedArray is applied to the this value prior to evaluating the algorithm. @@ -2856,7 +2832,7 @@ impl BuiltinTypedArray { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-%typedarray%.prototype.values - fn values(this: &JsValue, _: &[JsValue], context: &mut Context<'_>) -> JsResult { + fn values(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Let O be the this value. // 2. Perform ? ValidateTypedArray(O). let o = this.as_object().ok_or_else(|| { @@ -2886,7 +2862,7 @@ impl BuiltinTypedArray { pub(crate) fn with( this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let O be the this value. let obj = this.as_object().ok_or_else(|| { @@ -2980,7 +2956,7 @@ impl BuiltinTypedArray { /// /// [spec]: https://tc39.es/ecma262/#sec-get-%typedarray%.prototype-@@tostringtag #[allow(clippy::unnecessary_wraps)] - fn to_string_tag(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn to_string_tag(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { // 1. Let O be the this value. // 2. If Type(O) is not Object, return undefined. // 3. If O does not have a [[TypedArrayName]] internal slot, return undefined. @@ -3007,7 +2983,7 @@ impl BuiltinTypedArray { exemplar: &JsObject, kind: TypedArrayKind, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let defaultConstructor be the intrinsic object listed in column one of Table 73 for exemplar.[[TypedArrayName]]. let default_constructor = kind.standard_constructor(); @@ -3046,7 +3022,7 @@ impl BuiltinTypedArray { fn create( constructor: &JsObject, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let newTypedArray be ? Construct(constructor, argumentList). let new_typed_array = constructor.construct(args, Some(constructor), context)?; @@ -3081,7 +3057,7 @@ impl BuiltinTypedArray { /// fn allocate_buffer( length: u64, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Assert: O.[[ViewedArrayBuffer]] is undefined. @@ -3117,7 +3093,7 @@ impl BuiltinTypedArray { pub(crate) fn initialize_from_list( proto: JsObject, values: Vec, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let len be the number of elements in values. let len = values.len() as u64; @@ -3157,7 +3133,7 @@ impl BuiltinTypedArray { pub(super) fn allocate( new_target: &JsValue, length: u64, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). let proto = get_prototype_from_constructor(new_target, T::STANDARD_CONSTRUCTOR, context)?; @@ -3195,7 +3171,7 @@ impl BuiltinTypedArray { pub(super) fn initialize_from_typed_array( proto: JsObject, src_array: &JsObject, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let src_array = src_array.borrow(); let src_array = src_array @@ -3355,7 +3331,7 @@ impl BuiltinTypedArray { buffer: JsObject, byte_offset: &JsValue, length: &JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let elementSize be TypedArrayElementSize(O). let element_size = T::ERASED.element_size(); @@ -3457,7 +3433,7 @@ impl BuiltinTypedArray { pub(super) fn initialize_from_array_like( proto: JsObject, array_like: &JsObject, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let len be ? LengthOfArrayLike(arrayLike). let len = array_like.length_of_array_like(context)?; @@ -3501,7 +3477,7 @@ fn compare_typed_array_elements( x: &JsValue, y: &JsValue, compare_fn: Option<&JsObject>, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Assert: x is a Number and y is a Number, or x is a BigInt and y is a BigInt. diff --git a/boa_engine/src/builtins/typed_array/element/mod.rs b/boa_engine/src/builtins/typed_array/element/mod.rs index e439c6af302..3137816f4ba 100644 --- a/boa_engine/src/builtins/typed_array/element/mod.rs +++ b/boa_engine/src/builtins/typed_array/element/mod.rs @@ -194,7 +194,7 @@ pub(crate) trait Element: type Atomic: Atomic; /// Converts a `JsValue` into the native element `Self`. - fn from_js_value(value: &JsValue, context: &mut Context<'_>) -> JsResult; + fn from_js_value(value: &JsValue, context: &mut Context) -> JsResult; /// Converts from the plain type of an atomic to `Self`. fn from_plain(bytes: ::Plain) -> Self; @@ -255,7 +255,7 @@ macro_rules! element { impl Element for $element { type Atomic = $atomic; - fn from_js_value(value: &JsValue, context: &mut Context<'_>) -> JsResult { + fn from_js_value(value: &JsValue, context: &mut Context) -> JsResult { $from_js(value, context) } diff --git a/boa_engine/src/builtins/typed_array/mod.rs b/boa_engine/src/builtins/typed_array/mod.rs index 597a3f74672..110460c7690 100644 --- a/boa_engine/src/builtins/typed_array/mod.rs +++ b/boa_engine/src/builtins/typed_array/mod.rs @@ -108,7 +108,7 @@ impl BuiltInConstructor for T { fn constructor( new_target: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If NewTarget is undefined, throw a TypeError exception. if new_target.is_undefined() { @@ -458,7 +458,7 @@ impl TypedArrayKind { pub(crate) fn get_element( self, value: &JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { match self { TypedArrayKind::Int8 => value.to_int8(context).map(TypedArrayElement::Int8), diff --git a/boa_engine/src/builtins/uri/mod.rs b/boa_engine/src/builtins/uri/mod.rs index dfb26d91d9e..82b711b3f26 100644 --- a/boa_engine/src/builtins/uri/mod.rs +++ b/boa_engine/src/builtins/uri/mod.rs @@ -173,7 +173,7 @@ impl BuiltInObject for EncodeUriComponent { pub(crate) fn decode_uri( _: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let encoded_uri = args.get_or_undefined(0); @@ -201,7 +201,7 @@ pub(crate) fn decode_uri( pub(crate) fn decode_uri_component( _: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let encoded_uri_component = args.get_or_undefined(0); @@ -233,7 +233,7 @@ pub(crate) fn decode_uri_component( pub(crate) fn encode_uri( _: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let uri = args.get_or_undefined(0); @@ -262,7 +262,7 @@ pub(crate) fn encode_uri( pub(crate) fn encode_uri_component( _: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let uri_component = args.get_or_undefined(0); diff --git a/boa_engine/src/builtins/weak/weak_ref.rs b/boa_engine/src/builtins/weak/weak_ref.rs index c6f54f4caba..51543d37ad2 100644 --- a/boa_engine/src/builtins/weak/weak_ref.rs +++ b/boa_engine/src/builtins/weak/weak_ref.rs @@ -63,7 +63,7 @@ impl BuiltInConstructor for WeakRef { fn constructor( new_target: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // If NewTarget is undefined, throw a TypeError exception. if new_target.is_undefined() { @@ -105,11 +105,7 @@ impl WeakRef { /// proper [`JsObject`], or returns `undefined` otherwise. /// /// [spec]: https://tc39.es/ecma262/#sec-weak-ref.prototype.deref - pub(crate) fn deref( - this: &JsValue, - _: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn deref(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult { // 1. Let weakRef be the this value. // 2. Perform ? RequireInternalSlot(weakRef, [[WeakRefTarget]]). let weak_ref = this.as_object().map(JsObject::borrow).ok_or_else(|| { diff --git a/boa_engine/src/builtins/weak_map/mod.rs b/boa_engine/src/builtins/weak_map/mod.rs index 19ec7dc7c22..5824cdbf2f2 100644 --- a/boa_engine/src/builtins/weak_map/mod.rs +++ b/boa_engine/src/builtins/weak_map/mod.rs @@ -72,7 +72,7 @@ impl BuiltInConstructor for WeakMap { fn constructor( new_target: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If NewTarget is undefined, throw a TypeError exception. if new_target.is_undefined() { @@ -124,7 +124,7 @@ impl WeakMap { pub(crate) fn delete( this: &JsValue, args: &[JsValue], - _context: &mut Context<'_>, + _context: &mut Context, ) -> JsResult { // 1. Let M be the this value. // 2. Perform ? RequireInternalSlot(M, [[WeakMapData]]). @@ -164,7 +164,7 @@ impl WeakMap { pub(crate) fn get( this: &JsValue, args: &[JsValue], - _context: &mut Context<'_>, + _context: &mut Context, ) -> JsResult { // 1. Let M be the this value. // 2. Perform ? RequireInternalSlot(M, [[WeakMapData]]). @@ -201,7 +201,7 @@ impl WeakMap { pub(crate) fn has( this: &JsValue, args: &[JsValue], - _context: &mut Context<'_>, + _context: &mut Context, ) -> JsResult { // 1. Let M be the this value. // 2. Perform ? RequireInternalSlot(M, [[WeakMapData]]). @@ -238,7 +238,7 @@ impl WeakMap { pub(crate) fn set( this: &JsValue, args: &[JsValue], - _context: &mut Context<'_>, + _context: &mut Context, ) -> JsResult { // 1. Let M be the this value. // 2. Perform ? RequireInternalSlot(M, [[WeakMapData]]). diff --git a/boa_engine/src/builtins/weak_set/mod.rs b/boa_engine/src/builtins/weak_set/mod.rs index 65a74221cd6..de99c2195f5 100644 --- a/boa_engine/src/builtins/weak_set/mod.rs +++ b/boa_engine/src/builtins/weak_set/mod.rs @@ -68,7 +68,7 @@ impl BuiltInConstructor for WeakSet { fn constructor( new_target: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If NewTarget is undefined, throw a TypeError exception. if new_target.is_undefined() { @@ -136,7 +136,7 @@ impl WeakSet { pub(crate) fn add( this: &JsValue, args: &[JsValue], - _context: &mut Context<'_>, + _context: &mut Context, ) -> JsResult { // 1. Let S be the this value. // 2. Perform ? RequireInternalSlot(S, [[WeakSetData]]). @@ -188,7 +188,7 @@ impl WeakSet { pub(crate) fn delete( this: &JsValue, args: &[JsValue], - _context: &mut Context<'_>, + _context: &mut Context, ) -> JsResult { // 1. Let S be the this value. // 2. Perform ? RequireInternalSlot(S, [[WeakSetData]]). @@ -230,7 +230,7 @@ impl WeakSet { pub(crate) fn has( this: &JsValue, args: &[JsValue], - _context: &mut Context<'_>, + _context: &mut Context, ) -> JsResult { // 1. Let S be the this value. // 2. Perform ? RequireInternalSlot(S, [[WeakSetData]]). diff --git a/boa_engine/src/bytecompiler/class.rs b/boa_engine/src/bytecompiler/class.rs index cd5a35c2bd5..10e5d1f4292 100644 --- a/boa_engine/src/bytecompiler/class.rs +++ b/boa_engine/src/bytecompiler/class.rs @@ -17,7 +17,7 @@ enum StaticElement { StaticField((Gc, Option)), } -impl ByteCompiler<'_, '_> { +impl ByteCompiler<'_> { /// This function compiles a class declaration or expression. /// /// The compilation of a class declaration and expression is mostly equal. diff --git a/boa_engine/src/bytecompiler/declaration/declaration_pattern.rs b/boa_engine/src/bytecompiler/declaration/declaration_pattern.rs index 946be8bae37..5200f3982d3 100644 --- a/boa_engine/src/bytecompiler/declaration/declaration_pattern.rs +++ b/boa_engine/src/bytecompiler/declaration/declaration_pattern.rs @@ -7,7 +7,7 @@ use boa_ast::{ property::PropertyName, }; -impl ByteCompiler<'_, '_> { +impl ByteCompiler<'_> { pub(crate) fn compile_declaration_pattern_impl( &mut self, pattern: &Pattern, diff --git a/boa_engine/src/bytecompiler/declarations.rs b/boa_engine/src/bytecompiler/declarations.rs index 66a10a971a2..5edbc9888b3 100644 --- a/boa_engine/src/bytecompiler/declarations.rs +++ b/boa_engine/src/bytecompiler/declarations.rs @@ -25,7 +25,7 @@ use boa_ast::operations::annex_b_function_declarations_names; use super::Operand; -impl ByteCompiler<'_, '_> { +impl ByteCompiler<'_> { /// `GlobalDeclarationInstantiation ( script, env )` /// /// More information: diff --git a/boa_engine/src/bytecompiler/env.rs b/boa_engine/src/bytecompiler/env.rs index a31be573be2..8a61adee209 100644 --- a/boa_engine/src/bytecompiler/env.rs +++ b/boa_engine/src/bytecompiler/env.rs @@ -2,7 +2,7 @@ use super::ByteCompiler; use crate::environments::CompileTimeEnvironment; use std::rc::Rc; -impl ByteCompiler<'_, '_> { +impl ByteCompiler<'_> { /// Push either a new declarative or function environment on the compile time environment stack. #[must_use] pub(crate) fn push_compile_environment(&mut self, function_scope: bool) -> u32 { diff --git a/boa_engine/src/bytecompiler/expression/assign.rs b/boa_engine/src/bytecompiler/expression/assign.rs index 0bf4c403749..6b45d824bfe 100644 --- a/boa_engine/src/bytecompiler/expression/assign.rs +++ b/boa_engine/src/bytecompiler/expression/assign.rs @@ -8,7 +8,7 @@ use boa_ast::expression::{ operator::{assign::AssignOp, Assign}, }; -impl ByteCompiler<'_, '_> { +impl ByteCompiler<'_> { pub(crate) fn compile_assign(&mut self, assign: &Assign, use_expr: bool) { if assign.op() == AssignOp::Assign { match Access::from_assign_target(assign.lhs()) { diff --git a/boa_engine/src/bytecompiler/expression/binary.rs b/boa_engine/src/bytecompiler/expression/binary.rs index 97ec9daf6ef..04388e7c6dc 100644 --- a/boa_engine/src/bytecompiler/expression/binary.rs +++ b/boa_engine/src/bytecompiler/expression/binary.rs @@ -5,7 +5,7 @@ use boa_ast::expression::operator::{ use crate::{bytecompiler::ByteCompiler, vm::Opcode}; -impl ByteCompiler<'_, '_> { +impl ByteCompiler<'_> { pub(crate) fn compile_binary(&mut self, binary: &Binary, use_expr: bool) { self.compile_expr(binary.lhs(), true); match binary.op() { diff --git a/boa_engine/src/bytecompiler/expression/mod.rs b/boa_engine/src/bytecompiler/expression/mod.rs index 51c5c3b1f8c..dff1fe07af0 100644 --- a/boa_engine/src/bytecompiler/expression/mod.rs +++ b/boa_engine/src/bytecompiler/expression/mod.rs @@ -19,7 +19,7 @@ use boa_ast::{ Expression, }; -impl ByteCompiler<'_, '_> { +impl ByteCompiler<'_> { fn compile_literal(&mut self, lit: &AstLiteral, use_expr: bool) { match lit { AstLiteral::String(v) => self.emit_push_literal(Literal::String( diff --git a/boa_engine/src/bytecompiler/expression/object_literal.rs b/boa_engine/src/bytecompiler/expression/object_literal.rs index 10dea9d1665..3fcabb0a3e8 100644 --- a/boa_engine/src/bytecompiler/expression/object_literal.rs +++ b/boa_engine/src/bytecompiler/expression/object_literal.rs @@ -9,7 +9,7 @@ use boa_ast::{ }; use boa_interner::Sym; -impl ByteCompiler<'_, '_> { +impl ByteCompiler<'_> { pub(crate) fn compile_object_literal(&mut self, object: &ObjectLiteral, use_expr: bool) { self.emit_opcode(Opcode::PushEmptyObject); for property in object.properties() { diff --git a/boa_engine/src/bytecompiler/expression/unary.rs b/boa_engine/src/bytecompiler/expression/unary.rs index 55715fea5ee..f853496f94b 100644 --- a/boa_engine/src/bytecompiler/expression/unary.rs +++ b/boa_engine/src/bytecompiler/expression/unary.rs @@ -8,7 +8,7 @@ use crate::{ vm::Opcode, }; -impl ByteCompiler<'_, '_> { +impl ByteCompiler<'_> { pub(crate) fn compile_unary(&mut self, unary: &Unary, use_expr: bool) { let opcode = match unary.op() { UnaryOp::Delete => { diff --git a/boa_engine/src/bytecompiler/expression/update.rs b/boa_engine/src/bytecompiler/expression/update.rs index 6a6e69acff1..d71f2ddaaa3 100644 --- a/boa_engine/src/bytecompiler/expression/update.rs +++ b/boa_engine/src/bytecompiler/expression/update.rs @@ -8,7 +8,7 @@ use boa_ast::expression::{ operator::{update::UpdateOp, Update}, }; -impl ByteCompiler<'_, '_> { +impl ByteCompiler<'_> { pub(crate) fn compile_update(&mut self, update: &Update, use_expr: bool) { let opcode = match update.op() { UpdateOp::IncrementPre => Opcode::Inc, diff --git a/boa_engine/src/bytecompiler/function.rs b/boa_engine/src/bytecompiler/function.rs index 27c101da97e..f3bbcf8bbe2 100644 --- a/boa_engine/src/bytecompiler/function.rs +++ b/boa_engine/src/bytecompiler/function.rs @@ -91,7 +91,7 @@ impl FunctionCompiler { body: &FunctionBody, variable_environment: Rc, lexical_environment: Rc, - context: &mut Context<'_>, + context: &mut Context, ) -> Gc { self.strict = self.strict || body.strict(); diff --git a/boa_engine/src/bytecompiler/jump_control.rs b/boa_engine/src/bytecompiler/jump_control.rs index 7ba5dec8a69..50a9bb09eba 100644 --- a/boa_engine/src/bytecompiler/jump_control.rs +++ b/boa_engine/src/bytecompiler/jump_control.rs @@ -87,11 +87,7 @@ impl JumpRecord { } /// Performs the [`JumpRecordAction`]s. - pub(crate) fn perform_actions( - mut self, - start_address: u32, - compiler: &mut ByteCompiler<'_, '_>, - ) { + pub(crate) fn perform_actions(mut self, start_address: u32, compiler: &mut ByteCompiler<'_>) { while let Some(action) = self.actions.pop() { match action { JumpRecordAction::Transfer { index } => { @@ -310,7 +306,7 @@ impl JumpControlInfo { } // `JumpControlInfo` related methods that are implemented on `ByteCompiler`. -impl ByteCompiler<'_, '_> { +impl ByteCompiler<'_> { /// Pushes a generic `JumpControlInfo` onto `ByteCompiler` /// /// Default `JumpControlInfoKind` is `JumpControlInfoKind::Loop` diff --git a/boa_engine/src/bytecompiler/mod.rs b/boa_engine/src/bytecompiler/mod.rs index 86333d97213..9851852f4e8 100644 --- a/boa_engine/src/bytecompiler/mod.rs +++ b/boa_engine/src/bytecompiler/mod.rs @@ -232,7 +232,7 @@ pub(crate) enum Operand { /// The [`ByteCompiler`] is used to compile ECMAScript AST from [`boa_ast`] to bytecode. #[derive(Debug)] #[allow(clippy::struct_excessive_bools)] -pub struct ByteCompiler<'ctx, 'host> { +pub struct ByteCompiler<'ctx> { /// Name of this function. pub(crate) function_name: Sym, @@ -275,13 +275,13 @@ pub struct ByteCompiler<'ctx, 'host> { json_parse: bool, // TODO: remove when we separate scripts from the context - pub(crate) context: &'ctx mut Context<'host>, + pub(crate) context: &'ctx mut Context, #[cfg(feature = "annex-b")] annex_b_function_names: Vec, } -impl<'ctx, 'host> ByteCompiler<'ctx, 'host> { +impl<'ctx> ByteCompiler<'ctx> { /// Represents a placeholder address that will be patched later. const DUMMY_ADDRESS: u32 = u32::MAX; const DUMMY_LABEL: Label = Label { index: u32::MAX }; @@ -295,8 +295,8 @@ impl<'ctx, 'host> ByteCompiler<'ctx, 'host> { variable_environment: Rc, lexical_environment: Rc, // TODO: remove when we separate scripts from the context - context: &'ctx mut Context<'host>, - ) -> ByteCompiler<'ctx, 'host> { + context: &'ctx mut Context, + ) -> ByteCompiler<'ctx> { let mut code_block_flags = CodeBlockFlags::empty(); code_block_flags.set(CodeBlockFlags::STRICT, strict); code_block_flags |= CodeBlockFlags::HAS_PROTOTYPE_PROPERTY; @@ -734,7 +734,7 @@ impl<'ctx, 'host> ByteCompiler<'ctx, 'host> { } } - fn access_set_top_of_stack_expr_fn(compiler: &mut ByteCompiler<'_, '_>, level: u8) { + fn access_set_top_of_stack_expr_fn(compiler: &mut ByteCompiler<'_>, level: u8) { match level { 0 => {} 1 => compiler.emit_opcode(Opcode::Swap), @@ -746,7 +746,7 @@ impl<'ctx, 'host> ByteCompiler<'ctx, 'host> { fn access_set(&mut self, access: Access<'_>, use_expr: bool, expr_fn: F) where - F: FnOnce(&mut ByteCompiler<'_, '_>, u8) -> R, + F: FnOnce(&mut ByteCompiler<'_>, u8) -> R, { match access { Access::Variable { name } => { diff --git a/boa_engine/src/bytecompiler/module.rs b/boa_engine/src/bytecompiler/module.rs index c417c6b1a7b..434bd2d7ce0 100644 --- a/boa_engine/src/bytecompiler/module.rs +++ b/boa_engine/src/bytecompiler/module.rs @@ -4,7 +4,7 @@ use super::{ByteCompiler, Literal, Operand}; use boa_ast::{declaration::ExportDeclaration, expression::Identifier, ModuleItem, ModuleItemList}; use boa_interner::Sym; -impl ByteCompiler<'_, '_> { +impl ByteCompiler<'_> { /// Compiles a [`ModuleItemList`]. #[inline] pub fn compile_module_item_list(&mut self, list: &ModuleItemList) { diff --git a/boa_engine/src/bytecompiler/statement/block.rs b/boa_engine/src/bytecompiler/statement/block.rs index e96096edbdf..655f3ce6421 100644 --- a/boa_engine/src/bytecompiler/statement/block.rs +++ b/boa_engine/src/bytecompiler/statement/block.rs @@ -1,7 +1,7 @@ use crate::{bytecompiler::ByteCompiler, vm::Opcode}; use boa_ast::statement::Block; -impl ByteCompiler<'_, '_> { +impl ByteCompiler<'_> { /// Compile a [`Block`] `boa_ast` node pub(crate) fn compile_block(&mut self, block: &Block, use_expr: bool) { let old_lex_env = self.lexical_environment.clone(); diff --git a/boa_engine/src/bytecompiler/statement/break.rs b/boa_engine/src/bytecompiler/statement/break.rs index 1d70df12927..c1c80c67e89 100644 --- a/boa_engine/src/bytecompiler/statement/break.rs +++ b/boa_engine/src/bytecompiler/statement/break.rs @@ -4,7 +4,7 @@ use crate::bytecompiler::{ }; use boa_ast::statement::Break; -impl ByteCompiler<'_, '_> { +impl ByteCompiler<'_> { /// Compile a [`Break`] `boa_ast` node pub(crate) fn compile_break(&mut self, node: Break, _use_expr: bool) { let actions = self.break_jump_record_actions(node); diff --git a/boa_engine/src/bytecompiler/statement/continue.rs b/boa_engine/src/bytecompiler/statement/continue.rs index def3058ea52..d05611da266 100644 --- a/boa_engine/src/bytecompiler/statement/continue.rs +++ b/boa_engine/src/bytecompiler/statement/continue.rs @@ -4,7 +4,7 @@ use crate::bytecompiler::{ }; use boa_ast::statement::Continue; -impl ByteCompiler<'_, '_> { +impl ByteCompiler<'_> { #[allow(clippy::unnecessary_wraps)] pub(crate) fn compile_continue(&mut self, node: Continue, _use_expr: bool) { let actions = self.continue_jump_record_actions(node); diff --git a/boa_engine/src/bytecompiler/statement/if.rs b/boa_engine/src/bytecompiler/statement/if.rs index d6b0c8e947c..095cf5fa6b2 100644 --- a/boa_engine/src/bytecompiler/statement/if.rs +++ b/boa_engine/src/bytecompiler/statement/if.rs @@ -1,7 +1,7 @@ use crate::bytecompiler::ByteCompiler; use boa_ast::statement::If; -impl ByteCompiler<'_, '_> { +impl ByteCompiler<'_> { pub(crate) fn compile_if(&mut self, node: &If, use_expr: bool) { self.compile_expr(node.cond(), true); let jelse = self.jump_if_false(); diff --git a/boa_engine/src/bytecompiler/statement/labelled.rs b/boa_engine/src/bytecompiler/statement/labelled.rs index 860a13b4ac0..a723edab9ec 100644 --- a/boa_engine/src/bytecompiler/statement/labelled.rs +++ b/boa_engine/src/bytecompiler/statement/labelled.rs @@ -4,7 +4,7 @@ use boa_ast::{ Statement, }; -impl ByteCompiler<'_, '_> { +impl ByteCompiler<'_> { /// Compile a [`Labelled`] `boa_ast` node pub(crate) fn compile_labelled(&mut self, labelled: &Labelled, use_expr: bool) { let labelled_loc = self.next_opcode_location(); diff --git a/boa_engine/src/bytecompiler/statement/loop.rs b/boa_engine/src/bytecompiler/statement/loop.rs index ada2c3c3f42..fa47416a5ec 100644 --- a/boa_engine/src/bytecompiler/statement/loop.rs +++ b/boa_engine/src/bytecompiler/statement/loop.rs @@ -14,7 +14,7 @@ use crate::{ vm::{BindingOpcode, Opcode}, }; -impl ByteCompiler<'_, '_> { +impl ByteCompiler<'_> { pub(crate) fn compile_for_loop( &mut self, for_loop: &ForLoop, diff --git a/boa_engine/src/bytecompiler/statement/mod.rs b/boa_engine/src/bytecompiler/statement/mod.rs index 91c332ea6a7..1abce62e11d 100644 --- a/boa_engine/src/bytecompiler/statement/mod.rs +++ b/boa_engine/src/bytecompiler/statement/mod.rs @@ -14,7 +14,7 @@ mod switch; mod r#try; mod with; -impl ByteCompiler<'_, '_> { +impl ByteCompiler<'_> { /// Compiles a [`Statement`] `boa_ast` node. pub fn compile_stmt(&mut self, node: &Statement, use_expr: bool, root_statement: bool) { match node { diff --git a/boa_engine/src/bytecompiler/statement/switch.rs b/boa_engine/src/bytecompiler/statement/switch.rs index 2540e26ca2e..366f6e276f7 100644 --- a/boa_engine/src/bytecompiler/statement/switch.rs +++ b/boa_engine/src/bytecompiler/statement/switch.rs @@ -1,7 +1,7 @@ use crate::{bytecompiler::ByteCompiler, vm::Opcode}; use boa_ast::statement::Switch; -impl ByteCompiler<'_, '_> { +impl ByteCompiler<'_> { /// Compile a [`Switch`] `boa_ast` node pub(crate) fn compile_switch(&mut self, switch: &Switch, use_expr: bool) { self.compile_expr(switch.val(), true); diff --git a/boa_engine/src/bytecompiler/statement/try.rs b/boa_engine/src/bytecompiler/statement/try.rs index 9a70cbb848d..bf86c55b39c 100644 --- a/boa_engine/src/bytecompiler/statement/try.rs +++ b/boa_engine/src/bytecompiler/statement/try.rs @@ -9,7 +9,7 @@ use boa_ast::{ Statement, StatementListItem, }; -impl ByteCompiler<'_, '_> { +impl ByteCompiler<'_> { /// Compile try statement. pub(crate) fn compile_try(&mut self, t: &Try, use_expr: bool) { let has_catch = t.catch().is_some(); diff --git a/boa_engine/src/bytecompiler/statement/with.rs b/boa_engine/src/bytecompiler/statement/with.rs index a2a55f89ad3..ec90b75b17d 100644 --- a/boa_engine/src/bytecompiler/statement/with.rs +++ b/boa_engine/src/bytecompiler/statement/with.rs @@ -1,7 +1,7 @@ use crate::{bytecompiler::ByteCompiler, vm::Opcode}; use boa_ast::statement::With; -impl ByteCompiler<'_, '_> { +impl ByteCompiler<'_> { /// Compile a [`With`] `boa_ast` node pub(crate) fn compile_with(&mut self, with: &With, use_expr: bool) { self.compile_expr(with.expression(), true); diff --git a/boa_engine/src/bytecompiler/utils.rs b/boa_engine/src/bytecompiler/utils.rs index 8319fb31a42..9f4b36004ca 100644 --- a/boa_engine/src/bytecompiler/utils.rs +++ b/boa_engine/src/bytecompiler/utils.rs @@ -5,7 +5,7 @@ use crate::{ use super::{ByteCompiler, Literal, Operand}; -impl ByteCompiler<'_, '_> { +impl ByteCompiler<'_> { /// Closes an iterator /// /// This is equivalent to the [`IteratorClose`][iter] and [`AsyncIteratorClose`][async] diff --git a/boa_engine/src/class.rs b/boa_engine/src/class.rs index e44e8e934ea..2472507b362 100644 --- a/boa_engine/src/class.rs +++ b/boa_engine/src/class.rs @@ -28,7 +28,7 @@ //! const LENGTH: usize = 1; //! //! // This is what is called when we do `new Animal()` to construct the inner data of the class. -//! fn make_data(_this: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult { +//! fn make_data(_this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { //! // This is equivalent to `String(arg)`. //! let kind = args.get_or_undefined(0).to_string(context)?; //! @@ -91,10 +91,10 @@ pub trait Class: NativeObject + Sized { /// Creates the internal data for an instance of this class. /// /// This method can also be called the "native constructor" of this class. - fn make_data(this: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult; + fn make_data(this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult; /// Initializes the properties and methods of this class. - fn init(class: &mut ClassBuilder<'_, '_>) -> JsResult<()>; + fn init(class: &mut ClassBuilder<'_>) -> JsResult<()>; /// Creates a new [`JsObject`] with its internal data set to the result of calling `Self::make_data`. /// @@ -110,7 +110,7 @@ pub trait Class: NativeObject + Sized { fn construct( new_target: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { if new_target.is_undefined() { return Err(JsNativeError::typ() @@ -150,12 +150,12 @@ pub trait Class: NativeObject + Sized { /// Class builder which allows adding methods and static methods to the class. #[derive(Debug)] -pub struct ClassBuilder<'ctx, 'host> { - builder: ConstructorBuilder<'ctx, 'host>, +pub struct ClassBuilder<'ctx> { + builder: ConstructorBuilder<'ctx>, } -impl<'ctx, 'host> ClassBuilder<'ctx, 'host> { - pub(crate) fn new(context: &'ctx mut Context<'host>) -> Self +impl<'ctx> ClassBuilder<'ctx> { + pub(crate) fn new(context: &'ctx mut Context) -> Self where T: Class, { @@ -283,7 +283,7 @@ impl<'ctx, 'host> ClassBuilder<'ctx, 'host> { /// Return the current context. #[inline] - pub fn context(&mut self) -> &mut Context<'host> { + pub fn context(&mut self) -> &mut Context { self.builder.context() } } diff --git a/boa_engine/src/context/hooks.rs b/boa_engine/src/context/hooks.rs index 2bbaa042627..8af17cabe09 100644 --- a/boa_engine/src/context/hooks.rs +++ b/boa_engine/src/context/hooks.rs @@ -32,15 +32,15 @@ use super::intrinsics::Intrinsics; /// fn ensure_can_compile_strings( /// &self, /// _realm: Realm, -/// context: &mut Context<'_>, +/// context: &mut Context, /// ) -> JsResult<()> { /// Err(JsNativeError::typ() /// .with_message("eval calls not available") /// .into()) /// } /// } -/// let hooks: &dyn HostHooks = &Hooks; // Can have additional state. -/// let context = &mut ContextBuilder::new().host_hooks(hooks).build().unwrap(); +/// +/// let context = &mut ContextBuilder::new().host_hooks(&Hooks).build().unwrap(); /// let result = context.eval(Source::from_bytes(r#"eval("let a = 5")"#)); /// assert_eq!( /// result.unwrap_err().to_string(), @@ -57,7 +57,7 @@ pub trait HostHooks { /// - It must return a `JobCallback` Record whose `[[Callback]]` field is `callback`. /// /// [spec]: https://tc39.es/ecma262/#sec-hostmakejobcallback - fn make_job_callback(&self, callback: JsFunction, _context: &mut Context<'_>) -> JobCallback { + fn make_job_callback(&self, callback: JsFunction, _context: &mut Context) -> JobCallback { // The default implementation of HostMakeJobCallback performs the following steps when called: // 1. Return the JobCallback Record { [[Callback]]: callback, [[HostDefined]]: empty }. @@ -76,7 +76,7 @@ pub trait HostHooks { job: JobCallback, this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // The default implementation of HostCallJobCallback performs the following steps when called: @@ -98,7 +98,7 @@ pub trait HostHooks { &self, _promise: &JsObject, _operation: OperationType, - _context: &mut Context<'_>, + _context: &mut Context, ) { // The default implementation of HostPromiseRejectionTracker is to return unused. } @@ -112,11 +112,7 @@ pub trait HostHooks { /// /// [spec]: https://tc39.es/ecma262/#sec-hostensurecancompilestrings // TODO: Track https://github.com/tc39/ecma262/issues/938 - fn ensure_can_compile_strings( - &self, - _realm: Realm, - _context: &mut Context<'_>, - ) -> JsResult<()> { + fn ensure_can_compile_strings(&self, _realm: Realm, _context: &mut Context) -> JsResult<()> { // The default implementation of HostEnsureCanCompileStrings is to return NormalCompletion(unused). Ok(()) } @@ -129,11 +125,7 @@ pub trait HostHooks { /// specific `func` as its argument, it must return the same result. /// /// [spec]: https://tc39.es/ecma262/#sec-hosthassourcetextavailable - fn has_source_text_available( - &self, - _function: &JsFunction, - _context: &mut Context<'_>, - ) -> bool { + fn has_source_text_available(&self, _function: &JsFunction, _context: &mut Context) -> bool { // The default implementation of HostHasSourceTextAvailable is to return true. true } @@ -152,7 +144,7 @@ pub trait HostHooks { fn ensure_can_add_private_element( &self, _o: &JsObject, - _context: &mut Context<'_>, + _context: &mut Context, ) -> JsResult<()> { Ok(()) } @@ -234,7 +226,7 @@ pub trait HostHooks { /// /// /// [specification]: https://tc39.es/ecma262/multipage/structured-data.html#sec-resizable-arraybuffer-guidelines - fn max_buffer_size(&self) -> u64 { + fn max_buffer_size(&self, _context: &mut Context) -> u64 { 1_610_612_736 // 1.5 GiB } } diff --git a/boa_engine/src/context/icu.rs b/boa_engine/src/context/icu.rs index 6abd1833438..f2307e7c5a4 100644 --- a/boa_engine/src/context/icu.rs +++ b/boa_engine/src/context/icu.rs @@ -19,15 +19,14 @@ use crate::builtins::string::StringNormalizers; /// Providers can be either [`BufferProvider`]s or [`AnyProvider`]s. /// /// The [`icu_provider`] documentation has more information about data providers. -#[derive(Clone, Copy)] -pub enum BoaProvider<'a> { +pub enum BoaProvider { /// A [`BufferProvider`] data provider. - Buffer(&'a dyn BufferProvider), + Buffer(Box), /// An [`AnyProvider`] data provider. - Any(&'a dyn AnyProvider), + Any(Box), } -impl Debug for BoaProvider<'_> { +impl Debug for BoaProvider { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { Self::Buffer(_) => f.debug_tuple("Buffer").field(&"..").finish(), @@ -38,7 +37,7 @@ impl Debug for BoaProvider<'_> { // This blanket implementation mirrors the `DataProvider` implementations of `BufferProvider` and // `AnyProvider`, which allows us to use `unstable` constructors in a stable way. -impl DataProvider for BoaProvider<'_> +impl DataProvider for BoaProvider where M: KeyedDataMarker + 'static, for<'de> YokeTraitHack<>::Output>: Deserialize<'de>, @@ -69,15 +68,15 @@ pub enum IcuError { /// Collection of tools initialized from a [`DataProvider`] that are used for the functionality of /// `Intl`. -pub(crate) struct Icu<'provider> { - provider: BoaProvider<'provider>, +pub(crate) struct Icu { + provider: BoaProvider, locale_canonicalizer: LocaleCanonicalizer, locale_expander: LocaleExpander, string_normalizers: StringNormalizers, case_mapper: CaseMapper, } -impl Debug for Icu<'_> { +impl Debug for Icu { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_struct("Icu") .field("provider", &self.provider) @@ -89,13 +88,13 @@ impl Debug for Icu<'_> { } } -impl<'provider> Icu<'provider> { +impl Icu { /// Creates a new [`Icu`] from a valid [`BoaProvider`] /// /// # Errors /// /// Returns an error if any of the tools required cannot be constructed. - pub(crate) fn new(provider: BoaProvider<'provider>) -> Result, IcuError> { + pub(crate) fn new(provider: BoaProvider) -> Result { Ok(Self { locale_canonicalizer: LocaleCanonicalizer::try_new_unstable(&provider)?, locale_expander: LocaleExpander::try_new_extended_unstable(&provider)?, @@ -131,7 +130,32 @@ impl<'provider> Icu<'provider> { } /// Gets the inner icu data provider - pub(crate) const fn provider(&self) -> BoaProvider<'provider> { - self.provider + pub(crate) const fn provider(&self) -> &BoaProvider { + &self.provider + } +} + +/// Adapter to allow creating a `Box` from +/// a &'static impl Provider. +#[derive(Debug)] +pub(crate) struct StaticProviderAdapter(pub(crate) &'static T); + +impl BufferProvider for StaticProviderAdapter { + fn load_buffer( + &self, + key: icu_provider::DataKey, + req: DataRequest<'_>, + ) -> Result, DataError> { + self.0.load_buffer(key, req) + } +} + +impl AnyProvider for StaticProviderAdapter { + fn load_any( + &self, + key: icu_provider::DataKey, + req: DataRequest<'_>, + ) -> Result { + self.0.load_any(key, req) } } diff --git a/boa_engine/src/context/maybe_shared.rs b/boa_engine/src/context/maybe_shared.rs deleted file mode 100644 index 171885c55fd..00000000000 --- a/boa_engine/src/context/maybe_shared.rs +++ /dev/null @@ -1,42 +0,0 @@ -use std::{ops::Deref, rc::Rc}; - -/// A [`Cow`][std::borrow::Cow]-like pointer where the `Owned` variant is an [`Rc`]. -#[derive(Debug, PartialEq, Eq, PartialOrd, Ord)] -pub enum MaybeShared<'a, T: ?Sized> { - /// Borrowed data. - Borrowed(&'a T), - /// `Rc` shared data. - Shared(Rc), -} - -impl Clone for MaybeShared<'_, T> { - fn clone(&self) -> Self { - match self { - Self::Borrowed(b) => Self::Borrowed(b), - Self::Shared(sh) => Self::Shared(sh.clone()), - } - } -} - -impl Deref for MaybeShared<'_, T> { - type Target = T; - - fn deref(&self) -> &Self::Target { - match self { - MaybeShared::Borrowed(b) => b, - MaybeShared::Shared(sh) => sh, - } - } -} - -impl<'a, T: ?Sized> From<&'a T> for MaybeShared<'a, T> { - fn from(value: &'a T) -> Self { - Self::Borrowed(value) - } -} - -impl From> for MaybeShared<'static, T> { - fn from(value: Rc) -> Self { - Self::Shared(value) - } -} diff --git a/boa_engine/src/context/mod.rs b/boa_engine/src/context/mod.rs index 3aa8617fce2..c27418c4cf4 100644 --- a/boa_engine/src/context/mod.rs +++ b/boa_engine/src/context/mod.rs @@ -4,13 +4,11 @@ mod hooks; #[cfg(feature = "intl")] pub(crate) mod icu; pub mod intrinsics; -mod maybe_shared; pub use hooks::{DefaultHooks, HostHooks}; #[cfg(feature = "intl")] pub use icu::{BoaProvider, IcuError}; use intrinsics::Intrinsics; -pub use maybe_shared::MaybeShared; #[cfg(not(feature = "intl"))] pub use std::marker::PhantomData; @@ -87,7 +85,7 @@ thread_local! { /// /// assert_eq!(value.as_number(), Some(12.0)) /// ``` -pub struct Context<'host> { +pub struct Context { /// String interner in the context. interner: Interner, @@ -106,13 +104,13 @@ pub struct Context<'host> { /// ICU related utilities #[cfg(feature = "intl")] - icu: icu::Icu<'host>, + icu: icu::Icu, - host_hooks: MaybeShared<'host, dyn HostHooks>, + host_hooks: &'static dyn HostHooks, - job_queue: MaybeShared<'host, dyn JobQueue>, + job_queue: Rc, - module_loader: MaybeShared<'host, dyn ModuleLoader>, + module_loader: Rc, optimizer_options: OptimizerOptions, root_shape: RootShape, @@ -121,7 +119,7 @@ pub struct Context<'host> { parser_identifier: u32, } -impl std::fmt::Debug for Context<'_> { +impl std::fmt::Debug for Context { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let mut debug = f.debug_struct("Context"); @@ -142,7 +140,7 @@ impl std::fmt::Debug for Context<'_> { } } -impl Drop for Context<'_> { +impl Drop for Context { fn drop(&mut self) { if !self.can_block { CANNOT_BLOCK_COUNTER.set(CANNOT_BLOCK_COUNTER.get() - 1); @@ -150,7 +148,7 @@ impl Drop for Context<'_> { } } -impl Default for Context<'_> { +impl Default for Context { fn default() -> Self { ContextBuilder::default() .build() @@ -159,11 +157,11 @@ impl Default for Context<'_> { } // ==== Public API ==== -impl<'host> Context<'host> { +impl Context { /// Create a new [`ContextBuilder`] to specify the [`Interner`] and/or /// the icu data provider. #[must_use] - pub fn builder() -> ContextBuilder<'static, 'static, 'static, 'static> { + pub fn builder() -> ContextBuilder { ContextBuilder::default() } @@ -490,8 +488,8 @@ impl<'host> Context<'host> { /// # Note /// /// Concurrent job execution cannot be guaranteed by the engine, since this depends on the - /// specific handling of each [`JobQueue`]. If you need to ensure that jobs are executed - /// concurrently, you can provide a custom implementor of `JobQueue` to the context. + /// specific handling of each [`JobQueue`]. If you want to execute jobs concurrently, you must + /// provide a custom implementor of `JobQueue` to the context. #[allow(clippy::future_not_send)] pub async fn run_jobs_async(&mut self) { self.job_queue().run_jobs_async(self).await; @@ -528,7 +526,7 @@ impl<'host> Context<'host> { /// Create a new Realm with the default global bindings. pub fn create_realm(&mut self) -> JsResult { - let realm = Realm::create(&*self.host_hooks, &self.root_shape); + let realm = Realm::create(self.host_hooks, &self.root_shape); let old_realm = self.enter_realm(realm); @@ -547,20 +545,20 @@ impl<'host> Context<'host> { /// Gets the host hooks. #[inline] #[must_use] - pub fn host_hooks(&self) -> MaybeShared<'host, dyn HostHooks> { - self.host_hooks.clone() + pub fn host_hooks(&self) -> &'static dyn HostHooks { + self.host_hooks } /// Gets the job queue. #[inline] #[must_use] - pub fn job_queue(&self) -> MaybeShared<'host, dyn JobQueue> { + pub fn job_queue(&self) -> Rc { self.job_queue.clone() } /// Gets the module loader. #[must_use] - pub fn module_loader(&self) -> MaybeShared<'host, dyn ModuleLoader> { + pub fn module_loader(&self) -> Rc { self.module_loader.clone() } @@ -593,7 +591,7 @@ impl<'host> Context<'host> { // ==== Private API ==== -impl Context<'_> { +impl Context { /// Swaps the currently active realm with `realm`. pub(crate) fn swap_realm(&mut self, realm: &mut Realm) { std::mem::swap(&mut self.vm.realm, realm); @@ -831,18 +829,18 @@ impl Context<'_> { } } -impl<'host> Context<'host> { +impl Context { /// Creates a `ContextCleanupGuard` that executes some cleanup after being dropped. - pub(crate) fn guard(&mut self, cleanup: F) -> ContextCleanupGuard<'_, 'host, F> + pub(crate) fn guard(&mut self, cleanup: F) -> ContextCleanupGuard<'_, F> where - F: FnOnce(&mut Context<'_>) + 'static, + F: FnOnce(&mut Context) + 'static, { ContextCleanupGuard::new(self, cleanup) } /// Get the ICU related utilities #[cfg(feature = "intl")] - pub(crate) const fn icu(&self) -> &icu::Icu<'host> { + pub(crate) const fn icu(&self) -> &icu::Icu { &self.icu } } @@ -859,21 +857,19 @@ impl<'host> Context<'host> { doc = "The required data in a valid provider is specified in [`BoaProvider`]" )] #[derive(Default)] -pub struct ContextBuilder<'icu, 'hooks, 'queue, 'module> { +pub struct ContextBuilder { interner: Option, - host_hooks: Option>, - job_queue: Option>, - module_loader: Option>, + host_hooks: Option<&'static dyn HostHooks>, + job_queue: Option>, + module_loader: Option>, can_block: bool, #[cfg(feature = "intl")] - icu: Option>, - #[cfg(not(feature = "intl"))] - icu: PhantomData<&'icu ()>, + icu: Option, #[cfg(feature = "fuzz")] instructions_remaining: usize, } -impl std::fmt::Debug for ContextBuilder<'_, '_, '_, '_> { +impl std::fmt::Debug for ContextBuilder { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { #[derive(Clone, Copy, Debug)] struct JobQueue; @@ -903,7 +899,7 @@ impl std::fmt::Debug for ContextBuilder<'_, '_, '_, '_> { } } -impl<'icu, 'hooks, 'queue, 'module> ContextBuilder<'icu, 'hooks, 'queue, 'module> { +impl ContextBuilder { /// Creates a new [`ContextBuilder`] with a default empty [`Interner`] /// and a default `BoaProvider` if the `intl` feature is enabled. #[must_use] @@ -936,61 +932,32 @@ impl<'icu, 'hooks, 'queue, 'module> ContextBuilder<'icu, 'hooks, 'queue, 'module /// [`LocaleCanonicalizer`]: icu_locid_transform::LocaleCanonicalizer /// [`LocaleExpander`]: icu_locid_transform::LocaleExpander #[cfg(feature = "intl")] - pub fn icu_provider( - self, - provider: BoaProvider<'_>, - ) -> Result, IcuError> { - Ok(ContextBuilder { - icu: Some(icu::Icu::new(provider)?), - ..self - }) + pub fn icu_provider(mut self, provider: BoaProvider) -> Result { + self.icu = Some(icu::Icu::new(provider)?); + Ok(self) } /// Initializes the [`HostHooks`] for the context. /// /// [`Host Hooks`]: https://tc39.es/ecma262/#sec-host-hooks-summary #[must_use] - pub fn host_hooks<'new_hooks, H>( - self, - host_hooks: H, - ) -> ContextBuilder<'icu, 'new_hooks, 'queue, 'module> - where - H: Into>, - { - ContextBuilder { - host_hooks: Some(host_hooks.into()), - ..self - } + pub fn host_hooks(mut self, host_hooks: &'static H) -> Self { + self.host_hooks = Some(host_hooks); + self } /// Initializes the [`JobQueue`] for the context. #[must_use] - pub fn job_queue<'new_queue, Q>( - self, - job_queue: Q, - ) -> ContextBuilder<'icu, 'hooks, 'new_queue, 'module> - where - Q: Into>, - { - ContextBuilder { - job_queue: Some(job_queue.into()), - ..self - } + pub fn job_queue(mut self, job_queue: Rc) -> Self { + self.job_queue = Some(job_queue); + self } /// Initializes the [`ModuleLoader`] for the context. #[must_use] - pub fn module_loader<'new_module, M>( - self, - module_loader: M, - ) -> ContextBuilder<'icu, 'hooks, 'queue, 'new_module> - where - M: Into>, - { - ContextBuilder { - module_loader: Some(module_loader.into()), - ..self - } + pub fn module_loader(mut self, module_loader: Rc) -> Self { + self.module_loader = Some(module_loader); + self } /// [`AgentCanSuspend ( )`][spec] aka `[[CanBlock]]` @@ -1006,10 +973,7 @@ impl<'icu, 'hooks, 'queue, 'module> ContextBuilder<'icu, 'hooks, 'queue, 'module /// [spec]: https://tc39.es/ecma262/#sec-agentcansuspend /// [wait]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/wait #[must_use] - pub const fn can_block( - mut self, - can_block: bool, - ) -> ContextBuilder<'icu, 'hooks, 'queue, 'module> { + pub const fn can_block(mut self, can_block: bool) -> Self { self.can_block = can_block; self } @@ -1028,13 +992,7 @@ impl<'icu, 'hooks, 'queue, 'module> ContextBuilder<'icu, 'hooks, 'queue, 'module /// all missing parameters to their default values. // TODO: try to use a custom error here, since most of the `JsError` APIs // require having a `Context` in the first place. - pub fn build<'host>(self) -> JsResult> - where - 'icu: 'host, - 'hooks: 'host, - 'queue: 'host, - 'module: 'host, - { + pub fn build(self) -> JsResult { if self.can_block { if CANNOT_BLOCK_COUNTER.get() > 0 { return Err(JsNativeError::typ() @@ -1049,46 +1007,38 @@ impl<'icu, 'hooks, 'queue, 'module> ContextBuilder<'icu, 'hooks, 'queue, 'module let root_shape = RootShape::default(); - let host_hooks = self.host_hooks.unwrap_or_else(|| { - let hooks: &dyn HostHooks = &DefaultHooks; - hooks.into() - }); - let realm = Realm::create(&*host_hooks, &root_shape); + let host_hooks = self.host_hooks.unwrap_or(&DefaultHooks); + let realm = Realm::create(host_hooks, &root_shape); let vm = Vm::new(realm); - let module_loader = if let Some(loader) = self.module_loader { + let module_loader: Rc = if let Some(loader) = self.module_loader { loader + } else if let Ok(loader) = SimpleModuleLoader::new(Path::new(".")) { + Rc::new(loader) } else { - SimpleModuleLoader::new(Path::new(".")).map_or_else( - |_| { - let loader: &dyn ModuleLoader = &IdleModuleLoader; - loader.into() - }, - |loader| { - let loader: Rc = Rc::new(loader); - loader.into() - }, - ) + Rc::new(IdleModuleLoader) }; + let job_queue = self + .job_queue + .unwrap_or_else(|| Rc::new(SimpleJobQueue::new())); + let mut context = Context { interner: self.interner.unwrap_or_default(), vm, strict: false, #[cfg(feature = "intl")] icu: self.icu.unwrap_or_else(|| { - let buffer: &dyn icu_provider::BufferProvider = boa_icu_provider::buffer(); - let provider = BoaProvider::Buffer(buffer); + let provider = BoaProvider::Buffer(Box::new(icu::StaticProviderAdapter( + boa_icu_provider::buffer(), + ))); icu::Icu::new(provider).expect("Failed to initialize default icu data.") }), #[cfg(feature = "fuzz")] instructions_remaining: self.instructions_remaining, kept_alive: Vec::new(), host_hooks, - job_queue: self.job_queue.unwrap_or_else(|| { - let queue: Rc = Rc::new(SimpleJobQueue::new()); - queue.into() - }), + job_queue, module_loader, optimizer_options: OptimizerOptions::OPTIMIZE_ALL, root_shape, @@ -1104,20 +1054,20 @@ impl<'icu, 'hooks, 'queue, 'module> ContextBuilder<'icu, 'hooks, 'queue, 'module /// A cleanup guard for a [`Context`] that is executed when dropped. #[derive(Debug)] -pub(crate) struct ContextCleanupGuard<'a, 'host, F> +pub(crate) struct ContextCleanupGuard<'a, F> where - F: FnOnce(&mut Context<'_>) + 'static, + F: FnOnce(&mut Context) + 'static, { - context: &'a mut Context<'host>, + context: &'a mut Context, cleanup: Option, } -impl<'a, 'host, F> ContextCleanupGuard<'a, 'host, F> +impl<'a, F> ContextCleanupGuard<'a, F> where - F: FnOnce(&mut Context<'_>) + 'static, + F: FnOnce(&mut Context) + 'static, { /// Creates a new `ContextCleanupGuard` from the current context and its cleanup operation. - pub(crate) fn new(context: &'a mut Context<'host>, cleanup: F) -> Self { + pub(crate) fn new(context: &'a mut Context, cleanup: F) -> Self { Self { context, cleanup: Some(cleanup), @@ -1125,29 +1075,29 @@ where } } -impl<'host, F> std::ops::Deref for ContextCleanupGuard<'_, 'host, F> +impl std::ops::Deref for ContextCleanupGuard<'_, F> where - F: FnOnce(&mut Context<'_>) + 'static, + F: FnOnce(&mut Context) + 'static, { - type Target = Context<'host>; + type Target = Context; fn deref(&self) -> &Self::Target { self.context } } -impl std::ops::DerefMut for ContextCleanupGuard<'_, '_, F> +impl std::ops::DerefMut for ContextCleanupGuard<'_, F> where - F: FnOnce(&mut Context<'_>) + 'static, + F: FnOnce(&mut Context) + 'static, { fn deref_mut(&mut self) -> &mut Self::Target { self.context } } -impl Drop for ContextCleanupGuard<'_, '_, F> +impl Drop for ContextCleanupGuard<'_, F> where - F: FnOnce(&mut Context<'_>) + 'static, + F: FnOnce(&mut Context) + 'static, { fn drop(&mut self) { if let Some(cleanup) = self.cleanup.take() { diff --git a/boa_engine/src/environments/runtime/mod.rs b/boa_engine/src/environments/runtime/mod.rs index f873dfd95f0..d7b5c53412f 100644 --- a/boa_engine/src/environments/runtime/mod.rs +++ b/boa_engine/src/environments/runtime/mod.rs @@ -485,7 +485,7 @@ pub(crate) enum BindingLocatorError { Silent, } -impl Context<'_> { +impl Context { /// Gets the corresponding runtime binding of the provided `BindingLocator`, modifying /// its indexes in place. /// diff --git a/boa_engine/src/error.rs b/boa_engine/src/error.rs index c6cfcd78d87..6749a8b6f2b 100644 --- a/boa_engine/src/error.rs +++ b/boa_engine/src/error.rs @@ -190,7 +190,7 @@ impl JsError { /// /// assert!(error_val.as_object().unwrap().borrow().is_error()); /// ``` - pub fn to_opaque(&self, context: &mut Context<'_>) -> JsValue { + pub fn to_opaque(&self, context: &mut Context) -> JsValue { match &self.inner { Repr::Native(e) => e.to_opaque(context).into(), Repr::Opaque(v) => v.clone(), @@ -235,7 +235,7 @@ impl JsError { /// assert!(matches!(error.kind, JsNativeErrorKind::Type)); /// assert_eq!(error.message(), "type error!"); /// ``` - pub fn try_native(&self, context: &mut Context<'_>) -> Result { + pub fn try_native(&self, context: &mut Context) -> Result { match &self.inner { Repr::Native(e) => Ok(e.clone()), Repr::Opaque(val) => { @@ -247,7 +247,7 @@ impl JsError { .as_error() .ok_or_else(|| TryNativeError::NotAnErrorObject(val.clone()))?; - let try_get_property = |key: JsString, name, context: &mut Context<'_>| { + let try_get_property = |key: JsString, name, context: &mut Context| { obj.has_property(key.clone(), context) .map_err(|e| TryNativeError::InaccessibleProperty { property: name, @@ -414,7 +414,7 @@ impl JsError { /// "Symbol(error!)" /// ); /// ``` - pub fn into_erased(self, context: &mut Context<'_>) -> JsErasedError { + pub fn into_erased(self, context: &mut Context) -> JsErasedError { let Ok(native) = self.try_native(context) else { return JsErasedError { inner: ErasedRepr::Opaque(self.to_string().into_boxed_str()), @@ -910,7 +910,7 @@ impl JsNativeError { /// /// If converting a [`JsNativeErrorKind::RuntimeLimit`] to an opaque object. #[inline] - pub fn to_opaque(&self, context: &mut Context<'_>) -> JsObject { + pub fn to_opaque(&self, context: &mut Context) -> JsObject { let Self { kind, message, diff --git a/boa_engine/src/job.rs b/boa_engine/src/job.rs index a5bbe606534..fac295af8d3 100644 --- a/boa_engine/src/job.rs +++ b/boa_engine/src/job.rs @@ -53,7 +53,7 @@ pub type FutureJob = Pin + 'static>>; /// ## [`Trace`]? /// /// `NativeJob` doesn't implement `Trace` because it doesn't need to; all jobs can only be run once -/// and putting a [`JobQueue`] on a garbage collected object should definitely be discouraged. +/// and putting a [`JobQueue`] on a garbage collected object is not allowed. /// /// On the other hand, it seems like this type breaks all the safety checks of the /// [`NativeFunction`] API, since you can capture any `Trace` variable into the closure... but it @@ -66,7 +66,7 @@ pub type FutureJob = Pin + 'static>>; /// [`NativeFunction`]: crate::native_function::NativeFunction pub struct NativeJob { #[allow(clippy::type_complexity)] - f: Box) -> JsResult>, + f: Box JsResult>, realm: Option, } @@ -80,7 +80,7 @@ impl NativeJob { /// Creates a new `NativeJob` from a closure. pub fn new(f: F) -> Self where - F: FnOnce(&mut Context<'_>) -> JsResult + 'static, + F: FnOnce(&mut Context) -> JsResult + 'static, { Self { f: Box::new(f), @@ -89,9 +89,9 @@ impl NativeJob { } /// Creates a new `NativeJob` from a closure and an execution realm. - pub fn with_realm(f: F, realm: Realm, _context: &mut Context<'_>) -> Self + pub fn with_realm(f: F, realm: Realm, _context: &mut Context) -> Self where - F: FnOnce(&mut Context<'_>) -> JsResult + 'static, + F: FnOnce(&mut Context) -> JsResult + 'static, { Self { f: Box::new(f), @@ -111,7 +111,7 @@ impl NativeJob { /// /// If the native job has an execution realm defined, this sets the running execution /// context to the realm's before calling the inner closure, and resets it after execution. - pub fn call(self, context: &mut Context<'_>) -> JsResult { + pub fn call(self, context: &mut Context) -> JsResult { // If realm is not null, each time job is invoked the implementation must perform // implementation-defined steps such that execution is prepared to evaluate ECMAScript // code at the time of job's invocation. @@ -209,14 +209,14 @@ pub trait JobQueue { /// /// [spec]: https://tc39.es/ecma262/#sec-hostenqueuepromisejob /// [Jobs]: https://tc39.es/ecma262/#sec-jobs - fn enqueue_promise_job(&self, job: NativeJob, context: &mut Context<'_>); + fn enqueue_promise_job(&self, job: NativeJob, context: &mut Context); /// Runs all jobs in the queue. /// /// Running a job could enqueue more jobs in the queue. The implementor of the trait /// determines if the method should loop until there are no more queued jobs or if /// it should only run one iteration of the queue. - fn run_jobs(&self, context: &mut Context<'_>); + fn run_jobs(&self, context: &mut Context); /// Enqueues a new [`Future`] job on the job queue. /// @@ -224,7 +224,7 @@ pub trait JobQueue { /// job queue to update the state of the inner `Promise`, which is what ECMAScript sees. Failing /// to do this will leave the inner `Promise` in the `pending` state, which won't call any `then` /// or `catch` handlers, even if `future` was already completed. - fn enqueue_future_job(&self, future: FutureJob, context: &mut Context<'_>); + fn enqueue_future_job(&self, future: FutureJob, context: &mut Context); /// Asynchronously runs all jobs in the queue. /// @@ -234,14 +234,13 @@ pub trait JobQueue { /// /// By default forwards to [`JobQueue::run_jobs`]. Implementors using async should override this /// with a proper algorithm to run jobs asynchronously. - fn run_jobs_async<'a, 'ctx, 'host, 'fut>( + fn run_jobs_async<'a, 'ctx, 'fut>( &'a self, - context: &'ctx mut Context<'host>, + context: &'ctx mut Context, ) -> Pin + 'fut>> where 'a: 'fut, 'ctx: 'fut, - 'host: 'fut, { Box::pin(async { self.run_jobs(context) }) } @@ -250,16 +249,17 @@ pub trait JobQueue { /// A job queue that does nothing. /// /// This queue is mostly useful if you want to disable the promise capabilities of the engine. This -/// can be done by passing a reference to it to the [`ContextBuilder`]: +/// can be done by passing it to the [`ContextBuilder`]: /// /// ``` +/// use std::rc::Rc; /// use boa_engine::{ /// context::ContextBuilder, /// job::{IdleJobQueue, JobQueue}, /// }; /// -/// let queue: &dyn JobQueue = &IdleJobQueue; -/// let context = ContextBuilder::new().job_queue(queue).build(); +/// let queue = Rc::new(IdleJobQueue); +/// let context = ContextBuilder::new().job_queue(queue ).build(); /// ``` /// /// [`ContextBuilder`]: crate::context::ContextBuilder @@ -267,11 +267,11 @@ pub trait JobQueue { pub struct IdleJobQueue; impl JobQueue for IdleJobQueue { - fn enqueue_promise_job(&self, _: NativeJob, _: &mut Context<'_>) {} + fn enqueue_promise_job(&self, _: NativeJob, _: &mut Context) {} - fn run_jobs(&self, _: &mut Context<'_>) {} + fn run_jobs(&self, _: &mut Context) {} - fn enqueue_future_job(&self, _: FutureJob, _: &mut Context<'_>) {} + fn enqueue_future_job(&self, _: FutureJob, _: &mut Context) {} } /// A simple FIFO job queue that bails on the first error. @@ -298,11 +298,11 @@ impl SimpleJobQueue { } impl JobQueue for SimpleJobQueue { - fn enqueue_promise_job(&self, job: NativeJob, _: &mut Context<'_>) { + fn enqueue_promise_job(&self, job: NativeJob, _: &mut Context) { self.0.borrow_mut().push_back(job); } - fn run_jobs(&self, context: &mut Context<'_>) { + fn run_jobs(&self, context: &mut Context) { // Yeah, I have no idea why Rust extends the lifetime of a `RefCell` that should be immediately // dropped after calling `pop_front`. let mut next_job = self.0.borrow_mut().pop_front(); @@ -315,7 +315,7 @@ impl JobQueue for SimpleJobQueue { } } - fn enqueue_future_job(&self, future: FutureJob, context: &mut Context<'_>) { + fn enqueue_future_job(&self, future: FutureJob, context: &mut Context) { let job = pollster::block_on(future); self.enqueue_promise_job(job, context); } diff --git a/boa_engine/src/lib.rs b/boa_engine/src/lib.rs index 0fee87c626f..d7bb7cf7707 100644 --- a/boa_engine/src/lib.rs +++ b/boa_engine/src/lib.rs @@ -230,7 +230,7 @@ enum Inner { source: Cow<'static, str>, }, InspectContext { - op: fn(&mut Context<'_>), + op: fn(&mut Context), }, Assert { source: Cow<'static, str>, @@ -241,7 +241,7 @@ enum Inner { }, AssertWithOp { source: Cow<'static, str>, - op: fn(JsValue, &mut Context<'_>) -> bool, + op: fn(JsValue, &mut Context) -> bool, }, AssertOpaqueError { source: Cow<'static, str>, @@ -253,7 +253,7 @@ enum Inner { message: &'static str, }, AssertContext { - op: fn(&mut Context<'_>) -> bool, + op: fn(&mut Context) -> bool, }, } @@ -274,7 +274,7 @@ impl TestAction { /// Executes `op` with the currently active context. /// /// Useful to make custom assertions that must be done from Rust code. - fn inspect_context(op: fn(&mut Context<'_>)) -> Self { + fn inspect_context(op: fn(&mut Context)) -> Self { Self(Inner::InspectContext { op }) } @@ -298,7 +298,7 @@ impl TestAction { /// Useful to check properties of the obtained value that cannot be checked from JS code. fn assert_with_op( source: impl Into>, - op: fn(JsValue, &mut Context<'_>) -> bool, + op: fn(JsValue, &mut Context) -> bool, ) -> Self { Self(Inner::AssertWithOp { source: source.into(), @@ -331,7 +331,7 @@ impl TestAction { } /// Asserts that calling `op` with the currently executing context returns `true`. - fn assert_context(op: fn(&mut Context<'_>) -> bool) -> Self { + fn assert_context(op: fn(&mut Context) -> bool) -> Self { Self(Inner::AssertContext { op }) } } @@ -347,9 +347,9 @@ fn run_test_actions(actions: impl IntoIterator) { /// Executes a list of test actions on the provided context. #[cfg(test)] #[track_caller] -fn run_test_actions_with(actions: impl IntoIterator, context: &mut Context<'_>) { +fn run_test_actions_with(actions: impl IntoIterator, context: &mut Context) { #[track_caller] - fn forward_val(context: &mut Context<'_>, source: &str) -> JsResult { + fn forward_val(context: &mut Context, source: &str) -> JsResult { context.eval(Source::from_bytes(source)) } diff --git a/boa_engine/src/module/loader.rs b/boa_engine/src/module/loader.rs index 0fb735ad149..5d9da5755b7 100644 --- a/boa_engine/src/module/loader.rs +++ b/boa_engine/src/module/loader.rs @@ -65,8 +65,8 @@ pub trait ModuleLoader { &self, referrer: Referrer, specifier: JsString, - finish_load: Box, &mut Context<'_>)>, - context: &mut Context<'_>, + finish_load: Box, &mut Context)>, + context: &mut Context, ); /// Registers a new module into the module loader. @@ -101,13 +101,7 @@ pub trait ModuleLoader { /// /// [meta]: https://tc39.es/ecma262/#sec-hostgetimportmetaproperties /// [final]: https://tc39.es/ecma262/#sec-hostfinalizeimportmeta - fn init_import_meta( - &self, - _import_meta: &JsObject, - _module: &Module, - _context: &mut Context<'_>, - ) { - } + fn init_import_meta(&self, _import_meta: &JsObject, _module: &Module, _context: &mut Context) {} } /// A module loader that throws when trying to load any modules. @@ -121,8 +115,8 @@ impl ModuleLoader for IdleModuleLoader { &self, _referrer: Referrer, _specifier: JsString, - finish_load: Box, &mut Context<'_>)>, - context: &mut Context<'_>, + finish_load: Box, &mut Context)>, + context: &mut Context, ) { finish_load( Err(JsNativeError::typ() @@ -184,8 +178,8 @@ impl ModuleLoader for SimpleModuleLoader { &self, _referrer: Referrer, specifier: JsString, - finish_load: Box, &mut Context<'_>)>, - context: &mut Context<'_>, + finish_load: Box, &mut Context)>, + context: &mut Context, ) { let result = (|| { let path = specifier diff --git a/boa_engine/src/module/mod.rs b/boa_engine/src/module/mod.rs index 65223788497..3c564d73cb0 100644 --- a/boa_engine/src/module/mod.rs +++ b/boa_engine/src/module/mod.rs @@ -145,7 +145,7 @@ impl Module { pub fn parse( src: Source<'_, R>, realm: Option, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let _timer = Profiler::global().start_event("Module parsing", "Main"); let mut parser = Parser::new(src); @@ -178,7 +178,7 @@ impl Module { export_names: &[JsString], evaluation_steps: SyntheticModuleInitializer, realm: Option, - context: &mut Context<'_>, + context: &mut Context, ) -> Self { let names: FxHashSet = export_names .iter() @@ -234,7 +234,7 @@ impl Module { /// [spec]: https://tc39.es/ecma262/#table-abstract-methods-of-module-records #[allow(clippy::missing_panics_doc)] #[inline] - pub fn load(&self, context: &mut Context<'_>) -> JsPromise { + pub fn load(&self, context: &mut Context) -> JsPromise { match self.kind() { ModuleKind::SourceText(_) => { // Concrete method [`LoadRequestedModules ( [ hostDefined ] )`][spec]. @@ -277,7 +277,7 @@ impl Module { /// Abstract operation [`InnerModuleLoading`][spec]. /// /// [spec]: https://tc39.es/ecma262/#sec-InnerModuleLoading - fn inner_load(&self, state: &Rc, context: &mut Context<'_>) { + fn inner_load(&self, state: &Rc, context: &mut Context) { // 1. Assert: state.[[IsLoading]] is true. assert!(state.loading.get()); @@ -364,7 +364,7 @@ impl Module { /// [spec]: https://tc39.es/ecma262/#table-abstract-methods-of-module-records #[allow(clippy::missing_panics_doc)] #[inline] - pub fn link(&self, context: &mut Context<'_>) -> JsResult<()> { + pub fn link(&self, context: &mut Context) -> JsResult<()> { match self.kind() { ModuleKind::SourceText(src) => src.link(context), ModuleKind::Synthetic(synth) => { @@ -381,7 +381,7 @@ impl Module { &self, stack: &mut Vec, index: usize, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { match self.kind() { ModuleKind::SourceText(src) => src.inner_link(stack, index, context), @@ -408,7 +408,7 @@ impl Module { /// /// [spec]: https://tc39.es/ecma262/#table-abstract-methods-of-module-records #[inline] - pub fn evaluate(&self, context: &mut Context<'_>) -> JsPromise { + pub fn evaluate(&self, context: &mut Context) -> JsPromise { match self.kind() { ModuleKind::SourceText(src) => src.evaluate(context), ModuleKind::Synthetic(synth) => synth.evaluate(context), @@ -422,7 +422,7 @@ impl Module { &self, stack: &mut Vec, index: usize, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { match self.kind() { ModuleKind::SourceText(src) => src.inner_evaluate(stack, index, None, context), @@ -450,14 +450,13 @@ impl Module { /// /// # Examples /// ``` - /// # use std::path::Path; + /// # use std::{path::Path, rc::Rc}; /// # use boa_engine::{Context, Source, Module, JsValue}; /// # use boa_engine::builtins::promise::PromiseState; /// # use boa_engine::module::{ModuleLoader, SimpleModuleLoader}; - /// let loader = &SimpleModuleLoader::new(Path::new(".")).unwrap(); - /// let dyn_loader: &dyn ModuleLoader = loader; + /// let loader = Rc::new(SimpleModuleLoader::new(Path::new(".")).unwrap()); /// let mut context = &mut Context::builder() - /// .module_loader(dyn_loader) + /// .module_loader(loader.clone()) /// .build() /// .unwrap(); /// @@ -478,7 +477,7 @@ impl Module { /// ``` #[allow(dropping_copy_types)] #[inline] - pub fn load_link_evaluate(&self, context: &mut Context<'_>) -> JsPromise { + pub fn load_link_evaluate(&self, context: &mut Context) -> JsPromise { let main_timer = Profiler::global().start_event("Module evaluation", "Main"); let promise = self @@ -522,7 +521,7 @@ impl Module { /// /// [spec]: https://tc39.es/ecma262/#sec-getmodulenamespace /// [ns]: https://tc39.es/ecma262/#sec-module-namespace-exotic-objects - pub fn namespace(&self, context: &mut Context<'_>) -> JsObject { + pub fn namespace(&self, context: &mut Context) -> JsObject { // 1. Assert: If module is a Cyclic Module Record, then module.[[Status]] is not new or unlinked. // 2. Let namespace be module.[[Namespace]]. // 3. If namespace is empty, then @@ -584,7 +583,7 @@ impl ModuleNamespace { /// Abstract operation [`ModuleNamespaceCreate ( module, exports )`][spec]. /// /// [spec]: https://tc39.es/ecma262/#sec-modulenamespacecreate - pub(crate) fn create(module: Module, names: Vec, context: &mut Context<'_>) -> JsObject { + pub(crate) fn create(module: Module, names: Vec, context: &mut Context) -> JsObject { // 1. Assert: module.[[Namespace]] is empty. // ignored since this is ensured by `Module::namespace`. diff --git a/boa_engine/src/module/source.rs b/boa_engine/src/module/source.rs index 9da65acac20..982ee917757 100644 --- a/boa_engine/src/module/source.rs +++ b/boa_engine/src/module/source.rs @@ -410,7 +410,7 @@ impl SourceTextModule { /// Abstract operation [`InnerModuleLoading`][spec]. /// /// [spec]: https://tc39.es/ecma262/#sec-InnerModuleLoading - pub(super) fn inner_load(&self, state: &Rc, context: &mut Context<'_>) { + pub(super) fn inner_load(&self, state: &Rc, context: &mut Context) { // 2. If module is a Cyclic Module Record, module.[[Status]] is new, and state.[[Visited]] does not contain // module, then // a. Append module to state.[[Visited]]. @@ -691,7 +691,7 @@ impl SourceTextModule { /// Concrete method [`Link ( )`][spec]. /// /// [spec]: https://tc39.es/ecma262/#sec-moduledeclarationlinking - pub(super) fn link(&self, context: &mut Context<'_>) -> JsResult<()> { + pub(super) fn link(&self, context: &mut Context) -> JsResult<()> { // 1. Assert: module.[[Status]] is one of unlinked, linked, evaluating-async, or evaluated. debug_assert!(matches!( &*self.inner.status.borrow(), @@ -739,7 +739,7 @@ impl SourceTextModule { &self, stack: &mut Vec, mut index: usize, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 2. If module.[[Status]] is one of linking, linked, evaluating-async, or evaluated, then if matches!( @@ -882,7 +882,7 @@ impl SourceTextModule { /// Concrete method [`Evaluate ( )`][spec]. /// /// [spec]: https://tc39.es/ecma262/#sec-moduleevaluation - pub(super) fn evaluate(&self, context: &mut Context<'_>) -> JsPromise { + pub(super) fn evaluate(&self, context: &mut Context) -> JsPromise { // 1. Assert: This call to Evaluate is not happening at the same time as another call to Evaluate within the surrounding agent. let (module, promise) = { match &*self.inner.status.borrow() { @@ -1012,7 +1012,7 @@ impl SourceTextModule { stack: &mut Vec, mut index: usize, capability: Option, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { /// Gets the next evaluation index of an async module. /// @@ -1246,7 +1246,7 @@ impl SourceTextModule { /// Abstract operation [`ExecuteAsyncModule ( module )`][spec]. /// /// [spec]: https://tc39.es/ecma262/#sec-execute-async-module - fn execute_async(&self, context: &mut Context<'_>) { + fn execute_async(&self, context: &mut Context) { // 1. Assert: module.[[Status]] is either evaluating or evaluating-async. debug_assert!(matches!( &*self.inner.status.borrow(), @@ -1359,7 +1359,7 @@ impl SourceTextModule { /// Abstract operation [`InitializeEnvironment ( )`][spec]. /// /// [spec]: https://tc39.es/ecma262/#sec-source-text-module-record-initialize-environment - fn initialize_environment(&self, context: &mut Context<'_>) -> JsResult<()> { + fn initialize_environment(&self, context: &mut Context) -> JsResult<()> { #[derive(Debug)] enum ImportBinding { Namespace { @@ -1702,7 +1702,7 @@ impl SourceTextModule { fn execute( &self, capability: Option, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult<()> { // 1. Let moduleContext be a new ECMAScript code execution context. let SourceTextContext { @@ -1776,7 +1776,7 @@ impl SourceTextModule { /// /// [spec]: https://tc39.es/ecma262/#sec-async-module-execution-fulfilled #[allow(clippy::mutable_key_type)] -fn async_module_execution_fulfilled(module: &SourceTextModule, context: &mut Context<'_>) { +fn async_module_execution_fulfilled(module: &SourceTextModule, context: &mut Context) { // 1. If module.[[Status]] is evaluated, then if let Status::Evaluated { error, .. } = &*module.inner.status.borrow() { // a. Assert: module.[[EvaluationError]] is not empty. @@ -1904,7 +1904,7 @@ fn async_module_execution_fulfilled(module: &SourceTextModule, context: &mut Con fn async_module_execution_rejected( module: &SourceTextModule, error: &JsError, - context: &mut Context<'_>, + context: &mut Context, ) { // 1. If module.[[Status]] is evaluated, then if let Status::Evaluated { error, .. } = &*module.inner.status.borrow() { diff --git a/boa_engine/src/module/synthetic.rs b/boa_engine/src/module/synthetic.rs index 9587e90ada6..521de2a9a6c 100644 --- a/boa_engine/src/module/synthetic.rs +++ b/boa_engine/src/module/synthetic.rs @@ -17,13 +17,13 @@ use crate::{ use super::{BindingName, ModuleRepr, ResolveExportError, ResolvedBinding}; trait TraceableCallback: Trace { - fn call(&self, module: &SyntheticModule, context: &mut Context<'_>) -> JsResult<()>; + fn call(&self, module: &SyntheticModule, context: &mut Context) -> JsResult<()>; } #[derive(Trace, Finalize)] struct Callback where - F: Fn(&SyntheticModule, &T, &mut Context<'_>) -> JsResult<()>, + F: Fn(&SyntheticModule, &T, &mut Context) -> JsResult<()>, T: Trace, { // SAFETY: `SyntheticModuleInitializer`'s safe API ensures only `Copy` closures are stored; its unsafe API, @@ -36,10 +36,10 @@ where impl TraceableCallback for Callback where - F: Fn(&SyntheticModule, &T, &mut Context<'_>) -> JsResult<()>, + F: Fn(&SyntheticModule, &T, &mut Context) -> JsResult<()>, T: Trace, { - fn call(&self, module: &SyntheticModule, context: &mut Context<'_>) -> JsResult<()> { + fn call(&self, module: &SyntheticModule, context: &mut Context) -> JsResult<()> { (self.f)(module, &self.captures, context) } } @@ -68,7 +68,7 @@ impl SyntheticModuleInitializer { /// Creates a `SyntheticModuleInitializer` from a [`Copy`] closure. pub fn from_copy_closure(closure: F) -> Self where - F: Fn(&SyntheticModule, &mut Context<'_>) -> JsResult<()> + Copy + 'static, + F: Fn(&SyntheticModule, &mut Context) -> JsResult<()> + Copy + 'static, { // SAFETY: The `Copy` bound ensures there are no traceable types inside the closure. unsafe { Self::from_closure(closure) } @@ -77,7 +77,7 @@ impl SyntheticModuleInitializer { /// Creates a `SyntheticModuleInitializer` from a [`Copy`] closure and a list of traceable captures. pub fn from_copy_closure_with_captures(closure: F, captures: T) -> Self where - F: Fn(&SyntheticModule, &T, &mut Context<'_>) -> JsResult<()> + Copy + 'static, + F: Fn(&SyntheticModule, &T, &mut Context) -> JsResult<()> + Copy + 'static, T: Trace + 'static, { // SAFETY: The `Copy` bound ensures there are no traceable types inside the closure. @@ -94,7 +94,7 @@ impl SyntheticModuleInitializer { /// on why that is the case. pub unsafe fn from_closure(closure: F) -> Self where - F: Fn(&SyntheticModule, &mut Context<'_>) -> JsResult<()> + 'static, + F: Fn(&SyntheticModule, &mut Context) -> JsResult<()> + 'static, { // SAFETY: The caller must ensure the invariants of the closure hold. unsafe { @@ -112,7 +112,7 @@ impl SyntheticModuleInitializer { /// on why that is the case. pub unsafe fn from_closure_with_captures(closure: F, captures: T) -> Self where - F: Fn(&SyntheticModule, &T, &mut Context<'_>) -> JsResult<()> + 'static, + F: Fn(&SyntheticModule, &T, &mut Context) -> JsResult<()> + 'static, T: Trace + 'static, { // Hopefully, this unsafe operation will be replaced by the `CoerceUnsized` API in the @@ -133,7 +133,7 @@ impl SyntheticModuleInitializer { /// Calls this `SyntheticModuleInitializer`, forwarding the arguments to the corresponding function. #[inline] - pub fn call(&self, module: &SyntheticModule, context: &mut Context<'_>) -> JsResult<()> { + pub fn call(&self, module: &SyntheticModule, context: &mut Context) -> JsResult<()> { self.inner.call(module, context) } } @@ -195,7 +195,7 @@ impl SyntheticModule { /// Concrete method [`LoadRequestedModules ( )`][spec]. /// /// [spec]: https://tc39.es/proposal-json-modules/#sec-smr-LoadRequestedModules - pub(super) fn load(context: &mut Context<'_>) -> JsPromise { + pub(super) fn load(context: &mut Context) -> JsPromise { // 1. Return ! PromiseResolve(%Promise%, undefined). JsPromise::resolve(JsValue::undefined(), context) } @@ -231,7 +231,7 @@ impl SyntheticModule { /// Concrete method [`Link ( )`][spec]. /// /// [spec]: https://tc39.es/ecma262/#sec-moduledeclarationlinking - pub(super) fn link(&self, context: &mut Context<'_>) { + pub(super) fn link(&self, context: &mut Context) { let parent = self.parent(); // 1. Let realm be module.[[Realm]]. // 2. Let env be NewModuleEnvironment(realm.[[GlobalEnv]]). @@ -287,7 +287,7 @@ impl SyntheticModule { /// Concrete method [`Evaluate ( )`][spec]. /// /// [spec]: https://tc39.es/proposal-json-modules/#sec-smr-Evaluate - pub(super) fn evaluate(&self, context: &mut Context<'_>) -> JsPromise { + pub(super) fn evaluate(&self, context: &mut Context) -> JsPromise { // 1. Let moduleContext be a new ECMAScript code execution context. let parent = self.parent(); @@ -357,7 +357,7 @@ impl SyntheticModule { &self, export_name: &JsString, export_value: JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult<()> { let identifier = context.interner_mut().get_or_intern(&**export_name); let identifier = Identifier::new(identifier); diff --git a/boa_engine/src/native_function.rs b/boa_engine/src/native_function.rs index 2f707716c7a..b3483e682be 100644 --- a/boa_engine/src/native_function.rs +++ b/boa_engine/src/native_function.rs @@ -21,21 +21,16 @@ use crate::{ /// - The second argument represents the list of all arguments passed to the function. /// /// - The last argument is the engine [`Context`]. -pub type NativeFunctionPointer = fn(&JsValue, &[JsValue], &mut Context<'_>) -> JsResult; +pub type NativeFunctionPointer = fn(&JsValue, &[JsValue], &mut Context) -> JsResult; trait TraceableClosure: Trace { - fn call( - &self, - this: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult; + fn call(&self, this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult; } #[derive(Trace, Finalize)] struct Closure where - F: Fn(&JsValue, &[JsValue], &T, &mut Context<'_>) -> JsResult, + F: Fn(&JsValue, &[JsValue], &T, &mut Context) -> JsResult, T: Trace, { // SAFETY: `NativeFunction`'s safe API ensures only `Copy` closures are stored; its unsafe API, @@ -48,15 +43,10 @@ where impl TraceableClosure for Closure where - F: Fn(&JsValue, &[JsValue], &T, &mut Context<'_>) -> JsResult, + F: Fn(&JsValue, &[JsValue], &T, &mut Context) -> JsResult, T: Trace, { - fn call( - &self, - this: &JsValue, - args: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + fn call(&self, this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { (self.f)(this, args, &self.captures, context) } } @@ -152,7 +142,7 @@ impl NativeFunction { /// async fn test( /// _this: &JsValue, /// args: &[JsValue], - /// _context: &mut Context<'_>, + /// _context: &mut Context, /// ) -> JsResult { /// let arg = args.get(0).cloned(); /// std::future::ready(()).await; @@ -171,7 +161,7 @@ impl NativeFunction { /// fn test<'a>( /// _this: &JsValue, /// args: &'a [JsValue], - /// _context: &mut Context<'_>, + /// _context: &mut Context, /// ) -> impl Future> + 'a { /// async move { /// let arg = args.get(0).cloned(); @@ -197,7 +187,7 @@ impl NativeFunction { /// fn test( /// _this: &JsValue, /// args: &[JsValue], - /// _context: &mut Context<'_>, + /// _context: &mut Context, /// ) -> impl Future> { /// let arg = args.get(0).cloned(); /// async move { @@ -212,7 +202,7 @@ impl NativeFunction { /// And this should always return a `'static` future. /// /// [`Future`]: std::future::Future - pub fn from_async_fn(f: fn(&JsValue, &[JsValue], &mut Context<'_>) -> Fut) -> Self + pub fn from_async_fn(f: fn(&JsValue, &[JsValue], &mut Context) -> Fut) -> Self where Fut: std::future::IntoFuture> + 'static, { @@ -226,7 +216,7 @@ impl NativeFunction { /// Creates a `NativeFunction` from a `Copy` closure. pub fn from_copy_closure(closure: F) -> Self where - F: Fn(&JsValue, &[JsValue], &mut Context<'_>) -> JsResult + Copy + 'static, + F: Fn(&JsValue, &[JsValue], &mut Context) -> JsResult + Copy + 'static, { // SAFETY: The `Copy` bound ensures there are no traceable types inside the closure. unsafe { Self::from_closure(closure) } @@ -235,7 +225,7 @@ impl NativeFunction { /// Creates a `NativeFunction` from a `Copy` closure and a list of traceable captures. pub fn from_copy_closure_with_captures(closure: F, captures: T) -> Self where - F: Fn(&JsValue, &[JsValue], &T, &mut Context<'_>) -> JsResult + Copy + 'static, + F: Fn(&JsValue, &[JsValue], &T, &mut Context) -> JsResult + Copy + 'static, T: Trace + 'static, { // SAFETY: The `Copy` bound ensures there are no traceable types inside the closure. @@ -252,7 +242,7 @@ impl NativeFunction { /// on why that is the case. pub unsafe fn from_closure(closure: F) -> Self where - F: Fn(&JsValue, &[JsValue], &mut Context<'_>) -> JsResult + 'static, + F: Fn(&JsValue, &[JsValue], &mut Context) -> JsResult + 'static, { // SAFETY: The caller must ensure the invariants of the closure hold. unsafe { @@ -273,7 +263,7 @@ impl NativeFunction { /// on why that is the case. pub unsafe fn from_closure_with_captures(closure: F, captures: T) -> Self where - F: Fn(&JsValue, &[JsValue], &T, &mut Context<'_>) -> JsResult + 'static, + F: Fn(&JsValue, &[JsValue], &T, &mut Context) -> JsResult + 'static, T: Trace + 'static, { // Hopefully, this unsafe operation will be replaced by the `CoerceUnsized` API in the @@ -297,7 +287,7 @@ impl NativeFunction { &self, this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { match self.inner { Inner::PointerFn(f) => f(this, args, context), diff --git a/boa_engine/src/object/builtins/jsarray.rs b/boa_engine/src/object/builtins/jsarray.rs index d5eaa595990..ae8d2b8acab 100644 --- a/boa_engine/src/object/builtins/jsarray.rs +++ b/boa_engine/src/object/builtins/jsarray.rs @@ -18,7 +18,7 @@ pub struct JsArray { impl JsArray { /// Create a new empty array. #[inline] - pub fn new(context: &mut Context<'_>) -> Self { + pub fn new(context: &mut Context) -> Self { let inner = Array::array_create(0, None, context) .expect("creating an empty array with the default prototype must not fail"); @@ -26,7 +26,7 @@ impl JsArray { } /// Create an array from a `IntoIterator` convertible object. - pub fn from_iter(elements: I, context: &mut Context<'_>) -> Self + pub fn from_iter(elements: I, context: &mut Context) -> Self where I: IntoIterator, { @@ -53,18 +53,18 @@ impl JsArray { /// /// Same as `array.length` in JavaScript. #[inline] - pub fn length(&self, context: &mut Context<'_>) -> JsResult { + pub fn length(&self, context: &mut Context) -> JsResult { self.inner.length_of_array_like(context) } /// Check if the array is empty, i.e. the `length` is zero. #[inline] - pub fn is_empty(&self, context: &mut Context<'_>) -> JsResult { + pub fn is_empty(&self, context: &mut Context) -> JsResult { self.inner.length_of_array_like(context).map(|len| len == 0) } /// Push an element to the array. - pub fn push(&self, value: T, context: &mut Context<'_>) -> JsResult + pub fn push(&self, value: T, context: &mut Context) -> JsResult where T: Into, { @@ -73,18 +73,18 @@ impl JsArray { /// Pushes a slice of elements to the array. #[inline] - pub fn push_items(&self, items: &[JsValue], context: &mut Context<'_>) -> JsResult { + pub fn push_items(&self, items: &[JsValue], context: &mut Context) -> JsResult { Array::push(&self.inner.clone().into(), items, context) } /// Pops an element from the array. #[inline] - pub fn pop(&self, context: &mut Context<'_>) -> JsResult { + pub fn pop(&self, context: &mut Context) -> JsResult { Array::pop(&self.inner.clone().into(), &[], context) } /// Calls `Array.prototype.at()`. - pub fn at(&self, index: T, context: &mut Context<'_>) -> JsResult + pub fn at(&self, index: T, context: &mut Context) -> JsResult where T: Into, { @@ -93,26 +93,26 @@ impl JsArray { /// Calls `Array.prototype.shift()`. #[inline] - pub fn shift(&self, context: &mut Context<'_>) -> JsResult { + pub fn shift(&self, context: &mut Context) -> JsResult { Array::shift(&self.inner.clone().into(), &[], context) } /// Calls `Array.prototype.unshift()`. #[inline] - pub fn unshift(&self, items: &[JsValue], context: &mut Context<'_>) -> JsResult { + pub fn unshift(&self, items: &[JsValue], context: &mut Context) -> JsResult { Array::shift(&self.inner.clone().into(), items, context) } /// Calls `Array.prototype.reverse()`. #[inline] - pub fn reverse(&self, context: &mut Context<'_>) -> JsResult { + pub fn reverse(&self, context: &mut Context) -> JsResult { Array::reverse(&self.inner.clone().into(), &[], context)?; Ok(self.clone()) } /// Calls `Array.prototype.concat()`. #[inline] - pub fn concat(&self, items: &[JsValue], context: &mut Context<'_>) -> JsResult { + pub fn concat(&self, items: &[JsValue], context: &mut Context) -> JsResult { let object = Array::concat(&self.inner.clone().into(), items, context)? .as_object() .cloned() @@ -123,11 +123,7 @@ impl JsArray { /// Calls `Array.prototype.join()`. #[inline] - pub fn join( - &self, - separator: Option, - context: &mut Context<'_>, - ) -> JsResult { + pub fn join(&self, separator: Option, context: &mut Context) -> JsResult { Array::join( &self.inner.clone().into(), &[separator.into_or_undefined()], @@ -146,7 +142,7 @@ impl JsArray { value: T, start: Option, end: Option, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult where T: Into, @@ -168,7 +164,7 @@ impl JsArray { &self, search_element: T, from_index: Option, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult> where T: Into, @@ -194,7 +190,7 @@ impl JsArray { &self, search_element: T, from_index: Option, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult> where T: Into, @@ -221,7 +217,7 @@ impl JsArray { &self, predicate: JsFunction, this_arg: Option, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { Array::find( &self.inner.clone().into(), @@ -236,7 +232,7 @@ impl JsArray { &self, callback: JsFunction, this_arg: Option, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let object = Array::filter( &self.inner.clone().into(), @@ -256,7 +252,7 @@ impl JsArray { &self, callback: JsFunction, this_arg: Option, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let object = Array::map( &self.inner.clone().into(), @@ -276,7 +272,7 @@ impl JsArray { &self, callback: JsFunction, this_arg: Option, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let result = Array::every( &self.inner.clone().into(), @@ -295,7 +291,7 @@ impl JsArray { &self, callback: JsFunction, this_arg: Option, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let result = Array::some( &self.inner.clone().into(), @@ -310,11 +306,7 @@ impl JsArray { /// Calls `Array.prototype.sort()`. #[inline] - pub fn sort( - &self, - compare_fn: Option, - context: &mut Context<'_>, - ) -> JsResult { + pub fn sort(&self, compare_fn: Option, context: &mut Context) -> JsResult { Array::sort( &self.inner.clone().into(), &[compare_fn.into_or_undefined()], @@ -330,7 +322,7 @@ impl JsArray { &self, start: Option, end: Option, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let object = Array::slice( &self.inner.clone().into(), @@ -350,7 +342,7 @@ impl JsArray { &self, callback: JsFunction, initial_value: Option, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { Array::reduce( &self.inner.clone().into(), @@ -365,7 +357,7 @@ impl JsArray { &self, callback: JsFunction, initial_value: Option, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { Array::reduce_right( &self.inner.clone().into(), @@ -376,7 +368,7 @@ impl JsArray { /// Calls `Array.prototype.toReversed`. #[inline] - pub fn to_reversed(&self, context: &mut Context<'_>) -> JsResult { + pub fn to_reversed(&self, context: &mut Context) -> JsResult { let array = Array::to_reversed(&self.inner.clone().into(), &[], context)?; Ok(Self { @@ -392,7 +384,7 @@ impl JsArray { pub fn to_sorted( &self, compare_fn: Option, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let array = Array::to_sorted( &self.inner.clone().into(), @@ -410,7 +402,7 @@ impl JsArray { /// Calls `Array.prototype.with`. #[inline] - pub fn with(&self, index: u64, value: JsValue, context: &mut Context<'_>) -> JsResult { + pub fn with(&self, index: u64, value: JsValue, context: &mut Context) -> JsResult { let array = Array::with(&self.inner.clone().into(), &[index.into(), value], context)?; Ok(Self { @@ -448,7 +440,7 @@ impl Deref for JsArray { impl JsObjectType for JsArray {} impl TryFromJs for JsArray { - fn try_from_js(value: &JsValue, _context: &mut Context<'_>) -> JsResult { + fn try_from_js(value: &JsValue, _context: &mut Context) -> JsResult { match value { JsValue::Object(o) => Self::from_object(o.clone()), _ => Err(JsNativeError::typ() diff --git a/boa_engine/src/object/builtins/jsarraybuffer.rs b/boa_engine/src/object/builtins/jsarraybuffer.rs index c364741e8f6..2231cb38831 100644 --- a/boa_engine/src/object/builtins/jsarraybuffer.rs +++ b/boa_engine/src/object/builtins/jsarraybuffer.rs @@ -39,7 +39,7 @@ impl JsArrayBuffer { /// # } /// ``` #[inline] - pub fn new(byte_length: usize, context: &mut Context<'_>) -> JsResult { + pub fn new(byte_length: usize, context: &mut Context) -> JsResult { let inner = ArrayBuffer::allocate( &context .intrinsics() @@ -80,7 +80,7 @@ impl JsArrayBuffer { /// # Ok(()) /// # } /// ``` - pub fn from_byte_block(byte_block: Vec, context: &mut Context<'_>) -> JsResult { + pub fn from_byte_block(byte_block: Vec, context: &mut Context) -> JsResult { let constructor = context .intrinsics() .constructors() @@ -148,7 +148,7 @@ impl JsArrayBuffer { /// # } /// ``` #[inline] - pub fn byte_length(&self, context: &mut Context<'_>) -> usize { + pub fn byte_length(&self, context: &mut Context) -> usize { ArrayBuffer::get_byte_length(&self.inner.clone().into(), &[], context) .expect("it should not throw") .as_number() @@ -226,7 +226,7 @@ impl Deref for JsArrayBuffer { impl JsObjectType for JsArrayBuffer {} impl TryFromJs for JsArrayBuffer { - fn try_from_js(value: &JsValue, _context: &mut Context<'_>) -> JsResult { + fn try_from_js(value: &JsValue, _context: &mut Context) -> JsResult { match value { JsValue::Object(o) => Self::from_object(o.clone()), _ => Err(JsNativeError::typ() diff --git a/boa_engine/src/object/builtins/jsdataview.rs b/boa_engine/src/object/builtins/jsdataview.rs index e8f355e639d..821e27d432e 100644 --- a/boa_engine/src/object/builtins/jsdataview.rs +++ b/boa_engine/src/object/builtins/jsdataview.rs @@ -44,7 +44,7 @@ impl JsDataView { array_buffer: &JsArrayBuffer, offset: Option, byte_length: Option, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let (byte_offset, byte_length) = { let borrowed_buffer = array_buffer.borrow(); @@ -122,20 +122,20 @@ impl JsDataView { /// Returns the `viewed_array_buffer` field for [`JsDataView`] #[inline] - pub fn buffer(&self, context: &mut Context<'_>) -> JsResult { + pub fn buffer(&self, context: &mut Context) -> JsResult { DataView::get_buffer(&self.inner.clone().into(), &[], context) } /// Returns the `byte_length` property of [`JsDataView`] as a u64 integer #[inline] - pub fn byte_length(&self, context: &mut Context<'_>) -> JsResult { + pub fn byte_length(&self, context: &mut Context) -> JsResult { DataView::get_byte_length(&self.inner.clone().into(), &[], context) .map(|v| v.as_number().expect("value should be a number") as u64) } /// Returns the `byte_offset` field property of [`JsDataView`] as a u64 integer #[inline] - pub fn byte_offset(&self, context: &mut Context<'_>) -> JsResult { + pub fn byte_offset(&self, context: &mut Context) -> JsResult { DataView::get_byte_offset(&self.inner.clone().into(), &[], context) .map(|v| v.as_number().expect("byte_offset value must be a number") as u64) } @@ -146,7 +146,7 @@ impl JsDataView { &self, byte_offset: usize, is_little_endian: bool, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { DataView::get_big_int64( &self.inner.clone().into(), @@ -162,7 +162,7 @@ impl JsDataView { &self, byte_offset: usize, is_little_endian: bool, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { DataView::get_big_uint64( &self.inner.clone().into(), @@ -178,7 +178,7 @@ impl JsDataView { &self, byte_offset: usize, is_little_endian: bool, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { DataView::get_float32( &self.inner.clone().into(), @@ -194,7 +194,7 @@ impl JsDataView { &self, byte_offset: usize, is_little_endian: bool, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { DataView::get_float64( &self.inner.clone().into(), @@ -210,7 +210,7 @@ impl JsDataView { &self, byte_offset: usize, is_little_endian: bool, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { DataView::get_int8( &self.inner.clone().into(), @@ -226,7 +226,7 @@ impl JsDataView { &self, byte_offset: usize, is_little_endian: bool, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { DataView::get_int16( &self.inner.clone().into(), @@ -242,7 +242,7 @@ impl JsDataView { &self, byte_offset: usize, is_little_endian: bool, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { DataView::get_int32( &self.inner.clone().into(), @@ -258,7 +258,7 @@ impl JsDataView { &self, byte_offset: usize, is_little_endian: bool, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { DataView::get_uint8( &self.inner.clone().into(), @@ -274,7 +274,7 @@ impl JsDataView { &self, byte_offset: usize, is_little_endian: bool, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { DataView::get_uint16( &self.inner.clone().into(), @@ -290,7 +290,7 @@ impl JsDataView { &self, byte_offset: usize, is_little_endian: bool, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { DataView::get_uint32( &self.inner.clone().into(), @@ -307,7 +307,7 @@ impl JsDataView { byte_offset: usize, value: i64, is_little_endian: bool, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { DataView::set_big_int64( &self.inner.clone().into(), @@ -323,7 +323,7 @@ impl JsDataView { byte_offset: usize, value: u64, is_little_endian: bool, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { DataView::set_big_uint64( &self.inner.clone().into(), @@ -339,7 +339,7 @@ impl JsDataView { byte_offset: usize, value: f32, is_little_endian: bool, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { DataView::set_float32( &self.inner.clone().into(), @@ -355,7 +355,7 @@ impl JsDataView { byte_offset: usize, value: f64, is_little_endian: bool, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { DataView::set_float64( &self.inner.clone().into(), @@ -371,7 +371,7 @@ impl JsDataView { byte_offset: usize, value: i8, is_little_endian: bool, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { DataView::set_int8( &self.inner.clone().into(), @@ -387,7 +387,7 @@ impl JsDataView { byte_offset: usize, value: i16, is_little_endian: bool, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { DataView::set_int16( &self.inner.clone().into(), @@ -403,7 +403,7 @@ impl JsDataView { byte_offset: usize, value: i32, is_little_endian: bool, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { DataView::set_int32( &self.inner.clone().into(), @@ -419,7 +419,7 @@ impl JsDataView { byte_offset: usize, value: u8, is_little_endian: bool, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { DataView::set_uint8( &self.inner.clone().into(), @@ -435,7 +435,7 @@ impl JsDataView { byte_offset: usize, value: u16, is_little_endian: bool, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { DataView::set_uint16( &self.inner.clone().into(), @@ -451,7 +451,7 @@ impl JsDataView { byte_offset: usize, value: u32, is_little_endian: bool, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { DataView::set_uint32( &self.inner.clone().into(), @@ -487,7 +487,7 @@ impl Deref for JsDataView { impl JsObjectType for JsDataView {} impl TryFromJs for JsDataView { - fn try_from_js(value: &JsValue, _context: &mut Context<'_>) -> JsResult { + fn try_from_js(value: &JsValue, _context: &mut Context) -> JsResult { match value { JsValue::Object(o) => Self::from_object(o.clone()), _ => Err(JsNativeError::typ() diff --git a/boa_engine/src/object/builtins/jsdate.rs b/boa_engine/src/object/builtins/jsdate.rs index 2a190abcf9f..9034a10723e 100644 --- a/boa_engine/src/object/builtins/jsdate.rs +++ b/boa_engine/src/object/builtins/jsdate.rs @@ -46,12 +46,12 @@ pub struct JsDate { impl JsDate { /// Create a new `Date` object with universal time. #[inline] - pub fn new(context: &mut Context<'_>) -> Self { + pub fn new(context: &mut Context) -> Self { let prototype = context.intrinsics().constructors().date().prototype(); let inner = JsObject::from_proto_and_data_with_shared_shape( context.root_shape(), prototype, - ObjectData::date(Date::utc_now(&*context.host_hooks())), + ObjectData::date(Date::utc_now(context.host_hooks())), ); Self { inner } @@ -73,7 +73,7 @@ impl JsDate { /// /// Same as JavaScript's `Date.now()` #[inline] - pub fn now(context: &mut Context<'_>) -> JsResult { + pub fn now(context: &mut Context) -> JsResult { Date::now(&JsValue::Null, &[JsValue::Null], context) } @@ -85,7 +85,7 @@ impl JsDate { /// /// Same as JavaScript's `Date.parse(value)`. #[inline] - pub fn parse(value: JsValue, context: &mut Context<'_>) -> JsResult { + pub fn parse(value: JsValue, context: &mut Context) -> JsResult { Date::parse(&JsValue::Null, &[value], context) } @@ -94,7 +94,7 @@ impl JsDate { /// /// Same as JavaScript's `Date.UTC()` #[inline] - pub fn utc(values: &[JsValue], context: &mut Context<'_>) -> JsResult { + pub fn utc(values: &[JsValue], context: &mut Context) -> JsResult { Date::utc(&JsValue::Null, values, context) } @@ -103,7 +103,7 @@ impl JsDate { /// /// Same as JavaScript's `Date.prototype.getDate()`. #[inline] - pub fn get_date(&self, context: &mut Context<'_>) -> JsResult { + pub fn get_date(&self, context: &mut Context) -> JsResult { Date::get_date::(&self.inner.clone().into(), &[JsValue::null()], context) } @@ -112,7 +112,7 @@ impl JsDate { /// /// Same as JavaScript's `Date.prototype.getDay()`. #[inline] - pub fn get_day(&self, context: &mut Context<'_>) -> JsResult { + pub fn get_day(&self, context: &mut Context) -> JsResult { Date::get_day::(&self.inner.clone().into(), &[JsValue::null()], context) } @@ -121,7 +121,7 @@ impl JsDate { /// /// Same as JavaScript's `Date.prototype.getFullYear()`. #[inline] - pub fn get_full_year(&self, context: &mut Context<'_>) -> JsResult { + pub fn get_full_year(&self, context: &mut Context) -> JsResult { Date::get_full_year::(&self.inner.clone().into(), &[JsValue::null()], context) } @@ -129,7 +129,7 @@ impl JsDate { /// /// Same as JavaScript's `Date.prototype.getHours()`. #[inline] - pub fn get_hours(&self, context: &mut Context<'_>) -> JsResult { + pub fn get_hours(&self, context: &mut Context) -> JsResult { Date::get_hours::(&self.inner.clone().into(), &[JsValue::null()], context) } @@ -138,7 +138,7 @@ impl JsDate { /// /// Same as JavaScript's `Date.prototype.getMilliseconds()`. #[inline] - pub fn get_milliseconds(&self, context: &mut Context<'_>) -> JsResult { + pub fn get_milliseconds(&self, context: &mut Context) -> JsResult { Date::get_milliseconds::(&self.inner.clone().into(), &[JsValue::null()], context) } @@ -146,7 +146,7 @@ impl JsDate { /// /// Same as JavaScript's `Date.prototype.getMinutes()`. #[inline] - pub fn get_minutes(&self, context: &mut Context<'_>) -> JsResult { + pub fn get_minutes(&self, context: &mut Context) -> JsResult { Date::get_minutes::(&self.inner.clone().into(), &[JsValue::null()], context) } @@ -154,7 +154,7 @@ impl JsDate { /// /// Same as JavaScript's `Date.prototype.getMonth()`. #[inline] - pub fn get_month(&self, context: &mut Context<'_>) -> JsResult { + pub fn get_month(&self, context: &mut Context) -> JsResult { Date::get_month::(&self.inner.clone().into(), &[JsValue::null()], context) } @@ -162,7 +162,7 @@ impl JsDate { /// /// Same as JavaScript's `Date.prototype.getSeconds()`. #[inline] - pub fn get_seconds(&self, context: &mut Context<'_>) -> JsResult { + pub fn get_seconds(&self, context: &mut Context) -> JsResult { Date::get_seconds::(&self.inner.clone().into(), &[JsValue::null()], context) } @@ -172,7 +172,7 @@ impl JsDate { /// /// Same as JavaScript's `Date.prototype.getTime()`. #[inline] - pub fn get_time(&self, context: &mut Context<'_>) -> JsResult { + pub fn get_time(&self, context: &mut Context) -> JsResult { Date::get_time(&self.inner.clone().into(), &[JsValue::null()], context) } @@ -180,7 +180,7 @@ impl JsDate { /// /// Same as JavaScript's `Date.prototype.getTimezoneOffset()`. #[inline] - pub fn get_timezone_offset(&self, context: &mut Context<'_>) -> JsResult { + pub fn get_timezone_offset(&self, context: &mut Context) -> JsResult { Date::get_timezone_offset(&self.inner.clone().into(), &[JsValue::Null], context) } @@ -189,7 +189,7 @@ impl JsDate { /// /// Same as JavaScript's `Date.prototype.getUTCDate()`. #[inline] - pub fn get_utc_date(&self, context: &mut Context<'_>) -> JsResult { + pub fn get_utc_date(&self, context: &mut Context) -> JsResult { Date::get_date::(&self.inner.clone().into(), &[JsValue::null()], context) } @@ -198,7 +198,7 @@ impl JsDate { /// /// Same as JavaScript's `Date.prototype.getUTCDay()`. #[inline] - pub fn get_utc_day(&self, context: &mut Context<'_>) -> JsResult { + pub fn get_utc_day(&self, context: &mut Context) -> JsResult { Date::get_day::(&self.inner.clone().into(), &[JsValue::null()], context) } @@ -207,7 +207,7 @@ impl JsDate { /// /// Same as JavaScript's `Date.prototype.getUTCFullYear()`. #[inline] - pub fn get_utc_full_year(&self, context: &mut Context<'_>) -> JsResult { + pub fn get_utc_full_year(&self, context: &mut Context) -> JsResult { Date::get_full_year::(&self.inner.clone().into(), &[JsValue::null()], context) } @@ -216,7 +216,7 @@ impl JsDate { /// /// Same as JavaScript's `Date.prototype.getUTCHours()`. #[inline] - pub fn get_utc_hours(&self, context: &mut Context<'_>) -> JsResult { + pub fn get_utc_hours(&self, context: &mut Context) -> JsResult { Date::get_hours::(&self.inner.clone().into(), &[JsValue::null()], context) } @@ -225,7 +225,7 @@ impl JsDate { /// /// Same as JavaScript's `Date.prototype.getUTCMilliseconds()`. #[inline] - pub fn get_utc_milliseconds(&self, context: &mut Context<'_>) -> JsResult { + pub fn get_utc_milliseconds(&self, context: &mut Context) -> JsResult { Date::get_milliseconds::(&self.inner.clone().into(), &[JsValue::null()], context) } @@ -234,7 +234,7 @@ impl JsDate { /// /// Same as JavaScript's `Date.prototype.getUTCMinutes()`. #[inline] - pub fn get_utc_minutes(&self, context: &mut Context<'_>) -> JsResult { + pub fn get_utc_minutes(&self, context: &mut Context) -> JsResult { Date::get_minutes::(&self.inner.clone().into(), &[JsValue::null()], context) } @@ -243,7 +243,7 @@ impl JsDate { /// /// Same as JavaScript's `Date.prototype.getUTCMonth()`. #[inline] - pub fn get_utc_month(&self, context: &mut Context<'_>) -> JsResult { + pub fn get_utc_month(&self, context: &mut Context) -> JsResult { Date::get_month::(&self.inner.clone().into(), &[JsValue::null()], context) } @@ -252,7 +252,7 @@ impl JsDate { /// /// Same as JavaScript's `Date.prototype.getUTCSeconds()`. #[inline] - pub fn get_utc_seconds(&self, context: &mut Context<'_>) -> JsResult { + pub fn get_utc_seconds(&self, context: &mut Context) -> JsResult { Date::get_seconds::(&self.inner.clone().into(), &[JsValue::null()], context) } @@ -263,7 +263,7 @@ impl JsDate { /// the UNIX epoch and the given date. /// /// Same as JavaScript's `Date.prototype.setDate()`. - pub fn set_date(&self, value: T, context: &mut Context<'_>) -> JsResult + pub fn set_date(&self, value: T, context: &mut Context) -> JsResult where T: Into, { @@ -278,11 +278,7 @@ impl JsDate { /// /// Same as JavaScript's `Date.prototype.setFullYear()`. #[inline] - pub fn set_full_year( - &self, - values: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub fn set_full_year(&self, values: &[JsValue], context: &mut Context) -> JsResult { Date::set_full_year::(&self.inner.clone().into(), values, context) } @@ -293,7 +289,7 @@ impl JsDate { /// /// Same as JavaScript's `Date.prototype.setHours()`. #[inline] - pub fn set_hours(&self, values: &[JsValue], context: &mut Context<'_>) -> JsResult { + pub fn set_hours(&self, values: &[JsValue], context: &mut Context) -> JsResult { Date::set_hours::(&self.inner.clone().into(), values, context) } @@ -303,7 +299,7 @@ impl JsDate { /// the UNIX epoch and updated date. /// /// Same as JavaScript's `Date.prototype.setMilliseconds()`. - pub fn set_milliseconds(&self, value: T, context: &mut Context<'_>) -> JsResult + pub fn set_milliseconds(&self, value: T, context: &mut Context) -> JsResult where T: Into, { @@ -317,7 +313,7 @@ impl JsDate { /// /// Same as JavaScript's `Date.prototype.setMinutes()`. #[inline] - pub fn set_minutes(&self, values: &[JsValue], context: &mut Context<'_>) -> JsResult { + pub fn set_minutes(&self, values: &[JsValue], context: &mut Context) -> JsResult { Date::set_minutes::(&self.inner.clone().into(), values, context) } @@ -328,7 +324,7 @@ impl JsDate { /// /// Same as JavaScript's `Date.prototype.setMonth()`. #[inline] - pub fn set_month(&self, values: &[JsValue], context: &mut Context<'_>) -> JsResult { + pub fn set_month(&self, values: &[JsValue], context: &mut Context) -> JsResult { Date::set_month::(&self.inner.clone().into(), values, context) } @@ -339,7 +335,7 @@ impl JsDate { /// /// Same as JavaScript's `Date.prototype.setSeconds()`. #[inline] - pub fn set_seconds(&self, values: &[JsValue], context: &mut Context<'_>) -> JsResult { + pub fn set_seconds(&self, values: &[JsValue], context: &mut Context) -> JsResult { Date::set_seconds::(&self.inner.clone().into(), values, context) } @@ -351,7 +347,7 @@ impl JsDate { /// the UNIX epoch and the updated date. /// /// Same as JavaScript's `Date.prototype.setTime()`. - pub fn set_time(&self, value: T, context: &mut Context<'_>) -> JsResult + pub fn set_time(&self, value: T, context: &mut Context) -> JsResult where T: Into, { @@ -365,7 +361,7 @@ impl JsDate { /// the UNIX epoch and the updated date. /// /// Same as JavaScript's `Date.prototype.setUTCDate()`. - pub fn set_utc_date(&self, value: T, context: &mut Context<'_>) -> JsResult + pub fn set_utc_date(&self, value: T, context: &mut Context) -> JsResult where T: Into, { @@ -383,7 +379,7 @@ impl JsDate { pub fn set_utc_full_year( &self, values: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { Date::set_full_year::(&self.inner.clone().into(), values, context) } @@ -395,11 +391,7 @@ impl JsDate { /// /// Same as JavaScript's `Date.prototype.setUTCHours()`. #[inline] - pub fn set_utc_hours( - &self, - values: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub fn set_utc_hours(&self, values: &[JsValue], context: &mut Context) -> JsResult { Date::set_hours::(&self.inner.clone().into(), values, context) } @@ -409,7 +401,7 @@ impl JsDate { /// the UNIX epoch and the updated date. /// /// Same as JavaScript's `Date.prototype.setUTCMilliseconds()`. - pub fn set_utc_milliseconds(&self, value: T, context: &mut Context<'_>) -> JsResult + pub fn set_utc_milliseconds(&self, value: T, context: &mut Context) -> JsResult where T: Into, { @@ -423,11 +415,7 @@ impl JsDate { /// /// Same as JavaScript's `Date.prototype.setUTCMinutes()`. #[inline] - pub fn set_utc_minutes( - &self, - values: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub fn set_utc_minutes(&self, values: &[JsValue], context: &mut Context) -> JsResult { Date::set_minutes::(&self.inner.clone().into(), values, context) } @@ -438,11 +426,7 @@ impl JsDate { /// /// Same as JavaScript's `Date.prototype.setUTCMonth()`. #[inline] - pub fn set_utc_month( - &self, - values: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub fn set_utc_month(&self, values: &[JsValue], context: &mut Context) -> JsResult { Date::set_month::(&self.inner.clone().into(), values, context) } @@ -453,11 +437,7 @@ impl JsDate { /// /// Same as JavaScript's `Date.prototype.setUTCSeconds()`. #[inline] - pub fn set_utc_seconds( - &self, - values: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub fn set_utc_seconds(&self, values: &[JsValue], context: &mut Context) -> JsResult { Date::set_seconds::(&self.inner.clone().into(), values, context) } @@ -465,7 +445,7 @@ impl JsDate { /// /// Same as JavaScript's `Date.prototype.toDateString()`. #[inline] - pub fn to_date_string(&self, context: &mut Context<'_>) -> JsResult { + pub fn to_date_string(&self, context: &mut Context) -> JsResult { Date::to_date_string(&self.inner.clone().into(), &[JsValue::Null], context) } @@ -476,7 +456,7 @@ impl JsDate { /// Same as JavaScript's legacy `Date.prototype.toGMTString()` #[deprecated] #[inline] - pub fn to_gmt_string(&self, context: &mut Context<'_>) -> JsResult { + pub fn to_gmt_string(&self, context: &mut Context) -> JsResult { Date::to_utc_string(&self.inner.clone().into(), &[JsValue::Null], context) } @@ -485,7 +465,7 @@ impl JsDate { /// /// Same as JavaScript's `Date.prototype.toISOString()`. #[inline] - pub fn to_iso_string(&self, context: &mut Context<'_>) -> JsResult { + pub fn to_iso_string(&self, context: &mut Context) -> JsResult { Date::to_iso_string(&self.inner.clone().into(), &[JsValue::Null], context) } @@ -493,7 +473,7 @@ impl JsDate { /// /// Same as JavaScript's `Date.prototype.toJSON()`. #[inline] - pub fn to_json(&self, context: &mut Context<'_>) -> JsResult { + pub fn to_json(&self, context: &mut Context) -> JsResult { Date::to_json(&self.inner.clone().into(), &[JsValue::Null], context) } @@ -506,7 +486,7 @@ impl JsDate { pub fn to_local_date_string( &self, values: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { Date::to_locale_date_string(&self.inner.clone().into(), values, context) } @@ -516,11 +496,7 @@ impl JsDate { /// /// Same as JavaScript's `Date.prototype.toLocaleDateString()`. #[inline] - pub fn to_locale_string( - &self, - values: &[JsValue], - context: &mut Context<'_>, - ) -> JsResult { + pub fn to_locale_string(&self, values: &[JsValue], context: &mut Context) -> JsResult { Date::to_locale_string(&self.inner.clone().into(), values, context) } @@ -531,7 +507,7 @@ impl JsDate { pub fn to_locale_time_string( &self, values: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { Date::to_locale_time_string(&self.inner.clone().into(), values, context) } @@ -540,7 +516,7 @@ impl JsDate { /// /// Same as JavaScript's `Date.prototype.toString()`. #[inline] - pub fn to_string(&self, context: &mut Context<'_>) -> JsResult { + pub fn to_string(&self, context: &mut Context) -> JsResult { Date::to_string(&self.inner.clone().into(), &[JsValue::Null], context) } @@ -548,7 +524,7 @@ impl JsDate { /// /// Same as JavaScript's `Date.prototype.toTimeString()`. #[inline] - pub fn to_time_string(&self, context: &mut Context<'_>) -> JsResult { + pub fn to_time_string(&self, context: &mut Context) -> JsResult { Date::to_time_string(&self.inner.clone().into(), &[JsValue::Null], context) } @@ -556,7 +532,7 @@ impl JsDate { /// /// Same as JavaScript's `Date.prototype.toUTCString()`. #[inline] - pub fn to_utc_string(&self, context: &mut Context<'_>) -> JsResult { + pub fn to_utc_string(&self, context: &mut Context) -> JsResult { Date::to_utc_string(&self.inner.clone().into(), &[JsValue::Null], context) } @@ -564,12 +540,12 @@ impl JsDate { /// /// Same as JavaScript's `Date.prototype.valueOf()`. #[inline] - pub fn value_of(&self, context: &mut Context<'_>) -> JsResult { + pub fn value_of(&self, context: &mut Context) -> JsResult { Date::value_of(&self.inner.clone().into(), &[JsValue::Null], context) } /// Utility create a `Date` object from RFC3339 string - pub fn new_from_parse(value: &JsValue, context: &mut Context<'_>) -> JsResult { + pub fn new_from_parse(value: &JsValue, context: &mut Context) -> JsResult { let prototype = context.intrinsics().constructors().date().prototype(); let string = value .to_string(context)? @@ -615,7 +591,7 @@ impl Deref for JsDate { impl JsObjectType for JsDate {} impl TryFromJs for JsDate { - fn try_from_js(value: &JsValue, _context: &mut Context<'_>) -> JsResult { + fn try_from_js(value: &JsValue, _context: &mut Context) -> JsResult { match value { JsValue::Object(o) => Self::from_object(o.clone()), _ => Err(JsNativeError::typ() diff --git a/boa_engine/src/object/builtins/jsfunction.rs b/boa_engine/src/object/builtins/jsfunction.rs index 046f68a2f0d..403f08e8ac6 100644 --- a/boa_engine/src/object/builtins/jsfunction.rs +++ b/boa_engine/src/object/builtins/jsfunction.rs @@ -86,7 +86,7 @@ impl Deref for JsFunction { impl JsObjectType for JsFunction {} impl TryFromJs for JsFunction { - fn try_from_js(value: &JsValue, _context: &mut Context<'_>) -> JsResult { + fn try_from_js(value: &JsValue, _context: &mut Context) -> JsResult { match value { JsValue::Object(o) => Self::from_object(o.clone()).ok_or_else(|| { JsNativeError::typ() diff --git a/boa_engine/src/object/builtins/jsgenerator.rs b/boa_engine/src/object/builtins/jsgenerator.rs index c2b745c0a7d..41b2e7a1f91 100644 --- a/boa_engine/src/object/builtins/jsgenerator.rs +++ b/boa_engine/src/object/builtins/jsgenerator.rs @@ -31,7 +31,7 @@ impl JsGenerator { /// Calls `Generator.prototype.next()` /// /// This method returns an object with the properties `done` and `value` - pub fn next(&self, value: T, context: &mut Context<'_>) -> JsResult + pub fn next(&self, value: T, context: &mut Context) -> JsResult where T: Into, { @@ -41,7 +41,7 @@ impl JsGenerator { /// Calls `Generator.prototype.return()` /// /// This method returns the given value and finishes the generator - pub fn r#return(&self, value: T, context: &mut Context<'_>) -> JsResult + pub fn r#return(&self, value: T, context: &mut Context) -> JsResult where T: Into, { @@ -52,7 +52,7 @@ impl JsGenerator { /// /// This method resumes the execution of a generator by throwing an error and returning an /// an object with the properties `done` and `value` - pub fn throw(&self, value: T, context: &mut Context<'_>) -> JsResult + pub fn throw(&self, value: T, context: &mut Context) -> JsResult where T: Into, { @@ -86,7 +86,7 @@ impl Deref for JsGenerator { impl JsObjectType for JsGenerator {} impl TryFromJs for JsGenerator { - fn try_from_js(value: &JsValue, _context: &mut Context<'_>) -> JsResult { + fn try_from_js(value: &JsValue, _context: &mut Context) -> JsResult { match value { JsValue::Object(o) => Self::from_object(o.clone()), _ => Err(JsNativeError::typ() diff --git a/boa_engine/src/object/builtins/jsmap.rs b/boa_engine/src/object/builtins/jsmap.rs index 074602b7ab7..3764f00fd94 100644 --- a/boa_engine/src/object/builtins/jsmap.rs +++ b/boa_engine/src/object/builtins/jsmap.rs @@ -91,7 +91,7 @@ impl JsMap { /// let map = JsMap::new(context); /// ``` #[inline] - pub fn new(context: &mut Context<'_>) -> Self { + pub fn new(context: &mut Context) -> Self { let map = Self::create_map(context); Self { inner: map } } @@ -123,7 +123,7 @@ impl JsMap { /// # Ok(()) /// # } /// ``` - pub fn from_js_iterable(iterable: &JsValue, context: &mut Context<'_>) -> JsResult { + pub fn from_js_iterable(iterable: &JsValue, context: &mut Context) -> JsResult { // Create a new map object. let map = Self::create_map(context); @@ -186,7 +186,7 @@ impl JsMap { } // Utility function to generate the default `Map` object. - fn create_map(context: &mut Context<'_>) -> JsObject { + fn create_map(context: &mut Context) -> JsObject { // Get default Map prototype let prototype = context.intrinsics().constructors().map().prototype(); @@ -200,7 +200,7 @@ impl JsMap { /// Returns a new [`JsMapIterator`] object that yields the `[key, value]` pairs within the [`JsMap`] in insertion order. #[inline] - pub fn entries(&self, context: &mut Context<'_>) -> JsResult { + pub fn entries(&self, context: &mut Context) -> JsResult { let iterator_record = Map::entries(&self.inner.clone().into(), &[], context)? .get_iterator(context, None, None)?; let map_iterator_object = iterator_record.iterator(); @@ -209,7 +209,7 @@ impl JsMap { /// Returns a new [`JsMapIterator`] object that yields the `key` for each element within the [`JsMap`] in insertion order. #[inline] - pub fn keys(&self, context: &mut Context<'_>) -> JsResult { + pub fn keys(&self, context: &mut Context) -> JsResult { let iterator_record = Map::keys(&self.inner.clone().into(), &[], context)? .get_iterator(context, None, None)?; let map_iterator_object = iterator_record.iterator(); @@ -240,7 +240,7 @@ impl JsMap { /// # Ok(()) /// # } /// ``` - pub fn set(&self, key: K, value: V, context: &mut Context<'_>) -> JsResult + pub fn set(&self, key: K, value: V, context: &mut Context) -> JsResult where K: Into, V: Into, @@ -274,7 +274,7 @@ impl JsMap { /// # } /// ``` #[inline] - pub fn get_size(&self, context: &mut Context<'_>) -> JsResult { + pub fn get_size(&self, context: &mut Context) -> JsResult { Map::get_size(&self.inner.clone().into(), &[], context) } @@ -303,7 +303,7 @@ impl JsMap { /// # Ok(()) /// # } /// ``` - pub fn delete(&self, key: T, context: &mut Context<'_>) -> JsResult + pub fn delete(&self, key: T, context: &mut Context) -> JsResult where T: Into, { @@ -330,7 +330,7 @@ impl JsMap { /// # Ok(()) /// # } /// ``` - pub fn get(&self, key: T, context: &mut Context<'_>) -> JsResult + pub fn get(&self, key: T, context: &mut Context) -> JsResult where T: Into, { @@ -359,7 +359,7 @@ impl JsMap { /// # } /// ``` #[inline] - pub fn clear(&self, context: &mut Context<'_>) -> JsResult { + pub fn clear(&self, context: &mut Context) -> JsResult { Map::clear(&self.inner.clone().into(), &[], context) } @@ -383,7 +383,7 @@ impl JsMap { /// # Ok(()) /// # } /// ``` - pub fn has(&self, key: T, context: &mut Context<'_>) -> JsResult + pub fn has(&self, key: T, context: &mut Context) -> JsResult where T: Into, { @@ -396,7 +396,7 @@ impl JsMap { &self, callback: JsFunction, this_arg: JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { Map::for_each( &self.inner.clone().into(), @@ -407,7 +407,7 @@ impl JsMap { /// Returns a new [`JsMapIterator`] object that yields the `value` for each element within the [`JsMap`] in insertion order. #[inline] - pub fn values(&self, context: &mut Context<'_>) -> JsResult { + pub fn values(&self, context: &mut Context) -> JsResult { let iterator_record = Map::values(&self.inner.clone().into(), &[], context)? .get_iterator(context, None, None)?; let map_iterator_object = iterator_record.iterator(); @@ -441,7 +441,7 @@ impl Deref for JsMap { impl JsObjectType for JsMap {} impl TryFromJs for JsMap { - fn try_from_js(value: &JsValue, _context: &mut Context<'_>) -> JsResult { + fn try_from_js(value: &JsValue, _context: &mut Context) -> JsResult { match value { JsValue::Object(o) => Self::from_object(o.clone()), _ => Err(JsNativeError::typ() diff --git a/boa_engine/src/object/builtins/jsmap_iterator.rs b/boa_engine/src/object/builtins/jsmap_iterator.rs index cc1a72a06c0..156c8045852 100644 --- a/boa_engine/src/object/builtins/jsmap_iterator.rs +++ b/boa_engine/src/object/builtins/jsmap_iterator.rs @@ -30,7 +30,7 @@ impl JsMapIterator { } /// Advances the `JsMapIterator` and gets the next result in the `JsMap` - pub fn next(&self, context: &mut Context<'_>) -> JsResult { + pub fn next(&self, context: &mut Context) -> JsResult { MapIterator::next(&self.inner.clone().into(), &[], context) } } @@ -61,7 +61,7 @@ impl Deref for JsMapIterator { impl JsObjectType for JsMapIterator {} impl TryFromJs for JsMapIterator { - fn try_from_js(value: &JsValue, _context: &mut Context<'_>) -> JsResult { + fn try_from_js(value: &JsValue, _context: &mut Context) -> JsResult { match value { JsValue::Object(o) => Self::from_object(o.clone()), _ => Err(JsNativeError::typ() diff --git a/boa_engine/src/object/builtins/jspromise.rs b/boa_engine/src/object/builtins/jspromise.rs index 9d694020802..8e8b7566e77 100644 --- a/boa_engine/src/object/builtins/jspromise.rs +++ b/boa_engine/src/object/builtins/jspromise.rs @@ -161,9 +161,9 @@ impl JsPromise { /// ``` /// /// [`Promise()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/Promise - pub fn new(executor: F, context: &mut Context<'_>) -> Self + pub fn new(executor: F, context: &mut Context) -> Self where - F: FnOnce(&ResolvingFunctions, &mut Context<'_>) -> JsResult, + F: FnOnce(&ResolvingFunctions, &mut Context) -> JsResult, { let promise = JsObject::from_proto_and_data_with_shared_shape( context.root_shape(), @@ -215,7 +215,7 @@ impl JsPromise { /// # } /// ``` #[inline] - pub fn new_pending(context: &mut Context<'_>) -> (Self, ResolvingFunctions) { + pub fn new_pending(context: &mut Context) -> (Self, ResolvingFunctions) { let promise = JsObject::from_proto_and_data_with_shared_shape( context.root_shape(), context.intrinsics().constructors().promise().prototype(), @@ -297,7 +297,7 @@ impl JsPromise { /// ``` /// /// [async_fn]: crate::native_function::NativeFunction::from_async_fn - pub fn from_future(future: Fut, context: &mut Context<'_>) -> Self + pub fn from_future(future: Fut, context: &mut Context) -> Self where Fut: std::future::IntoFuture> + 'static, { @@ -351,7 +351,7 @@ impl JsPromise { /// /// [`Promise.resolve()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/resolve /// [thenables]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise#thenables - pub fn resolve>(value: V, context: &mut Context<'_>) -> Self { + pub fn resolve>(value: V, context: &mut Context) -> Self { Promise::promise_resolve( &context.intrinsics().constructors().promise().constructor(), value.into(), @@ -392,7 +392,7 @@ impl JsPromise { /// /// [`Promise.reject`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/reject /// [thenable]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise#thenables - pub fn reject>(error: E, context: &mut Context<'_>) -> Self { + pub fn reject>(error: E, context: &mut Context) -> Self { Promise::promise_reject( &context.intrinsics().constructors().promise().constructor(), &error.into(), @@ -505,7 +505,7 @@ impl JsPromise { &self, on_fulfilled: Option, on_rejected: Option, - context: &mut Context<'_>, + context: &mut Context, ) -> Self { Promise::inner_then(self, on_fulfilled, on_rejected, context) .and_then(Self::from_object) @@ -566,7 +566,7 @@ impl JsPromise { /// [then]: JsPromise::then #[inline] #[allow(clippy::return_self_not_must_use)] // Could just be used to add a handler on an existing promise - pub fn catch(&self, on_rejected: JsFunction, context: &mut Context<'_>) -> Self { + pub fn catch(&self, on_rejected: JsFunction, context: &mut Context) -> Self { self.then(None, Some(on_rejected), context) } @@ -644,7 +644,7 @@ impl JsPromise { /// [then]: JsPromise::then #[inline] #[allow(clippy::return_self_not_must_use)] // Could just be used to add a handler on an existing promise - pub fn finally(&self, on_finally: JsFunction, context: &mut Context<'_>) -> Self { + pub fn finally(&self, on_finally: JsFunction, context: &mut Context) -> Self { let (then, catch) = Promise::then_catch_finally_closures( context.intrinsics().constructors().promise().constructor(), on_finally, @@ -711,7 +711,7 @@ impl JsPromise { /// ``` /// /// [`Promise.all`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all - pub fn all(promises: I, context: &mut Context<'_>) -> Self + pub fn all(promises: I, context: &mut Context) -> Self where I: IntoIterator, { @@ -800,7 +800,7 @@ impl JsPromise { /// ``` /// /// [`Promise.allSettled`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/allSettled - pub fn all_settled(promises: I, context: &mut Context<'_>) -> Self + pub fn all_settled(promises: I, context: &mut Context) -> Self where I: IntoIterator, { @@ -863,7 +863,7 @@ impl JsPromise { /// ``` /// /// [`Promise.any`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/any - pub fn any(promises: I, context: &mut Context<'_>) -> Self + pub fn any(promises: I, context: &mut Context) -> Self where I: IntoIterator, { @@ -937,7 +937,7 @@ impl JsPromise { /// ``` /// /// [`Promise.race`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/race - pub fn race(promises: I, context: &mut Context<'_>) -> Self + pub fn race(promises: I, context: &mut Context) -> Self where I: IntoIterator, { @@ -1000,7 +1000,7 @@ impl JsPromise { /// # Ok(()) /// # } /// ``` - pub fn into_js_future(self, context: &mut Context<'_>) -> JsFuture { + pub fn into_js_future(self, context: &mut Context) -> JsFuture { // Mostly based from: // https://docs.rs/wasm-bindgen-futures/0.4.37/src/wasm_bindgen_futures/lib.rs.html#109-168 @@ -1092,7 +1092,7 @@ impl std::ops::Deref for JsPromise { impl JsObjectType for JsPromise {} impl TryFromJs for JsPromise { - fn try_from_js(value: &JsValue, _context: &mut Context<'_>) -> JsResult { + fn try_from_js(value: &JsValue, _context: &mut Context) -> JsResult { match value { JsValue::Object(o) => Self::from_object(o.clone()), _ => Err(JsNativeError::typ() diff --git a/boa_engine/src/object/builtins/jsproxy.rs b/boa_engine/src/object/builtins/jsproxy.rs index b3d005c2544..3a316b17196 100644 --- a/boa_engine/src/object/builtins/jsproxy.rs +++ b/boa_engine/src/object/builtins/jsproxy.rs @@ -75,7 +75,7 @@ impl std::ops::Deref for JsProxy { impl JsObjectType for JsProxy {} impl TryFromJs for JsProxy { - fn try_from_js(value: &JsValue, _context: &mut Context<'_>) -> JsResult { + fn try_from_js(value: &JsValue, _context: &mut Context) -> JsResult { match value { JsValue::Object(o) => Self::from_object(o.clone()), _ => Err(JsNativeError::typ() @@ -107,7 +107,7 @@ impl JsRevocableProxy { /// Disables the traps of the internal `proxy` object, essentially /// making it unusable and throwing `TypeError`s for all the traps. #[inline] - pub fn revoke(self, context: &mut Context<'_>) -> JsResult<()> { + pub fn revoke(self, context: &mut Context) -> JsResult<()> { self.revoker.call(&JsValue::undefined(), &[], context)?; Ok(()) } @@ -397,7 +397,7 @@ impl JsProxyBuilder { /// [`JsObject`] in case there's a need to manipulate the returned object /// inside Rust code. #[must_use] - pub fn build(self, context: &mut Context<'_>) -> JsProxy { + pub fn build(self, context: &mut Context) -> JsProxy { let handler = JsObject::with_object_proto(context.intrinsics()); if let Some(apply) = self.apply { @@ -548,7 +548,7 @@ impl JsProxyBuilder { /// revoker in case there's a need to manipulate the returned objects /// inside Rust code. #[must_use] - pub fn build_revocable(self, context: &mut Context<'_>) -> JsRevocableProxy { + pub fn build_revocable(self, context: &mut Context) -> JsRevocableProxy { let proxy = self.build(context); let revoker = Proxy::revoker(proxy.inner.clone(), context); diff --git a/boa_engine/src/object/builtins/jsregexp.rs b/boa_engine/src/object/builtins/jsregexp.rs index fc5b2e68a97..e262e251f44 100644 --- a/boa_engine/src/object/builtins/jsregexp.rs +++ b/boa_engine/src/object/builtins/jsregexp.rs @@ -56,7 +56,7 @@ impl JsRegExp { /// # Ok(()) /// # } /// ``` - pub fn new(pattern: S, flags: S, context: &mut Context<'_>) -> JsResult + pub fn new(pattern: S, flags: S, context: &mut Context) -> JsResult where S: Into, { @@ -82,49 +82,49 @@ impl JsRegExp { /// Returns a boolean value for whether the `d` flag is present in `JsRegExp` flags #[inline] - pub fn has_indices(&self, context: &mut Context<'_>) -> JsResult { + pub fn has_indices(&self, context: &mut Context) -> JsResult { RegExp::get_has_indices(&self.inner.clone().into(), &[], context) .map(|v| v.as_boolean().expect("value must be a bool")) } /// Returns a boolean value for whether the `g` flag is present in `JsRegExp` flags #[inline] - pub fn global(&self, context: &mut Context<'_>) -> JsResult { + pub fn global(&self, context: &mut Context) -> JsResult { RegExp::get_global(&self.inner.clone().into(), &[], context) .map(|v| v.as_boolean().expect("value must be a bool")) } /// Returns a boolean value for whether the `i` flag is present in `JsRegExp` flags #[inline] - pub fn ignore_case(&self, context: &mut Context<'_>) -> JsResult { + pub fn ignore_case(&self, context: &mut Context) -> JsResult { RegExp::get_ignore_case(&self.inner.clone().into(), &[], context) .map(|v| v.as_boolean().expect("value must be a bool")) } /// Returns a boolean value for whether the `m` flag is present in `JsRegExp` flags #[inline] - pub fn multiline(&self, context: &mut Context<'_>) -> JsResult { + pub fn multiline(&self, context: &mut Context) -> JsResult { RegExp::get_multiline(&self.inner.clone().into(), &[], context) .map(|v| v.as_boolean().expect("value must be a bool")) } /// Returns a boolean value for whether the `s` flag is present in `JsRegExp` flags #[inline] - pub fn dot_all(&self, context: &mut Context<'_>) -> JsResult { + pub fn dot_all(&self, context: &mut Context) -> JsResult { RegExp::get_dot_all(&self.inner.clone().into(), &[], context) .map(|v| v.as_boolean().expect("value must be a bool")) } /// Returns a boolean value for whether the `u` flag is present in `JsRegExp` flags #[inline] - pub fn unicode(&self, context: &mut Context<'_>) -> JsResult { + pub fn unicode(&self, context: &mut Context) -> JsResult { RegExp::get_unicode(&self.inner.clone().into(), &[], context) .map(|v| v.as_boolean().expect("value must be a bool")) } /// Returns a boolean value for whether the `y` flag is present in `JsRegExp` flags #[inline] - pub fn sticky(&self, context: &mut Context<'_>) -> JsResult { + pub fn sticky(&self, context: &mut Context) -> JsResult { RegExp::get_sticky(&self.inner.clone().into(), &[], context) .map(|v| v.as_boolean().expect("value must be a bool")) } @@ -145,7 +145,7 @@ impl JsRegExp { /// # } /// ``` #[inline] - pub fn flags(&self, context: &mut Context<'_>) -> JsResult { + pub fn flags(&self, context: &mut Context) -> JsResult { RegExp::get_flags(&self.inner.clone().into(), &[], context).map(|v| { v.as_string() .expect("value must be string") @@ -170,7 +170,7 @@ impl JsRegExp { /// # } /// ``` #[inline] - pub fn source(&self, context: &mut Context<'_>) -> JsResult { + pub fn source(&self, context: &mut Context) -> JsResult { RegExp::get_source(&self.inner.clone().into(), &[], context).map(|v| { v.as_string() .expect("value must be string") @@ -194,7 +194,7 @@ impl JsRegExp { /// # Ok(()) /// # } /// ``` - pub fn test(&self, search_string: S, context: &mut Context<'_>) -> JsResult + pub fn test(&self, search_string: S, context: &mut Context) -> JsResult where S: Into, { @@ -205,7 +205,7 @@ impl JsRegExp { /// Executes a search for a match in a specified string /// /// Returns a `JsArray` containing matched value and updates the `lastIndex` property, or `None` - pub fn exec(&self, search_string: S, context: &mut Context<'_>) -> JsResult> + pub fn exec(&self, search_string: S, context: &mut Context) -> JsResult> where S: Into, { @@ -237,7 +237,7 @@ impl JsRegExp { /// # } /// ``` #[inline] - pub fn to_string(&self, context: &mut Context<'_>) -> JsResult { + pub fn to_string(&self, context: &mut Context) -> JsResult { RegExp::to_string(&self.inner.clone().into(), &[], context).map(|v| { v.as_string() .expect("value must be a string") @@ -273,7 +273,7 @@ impl Deref for JsRegExp { impl JsObjectType for JsRegExp {} impl TryFromJs for JsRegExp { - fn try_from_js(value: &JsValue, _context: &mut Context<'_>) -> JsResult { + fn try_from_js(value: &JsValue, _context: &mut Context) -> JsResult { match value { JsValue::Object(o) => Self::from_object(o.clone()), _ => Err(JsNativeError::typ() diff --git a/boa_engine/src/object/builtins/jsset.rs b/boa_engine/src/object/builtins/jsset.rs index 8197c134394..cfc63ffd07f 100644 --- a/boa_engine/src/object/builtins/jsset.rs +++ b/boa_engine/src/object/builtins/jsset.rs @@ -23,7 +23,7 @@ impl JsSet { /// Doesn't matches JavaScript `new Set()` as it doesn't takes an iterator /// similar to Rust initialization. #[inline] - pub fn new(context: &mut Context<'_>) -> Self { + pub fn new(context: &mut Context) -> Self { let inner = Set::set_create(None, context); Self { inner } @@ -41,7 +41,7 @@ impl JsSet { /// Returns the Set object with added value. /// /// Same as JavaScript's `set.add(value)`. - pub fn add(&self, value: T, context: &mut Context<'_>) -> JsResult + pub fn add(&self, value: T, context: &mut Context) -> JsResult where T: Into, { @@ -53,7 +53,7 @@ impl JsSet { /// /// Same as JavaScript's `set.add(["one", "two", "three"])` #[inline] - pub fn add_items(&self, items: &[JsValue], context: &mut Context<'_>) -> JsResult { + pub fn add_items(&self, items: &[JsValue], context: &mut Context) -> JsResult { Set::add(&self.inner.clone().into(), items, context) } @@ -62,7 +62,7 @@ impl JsSet { /// /// Same as JavaScript's `set.clear()`. #[inline] - pub fn clear(&self, context: &mut Context<'_>) -> JsResult { + pub fn clear(&self, context: &mut Context) -> JsResult { Set::clear(&self.inner.clone().into(), &[JsValue::Null], context) } @@ -71,7 +71,7 @@ impl JsSet { /// successfully removed or not. /// /// Same as JavaScript's `set.delete(value)`. - pub fn delete(&self, value: T, context: &mut Context<'_>) -> JsResult + pub fn delete(&self, value: T, context: &mut Context) -> JsResult where T: Into, { @@ -86,7 +86,7 @@ impl JsSet { /// with the given value in the Set object or not. /// /// Same as JavaScript's `set.has(value)`. - pub fn has(&self, value: T, context: &mut Context<'_>) -> JsResult + pub fn has(&self, value: T, context: &mut Context) -> JsResult where T: Into, { @@ -102,7 +102,7 @@ impl JsSet { /// /// Same as JavaScript's `set.values()`. #[inline] - pub fn values(&self, context: &mut Context<'_>) -> JsResult { + pub fn values(&self, context: &mut Context) -> JsResult { let iterator_object = Set::values(&self.inner.clone().into(), &[JsValue::Null], context)? .get_iterator(context, None, None)?; @@ -115,7 +115,7 @@ impl JsSet { /// /// Same as JavaScript's `set.keys()`. #[inline] - pub fn keys(&self, context: &mut Context<'_>) -> JsResult { + pub fn keys(&self, context: &mut Context) -> JsResult { let iterator_object = Set::values(&self.inner.clone().into(), &[JsValue::Null], context)? .get_iterator(context, None, None)?; @@ -132,7 +132,7 @@ impl JsSet { &self, callback: JsFunction, this_arg: JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { Set::for_each( &self.inner.clone().into(), @@ -154,7 +154,7 @@ impl JsSet { } /// Utility: Creates a `JsSet` from a `` convertible object. - pub fn from_iter(elements: I, context: &mut Context<'_>) -> Self + pub fn from_iter(elements: I, context: &mut Context) -> Self where I: IntoIterator, { @@ -188,7 +188,7 @@ impl Deref for JsSet { impl JsObjectType for JsSet {} impl TryFromJs for JsSet { - fn try_from_js(value: &JsValue, _context: &mut Context<'_>) -> JsResult { + fn try_from_js(value: &JsValue, _context: &mut Context) -> JsResult { match value { JsValue::Object(o) => Self::from_object(o.clone()), _ => Err(JsNativeError::typ() diff --git a/boa_engine/src/object/builtins/jsset_iterator.rs b/boa_engine/src/object/builtins/jsset_iterator.rs index b0b764eee87..8fe4fc226cc 100644 --- a/boa_engine/src/object/builtins/jsset_iterator.rs +++ b/boa_engine/src/object/builtins/jsset_iterator.rs @@ -30,7 +30,7 @@ impl JsSetIterator { } } /// Advances the `JsSetIterator` and gets the next result in the `JsSet`. - pub fn next(&self, context: &mut Context<'_>) -> JsResult { + pub fn next(&self, context: &mut Context) -> JsResult { SetIterator::next(&self.inner.clone().into(), &[JsValue::Null], context) } } @@ -61,7 +61,7 @@ impl Deref for JsSetIterator { impl JsObjectType for JsSetIterator {} impl TryFromJs for JsSetIterator { - fn try_from_js(value: &JsValue, _context: &mut Context<'_>) -> JsResult { + fn try_from_js(value: &JsValue, _context: &mut Context) -> JsResult { match value { JsValue::Object(o) => Self::from_object(o.clone()), _ => Err(JsNativeError::typ() diff --git a/boa_engine/src/object/builtins/jssharedarraybuffer.rs b/boa_engine/src/object/builtins/jssharedarraybuffer.rs index b78464d8f77..6d674295c71 100644 --- a/boa_engine/src/object/builtins/jssharedarraybuffer.rs +++ b/boa_engine/src/object/builtins/jssharedarraybuffer.rs @@ -18,7 +18,7 @@ pub struct JsSharedArrayBuffer { impl JsSharedArrayBuffer { /// Creates a new [`JsSharedArrayBuffer`] with `byte_length` bytes of allocated space. #[inline] - pub fn new(byte_length: usize, context: &mut Context<'_>) -> JsResult { + pub fn new(byte_length: usize, context: &mut Context) -> JsResult { let inner = SharedArrayBuffer::allocate( &context .intrinsics() @@ -35,7 +35,7 @@ impl JsSharedArrayBuffer { /// Creates a [`JsSharedArrayBuffer`] from a shared raw buffer. #[inline] - pub fn from_buffer(buffer: SharedArrayBuffer, context: &mut Context<'_>) -> Self { + pub fn from_buffer(buffer: SharedArrayBuffer, context: &mut Context) -> Self { let proto = context .intrinsics() .constructors() @@ -114,7 +114,7 @@ impl Deref for JsSharedArrayBuffer { impl JsObjectType for JsSharedArrayBuffer {} impl TryFromJs for JsSharedArrayBuffer { - fn try_from_js(value: &JsValue, _context: &mut Context<'_>) -> JsResult { + fn try_from_js(value: &JsValue, _context: &mut Context) -> JsResult { match value { JsValue::Object(o) => Self::from_object(o.clone()), _ => Err(JsNativeError::typ() diff --git a/boa_engine/src/object/builtins/jstypedarray.rs b/boa_engine/src/object/builtins/jstypedarray.rs index e9ccf9e3683..b4378a3989c 100644 --- a/boa_engine/src/object/builtins/jstypedarray.rs +++ b/boa_engine/src/object/builtins/jstypedarray.rs @@ -38,7 +38,7 @@ impl JsTypedArray { /// /// Same as `array.length` in JavaScript. #[inline] - pub fn length(&self, context: &mut Context<'_>) -> JsResult { + pub fn length(&self, context: &mut Context) -> JsResult { Ok( BuiltinTypedArray::length(&self.inner.clone().into(), &[], context)? .as_number() @@ -49,12 +49,12 @@ impl JsTypedArray { /// Check if the array is empty, i.e. the `length` is zero. #[inline] - pub fn is_empty(&self, context: &mut Context<'_>) -> JsResult { + pub fn is_empty(&self, context: &mut Context) -> JsResult { Ok(self.length(context)? == 0) } /// Calls `TypedArray.prototype.at()`. - pub fn at(&self, index: T, context: &mut Context<'_>) -> JsResult + pub fn at(&self, index: T, context: &mut Context) -> JsResult where T: Into, { @@ -63,7 +63,7 @@ impl JsTypedArray { /// Returns `TypedArray.prototype.byteLength`. #[inline] - pub fn byte_length(&self, context: &mut Context<'_>) -> JsResult { + pub fn byte_length(&self, context: &mut Context) -> JsResult { Ok( BuiltinTypedArray::byte_length(&self.inner.clone().into(), &[], context)? .as_number() @@ -74,7 +74,7 @@ impl JsTypedArray { /// Returns `TypedArray.prototype.byteOffset`. #[inline] - pub fn byte_offset(&self, context: &mut Context<'_>) -> JsResult { + pub fn byte_offset(&self, context: &mut Context) -> JsResult { Ok( BuiltinTypedArray::byte_offset(&self.inner.clone().into(), &[], context)? .as_number() @@ -89,7 +89,7 @@ impl JsTypedArray { value: T, start: Option, end: Option, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult where T: Into, @@ -111,7 +111,7 @@ impl JsTypedArray { &self, predicate: JsFunction, this_arg: Option, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let result = BuiltinTypedArray::every( &self.inner.clone().into(), @@ -130,7 +130,7 @@ impl JsTypedArray { &self, callback: JsFunction, this_arg: Option, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let result = BuiltinTypedArray::some( &self.inner.clone().into(), @@ -145,11 +145,7 @@ impl JsTypedArray { /// Calls `TypedArray.prototype.sort()`. #[inline] - pub fn sort( - &self, - compare_fn: Option, - context: &mut Context<'_>, - ) -> JsResult { + pub fn sort(&self, compare_fn: Option, context: &mut Context) -> JsResult { BuiltinTypedArray::sort( &self.inner.clone().into(), &[compare_fn.into_or_undefined()], @@ -165,7 +161,7 @@ impl JsTypedArray { &self, callback: JsFunction, this_arg: Option, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let object = BuiltinTypedArray::filter( &self.inner.clone().into(), @@ -187,7 +183,7 @@ impl JsTypedArray { &self, callback: JsFunction, this_arg: Option, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let object = BuiltinTypedArray::map( &self.inner.clone().into(), @@ -209,7 +205,7 @@ impl JsTypedArray { &self, callback: JsFunction, initial_value: Option, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { BuiltinTypedArray::reduce( &self.inner.clone().into(), @@ -224,7 +220,7 @@ impl JsTypedArray { &self, callback: JsFunction, initial_value: Option, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { BuiltinTypedArray::reduceright( &self.inner.clone().into(), @@ -235,7 +231,7 @@ impl JsTypedArray { /// Calls `TypedArray.prototype.reverse()`. #[inline] - pub fn reverse(&self, context: &mut Context<'_>) -> JsResult { + pub fn reverse(&self, context: &mut Context) -> JsResult { BuiltinTypedArray::reverse(&self.inner.clone().into(), &[], context)?; Ok(self.clone()) } @@ -246,7 +242,7 @@ impl JsTypedArray { &self, start: Option, end: Option, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let object = BuiltinTypedArray::slice( &self.inner.clone().into(), @@ -268,7 +264,7 @@ impl JsTypedArray { &self, predicate: JsFunction, this_arg: Option, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { BuiltinTypedArray::find( &self.inner.clone().into(), @@ -282,7 +278,7 @@ impl JsTypedArray { &self, search_element: T, from_index: Option, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult> where T: Into, @@ -308,7 +304,7 @@ impl JsTypedArray { &self, search_element: T, from_index: Option, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult> where T: Into, @@ -331,11 +327,7 @@ impl JsTypedArray { /// Calls `TypedArray.prototype.join()`. #[inline] - pub fn join( - &self, - separator: Option, - context: &mut Context<'_>, - ) -> JsResult { + pub fn join(&self, separator: Option, context: &mut Context) -> JsResult { BuiltinTypedArray::join( &self.inner.clone().into(), &[separator.into_or_undefined()], @@ -350,7 +342,7 @@ impl JsTypedArray { /// Calls `TypedArray.prototype.toReversed ( )`. #[inline] - pub fn to_reversed(&self, context: &mut Context<'_>) -> JsResult { + pub fn to_reversed(&self, context: &mut Context) -> JsResult { let array = BuiltinTypedArray::to_reversed(&self.inner.clone().into(), &[], context)?; Ok(Self { @@ -366,7 +358,7 @@ impl JsTypedArray { pub fn to_sorted( &self, compare_fn: Option, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let array = BuiltinTypedArray::to_sorted( &self.inner.clone().into(), @@ -384,7 +376,7 @@ impl JsTypedArray { /// Calls `TypedArray.prototype.with ( index, value )`. #[inline] - pub fn with(&self, index: u64, value: JsValue, context: &mut Context<'_>) -> JsResult { + pub fn with(&self, index: u64, value: JsValue, context: &mut Context) -> JsResult { let array = BuiltinTypedArray::with(&self.inner.clone().into(), &[index.into(), value], context)?; @@ -423,7 +415,7 @@ impl Deref for JsTypedArray { impl JsObjectType for JsTypedArray {} impl TryFromJs for JsTypedArray { - fn try_from_js(value: &JsValue, _context: &mut Context<'_>) -> JsResult { + fn try_from_js(value: &JsValue, _context: &mut Context) -> JsResult { match value { JsValue::Object(o) => Self::from_object(o.clone()), _ => Err(JsNativeError::typ() @@ -474,7 +466,7 @@ macro_rules! JsTypedArrayType { /// Create the typed array from a [`JsArrayBuffer`]. pub fn from_array_buffer( array_buffer: JsArrayBuffer, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let new_target = context .intrinsics() @@ -499,7 +491,7 @@ macro_rules! JsTypedArrayType { } /// Create the typed array from an iterator. - pub fn from_iter(elements: I, context: &mut Context<'_>) -> JsResult + pub fn from_iter(elements: I, context: &mut Context) -> JsResult where I: IntoIterator, { @@ -557,7 +549,7 @@ macro_rules! JsTypedArrayType { } impl TryFromJs for $name { - fn try_from_js(value: &JsValue, _context: &mut Context<'_>) -> JsResult { + fn try_from_js(value: &JsValue, _context: &mut Context) -> JsResult { match value { JsValue::Object(o) => Self::from_object(o.clone()), _ => Err(JsNativeError::typ() diff --git a/boa_engine/src/object/internal_methods/arguments.rs b/boa_engine/src/object/internal_methods/arguments.rs index e086cde3d29..7082e65a69c 100644 --- a/boa_engine/src/object/internal_methods/arguments.rs +++ b/boa_engine/src/object/internal_methods/arguments.rs @@ -25,7 +25,7 @@ pub(crate) static ARGUMENTS_EXOTIC_INTERNAL_METHODS: InternalObjectMethods = pub(crate) fn arguments_exotic_get_own_property( obj: &JsObject, key: &PropertyKey, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult> { // 1. Let desc be OrdinaryGetOwnProperty(args, P). // 2. If desc is undefined, return desc. @@ -70,7 +70,7 @@ pub(crate) fn arguments_exotic_define_own_property( obj: &JsObject, key: &PropertyKey, desc: PropertyDescriptor, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 2. Let isMapped be HasOwnProperty(map, P). let mapped = if let &PropertyKey::Index(index) = &key { @@ -161,7 +161,7 @@ pub(crate) fn arguments_exotic_get( obj: &JsObject, key: &PropertyKey, receiver: JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { if let PropertyKey::Index(index) = key { // 1. Let map be args.[[ParameterMap]]. @@ -194,7 +194,7 @@ pub(crate) fn arguments_exotic_set( key: PropertyKey, value: JsValue, receiver: JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If SameValue(args, Receiver) is false, then // a. Let isMapped be false. @@ -226,7 +226,7 @@ pub(crate) fn arguments_exotic_set( pub(crate) fn arguments_exotic_delete( obj: &JsObject, key: &PropertyKey, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 3. Let result be ? OrdinaryDelete(args, P). let result = super::ordinary_delete(obj, key, context)?; diff --git a/boa_engine/src/object/internal_methods/array.rs b/boa_engine/src/object/internal_methods/array.rs index 0d95759acf8..b0759dc1dbe 100644 --- a/boa_engine/src/object/internal_methods/array.rs +++ b/boa_engine/src/object/internal_methods/array.rs @@ -29,7 +29,7 @@ pub(crate) fn array_exotic_define_own_property( obj: &JsObject, key: &PropertyKey, desc: PropertyDescriptor, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Assert: IsPropertyKey(P) is true. match key { @@ -111,7 +111,7 @@ pub(crate) fn array_exotic_define_own_property( fn array_set_length( obj: &JsObject, desc: PropertyDescriptor, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If Desc.[[Value]] is absent, then let Some(new_len_val) = desc.value() else { diff --git a/boa_engine/src/object/internal_methods/bound_function.rs b/boa_engine/src/object/internal_methods/bound_function.rs index 8ff1da7dcf2..f991ec18bca 100644 --- a/boa_engine/src/object/internal_methods/bound_function.rs +++ b/boa_engine/src/object/internal_methods/bound_function.rs @@ -31,7 +31,7 @@ pub(crate) static BOUND_CONSTRUCTOR_EXOTIC_INTERNAL_METHODS: InternalObjectMetho fn bound_function_exotic_call( obj: &JsObject, argument_count: usize, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let obj = obj.borrow(); let bound_function = obj @@ -70,7 +70,7 @@ fn bound_function_exotic_call( fn bound_function_exotic_construct( function_object: &JsObject, argument_count: usize, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let new_target = context.vm.pop(); diff --git a/boa_engine/src/object/internal_methods/function.rs b/boa_engine/src/object/internal_methods/function.rs index d9139b6c14c..1449f901a3a 100644 --- a/boa_engine/src/object/internal_methods/function.rs +++ b/boa_engine/src/object/internal_methods/function.rs @@ -40,7 +40,7 @@ pub(crate) static CONSTRUCTOR_INTERNAL_METHODS: InternalObjectMethods = Internal pub(crate) fn function_call( function_object: &JsObject, argument_count: usize, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { context.check_runtime_limits()?; @@ -125,7 +125,7 @@ pub(crate) fn function_call( fn function_construct( this_function_object: &JsObject, argument_count: usize, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { context.check_runtime_limits()?; @@ -244,7 +244,7 @@ pub(crate) static NATIVE_CONSTRUCTOR_INTERNAL_METHODS: InternalObjectMethods = pub(crate) fn native_function_call( obj: &JsObject, argument_count: usize, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let args = context.vm.pop_n_values(argument_count); let _func = context.vm.pop(); @@ -294,7 +294,7 @@ pub(crate) fn native_function_call( fn native_function_construct( obj: &JsObject, argument_count: usize, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // We technically don't need this since native functions don't push any new frames to the // vm, but we'll eventually have to combine the native stack with the vm stack. diff --git a/boa_engine/src/object/internal_methods/immutable_prototype.rs b/boa_engine/src/object/internal_methods/immutable_prototype.rs index f9cf56c7410..57c3ccb898f 100644 --- a/boa_engine/src/object/internal_methods/immutable_prototype.rs +++ b/boa_engine/src/object/internal_methods/immutable_prototype.rs @@ -21,7 +21,7 @@ pub(crate) static IMMUTABLE_PROTOTYPE_EXOTIC_INTERNAL_METHODS: InternalObjectMet pub(crate) fn immutable_prototype_exotic_set_prototype_of( obj: &JsObject, val: JsPrototype, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Return ? SetImmutablePrototype(O, V). diff --git a/boa_engine/src/object/internal_methods/integer_indexed.rs b/boa_engine/src/object/internal_methods/integer_indexed.rs index a0c91562138..10353c9b566 100644 --- a/boa_engine/src/object/internal_methods/integer_indexed.rs +++ b/boa_engine/src/object/internal_methods/integer_indexed.rs @@ -62,7 +62,7 @@ fn canonical_numeric_index_string(argument: &JsString) -> Option { pub(crate) fn integer_indexed_exotic_get_own_property( obj: &JsObject, key: &PropertyKey, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult> { let p = match key { PropertyKey::String(key) => { @@ -104,7 +104,7 @@ pub(crate) fn integer_indexed_exotic_get_own_property( pub(crate) fn integer_indexed_exotic_has_property( obj: &JsObject, key: &PropertyKey, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let p = match key { PropertyKey::String(key) => { @@ -135,7 +135,7 @@ pub(crate) fn integer_indexed_exotic_define_own_property( obj: &JsObject, key: &PropertyKey, desc: PropertyDescriptor, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let p = match key { PropertyKey::String(key) => { @@ -197,7 +197,7 @@ pub(crate) fn integer_indexed_exotic_get( obj: &JsObject, key: &PropertyKey, receiver: JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let p = match key { PropertyKey::String(key) => { @@ -230,7 +230,7 @@ pub(crate) fn integer_indexed_exotic_set( key: PropertyKey, value: JsValue, receiver: JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let p = match &key { PropertyKey::String(key) => { @@ -272,7 +272,7 @@ pub(crate) fn integer_indexed_exotic_set( pub(crate) fn integer_indexed_exotic_delete( obj: &JsObject, key: &PropertyKey, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let p = match &key { PropertyKey::String(key) => { @@ -303,7 +303,7 @@ pub(crate) fn integer_indexed_exotic_delete( #[allow(clippy::unnecessary_wraps)] pub(crate) fn integer_indexed_exotic_own_property_keys( obj: &JsObject, - _context: &mut Context<'_>, + _context: &mut Context, ) -> JsResult> { let obj = obj.borrow(); let inner = obj.as_typed_array().expect( @@ -388,7 +388,7 @@ pub(crate) fn integer_indexed_element_set( obj: &JsObject, index: f64, value: &JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult<()> { let obj_borrow = obj.borrow(); let inner = obj_borrow.as_typed_array().expect( diff --git a/boa_engine/src/object/internal_methods/mod.rs b/boa_engine/src/object/internal_methods/mod.rs index de77e14a4b4..fa718a6025b 100644 --- a/boa_engine/src/object/internal_methods/mod.rs +++ b/boa_engine/src/object/internal_methods/mod.rs @@ -38,7 +38,7 @@ impl JsObject { /// /// [spec]: https://tc39.es/ecma262/#sec-ordinary-object-internal-methods-and-internal-slots-getprototypeof #[track_caller] - pub(crate) fn __get_prototype_of__(&self, context: &mut Context<'_>) -> JsResult { + pub(crate) fn __get_prototype_of__(&self, context: &mut Context) -> JsResult { let _timer = Profiler::global().start_event("Object::__get_prototype_of__", "object"); (self.vtable().__get_prototype_of__)(self, context) } @@ -54,7 +54,7 @@ impl JsObject { pub(crate) fn __set_prototype_of__( &self, val: JsPrototype, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let _timer = Profiler::global().start_event("Object::__set_prototype_of__", "object"); (self.vtable().__set_prototype_of__)(self, val, context) @@ -68,7 +68,7 @@ impl JsObject { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-ordinary-object-internal-methods-and-internal-slots-isextensible - pub(crate) fn __is_extensible__(&self, context: &mut Context<'_>) -> JsResult { + pub(crate) fn __is_extensible__(&self, context: &mut Context) -> JsResult { let _timer = Profiler::global().start_event("Object::__is_extensible__", "object"); (self.vtable().__is_extensible__)(self, context) } @@ -81,7 +81,7 @@ impl JsObject { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-ordinary-object-internal-methods-and-internal-slots-preventextensions - pub(crate) fn __prevent_extensions__(&self, context: &mut Context<'_>) -> JsResult { + pub(crate) fn __prevent_extensions__(&self, context: &mut Context) -> JsResult { let _timer = Profiler::global().start_event("Object::__prevent_extensions__", "object"); (self.vtable().__prevent_extensions__)(self, context) } @@ -97,7 +97,7 @@ impl JsObject { pub(crate) fn __get_own_property__( &self, key: &PropertyKey, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult> { let _timer = Profiler::global().start_event("Object::__get_own_property__", "object"); (self.vtable().__get_own_property__)(self, key, context) @@ -115,7 +115,7 @@ impl JsObject { &self, key: &PropertyKey, desc: PropertyDescriptor, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let _timer = Profiler::global().start_event("Object::__define_own_property__", "object"); (self.vtable().__define_own_property__)(self, key, desc, context) @@ -132,7 +132,7 @@ impl JsObject { pub(crate) fn __has_property__( &self, key: &PropertyKey, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let _timer = Profiler::global().start_event("Object::__has_property__", "object"); (self.vtable().__has_property__)(self, key, context) @@ -150,7 +150,7 @@ impl JsObject { &self, key: &PropertyKey, receiver: JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let _timer = Profiler::global().start_event("Object::__get__", "object"); (self.vtable().__get__)(self, key, receiver, context) @@ -169,7 +169,7 @@ impl JsObject { key: PropertyKey, value: JsValue, receiver: JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let _timer = Profiler::global().start_event("Object::__set__", "object"); (self.vtable().__set__)(self, key, value, receiver, context) @@ -183,11 +183,7 @@ impl JsObject { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-ordinary-object-internal-methods-and-internal-slots-delete-p - pub(crate) fn __delete__( - &self, - key: &PropertyKey, - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn __delete__(&self, key: &PropertyKey, context: &mut Context) -> JsResult { let _timer = Profiler::global().start_event("Object::__delete__", "object"); (self.vtable().__delete__)(self, key, context) } @@ -203,7 +199,7 @@ impl JsObject { #[track_caller] pub(crate) fn __own_property_keys__( &self, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult> { let _timer = Profiler::global().start_event("Object::__own_property_keys__", "object"); (self.vtable().__own_property_keys__)(self, context) @@ -283,24 +279,23 @@ pub(crate) static ORDINARY_INTERNAL_METHODS: InternalObjectMethods = InternalObj #[derive(Clone, Copy)] #[allow(clippy::type_complexity)] pub(crate) struct InternalObjectMethods { - pub(crate) __get_prototype_of__: fn(&JsObject, &mut Context<'_>) -> JsResult, - pub(crate) __set_prototype_of__: fn(&JsObject, JsPrototype, &mut Context<'_>) -> JsResult, - pub(crate) __is_extensible__: fn(&JsObject, &mut Context<'_>) -> JsResult, - pub(crate) __prevent_extensions__: fn(&JsObject, &mut Context<'_>) -> JsResult, + pub(crate) __get_prototype_of__: fn(&JsObject, &mut Context) -> JsResult, + pub(crate) __set_prototype_of__: fn(&JsObject, JsPrototype, &mut Context) -> JsResult, + pub(crate) __is_extensible__: fn(&JsObject, &mut Context) -> JsResult, + pub(crate) __prevent_extensions__: fn(&JsObject, &mut Context) -> JsResult, pub(crate) __get_own_property__: - fn(&JsObject, &PropertyKey, &mut Context<'_>) -> JsResult>, + fn(&JsObject, &PropertyKey, &mut Context) -> JsResult>, pub(crate) __define_own_property__: - fn(&JsObject, &PropertyKey, PropertyDescriptor, &mut Context<'_>) -> JsResult, - pub(crate) __has_property__: fn(&JsObject, &PropertyKey, &mut Context<'_>) -> JsResult, - pub(crate) __get__: fn(&JsObject, &PropertyKey, JsValue, &mut Context<'_>) -> JsResult, + fn(&JsObject, &PropertyKey, PropertyDescriptor, &mut Context) -> JsResult, + pub(crate) __has_property__: fn(&JsObject, &PropertyKey, &mut Context) -> JsResult, + pub(crate) __get__: fn(&JsObject, &PropertyKey, JsValue, &mut Context) -> JsResult, pub(crate) __set__: - fn(&JsObject, PropertyKey, JsValue, JsValue, &mut Context<'_>) -> JsResult, - pub(crate) __delete__: fn(&JsObject, &PropertyKey, &mut Context<'_>) -> JsResult, - pub(crate) __own_property_keys__: fn(&JsObject, &mut Context<'_>) -> JsResult>, - pub(crate) __call__: - fn(&JsObject, argument_count: usize, &mut Context<'_>) -> JsResult, + fn(&JsObject, PropertyKey, JsValue, JsValue, &mut Context) -> JsResult, + pub(crate) __delete__: fn(&JsObject, &PropertyKey, &mut Context) -> JsResult, + pub(crate) __own_property_keys__: fn(&JsObject, &mut Context) -> JsResult>, + pub(crate) __call__: fn(&JsObject, argument_count: usize, &mut Context) -> JsResult, pub(crate) __construct__: - fn(&JsObject, argument_count: usize, &mut Context<'_>) -> JsResult, + fn(&JsObject, argument_count: usize, &mut Context) -> JsResult, } /// The return value of an internal method (`[[Call]]` or `[[Construct]]`). @@ -314,7 +309,7 @@ pub(crate) enum CallValue { /// Further processing is needed. Pending { - func: fn(&JsObject, argument_count: usize, &mut Context<'_>) -> JsResult, + func: fn(&JsObject, argument_count: usize, &mut Context) -> JsResult, object: JsObject, argument_count: usize, }, @@ -325,7 +320,7 @@ pub(crate) enum CallValue { impl CallValue { /// Resolves the [`CallValue`], and return if the value is complete. - pub(crate) fn resolve(mut self, context: &mut Context<'_>) -> JsResult { + pub(crate) fn resolve(mut self, context: &mut Context) -> JsResult { while let Self::Pending { func, object, @@ -348,7 +343,7 @@ impl CallValue { #[allow(clippy::unnecessary_wraps)] pub(crate) fn ordinary_get_prototype_of( obj: &JsObject, - _context: &mut Context<'_>, + _context: &mut Context, ) -> JsResult { let _timer = Profiler::global().start_event("Object::ordinary_get_prototype_of", "object"); @@ -366,7 +361,7 @@ pub(crate) fn ordinary_get_prototype_of( pub(crate) fn ordinary_set_prototype_of( obj: &JsObject, val: JsPrototype, - _: &mut Context<'_>, + _: &mut Context, ) -> JsResult { // 1. Assert: Either Type(V) is Object or Type(V) is Null. // 2. Let current be O.[[Prototype]]. @@ -419,7 +414,7 @@ pub(crate) fn ordinary_set_prototype_of( /// /// [spec]: https://tc39.es/ecma262/#sec-ordinaryisextensible #[allow(clippy::unnecessary_wraps)] -pub(crate) fn ordinary_is_extensible(obj: &JsObject, _context: &mut Context<'_>) -> JsResult { +pub(crate) fn ordinary_is_extensible(obj: &JsObject, _context: &mut Context) -> JsResult { // 1. Return O.[[Extensible]]. Ok(obj.borrow().extensible) } @@ -433,7 +428,7 @@ pub(crate) fn ordinary_is_extensible(obj: &JsObject, _context: &mut Context<'_>) #[allow(clippy::unnecessary_wraps)] pub(crate) fn ordinary_prevent_extensions( obj: &JsObject, - _context: &mut Context<'_>, + _context: &mut Context, ) -> JsResult { // 1. Set O.[[Extensible]] to false. obj.borrow_mut().extensible = false; @@ -452,7 +447,7 @@ pub(crate) fn ordinary_prevent_extensions( pub(crate) fn ordinary_get_own_property( obj: &JsObject, key: &PropertyKey, - _context: &mut Context<'_>, + _context: &mut Context, ) -> JsResult> { let _timer = Profiler::global().start_event("Object::ordinary_get_own_property", "object"); // 1. Assert: IsPropertyKey(P) is true. @@ -482,7 +477,7 @@ pub(crate) fn ordinary_define_own_property( obj: &JsObject, key: &PropertyKey, desc: PropertyDescriptor, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let _timer = Profiler::global().start_event("Object::ordinary_define_own_property", "object"); // 1. Let current be ? O.[[GetOwnProperty]](P). @@ -509,7 +504,7 @@ pub(crate) fn ordinary_define_own_property( pub(crate) fn ordinary_has_property( obj: &JsObject, key: &PropertyKey, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let _timer = Profiler::global().start_event("Object::ordinary_has_property", "object"); // 1. Assert: IsPropertyKey(P) is true. @@ -539,7 +534,7 @@ pub(crate) fn ordinary_get( obj: &JsObject, key: &PropertyKey, receiver: JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let _timer = Profiler::global().start_event("Object::ordinary_get", "object"); // 1. Assert: IsPropertyKey(P) is true. @@ -585,7 +580,7 @@ pub(crate) fn ordinary_set( key: PropertyKey, value: JsValue, receiver: JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let _timer = Profiler::global().start_event("Object::ordinary_set", "object"); @@ -684,7 +679,7 @@ pub(crate) fn ordinary_set( pub(crate) fn ordinary_delete( obj: &JsObject, key: &PropertyKey, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let _timer = Profiler::global().start_event("Object::ordinary_delete", "object"); // 1. Assert: IsPropertyKey(P) is true. @@ -715,7 +710,7 @@ pub(crate) fn ordinary_delete( #[allow(clippy::unnecessary_wraps)] pub(crate) fn ordinary_own_property_keys( obj: &JsObject, - _context: &mut Context<'_>, + _context: &mut Context, ) -> JsResult> { let _timer = Profiler::global().start_event("Object::ordinary_own_property_keys", "object"); // 1. Let keys be a new empty List. @@ -921,7 +916,7 @@ pub(crate) fn validate_and_apply_property_descriptor( pub(crate) fn get_prototype_from_constructor( constructor: &JsValue, default: F, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult where F: FnOnce(&StandardConstructors) -> &StandardConstructor, @@ -949,7 +944,7 @@ where pub(crate) fn non_existant_call( _obj: &JsObject, _argument_count: usize, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { Err(JsNativeError::typ() .with_message("not a callable function") @@ -960,7 +955,7 @@ pub(crate) fn non_existant_call( pub(crate) fn non_existant_construct( _obj: &JsObject, _argument_count: usize, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { Err(JsNativeError::typ() .with_message("not a constructor") diff --git a/boa_engine/src/object/internal_methods/module_namespace.rs b/boa_engine/src/object/internal_methods/module_namespace.rs index 359ed2cd8f3..a267418d16e 100644 --- a/boa_engine/src/object/internal_methods/module_namespace.rs +++ b/boa_engine/src/object/internal_methods/module_namespace.rs @@ -39,7 +39,7 @@ pub(crate) static MODULE_NAMESPACE_EXOTIC_INTERNAL_METHODS: InternalObjectMethod #[allow(clippy::unnecessary_wraps)] fn module_namespace_exotic_get_prototype_of( _: &JsObject, - _: &mut Context<'_>, + _: &mut Context, ) -> JsResult { // 1. Return null. Ok(None) @@ -52,7 +52,7 @@ fn module_namespace_exotic_get_prototype_of( fn module_namespace_exotic_set_prototype_of( obj: &JsObject, val: JsPrototype, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Return ! SetImmutablePrototype(O, V). Ok( @@ -65,7 +65,7 @@ fn module_namespace_exotic_set_prototype_of( /// /// [spec]: https://tc39.es/ecma262/#sec-module-namespace-exotic-objects-isextensible #[allow(clippy::unnecessary_wraps)] -fn module_namespace_exotic_is_extensible(_: &JsObject, _: &mut Context<'_>) -> JsResult { +fn module_namespace_exotic_is_extensible(_: &JsObject, _: &mut Context) -> JsResult { // 1. Return false. Ok(false) } @@ -74,7 +74,7 @@ fn module_namespace_exotic_is_extensible(_: &JsObject, _: &mut Context<'_>) -> J /// /// [spec]: https://tc39.es/ecma262/#sec-module-namespace-exotic-objects-preventextensions #[allow(clippy::unnecessary_wraps)] -fn module_namespace_exotic_prevent_extensions(_: &JsObject, _: &mut Context<'_>) -> JsResult { +fn module_namespace_exotic_prevent_extensions(_: &JsObject, _: &mut Context) -> JsResult { Ok(true) } @@ -84,7 +84,7 @@ fn module_namespace_exotic_prevent_extensions(_: &JsObject, _: &mut Context<'_>) fn module_namespace_exotic_get_own_property( obj: &JsObject, key: &PropertyKey, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult> { // 1. If P is a Symbol, return OrdinaryGetOwnProperty(O, P). let key = match key { @@ -128,7 +128,7 @@ fn module_namespace_exotic_define_own_property( obj: &JsObject, key: &PropertyKey, desc: PropertyDescriptor, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If P is a Symbol, return ! OrdinaryDefineOwnProperty(O, P, Desc). if let PropertyKey::Symbol(_) = key { @@ -164,7 +164,7 @@ fn module_namespace_exotic_define_own_property( fn module_namespace_exotic_has_property( obj: &JsObject, key: &PropertyKey, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If P is a Symbol, return ! OrdinaryHasProperty(O, P). let key = match key { @@ -193,7 +193,7 @@ fn module_namespace_exotic_get( obj: &JsObject, key: &PropertyKey, receiver: JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If P is a Symbol, then // a. Return ! OrdinaryGet(O, P, Receiver). @@ -269,7 +269,7 @@ fn module_namespace_exotic_set( _key: PropertyKey, _value: JsValue, _receiver: JsValue, - _context: &mut Context<'_>, + _context: &mut Context, ) -> JsResult { // 1. Return false. Ok(false) @@ -281,7 +281,7 @@ fn module_namespace_exotic_set( fn module_namespace_exotic_delete( obj: &JsObject, key: &PropertyKey, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If P is a Symbol, then // a. Return ! OrdinaryDelete(O, P). @@ -309,7 +309,7 @@ fn module_namespace_exotic_delete( /// [spec]: https://tc39.es/ecma262/#sec-module-namespace-exotic-objects-ownpropertykeys fn module_namespace_exotic_own_property_keys( obj: &JsObject, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult> { // 2. Let symbolKeys be OrdinaryOwnPropertyKeys(O). let symbol_keys = ordinary_own_property_keys(obj, context)?; diff --git a/boa_engine/src/object/internal_methods/proxy.rs b/boa_engine/src/object/internal_methods/proxy.rs index 5e9ac2cb590..9efda63307c 100644 --- a/boa_engine/src/object/internal_methods/proxy.rs +++ b/boa_engine/src/object/internal_methods/proxy.rs @@ -54,7 +54,7 @@ pub(crate) static PROXY_EXOTIC_INTERNAL_METHODS_ALL: InternalObjectMethods = /// [spec]: https://tc39.es/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-getprototypeof pub(crate) fn proxy_exotic_get_prototype_of( obj: &JsObject, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let handler be O.[[ProxyHandler]]. // 2. If handler is null, throw a TypeError exception. @@ -116,7 +116,7 @@ pub(crate) fn proxy_exotic_get_prototype_of( pub(crate) fn proxy_exotic_set_prototype_of( obj: &JsObject, val: JsPrototype, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let handler be O.[[ProxyHandler]]. // 2. If handler is null, throw a TypeError exception. @@ -177,10 +177,7 @@ pub(crate) fn proxy_exotic_set_prototype_of( /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-isextensible -pub(crate) fn proxy_exotic_is_extensible( - obj: &JsObject, - context: &mut Context<'_>, -) -> JsResult { +pub(crate) fn proxy_exotic_is_extensible(obj: &JsObject, context: &mut Context) -> JsResult { // 1. Let handler be O.[[ProxyHandler]]. // 2. If handler is null, throw a TypeError exception. // 3. Assert: Type(handler) is Object. @@ -225,7 +222,7 @@ pub(crate) fn proxy_exotic_is_extensible( /// [spec]: https://tc39.es/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-preventextensions pub(crate) fn proxy_exotic_prevent_extensions( obj: &JsObject, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let handler be O.[[ProxyHandler]]. // 2. If handler is null, throw a TypeError exception. @@ -271,7 +268,7 @@ pub(crate) fn proxy_exotic_prevent_extensions( pub(crate) fn proxy_exotic_get_own_property( obj: &JsObject, key: &PropertyKey, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult> { // 1. Let handler be O.[[ProxyHandler]]. // 2. If handler is null, throw a TypeError exception. @@ -395,7 +392,7 @@ pub(crate) fn proxy_exotic_define_own_property( obj: &JsObject, key: &PropertyKey, desc: PropertyDescriptor, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let handler be O.[[ProxyHandler]]. // 2. If handler is null, throw a TypeError exception. @@ -506,7 +503,7 @@ pub(crate) fn proxy_exotic_define_own_property( pub(crate) fn proxy_exotic_has_property( obj: &JsObject, key: &PropertyKey, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let handler be O.[[ProxyHandler]]. // 2. If handler is null, throw a TypeError exception. @@ -572,7 +569,7 @@ pub(crate) fn proxy_exotic_get( obj: &JsObject, key: &PropertyKey, receiver: JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let handler be O.[[ProxyHandler]]. // 2. If handler is null, throw a TypeError exception. @@ -641,7 +638,7 @@ pub(crate) fn proxy_exotic_set( key: PropertyKey, value: JsValue, receiver: JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let handler be O.[[ProxyHandler]]. // 2. If handler is null, throw a TypeError exception. @@ -722,7 +719,7 @@ pub(crate) fn proxy_exotic_set( pub(crate) fn proxy_exotic_delete( obj: &JsObject, key: &PropertyKey, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let handler be O.[[ProxyHandler]]. // 2. If handler is null, throw a TypeError exception. @@ -788,7 +785,7 @@ pub(crate) fn proxy_exotic_delete( /// [spec]: https://tc39.es/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-ownpropertykeys pub(crate) fn proxy_exotic_own_property_keys( obj: &JsObject, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult> { // 1. Let handler be O.[[ProxyHandler]]. // 2. If handler is null, throw a TypeError exception. @@ -923,7 +920,7 @@ pub(crate) fn proxy_exotic_own_property_keys( fn proxy_exotic_call( obj: &JsObject, argument_count: usize, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let handler be O.[[ProxyHandler]]. // 2. If handler is null, throw a TypeError exception. @@ -969,7 +966,7 @@ fn proxy_exotic_call( fn proxy_exotic_construct( obj: &JsObject, argument_count: usize, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let handler be O.[[ProxyHandler]]. // 2. If handler is null, throw a TypeError exception. diff --git a/boa_engine/src/object/internal_methods/string.rs b/boa_engine/src/object/internal_methods/string.rs index aacb579603b..97053a74046 100644 --- a/boa_engine/src/object/internal_methods/string.rs +++ b/boa_engine/src/object/internal_methods/string.rs @@ -29,7 +29,7 @@ pub(crate) static STRING_EXOTIC_INTERNAL_METHODS: InternalObjectMethods = Intern pub(crate) fn string_exotic_get_own_property( obj: &JsObject, key: &PropertyKey, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult> { // 1. Assert: IsPropertyKey(P) is true. // 2. Let desc be OrdinaryGetOwnProperty(S, P). @@ -54,7 +54,7 @@ pub(crate) fn string_exotic_define_own_property( obj: &JsObject, key: &PropertyKey, desc: PropertyDescriptor, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Assert: IsPropertyKey(P) is true. // 2. Let stringDesc be ! StringGetOwnProperty(S, P). @@ -85,7 +85,7 @@ pub(crate) fn string_exotic_define_own_property( #[allow(clippy::unnecessary_wraps)] pub(crate) fn string_exotic_own_property_keys( obj: &JsObject, - _context: &mut Context<'_>, + _context: &mut Context, ) -> JsResult> { let obj = obj.borrow(); diff --git a/boa_engine/src/object/jsobject.rs b/boa_engine/src/object/jsobject.rs index 600460675da..d5be5d10843 100644 --- a/boa_engine/src/object/jsobject.rs +++ b/boa_engine/src/object/jsobject.rs @@ -233,7 +233,7 @@ impl JsObject { /// [spec]: https://tc39.es/ecma262/#sec-ordinarytoprimitive pub(crate) fn ordinary_to_primitive( &self, - context: &mut Context<'_>, + context: &mut Context, hint: PreferredType, ) -> JsResult { // 1. Assert: Type(O) is Object. @@ -894,10 +894,7 @@ impl JsObject { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-topropertydescriptor - pub fn to_property_descriptor( - &self, - context: &mut Context<'_>, - ) -> JsResult { + pub fn to_property_descriptor(&self, context: &mut Context) -> JsResult { // 1 is implemented on the method `to_property_descriptor` of value // 2. Let desc be a new Property Descriptor that initially has no fields. @@ -998,7 +995,7 @@ Cannot both specify accessors and a value or writable attribute", &self, source: &JsValue, excluded_keys: Vec, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult<()> where K: Into, diff --git a/boa_engine/src/object/mod.rs b/boa_engine/src/object/mod.rs index 9bcf44a6b82..fbec95e8cae 100644 --- a/boa_engine/src/object/mod.rs +++ b/boa_engine/src/object/mod.rs @@ -2631,21 +2631,21 @@ impl<'realm> FunctionObjectBuilder<'realm> { /// } /// ``` #[derive(Debug)] -pub struct ObjectInitializer<'ctx, 'host> { - context: &'ctx mut Context<'host>, +pub struct ObjectInitializer<'ctx> { + context: &'ctx mut Context, object: JsObject, } -impl<'ctx, 'host> ObjectInitializer<'ctx, 'host> { +impl<'ctx> ObjectInitializer<'ctx> { /// Create a new `ObjectBuilder`. #[inline] - pub fn new(context: &'ctx mut Context<'host>) -> Self { + pub fn new(context: &'ctx mut Context) -> Self { let object = JsObject::with_object_proto(context.intrinsics()); Self { context, object } } /// Create a new `ObjectBuilder` with custom [`NativeObject`] data. - pub fn with_native(data: T, context: &'ctx mut Context<'host>) -> Self { + pub fn with_native(data: T, context: &'ctx mut Context) -> Self { let object = JsObject::from_proto_and_data_with_shared_shape( context.root_shape(), context.intrinsics().constructors().object().prototype(), @@ -2727,15 +2727,15 @@ impl<'ctx, 'host> ObjectInitializer<'ctx, 'host> { /// Gets the context used to create the object. #[inline] - pub fn context(&mut self) -> &mut Context<'host> { + pub fn context(&mut self) -> &mut Context { self.context } } /// Builder for creating constructors objects, like `Array`. #[derive(Debug)] -pub struct ConstructorBuilder<'ctx, 'host> { - context: &'ctx mut Context<'host>, +pub struct ConstructorBuilder<'ctx> { + context: &'ctx mut Context, function: NativeFunction, constructor_object: Object, has_prototype_property: bool, @@ -2748,13 +2748,10 @@ pub struct ConstructorBuilder<'ctx, 'host> { custom_prototype: Option, } -impl<'ctx, 'host> ConstructorBuilder<'ctx, 'host> { +impl<'ctx> ConstructorBuilder<'ctx> { /// Create a new `ConstructorBuilder`. #[inline] - pub fn new( - context: &'ctx mut Context<'host>, - function: NativeFunction, - ) -> ConstructorBuilder<'ctx, 'host> { + pub fn new(context: &'ctx mut Context, function: NativeFunction) -> ConstructorBuilder<'ctx> { Self { context, function, @@ -2989,7 +2986,7 @@ impl<'ctx, 'host> ConstructorBuilder<'ctx, 'host> { /// Return the current context. #[inline] - pub fn context(&mut self) -> &mut Context<'host> { + pub fn context(&mut self) -> &mut Context { self.context } diff --git a/boa_engine/src/object/operations.rs b/boa_engine/src/object/operations.rs index 42a450be9c3..83b747b86bb 100644 --- a/boa_engine/src/object/operations.rs +++ b/boa_engine/src/object/operations.rs @@ -55,7 +55,7 @@ impl JsObject { /// /// [spec]: https://tc39.es/ecma262/#sec-isextensible-o #[inline] - pub fn is_extensible(&self, context: &mut Context<'_>) -> JsResult { + pub fn is_extensible(&self, context: &mut Context) -> JsResult { // 1. Return ? O.[[IsExtensible]](). self.__is_extensible__(context) } @@ -66,7 +66,7 @@ impl JsObject { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-get-o-p - pub fn get(&self, key: K, context: &mut Context<'_>) -> JsResult + pub fn get(&self, key: K, context: &mut Context) -> JsResult where K: Into, { @@ -82,13 +82,7 @@ impl JsObject { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-set-o-p-v-throw - pub fn set( - &self, - key: K, - value: V, - throw: bool, - context: &mut Context<'_>, - ) -> JsResult + pub fn set(&self, key: K, value: V, throw: bool, context: &mut Context) -> JsResult where K: Into, V: Into, @@ -119,7 +113,7 @@ impl JsObject { &self, key: K, value: V, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult where K: Into, @@ -149,7 +143,7 @@ impl JsObject { &self, key: K, value: V, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult where K: Into, @@ -180,7 +174,7 @@ impl JsObject { &self, key: K, value: V, - context: &mut Context<'_>, + context: &mut Context, ) where K: Into, V: Into, @@ -217,7 +211,7 @@ impl JsObject { &self, key: K, desc: P, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult where K: Into, @@ -244,7 +238,7 @@ impl JsObject { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-deletepropertyorthrow - pub fn delete_property_or_throw(&self, key: K, context: &mut Context<'_>) -> JsResult + pub fn delete_property_or_throw(&self, key: K, context: &mut Context) -> JsResult where K: Into, { @@ -269,7 +263,7 @@ impl JsObject { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-hasproperty - pub fn has_property(&self, key: K, context: &mut Context<'_>) -> JsResult + pub fn has_property(&self, key: K, context: &mut Context) -> JsResult where K: Into, { @@ -285,7 +279,7 @@ impl JsObject { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-hasownproperty - pub fn has_own_property(&self, key: K, context: &mut Context<'_>) -> JsResult + pub fn has_own_property(&self, key: K, context: &mut Context) -> JsResult where K: Into, { @@ -315,7 +309,7 @@ impl JsObject { &self, this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // SKIP: 1. If argumentsList is not present, set argumentsList to a new empty List. // SKIP: 2. If IsCallable(F) is false, throw a TypeError exception. @@ -362,7 +356,7 @@ impl JsObject { &self, args: &[JsValue], new_target: Option<&Self>, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If newTarget is not present, set newTarget to F. let new_target = new_target.unwrap_or(self); @@ -403,7 +397,7 @@ impl JsObject { pub fn set_integrity_level( &self, level: IntegrityLevel, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Assert: Type(O) is Object. // 2. Assert: level is either sealed or frozen. @@ -472,7 +466,7 @@ impl JsObject { pub fn test_integrity_level( &self, level: IntegrityLevel, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Assert: Type(O) is Object. // 2. Assert: level is either sealed or frozen. @@ -517,7 +511,7 @@ impl JsObject { /// Returns the value of the "length" property of an array-like object. /// /// [spec]: https://tc39.es/ecma262/#sec-lengthofarraylike - pub(crate) fn length_of_array_like(&self, context: &mut Context<'_>) -> JsResult { + pub(crate) fn length_of_array_like(&self, context: &mut Context) -> JsResult { // 1. Assert: Type(obj) is Object. // NOTE: This is an optimization, most of the cases that `LengthOfArrayLike` will be called @@ -549,7 +543,7 @@ impl JsObject { pub(crate) fn species_constructor( &self, default_constructor: F, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult where F: FnOnce(&StandardConstructors) -> &StandardConstructor, @@ -597,7 +591,7 @@ impl JsObject { pub(crate) fn enumerable_own_property_names( &self, kind: PropertyNameKind, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult> { // 1. Assert: Type(O) is Object. // 2. Let ownKeys be ? O.[[OwnPropertyKeys]](). @@ -658,7 +652,7 @@ impl JsObject { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-getmethod - pub(crate) fn get_method(&self, key: K, context: &mut Context<'_>) -> JsResult> + pub(crate) fn get_method(&self, key: K, context: &mut Context) -> JsResult> where K: Into, { @@ -714,7 +708,7 @@ impl JsObject { /// Abstract operation [`GetFunctionRealm`][spec]. /// /// [spec]: https://tc39.es/ecma262/#sec-getfunctionrealm - pub(crate) fn get_function_realm(&self, context: &mut Context<'_>) -> JsResult { + pub(crate) fn get_function_realm(&self, context: &mut Context) -> JsResult { let constructor = self.borrow(); if let Some(fun) = constructor.as_function() { return Ok(fun.realm().clone()); @@ -787,7 +781,7 @@ impl JsObject { &self, name: &PrivateName, value: JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult<()> { // 1. If the host is a web browser, then // a. Perform ? HostEnsureCanAddPrivateElement(O). @@ -826,7 +820,7 @@ impl JsObject { &self, name: &PrivateName, method: &PrivateElement, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult<()> { // 1. Assert: method.[[Kind]] is either method or accessor. assert!(matches!( @@ -874,7 +868,7 @@ impl JsObject { pub(crate) fn private_get( &self, name: &PrivateName, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. Let entry be PrivateElementFind(O, P). let entry = self.private_element_find(name, true, true); @@ -917,7 +911,7 @@ impl JsObject { &self, name: &PrivateName, value: JsValue, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult<()> { // 1. Let entry be PrivateElementFind(O, P). // Note: This function is inlined here for mutable access. @@ -980,7 +974,7 @@ impl JsObject { pub(crate) fn define_field( &self, field_record: &ClassFieldDefinition, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult<()> { // 2. Let initializer be fieldRecord.[[Initializer]]. let initializer = match field_record { @@ -1024,7 +1018,7 @@ impl JsObject { pub(crate) fn initialize_instance_elements( &self, constructor: &Self, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult<()> { let constructor_borrow = constructor.borrow(); let constructor_function = constructor_borrow @@ -1063,7 +1057,7 @@ impl JsObject { &self, key: K, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult where K: Into, @@ -1090,7 +1084,7 @@ impl JsValue { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-getv - pub(crate) fn get_v(&self, key: K, context: &mut Context<'_>) -> JsResult + pub(crate) fn get_v(&self, key: K, context: &mut Context) -> JsResult where K: Into, { @@ -1109,11 +1103,7 @@ impl JsValue { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-getmethod - pub(crate) fn get_method( - &self, - key: K, - context: &mut Context<'_>, - ) -> JsResult> + pub(crate) fn get_method(&self, key: K, context: &mut Context) -> JsResult> where K: Into, { @@ -1132,7 +1122,7 @@ impl JsValue { pub(crate) fn create_list_from_array_like( &self, element_types: &[Type], - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult> { // 1. If elementTypes is not present, set elementTypes to « Undefined, Null, Boolean, String, Symbol, Number, BigInt, Object ». let types = if element_types.is_empty() { @@ -1193,12 +1183,7 @@ impl JsValue { /// /// [call]: https://tc39.es/ecma262/#sec-call #[inline] - pub(crate) fn call( - &self, - this: &Self, - args: &[Self], - context: &mut Context<'_>, - ) -> JsResult { + pub(crate) fn call(&self, this: &Self, args: &[Self], context: &mut Context) -> JsResult { let Some(object) = self.as_object() else { return Err(JsNativeError::typ() .with_message(format!( @@ -1219,12 +1204,7 @@ impl JsValue { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-invoke - pub(crate) fn invoke( - &self, - key: K, - args: &[Self], - context: &mut Context<'_>, - ) -> JsResult + pub(crate) fn invoke(&self, key: K, args: &[Self], context: &mut Context) -> JsResult where K: Into, { @@ -1245,7 +1225,7 @@ impl JsValue { pub fn ordinary_has_instance( function: &Self, object: &Self, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { // 1. If IsCallable(C) is false, return false. let Some(function) = function.as_callable() else { diff --git a/boa_engine/src/optimizer/mod.rs b/boa_engine/src/optimizer/mod.rs index e675a72a718..77a2716e782 100644 --- a/boa_engine/src/optimizer/mod.rs +++ b/boa_engine/src/optimizer/mod.rs @@ -66,14 +66,14 @@ impl fmt::Display for OptimizerStatistics { /// This represents an AST optimizer. #[derive(Debug)] -pub(crate) struct Optimizer<'context, 'host> { +pub(crate) struct Optimizer<'context> { statistics: OptimizerStatistics, - context: &'context mut Context<'host>, + context: &'context mut Context, } -impl<'context, 'host> Optimizer<'context, 'host> { +impl<'context> Optimizer<'context> { /// Create a optimizer. - pub(crate) fn new(context: &'context mut Context<'host>) -> Self { + pub(crate) fn new(context: &'context mut Context) -> Self { Self { statistics: OptimizerStatistics::default(), context, @@ -125,7 +125,7 @@ impl<'context, 'host> Optimizer<'context, 'host> { } } -impl<'ast> VisitorMut<'ast> for Optimizer<'_, '_> { +impl<'ast> VisitorMut<'ast> for Optimizer<'_> { type BreakTy = (); fn visit_expression_mut(&mut self, node: &'ast mut Expression) -> ControlFlow { diff --git a/boa_engine/src/optimizer/pass/constant_folding.rs b/boa_engine/src/optimizer/pass/constant_folding.rs index d510e11310e..0c0aa18b73e 100644 --- a/boa_engine/src/optimizer/pass/constant_folding.rs +++ b/boa_engine/src/optimizer/pass/constant_folding.rs @@ -13,7 +13,7 @@ use boa_ast::{ Expression, }; -fn literal_to_js_value(literal: &Literal, context: &mut Context<'_>) -> JsValue { +fn literal_to_js_value(literal: &Literal, context: &mut Context) -> JsValue { match literal { Literal::String(v) => JsValue::new(JsString::from( context.interner().resolve_expect(*v).utf16(), @@ -27,7 +27,7 @@ fn literal_to_js_value(literal: &Literal, context: &mut Context<'_>) -> JsValue } } -fn js_value_to_literal(value: JsValue, context: &mut Context<'_>) -> Literal { +fn js_value_to_literal(value: JsValue, context: &mut Context) -> Literal { match value { JsValue::Null => Literal::Null, JsValue::Undefined => Literal::Undefined, @@ -48,7 +48,7 @@ pub(crate) struct ConstantFolding {} impl ConstantFolding { pub(crate) fn fold_expression( expr: &mut Expression, - context: &mut Context<'_>, + context: &mut Context, ) -> PassAction { match expr { Expression::Unary(unary) => Self::constant_fold_unary_expr(unary, context), @@ -59,7 +59,7 @@ impl ConstantFolding { fn constant_fold_unary_expr( unary: &mut Unary, - context: &mut Context<'_>, + context: &mut Context, ) -> PassAction { let Expression::Literal(literal) = unary.target() else { return PassAction::Keep; @@ -102,7 +102,7 @@ impl ConstantFolding { fn constant_fold_binary_expr( binary: &mut Binary, - context: &mut Context<'_>, + context: &mut Context, ) -> PassAction { let Expression::Literal(lhs) = binary.lhs() else { return PassAction::Keep; diff --git a/boa_engine/src/script.rs b/boa_engine/src/script.rs index 780ca189176..724b05d1135 100644 --- a/boa_engine/src/script.rs +++ b/boa_engine/src/script.rs @@ -79,7 +79,7 @@ impl Script { pub fn parse( src: Source<'_, R>, realm: Option, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let _timer = Profiler::global().start_event("Script parsing", "Main"); let mut parser = Parser::new(src); @@ -106,7 +106,7 @@ impl Script { /// Compiles the codeblock of this script. /// /// This is a no-op if this has been called previously. - pub fn codeblock(&self, context: &mut Context<'_>) -> JsResult> { + pub fn codeblock(&self, context: &mut Context) -> JsResult> { let mut codeblock = self.inner.codeblock.borrow_mut(); if let Some(codeblock) = &*codeblock { @@ -143,7 +143,7 @@ impl Script { /// on the context or [`JobQueue::run_jobs`] on the provided queue to run them. /// /// [`JobQueue::run_jobs`]: crate::job::JobQueue::run_jobs - pub fn evaluate(&self, context: &mut Context<'_>) -> JsResult { + pub fn evaluate(&self, context: &mut Context) -> JsResult { let _timer = Profiler::global().start_event("Execution", "Main"); self.prepare_run(context)?; @@ -162,7 +162,7 @@ impl Script { /// execution is suspended. See [`Script::evaluate_async_with_budget`] if you want to also /// customize this parameter. #[allow(clippy::future_not_send)] - pub async fn evaluate_async(&self, context: &mut Context<'_>) -> JsResult { + pub async fn evaluate_async(&self, context: &mut Context) -> JsResult { self.evaluate_async_with_budget(context, 256).await } @@ -176,7 +176,7 @@ impl Script { #[allow(clippy::future_not_send)] pub async fn evaluate_async_with_budget( &self, - context: &mut Context<'_>, + context: &mut Context, budget: u32, ) -> JsResult { let _timer = Profiler::global().start_event("Async Execution", "Main"); @@ -191,7 +191,7 @@ impl Script { record.consume() } - fn prepare_run(&self, context: &mut Context<'_>) -> JsResult<()> { + fn prepare_run(&self, context: &mut Context) -> JsResult<()> { let codeblock = self.codeblock(context)?; let env_fp = context.vm.environments.len() as u32; diff --git a/boa_engine/src/value/conversions/serde_json.rs b/boa_engine/src/value/conversions/serde_json.rs index f4f73f63eeb..7b79e780c26 100644 --- a/boa_engine/src/value/conversions/serde_json.rs +++ b/boa_engine/src/value/conversions/serde_json.rs @@ -36,7 +36,7 @@ impl JsValue { /// # /// # assert_eq!(json, value.to_json(&mut context).unwrap()); /// ``` - pub fn from_json(json: &Value, context: &mut Context<'_>) -> JsResult { + pub fn from_json(json: &Value, context: &mut Context) -> JsResult { /// Biggest possible integer, as i64. const MAX_INT: i64 = i32::MAX as i64; @@ -112,7 +112,7 @@ impl JsValue { /// # Panics /// /// Panics if the `JsValue` is `Undefined`. - pub fn to_json(&self, context: &mut Context<'_>) -> JsResult { + pub fn to_json(&self, context: &mut Context) -> JsResult { match self { Self::Null => Ok(Value::Null), Self::Undefined => todo!("undefined to JSON"), diff --git a/boa_engine/src/value/conversions/try_from_js.rs b/boa_engine/src/value/conversions/try_from_js.rs index 783319dff94..55164e931f4 100644 --- a/boa_engine/src/value/conversions/try_from_js.rs +++ b/boa_engine/src/value/conversions/try_from_js.rs @@ -6,13 +6,13 @@ use num_bigint::BigInt; /// This trait adds a fallible and efficient conversions from a [`JsValue`] to Rust types. pub trait TryFromJs: Sized { /// This function tries to convert a JavaScript value into `Self`. - fn try_from_js(value: &JsValue, context: &mut Context<'_>) -> JsResult; + fn try_from_js(value: &JsValue, context: &mut Context) -> JsResult; } impl JsValue { /// This function is the inverse of [`TryFromJs`]. It tries to convert a [`JsValue`] to a given /// Rust type. - pub fn try_js_into(&self, context: &mut Context<'_>) -> JsResult + pub fn try_js_into(&self, context: &mut Context) -> JsResult where T: TryFromJs, { @@ -21,7 +21,7 @@ impl JsValue { } impl TryFromJs for bool { - fn try_from_js(value: &JsValue, _context: &mut Context<'_>) -> JsResult { + fn try_from_js(value: &JsValue, _context: &mut Context) -> JsResult { match value { JsValue::Boolean(b) => Ok(*b), _ => Err(JsNativeError::typ() @@ -32,7 +32,7 @@ impl TryFromJs for bool { } impl TryFromJs for String { - fn try_from_js(value: &JsValue, _context: &mut Context<'_>) -> JsResult { + fn try_from_js(value: &JsValue, _context: &mut Context) -> JsResult { match value { JsValue::String(s) => s.to_std_string().map_err(|e| { JsNativeError::typ() @@ -50,7 +50,7 @@ impl TryFromJs for Option where T: TryFromJs, { - fn try_from_js(value: &JsValue, context: &mut Context<'_>) -> JsResult { + fn try_from_js(value: &JsValue, context: &mut Context) -> JsResult { match value { JsValue::Null | JsValue::Undefined => Ok(None), value => Ok(Some(T::try_from_js(value, context)?)), @@ -59,7 +59,7 @@ where } impl TryFromJs for JsBigInt { - fn try_from_js(value: &JsValue, _context: &mut Context<'_>) -> JsResult { + fn try_from_js(value: &JsValue, _context: &mut Context) -> JsResult { match value { JsValue::BigInt(b) => Ok(b.clone()), _ => Err(JsNativeError::typ() @@ -70,7 +70,7 @@ impl TryFromJs for JsBigInt { } impl TryFromJs for BigInt { - fn try_from_js(value: &JsValue, _context: &mut Context<'_>) -> JsResult { + fn try_from_js(value: &JsValue, _context: &mut Context) -> JsResult { match value { JsValue::BigInt(b) => Ok(b.as_inner().clone()), _ => Err(JsNativeError::typ() @@ -81,13 +81,13 @@ impl TryFromJs for BigInt { } impl TryFromJs for JsValue { - fn try_from_js(value: &JsValue, _context: &mut Context<'_>) -> JsResult { + fn try_from_js(value: &JsValue, _context: &mut Context) -> JsResult { Ok(value.clone()) } } impl TryFromJs for f64 { - fn try_from_js(value: &JsValue, _context: &mut Context<'_>) -> JsResult { + fn try_from_js(value: &JsValue, _context: &mut Context) -> JsResult { match value { JsValue::Integer(i) => Ok((*i).into()), JsValue::Rational(r) => Ok(*r), @@ -99,7 +99,7 @@ impl TryFromJs for f64 { } impl TryFromJs for i8 { - fn try_from_js(value: &JsValue, _context: &mut Context<'_>) -> JsResult { + fn try_from_js(value: &JsValue, _context: &mut Context) -> JsResult { match value { JsValue::Integer(i) => (*i).try_into().map_err(|e| { JsNativeError::typ() @@ -114,7 +114,7 @@ impl TryFromJs for i8 { } impl TryFromJs for u8 { - fn try_from_js(value: &JsValue, _context: &mut Context<'_>) -> JsResult { + fn try_from_js(value: &JsValue, _context: &mut Context) -> JsResult { match value { JsValue::Integer(i) => (*i).try_into().map_err(|e| { JsNativeError::typ() @@ -129,7 +129,7 @@ impl TryFromJs for u8 { } impl TryFromJs for i16 { - fn try_from_js(value: &JsValue, _context: &mut Context<'_>) -> JsResult { + fn try_from_js(value: &JsValue, _context: &mut Context) -> JsResult { match value { JsValue::Integer(i) => (*i).try_into().map_err(|e| { JsNativeError::typ() @@ -144,7 +144,7 @@ impl TryFromJs for i16 { } impl TryFromJs for u16 { - fn try_from_js(value: &JsValue, _context: &mut Context<'_>) -> JsResult { + fn try_from_js(value: &JsValue, _context: &mut Context) -> JsResult { match value { JsValue::Integer(i) => (*i).try_into().map_err(|e| { JsNativeError::typ() @@ -159,7 +159,7 @@ impl TryFromJs for u16 { } impl TryFromJs for i32 { - fn try_from_js(value: &JsValue, _context: &mut Context<'_>) -> JsResult { + fn try_from_js(value: &JsValue, _context: &mut Context) -> JsResult { match value { JsValue::Integer(i) => Ok(*i), _ => Err(JsNativeError::typ() @@ -170,7 +170,7 @@ impl TryFromJs for i32 { } impl TryFromJs for u32 { - fn try_from_js(value: &JsValue, _context: &mut Context<'_>) -> JsResult { + fn try_from_js(value: &JsValue, _context: &mut Context) -> JsResult { match value { JsValue::Integer(i) => (*i).try_into().map_err(|e| { JsNativeError::typ() @@ -185,7 +185,7 @@ impl TryFromJs for u32 { } impl TryFromJs for i64 { - fn try_from_js(value: &JsValue, _context: &mut Context<'_>) -> JsResult { + fn try_from_js(value: &JsValue, _context: &mut Context) -> JsResult { match value { JsValue::Integer(i) => Ok((*i).into()), _ => Err(JsNativeError::typ() @@ -196,7 +196,7 @@ impl TryFromJs for i64 { } impl TryFromJs for u64 { - fn try_from_js(value: &JsValue, _context: &mut Context<'_>) -> JsResult { + fn try_from_js(value: &JsValue, _context: &mut Context) -> JsResult { match value { JsValue::Integer(i) => (*i).try_into().map_err(|e| { JsNativeError::typ() @@ -211,7 +211,7 @@ impl TryFromJs for u64 { } impl TryFromJs for usize { - fn try_from_js(value: &JsValue, _context: &mut Context<'_>) -> JsResult { + fn try_from_js(value: &JsValue, _context: &mut Context) -> JsResult { match value { JsValue::Integer(i) => (*i).try_into().map_err(|e| { JsNativeError::typ() @@ -226,7 +226,7 @@ impl TryFromJs for usize { } impl TryFromJs for i128 { - fn try_from_js(value: &JsValue, _context: &mut Context<'_>) -> JsResult { + fn try_from_js(value: &JsValue, _context: &mut Context) -> JsResult { match value { JsValue::Integer(i) => Ok((*i).into()), _ => Err(JsNativeError::typ() @@ -237,7 +237,7 @@ impl TryFromJs for i128 { } impl TryFromJs for u128 { - fn try_from_js(value: &JsValue, _context: &mut Context<'_>) -> JsResult { + fn try_from_js(value: &JsValue, _context: &mut Context) -> JsResult { match value { JsValue::Integer(i) => (*i).try_into().map_err(|e| { JsNativeError::typ() diff --git a/boa_engine/src/value/equality.rs b/boa_engine/src/value/equality.rs index 7e9255c381d..4f3c2846eab 100644 --- a/boa_engine/src/value/equality.rs +++ b/boa_engine/src/value/equality.rs @@ -38,7 +38,7 @@ impl JsValue { /// This method is executed when doing abstract equality comparisons with the `==` operator. /// For more information, check #[allow(clippy::float_cmp)] - pub fn equals(&self, other: &Self, context: &mut Context<'_>) -> JsResult { + pub fn equals(&self, other: &Self, context: &mut Context) -> JsResult { // 1. If Type(x) is the same as Type(y), then // a. Return the result of performing Strict Equality Comparison x === y. if self.get_type() == other.get_type() { diff --git a/boa_engine/src/value/mod.rs b/boa_engine/src/value/mod.rs index 57c42bcb51b..d27c815e242 100644 --- a/boa_engine/src/value/mod.rs +++ b/boa_engine/src/value/mod.rs @@ -350,7 +350,7 @@ impl JsValue { /// pub fn to_primitive( &self, - context: &mut Context<'_>, + context: &mut Context, preferred_type: PreferredType, ) -> JsResult { // 1. Assert: input is an ECMAScript language value. (always a value not need to check) @@ -406,7 +406,7 @@ impl JsValue { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-tobigint - pub fn to_bigint(&self, context: &mut Context<'_>) -> JsResult { + pub fn to_bigint(&self, context: &mut Context) -> JsResult { match self { Self::Null => Err(JsNativeError::typ() .with_message("cannot convert null to a BigInt") @@ -467,7 +467,7 @@ impl JsValue { /// Converts the value to a string. /// /// This function is equivalent to `String(value)` in JavaScript. - pub fn to_string(&self, context: &mut Context<'_>) -> JsResult { + pub fn to_string(&self, context: &mut Context) -> JsResult { match self { Self::Null => Ok("null".into()), Self::Undefined => Ok("undefined".into()), @@ -491,7 +491,7 @@ impl JsValue { /// This function is equivalent to `Object(value)` in JavaScript. /// /// See: - pub fn to_object(&self, context: &mut Context<'_>) -> JsResult { + pub fn to_object(&self, context: &mut Context) -> JsResult { // TODO: add fast paths with object template match self { Self::Undefined | Self::Null => Err(JsNativeError::typ() @@ -533,7 +533,7 @@ impl JsValue { /// Converts the value to a `PropertyKey`, that can be used as a key for properties. /// /// See - pub fn to_property_key(&self, context: &mut Context<'_>) -> JsResult { + pub fn to_property_key(&self, context: &mut Context) -> JsResult { Ok(match self { // Fast path: Self::String(string) => string.clone().into(), @@ -553,7 +553,7 @@ impl JsValue { /// It returns value converted to a numeric value of type `Number` or `BigInt`. /// /// See: - pub fn to_numeric(&self, context: &mut Context<'_>) -> JsResult { + pub fn to_numeric(&self, context: &mut Context) -> JsResult { // 1. Let primValue be ? ToPrimitive(value, number). let primitive = self.to_primitive(context, PreferredType::Number)?; @@ -571,7 +571,7 @@ impl JsValue { /// This function is equivalent to `value | 0` in JavaScript /// /// See: - pub fn to_u32(&self, context: &mut Context<'_>) -> JsResult { + pub fn to_u32(&self, context: &mut Context) -> JsResult { // This is the fast path, if the value is Integer we can just return it. if let Self::Integer(number) = *self { if let Ok(number) = u32::try_from(number) { @@ -586,7 +586,7 @@ impl JsValue { /// Converts a value to an integral 32 bit signed integer. /// /// See: - pub fn to_i32(&self, context: &mut Context<'_>) -> JsResult { + pub fn to_i32(&self, context: &mut Context) -> JsResult { // This is the fast path, if the value is Integer we can just return it. if let Self::Integer(number) = *self { return Ok(number); @@ -602,7 +602,7 @@ impl JsValue { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-toint8 - pub fn to_int8(&self, context: &mut Context<'_>) -> JsResult { + pub fn to_int8(&self, context: &mut Context) -> JsResult { // 1. Let number be ? ToNumber(argument). let number = self.to_number(context)?; @@ -631,7 +631,7 @@ impl JsValue { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-touint8 - pub fn to_uint8(&self, context: &mut Context<'_>) -> JsResult { + pub fn to_uint8(&self, context: &mut Context) -> JsResult { // 1. Let number be ? ToNumber(argument). let number = self.to_number(context)?; @@ -656,7 +656,7 @@ impl JsValue { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-touint8clamp - pub fn to_uint8_clamp(&self, context: &mut Context<'_>) -> JsResult { + pub fn to_uint8_clamp(&self, context: &mut Context) -> JsResult { // 1. Let number be ? ToNumber(argument). let number = self.to_number(context)?; @@ -703,7 +703,7 @@ impl JsValue { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-toint16 - pub fn to_int16(&self, context: &mut Context<'_>) -> JsResult { + pub fn to_int16(&self, context: &mut Context) -> JsResult { // 1. Let number be ? ToNumber(argument). let number = self.to_number(context)?; @@ -732,7 +732,7 @@ impl JsValue { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-touint16 - pub fn to_uint16(&self, context: &mut Context<'_>) -> JsResult { + pub fn to_uint16(&self, context: &mut Context) -> JsResult { // 1. Let number be ? ToNumber(argument). let number = self.to_number(context)?; @@ -757,7 +757,7 @@ impl JsValue { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-tobigint64 - pub fn to_big_int64(&self, context: &mut Context<'_>) -> JsResult { + pub fn to_big_int64(&self, context: &mut Context) -> JsResult { // 1. Let n be ? ToBigInt(argument). let n = self.to_bigint(context)?; @@ -782,7 +782,7 @@ impl JsValue { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-tobiguint64 - pub fn to_big_uint64(&self, context: &mut Context<'_>) -> JsResult { + pub fn to_big_uint64(&self, context: &mut Context) -> JsResult { // 1. Let n be ? ToBigInt(argument). let n = self.to_bigint(context)?; @@ -797,7 +797,7 @@ impl JsValue { /// Converts a value to a non-negative integer if it is a valid integer index value. /// /// See: - pub fn to_index(&self, context: &mut Context<'_>) -> JsResult { + pub fn to_index(&self, context: &mut Context) -> JsResult { // 1. If value is undefined, then if self.is_undefined() { // a. Return 0. @@ -828,7 +828,7 @@ impl JsValue { /// Converts argument to an integer suitable for use as the length of an array-like object. /// /// See: - pub fn to_length(&self, context: &mut Context<'_>) -> JsResult { + pub fn to_length(&self, context: &mut Context) -> JsResult { // 1. Let len be ? ToInteger(argument). // 2. If len ≤ +0, return +0. // 3. Return min(len, 2^53 - 1). @@ -846,7 +846,7 @@ impl JsValue { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-tointegerorinfinity - pub fn to_integer_or_infinity(&self, context: &mut Context<'_>) -> JsResult { + pub fn to_integer_or_infinity(&self, context: &mut Context) -> JsResult { // 1. Let number be ? ToNumber(argument). let number = self.to_number(context)?; @@ -858,7 +858,7 @@ impl JsValue { /// /// This function is almost the same as [`Self::to_integer_or_infinity`], but with the exception /// that this will return `Nan` if [`Self::to_number`] returns a non-finite number. - pub(crate) fn to_integer_or_nan(&self, context: &mut Context<'_>) -> JsResult { + pub(crate) fn to_integer_or_nan(&self, context: &mut Context) -> JsResult { // 1. Let number be ? ToNumber(argument). let number = self.to_number(context)?; @@ -875,7 +875,7 @@ impl JsValue { /// This function is equivalent to the unary `+` operator (`+value`) in JavaScript /// /// See: - pub fn to_number(&self, context: &mut Context<'_>) -> JsResult { + pub fn to_number(&self, context: &mut Context) -> JsResult { match *self { Self::Null => Ok(0.0), Self::Undefined => Ok(f64::NAN), @@ -901,7 +901,7 @@ impl JsValue { /// This function is equivalent to `Number(value)` in JavaScript /// /// See: - pub fn to_numeric_number(&self, context: &mut Context<'_>) -> JsResult { + pub fn to_numeric_number(&self, context: &mut Context) -> JsResult { let primitive = self.to_primitive(context, PreferredType::Number)?; if let Some(bigint) = primitive.as_bigint() { return Ok(bigint.to_f64()); @@ -938,10 +938,7 @@ impl JsValue { /// /// [spec]: https://tc39.es/ecma262/#sec-topropertydescriptor #[inline] - pub fn to_property_descriptor( - &self, - context: &mut Context<'_>, - ) -> JsResult { + pub fn to_property_descriptor(&self, context: &mut Context) -> JsResult { // 1. If Type(Obj) is not Object, throw a TypeError exception. self.as_object() .ok_or_else(|| { diff --git a/boa_engine/src/value/operations.rs b/boa_engine/src/value/operations.rs index 44fe42b37a1..e7a403296a6 100644 --- a/boa_engine/src/value/operations.rs +++ b/boa_engine/src/value/operations.rs @@ -11,7 +11,7 @@ use crate::{ impl JsValue { /// Perform the binary `+` operator on the value and return the result. - pub fn add(&self, other: &Self, context: &mut Context<'_>) -> JsResult { + pub fn add(&self, other: &Self, context: &mut Context) -> JsResult { Ok(match (self, other) { // Fast path: // Numeric add @@ -51,7 +51,7 @@ impl JsValue { } /// Perform the binary `-` operator on the value and return the result. - pub fn sub(&self, other: &Self, context: &mut Context<'_>) -> JsResult { + pub fn sub(&self, other: &Self, context: &mut Context) -> JsResult { Ok(match (self, other) { // Fast path: (Self::Integer(x), Self::Integer(y)) => x @@ -77,7 +77,7 @@ impl JsValue { } /// Perform the binary `*` operator on the value and return the result. - pub fn mul(&self, other: &Self, context: &mut Context<'_>) -> JsResult { + pub fn mul(&self, other: &Self, context: &mut Context) -> JsResult { Ok(match (self, other) { // Fast path: (Self::Integer(x), Self::Integer(y)) => x @@ -103,7 +103,7 @@ impl JsValue { } /// Perform the binary `/` operator on the value and return the result. - pub fn div(&self, other: &Self, context: &mut Context<'_>) -> JsResult { + pub fn div(&self, other: &Self, context: &mut Context) -> JsResult { Ok(match (self, other) { // Fast path: (Self::Integer(x), Self::Integer(y)) => x @@ -144,7 +144,7 @@ impl JsValue { } /// Perform the binary `%` operator on the value and return the result. - pub fn rem(&self, other: &Self, context: &mut Context<'_>) -> JsResult { + pub fn rem(&self, other: &Self, context: &mut Context) -> JsResult { Ok(match (self, other) { // Fast path: (Self::Integer(x), Self::Integer(y)) => { @@ -197,7 +197,7 @@ impl JsValue { /// Perform the binary `**` operator on the value and return the result. // NOTE: There are some cases in the spec where we have to compare floats #[allow(clippy::float_cmp)] - pub fn pow(&self, other: &Self, context: &mut Context<'_>) -> JsResult { + pub fn pow(&self, other: &Self, context: &mut Context) -> JsResult { Ok(match (self, other) { // Fast path: (Self::Integer(x), Self::Integer(y)) => u32::try_from(*y) @@ -241,7 +241,7 @@ impl JsValue { } /// Perform the binary `&` operator on the value and return the result. - pub fn bitand(&self, other: &Self, context: &mut Context<'_>) -> JsResult { + pub fn bitand(&self, other: &Self, context: &mut Context) -> JsResult { Ok(match (self, other) { // Fast path: (Self::Integer(x), Self::Integer(y)) => Self::new(x & y), @@ -271,7 +271,7 @@ impl JsValue { } /// Perform the binary `|` operator on the value and return the result. - pub fn bitor(&self, other: &Self, context: &mut Context<'_>) -> JsResult { + pub fn bitor(&self, other: &Self, context: &mut Context) -> JsResult { Ok(match (self, other) { // Fast path: (Self::Integer(x), Self::Integer(y)) => Self::new(x | y), @@ -301,7 +301,7 @@ impl JsValue { } /// Perform the binary `^` operator on the value and return the result. - pub fn bitxor(&self, other: &Self, context: &mut Context<'_>) -> JsResult { + pub fn bitxor(&self, other: &Self, context: &mut Context) -> JsResult { Ok(match (self, other) { // Fast path: (Self::Integer(x), Self::Integer(y)) => Self::new(x ^ y), @@ -331,7 +331,7 @@ impl JsValue { } /// Perform the binary `<<` operator on the value and return the result. - pub fn shl(&self, other: &Self, context: &mut Context<'_>) -> JsResult { + pub fn shl(&self, other: &Self, context: &mut Context) -> JsResult { Ok(match (self, other) { // Fast path: (Self::Integer(x), Self::Integer(y)) => Self::new(x.wrapping_shl(*y as u32)), @@ -363,7 +363,7 @@ impl JsValue { } /// Perform the binary `>>` operator on the value and return the result. - pub fn shr(&self, other: &Self, context: &mut Context<'_>) -> JsResult { + pub fn shr(&self, other: &Self, context: &mut Context) -> JsResult { Ok(match (self, other) { // Fast path: (Self::Integer(x), Self::Integer(y)) => Self::new(x.wrapping_shr(*y as u32)), @@ -395,7 +395,7 @@ impl JsValue { } /// Perform the binary `>>>` operator on the value and return the result. - pub fn ushr(&self, other: &Self, context: &mut Context<'_>) -> JsResult { + pub fn ushr(&self, other: &Self, context: &mut Context) -> JsResult { Ok(match (self, other) { // Fast path: (Self::Integer(x), Self::Integer(y)) => Self::new((*x as u32).wrapping_shr(*y as u32)), @@ -434,7 +434,7 @@ impl JsValue { /// - [ECMAScript reference][spec] /// /// [spec]: https://tc39.es/ecma262/#sec-instanceofoperator - pub fn instance_of(&self, target: &Self, context: &mut Context<'_>) -> JsResult { + pub fn instance_of(&self, target: &Self, context: &mut Context) -> JsResult { // 1. If Type(target) is not Object, throw a TypeError exception. if !target.is_object() { return Err(JsNativeError::typ() @@ -468,7 +468,7 @@ impl JsValue { } /// Returns the negated value. - pub fn neg(&self, context: &mut Context<'_>) -> JsResult { + pub fn neg(&self, context: &mut Context) -> JsResult { Ok(match *self { Self::Symbol(_) | Self::Undefined => Self::new(f64::NAN), Self::Object(_) => Self::new( @@ -512,7 +512,7 @@ impl JsValue { &self, other: &Self, left_first: bool, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { Ok(match (self, other) { // Fast path (for some common operations): @@ -590,7 +590,7 @@ impl JsValue { /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Less_than /// [spec]: https://tc39.es/ecma262/#sec-relational-operators-runtime-semantics-evaluation #[inline] - pub fn lt(&self, other: &Self, context: &mut Context<'_>) -> JsResult { + pub fn lt(&self, other: &Self, context: &mut Context) -> JsResult { match self.abstract_relation(other, true, context)? { AbstractRelation::True => Ok(true), AbstractRelation::False | AbstractRelation::Undefined => Ok(false), @@ -607,7 +607,7 @@ impl JsValue { /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Less_than_or_equal /// [spec]: https://tc39.es/ecma262/#sec-relational-operators-runtime-semantics-evaluation #[inline] - pub fn le(&self, other: &Self, context: &mut Context<'_>) -> JsResult { + pub fn le(&self, other: &Self, context: &mut Context) -> JsResult { match other.abstract_relation(self, false, context)? { AbstractRelation::False => Ok(true), AbstractRelation::True | AbstractRelation::Undefined => Ok(false), @@ -624,7 +624,7 @@ impl JsValue { /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Greater_than /// [spec]: https://tc39.es/ecma262/#sec-relational-operators-runtime-semantics-evaluation #[inline] - pub fn gt(&self, other: &Self, context: &mut Context<'_>) -> JsResult { + pub fn gt(&self, other: &Self, context: &mut Context) -> JsResult { match other.abstract_relation(self, false, context)? { AbstractRelation::True => Ok(true), AbstractRelation::False | AbstractRelation::Undefined => Ok(false), @@ -641,7 +641,7 @@ impl JsValue { /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Greater_than_or_equal /// [spec]: https://tc39.es/ecma262/#sec-relational-operators-runtime-semantics-evaluation #[inline] - pub fn ge(&self, other: &Self, context: &mut Context<'_>) -> JsResult { + pub fn ge(&self, other: &Self, context: &mut Context) -> JsResult { match self.abstract_relation(other, true, context)? { AbstractRelation::False => Ok(true), AbstractRelation::True | AbstractRelation::Undefined => Ok(false), diff --git a/boa_engine/src/vm/code_block.rs b/boa_engine/src/vm/code_block.rs index 6e0fedb5eac..4ba94b1a007 100644 --- a/boa_engine/src/vm/code_block.rs +++ b/boa_engine/src/vm/code_block.rs @@ -826,7 +826,7 @@ impl ToInternedString for CodeBlock { pub(crate) fn create_function_object( code: Gc, prototype: JsObject, - context: &mut Context<'_>, + context: &mut Context, ) -> JsObject { let _timer = Profiler::global().start_event("create_function_object", "vm"); @@ -899,10 +899,7 @@ pub(crate) fn create_function_object( /// This is prefered over [`create_function_object`] if prototype is [`None`], /// because it constructs the function from a pre-initialized object template, /// with all the properties and prototype set. -pub(crate) fn create_function_object_fast( - code: Gc, - context: &mut Context<'_>, -) -> JsObject { +pub(crate) fn create_function_object_fast(code: Gc, context: &mut Context) -> JsObject { let _timer = Profiler::global().start_event("create_function_object_fast", "vm"); let name: JsValue = code.name().clone().into(); diff --git a/boa_engine/src/vm/mod.rs b/boa_engine/src/vm/mod.rs index f5867ceb62e..a924ee1c2ef 100644 --- a/boa_engine/src/vm/mod.rs +++ b/boa_engine/src/vm/mod.rs @@ -252,7 +252,7 @@ pub(crate) enum CompletionType { } #[cfg(feature = "trace")] -impl Context<'_> { +impl Context { const COLUMN_WIDTH: usize = 26; const TIME_COLUMN_WIDTH: usize = Self::COLUMN_WIDTH / 2; const OPCODE_COLUMN_WIDTH: usize = Self::COLUMN_WIDTH; @@ -293,7 +293,7 @@ impl Context<'_> { fn trace_execute_instruction(&mut self, f: F) -> JsResult where - F: FnOnce(Opcode, &mut Context<'_>) -> JsResult, + F: FnOnce(Opcode, &mut Context) -> JsResult, { let bytecodes = &self.vm.frame().code_block.bytecode; let pc = self.vm.frame().pc as usize; @@ -371,10 +371,10 @@ impl Context<'_> { } } -impl Context<'_> { +impl Context { fn execute_instruction(&mut self, f: F) -> JsResult where - F: FnOnce(Opcode, &mut Context<'_>) -> JsResult, + F: FnOnce(Opcode, &mut Context) -> JsResult, { let opcode: Opcode = { let _timer = Profiler::global().start_event("Opcode retrieval", "vm"); @@ -394,7 +394,7 @@ impl Context<'_> { fn execute_one(&mut self, f: F) -> ControlFlow where - F: FnOnce(Opcode, &mut Context<'_>) -> JsResult, + F: FnOnce(Opcode, &mut Context) -> JsResult, { #[cfg(feature = "fuzz")] { diff --git a/boa_engine/src/vm/opcode/arguments.rs b/boa_engine/src/vm/opcode/arguments.rs index 80c399f3cf2..c8cedd01d4f 100644 --- a/boa_engine/src/vm/opcode/arguments.rs +++ b/boa_engine/src/vm/opcode/arguments.rs @@ -18,7 +18,7 @@ impl Operation for CreateMappedArgumentsObject { const INSTRUCTION: &'static str = "INST - CreateMappedArgumentsObject"; const COST: u8 = 8; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let arguments_start = context.vm.frame().fp as usize + CallFrame::FIRST_ARGUMENT_POSITION; let function_object = context .vm @@ -54,7 +54,7 @@ impl Operation for CreateUnmappedArgumentsObject { const INSTRUCTION: &'static str = "INST - CreateUnmappedArgumentsObject"; const COST: u8 = 4; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let arguments_start = context.vm.frame().fp as usize + CallFrame::FIRST_ARGUMENT_POSITION; let args = context.vm.stack[arguments_start..].to_vec(); let arguments = Arguments::create_unmapped_arguments_object(&args, context); diff --git a/boa_engine/src/vm/opcode/await/mod.rs b/boa_engine/src/vm/opcode/await/mod.rs index a4e032c455d..c17ec585791 100644 --- a/boa_engine/src/vm/opcode/await/mod.rs +++ b/boa_engine/src/vm/opcode/await/mod.rs @@ -20,7 +20,7 @@ impl Operation for Await { const INSTRUCTION: &'static str = "INST - Await"; const COST: u8 = 5; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let value = context.vm.pop(); // 2. Let promise be ? PromiseResolve(%Promise%, value). @@ -153,7 +153,7 @@ impl Operation for CreatePromiseCapability { const INSTRUCTION: &'static str = "INST - CreatePromiseCapability"; const COST: u8 = 8; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { if context.vm.frame().promise_capability.is_some() { return Ok(CompletionType::Normal); } @@ -181,7 +181,7 @@ impl Operation for CompletePromiseCapability { const INSTRUCTION: &'static str = "INST - CompletePromiseCapability"; const COST: u8 = 8; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { // If the current executing function is an async function we have to resolve/reject it's promise at the end. // The relevant spec section is 3. in [AsyncBlockStart](https://tc39.es/ecma262/#sec-asyncblockstart). let Some(promise_capability) = context.vm.frame_mut().promise_capability.take() else { diff --git a/boa_engine/src/vm/opcode/binary_ops/logical.rs b/boa_engine/src/vm/opcode/binary_ops/logical.rs index 161c8936a10..547a68a0413 100644 --- a/boa_engine/src/vm/opcode/binary_ops/logical.rs +++ b/boa_engine/src/vm/opcode/binary_ops/logical.rs @@ -15,7 +15,7 @@ impl Operation for LogicalAnd { const INSTRUCTION: &'static str = "INST - LogicalAnd"; const COST: u8 = 1; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let exit = context.vm.read::(); let lhs = context.vm.pop(); if !lhs.to_boolean() { @@ -38,7 +38,7 @@ impl Operation for LogicalOr { const INSTRUCTION: &'static str = "INST - LogicalOr"; const COST: u8 = 1; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let exit = context.vm.read::(); let lhs = context.vm.pop(); if lhs.to_boolean() { @@ -61,7 +61,7 @@ impl Operation for Coalesce { const INSTRUCTION: &'static str = "INST - Coalesce"; const COST: u8 = 1; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let exit = context.vm.read::(); let lhs = context.vm.pop(); if !lhs.is_null_or_undefined() { diff --git a/boa_engine/src/vm/opcode/binary_ops/macro_defined.rs b/boa_engine/src/vm/opcode/binary_ops/macro_defined.rs index 38d6f01dd3d..c36dea2b8f9 100644 --- a/boa_engine/src/vm/opcode/binary_ops/macro_defined.rs +++ b/boa_engine/src/vm/opcode/binary_ops/macro_defined.rs @@ -17,7 +17,7 @@ macro_rules! implement_bin_ops { const INSTRUCTION: &'static str = stringify!("INST - " + $name); const COST: u8 = 2; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let rhs = context.vm.pop(); let lhs = context.vm.pop(); let value = lhs.$op(&rhs, context)?; diff --git a/boa_engine/src/vm/opcode/binary_ops/mod.rs b/boa_engine/src/vm/opcode/binary_ops/mod.rs index 2c801064217..2ecf80d4fe3 100644 --- a/boa_engine/src/vm/opcode/binary_ops/mod.rs +++ b/boa_engine/src/vm/opcode/binary_ops/mod.rs @@ -22,7 +22,7 @@ impl Operation for NotEq { const INSTRUCTION: &'static str = "INST - NotEq"; const COST: u8 = 2; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let rhs = context.vm.pop(); let lhs = context.vm.pop(); let value = !lhs.equals(&rhs, context)?; @@ -43,7 +43,7 @@ impl Operation for StrictEq { const INSTRUCTION: &'static str = "INST - StrictEq"; const COST: u8 = 2; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let rhs = context.vm.pop(); let lhs = context.vm.pop(); context.vm.push(lhs.strict_equals(&rhs)); @@ -63,7 +63,7 @@ impl Operation for StrictNotEq { const INSTRUCTION: &'static str = "INST - StrictNotEq"; const COST: u8 = 2; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let rhs = context.vm.pop(); let lhs = context.vm.pop(); context.vm.push(!lhs.strict_equals(&rhs)); @@ -83,7 +83,7 @@ impl Operation for In { const INSTRUCTION: &'static str = "INST - In"; const COST: u8 = 3; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let rhs = context.vm.pop(); let lhs = context.vm.pop(); @@ -110,7 +110,7 @@ impl Operation for In { pub(crate) struct InPrivate; impl InPrivate { - fn operation(context: &mut Context<'_>, index: usize) -> JsResult { + fn operation(context: &mut Context, index: usize) -> JsResult { let name = context.vm.frame().code_block().constant_string(index); let rhs = context.vm.pop(); @@ -143,17 +143,17 @@ impl Operation for InPrivate { const INSTRUCTION: &'static str = "INST - InPrivate"; const COST: u8 = 4; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } @@ -171,7 +171,7 @@ impl Operation for InstanceOf { const INSTRUCTION: &'static str = "INST - InstanceOf"; const COST: u8 = 4; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let target = context.vm.pop(); let v = context.vm.pop(); let value = v.instance_of(&target, context)?; diff --git a/boa_engine/src/vm/opcode/call/mod.rs b/boa_engine/src/vm/opcode/call/mod.rs index 1ea6696e5e5..4affc43f6f6 100644 --- a/boa_engine/src/vm/opcode/call/mod.rs +++ b/boa_engine/src/vm/opcode/call/mod.rs @@ -15,7 +15,7 @@ use crate::{ pub(crate) struct CallEval; impl CallEval { - fn operation(context: &mut Context<'_>, argument_count: usize) -> JsResult { + fn operation(context: &mut Context, argument_count: usize) -> JsResult { let at = context.vm.stack.len() - argument_count; let func = &context.vm.stack[at - 1]; @@ -67,17 +67,17 @@ impl Operation for CallEval { // the cost of the call. const COST: u8 = 5; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let argument_count = context.vm.read::(); Self::operation(context, argument_count as usize) } - fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context) -> JsResult { let argument_count = context.vm.read::() as usize; Self::operation(context, argument_count) } - fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(context: &mut Context) -> JsResult { let argument_count = context.vm.read::(); Self::operation(context, argument_count as usize) } @@ -97,7 +97,7 @@ impl Operation for CallEvalSpread { // the cost of the call. const COST: u8 = 5; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { // Get the arguments that are stored as an array object on the stack. let arguments_array = context.vm.pop(); let arguments_array_object = arguments_array @@ -164,7 +164,7 @@ impl Operation for CallEvalSpread { pub(crate) struct Call; impl Call { - fn operation(context: &mut Context<'_>, argument_count: usize) -> JsResult { + fn operation(context: &mut Context, argument_count: usize) -> JsResult { let at = context.vm.stack.len() - argument_count; let func = &context.vm.stack[at - 1]; @@ -184,17 +184,17 @@ impl Operation for Call { const INSTRUCTION: &'static str = "INST - Call"; const COST: u8 = 3; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let argument_count = context.vm.read::(); Self::operation(context, argument_count as usize) } - fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context) -> JsResult { let argument_count = context.vm.read::() as usize; Self::operation(context, argument_count) } - fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(context: &mut Context) -> JsResult { let argument_count = context.vm.read::(); Self::operation(context, argument_count as usize) } @@ -208,7 +208,7 @@ impl Operation for CallSpread { const INSTRUCTION: &'static str = "INST - CallSpread"; const COST: u8 = 3; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { // Get the arguments that are stored as an array object on the stack. let arguments_array = context.vm.pop(); let arguments_array_object = arguments_array @@ -250,7 +250,7 @@ impl Operation for ImportCall { const INSTRUCTION: &'static str = "INST - ImportCall"; const COST: u8 = 15; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { // Import Calls // Runtime Semantics: Evaluation // https://tc39.es/ecma262/#sec-import-call-runtime-semantics-evaluation diff --git a/boa_engine/src/vm/opcode/concat/mod.rs b/boa_engine/src/vm/opcode/concat/mod.rs index 068e4c96e61..d6d33a215c7 100644 --- a/boa_engine/src/vm/opcode/concat/mod.rs +++ b/boa_engine/src/vm/opcode/concat/mod.rs @@ -11,7 +11,7 @@ use crate::{ pub(crate) struct ConcatToString; impl ConcatToString { - fn operation(context: &mut Context<'_>, value_count: usize) -> JsResult { + fn operation(context: &mut Context, value_count: usize) -> JsResult { let mut strings = Vec::with_capacity(value_count); for _ in 0..value_count { strings.push(context.vm.pop().to_string(context)?); @@ -33,17 +33,17 @@ impl Operation for ConcatToString { const INSTRUCTION: &'static str = "INST - ConcatToString"; const COST: u8 = 6; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let value_count = context.vm.read::() as usize; Self::operation(context, value_count) } - fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context) -> JsResult { let value_count = context.vm.read::() as usize; Self::operation(context, value_count) } - fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(context: &mut Context) -> JsResult { let value_count = context.vm.read::() as usize; Self::operation(context, value_count) } diff --git a/boa_engine/src/vm/opcode/control_flow/jump.rs b/boa_engine/src/vm/opcode/control_flow/jump.rs index 9b7b6a46c3d..5ed13643b5d 100644 --- a/boa_engine/src/vm/opcode/control_flow/jump.rs +++ b/boa_engine/src/vm/opcode/control_flow/jump.rs @@ -15,7 +15,7 @@ impl Operation for Jump { const INSTRUCTION: &'static str = "INST - Jump"; const COST: u8 = 1; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let address = context.vm.read::(); context.vm.frame_mut().pc = address; Ok(CompletionType::Normal) @@ -34,7 +34,7 @@ impl Operation for JumpIfTrue { const INSTRUCTION: &'static str = "INST - JumpIfTrue"; const COST: u8 = 1; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let address = context.vm.read::(); if context.vm.pop().to_boolean() { context.vm.frame_mut().pc = address; @@ -55,7 +55,7 @@ impl Operation for JumpIfFalse { const INSTRUCTION: &'static str = "INST - JumpIfFalse"; const COST: u8 = 1; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let address = context.vm.read::(); if !context.vm.pop().to_boolean() { context.vm.frame_mut().pc = address; @@ -76,7 +76,7 @@ impl Operation for JumpIfNotUndefined { const INSTRUCTION: &'static str = "INST - JumpIfNotUndefined"; const COST: u8 = 1; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let address = context.vm.read::(); let value = context.vm.pop(); if !value.is_undefined() { @@ -99,7 +99,7 @@ impl Operation for JumpIfNullOrUndefined { const INSTRUCTION: &'static str = "INST - JumpIfNullOrUndefined"; const COST: u8 = 1; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let address = context.vm.read::(); let value = context.vm.pop(); if value.is_null_or_undefined() { @@ -123,7 +123,7 @@ impl Operation for JumpTable { const INSTRUCTION: &'static str = "INST - JumpTable"; const COST: u8 = 5; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let default = context.vm.read::(); let count = context.vm.read::(); diff --git a/boa_engine/src/vm/opcode/control_flow/return.rs b/boa_engine/src/vm/opcode/control_flow/return.rs index 4b6ea6b0487..2296c410210 100644 --- a/boa_engine/src/vm/opcode/control_flow/return.rs +++ b/boa_engine/src/vm/opcode/control_flow/return.rs @@ -15,7 +15,7 @@ impl Operation for Return { const INSTRUCTION: &'static str = "INST - Return"; const COST: u8 = 4; - fn execute(_context: &mut Context<'_>) -> JsResult { + fn execute(_context: &mut Context) -> JsResult { Ok(CompletionType::Return) } } @@ -32,7 +32,7 @@ impl Operation for CheckReturn { const INSTRUCTION: &'static str = "INST - CheckReturn"; const COST: u8 = 3; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { if !context.vm.frame().construct() { return Ok(CompletionType::Normal); } @@ -84,7 +84,7 @@ impl Operation for GetReturnValue { const INSTRUCTION: &'static str = "INST - GetReturnValue"; const COST: u8 = 2; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let value = context.vm.get_return_value(); context.vm.push(value); Ok(CompletionType::Normal) @@ -103,7 +103,7 @@ impl Operation for SetReturnValue { const INSTRUCTION: &'static str = "INST - SetReturnValue"; const COST: u8 = 2; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let value = context.vm.pop(); context.vm.set_return_value(value); Ok(CompletionType::Normal) diff --git a/boa_engine/src/vm/opcode/control_flow/throw.rs b/boa_engine/src/vm/opcode/control_flow/throw.rs index 5ea28b84249..bde9b6288f7 100644 --- a/boa_engine/src/vm/opcode/control_flow/throw.rs +++ b/boa_engine/src/vm/opcode/control_flow/throw.rs @@ -15,7 +15,7 @@ impl Operation for Throw { const INSTRUCTION: &'static str = "INST - Throw"; const COST: u8 = 6; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let error = JsError::from_opaque(context.vm.pop()); context.vm.pending_exception = Some(error); @@ -41,7 +41,7 @@ impl Operation for ReThrow { const INSTRUCTION: &'static str = "INST - ReThrow"; const COST: u8 = 2; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { // Note: -1 because we increment after fetching the opcode. let pc = context.vm.frame().pc.saturating_sub(1); if context.vm.handle_exception_at(pc) { @@ -73,7 +73,7 @@ impl Operation for Exception { const INSTRUCTION: &'static str = "INST - Exception"; const COST: u8 = 2; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { if let Some(error) = context.vm.pending_exception.take() { let error = error.to_opaque(context); context.vm.push(error); @@ -101,7 +101,7 @@ impl Operation for MaybeException { const INSTRUCTION: &'static str = "INST - MaybeException"; const COST: u8 = 3; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { if let Some(error) = context.vm.pending_exception.take() { let error = error.to_opaque(context); context.vm.push(error); @@ -122,7 +122,7 @@ impl Operation for MaybeException { pub(crate) struct ThrowNewTypeError; impl ThrowNewTypeError { - fn operation(context: &mut Context<'_>, index: usize) -> JsResult { + fn operation(context: &mut Context, index: usize) -> JsResult { let msg = context.vm.frame().code_block().constant_string(index); let msg = msg .to_std_string() @@ -136,17 +136,17 @@ impl Operation for ThrowNewTypeError { const INSTRUCTION: &'static str = "INST - ThrowNewTypeError"; const COST: u8 = 2; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } diff --git a/boa_engine/src/vm/opcode/copy/mod.rs b/boa_engine/src/vm/opcode/copy/mod.rs index 1413459c66d..a33e8d03551 100644 --- a/boa_engine/src/vm/opcode/copy/mod.rs +++ b/boa_engine/src/vm/opcode/copy/mod.rs @@ -12,7 +12,7 @@ pub(crate) struct CopyDataProperties; impl CopyDataProperties { fn operation( - context: &mut Context<'_>, + context: &mut Context, excluded_key_count: usize, excluded_key_count_computed: usize, ) -> JsResult { @@ -45,19 +45,19 @@ impl Operation for CopyDataProperties { const INSTRUCTION: &'static str = "INST - CopyDataProperties"; const COST: u8 = 6; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let excluded_key_count = context.vm.read::() as usize; let excluded_key_count_computed = context.vm.read::() as usize; Self::operation(context, excluded_key_count, excluded_key_count_computed) } - fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context) -> JsResult { let excluded_key_count = context.vm.read::() as usize; let excluded_key_count_computed = context.vm.read::() as usize; Self::operation(context, excluded_key_count, excluded_key_count_computed) } - fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(context: &mut Context) -> JsResult { let excluded_key_count = context.vm.read::() as usize; let excluded_key_count_computed = context.vm.read::() as usize; Self::operation(context, excluded_key_count, excluded_key_count_computed) diff --git a/boa_engine/src/vm/opcode/define/class/getter.rs b/boa_engine/src/vm/opcode/define/class/getter.rs index 5b9d6ca4706..128fd886ce4 100644 --- a/boa_engine/src/vm/opcode/define/class/getter.rs +++ b/boa_engine/src/vm/opcode/define/class/getter.rs @@ -13,7 +13,7 @@ use crate::{ pub(crate) struct DefineClassStaticGetterByName; impl DefineClassStaticGetterByName { - fn operation(context: &mut Context<'_>, index: usize) -> JsResult { + fn operation(context: &mut Context, index: usize) -> JsResult { let function = context.vm.pop(); let class = context.vm.pop(); let class = class.as_object().expect("class must be object"); @@ -58,17 +58,17 @@ impl Operation for DefineClassStaticGetterByName { const INSTRUCTION: &'static str = "INST - DefineClassStaticGetterByName"; const COST: u8 = 6; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } @@ -82,7 +82,7 @@ impl Operation for DefineClassStaticGetterByName { pub(crate) struct DefineClassGetterByName; impl DefineClassGetterByName { - fn operation(context: &mut Context<'_>, index: usize) -> JsResult { + fn operation(context: &mut Context, index: usize) -> JsResult { let function = context.vm.pop(); let class_proto = context.vm.pop(); let class_proto = class_proto.as_object().expect("class must be object"); @@ -127,17 +127,17 @@ impl Operation for DefineClassGetterByName { const INSTRUCTION: &'static str = "INST - DefineClassGetterByName"; const COST: u8 = 6; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } @@ -155,7 +155,7 @@ impl Operation for DefineClassStaticGetterByValue { const INSTRUCTION: &'static str = "INST - DefineClassStaticGetterByValue"; const COST: u8 = 6; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let function = context.vm.pop(); let key = context.vm.pop(); let class = context.vm.pop(); @@ -205,7 +205,7 @@ impl Operation for DefineClassGetterByValue { const INSTRUCTION: &'static str = "INST - DefineClassGetterByValue"; const COST: u8 = 6; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let function = context.vm.pop(); let key = context.vm.pop(); let class_proto = context.vm.pop(); diff --git a/boa_engine/src/vm/opcode/define/class/method.rs b/boa_engine/src/vm/opcode/define/class/method.rs index bc6e8b53e41..19cb735f2fb 100644 --- a/boa_engine/src/vm/opcode/define/class/method.rs +++ b/boa_engine/src/vm/opcode/define/class/method.rs @@ -13,7 +13,7 @@ use crate::{ pub(crate) struct DefineClassStaticMethodByName; impl DefineClassStaticMethodByName { - fn operation(context: &mut Context<'_>, index: usize) -> JsResult { + fn operation(context: &mut Context, index: usize) -> JsResult { let function = context.vm.pop(); let class = context.vm.pop(); let class = class.as_object().expect("class must be object"); @@ -54,17 +54,17 @@ impl Operation for DefineClassStaticMethodByName { const INSTRUCTION: &'static str = "INST - DefineClassStaticMethodByName"; const COST: u8 = 6; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } @@ -78,7 +78,7 @@ impl Operation for DefineClassStaticMethodByName { pub(crate) struct DefineClassMethodByName; impl DefineClassMethodByName { - fn operation(context: &mut Context<'_>, index: usize) -> JsResult { + fn operation(context: &mut Context, index: usize) -> JsResult { let function = context.vm.pop(); let class_proto = context.vm.pop(); let class_proto = class_proto.as_object().expect("class must be object"); @@ -119,17 +119,17 @@ impl Operation for DefineClassMethodByName { const INSTRUCTION: &'static str = "INST - DefineClassMethodByName"; const COST: u8 = 6; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } @@ -147,7 +147,7 @@ impl Operation for DefineClassStaticMethodByValue { const INSTRUCTION: &'static str = "INST - DefineClassStaticMethodByValue"; const COST: u8 = 6; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let function = context.vm.pop(); let key = context.vm.pop(); let class = context.vm.pop(); @@ -193,7 +193,7 @@ impl Operation for DefineClassMethodByValue { const INSTRUCTION: &'static str = "INST - DefineClassMethodByValue"; const COST: u8 = 6; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let function = context.vm.pop(); let key = context.vm.pop(); let class_proto = context.vm.pop(); diff --git a/boa_engine/src/vm/opcode/define/class/setter.rs b/boa_engine/src/vm/opcode/define/class/setter.rs index 73cfa2740ea..58a7131a119 100644 --- a/boa_engine/src/vm/opcode/define/class/setter.rs +++ b/boa_engine/src/vm/opcode/define/class/setter.rs @@ -13,7 +13,7 @@ use crate::{ pub(crate) struct DefineClassStaticSetterByName; impl DefineClassStaticSetterByName { - fn operation(context: &mut Context<'_>, index: usize) -> JsResult { + fn operation(context: &mut Context, index: usize) -> JsResult { let function = context.vm.pop(); let class = context.vm.pop(); let class = class.as_object().expect("class must be object"); @@ -59,17 +59,17 @@ impl Operation for DefineClassStaticSetterByName { const INSTRUCTION: &'static str = "INST - DefineClassStaticSetterByName"; const COST: u8 = 6; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } @@ -83,7 +83,7 @@ impl Operation for DefineClassStaticSetterByName { pub(crate) struct DefineClassSetterByName; impl DefineClassSetterByName { - fn operation(context: &mut Context<'_>, index: usize) -> JsResult { + fn operation(context: &mut Context, index: usize) -> JsResult { let function = context.vm.pop(); let class_proto = context.vm.pop(); let class_proto = class_proto.as_object().expect("class must be object"); @@ -130,17 +130,17 @@ impl Operation for DefineClassSetterByName { const INSTRUCTION: &'static str = "INST - DefineClassSetterByName"; const COST: u8 = 6; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } @@ -158,7 +158,7 @@ impl Operation for DefineClassStaticSetterByValue { const INSTRUCTION: &'static str = "INST - DefineClassStaticSetterByValue"; const COST: u8 = 6; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let function = context.vm.pop(); let key = context.vm.pop(); let class = context.vm.pop(); @@ -210,7 +210,7 @@ impl Operation for DefineClassSetterByValue { const INSTRUCTION: &'static str = "INST - DefineClassSetterByValue"; const COST: u8 = 6; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let function = context.vm.pop(); let key = context.vm.pop(); let class_proto = context.vm.pop(); diff --git a/boa_engine/src/vm/opcode/define/mod.rs b/boa_engine/src/vm/opcode/define/mod.rs index bee48d200b9..4641229481b 100644 --- a/boa_engine/src/vm/opcode/define/mod.rs +++ b/boa_engine/src/vm/opcode/define/mod.rs @@ -18,7 +18,7 @@ pub(crate) struct DefVar; impl DefVar { #[allow(clippy::unnecessary_wraps)] - fn operation(context: &mut Context<'_>, index: usize) -> JsResult { + fn operation(context: &mut Context, index: usize) -> JsResult { // TODO: spec specifies to return `empty` on empty vars, but we're trying to initialize. let binding_locator = context.vm.frame().code_block.bindings[index]; @@ -36,17 +36,17 @@ impl Operation for DefVar { const INSTRUCTION: &'static str = "INST - DefVar"; const COST: u8 = 3; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let index = context.vm.read::(); Self::operation(context, index as usize) } - fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(context: &mut Context) -> JsResult { let index = context.vm.read::(); Self::operation(context, index as usize) } @@ -60,7 +60,7 @@ impl Operation for DefVar { pub(crate) struct DefInitVar; impl DefInitVar { - fn operation(context: &mut Context<'_>, index: usize) -> JsResult { + fn operation(context: &mut Context, index: usize) -> JsResult { let value = context.vm.pop(); let mut binding_locator = context.vm.frame().code_block.bindings[index]; context.find_runtime_binding(&mut binding_locator)?; @@ -79,17 +79,17 @@ impl Operation for DefInitVar { const INSTRUCTION: &'static str = "INST - DefInitVar"; const COST: u8 = 3; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let index = context.vm.read::(); Self::operation(context, index as usize) } - fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(context: &mut Context) -> JsResult { let index = context.vm.read::(); Self::operation(context, index as usize) } @@ -104,7 +104,7 @@ pub(crate) struct PutLexicalValue; impl PutLexicalValue { #[allow(clippy::unnecessary_wraps)] - fn operation(context: &mut Context<'_>, index: usize) -> JsResult { + fn operation(context: &mut Context, index: usize) -> JsResult { let value = context.vm.pop(); let binding_locator = context.vm.frame().code_block.bindings[index]; context.vm.environments.put_lexical_value( @@ -122,17 +122,17 @@ impl Operation for PutLexicalValue { const INSTRUCTION: &'static str = "INST - PutLexicalValue"; const COST: u8 = 3; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let index = context.vm.read::(); Self::operation(context, index as usize) } - fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(context: &mut Context) -> JsResult { let index = context.vm.read::(); Self::operation(context, index as usize) } @@ -150,7 +150,7 @@ pub(crate) struct CreateGlobalFunctionBinding; impl CreateGlobalFunctionBinding { #[allow(clippy::unnecessary_wraps)] fn operation( - context: &mut Context<'_>, + context: &mut Context, index: usize, configurable: bool, ) -> JsResult { @@ -172,19 +172,19 @@ impl Operation for CreateGlobalFunctionBinding { const INSTRUCTION: &'static str = "INST - CreateGlobalFunctionBinding"; const COST: u8 = 2; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let configurable = context.vm.read::() != 0; let index = context.vm.read::() as usize; Self::operation(context, index, configurable) } - fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context) -> JsResult { let configurable = context.vm.read::() != 0; let index = context.vm.read::() as usize; Self::operation(context, index, configurable) } - fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(context: &mut Context) -> JsResult { let configurable = context.vm.read::() != 0; let index = context.vm.read::() as usize; Self::operation(context, index, configurable) diff --git a/boa_engine/src/vm/opcode/define/own_property.rs b/boa_engine/src/vm/opcode/define/own_property.rs index 82dde0f9961..817b93ca707 100644 --- a/boa_engine/src/vm/opcode/define/own_property.rs +++ b/boa_engine/src/vm/opcode/define/own_property.rs @@ -12,7 +12,7 @@ use crate::{ pub(crate) struct DefineOwnPropertyByName; impl DefineOwnPropertyByName { - fn operation(context: &mut Context<'_>, index: usize) -> JsResult { + fn operation(context: &mut Context, index: usize) -> JsResult { let value = context.vm.pop(); let object = context.vm.pop(); let object = if let Some(object) = object.as_object() { @@ -40,17 +40,17 @@ impl Operation for DefineOwnPropertyByName { const INSTRUCTION: &'static str = "INST - DefineOwnPropertyByName"; const COST: u8 = 4; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } @@ -68,7 +68,7 @@ impl Operation for DefineOwnPropertyByValue { const INSTRUCTION: &'static str = "INST - DefineOwnPropertyByValue"; const COST: u8 = 4; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let value = context.vm.pop(); let key = context.vm.pop(); let object = context.vm.pop(); diff --git a/boa_engine/src/vm/opcode/delete/mod.rs b/boa_engine/src/vm/opcode/delete/mod.rs index 2068ea8798d..375dd270681 100644 --- a/boa_engine/src/vm/opcode/delete/mod.rs +++ b/boa_engine/src/vm/opcode/delete/mod.rs @@ -12,7 +12,7 @@ use crate::{ pub(crate) struct DeletePropertyByName; impl DeletePropertyByName { - fn operation(context: &mut Context<'_>, index: usize) -> JsResult { + fn operation(context: &mut Context, index: usize) -> JsResult { let value = context.vm.pop(); let object = value.to_object(context)?; let key = context @@ -37,17 +37,17 @@ impl Operation for DeletePropertyByName { const INSTRUCTION: &'static str = "INST - DeletePropertyByName"; const COST: u8 = 3; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } @@ -65,7 +65,7 @@ impl Operation for DeletePropertyByValue { const INSTRUCTION: &'static str = "INST - DeletePropertyByValue"; const COST: u8 = 3; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let key_value = context.vm.pop(); let value = context.vm.pop(); let object = value.to_object(context)?; @@ -89,7 +89,7 @@ impl Operation for DeletePropertyByValue { pub(crate) struct DeleteName; impl DeleteName { - fn operation(context: &mut Context<'_>, index: usize) -> JsResult { + fn operation(context: &mut Context, index: usize) -> JsResult { let mut binding_locator = context.vm.frame().code_block.bindings[index]; context.find_runtime_binding(&mut binding_locator)?; @@ -106,17 +106,17 @@ impl Operation for DeleteName { const INSTRUCTION: &'static str = "INST - DeleteName"; const COST: u8 = 3; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let index = context.vm.read::(); Self::operation(context, index as usize) } - fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(context: &mut Context) -> JsResult { let index = context.vm.read::(); Self::operation(context, index as usize) } @@ -134,7 +134,7 @@ impl Operation for DeleteSuperThrow { const INSTRUCTION: &'static str = "INST - DeleteSuperThrow"; const COST: u8 = 2; - fn execute(_: &mut Context<'_>) -> JsResult { + fn execute(_: &mut Context) -> JsResult { Err(JsNativeError::reference() .with_message("cannot delete a property of `super`") .into()) diff --git a/boa_engine/src/vm/opcode/dup/mod.rs b/boa_engine/src/vm/opcode/dup/mod.rs index 963d063a3b6..bf19e640aa6 100644 --- a/boa_engine/src/vm/opcode/dup/mod.rs +++ b/boa_engine/src/vm/opcode/dup/mod.rs @@ -15,7 +15,7 @@ impl Operation for Dup { const INSTRUCTION: &'static str = "INST - Dup"; const COST: u8 = 1; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let value = context.vm.pop(); context.vm.push(value.clone()); context.vm.push(value); diff --git a/boa_engine/src/vm/opcode/environment/mod.rs b/boa_engine/src/vm/opcode/environment/mod.rs index d08c658df8c..aadba960aca 100644 --- a/boa_engine/src/vm/opcode/environment/mod.rs +++ b/boa_engine/src/vm/opcode/environment/mod.rs @@ -16,7 +16,7 @@ impl Operation for This { const INSTRUCTION: &'static str = "INST - This"; const COST: u8 = 1; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let this = context.vm.environments.get_this_binding()?; context.vm.push(this); Ok(CompletionType::Normal) @@ -35,7 +35,7 @@ impl Operation for Super { const INSTRUCTION: &'static str = "INST - Super"; const COST: u8 = 3; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let home_object = { let env = context .vm @@ -76,7 +76,7 @@ impl Operation for SuperCallPrepare { const INSTRUCTION: &'static str = "INST - SuperCallPrepare"; const COST: u8 = 3; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let this_env = context .vm .environments @@ -103,7 +103,7 @@ impl Operation for SuperCallPrepare { pub(crate) struct SuperCall; impl SuperCall { - fn operation(context: &mut Context<'_>, argument_count: usize) -> JsResult { + fn operation(context: &mut Context, argument_count: usize) -> JsResult { let super_constructor_index = context.vm.stack.len() - argument_count - 1; let super_constructor = context.vm.stack[super_constructor_index].clone(); let Some(super_constructor) = super_constructor.as_constructor() else { @@ -139,17 +139,17 @@ impl Operation for SuperCall { const INSTRUCTION: &'static str = "INST - SuperCall"; const COST: u8 = 3; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let value_count = context.vm.read::() as usize; Self::operation(context, value_count) } - fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context) -> JsResult { let value_count = context.vm.read::() as usize; Self::operation(context, value_count) } - fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(context: &mut Context) -> JsResult { let value_count = context.vm.read::() as usize; Self::operation(context, value_count) } @@ -167,7 +167,7 @@ impl Operation for SuperCallSpread { const INSTRUCTION: &'static str = "INST - SuperCallSpread"; const COST: u8 = 3; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { // Get the arguments that are stored as an array object on the stack. let arguments_array = context.vm.pop(); let arguments_array_object = arguments_array @@ -226,7 +226,7 @@ impl Operation for SuperCallDerived { const INSTRUCTION: &'static str = "INST - SuperCallDerived"; const COST: u8 = 3; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let argument_count = context.vm.frame().argument_count as usize; let this_env = context @@ -279,7 +279,7 @@ impl Operation for BindThisValue { const INSTRUCTION: &'static str = "INST - BindThisValue"; const COST: u8 = 6; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { // Taken from `SuperCall : super Arguments` steps 7-12. // // diff --git a/boa_engine/src/vm/opcode/generator/mod.rs b/boa_engine/src/vm/opcode/generator/mod.rs index 08418bd68e0..9579e15a1d0 100644 --- a/boa_engine/src/vm/opcode/generator/mod.rs +++ b/boa_engine/src/vm/opcode/generator/mod.rs @@ -34,7 +34,7 @@ impl Operation for Generator { const INSTRUCTION: &'static str = "INST - Generator"; const COST: u8 = 8; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let r#async = context.vm.read::() != 0; let frame = context.vm.frame(); @@ -131,7 +131,7 @@ impl Operation for AsyncGeneratorClose { const INSTRUCTION: &'static str = "INST - AsyncGeneratorClose"; const COST: u8 = 8; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { // Step 3.e-g in [AsyncGeneratorStart](https://tc39.es/ecma262/#sec-asyncgeneratorstart) let generator_object = context .vm @@ -180,7 +180,7 @@ impl Operation for GeneratorNext { const INSTRUCTION: &'static str = "INST - GeneratorNext"; const COST: u8 = 1; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let generator_resume_kind = context.vm.pop().to_generator_resume_kind(); match generator_resume_kind { GeneratorResumeKind::Normal => Ok(CompletionType::Normal), @@ -207,7 +207,7 @@ impl Operation for JumpIfNotResumeKind { const INSTRUCTION: &'static str = "INST - JumpIfNotResumeKind"; const COST: u8 = 1; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let exit = context.vm.read::(); let resume_kind = context.vm.read::(); @@ -234,7 +234,7 @@ impl Operation for GeneratorDelegateNext { const INSTRUCTION: &'static str = "INST - GeneratorDelegateNext"; const COST: u8 = 18; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let throw_method_undefined = context.vm.read::(); let return_method_undefined = context.vm.read::(); @@ -324,7 +324,7 @@ impl Operation for GeneratorDelegateResume { const INSTRUCTION: &'static str = "INST - GeneratorDelegateResume"; const COST: u8 = 7; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let return_gen = context.vm.read::(); let exit = context.vm.read::(); diff --git a/boa_engine/src/vm/opcode/generator/yield_stm.rs b/boa_engine/src/vm/opcode/generator/yield_stm.rs index 13c5be3f6cc..97a2cb8aeb4 100644 --- a/boa_engine/src/vm/opcode/generator/yield_stm.rs +++ b/boa_engine/src/vm/opcode/generator/yield_stm.rs @@ -16,7 +16,7 @@ impl Operation for GeneratorYield { const INSTRUCTION: &'static str = "INST - GeneratorYield"; const COST: u8 = 1; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let value = context.vm.pop(); context.vm.set_return_value(value); Ok(CompletionType::Yield) @@ -35,7 +35,7 @@ impl Operation for AsyncGeneratorYield { const INSTRUCTION: &'static str = "INST - AsyncGeneratorYield"; const COST: u8 = 8; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let value = context.vm.pop(); let async_gen = context diff --git a/boa_engine/src/vm/opcode/get/argument.rs b/boa_engine/src/vm/opcode/get/argument.rs index a27f23dab6c..77ab9324585 100644 --- a/boa_engine/src/vm/opcode/get/argument.rs +++ b/boa_engine/src/vm/opcode/get/argument.rs @@ -12,7 +12,7 @@ pub(crate) struct GetArgument; impl GetArgument { #[allow(clippy::unnecessary_wraps)] - fn operation(context: &mut Context<'_>, index: usize) -> JsResult { + fn operation(context: &mut Context, index: usize) -> JsResult { let fp = context.vm.frame().fp as usize; let argument_index = fp + 2; let argument_count = context.vm.frame().argument_count as usize; @@ -31,17 +31,17 @@ impl Operation for GetArgument { const INSTRUCTION: &'static str = "INST - GetArgument"; const COST: u8 = 2; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } diff --git a/boa_engine/src/vm/opcode/get/function.rs b/boa_engine/src/vm/opcode/get/function.rs index c84b13371a9..bd19632532f 100644 --- a/boa_engine/src/vm/opcode/get/function.rs +++ b/boa_engine/src/vm/opcode/get/function.rs @@ -12,7 +12,7 @@ pub(crate) struct GetFunction; impl GetFunction { #[allow(clippy::unnecessary_wraps)] - fn operation(context: &mut Context<'_>, index: usize) -> JsResult { + fn operation(context: &mut Context, index: usize) -> JsResult { let code = context.vm.frame().code_block().constant_function(index); let function = create_function_object_fast(code, context); context.vm.push(function); @@ -25,17 +25,17 @@ impl Operation for GetFunction { const INSTRUCTION: &'static str = "INST - GetFunction"; const COST: u8 = 3; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } diff --git a/boa_engine/src/vm/opcode/get/name.rs b/boa_engine/src/vm/opcode/get/name.rs index f2b3ce87c9d..b5560ca1412 100644 --- a/boa_engine/src/vm/opcode/get/name.rs +++ b/boa_engine/src/vm/opcode/get/name.rs @@ -12,7 +12,7 @@ use crate::{ pub(crate) struct GetName; impl GetName { - fn operation(context: &mut Context<'_>, index: usize) -> JsResult { + fn operation(context: &mut Context, index: usize) -> JsResult { let mut binding_locator = context.vm.frame().code_block.bindings[index]; context.find_runtime_binding(&mut binding_locator)?; let value = context.get_binding(binding_locator)?.ok_or_else(|| { @@ -33,17 +33,17 @@ impl Operation for GetName { const INSTRUCTION: &'static str = "INST - GetName"; const COST: u8 = 4; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let index = context.vm.read::(); Self::operation(context, index as usize) } - fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(context: &mut Context) -> JsResult { let index = context.vm.read::(); Self::operation(context, index as usize) } @@ -57,7 +57,7 @@ impl Operation for GetName { pub(crate) struct GetLocator; impl GetLocator { - fn operation(context: &mut Context<'_>, index: usize) -> JsResult { + fn operation(context: &mut Context, index: usize) -> JsResult { let mut binding_locator = context.vm.frame().code_block.bindings[index]; context.find_runtime_binding(&mut binding_locator)?; @@ -72,17 +72,17 @@ impl Operation for GetLocator { const INSTRUCTION: &'static str = "INST - GetLocator"; const COST: u8 = 4; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let index = context.vm.read::(); Self::operation(context, index as usize) } - fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(context: &mut Context) -> JsResult { let index = context.vm.read::(); Self::operation(context, index as usize) } @@ -97,7 +97,7 @@ impl Operation for GetLocator { pub(crate) struct GetNameAndLocator; impl GetNameAndLocator { - fn operation(context: &mut Context<'_>, index: usize) -> JsResult { + fn operation(context: &mut Context, index: usize) -> JsResult { let mut binding_locator = context.vm.frame().code_block.bindings[index]; context.find_runtime_binding(&mut binding_locator)?; let value = context.get_binding(binding_locator)?.ok_or_else(|| { @@ -119,17 +119,17 @@ impl Operation for GetNameAndLocator { const INSTRUCTION: &'static str = "INST - GetNameAndLocator"; const COST: u8 = 4; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let index = context.vm.read::(); Self::operation(context, index as usize) } - fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(context: &mut Context) -> JsResult { let index = context.vm.read::(); Self::operation(context, index as usize) } @@ -143,7 +143,7 @@ impl Operation for GetNameAndLocator { pub(crate) struct GetNameOrUndefined; impl GetNameOrUndefined { - fn operation(context: &mut Context<'_>, index: usize) -> JsResult { + fn operation(context: &mut Context, index: usize) -> JsResult { let mut binding_locator = context.vm.frame().code_block.bindings[index]; let is_global = binding_locator.is_global(); @@ -174,17 +174,17 @@ impl Operation for GetNameOrUndefined { const INSTRUCTION: &'static str = "INST - GetNameOrUndefined"; const COST: u8 = 4; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let index = context.vm.read::(); Self::operation(context, index as usize) } - fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(context: &mut Context) -> JsResult { let index = context.vm.read::(); Self::operation(context, index as usize) } diff --git a/boa_engine/src/vm/opcode/get/private.rs b/boa_engine/src/vm/opcode/get/private.rs index 269eee1d21d..cca43b0186c 100644 --- a/boa_engine/src/vm/opcode/get/private.rs +++ b/boa_engine/src/vm/opcode/get/private.rs @@ -11,7 +11,7 @@ use crate::{ pub(crate) struct GetPrivateField; impl GetPrivateField { - fn operation(context: &mut Context<'_>, index: usize) -> JsResult { + fn operation(context: &mut Context, index: usize) -> JsResult { let name = context.vm.frame().code_block().constant_string(index); let value = context.vm.pop(); let base_obj = value.to_object(context)?; @@ -33,17 +33,17 @@ impl Operation for GetPrivateField { const INSTRUCTION: &'static str = "INST - GetPrivateField"; const COST: u8 = 4; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } diff --git a/boa_engine/src/vm/opcode/get/property.rs b/boa_engine/src/vm/opcode/get/property.rs index fe077618ec6..1a7aa2873fa 100644 --- a/boa_engine/src/vm/opcode/get/property.rs +++ b/boa_engine/src/vm/opcode/get/property.rs @@ -12,7 +12,7 @@ use crate::{ pub(crate) struct GetPropertyByName; impl GetPropertyByName { - fn operation(context: &mut Context<'_>, index: usize) -> JsResult { + fn operation(context: &mut Context, index: usize) -> JsResult { let receiver = context.vm.pop(); let value = context.vm.pop(); let object = if let Some(object) = value.as_object() { @@ -39,17 +39,17 @@ impl Operation for GetPropertyByName { const INSTRUCTION: &'static str = "INST - GetPropertyByName"; const COST: u8 = 4; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let index = context.vm.read::(); Self::operation(context, index as usize) } - fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(context: &mut Context) -> JsResult { let index = context.vm.read::(); Self::operation(context, index as usize) } @@ -67,7 +67,7 @@ impl Operation for GetPropertyByValue { const INSTRUCTION: &'static str = "INST - GetPropertyByValue"; const COST: u8 = 4; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let key = context.vm.pop(); let receiver = context.vm.pop(); let value = context.vm.pop(); @@ -114,7 +114,7 @@ impl Operation for GetPropertyByValuePush { const INSTRUCTION: &'static str = "INST - GetPropertyByValuePush"; const COST: u8 = 4; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let key = context.vm.pop(); let receiver = context.vm.pop(); let value = context.vm.pop(); diff --git a/boa_engine/src/vm/opcode/iteration/for_in.rs b/boa_engine/src/vm/opcode/iteration/for_in.rs index ea56e377201..0baa43e8dd6 100644 --- a/boa_engine/src/vm/opcode/iteration/for_in.rs +++ b/boa_engine/src/vm/opcode/iteration/for_in.rs @@ -17,7 +17,7 @@ impl Operation for CreateForInIterator { const INSTRUCTION: &'static str = "INST - CreateForInIterator"; const COST: u8 = 4; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let object = context.vm.pop(); let object = object.to_object(context)?; diff --git a/boa_engine/src/vm/opcode/iteration/get.rs b/boa_engine/src/vm/opcode/iteration/get.rs index 2df6ffe5dda..a2bf6104420 100644 --- a/boa_engine/src/vm/opcode/iteration/get.rs +++ b/boa_engine/src/vm/opcode/iteration/get.rs @@ -16,7 +16,7 @@ impl Operation for GetIterator { const INSTRUCTION: &'static str = "INST - GetIterator"; const COST: u8 = 6; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let object = context.vm.pop(); let iterator = object.get_iterator(context, None, None)?; context.vm.frame_mut().iterators.push(iterator); @@ -36,7 +36,7 @@ impl Operation for GetAsyncIterator { const INSTRUCTION: &'static str = "INST - GetAsyncIterator"; const COST: u8 = 6; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let object = context.vm.pop(); let iterator = object.get_iterator(context, Some(IteratorHint::Async), None)?; context.vm.frame_mut().iterators.push(iterator); diff --git a/boa_engine/src/vm/opcode/iteration/iterator.rs b/boa_engine/src/vm/opcode/iteration/iterator.rs index b670911bb00..c4dddb79d02 100644 --- a/boa_engine/src/vm/opcode/iteration/iterator.rs +++ b/boa_engine/src/vm/opcode/iteration/iterator.rs @@ -19,7 +19,7 @@ impl Operation for IteratorNext { const INSTRUCTION: &'static str = "INST - IteratorNext"; const COST: u8 = 6; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let mut iterator = context .vm .frame_mut() @@ -47,7 +47,7 @@ impl Operation for IteratorNextWithoutPop { const INSTRUCTION: &'static str = "INST - IteratorNextWithoutPop"; const COST: u8 = 6; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let mut iterator = context .vm .frame_mut() @@ -78,7 +78,7 @@ impl Operation for IteratorFinishAsyncNext { const INSTRUCTION: &'static str = "INST - IteratorFinishAsyncNext"; const COST: u8 = 5; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let mut iterator = context .vm .frame_mut() @@ -120,7 +120,7 @@ impl Operation for IteratorResult { const INSTRUCTION: &'static str = "INST - IteratorResult"; const COST: u8 = 3; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let last_result = context .vm .frame() @@ -149,7 +149,7 @@ impl Operation for IteratorValue { const INSTRUCTION: &'static str = "INST - IteratorValue"; const COST: u8 = 5; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let mut iterator = context .vm .frame_mut() @@ -178,7 +178,7 @@ impl Operation for IteratorValueWithoutPop { const INSTRUCTION: &'static str = "INST - IteratorValueWithoutPop"; const COST: u8 = 5; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let mut iterator = context .vm .frame_mut() @@ -207,7 +207,7 @@ impl Operation for IteratorDone { const INSTRUCTION: &'static str = "INST - IteratorDone"; const COST: u8 = 3; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let done = context .vm .frame() @@ -234,7 +234,7 @@ impl Operation for IteratorReturn { const INSTRUCTION: &'static str = "INST - IteratorReturn"; const COST: u8 = 8; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let record = context .vm .frame_mut() @@ -271,7 +271,7 @@ impl Operation for IteratorToArray { const INSTRUCTION: &'static str = "INST - IteratorToArray"; const COST: u8 = 8; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let mut iterator = context .vm .frame_mut() @@ -325,7 +325,7 @@ impl Operation for IteratorPop { const INSTRUCTION: &'static str = "INST - IteratorPop"; const COST: u8 = 1; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { context.vm.frame_mut().iterators.pop(); Ok(CompletionType::Normal) } @@ -343,7 +343,7 @@ impl Operation for IteratorStackEmpty { const INSTRUCTION: &'static str = "INST - IteratorStackEmpty"; const COST: u8 = 1; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let is_empty = context.vm.frame().iterators.is_empty(); context.vm.push(is_empty); Ok(CompletionType::Normal) @@ -362,7 +362,7 @@ impl Operation for CreateIteratorResult { const INSTRUCTION: &'static str = "INST - CreateIteratorResult"; const COST: u8 = 3; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let value = context.vm.pop(); let done = context.vm.read::() != 0; diff --git a/boa_engine/src/vm/opcode/iteration/loop_ops.rs b/boa_engine/src/vm/opcode/iteration/loop_ops.rs index df1488a4c3a..91d43c18e24 100644 --- a/boa_engine/src/vm/opcode/iteration/loop_ops.rs +++ b/boa_engine/src/vm/opcode/iteration/loop_ops.rs @@ -16,7 +16,7 @@ impl Operation for IncrementLoopIteration { const INSTRUCTION: &'static str = "INST - IncrementLoopIteration"; const COST: u8 = 3; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let previous_iteration_count = context.vm.frame_mut().loop_iteration_count; let max = context.vm.runtime_limits.loop_iteration_limit(); diff --git a/boa_engine/src/vm/opcode/meta/mod.rs b/boa_engine/src/vm/opcode/meta/mod.rs index 464c5645e1f..c93fd5be4d9 100644 --- a/boa_engine/src/vm/opcode/meta/mod.rs +++ b/boa_engine/src/vm/opcode/meta/mod.rs @@ -18,7 +18,7 @@ impl Operation for NewTarget { const INSTRUCTION: &'static str = "INST - NewTarget"; const COST: u8 = 2; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let new_target = if let Some(new_target) = context .vm .environments @@ -47,7 +47,7 @@ impl Operation for ImportMeta { const INSTRUCTION: &'static str = "INST - ImportMeta"; const COST: u8 = 6; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { // Meta Properties // // ImportMeta : import . meta diff --git a/boa_engine/src/vm/opcode/mod.rs b/boa_engine/src/vm/opcode/mod.rs index e134792252a..2d0bc52e797 100644 --- a/boa_engine/src/vm/opcode/mod.rs +++ b/boa_engine/src/vm/opcode/mod.rs @@ -429,14 +429,14 @@ macro_rules! generate_opcodes { Self::INSTRUCTIONS[self as usize] } - const SPEND_FNS: [fn(&mut Context<'_>, &mut u32) -> JsResult; Self::MAX] = [ + const SPEND_FNS: [fn(&mut Context, &mut u32) -> JsResult; Self::MAX] = [ $( $mapping)?)>::spend_budget_and_execute),*, ]; /// Spends the cost of this opcode into the provided budget and executes it. pub(super) fn spend_budget_and_execute( self, - context: &mut Context<'_>, + context: &mut Context, budget: &mut u32 ) -> JsResult { Self::SPEND_FNS[self as usize](context, budget) @@ -451,13 +451,13 @@ macro_rules! generate_opcodes { Self::COSTS[self as usize] } - const EXECUTE_FNS: [fn(&mut Context<'_>) -> JsResult; Self::MAX * 3] = [ + const EXECUTE_FNS: [fn(&mut Context) -> JsResult; Self::MAX * 3] = [ $( $mapping)?)>::execute),*, $( $mapping)?)>::execute_with_u16_operands),*, $( $mapping)?)>::execute_with_u32_operands),* ]; - pub(super) fn execute(self, context: &mut Context<'_>) -> JsResult { + pub(super) fn execute(self, context: &mut Context) -> JsResult { Self::EXECUTE_FNS[self as usize](context) } } @@ -558,25 +558,25 @@ pub(crate) trait Operation { const COST: u8; /// Execute opcode with [`VaryingOperandKind::U8`] sized [`VaryingOperand`]s. - fn execute(context: &mut Context<'_>) -> JsResult; + fn execute(context: &mut Context) -> JsResult; /// Execute opcode with [`VaryingOperandKind::U16`] sized [`VaryingOperand`]s. /// /// By default if not implemented will call [`Reserved::execute_with_u16_operands()`] which panics. - fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context) -> JsResult { Reserved::execute_with_u16_operands(context) } /// Execute opcode with [`VaryingOperandKind::U32`] sized [`VaryingOperand`]s. /// /// By default if not implemented will call [`Reserved::execute_with_u32_operands()`] which panics. - fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(context: &mut Context) -> JsResult { Reserved::execute_with_u32_operands(context) } /// Spends the cost of this operation into `budget` and runs `execute`. fn spend_budget_and_execute( - context: &mut Context<'_>, + context: &mut Context, budget: &mut u32, ) -> JsResult { *budget = budget.saturating_sub(u32::from(Self::COST)); diff --git a/boa_engine/src/vm/opcode/modifier.rs b/boa_engine/src/vm/opcode/modifier.rs index dbfa590f68a..deb33909310 100644 --- a/boa_engine/src/vm/opcode/modifier.rs +++ b/boa_engine/src/vm/opcode/modifier.rs @@ -14,14 +14,14 @@ impl Operation for U16Operands { const INSTRUCTION: &'static str = "INST - U16Operands"; const COST: u8 = 1; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let opcode = context.vm.read::() as usize; Opcode::EXECUTE_FNS[Opcode::MAX + opcode](context) } fn spend_budget_and_execute( - context: &mut Context<'_>, + context: &mut Context, budget: &mut u32, ) -> JsResult { let opcode: Opcode = context.vm.read::().into(); @@ -43,14 +43,14 @@ impl Operation for U32Operands { const INSTRUCTION: &'static str = "INST - U32Operands"; const COST: u8 = 1; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let opcode = context.vm.read::() as usize; Opcode::EXECUTE_FNS[Opcode::MAX * 2 + opcode](context) } fn spend_budget_and_execute( - context: &mut Context<'_>, + context: &mut Context, budget: &mut u32, ) -> JsResult { let opcode: Opcode = context.vm.read::().into(); diff --git a/boa_engine/src/vm/opcode/new/mod.rs b/boa_engine/src/vm/opcode/new/mod.rs index 9ca33ee2baf..8719d6ea590 100644 --- a/boa_engine/src/vm/opcode/new/mod.rs +++ b/boa_engine/src/vm/opcode/new/mod.rs @@ -12,7 +12,7 @@ use crate::{ pub(crate) struct New; impl New { - fn operation(context: &mut Context<'_>, argument_count: usize) -> JsResult { + fn operation(context: &mut Context, argument_count: usize) -> JsResult { let at = context.vm.stack.len() - argument_count; let func = &context.vm.stack[at - 1]; @@ -33,17 +33,17 @@ impl Operation for New { const INSTRUCTION: &'static str = "INST - New"; const COST: u8 = 3; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let argument_count = context.vm.read::() as usize; Self::operation(context, argument_count) } - fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context) -> JsResult { let argument_count = context.vm.read::() as usize; Self::operation(context, argument_count) } - fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(context: &mut Context) -> JsResult { let argument_count = context.vm.read::() as usize; Self::operation(context, argument_count) } @@ -61,7 +61,7 @@ impl Operation for NewSpread { const INSTRUCTION: &'static str = "INST - NewSpread"; const COST: u8 = 3; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { // Get the arguments that are stored as an array object on the stack. let arguments_array = context.vm.pop(); let arguments_array_object = arguments_array diff --git a/boa_engine/src/vm/opcode/nop/mod.rs b/boa_engine/src/vm/opcode/nop/mod.rs index 290173c66ab..d5571a9b7f7 100644 --- a/boa_engine/src/vm/opcode/nop/mod.rs +++ b/boa_engine/src/vm/opcode/nop/mod.rs @@ -15,7 +15,7 @@ impl Operation for Nop { const INSTRUCTION: &'static str = "INST - Nop"; const COST: u8 = 1; - fn execute(_: &mut Context<'_>) -> JsResult { + fn execute(_: &mut Context) -> JsResult { Ok(CompletionType::Normal) } } @@ -32,15 +32,15 @@ impl Operation for Reserved { const INSTRUCTION: &'static str = "INST - Reserved"; const COST: u8 = 0; - fn execute(_: &mut Context<'_>) -> JsResult { + fn execute(_: &mut Context) -> JsResult { unreachable!("Reserved opcodes are unreachable!") } - fn execute_with_u16_operands(_: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(_: &mut Context) -> JsResult { unreachable!("Reserved.U16 opcodes are unreachable!") } - fn execute_with_u32_operands(_: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(_: &mut Context) -> JsResult { unreachable!("Reserved.U32 opcodes are unreachable!") } } diff --git a/boa_engine/src/vm/opcode/pop/mod.rs b/boa_engine/src/vm/opcode/pop/mod.rs index 84c21b9b7bf..35cc64ae66d 100644 --- a/boa_engine/src/vm/opcode/pop/mod.rs +++ b/boa_engine/src/vm/opcode/pop/mod.rs @@ -15,7 +15,7 @@ impl Operation for Pop { const INSTRUCTION: &'static str = "INST - Pop"; const COST: u8 = 1; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let _val = context.vm.pop(); Ok(CompletionType::Normal) } @@ -33,7 +33,7 @@ impl Operation for PopEnvironment { const INSTRUCTION: &'static str = "INST - PopEnvironment"; const COST: u8 = 1; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { context.vm.environments.pop(); Ok(CompletionType::Normal) } diff --git a/boa_engine/src/vm/opcode/push/array.rs b/boa_engine/src/vm/opcode/push/array.rs index 748adba8ff8..8afbe2603a2 100644 --- a/boa_engine/src/vm/opcode/push/array.rs +++ b/boa_engine/src/vm/opcode/push/array.rs @@ -18,7 +18,7 @@ impl Operation for PushNewArray { const INSTRUCTION: &'static str = "INST - PushNewArray"; const COST: u8 = 3; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let array = context .intrinsics() .templates() @@ -41,7 +41,7 @@ impl Operation for PushValueToArray { const INSTRUCTION: &'static str = "INST - PushValueToArray"; const COST: u8 = 3; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let value = context.vm.pop(); let array = context.vm.pop(); let o = array.as_object().expect("should be an object"); @@ -67,7 +67,7 @@ impl Operation for PushElisionToArray { const INSTRUCTION: &'static str = "INST - PushElisionToArray"; const COST: u8 = 3; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let array = context.vm.pop(); let o = array.as_object().expect("should always be an object"); @@ -93,7 +93,7 @@ impl Operation for PushIteratorToArray { const INSTRUCTION: &'static str = "INST - PushIteratorToArray"; const COST: u8 = 8; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let mut iterator = context .vm .frame_mut() diff --git a/boa_engine/src/vm/opcode/push/class/field.rs b/boa_engine/src/vm/opcode/push/class/field.rs index 3e6ce9f8295..5868b761c1a 100644 --- a/boa_engine/src/vm/opcode/push/class/field.rs +++ b/boa_engine/src/vm/opcode/push/class/field.rs @@ -16,7 +16,7 @@ impl Operation for PushClassField { const INSTRUCTION: &'static str = "INST - PushClassField"; const COST: u8 = 6; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let field_function_value = context.vm.pop(); let field_name_value = context.vm.pop(); let class_value = context.vm.pop(); @@ -54,7 +54,7 @@ pub(crate) struct PushClassFieldPrivate; impl PushClassFieldPrivate { #[allow(clippy::unnecessary_wraps)] - fn operation(context: &mut Context<'_>, index: usize) -> JsResult { + fn operation(context: &mut Context, index: usize) -> JsResult { let name = context.vm.frame().code_block().constant_string(index); let field_function_value = context.vm.pop(); let class_value = context.vm.pop(); @@ -88,17 +88,17 @@ impl Operation for PushClassFieldPrivate { const INSTRUCTION: &'static str = "INST - PushClassFieldPrivate"; const COST: u8 = 3; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } diff --git a/boa_engine/src/vm/opcode/push/class/mod.rs b/boa_engine/src/vm/opcode/push/class/mod.rs index 4a6d1d77a42..60f8c8f8852 100644 --- a/boa_engine/src/vm/opcode/push/class/mod.rs +++ b/boa_engine/src/vm/opcode/push/class/mod.rs @@ -23,7 +23,7 @@ impl Operation for PushClassPrototype { const INSTRUCTION: &'static str = "INST - PushClassPrototype"; const COST: u8 = 6; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let superclass = context.vm.pop(); let class = context.vm.pop(); diff --git a/boa_engine/src/vm/opcode/push/class/private.rs b/boa_engine/src/vm/opcode/push/class/private.rs index 727e8118886..cce5288a6a7 100644 --- a/boa_engine/src/vm/opcode/push/class/private.rs +++ b/boa_engine/src/vm/opcode/push/class/private.rs @@ -16,7 +16,7 @@ pub(crate) struct PushClassPrivateMethod; impl PushClassPrivateMethod { #[allow(clippy::unnecessary_wraps)] - fn operation(context: &mut Context<'_>, index: usize) -> JsResult { + fn operation(context: &mut Context, index: usize) -> JsResult { let name = context.vm.frame().code_block().constant_string(index); let method = context.vm.pop(); let method_object = method.as_callable().expect("method must be callable"); @@ -53,17 +53,17 @@ impl Operation for PushClassPrivateMethod { const INSTRUCTION: &'static str = "INST - PushClassPrivateMethod"; const COST: u8 = 6; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } @@ -78,7 +78,7 @@ pub(crate) struct PushClassPrivateGetter; impl PushClassPrivateGetter { #[allow(clippy::unnecessary_wraps)] - fn operation(context: &mut Context<'_>, index: usize) -> JsResult { + fn operation(context: &mut Context, index: usize) -> JsResult { let name = context.vm.frame().code_block().constant_string(index); let getter = context.vm.pop(); let getter_object = getter.as_callable().expect("getter must be callable"); @@ -106,17 +106,17 @@ impl Operation for PushClassPrivateGetter { const INSTRUCTION: &'static str = "INST - PushClassPrivateGetter"; const COST: u8 = 6; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } @@ -131,7 +131,7 @@ pub(crate) struct PushClassPrivateSetter; impl PushClassPrivateSetter { #[allow(clippy::unnecessary_wraps)] - fn operation(context: &mut Context<'_>, index: usize) -> JsResult { + fn operation(context: &mut Context, index: usize) -> JsResult { let name = context.vm.frame().code_block().constant_string(index); let setter = context.vm.pop(); let setter_object = setter.as_callable().expect("getter must be callable"); @@ -159,17 +159,17 @@ impl Operation for PushClassPrivateSetter { const INSTRUCTION: &'static str = "INST - PushClassPrivateSetter"; const COST: u8 = 6; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } diff --git a/boa_engine/src/vm/opcode/push/environment.rs b/boa_engine/src/vm/opcode/push/environment.rs index 6ddef4dc56e..13eddef9661 100644 --- a/boa_engine/src/vm/opcode/push/environment.rs +++ b/boa_engine/src/vm/opcode/push/environment.rs @@ -15,7 +15,7 @@ pub(crate) struct PushDeclarativeEnvironment; impl PushDeclarativeEnvironment { #[allow(clippy::unnecessary_wraps)] fn operation( - context: &mut Context<'_>, + context: &mut Context, compile_environments_index: usize, ) -> JsResult { let compile_environment = context @@ -33,17 +33,17 @@ impl Operation for PushDeclarativeEnvironment { const INSTRUCTION: &'static str = "INST - PushDeclarativeEnvironment"; const COST: u8 = 3; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let compile_environments_index = context.vm.read::() as usize; Self::operation(context, compile_environments_index) } - fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context) -> JsResult { let compile_environments_index = context.vm.read::() as usize; Self::operation(context, compile_environments_index) } - fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(context: &mut Context) -> JsResult { let compile_environments_index = context.vm.read::() as usize; Self::operation(context, compile_environments_index) } @@ -61,7 +61,7 @@ impl Operation for PushObjectEnvironment { const INSTRUCTION: &'static str = "INST - PushObjectEnvironment"; const COST: u8 = 3; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let object = context.vm.pop(); let object = object.to_object(context)?; @@ -82,7 +82,7 @@ impl Operation for PushPrivateEnvironment { const INSTRUCTION: &'static str = "INST - PushPrivateEnvironment"; const COST: u8 = 5; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let class_value = context.vm.pop(); let class = class_value.to_object(context)?; @@ -126,7 +126,7 @@ impl Operation for PopPrivateEnvironment { const INSTRUCTION: &'static str = "INST - PopPrivateEnvironment"; const COST: u8 = 1; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { context.vm.environments.pop_private(); Ok(CompletionType::Normal) } diff --git a/boa_engine/src/vm/opcode/push/literal.rs b/boa_engine/src/vm/opcode/push/literal.rs index db192274247..697e626c297 100644 --- a/boa_engine/src/vm/opcode/push/literal.rs +++ b/boa_engine/src/vm/opcode/push/literal.rs @@ -13,7 +13,7 @@ pub(crate) struct PushLiteral; impl PushLiteral { #[allow(clippy::unnecessary_wraps)] - fn operation(context: &mut Context<'_>, index: usize) -> JsResult { + fn operation(context: &mut Context, index: usize) -> JsResult { let constant = &context.vm.frame().code_block().constants[index]; let value: JsValue = match constant { Constant::BigInt(v) => v.clone().into(), @@ -30,17 +30,17 @@ impl Operation for PushLiteral { const INSTRUCTION: &'static str = "INST - PushLiteral"; const COST: u8 = 1; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } @@ -55,7 +55,7 @@ pub(crate) struct PushRegExp; impl PushRegExp { fn operation( - context: &mut Context<'_>, + context: &mut Context, pattern_index: usize, flags_index: usize, ) -> JsResult { @@ -77,19 +77,19 @@ impl Operation for PushRegExp { const INSTRUCTION: &'static str = "INST - PushRegExp"; const COST: u8 = 5; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let pattern_index = context.vm.read::() as usize; let flags_index = context.vm.read::() as usize; Self::operation(context, pattern_index, flags_index) } - fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context) -> JsResult { let pattern_index = context.vm.read::() as usize; let flags_index = context.vm.read::() as usize; Self::operation(context, pattern_index, flags_index) } - fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(context: &mut Context) -> JsResult { let pattern_index = context.vm.read::() as usize; let flags_index = context.vm.read::() as usize; Self::operation(context, pattern_index, flags_index) diff --git a/boa_engine/src/vm/opcode/push/mod.rs b/boa_engine/src/vm/opcode/push/mod.rs index bf521839956..5a351dbf931 100644 --- a/boa_engine/src/vm/opcode/push/mod.rs +++ b/boa_engine/src/vm/opcode/push/mod.rs @@ -31,7 +31,7 @@ macro_rules! implement_push_generics { const INSTRUCTION: &'static str = stringify!("INST - " + $name); const COST: u8 = 1; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { context.vm.push($push_value); Ok(CompletionType::Normal) } diff --git a/boa_engine/src/vm/opcode/push/numbers.rs b/boa_engine/src/vm/opcode/push/numbers.rs index 3e42ffe3c2a..59c2af00333 100644 --- a/boa_engine/src/vm/opcode/push/numbers.rs +++ b/boa_engine/src/vm/opcode/push/numbers.rs @@ -17,7 +17,7 @@ macro_rules! implement_push_numbers_with_conversion { const INSTRUCTION: &'static str = stringify!("INST - " + $name); const COST: u8 = 1; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let value = context.vm.read::<$num_type>(); context.vm.push(i32::from(value)); Ok(CompletionType::Normal) @@ -40,7 +40,7 @@ macro_rules! implement_push_numbers_no_conversion { const INSTRUCTION: &'static str = stringify!("INST - " + $name); const COST: u8 = 1; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let value = context.vm.read::<$num_type>(); context.vm.push(value); Ok(CompletionType::Normal) diff --git a/boa_engine/src/vm/opcode/push/object.rs b/boa_engine/src/vm/opcode/push/object.rs index 2e6f97f15d8..c04eecd7fca 100644 --- a/boa_engine/src/vm/opcode/push/object.rs +++ b/boa_engine/src/vm/opcode/push/object.rs @@ -16,7 +16,7 @@ impl Operation for PushEmptyObject { const INSTRUCTION: &'static str = "INST - PushEmptyObject"; const COST: u8 = 1; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let o = context .intrinsics() .templates() diff --git a/boa_engine/src/vm/opcode/require/mod.rs b/boa_engine/src/vm/opcode/require/mod.rs index 7fa2f5e497f..f0453f2ba29 100644 --- a/boa_engine/src/vm/opcode/require/mod.rs +++ b/boa_engine/src/vm/opcode/require/mod.rs @@ -15,7 +15,7 @@ impl Operation for RequireObjectCoercible { const INSTRUCTION: &'static str = "INST - RequireObjectCoercible"; const COST: u8 = 1; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let value = context.vm.pop(); let value = value.require_object_coercible()?; context.vm.push(value.clone()); diff --git a/boa_engine/src/vm/opcode/rest_parameter/mod.rs b/boa_engine/src/vm/opcode/rest_parameter/mod.rs index 052e336d30a..280c2951df9 100644 --- a/boa_engine/src/vm/opcode/rest_parameter/mod.rs +++ b/boa_engine/src/vm/opcode/rest_parameter/mod.rs @@ -16,7 +16,7 @@ impl Operation for RestParameterInit { const INSTRUCTION: &'static str = "INST - RestParameterInit"; const COST: u8 = 6; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let arg_count = context.vm.frame().argument_count as usize; let param_count = context.vm.frame().code_block().params.as_ref().len(); diff --git a/boa_engine/src/vm/opcode/set/class_prototype.rs b/boa_engine/src/vm/opcode/set/class_prototype.rs index 32f24920eca..8f917a5a7d1 100644 --- a/boa_engine/src/vm/opcode/set/class_prototype.rs +++ b/boa_engine/src/vm/opcode/set/class_prototype.rs @@ -17,7 +17,7 @@ impl Operation for SetClassPrototype { const INSTRUCTION: &'static str = "INST - SetClassPrototype"; const COST: u8 = 6; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let prototype_value = context.vm.pop(); let prototype = match &prototype_value { JsValue::Object(proto) => Some(proto.clone()), diff --git a/boa_engine/src/vm/opcode/set/home_object.rs b/boa_engine/src/vm/opcode/set/home_object.rs index cde9c65fbb0..b280c4ad4b1 100644 --- a/boa_engine/src/vm/opcode/set/home_object.rs +++ b/boa_engine/src/vm/opcode/set/home_object.rs @@ -15,7 +15,7 @@ impl Operation for SetHomeObject { const INSTRUCTION: &'static str = "INST - SetHomeObject"; const COST: u8 = 4; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let function = context.vm.pop(); let home = context.vm.pop(); diff --git a/boa_engine/src/vm/opcode/set/name.rs b/boa_engine/src/vm/opcode/set/name.rs index dd26674e59c..79e111f696d 100644 --- a/boa_engine/src/vm/opcode/set/name.rs +++ b/boa_engine/src/vm/opcode/set/name.rs @@ -12,7 +12,7 @@ use crate::{ pub(crate) struct ThrowMutateImmutable; impl ThrowMutateImmutable { - fn operation(context: &mut Context<'_>, index: usize) -> JsResult { + fn operation(context: &mut Context, index: usize) -> JsResult { let name = context.vm.frame().code_block().constant_string(index); Err(JsNativeError::typ() @@ -29,17 +29,17 @@ impl Operation for ThrowMutateImmutable { const INSTRUCTION: &'static str = "INST - ThrowMutateImmutable"; const COST: u8 = 2; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let index = context.vm.read::(); Self::operation(context, index as usize) } - fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(context: &mut Context) -> JsResult { let index = context.vm.read::(); Self::operation(context, index as usize) } @@ -53,7 +53,7 @@ impl Operation for ThrowMutateImmutable { pub(crate) struct SetName; impl SetName { - fn operation(context: &mut Context<'_>, index: usize) -> JsResult { + fn operation(context: &mut Context, index: usize) -> JsResult { let mut binding_locator = context.vm.frame().code_block.bindings[index]; let value = context.vm.pop(); @@ -76,17 +76,17 @@ impl Operation for SetName { const INSTRUCTION: &'static str = "INST - SetName"; const COST: u8 = 4; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let index = context.vm.read::(); Self::operation(context, index as usize) } - fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(context: &mut Context) -> JsResult { let index = context.vm.read::(); Self::operation(context, index as usize) } @@ -104,7 +104,7 @@ impl Operation for SetNameByLocator { const INSTRUCTION: &'static str = "INST - SetNameByLocator"; const COST: u8 = 4; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let binding_locator = context .vm .frame_mut() @@ -126,7 +126,7 @@ impl Operation for SetNameByLocator { } /// Checks that the binding pointed by `locator` exists and is initialized. -fn verify_initialized(locator: BindingLocator, context: &mut Context<'_>) -> JsResult<()> { +fn verify_initialized(locator: BindingLocator, context: &mut Context) -> JsResult<()> { if !context.is_initialized_binding(&locator)? { let key = context.interner().resolve_expect(locator.name().sym()); let strict = context.vm.frame().code_block.strict(); diff --git a/boa_engine/src/vm/opcode/set/private.rs b/boa_engine/src/vm/opcode/set/private.rs index 287ad0d2750..d12574e7a81 100644 --- a/boa_engine/src/vm/opcode/set/private.rs +++ b/boa_engine/src/vm/opcode/set/private.rs @@ -15,7 +15,7 @@ use crate::{ pub(crate) struct SetPrivateField; impl SetPrivateField { - fn operation(context: &mut Context<'_>, index: usize) -> JsResult { + fn operation(context: &mut Context, index: usize) -> JsResult { let name = context.vm.frame().code_block().constant_string(index); let value = context.vm.pop(); let object = context.vm.pop(); @@ -38,17 +38,17 @@ impl Operation for SetPrivateField { const INSTRUCTION: &'static str = "INST - SetPrivateField"; const COST: u8 = 4; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } @@ -63,7 +63,7 @@ pub(crate) struct DefinePrivateField; impl DefinePrivateField { #[allow(clippy::unnecessary_wraps)] - fn operation(context: &mut Context<'_>, index: usize) -> JsResult { + fn operation(context: &mut Context, index: usize) -> JsResult { let name = context.vm.frame().code_block().constant_string(index); let value = context.vm.pop(); let object = context.vm.pop(); @@ -84,17 +84,17 @@ impl Operation for DefinePrivateField { const INSTRUCTION: &'static str = "INST - DefinePrivateField"; const COST: u8 = 4; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } @@ -109,7 +109,7 @@ pub(crate) struct SetPrivateMethod; impl SetPrivateMethod { #[allow(clippy::unnecessary_wraps)] - fn operation(context: &mut Context<'_>, index: usize) -> JsResult { + fn operation(context: &mut Context, index: usize) -> JsResult { let name = context.vm.frame().code_block().constant_string(index); let value = context.vm.pop(); let value = value.as_callable().expect("method must be callable"); @@ -144,17 +144,17 @@ impl Operation for SetPrivateMethod { const INSTRUCTION: &'static str = "INST - SetPrivateMethod"; const COST: u8 = 4; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } @@ -169,7 +169,7 @@ pub(crate) struct SetPrivateSetter; impl SetPrivateSetter { #[allow(clippy::unnecessary_wraps)] - fn operation(context: &mut Context<'_>, index: usize) -> JsResult { + fn operation(context: &mut Context, index: usize) -> JsResult { let name = context.vm.frame().code_block().constant_string(index); let value = context.vm.pop(); let value = value.as_callable().expect("setter must be callable"); @@ -195,17 +195,17 @@ impl Operation for SetPrivateSetter { const INSTRUCTION: &'static str = "INST - SetPrivateSetter"; const COST: u8 = 4; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } @@ -220,7 +220,7 @@ pub(crate) struct SetPrivateGetter; impl SetPrivateGetter { #[allow(clippy::unnecessary_wraps)] - fn operation(context: &mut Context<'_>, index: usize) -> JsResult { + fn operation(context: &mut Context, index: usize) -> JsResult { let name = context.vm.frame().code_block().constant_string(index); let value = context.vm.pop(); let value = value.as_callable().expect("getter must be callable"); @@ -246,17 +246,17 @@ impl Operation for SetPrivateGetter { const INSTRUCTION: &'static str = "INST - SetPrivateGetter"; const COST: u8 = 4; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } diff --git a/boa_engine/src/vm/opcode/set/property.rs b/boa_engine/src/vm/opcode/set/property.rs index a07fb841da3..9f609733c73 100644 --- a/boa_engine/src/vm/opcode/set/property.rs +++ b/boa_engine/src/vm/opcode/set/property.rs @@ -15,7 +15,7 @@ use crate::{ pub(crate) struct SetPropertyByName; impl SetPropertyByName { - fn operation(context: &mut Context<'_>, index: usize) -> JsResult { + fn operation(context: &mut Context, index: usize) -> JsResult { let value = context.vm.pop(); let receiver = context.vm.pop(); let object = context.vm.pop(); @@ -48,17 +48,17 @@ impl Operation for SetPropertyByName { const INSTRUCTION: &'static str = "INST - SetPropertyByName"; const COST: u8 = 4; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let index = context.vm.read::(); Self::operation(context, index as usize) } - fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(context: &mut Context) -> JsResult { let index = context.vm.read::(); Self::operation(context, index as usize) } @@ -76,7 +76,7 @@ impl Operation for SetPropertyByValue { const INSTRUCTION: &'static str = "INST - SetPropertyByValue"; const COST: u8 = 4; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let value = context.vm.pop(); let key = context.vm.pop(); let receiver = context.vm.pop(); @@ -177,7 +177,7 @@ impl Operation for SetPropertyByValue { pub(crate) struct SetPropertyGetterByName; impl SetPropertyGetterByName { - fn operation(context: &mut Context<'_>, index: usize) -> JsResult { + fn operation(context: &mut Context, index: usize) -> JsResult { let value = context.vm.pop(); let object = context.vm.pop(); let object = object.to_object(context)?; @@ -211,17 +211,17 @@ impl Operation for SetPropertyGetterByName { const INSTRUCTION: &'static str = "INST - SetPropertyGetterByName"; const COST: u8 = 4; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } @@ -239,7 +239,7 @@ impl Operation for SetPropertyGetterByValue { const INSTRUCTION: &'static str = "INST - SetPropertyGetterByValue"; const COST: u8 = 4; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let value = context.vm.pop(); let key = context.vm.pop(); let object = context.vm.pop(); @@ -272,7 +272,7 @@ impl Operation for SetPropertyGetterByValue { pub(crate) struct SetPropertySetterByName; impl SetPropertySetterByName { - fn operation(context: &mut Context<'_>, index: usize) -> JsResult { + fn operation(context: &mut Context, index: usize) -> JsResult { let value = context.vm.pop(); let object = context.vm.pop(); let object = object.to_object(context)?; @@ -306,17 +306,17 @@ impl Operation for SetPropertySetterByName { const INSTRUCTION: &'static str = "INST - SetPropertySetterByName"; const COST: u8 = 4; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(context: &mut Context) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } @@ -334,7 +334,7 @@ impl Operation for SetPropertySetterByValue { const INSTRUCTION: &'static str = "INST - SetPropertySetterByValue"; const COST: u8 = 4; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let value = context.vm.pop(); let key = context.vm.pop(); let object = context.vm.pop(); @@ -371,7 +371,7 @@ impl Operation for SetFunctionName { const INSTRUCTION: &'static str = "INST - SetFunctionName"; const COST: u8 = 4; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let prefix = context.vm.read::(); let function = context.vm.pop(); let name = context.vm.pop(); diff --git a/boa_engine/src/vm/opcode/set/prototype.rs b/boa_engine/src/vm/opcode/set/prototype.rs index 77ef64eefc7..e22a4530f96 100644 --- a/boa_engine/src/vm/opcode/set/prototype.rs +++ b/boa_engine/src/vm/opcode/set/prototype.rs @@ -15,7 +15,7 @@ impl Operation for SetPrototype { const INSTRUCTION: &'static str = "INST - SetPrototype"; const COST: u8 = 4; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let value = context.vm.pop(); let object = context.vm.pop(); diff --git a/boa_engine/src/vm/opcode/swap/mod.rs b/boa_engine/src/vm/opcode/swap/mod.rs index c3e01189593..27336bd8387 100644 --- a/boa_engine/src/vm/opcode/swap/mod.rs +++ b/boa_engine/src/vm/opcode/swap/mod.rs @@ -15,7 +15,7 @@ impl Operation for Swap { const INSTRUCTION: &'static str = "INST - Swap"; const COST: u8 = 1; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let len = context.vm.stack.len(); assert!(len > 1); context.vm.stack.swap(len - 1, len - 2); @@ -35,7 +35,7 @@ impl Operation for RotateLeft { const INSTRUCTION: &'static str = "INST - RotateLeft"; const COST: u8 = 2; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let n = context.vm.read::() as usize; let len = context.vm.stack.len(); context.vm.stack[(len - n)..].rotate_left(1); @@ -55,7 +55,7 @@ impl Operation for RotateRight { const INSTRUCTION: &'static str = "INST - RotateRight"; const COST: u8 = 2; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let n = context.vm.read::() as usize; let len = context.vm.stack.len(); context.vm.stack[(len - n)..].rotate_right(1); diff --git a/boa_engine/src/vm/opcode/switch/mod.rs b/boa_engine/src/vm/opcode/switch/mod.rs index d65124794f9..31e185825d6 100644 --- a/boa_engine/src/vm/opcode/switch/mod.rs +++ b/boa_engine/src/vm/opcode/switch/mod.rs @@ -16,7 +16,7 @@ impl Operation for Case { const INSTRUCTION: &'static str = "INST - Case"; const COST: u8 = 2; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let address = context.vm.read::(); let cond = context.vm.pop(); let value = context.vm.pop(); @@ -42,7 +42,7 @@ impl Operation for Default { const INSTRUCTION: &'static str = "INST - Default"; const COST: u8 = 2; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let exit = context.vm.read::(); let _val = context.vm.pop(); context.vm.frame_mut().pc = exit; diff --git a/boa_engine/src/vm/opcode/templates/mod.rs b/boa_engine/src/vm/opcode/templates/mod.rs index 397563d3860..c33e831d194 100644 --- a/boa_engine/src/vm/opcode/templates/mod.rs +++ b/boa_engine/src/vm/opcode/templates/mod.rs @@ -19,7 +19,7 @@ impl Operation for TemplateLookup { const INSTRUCTION: &'static str = "INST - TemplateLookup"; const COST: u8 = 3; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let jump = context.vm.read::(); let site = context.vm.read::(); @@ -41,7 +41,7 @@ pub(crate) struct TemplateCreate; impl TemplateCreate { #[allow(clippy::unnecessary_wraps)] - fn operation(context: &mut Context<'_>, count: u32, site: u64) -> JsResult { + fn operation(context: &mut Context, count: u32, site: u64) -> JsResult { let template = Array::array_create(count.into(), None, context).expect("cannot fail per spec"); let raw_obj = @@ -104,19 +104,19 @@ impl Operation for TemplateCreate { const INSTRUCTION: &'static str = "INST - TemplateCreate"; const COST: u8 = 6; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let count = u32::from(context.vm.read::()); let site = context.vm.read::(); Self::operation(context, count, site) } - fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context) -> JsResult { let count = u32::from(context.vm.read::()); let site = context.vm.read::(); Self::operation(context, count, site) } - fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(context: &mut Context) -> JsResult { let count = context.vm.read::(); let site = context.vm.read::(); Self::operation(context, count, site) diff --git a/boa_engine/src/vm/opcode/to/mod.rs b/boa_engine/src/vm/opcode/to/mod.rs index 38c8ffe5643..99a56f46a26 100644 --- a/boa_engine/src/vm/opcode/to/mod.rs +++ b/boa_engine/src/vm/opcode/to/mod.rs @@ -15,7 +15,7 @@ impl Operation for ToBoolean { const INSTRUCTION: &'static str = "INST - ToBoolean"; const COST: u8 = 1; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let value = context.vm.pop(); context.vm.push(value.to_boolean()); Ok(CompletionType::Normal) @@ -34,7 +34,7 @@ impl Operation for ToPropertyKey { const INSTRUCTION: &'static str = "INST - ToPropertyKey"; const COST: u8 = 2; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let value = context.vm.pop(); let key = value.to_property_key(context)?; context.vm.push(key); diff --git a/boa_engine/src/vm/opcode/unary_ops/decrement.rs b/boa_engine/src/vm/opcode/unary_ops/decrement.rs index 41ef62e3f2b..978b10607fc 100644 --- a/boa_engine/src/vm/opcode/unary_ops/decrement.rs +++ b/boa_engine/src/vm/opcode/unary_ops/decrement.rs @@ -16,7 +16,7 @@ impl Operation for Dec { const INSTRUCTION: &'static str = "INST - Dec"; const COST: u8 = 3; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let value = context.vm.pop(); match value { JsValue::Integer(number) if number > i32::MIN => { @@ -45,7 +45,7 @@ impl Operation for DecPost { const INSTRUCTION: &'static str = "INST - DecPost"; const COST: u8 = 3; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let value = context.vm.pop(); match value { JsValue::Integer(number) if number > i32::MIN => { diff --git a/boa_engine/src/vm/opcode/unary_ops/increment.rs b/boa_engine/src/vm/opcode/unary_ops/increment.rs index c18d0e5e157..87fefb21934 100644 --- a/boa_engine/src/vm/opcode/unary_ops/increment.rs +++ b/boa_engine/src/vm/opcode/unary_ops/increment.rs @@ -16,7 +16,7 @@ impl Operation for Inc { const INSTRUCTION: &'static str = "INST - Inc"; const COST: u8 = 3; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let value = context.vm.pop(); match value { JsValue::Integer(number) if number < i32::MAX => { @@ -45,7 +45,7 @@ impl Operation for IncPost { const INSTRUCTION: &'static str = "INST - IncPost"; const COST: u8 = 3; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let value = context.vm.pop(); match value { JsValue::Integer(number) if number < i32::MAX => { diff --git a/boa_engine/src/vm/opcode/unary_ops/logical.rs b/boa_engine/src/vm/opcode/unary_ops/logical.rs index 0c7fef54657..e2b7d44491d 100644 --- a/boa_engine/src/vm/opcode/unary_ops/logical.rs +++ b/boa_engine/src/vm/opcode/unary_ops/logical.rs @@ -15,7 +15,7 @@ impl Operation for LogicalNot { const INSTRUCTION: &'static str = "INST - LogicalNot"; const COST: u8 = 1; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let value = context.vm.pop(); context.vm.push(!value.to_boolean()); Ok(CompletionType::Normal) diff --git a/boa_engine/src/vm/opcode/unary_ops/mod.rs b/boa_engine/src/vm/opcode/unary_ops/mod.rs index 95680981b31..d9dc848b5a0 100644 --- a/boa_engine/src/vm/opcode/unary_ops/mod.rs +++ b/boa_engine/src/vm/opcode/unary_ops/mod.rs @@ -28,7 +28,7 @@ impl Operation for TypeOf { const INSTRUCTION: &'static str = "INST - TypeOf"; const COST: u8 = 1; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let value = context.vm.pop(); context.vm.push(value.js_type_of()); Ok(CompletionType::Normal) @@ -47,7 +47,7 @@ impl Operation for Pos { const INSTRUCTION: &'static str = "INST - Pos"; const COST: u8 = 3; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let value = context.vm.pop(); let value = value.to_number(context)?; context.vm.push(value); @@ -67,7 +67,7 @@ impl Operation for Neg { const INSTRUCTION: &'static str = "INST - Neg"; const COST: u8 = 3; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let value = context.vm.pop(); match value.to_numeric(context)? { Numeric::Number(number) => context.vm.push(number.neg()), @@ -89,7 +89,7 @@ impl Operation for BitNot { const INSTRUCTION: &'static str = "INST - BitNot"; const COST: u8 = 3; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let value = context.vm.pop(); match value.to_numeric(context)? { Numeric::Number(number) => context.vm.push(Number::not(number)), diff --git a/boa_engine/src/vm/opcode/unary_ops/void.rs b/boa_engine/src/vm/opcode/unary_ops/void.rs index 6cde2ed1953..8d33d9e6886 100644 --- a/boa_engine/src/vm/opcode/unary_ops/void.rs +++ b/boa_engine/src/vm/opcode/unary_ops/void.rs @@ -15,7 +15,7 @@ impl Operation for Void { const INSTRUCTION: &'static str = "INST - Void"; const COST: u8 = 1; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let _old = context.vm.pop(); context.vm.push(JsValue::undefined()); Ok(CompletionType::Normal) diff --git a/boa_engine/src/vm/opcode/value/mod.rs b/boa_engine/src/vm/opcode/value/mod.rs index 70890007f25..2fe6969ae89 100644 --- a/boa_engine/src/vm/opcode/value/mod.rs +++ b/boa_engine/src/vm/opcode/value/mod.rs @@ -16,7 +16,7 @@ impl Operation for ValueNotNullOrUndefined { const INSTRUCTION: &'static str = "INST - ValueNotNullOrUndefined"; const COST: u8 = 2; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let value = context.vm.pop(); if value.is_null() { return Err(JsNativeError::typ() @@ -45,7 +45,7 @@ impl Operation for IsObject { const INSTRUCTION: &'static str = "INST - IsObject"; const COST: u8 = 1; - fn execute(context: &mut Context<'_>) -> JsResult { + fn execute(context: &mut Context) -> JsResult { let value = context.vm.pop(); context.vm.push(value.is_object()); Ok(CompletionType::Normal) diff --git a/boa_examples/src/bin/classes.rs b/boa_examples/src/bin/classes.rs index 48144250daa..2c62e2521c6 100644 --- a/boa_examples/src/bin/classes.rs +++ b/boa_examples/src/bin/classes.rs @@ -32,7 +32,7 @@ struct Person { // or any function that matches the required signature. impl Person { /// Says hello if `this` is a `Person` - fn say_hello(this: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { + fn say_hello(this: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { // We check if this is an object. if let Some(object) = this.as_object() { // If it is we downcast the type to type `Person`. @@ -65,7 +65,7 @@ impl Class for Person { const LENGTH: usize = 2; // This is what is internally called when we construct a `Person` with the expression `new Person()`. - fn make_data(_this: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult { + fn make_data(_this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { // We get the first argument. If it is unavailable we default to `undefined`, // and then we call `to_string()`. // @@ -132,7 +132,7 @@ impl Class for Person { } /// Adds the custom runtime to the context. -fn add_runtime(context: &mut Context<'_>) { +fn add_runtime(context: &mut Context) { // We first add the `console` object, to be able to call `console.log()`. let console = Console::init(context); context diff --git a/boa_examples/src/bin/futures.rs b/boa_examples/src/bin/futures.rs index 6a688c717d1..060d410abcf 100644 --- a/boa_examples/src/bin/futures.rs +++ b/boa_examples/src/bin/futures.rs @@ -1,6 +1,7 @@ use std::{ cell::{Cell, RefCell}, collections::VecDeque, + rc::Rc, time::{Duration, Instant}, }; @@ -34,15 +35,15 @@ impl<'a> Queue<'a> { } impl<'a> JobQueue for Queue<'a> { - fn enqueue_promise_job(&self, job: NativeJob, _context: &mut boa_engine::Context<'_>) { + fn enqueue_promise_job(&self, job: NativeJob, _context: &mut boa_engine::Context) { self.jobs.borrow_mut().push_back(job); } - fn enqueue_future_job(&self, future: FutureJob, _context: &mut boa_engine::Context<'_>) { + fn enqueue_future_job(&self, future: FutureJob, _context: &mut boa_engine::Context) { self.futures.borrow().push(future) } - fn run_jobs(&self, context: &mut boa_engine::Context<'_>) { + fn run_jobs(&self, context: &mut boa_engine::Context) { // Early return in case there were no jobs scheduled. if self.jobs.borrow().is_empty() && self.futures.borrow().is_empty() { return; @@ -117,7 +118,7 @@ impl<'a> JobQueue for Queue<'a> { fn delay( _this: &JsValue, args: &[JsValue], - context: &mut Context<'_>, + context: &mut Context, ) -> impl Future> { let millis = args.get_or_undefined(0).to_u32(context); @@ -132,7 +133,7 @@ fn delay( } /// Adds the custom runtime to the context. -fn add_runtime(context: &mut Context<'_>) { +fn add_runtime(context: &mut Context) { // First add the `console` object, to be able to call `console.log()`. let console = Console::init(context); context @@ -152,8 +153,11 @@ fn add_runtime(context: &mut Context<'_>) { fn main() { // Initialize the required executors and the context let executor = LocalExecutor::new(); - let queue: &dyn JobQueue = &Queue::new(executor); - let context = &mut ContextBuilder::new().job_queue(queue).build().unwrap(); + let queue = Queue::new(executor); + let context = &mut ContextBuilder::new() + .job_queue(Rc::new(queue)) + .build() + .unwrap(); // Then, add a custom runtime. add_runtime(context); diff --git a/boa_examples/src/bin/jsdate.rs b/boa_examples/src/bin/jsdate.rs index 499f6664922..b1da16f25f6 100644 --- a/boa_examples/src/bin/jsdate.rs +++ b/boa_examples/src/bin/jsdate.rs @@ -21,8 +21,10 @@ impl HostHooks for CustomTimezone { } fn main() -> JsResult<()> { - let hooks: &dyn HostHooks = &CustomTimezone; - let context = &mut Context::builder().host_hooks(hooks).build().unwrap(); + let context = &mut Context::builder() + .host_hooks(&CustomTimezone) + .build() + .unwrap(); let timestamp = JsDate::utc( &[ diff --git a/boa_examples/src/bin/loadfile.rs b/boa_examples/src/bin/loadfile.rs index d9d4fcd46dc..98c38809e00 100644 --- a/boa_examples/src/bin/loadfile.rs +++ b/boa_examples/src/bin/loadfile.rs @@ -7,7 +7,7 @@ use boa_engine::{js_string, property::Attribute, Context, Source}; use boa_runtime::Console; /// Adds the custom runtime to the context. -fn add_runtime(context: &mut Context<'_>) { +fn add_runtime(context: &mut Context) { // We first add the `console` object, to be able to call `console.log()`. let console = Console::init(context); context diff --git a/boa_examples/src/bin/modulehandler.rs b/boa_examples/src/bin/modulehandler.rs index d446d39aadb..d77198934a3 100644 --- a/boa_examples/src/bin/modulehandler.rs +++ b/boa_examples/src/bin/modulehandler.rs @@ -9,7 +9,7 @@ use boa_runtime::Console; use std::{error::Error, fs::read_to_string}; /// Adds the custom runtime to the context. -fn add_runtime(context: &mut Context<'_>) { +fn add_runtime(context: &mut Context) { // We first add the `console` object, to be able to call `console.log()`. let console = Console::init(context); context @@ -57,7 +57,7 @@ fn main() -> Result<(), Box> { } // Custom implementation that mimics the 'require' module loader -fn require(_: &JsValue, args: &[JsValue], ctx: &mut Context<'_>) -> JsResult { +fn require(_: &JsValue, args: &[JsValue], ctx: &mut Context) -> JsResult { let arg = args.get_or_undefined(0); // BUG: Dev branch seems to be passing string arguments along with quotes diff --git a/boa_examples/src/bin/modules.rs b/boa_examples/src/bin/modules.rs index 02f6d69bc4d..65af1470a41 100644 --- a/boa_examples/src/bin/modules.rs +++ b/boa_examples/src/bin/modules.rs @@ -1,10 +1,8 @@ -use std::{error::Error, path::Path}; +use std::{error::Error, path::Path, rc::Rc}; use boa_engine::{ - builtins::promise::PromiseState, - js_string, - module::{ModuleLoader, SimpleModuleLoader}, - Context, JsError, JsNativeError, JsValue, Module, NativeFunction, + builtins::promise::PromiseState, js_string, module::SimpleModuleLoader, Context, JsError, + JsNativeError, JsValue, Module, NativeFunction, }; use boa_parser::Source; @@ -22,11 +20,10 @@ fn main() -> Result<(), Box> { "#; // This can be overriden with any custom implementation of `ModuleLoader`. - let loader = &SimpleModuleLoader::new("./scripts/modules")?; - let dyn_loader: &dyn ModuleLoader = loader; + let loader = Rc::new(SimpleModuleLoader::new("./scripts/modules")?); // Just need to cast to a `ModuleLoader` before passing it to the builder. - let context = &mut Context::builder().module_loader(dyn_loader).build()?; + let context = &mut Context::builder().module_loader(loader.clone()).build()?; let source = Source::from_reader(MODULE_SRC.as_bytes(), Some(Path::new("./main.mjs"))); // Can also pass a `Some(realm)` if you need to execute the module in another realm. diff --git a/boa_examples/src/bin/synthetic.rs b/boa_examples/src/bin/synthetic.rs index c194d746567..ea3e23fe8da 100644 --- a/boa_examples/src/bin/synthetic.rs +++ b/boa_examples/src/bin/synthetic.rs @@ -2,10 +2,11 @@ // This mirrors the `modules.rs` example but uses synthetic modules instead. use std::path::PathBuf; +use std::rc::Rc; use std::{error::Error, path::Path}; use boa_engine::builtins::promise::PromiseState; -use boa_engine::module::{ModuleLoader, SimpleModuleLoader, SyntheticModuleInitializer}; +use boa_engine::module::{SimpleModuleLoader, SyntheticModuleInitializer}; use boa_engine::object::FunctionObjectBuilder; use boa_engine::{ js_string, Context, JsArgs, JsError, JsNativeError, JsValue, Module, NativeFunction, Source, @@ -24,11 +25,10 @@ fn main() -> Result<(), Box> { "#; // This can be overriden with any custom implementation of `ModuleLoader`. - let loader = &SimpleModuleLoader::new("./scripts/modules")?; - let dyn_loader: &dyn ModuleLoader = loader; + let loader = Rc::new(SimpleModuleLoader::new("./scripts/modules")?); // Just need to cast to a `ModuleLoader` before passing it to the builder. - let context = &mut Context::builder().module_loader(dyn_loader).build()?; + let context = &mut Context::builder().module_loader(loader.clone()).build()?; // Now, create the synthetic module and insert it into the loader. let operations = create_operations_module(context); @@ -101,7 +101,7 @@ fn main() -> Result<(), Box> { } // Creates the synthetic equivalent to the `./modules/operations.mjs` file. -fn create_operations_module(context: &mut Context<'_>) -> Module { +fn create_operations_module(context: &mut Context) -> Module { // We first create the function objects that will be exported by the module. More // on that below. let sum = FunctionObjectBuilder::new( diff --git a/boa_runtime/src/console/mod.rs b/boa_runtime/src/console/mod.rs index bb5f72a9c5f..51df8c067ba 100644 --- a/boa_runtime/src/console/mod.rs +++ b/boa_runtime/src/console/mod.rs @@ -51,7 +51,7 @@ fn logger(msg: LogMessage, console_state: &Console) { } /// This represents the `console` formatter. -fn formatter(data: &[JsValue], context: &mut Context<'_>) -> JsResult { +fn formatter(data: &[JsValue], context: &mut Context) -> JsResult { match data { [] => Ok(String::new()), [val] => Ok(val.to_string(context)?.to_std_string_escaped()), @@ -136,9 +136,9 @@ impl Console { /// Initializes the `console` built-in object. #[allow(clippy::too_many_lines)] - pub fn init(context: &mut Context<'_>) -> JsObject { + pub fn init(context: &mut Context) -> JsObject { fn console_method( - f: fn(&JsValue, &[JsValue], &Console, &mut Context<'_>) -> JsResult, + f: fn(&JsValue, &[JsValue], &Console, &mut Context) -> JsResult, state: Rc>, ) -> NativeFunction { // SAFETY: `Console` doesn't contain types that need tracing. @@ -149,7 +149,7 @@ impl Console { } } fn console_method_mut( - f: fn(&JsValue, &[JsValue], &mut Console, &mut Context<'_>) -> JsResult, + f: fn(&JsValue, &[JsValue], &mut Console, &mut Context) -> JsResult, state: Rc>, ) -> NativeFunction { // SAFETY: `Console` doesn't contain types that need tracing. @@ -268,7 +268,7 @@ impl Console { _: &JsValue, args: &[JsValue], console: &Self, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let assertion = args.get(0).map_or(false, JsValue::to_boolean); @@ -302,12 +302,7 @@ impl Console { /// [spec]: https://console.spec.whatwg.org/#clear /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/API/console/clear #[allow(clippy::unnecessary_wraps)] - fn clear( - _: &JsValue, - _: &[JsValue], - console: &mut Self, - _: &mut Context<'_>, - ) -> JsResult { + fn clear(_: &JsValue, _: &[JsValue], console: &mut Self, _: &mut Context) -> JsResult { console.groups.clear(); Ok(JsValue::undefined()) } @@ -326,7 +321,7 @@ impl Console { _: &JsValue, args: &[JsValue], console: &Self, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { logger(LogMessage::Log(formatter(args, context)?), console); Ok(JsValue::undefined()) @@ -346,7 +341,7 @@ impl Console { _: &JsValue, args: &[JsValue], console: &Self, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { logger(LogMessage::Error(formatter(args, context)?), console); Ok(JsValue::undefined()) @@ -366,7 +361,7 @@ impl Console { _: &JsValue, args: &[JsValue], console: &Self, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { logger(LogMessage::Info(formatter(args, context)?), console); Ok(JsValue::undefined()) @@ -386,7 +381,7 @@ impl Console { _: &JsValue, args: &[JsValue], console: &Self, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { logger(LogMessage::Log(formatter(args, context)?), console); Ok(JsValue::undefined()) @@ -406,7 +401,7 @@ impl Console { _: &JsValue, args: &[JsValue], console: &Self, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { if !args.is_empty() { logger(LogMessage::Log(formatter(args, context)?), console); @@ -439,7 +434,7 @@ impl Console { _: &JsValue, args: &[JsValue], console: &Self, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { logger(LogMessage::Warn(formatter(args, context)?), console); Ok(JsValue::undefined()) @@ -459,7 +454,7 @@ impl Console { _: &JsValue, args: &[JsValue], console: &mut Self, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let label = match args.get(0) { Some(value) => value.to_string(context)?, @@ -488,7 +483,7 @@ impl Console { _: &JsValue, args: &[JsValue], console: &mut Self, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let label = match args.get(0) { Some(value) => value.to_string(context)?, @@ -527,7 +522,7 @@ impl Console { _: &JsValue, args: &[JsValue], console: &mut Self, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let label = match args.get(0) { Some(value) => value.to_string(context)?, @@ -564,7 +559,7 @@ impl Console { _: &JsValue, args: &[JsValue], console: &Self, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let label = match args.get(0) { Some(value) => value.to_string(context)?, @@ -608,7 +603,7 @@ impl Console { _: &JsValue, args: &[JsValue], console: &mut Self, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let label = match args.get(0) { Some(value) => value.to_string(context)?, @@ -655,7 +650,7 @@ impl Console { _: &JsValue, args: &[JsValue], console: &mut Self, - context: &mut Context<'_>, + context: &mut Context, ) -> JsResult { let group_label = formatter(args, context)?; @@ -680,7 +675,7 @@ impl Console { _: &JsValue, _: &[JsValue], console: &mut Self, - _: &mut Context<'_>, + _: &mut Context, ) -> JsResult { console.groups.pop(); @@ -698,12 +693,7 @@ impl Console { /// [spec]: https://console.spec.whatwg.org/#dir /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/API/console/dir #[allow(clippy::unnecessary_wraps)] - fn dir( - _: &JsValue, - args: &[JsValue], - console: &Self, - _: &mut Context<'_>, - ) -> JsResult { + fn dir(_: &JsValue, args: &[JsValue], console: &Self, _: &mut Context) -> JsResult { logger( LogMessage::Info(args.get_or_undefined(0).display_obj(true)), console, diff --git a/boa_runtime/src/lib.rs b/boa_runtime/src/lib.rs index 08860c0111d..d3e71b29c59 100644 --- a/boa_runtime/src/lib.rs +++ b/boa_runtime/src/lib.rs @@ -126,7 +126,7 @@ pub(crate) mod test { source: Cow<'static, str>, }, InspectContext { - op: fn(&mut Context<'_>), + op: fn(&mut Context), }, Assert { source: Cow<'static, str>, @@ -137,7 +137,7 @@ pub(crate) mod test { }, AssertWithOp { source: Cow<'static, str>, - op: fn(JsValue, &mut Context<'_>) -> bool, + op: fn(JsValue, &mut Context) -> bool, }, AssertOpaqueError { source: Cow<'static, str>, @@ -149,7 +149,7 @@ pub(crate) mod test { message: &'static str, }, AssertContext { - op: fn(&mut Context<'_>) -> bool, + op: fn(&mut Context) -> bool, }, } @@ -164,7 +164,7 @@ pub(crate) mod test { /// Executes `op` with the currently active context. /// /// Useful to make custom assertions that must be done from Rust code. - pub(crate) fn inspect_context(op: fn(&mut Context<'_>)) -> Self { + pub(crate) fn inspect_context(op: fn(&mut Context)) -> Self { Self(Inner::InspectContext { op }) } } @@ -181,10 +181,10 @@ pub(crate) mod test { #[allow(clippy::too_many_lines, clippy::missing_panics_doc)] pub(crate) fn run_test_actions_with( actions: impl IntoIterator, - context: &mut Context<'_>, + context: &mut Context, ) { #[track_caller] - fn forward_val(context: &mut Context<'_>, source: &str) -> JsResult { + fn forward_val(context: &mut Context, source: &str) -> JsResult { context.eval(Source::from_bytes(source)) } diff --git a/boa_tester/src/exec/js262.rs b/boa_tester/src/exec/js262.rs index 1fb66510559..b9ed810df56 100644 --- a/boa_tester/src/exec/js262.rs +++ b/boa_tester/src/exec/js262.rs @@ -69,7 +69,7 @@ impl Drop for WorkerHandles { } /// Creates the object $262 in the context. -pub(super) fn register_js262(handles: WorkerHandles, context: &mut Context<'_>) -> JsObject { +pub(super) fn register_js262(handles: WorkerHandles, context: &mut Context) -> JsObject { let global_obj = context.global_object(); let agent = agent_obj(handles, context); @@ -119,7 +119,7 @@ pub(super) fn register_js262(handles: WorkerHandles, context: &mut Context<'_>) /// Creates a new ECMAScript Realm, defines this API on the new realm's global object, and /// returns the `$262` property of the new realm's global object. #[allow(clippy::unnecessary_wraps)] -fn create_realm(_: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult { +fn create_realm(_: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { let context = &mut Context::default(); let js262 = register_js262(WorkerHandles::new(), context); @@ -130,7 +130,7 @@ fn create_realm(_: &JsValue, _: &[JsValue], _: &mut Context<'_>) -> JsResult) -> JsResult { +fn detach_array_buffer(_: &JsValue, args: &[JsValue], _: &mut Context) -> JsResult { fn type_err() -> JsNativeError { JsNativeError::typ().with_message("The provided object was not an ArrayBuffer") } @@ -159,7 +159,7 @@ fn detach_array_buffer(_: &JsValue, args: &[JsValue], _: &mut Context<'_>) -> Js /// The `$262.evalScript()` function. /// /// Accepts a string value as its first argument and executes it as an ECMAScript script. -fn eval_script(_this: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult { +fn eval_script(_this: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { args.get(0).and_then(JsValue::as_string).map_or_else( || Ok(JsValue::undefined()), |source_text| context.eval(Source::from_bytes(&source_text.to_std_string_escaped())), @@ -172,13 +172,13 @@ fn eval_script(_this: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> /// Must throw an exception if no capability exists. This is necessary for testing the /// semantics of any feature that relies on garbage collection, e.g. the `WeakRef` API. #[allow(clippy::unnecessary_wraps)] -fn gc(_this: &JsValue, _: &[JsValue], _context: &mut Context<'_>) -> JsResult { +fn gc(_this: &JsValue, _: &[JsValue], _context: &mut Context) -> JsResult { boa_gc::force_collect(); Ok(JsValue::undefined()) } /// The `$262.agent.sleep()` function. -fn sleep(_: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult { +fn sleep(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { let ms = args.get_or_undefined(0).to_number(context)? / 1000.0; std::thread::sleep(Duration::from_secs_f64(ms)); Ok(JsValue::undefined()) @@ -186,12 +186,12 @@ fn sleep(_: &JsValue, args: &[JsValue], context: &mut Context<'_>) -> JsResult) -> JsResult { +fn monotonic_now(_: &JsValue, _: &[JsValue], _: &mut Context) -> JsResult { Ok(JsValue::from(START.elapsed().as_millis() as f64)) } /// Initializes the `$262.agent` object in the main agent. -fn agent_obj(handles: WorkerHandles, context: &mut Context<'_>) -> JsObject { +fn agent_obj(handles: WorkerHandles, context: &mut Context) -> JsObject { // TODO: improve initialization of this by using a `[[HostDefined]]` field on `Context`. let bus = Rc::new(RefCell::new(bus::Bus::new(1))); @@ -273,7 +273,7 @@ fn agent_obj(handles: WorkerHandles, context: &mut Context<'_>) -> JsObject { fn register_js262_worker( rx: BusReader, tx: Sender>, - context: &mut Context<'_>, + context: &mut Context, ) { let rx = RefCell::new(rx); let receive_broadcast = unsafe { diff --git a/boa_tester/src/exec/mod.rs b/boa_tester/src/exec/mod.rs index 13ed6a4bb8c..b3301a15f4c 100644 --- a/boa_tester/src/exec/mod.rs +++ b/boa_tester/src/exec/mod.rs @@ -9,7 +9,7 @@ use crate::{ use boa_engine::{ builtins::promise::PromiseState, js_string, - module::{Module, ModuleLoader, SimpleModuleLoader}, + module::{Module, SimpleModuleLoader}, native_function::NativeFunction, object::FunctionObjectBuilder, optimizer::OptimizerOptions, @@ -243,13 +243,14 @@ impl Test { let result = std::panic::catch_unwind(|| match self.expected_outcome { Outcome::Positive => { let async_result = AsyncResult::default(); - let loader = &SimpleModuleLoader::new( - self.path.parent().expect("test should have a parent dir"), - ) - .expect("test path should be canonicalizable"); - let dyn_loader: &dyn ModuleLoader = loader; + let loader = Rc::new( + SimpleModuleLoader::new( + self.path.parent().expect("test should have a parent dir"), + ) + .expect("test path should be canonicalizable"), + ); let context = &mut Context::builder() - .module_loader(dyn_loader) + .module_loader(loader.clone()) .can_block(!self.flags.contains(TestFlags::CAN_BLOCK_IS_FALSE)) .build() .expect("cannot fail with default global object"); @@ -374,13 +375,14 @@ impl Test { phase: Phase::Resolution, error_type, } => { - let loader = &SimpleModuleLoader::new( - self.path.parent().expect("test should have a parent dir"), - ) - .expect("test path should be canonicalizable"); - let dyn_loader: &dyn ModuleLoader = loader; + let loader = Rc::new( + SimpleModuleLoader::new( + self.path.parent().expect("test should have a parent dir"), + ) + .expect("test path should be canonicalizable"), + ); let context = &mut Context::builder() - .module_loader(dyn_loader) + .module_loader(loader.clone()) .build() .expect("cannot fail with default global object"); @@ -429,13 +431,14 @@ impl Test { phase: Phase::Runtime, error_type, } => { - let loader = &SimpleModuleLoader::new( - self.path.parent().expect("test should have a parent dir"), - ) - .expect("test path should be canonicalizable"); - let dyn_loader: &dyn ModuleLoader = loader; + let loader = Rc::new( + SimpleModuleLoader::new( + self.path.parent().expect("test should have a parent dir"), + ) + .expect("test path should be canonicalizable"), + ); let context = &mut Context::builder() - .module_loader(dyn_loader) + .module_loader(loader.clone()) .can_block(!self.flags.contains(TestFlags::CAN_BLOCK_IS_FALSE)) .build() .expect("cannot fail with default global object"); @@ -586,7 +589,7 @@ impl Test { fn set_up_env( &self, harness: &Harness, - context: &mut Context<'_>, + context: &mut Context, async_result: AsyncResult, handles: WorkerHandles, console: bool, @@ -651,7 +654,7 @@ impl Test { } /// Returns `true` if `error` is a `target_type` error. -fn is_error_type(error: &JsError, target_type: ErrorType, context: &mut Context<'_>) -> bool { +fn is_error_type(error: &JsError, target_type: ErrorType, context: &mut Context) -> bool { if let Ok(error) = error.try_native(context) { match &error.kind { JsNativeErrorKind::Syntax if target_type == ErrorType::SyntaxError => {} @@ -679,7 +682,7 @@ fn is_error_type(error: &JsError, target_type: ErrorType, context: &mut Context< } /// Registers the print function in the context. -fn register_print_fn(context: &mut Context<'_>, async_result: AsyncResult) { +fn register_print_fn(context: &mut Context, async_result: AsyncResult) { // We use `FunctionBuilder` to define a closure with additional captures. let js_function = FunctionObjectBuilder::new( context.realm(),