diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f45460602e..8a85659fe1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -244,7 +244,7 @@ jobs: ~/.cargo/registry/index ~/.cargo/registry/cache ~/.cargo/git/db - key: 7-cargo-home-${{ matrix.os }}-${{ hashFiles('Cargo.lock') }} + key: 8-cargo-home-${{ matrix.os }}-${{ hashFiles('Cargo.lock') }} # In main branch, always creates fresh cache - name: Cache build output (main) @@ -260,7 +260,7 @@ jobs: !./target/*/*.zip !./target/*/*.tar.gz key: | - 7-cargo-target-${{ matrix.os }}-${{ matrix.profile }}-${{ github.sha }} + 8-cargo-target-${{ matrix.os }}-${{ matrix.profile }}-${{ github.sha }} # Restore cache from the latest 'main' branch build. - name: Cache build output (PR) @@ -276,7 +276,7 @@ jobs: !./target/*/*.tar.gz key: never_saved restore-keys: | - 7-cargo-target-${{ matrix.os }}-${{ matrix.profile }}- + 8-cargo-target-${{ matrix.os }}-${{ matrix.profile }}- # Don't save cache after building PRs or branches other than 'main'. - name: Skip save cache (PR) diff --git a/bench_util/benches/op_baseline.rs b/bench_util/benches/op_baseline.rs index 929e573cdb..07c4905a9d 100644 --- a/bench_util/benches/op_baseline.rs +++ b/bench_util/benches/op_baseline.rs @@ -22,22 +22,18 @@ fn setup() -> Vec { } #[op] -fn op_nop(_: &mut OpState, _: (), _: ()) -> Result<(), AnyError> { +fn op_nop(_: &mut OpState) -> Result<(), AnyError> { Ok(()) } #[op] -fn op_pi_json(_: &mut OpState, _: (), _: ()) -> Result { +fn op_pi_json(_: &mut OpState) -> Result { Ok(314159) } // this is a function since async closures aren't stable #[op] -async fn op_pi_async( - _: Rc>, - _: (), - _: (), -) -> Result { +async fn op_pi_async(_: Rc>) -> Result { Ok(314159) } diff --git a/cli/build.rs b/cli/build.rs index f1eb1829c4..d118dd5b9f 100644 --- a/cli/build.rs +++ b/cli/build.rs @@ -192,7 +192,6 @@ fn create_compiler_snapshot( fn op_build_info( state: &mut OpState, _args: Value, - _: (), ) -> Result { let build_specifier = "asset:///bootstrap.ts"; let build_libs = state.borrow::>(); @@ -203,31 +202,19 @@ fn create_compiler_snapshot( } #[op] - fn op_cwd( - _state: &mut OpState, - _args: Value, - _: (), - ) -> Result { + fn op_cwd(_state: &mut OpState, _args: Value) -> Result { Ok(json!("cache:///")) } #[op] - fn op_exists( - _state: &mut OpState, - _args: Value, - _: (), - ) -> Result { + fn op_exists(_state: &mut OpState, _args: Value) -> Result { Ok(json!(false)) } #[op] // using the same op that is used in `tsc.rs` for loading modules and reading // files, but a slightly different implementation at build time. - fn op_load( - state: &mut OpState, - args: LoadArgs, - _: (), - ) -> Result { + fn op_load(state: &mut OpState, args: LoadArgs) -> Result { let op_crate_libs = state.borrow::>(); let path_dts = state.borrow::(); let re_asset = diff --git a/cli/lsp/tsc.rs b/cli/lsp/tsc.rs index 648045f4e7..4f3e88e7d4 100644 --- a/cli/lsp/tsc.rs +++ b/cli/lsp/tsc.rs @@ -2515,7 +2515,6 @@ struct SourceSnapshotArgs { fn op_dispose( state: &mut OpState, args: SourceSnapshotArgs, - _: (), ) -> Result { let state = state.borrow_mut::(); let mark = state.performance.mark("op_dispose", Some(&args)); @@ -2535,7 +2534,6 @@ struct SpecifierArgs { fn op_exists( state: &mut OpState, args: SpecifierArgs, - _: (), ) -> Result { let state = state.borrow_mut::(); // we don't measure the performance of op_exists anymore because as of TS 4.5 @@ -2569,7 +2567,6 @@ struct GetChangeRangeArgs { fn op_get_change_range( state: &mut OpState, args: GetChangeRangeArgs, - _: (), ) -> Result { let state = state.borrow_mut::(); let mark = state.performance.mark("op_get_change_range", Some(&args)); @@ -2616,7 +2613,6 @@ fn op_get_change_range( fn op_get_length( state: &mut OpState, args: SourceSnapshotArgs, - _: (), ) -> Result { let state = state.borrow_mut::(); let mark = state.performance.mark("op_get_length", Some(&args)); @@ -2650,7 +2646,6 @@ struct GetTextArgs { fn op_get_text( state: &mut OpState, args: GetTextArgs, - _: (), ) -> Result { let state = state.borrow_mut::(); let mark = state.performance.mark("op_get_text", Some(&args)); @@ -2670,11 +2665,7 @@ fn op_get_text( } #[op] -fn op_is_cancelled( - state: &mut OpState, - _: (), - _: (), -) -> Result { +fn op_is_cancelled(state: &mut OpState) -> Result { let state = state.borrow_mut::(); Ok(state.token.is_cancelled()) } @@ -2683,7 +2674,6 @@ fn op_is_cancelled( fn op_load( state: &mut OpState, args: SpecifierArgs, - _: (), ) -> Result, AnyError> { let state = state.borrow_mut::(); let mark = state.performance.mark("op_load", Some(&args)); @@ -2697,7 +2687,6 @@ fn op_load( fn op_resolve( state: &mut OpState, args: ResolveArgs, - _: (), ) -> Result>, AnyError> { let state = state.borrow_mut::(); let mark = state.performance.mark("op_resolve", Some(&args)); @@ -2731,11 +2720,7 @@ fn op_resolve( } #[op] -fn op_respond( - state: &mut OpState, - args: Response, - _: (), -) -> Result { +fn op_respond(state: &mut OpState, args: Response) -> Result { let state = state.borrow_mut::(); state.response = Some(args); Ok(true) @@ -2745,7 +2730,6 @@ fn op_respond( fn op_script_names( state: &mut OpState, _args: Value, - _: (), ) -> Result, AnyError> { let state = state.borrow_mut::(); Ok( @@ -2769,7 +2753,6 @@ struct ScriptVersionArgs { fn op_script_version( state: &mut OpState, args: ScriptVersionArgs, - _: (), ) -> Result, AnyError> { let state = state.borrow_mut::(); // this op is very "noisy" and measuring its performance is not useful, so we @@ -3881,7 +3864,6 @@ mod tests { SpecifierArgs { specifier: "/error/unknown:something/index.d.ts".to_string(), }, - (), ); assert!(actual.is_ok()); let actual = actual.unwrap(); diff --git a/cli/ops/bench.rs b/cli/ops/bench.rs index ab15a2b4b0..4b7d6743fa 100644 --- a/cli/ops/bench.rs +++ b/cli/ops/bench.rs @@ -35,7 +35,6 @@ struct PermissionsHolder(Uuid, Permissions); pub fn op_pledge_test_permissions( state: &mut OpState, args: ChildPermissionsArg, - _: (), ) -> Result { let token = Uuid::new_v4(); let parent_permissions = state.borrow_mut::(); @@ -54,7 +53,6 @@ pub fn op_pledge_test_permissions( pub fn op_restore_test_permissions( state: &mut OpState, token: Uuid, - _: (), ) -> Result<(), AnyError> { if let Some(permissions_holder) = state.try_take::() { if token != permissions_holder.0 { @@ -70,11 +68,7 @@ pub fn op_restore_test_permissions( } #[op] -fn op_get_bench_origin( - state: &mut OpState, - _: (), - _: (), -) -> Result { +fn op_get_bench_origin(state: &mut OpState) -> Result { Ok(state.borrow::().to_string()) } @@ -82,7 +76,6 @@ fn op_get_bench_origin( fn op_dispatch_bench_event( state: &mut OpState, event: BenchEvent, - _: (), ) -> Result<(), AnyError> { let sender = state.borrow::>().clone(); sender.send(event).ok(); @@ -91,7 +84,7 @@ fn op_dispatch_bench_event( } #[op] -fn op_bench_now(state: &mut OpState, _: (), _: ()) -> Result { +fn op_bench_now(state: &mut OpState) -> Result { let ns = state.borrow::().elapsed().as_nanos(); let ns_u64 = u64::try_from(ns)?; Ok(ns_u64) diff --git a/cli/ops/errors.rs b/cli/ops/errors.rs index c215ade418..5be6e07374 100644 --- a/cli/ops/errors.rs +++ b/cli/ops/errors.rs @@ -46,7 +46,6 @@ struct AppliedSourceMap { fn op_apply_source_map( state: &mut OpState, args: ApplySourceMap, - _: (), ) -> Result { let mut mappings_map: CachedMaps = HashMap::new(); let ps = state.borrow::().clone(); @@ -71,7 +70,6 @@ fn op_apply_source_map( fn op_format_diagnostic( _state: &mut OpState, args: Value, - _: (), ) -> Result { let diagnostic: Diagnostics = serde_json::from_value(args)?; Ok(json!(diagnostic.to_string())) @@ -81,7 +79,6 @@ fn op_format_diagnostic( fn op_format_file_name( _state: &mut OpState, file_name: String, - _: (), ) -> Result { Ok(format_file_name(&file_name)) } diff --git a/cli/ops/runtime_compiler.rs b/cli/ops/runtime_compiler.rs index 6fb8d688c6..8c02190c02 100644 --- a/cli/ops/runtime_compiler.rs +++ b/cli/ops/runtime_compiler.rs @@ -144,7 +144,6 @@ fn to_maybe_jsx_import_source_module( async fn op_emit( state: Rc>, args: EmitArgs, - _: (), ) -> Result { deno_runtime::ops::check_unstable2(&state, "Deno.emit"); let root_specifier = args.root_specifier; diff --git a/cli/ops/testing.rs b/cli/ops/testing.rs index ebaa819e1b..eb2deb90c3 100644 --- a/cli/ops/testing.rs +++ b/cli/ops/testing.rs @@ -33,7 +33,6 @@ struct PermissionsHolder(Uuid, Permissions); pub fn op_pledge_test_permissions( state: &mut OpState, args: ChildPermissionsArg, - _: (), ) -> Result { let token = Uuid::new_v4(); let parent_permissions = state.borrow_mut::(); @@ -52,7 +51,6 @@ pub fn op_pledge_test_permissions( pub fn op_restore_test_permissions( state: &mut OpState, token: Uuid, - _: (), ) -> Result<(), AnyError> { if let Some(permissions_holder) = state.try_take::() { if token != permissions_holder.0 { @@ -68,11 +66,7 @@ pub fn op_restore_test_permissions( } #[op] -fn op_get_test_origin( - state: &mut OpState, - _: (), - _: (), -) -> Result { +fn op_get_test_origin(state: &mut OpState) -> Result { Ok(state.borrow::().to_string()) } @@ -80,7 +74,6 @@ fn op_get_test_origin( fn op_dispatch_test_event( state: &mut OpState, event: TestEvent, - _: (), ) -> Result<(), AnyError> { let sender = state.borrow::>().clone(); sender.send(event).ok(); diff --git a/cli/tsc.rs b/cli/tsc.rs index ddb8a442e8..39f78ec9d4 100644 --- a/cli/tsc.rs +++ b/cli/tsc.rs @@ -307,11 +307,7 @@ struct CreateHashArgs { } #[op] -fn op_create_hash( - s: &mut OpState, - args: Value, - _: (), -) -> Result { +fn op_create_hash(s: &mut OpState, args: Value) -> Result { let state = s.borrow_mut::(); let v: CreateHashArgs = serde_json::from_value(args) .context("Invalid request from JavaScript for \"op_create_hash\".")?; @@ -322,7 +318,7 @@ fn op_create_hash( } #[op] -fn op_cwd(s: &mut OpState, _args: Value, _: ()) -> Result { +fn op_cwd(s: &mut OpState, _args: Value) -> Result { let state = s.borrow_mut::(); if let Some(config_specifier) = &state.maybe_config_specifier { let cwd = config_specifier.join("./")?; @@ -347,11 +343,7 @@ struct EmitArgs { } #[op] -fn op_emit( - state: &mut OpState, - args: EmitArgs, - _: (), -) -> Result { +fn op_emit(state: &mut OpState, args: EmitArgs) -> Result { let state = state.borrow_mut::(); match args.file_name.as_ref() { "deno:///.tsbuildinfo" => state.maybe_tsbuildinfo = Some(args.data), @@ -406,11 +398,7 @@ struct ExistsArgs { } #[op] -fn op_exists( - state: &mut OpState, - args: ExistsArgs, - _: (), -) -> Result { +fn op_exists(state: &mut OpState, args: ExistsArgs) -> Result { let state = state.borrow_mut::(); let graph_data = state.graph_data.read(); if let Ok(specifier) = normalize_specifier(&args.specifier) { @@ -452,7 +440,7 @@ fn as_ts_script_kind(media_type: &MediaType) -> i32 { } #[op] -fn op_load(state: &mut OpState, args: Value, _: ()) -> Result { +fn op_load(state: &mut OpState, args: Value) -> Result { let state = state.borrow_mut::(); let v: LoadArgs = serde_json::from_value(args) .context("Invalid request from JavaScript for \"op_load\".")?; @@ -521,7 +509,6 @@ pub struct ResolveArgs { fn op_resolve( state: &mut OpState, args: ResolveArgs, - _: (), ) -> Result { let state = state.borrow_mut::(); let mut resolved: Vec<(String, String)> = Vec::new(); @@ -629,11 +616,7 @@ struct RespondArgs { } #[op] -fn op_respond( - state: &mut OpState, - args: Value, - _: (), -) -> Result { +fn op_respond(state: &mut OpState, args: Value) -> Result { let state = state.borrow_mut::(); let v: RespondArgs = serde_json::from_value(args) .context("Error converting the result for \"op_respond\".")?; @@ -881,7 +864,6 @@ mod tests { let actual = op_create_hash::call( &mut state, json!({ "data": "some sort of content" }), - (), ) .expect("could not invoke op"); assert_eq!( @@ -934,7 +916,6 @@ mod tests { file_name: "cache:///some/file.js".to_string(), maybe_specifiers: Some(vec!["file:///some/file.ts".to_string()]), }, - (), ) .expect("should have invoked op"); assert_eq!(actual, json!(true)); @@ -966,7 +947,6 @@ mod tests { vec!["file:///some/file.ts?q=.json".to_string()], ), }, - (), ) .expect("should have invoked op"); assert_eq!(actual, json!(true)); @@ -996,7 +976,6 @@ mod tests { file_name: "deno:///.tsbuildinfo".to_string(), maybe_specifiers: None, }, - (), ) .expect("should have invoked op"); assert_eq!(actual, json!(true)); @@ -1019,7 +998,6 @@ mod tests { let actual = op_load::call( &mut state, json!({ "specifier": "https://deno.land/x/mod.ts"}), - (), ) .expect("should have invoked op"); assert_eq!( @@ -1051,7 +1029,6 @@ mod tests { let value = op_load::call( &mut state, json!({ "specifier": "asset:///lib.dom.d.ts" }), - (), ) .expect("should have invoked op"); let actual: LoadResponse = @@ -1070,12 +1047,9 @@ mod tests { Some("some content".to_string()), ) .await; - let actual = op_load::call( - &mut state, - json!({ "specifier": "deno:///.tsbuildinfo"}), - (), - ) - .expect("should have invoked op"); + let actual = + op_load::call(&mut state, json!({ "specifier": "deno:///.tsbuildinfo"})) + .expect("should have invoked op"); assert_eq!( actual, json!({ @@ -1092,7 +1066,6 @@ mod tests { let actual = op_load::call( &mut state, json!({ "specifier": "https://deno.land/x/mod.ts"}), - (), ) .expect("should have invoked op"); assert_eq!( @@ -1119,7 +1092,6 @@ mod tests { base: "https://deno.land/x/a.ts".to_string(), specifiers: vec!["./b.ts".to_string()], }, - (), ) .expect("should have invoked op"); assert_eq!(actual, json!([["https://deno.land/x/b.ts", ".ts"]])); @@ -1139,7 +1111,6 @@ mod tests { base: "https://deno.land/x/a.ts".to_string(), specifiers: vec!["./bad.ts".to_string()], }, - (), ) .expect("should have not errored"); assert_eq!( @@ -1163,7 +1134,6 @@ mod tests { ], "stats": [["a", 12]] }), - (), ) .expect("should have invoked op"); assert_eq!(actual, json!(true)); diff --git a/core/examples/hello_world.rs b/core/examples/hello_world.rs index bfca5447c5..d5d7af94d6 100644 --- a/core/examples/hello_world.rs +++ b/core/examples/hello_world.rs @@ -17,7 +17,6 @@ use deno_core::*; fn op_sum( _state: &mut OpState, nums: Vec, - _: (), ) -> Result { // Sum inputs let sum = nums.iter().fold(0.0, |a, v| a + v); diff --git a/core/examples/http_bench_json_ops.rs b/core/examples/http_bench_json_ops.rs index 3f608eeae2..2068c3b853 100644 --- a/core/examples/http_bench_json_ops.rs +++ b/core/examples/http_bench_json_ops.rs @@ -135,7 +135,7 @@ fn create_js_runtime() -> JsRuntime { } #[op] -fn op_listen(state: &mut OpState, _: (), _: ()) -> Result { +fn op_listen(state: &mut OpState) -> Result { log::debug!("listen"); let addr = "127.0.0.1:4544".parse::().unwrap(); let std_listener = std::net::TcpListener::bind(&addr)?; @@ -149,7 +149,6 @@ fn op_listen(state: &mut OpState, _: (), _: ()) -> Result { async fn op_accept( state: Rc>, rid: ResourceId, - _: (), ) -> Result { log::debug!("accept rid={}", rid); diff --git a/core/examples/schedule_task.rs b/core/examples/schedule_task.rs index 3ada864178..7812dcb497 100644 --- a/core/examples/schedule_task.rs +++ b/core/examples/schedule_task.rs @@ -62,7 +62,7 @@ fn main() { } #[op] -fn op_schedule_task(state: &mut OpState, i: u8, _: ()) -> Result<(), Error> { +fn op_schedule_task(state: &mut OpState, i: u8) -> Result<(), Error> { let tx = state.borrow_mut::>(); tx.unbounded_send(Box::new(move || println!("Hello, world! x{}", i))) .expect("unbounded_send failed"); diff --git a/core/modules.rs b/core/modules.rs index 7c52741934..481091e0f8 100644 --- a/core/modules.rs +++ b/core/modules.rs @@ -1406,7 +1406,7 @@ import "/a.js"; static DISPATCH_COUNT: AtomicUsize = AtomicUsize::new(0); #[op] - fn op_test(_: &mut OpState, control: u8, _: ()) -> Result { + fn op_test(_: &mut OpState, control: u8) -> Result { DISPATCH_COUNT.fetch_add(1, Ordering::Relaxed); assert_eq!(control, 42); Ok(43) diff --git a/core/ops_builtin.rs b/core/ops_builtin.rs index 14d8c6e39e..a742a77b1b 100644 --- a/core/ops_builtin.rs +++ b/core/ops_builtin.rs @@ -40,7 +40,7 @@ pub(crate) fn init_builtins() -> Extension { } #[op] -pub fn void_op_sync(_: &mut OpState, _: (), _: ()) -> Result<(), Error> { +pub fn void_op_sync(_: &mut OpState) -> Result<(), Error> { Ok(()) } @@ -57,8 +57,6 @@ pub async fn void_op_async( #[op] pub fn op_resources( state: &mut OpState, - _: (), - _: (), ) -> Result, Error> { let serialized_resources = state .resource_table @@ -69,16 +67,12 @@ pub fn op_resources( } #[op] -pub fn op_void_sync(_state: &mut OpState, _: (), _: ()) -> Result<(), Error> { +pub fn op_void_sync(_state: &mut OpState) -> Result<(), Error> { Ok(()) } #[op] -pub async fn op_void_async( - _state: Rc>, - _: (), - _: (), -) -> Result<(), Error> { +pub async fn op_void_async(_state: Rc>) -> Result<(), Error> { Ok(()) } @@ -87,7 +81,6 @@ pub async fn op_void_async( pub fn op_close( state: &mut OpState, rid: Option, - _: (), ) -> Result<(), Error> { // TODO(@AaronO): drop Option after improving type-strictness balance in // serde_v8 @@ -102,7 +95,6 @@ pub fn op_close( pub fn op_try_close( state: &mut OpState, rid: Option, - _: (), ) -> Result<(), Error> { // TODO(@AaronO): drop Option after improving type-strictness balance in // serde_v8. @@ -114,8 +106,6 @@ pub fn op_try_close( #[op] pub fn op_metrics( state: &mut OpState, - _: (), - _: (), ) -> Result<(OpMetrics, Vec), Error> { let aggregate = state.tracker.aggregate(); let per_op = state.tracker.per_op(); @@ -229,7 +219,6 @@ async fn op_write( async fn op_shutdown( state: Rc>, rid: ResourceId, - _: (), ) -> Result<(), Error> { let resource = state.borrow().resource_table.get_any(rid)?; resource.shutdown().await diff --git a/core/runtime.rs b/core/runtime.rs index a4fa0c51ff..0190655268 100644 --- a/core/runtime.rs +++ b/core/runtime.rs @@ -2062,7 +2062,7 @@ pub mod tests { #[test] fn test_error_builder() { #[op] - fn op_err(_: &mut OpState, _: (), _: ()) -> Result<(), Error> { + fn op_err(_: &mut OpState) -> Result<(), Error> { Err(custom_error("DOMExceptionOperationError", "abc")) } @@ -2468,8 +2468,6 @@ assertEquals(1, notify_return_value); #[op] async fn op_async_borrow( op_state: Rc>, - _: (), - _: (), ) -> Result<(), Error> { let n = { let op_state = op_state.borrow(); @@ -2511,8 +2509,6 @@ assertEquals(1, notify_return_value); #[op] async fn op_async_sleep( _op_state: Rc>, - _: (), - _: (), ) -> Result<(), Error> { // Future must be Poll::Pending on first call tokio::time::sleep(std::time::Duration::from_millis(1)).await; @@ -2588,13 +2584,13 @@ assertEquals(1, notify_return_value); static NEXT_TICK: AtomicUsize = AtomicUsize::new(0); #[op] - fn op_macrotask(_: &mut OpState, _: (), _: ()) -> Result<(), AnyError> { + fn op_macrotask(_: &mut OpState) -> Result<(), AnyError> { MACROTASK.fetch_add(1, Ordering::Relaxed); Ok(()) } #[op] - fn op_next_tick(_: &mut OpState, _: (), _: ()) -> Result<(), AnyError> { + fn op_next_tick(_: &mut OpState) -> Result<(), AnyError> { NEXT_TICK.fetch_add(1, Ordering::Relaxed); Ok(()) } @@ -2725,21 +2721,13 @@ assertEquals(1, notify_return_value); static UNCAUGHT_EXCEPTION: AtomicUsize = AtomicUsize::new(0); #[op] - fn op_promise_reject( - _: &mut OpState, - _: (), - _: (), - ) -> Result<(), AnyError> { + fn op_promise_reject(_: &mut OpState) -> Result<(), AnyError> { PROMISE_REJECT.fetch_add(1, Ordering::Relaxed); Ok(()) } #[op] - fn op_uncaught_exception( - _: &mut OpState, - _: (), - _: (), - ) -> Result<(), AnyError> { + fn op_uncaught_exception(_: &mut OpState) -> Result<(), AnyError> { UNCAUGHT_EXCEPTION.fetch_add(1, Ordering::Relaxed); Ok(()) } diff --git a/ext/broadcast_channel/lib.rs b/ext/broadcast_channel/lib.rs index eff57c7dfe..e228871b9d 100644 --- a/ext/broadcast_channel/lib.rs +++ b/ext/broadcast_channel/lib.rs @@ -45,8 +45,6 @@ struct Unstable(bool); // --unstable #[op] pub fn op_broadcast_subscribe( state: &mut OpState, - _: (), - _: (), ) -> Result where BC: BroadcastChannel + 'static, @@ -97,7 +95,6 @@ where pub async fn op_broadcast_recv( state: Rc>, rid: ResourceId, - _: (), ) -> Result, AnyError> where BC: BroadcastChannel + 'static, diff --git a/ext/crypto/generate_key.rs b/ext/crypto/generate_key.rs index 9fe1b62f42..22f0913ec4 100644 --- a/ext/crypto/generate_key.rs +++ b/ext/crypto/generate_key.rs @@ -46,7 +46,6 @@ pub enum GenerateKeyOptions { pub async fn op_crypto_generate_key( _state: Rc>, opts: GenerateKeyOptions, - _: (), ) -> Result { let fun = || match opts { GenerateKeyOptions::Rsa { diff --git a/ext/crypto/lib.rs b/ext/crypto/lib.rs index 3b33830d3e..e45e3d272f 100644 --- a/ext/crypto/lib.rs +++ b/ext/crypto/lib.rs @@ -115,7 +115,6 @@ pub fn init(maybe_seed: Option) -> Extension { pub fn op_crypto_get_random_values( state: &mut OpState, mut zero_copy: ZeroCopyBuf, - _: (), ) -> Result<(), AnyError> { if zero_copy.len() > 65536 { return Err( @@ -791,11 +790,7 @@ impl<'a> TryFrom> } #[op] -pub fn op_crypto_random_uuid( - state: &mut OpState, - _: (), - _: (), -) -> Result { +pub fn op_crypto_random_uuid(state: &mut OpState) -> Result { let maybe_seeded_rng = state.try_borrow_mut::(); let uuid = if let Some(seeded_rng) = maybe_seeded_rng { let mut bytes = [0u8; 16]; diff --git a/ext/fetch/lib.rs b/ext/fetch/lib.rs index 7a0c9b16f2..59d5f9a6bc 100644 --- a/ext/fetch/lib.rs +++ b/ext/fetch/lib.rs @@ -369,7 +369,6 @@ pub struct FetchResponse { pub async fn op_fetch_send( state: Rc>, rid: ResourceId, - _: (), ) -> Result { let request = state .borrow_mut() @@ -528,7 +527,6 @@ pub struct CreateHttpClientOptions { pub fn op_fetch_custom_client( state: &mut OpState, args: CreateHttpClientOptions, - _: (), ) -> Result where FP: FetchPermissions + 'static, diff --git a/ext/ffi/lib.rs b/ext/ffi/lib.rs index b4d8712f4e..07297071a5 100644 --- a/ext/ffi/lib.rs +++ b/ext/ffi/lib.rs @@ -465,7 +465,6 @@ pub(crate) fn format_error(e: dlopen::Error, path: String) -> String { fn op_ffi_load( state: &mut deno_core::OpState, args: FfiLoadArgs, - _: (), ) -> Result where FP: FfiPermissions + 'static, @@ -652,7 +651,6 @@ fn ffi_call(args: FfiCallArgs, symbol: &Symbol) -> Result { fn op_ffi_call_ptr( _state: &mut deno_core::OpState, args: FfiCallPtrArgs, - _: (), ) -> Result { let symbol = args.get_symbol(); ffi_call(args.into(), &symbol) @@ -662,7 +660,6 @@ fn op_ffi_call_ptr( async fn op_ffi_call_ptr_nonblocking( _state: Rc>, args: FfiCallPtrArgs, - _: (), ) -> Result { let symbol = args.get_symbol(); tokio::task::spawn_blocking(move || ffi_call(args.into(), &symbol)) @@ -682,7 +679,6 @@ struct FfiGetArgs { fn op_ffi_get_static( state: &mut deno_core::OpState, args: FfiGetArgs, - _: (), ) -> Result { let resource = state .resource_table @@ -740,7 +736,6 @@ fn op_ffi_get_static( fn op_ffi_call( state: &mut deno_core::OpState, args: FfiCallArgs, - _: (), ) -> Result { let resource = state .resource_table @@ -759,7 +754,6 @@ fn op_ffi_call( async fn op_ffi_call_nonblocking( state: Rc>, args: FfiCallArgs, - _: (), ) -> Result { let resource = state .borrow() @@ -780,7 +774,6 @@ async fn op_ffi_call_nonblocking( fn op_ffi_ptr_of( state: &mut deno_core::OpState, buf: ZeroCopyBuf, - _: (), ) -> Result where FP: FfiPermissions + 'static, @@ -795,7 +788,6 @@ where fn op_ffi_buf_copy_into( state: &mut deno_core::OpState, (src, mut dst, len): (U32x2, ZeroCopyBuf, usize), - _: (), ) -> Result<(), AnyError> where FP: FfiPermissions + 'static, @@ -818,7 +810,6 @@ where fn op_ffi_cstr_read( state: &mut deno_core::OpState, ptr: U32x2, - _: (), ) -> Result where FP: FfiPermissions + 'static, @@ -834,7 +825,6 @@ where fn op_ffi_read_u8( state: &mut deno_core::OpState, ptr: U32x2, - _: (), ) -> Result where FP: FfiPermissions + 'static, @@ -849,7 +839,6 @@ where fn op_ffi_read_i8( state: &mut deno_core::OpState, ptr: U32x2, - _: (), ) -> Result where FP: FfiPermissions + 'static, @@ -864,7 +853,6 @@ where fn op_ffi_read_u16( state: &mut deno_core::OpState, ptr: U32x2, - _: (), ) -> Result where FP: FfiPermissions + 'static, @@ -879,7 +867,6 @@ where fn op_ffi_read_i16( state: &mut deno_core::OpState, ptr: U32x2, - _: (), ) -> Result where FP: FfiPermissions + 'static, @@ -894,7 +881,6 @@ where fn op_ffi_read_u32( state: &mut deno_core::OpState, ptr: U32x2, - _: (), ) -> Result where FP: FfiPermissions + 'static, @@ -909,7 +895,6 @@ where fn op_ffi_read_i32( state: &mut deno_core::OpState, ptr: U32x2, - _: (), ) -> Result where FP: FfiPermissions + 'static, @@ -924,7 +909,6 @@ where fn op_ffi_read_u64( state: &mut deno_core::OpState, ptr: U32x2, - _: (), ) -> Result where FP: FfiPermissions + 'static, @@ -941,7 +925,6 @@ where fn op_ffi_read_f32( state: &mut deno_core::OpState, ptr: U32x2, - _: (), ) -> Result where FP: FfiPermissions + 'static, @@ -956,7 +939,6 @@ where fn op_ffi_read_f64( state: &mut deno_core::OpState, ptr: U32x2, - _: (), ) -> Result where FP: FfiPermissions + 'static, diff --git a/ext/http/lib.rs b/ext/http/lib.rs index a89c7a4a1e..f57132555a 100644 --- a/ext/http/lib.rs +++ b/ext/http/lib.rs @@ -369,7 +369,6 @@ struct NextRequestResponse( async fn op_http_accept( state: Rc>, rid: ResourceId, - _: (), ) -> Result, AnyError> { let conn = state.borrow().resource_table.get::(rid)?; @@ -738,7 +737,6 @@ async fn op_http_write( async fn op_http_shutdown( state: Rc>, rid: ResourceId, - _: (), ) -> Result<(), AnyError> { let stream = state .borrow() @@ -802,7 +800,6 @@ async fn op_http_read( fn op_http_websocket_accept_header( _: &mut OpState, key: String, - _: (), ) -> Result { let digest = ring::digest::digest( &ring::digest::SHA1_FOR_LEGACY_USE_ONLY, @@ -815,7 +812,6 @@ fn op_http_websocket_accept_header( async fn op_http_upgrade_websocket( state: Rc>, rid: ResourceId, - _: (), ) -> Result { let stream = state .borrow_mut() diff --git a/ext/net/ops.rs b/ext/net/ops.rs index 2c9129ebf5..1cd3ad8e6b 100644 --- a/ext/net/ops.rs +++ b/ext/net/ops.rs @@ -162,7 +162,6 @@ async fn accept_tcp( async fn op_net_accept( state: Rc>, args: AcceptArgs, - _: (), ) -> Result { match args.transport.as_str() { "tcp" => accept_tcp(state, args, ()).await, @@ -306,7 +305,6 @@ pub struct ConnectArgs { pub async fn op_net_connect( state: Rc>, args: ConnectArgs, - _: (), ) -> Result where NP: NetPermissions + 'static, @@ -482,7 +480,6 @@ fn listen_udp( fn op_net_listen( state: &mut OpState, args: ListenArgs, - _: (), ) -> Result where NP: NetPermissions + 'static, @@ -622,7 +619,6 @@ pub struct NameServer { pub async fn op_dns_resolve( state: Rc>, args: ResolveAddrArgs, - _: (), ) -> Result, AnyError> where NP: NetPermissions + 'static, @@ -942,7 +938,7 @@ mod tests { }; let connect_fut = - op_net_connect::call::(conn_state, connect_args, ()); + op_net_connect::call::(conn_state, connect_args); let conn = connect_fut.await.unwrap(); let rid = conn.rid; diff --git a/ext/net/ops_tls.rs b/ext/net/ops_tls.rs index 6289d963fc..fea59cc22f 100644 --- a/ext/net/ops_tls.rs +++ b/ext/net/ops_tls.rs @@ -769,7 +769,6 @@ pub struct StartTlsArgs { pub async fn op_tls_start( state: Rc>, args: StartTlsArgs, - _: (), ) -> Result where NP: NetPermissions + 'static, @@ -862,7 +861,6 @@ where pub async fn op_tls_connect( state: Rc>, args: ConnectTlsArgs, - _: (), ) -> Result where NP: NetPermissions + 'static, @@ -1022,7 +1020,6 @@ pub struct ListenTlsArgs { pub fn op_tls_listen( state: &mut OpState, args: ListenTlsArgs, - _: (), ) -> Result where NP: NetPermissions + 'static, @@ -1119,7 +1116,6 @@ where pub async fn op_tls_accept( state: Rc>, rid: ResourceId, - _: (), ) -> Result { let resource = state .borrow() @@ -1171,7 +1167,6 @@ pub async fn op_tls_accept( pub async fn op_tls_handshake( state: Rc>, rid: ResourceId, - _: (), ) -> Result { let resource = state .borrow() diff --git a/ext/url/lib.rs b/ext/url/lib.rs index a82b3e7028..4187b76648 100644 --- a/ext/url/lib.rs +++ b/ext/url/lib.rs @@ -184,7 +184,6 @@ pub fn op_url_parse_search_params( pub fn op_url_stringify_search_params( _state: &mut deno_core::OpState, args: Vec<(String, String)>, - _: (), ) -> Result { let search = form_urlencoded::Serializer::new(String::new()) .extend_pairs(args) diff --git a/ext/web/blob.rs b/ext/web/blob.rs index ad7f6c5823..43121ee3a4 100644 --- a/ext/web/blob.rs +++ b/ext/web/blob.rs @@ -163,7 +163,6 @@ impl BlobPart for SlicedBlobPart { pub fn op_blob_create_part( state: &mut deno_core::OpState, data: ZeroCopyBuf, - _: (), ) -> Result { let blob_store = state.borrow::(); let part = InMemoryBlobPart(data.to_vec()); @@ -208,7 +207,6 @@ pub fn op_blob_slice_part( pub async fn op_blob_read_part( state: Rc>, id: Uuid, - _: (), ) -> Result { let part = { let state = state.borrow(); @@ -224,7 +222,6 @@ pub async fn op_blob_read_part( pub fn op_blob_remove_part( state: &mut deno_core::OpState, id: Uuid, - _: (), ) -> Result<(), AnyError> { let blob_store = state.borrow::(); blob_store.remove_part(&id); @@ -261,7 +258,6 @@ pub fn op_blob_create_object_url( pub fn op_blob_revoke_object_url( state: &mut deno_core::OpState, url: String, - _: (), ) -> Result<(), AnyError> { let url = Url::parse(&url)?; let blob_store = state.borrow::(); @@ -285,7 +281,6 @@ pub struct ReturnBlobPart { pub fn op_blob_from_object_url( state: &mut deno_core::OpState, url: String, - _: (), ) -> Result, AnyError> { let url = Url::parse(&url)?; if url.scheme() != "blob" { diff --git a/ext/web/compression.rs b/ext/web/compression.rs index d38f65d6a8..f5ee38257f 100644 --- a/ext/web/compression.rs +++ b/ext/web/compression.rs @@ -93,7 +93,6 @@ pub fn op_compression_write( pub fn op_compression_finish( state: &mut OpState, rid: ResourceId, - _: (), ) -> Result { let resource = state.resource_table.take::(rid)?; let resource = Rc::try_unwrap(resource).unwrap(); diff --git a/ext/web/lib.rs b/ext/web/lib.rs index 6c278cbb0d..17133e156f 100644 --- a/ext/web/lib.rs +++ b/ext/web/lib.rs @@ -123,7 +123,6 @@ pub fn init( fn op_base64_decode( _: &mut OpState, input: String, - _: (), ) -> Result { let mut input = input.into_bytes(); input.retain(|c| !c.is_ascii_whitespace()); @@ -134,7 +133,6 @@ fn op_base64_decode( fn op_base64_atob( _: &mut OpState, s: ByteString, - _: (), ) -> Result { let mut s = s.0; s.retain(|c| !c.is_ascii_whitespace()); @@ -188,17 +186,12 @@ fn b64_decode(input: &[u8]) -> Result, AnyError> { fn op_base64_encode( _: &mut OpState, s: ZeroCopyBuf, - _: (), ) -> Result { Ok(b64_encode(&s)) } #[op] -fn op_base64_btoa( - _: &mut OpState, - s: ByteString, - _: (), -) -> Result { +fn op_base64_btoa(_: &mut OpState, s: ByteString) -> Result { Ok(b64_encode(&s)) } @@ -220,7 +213,6 @@ struct DecoderOptions { fn op_encoding_normalize_label( _state: &mut OpState, label: String, - _: (), ) -> Result { let encoding = Encoding::for_label_no_replacement(label.as_bytes()) .ok_or_else(|| { @@ -236,7 +228,6 @@ fn op_encoding_normalize_label( fn op_encoding_new_decoder( state: &mut OpState, options: DecoderOptions, - _: (), ) -> Result { let DecoderOptions { label, diff --git a/ext/web/message_port.rs b/ext/web/message_port.rs index 7f2b18b3cc..b193e6b9b2 100644 --- a/ext/web/message_port.rs +++ b/ext/web/message_port.rs @@ -109,8 +109,6 @@ impl Resource for MessagePortResource { #[op] pub fn op_message_port_create_entangled( state: &mut OpState, - _: (), - _: (), ) -> Result<(ResourceId, ResourceId), AnyError> { let (port1, port2) = create_entangled_message_port(); @@ -211,7 +209,6 @@ pub fn op_message_port_post_message( pub async fn op_message_port_recv_message( state: Rc>, rid: ResourceId, - _: (), ) -> Result, AnyError> { let resource = { let state = state.borrow(); diff --git a/ext/web/timers.rs b/ext/web/timers.rs index 9a78240f75..670df35826 100644 --- a/ext/web/timers.rs +++ b/ext/web/timers.rs @@ -28,11 +28,7 @@ pub type StartTime = Instant; // If the High precision flag is not set, the // nanoseconds are rounded on 2ms. #[op] -pub fn op_now( - state: &mut OpState, - _argument: (), - _: (), -) -> Result +pub fn op_now(state: &mut OpState, _argument: ()) -> Result where TP: TimersPermission + 'static, { @@ -68,11 +64,7 @@ impl Resource for TimerHandle { /// Creates a [`TimerHandle`] resource that can be used to cancel invocations of /// [`op_sleep`]. #[op] -pub fn op_timer_handle( - state: &mut OpState, - _: (), - _: (), -) -> Result { +pub fn op_timer_handle(state: &mut OpState) -> Result { let rid = state .resource_table .add(TimerHandle(CancelHandle::new_rc())); @@ -98,7 +90,6 @@ pub async fn op_sleep( pub fn op_sleep_sync( state: &mut OpState, millis: u64, - _: (), ) -> Result<(), AnyError> where TP: TimersPermission + 'static, diff --git a/ext/webgpu/src/binding.rs b/ext/webgpu/src/binding.rs index 7370f80343..cb0d9e034d 100644 --- a/ext/webgpu/src/binding.rs +++ b/ext/webgpu/src/binding.rs @@ -182,7 +182,6 @@ pub struct CreateBindGroupLayoutArgs { pub fn op_webgpu_create_bind_group_layout( state: &mut OpState, args: CreateBindGroupLayoutArgs, - _: (), ) -> Result { let instance = state.borrow::(); let device_resource = state @@ -226,7 +225,6 @@ pub struct CreatePipelineLayoutArgs { pub fn op_webgpu_create_pipeline_layout( state: &mut OpState, args: CreatePipelineLayoutArgs, - _: (), ) -> Result { let instance = state.borrow::(); let device_resource = state @@ -278,7 +276,6 @@ pub struct CreateBindGroupArgs { pub fn op_webgpu_create_bind_group( state: &mut OpState, args: CreateBindGroupArgs, - _: (), ) -> Result { let instance = state.borrow::(); let device_resource = state diff --git a/ext/webgpu/src/buffer.rs b/ext/webgpu/src/buffer.rs index ce3a78d011..24bd98efb9 100644 --- a/ext/webgpu/src/buffer.rs +++ b/ext/webgpu/src/buffer.rs @@ -46,7 +46,6 @@ pub struct CreateBufferArgs { pub fn op_webgpu_create_buffer( state: &mut OpState, args: CreateBufferArgs, - _: (), ) -> Result { let instance = state.borrow::(); let device_resource = state @@ -83,7 +82,6 @@ pub struct BufferGetMapAsyncArgs { pub async fn op_webgpu_buffer_get_map_async( state: Rc>, args: BufferGetMapAsyncArgs, - _: (), ) -> Result { let (sender, receiver) = oneshot::channel::>(); diff --git a/ext/webgpu/src/bundle.rs b/ext/webgpu/src/bundle.rs index 4a08073026..0c1f822025 100644 --- a/ext/webgpu/src/bundle.rs +++ b/ext/webgpu/src/bundle.rs @@ -44,7 +44,6 @@ pub struct CreateRenderBundleEncoderArgs { pub fn op_webgpu_create_render_bundle_encoder( state: &mut OpState, args: CreateRenderBundleEncoderArgs, - _: (), ) -> Result { let device_resource = state .resource_table @@ -105,7 +104,6 @@ pub struct RenderBundleEncoderFinishArgs { pub fn op_webgpu_render_bundle_encoder_finish( state: &mut OpState, args: RenderBundleEncoderFinishArgs, - _: (), ) -> Result { let render_bundle_encoder_resource = state @@ -142,7 +140,6 @@ pub struct RenderBundleEncoderSetBindGroupArgs { pub fn op_webgpu_render_bundle_encoder_set_bind_group( state: &mut OpState, args: RenderBundleEncoderSetBindGroupArgs, - _: (), ) -> Result { let bind_group_resource = state @@ -197,7 +194,6 @@ pub struct RenderBundleEncoderPushDebugGroupArgs { pub fn op_webgpu_render_bundle_encoder_push_debug_group( state: &mut OpState, args: RenderBundleEncoderPushDebugGroupArgs, - _: (), ) -> Result { let render_bundle_encoder_resource = state @@ -227,7 +223,6 @@ pub struct RenderBundleEncoderPopDebugGroupArgs { pub fn op_webgpu_render_bundle_encoder_pop_debug_group( state: &mut OpState, args: RenderBundleEncoderPopDebugGroupArgs, - _: (), ) -> Result { let render_bundle_encoder_resource = state @@ -252,7 +247,6 @@ pub struct RenderBundleEncoderInsertDebugMarkerArgs { pub fn op_webgpu_render_bundle_encoder_insert_debug_marker( state: &mut OpState, args: RenderBundleEncoderInsertDebugMarkerArgs, - _: (), ) -> Result { let render_bundle_encoder_resource = state @@ -283,7 +277,6 @@ pub struct RenderBundleEncoderSetPipelineArgs { pub fn op_webgpu_render_bundle_encoder_set_pipeline( state: &mut OpState, args: RenderBundleEncoderSetPipelineArgs, - _: (), ) -> Result { let render_pipeline_resource = state @@ -316,7 +309,6 @@ pub struct RenderBundleEncoderSetIndexBufferArgs { pub fn op_webgpu_render_bundle_encoder_set_index_buffer( state: &mut OpState, args: RenderBundleEncoderSetIndexBufferArgs, - _: (), ) -> Result { let buffer_resource = state .resource_table @@ -353,7 +345,6 @@ pub struct RenderBundleEncoderSetVertexBufferArgs { pub fn op_webgpu_render_bundle_encoder_set_vertex_buffer( state: &mut OpState, args: RenderBundleEncoderSetVertexBufferArgs, - _: (), ) -> Result { let buffer_resource = state .resource_table @@ -388,7 +379,6 @@ pub struct RenderBundleEncoderDrawArgs { pub fn op_webgpu_render_bundle_encoder_draw( state: &mut OpState, args: RenderBundleEncoderDrawArgs, - _: (), ) -> Result { let render_bundle_encoder_resource = state @@ -421,7 +411,6 @@ pub struct RenderBundleEncoderDrawIndexedArgs { pub fn op_webgpu_render_bundle_encoder_draw_indexed( state: &mut OpState, args: RenderBundleEncoderDrawIndexedArgs, - _: (), ) -> Result { let render_bundle_encoder_resource = state @@ -452,7 +441,6 @@ pub struct RenderBundleEncoderDrawIndirectArgs { pub fn op_webgpu_render_bundle_encoder_draw_indirect( state: &mut OpState, args: RenderBundleEncoderDrawIndirectArgs, - _: (), ) -> Result { let buffer_resource = state .resource_table diff --git a/ext/webgpu/src/command_encoder.rs b/ext/webgpu/src/command_encoder.rs index c81b2abf6d..dc777a85d4 100644 --- a/ext/webgpu/src/command_encoder.rs +++ b/ext/webgpu/src/command_encoder.rs @@ -41,7 +41,6 @@ pub struct CreateCommandEncoderArgs { pub fn op_webgpu_create_command_encoder( state: &mut OpState, args: CreateCommandEncoderArgs, - _: (), ) -> Result { let instance = state.borrow::(); let device_resource = state @@ -102,7 +101,6 @@ pub struct CommandEncoderBeginRenderPassArgs { pub fn op_webgpu_command_encoder_begin_render_pass( state: &mut OpState, args: CommandEncoderBeginRenderPassArgs, - _: (), ) -> Result { let command_encoder_resource = state .resource_table @@ -221,7 +219,6 @@ pub struct CommandEncoderBeginComputePassArgs { pub fn op_webgpu_command_encoder_begin_compute_pass( state: &mut OpState, args: CommandEncoderBeginComputePassArgs, - _: (), ) -> Result { let command_encoder_resource = state .resource_table @@ -260,7 +257,6 @@ pub struct CommandEncoderCopyBufferToBufferArgs { pub fn op_webgpu_command_encoder_copy_buffer_to_buffer( state: &mut OpState, args: CommandEncoderCopyBufferToBufferArgs, - _: (), ) -> Result { let instance = state.borrow::(); let command_encoder_resource = state @@ -319,7 +315,6 @@ pub struct CommandEncoderCopyBufferToTextureArgs { pub fn op_webgpu_command_encoder_copy_buffer_to_texture( state: &mut OpState, args: CommandEncoderCopyBufferToTextureArgs, - _: (), ) -> Result { let instance = state.borrow::(); let command_encoder_resource = state @@ -370,7 +365,6 @@ pub struct CommandEncoderCopyTextureToBufferArgs { pub fn op_webgpu_command_encoder_copy_texture_to_buffer( state: &mut OpState, args: CommandEncoderCopyTextureToBufferArgs, - _: (), ) -> Result { let instance = state.borrow::(); let command_encoder_resource = state @@ -425,7 +419,6 @@ pub struct CommandEncoderCopyTextureToTextureArgs { pub fn op_webgpu_command_encoder_copy_texture_to_texture( state: &mut OpState, args: CommandEncoderCopyTextureToTextureArgs, - _: (), ) -> Result { let instance = state.borrow::(); let command_encoder_resource = state @@ -474,7 +467,6 @@ pub struct CommandEncoderClearBufferArgs { pub fn op_webgpu_command_encoder_clear_buffer( state: &mut OpState, args: CommandEncoderClearBufferArgs, - _: (), ) -> Result { let instance = state.borrow::(); let command_encoder_resource = state @@ -504,7 +496,6 @@ pub struct CommandEncoderPushDebugGroupArgs { pub fn op_webgpu_command_encoder_push_debug_group( state: &mut OpState, args: CommandEncoderPushDebugGroupArgs, - _: (), ) -> Result { let instance = state.borrow::(); let command_encoder_resource = state @@ -526,7 +517,6 @@ pub struct CommandEncoderPopDebugGroupArgs { pub fn op_webgpu_command_encoder_pop_debug_group( state: &mut OpState, args: CommandEncoderPopDebugGroupArgs, - _: (), ) -> Result { let instance = state.borrow::(); let command_encoder_resource = state @@ -548,7 +538,6 @@ pub struct CommandEncoderInsertDebugMarkerArgs { pub fn op_webgpu_command_encoder_insert_debug_marker( state: &mut OpState, args: CommandEncoderInsertDebugMarkerArgs, - _: (), ) -> Result { let instance = state.borrow::(); let command_encoder_resource = state @@ -574,7 +563,6 @@ pub struct CommandEncoderWriteTimestampArgs { pub fn op_webgpu_command_encoder_write_timestamp( state: &mut OpState, args: CommandEncoderWriteTimestampArgs, - _: (), ) -> Result { let instance = state.borrow::(); let command_encoder_resource = state @@ -607,7 +595,6 @@ pub struct CommandEncoderResolveQuerySetArgs { pub fn op_webgpu_command_encoder_resolve_query_set( state: &mut OpState, args: CommandEncoderResolveQuerySetArgs, - _: (), ) -> Result { let instance = state.borrow::(); let command_encoder_resource = state @@ -642,7 +629,6 @@ pub struct CommandEncoderFinishArgs { pub fn op_webgpu_command_encoder_finish( state: &mut OpState, args: CommandEncoderFinishArgs, - _: (), ) -> Result { let command_encoder_resource = state .resource_table diff --git a/ext/webgpu/src/compute_pass.rs b/ext/webgpu/src/compute_pass.rs index e6ebdc098e..9f6394f7ba 100644 --- a/ext/webgpu/src/compute_pass.rs +++ b/ext/webgpu/src/compute_pass.rs @@ -31,7 +31,6 @@ pub struct ComputePassSetPipelineArgs { pub fn op_webgpu_compute_pass_set_pipeline( state: &mut OpState, args: ComputePassSetPipelineArgs, - _: (), ) -> Result { let compute_pipeline_resource = state @@ -62,7 +61,6 @@ pub struct ComputePassDispatchArgs { pub fn op_webgpu_compute_pass_dispatch( state: &mut OpState, args: ComputePassDispatchArgs, - _: (), ) -> Result { let compute_pass_resource = state .resource_table @@ -90,7 +88,6 @@ pub struct ComputePassDispatchIndirectArgs { pub fn op_webgpu_compute_pass_dispatch_indirect( state: &mut OpState, args: ComputePassDispatchIndirectArgs, - _: (), ) -> Result { let buffer_resource = state .resource_table @@ -120,7 +117,6 @@ pub struct ComputePassBeginPipelineStatisticsQueryArgs { pub fn op_webgpu_compute_pass_begin_pipeline_statistics_query( state: &mut OpState, args: ComputePassBeginPipelineStatisticsQueryArgs, - _: (), ) -> Result { let compute_pass_resource = state .resource_table @@ -148,7 +144,6 @@ pub struct ComputePassEndPipelineStatisticsQueryArgs { pub fn op_webgpu_compute_pass_end_pipeline_statistics_query( state: &mut OpState, args: ComputePassEndPipelineStatisticsQueryArgs, - _: (), ) -> Result { let compute_pass_resource = state .resource_table @@ -173,7 +168,6 @@ pub struct ComputePassWriteTimestampArgs { pub fn op_webgpu_compute_pass_write_timestamp( state: &mut OpState, args: ComputePassWriteTimestampArgs, - _: (), ) -> Result { let compute_pass_resource = state .resource_table @@ -202,7 +196,6 @@ pub struct ComputePassEndPassArgs { pub fn op_webgpu_compute_pass_end_pass( state: &mut OpState, args: ComputePassEndPassArgs, - _: (), ) -> Result { let command_encoder_resource = state .resource_table @@ -237,7 +230,6 @@ pub struct ComputePassSetBindGroupArgs { pub fn op_webgpu_compute_pass_set_bind_group( state: &mut OpState, args: ComputePassSetBindGroupArgs, - _: (), ) -> Result { let bind_group_resource = state @@ -291,7 +283,6 @@ pub struct ComputePassPushDebugGroupArgs { pub fn op_webgpu_compute_pass_push_debug_group( state: &mut OpState, args: ComputePassPushDebugGroupArgs, - _: (), ) -> Result { let compute_pass_resource = state .resource_table @@ -321,7 +312,6 @@ pub struct ComputePassPopDebugGroupArgs { pub fn op_webgpu_compute_pass_pop_debug_group( state: &mut OpState, args: ComputePassPopDebugGroupArgs, - _: (), ) -> Result { let compute_pass_resource = state .resource_table @@ -345,7 +335,6 @@ pub struct ComputePassInsertDebugMarkerArgs { pub fn op_webgpu_compute_pass_insert_debug_marker( state: &mut OpState, args: ComputePassInsertDebugMarkerArgs, - _: (), ) -> Result { let compute_pass_resource = state .resource_table diff --git a/ext/webgpu/src/lib.rs b/ext/webgpu/src/lib.rs index d1eba20ba2..329bec7551 100644 --- a/ext/webgpu/src/lib.rs +++ b/ext/webgpu/src/lib.rs @@ -245,7 +245,6 @@ pub struct GpuAdapterDevice { pub async fn op_webgpu_request_adapter( state: Rc>, args: RequestAdapterArgs, - _: (), ) -> Result { let mut state = state.borrow_mut(); check_unstable(&state, "navigator.gpu.requestAdapter"); @@ -444,7 +443,6 @@ impl From for wgpu_types::Features { pub async fn op_webgpu_request_device( state: Rc>, args: RequestDeviceArgs, - _: (), ) -> Result { let mut state = state.borrow_mut(); let adapter_resource = state @@ -545,7 +543,6 @@ impl From for wgpu_types::QueryType { pub fn op_webgpu_create_query_set( state: &mut OpState, args: CreateQuerySetArgs, - _: (), ) -> Result { let device_resource = state.resource_table.get::(args.device_rid)?; diff --git a/ext/webgpu/src/pipeline.rs b/ext/webgpu/src/pipeline.rs index 6ea2a56776..8dd0e7e0f6 100644 --- a/ext/webgpu/src/pipeline.rs +++ b/ext/webgpu/src/pipeline.rs @@ -62,7 +62,6 @@ pub struct CreateComputePipelineArgs { pub fn op_webgpu_create_compute_pipeline( state: &mut OpState, args: CreateComputePipelineArgs, - _: (), ) -> Result { let instance = state.borrow::(); let device_resource = state @@ -132,7 +131,6 @@ pub struct PipelineLayout { pub fn op_webgpu_compute_pipeline_get_bind_group_layout( state: &mut OpState, args: ComputePipelineGetBindGroupLayoutArgs, - _: (), ) -> Result { let instance = state.borrow::(); let compute_pipeline_resource = state @@ -310,7 +308,6 @@ pub struct CreateRenderPipelineArgs { pub fn op_webgpu_create_render_pipeline( state: &mut OpState, args: CreateRenderPipelineArgs, - _: (), ) -> Result { let instance = state.borrow::(); let device_resource = state @@ -412,7 +409,6 @@ pub struct RenderPipelineGetBindGroupLayoutArgs { pub fn op_webgpu_render_pipeline_get_bind_group_layout( state: &mut OpState, args: RenderPipelineGetBindGroupLayoutArgs, - _: (), ) -> Result { let instance = state.borrow::(); let render_pipeline_resource = state diff --git a/ext/webgpu/src/queue.rs b/ext/webgpu/src/queue.rs index 3853f00252..b4532cf0c6 100644 --- a/ext/webgpu/src/queue.rs +++ b/ext/webgpu/src/queue.rs @@ -24,7 +24,6 @@ pub struct QueueSubmitArgs { pub fn op_webgpu_queue_submit( state: &mut OpState, args: QueueSubmitArgs, - _: (), ) -> Result { let instance = state.borrow::(); let queue_resource = diff --git a/ext/webgpu/src/render_pass.rs b/ext/webgpu/src/render_pass.rs index 822b4c8c9c..16398359fc 100644 --- a/ext/webgpu/src/render_pass.rs +++ b/ext/webgpu/src/render_pass.rs @@ -37,7 +37,6 @@ pub struct RenderPassSetViewportArgs { pub fn op_webgpu_render_pass_set_viewport( state: &mut OpState, args: RenderPassSetViewportArgs, - _: (), ) -> Result { let render_pass_resource = state .resource_table @@ -70,7 +69,6 @@ pub struct RenderPassSetScissorRectArgs { pub fn op_webgpu_render_pass_set_scissor_rect( state: &mut OpState, args: RenderPassSetScissorRectArgs, - _: (), ) -> Result { let render_pass_resource = state .resource_table @@ -98,7 +96,6 @@ pub struct RenderPassSetBlendConstantArgs { pub fn op_webgpu_render_pass_set_blend_constant( state: &mut OpState, args: RenderPassSetBlendConstantArgs, - _: (), ) -> Result { let render_pass_resource = state .resource_table @@ -123,7 +120,6 @@ pub struct RenderPassSetStencilReferenceArgs { pub fn op_webgpu_render_pass_set_stencil_reference( state: &mut OpState, args: RenderPassSetStencilReferenceArgs, - _: (), ) -> Result { let render_pass_resource = state .resource_table @@ -149,7 +145,6 @@ pub struct RenderPassBeginPipelineStatisticsQueryArgs { pub fn op_webgpu_render_pass_begin_pipeline_statistics_query( state: &mut OpState, args: RenderPassBeginPipelineStatisticsQueryArgs, - _: (), ) -> Result { let render_pass_resource = state .resource_table @@ -177,7 +172,6 @@ pub struct RenderPassEndPipelineStatisticsQueryArgs { pub fn op_webgpu_render_pass_end_pipeline_statistics_query( state: &mut OpState, args: RenderPassEndPipelineStatisticsQueryArgs, - _: (), ) -> Result { let render_pass_resource = state .resource_table @@ -202,7 +196,6 @@ pub struct RenderPassWriteTimestampArgs { pub fn op_webgpu_render_pass_write_timestamp( state: &mut OpState, args: RenderPassWriteTimestampArgs, - _: (), ) -> Result { let render_pass_resource = state .resource_table @@ -231,7 +224,6 @@ pub struct RenderPassExecuteBundlesArgs { pub fn op_webgpu_render_pass_execute_bundles( state: &mut OpState, args: RenderPassExecuteBundlesArgs, - _: (), ) -> Result { let mut render_bundle_ids = vec![]; @@ -271,7 +263,6 @@ pub struct RenderPassEndPassArgs { pub fn op_webgpu_render_pass_end_pass( state: &mut OpState, args: RenderPassEndPassArgs, - _: (), ) -> Result { let command_encoder_resource = state .resource_table @@ -303,7 +294,6 @@ pub struct RenderPassSetBindGroupArgs { pub fn op_webgpu_render_pass_set_bind_group( state: &mut OpState, args: RenderPassSetBindGroupArgs, - _: (), ) -> Result { let bind_group_resource = state @@ -357,7 +347,6 @@ pub struct RenderPassPushDebugGroupArgs { pub fn op_webgpu_render_pass_push_debug_group( state: &mut OpState, args: RenderPassPushDebugGroupArgs, - _: (), ) -> Result { let render_pass_resource = state .resource_table @@ -387,7 +376,6 @@ pub struct RenderPassPopDebugGroupArgs { pub fn op_webgpu_render_pass_pop_debug_group( state: &mut OpState, args: RenderPassPopDebugGroupArgs, - _: (), ) -> Result { let render_pass_resource = state .resource_table @@ -411,7 +399,6 @@ pub struct RenderPassInsertDebugMarkerArgs { pub fn op_webgpu_render_pass_insert_debug_marker( state: &mut OpState, args: RenderPassInsertDebugMarkerArgs, - _: (), ) -> Result { let render_pass_resource = state .resource_table @@ -442,7 +429,6 @@ pub struct RenderPassSetPipelineArgs { pub fn op_webgpu_render_pass_set_pipeline( state: &mut OpState, args: RenderPassSetPipelineArgs, - _: (), ) -> Result { let render_pipeline_resource = state @@ -474,7 +460,6 @@ pub struct RenderPassSetIndexBufferArgs { pub fn op_webgpu_render_pass_set_index_buffer( state: &mut OpState, args: RenderPassSetIndexBufferArgs, - _: (), ) -> Result { let buffer_resource = state .resource_table @@ -516,7 +501,6 @@ pub struct RenderPassSetVertexBufferArgs { pub fn op_webgpu_render_pass_set_vertex_buffer( state: &mut OpState, args: RenderPassSetVertexBufferArgs, - _: (), ) -> Result { let buffer_resource = state .resource_table @@ -559,7 +543,6 @@ pub struct RenderPassDrawArgs { pub fn op_webgpu_render_pass_draw( state: &mut OpState, args: RenderPassDrawArgs, - _: (), ) -> Result { let render_pass_resource = state .resource_table @@ -591,7 +574,6 @@ pub struct RenderPassDrawIndexedArgs { pub fn op_webgpu_render_pass_draw_indexed( state: &mut OpState, args: RenderPassDrawIndexedArgs, - _: (), ) -> Result { let render_pass_resource = state .resource_table @@ -621,7 +603,6 @@ pub struct RenderPassDrawIndirectArgs { pub fn op_webgpu_render_pass_draw_indirect( state: &mut OpState, args: RenderPassDrawIndirectArgs, - _: (), ) -> Result { let buffer_resource = state .resource_table @@ -651,7 +632,6 @@ pub struct RenderPassDrawIndexedIndirectArgs { pub fn op_webgpu_render_pass_draw_indexed_indirect( state: &mut OpState, args: RenderPassDrawIndexedIndirectArgs, - _: (), ) -> Result { let buffer_resource = state .resource_table diff --git a/ext/webgpu/src/sampler.rs b/ext/webgpu/src/sampler.rs index 3c0c43f532..c6827f4cb6 100644 --- a/ext/webgpu/src/sampler.rs +++ b/ext/webgpu/src/sampler.rs @@ -37,7 +37,6 @@ pub struct CreateSamplerArgs { pub fn op_webgpu_create_sampler( state: &mut OpState, args: CreateSamplerArgs, - _: (), ) -> Result { let instance = state.borrow::(); let device_resource = state diff --git a/ext/webgpu/src/shader.rs b/ext/webgpu/src/shader.rs index 0173fffa2b..a5e4e5d431 100644 --- a/ext/webgpu/src/shader.rs +++ b/ext/webgpu/src/shader.rs @@ -29,7 +29,6 @@ pub struct CreateShaderModuleArgs { pub fn op_webgpu_create_shader_module( state: &mut OpState, args: CreateShaderModuleArgs, - _: (), ) -> Result { let instance = state.borrow::(); let device_resource = state diff --git a/ext/webgpu/src/texture.rs b/ext/webgpu/src/texture.rs index 482437478a..0d11544090 100644 --- a/ext/webgpu/src/texture.rs +++ b/ext/webgpu/src/texture.rs @@ -39,7 +39,6 @@ pub struct CreateTextureArgs { pub fn op_webgpu_create_texture( state: &mut OpState, args: CreateTextureArgs, - _: (), ) -> Result { let instance = state.borrow::(); let device_resource = state @@ -82,7 +81,6 @@ pub struct CreateTextureViewArgs { pub fn op_webgpu_create_texture_view( state: &mut OpState, args: CreateTextureViewArgs, - _: (), ) -> Result { let instance = state.borrow::(); let texture_resource = state diff --git a/ext/websocket/lib.rs b/ext/websocket/lib.rs index d712140b54..0b94702748 100644 --- a/ext/websocket/lib.rs +++ b/ext/websocket/lib.rs @@ -234,7 +234,6 @@ pub struct CreateResponse { pub async fn op_ws_create( state: Rc>, args: CreateArgs, - _: (), ) -> Result where WP: WebSocketPermissions + 'static, @@ -413,7 +412,6 @@ pub struct CloseArgs { pub async fn op_ws_close( state: Rc>, args: CloseArgs, - _: (), ) -> Result<(), AnyError> { let rid = args.rid; let msg = Message::Close(args.code.map(|c| CloseFrame { @@ -448,7 +446,6 @@ pub enum NextEventResponse { pub async fn op_ws_next_event( state: Rc>, rid: ResourceId, - _: (), ) -> Result { let resource = state .borrow_mut() diff --git a/ext/webstorage/lib.rs b/ext/webstorage/lib.rs index c51301683c..8569fece66 100644 --- a/ext/webstorage/lib.rs +++ b/ext/webstorage/lib.rs @@ -104,7 +104,6 @@ fn get_webstorage( pub fn op_webstorage_length( state: &mut OpState, persistent: bool, - _: (), ) -> Result { let conn = get_webstorage(state, persistent)?; @@ -201,7 +200,6 @@ pub fn op_webstorage_remove( pub fn op_webstorage_clear( state: &mut OpState, persistent: bool, - _: (), ) -> Result<(), AnyError> { let conn = get_webstorage(state, persistent)?; @@ -215,7 +213,6 @@ pub fn op_webstorage_clear( pub fn op_webstorage_iterate_keys( state: &mut OpState, persistent: bool, - _: (), ) -> Result, AnyError> { let conn = get_webstorage(state, persistent)?; diff --git a/ops/lib.rs b/ops/lib.rs index d159c6c4b2..126da368a3 100644 --- a/ops/lib.rs +++ b/ops/lib.rs @@ -91,8 +91,7 @@ pub fn op(_attr: TokenStream, item: TokenStream) -> TokenStream { /// Generate the body of a v8 func for an async op fn codegen_v8_async(core: &TokenStream2, f: &syn::ItemFn) -> TokenStream2 { - let a = codegen_arg(core, &f.sig.inputs[1], "a", 2); - let b = codegen_arg(core, &f.sig.inputs[2], "b", 3); + let (arg_decls, args_tail) = codegen_args(core, f, 1, 2); let type_params = &f.sig.generics.params; quote! { @@ -115,8 +114,7 @@ fn codegen_v8_async(core: &TokenStream2, f: &syn::ItemFn) -> TokenStream2 { } }; - #a - #b + #arg_decls // SAFETY: Unchecked cast to external since #core guarantees args.data() is a v8 External. let state_refcell_raw = unsafe { @@ -138,7 +136,7 @@ fn codegen_v8_async(core: &TokenStream2, f: &syn::ItemFn) -> TokenStream2 { }; #core::_ops::queue_async_op(scope, async move { - let result = Self::call::<#type_params>(state, a, b).await; + let result = Self::call::<#type_params>(state, #args_tail).await; (promise_id, op_id, #core::_ops::to_op_result(get_class, result)) }); } @@ -146,8 +144,7 @@ fn codegen_v8_async(core: &TokenStream2, f: &syn::ItemFn) -> TokenStream2 { /// Generate the body of a v8 func for a sync op fn codegen_v8_sync(core: &TokenStream2, f: &syn::ItemFn) -> TokenStream2 { - let a = codegen_arg(core, &f.sig.inputs[1], "a", 1); - let b = codegen_arg(core, &f.sig.inputs[2], "b", 2); + let (arg_decls, args_tail) = codegen_args(core, f, 1, 1); let ret = codegen_sync_ret(core, &f.sig.output); let type_params = &f.sig.generics.params; @@ -157,8 +154,7 @@ fn codegen_v8_sync(core: &TokenStream2, f: &syn::ItemFn) -> TokenStream2 { #core::v8::Local::<#core::v8::Integer>::cast(args.get(0)).value() } as usize; - #a - #b + #arg_decls // SAFETY: Unchecked cast to external since #core guarantees args.data() is a v8 External. let state_refcell_raw = unsafe { @@ -169,7 +165,7 @@ fn codegen_v8_sync(core: &TokenStream2, f: &syn::ItemFn) -> TokenStream2 { let state = unsafe { &*(state_refcell_raw as *const std::cell::RefCell<#core::OpState>) }; let op_state = &mut state.borrow_mut(); - let result = Self::call::<#type_params>(op_state, a, b); + let result = Self::call::<#type_params>(op_state, #args_tail); op_state.tracker.track_sync(op_id); @@ -177,11 +173,34 @@ fn codegen_v8_sync(core: &TokenStream2, f: &syn::ItemFn) -> TokenStream2 { } } +fn codegen_args( + core: &TokenStream2, + f: &syn::ItemFn, + rust_i0: usize, // Index of first generic arg in rust + v8_i0: usize, // Index of first generic arg in v8/js +) -> (TokenStream2, TokenStream2) { + let inputs = &f.sig.inputs.iter().skip(rust_i0).enumerate(); + let ident_seq: TokenStream2 = inputs + .clone() + .map(|(i, _)| format!("arg_{i}")) + .collect::>() + .join(", ") + .parse() + .unwrap(); + let decls: TokenStream2 = inputs + .clone() + .map(|(i, arg)| { + codegen_arg(core, arg, format!("arg_{i}").as_ref(), v8_i0 + i) + }) + .collect(); + (decls, ident_seq) +} + fn codegen_arg( core: &TokenStream2, arg: &syn::FnArg, name: &str, - idx: i32, + idx: usize, ) -> TokenStream2 { let ident = quote::format_ident!("{name}"); let pat = match arg { @@ -194,7 +213,7 @@ fn codegen_arg( } // Otherwise deserialize it via serde_v8 quote! { - let #ident = args.get(#idx); + let #ident = args.get(#idx as i32); let #ident = match #core::serde_v8::from_v8(scope, #ident) { Ok(v) => v, Err(err) => { diff --git a/runtime/ops/fs.rs b/runtime/ops/fs.rs index f7f0ad33cc..a3d316ae7c 100644 --- a/runtime/ops/fs.rs +++ b/runtime/ops/fs.rs @@ -161,7 +161,6 @@ fn open_helper( fn op_open_sync( state: &mut OpState, args: OpenArgs, - _: (), ) -> Result { let (path, open_options) = open_helper(state, args)?; let std_file = open_options.open(&path).map_err(|err| { @@ -177,7 +176,6 @@ fn op_open_sync( async fn op_open_async( state: Rc>, args: OpenArgs, - _: (), ) -> Result { let (path, open_options) = open_helper(&mut state.borrow_mut(), args)?; let tokio_file = tokio::fs::OpenOptions::from(open_options) @@ -217,11 +215,7 @@ fn seek_helper(args: SeekArgs) -> Result<(u32, SeekFrom), AnyError> { } #[op] -fn op_seek_sync( - state: &mut OpState, - args: SeekArgs, - _: (), -) -> Result { +fn op_seek_sync(state: &mut OpState, args: SeekArgs) -> Result { let (rid, seek_from) = seek_helper(args)?; let pos = StdFileResource::with(state, rid, |r| match r { Ok(std_file) => std_file.seek(seek_from).map_err(AnyError::from), @@ -236,7 +230,6 @@ fn op_seek_sync( async fn op_seek_async( state: Rc>, args: SeekArgs, - _: (), ) -> Result { let (rid, seek_from) = seek_helper(args)?; @@ -261,7 +254,6 @@ async fn op_seek_async( fn op_fdatasync_sync( state: &mut OpState, rid: ResourceId, - _: (), ) -> Result<(), AnyError> { StdFileResource::with(state, rid, |r| match r { Ok(std_file) => std_file.sync_data().map_err(AnyError::from), @@ -274,7 +266,6 @@ fn op_fdatasync_sync( async fn op_fdatasync_async( state: Rc>, rid: ResourceId, - _: (), ) -> Result<(), AnyError> { let resource = state .borrow_mut() @@ -294,11 +285,7 @@ async fn op_fdatasync_async( } #[op] -fn op_fsync_sync( - state: &mut OpState, - rid: ResourceId, - _: (), -) -> Result<(), AnyError> { +fn op_fsync_sync(state: &mut OpState, rid: ResourceId) -> Result<(), AnyError> { StdFileResource::with(state, rid, |r| match r { Ok(std_file) => std_file.sync_all().map_err(AnyError::from), Err(_) => Err(type_error("cannot sync this type of resource".to_string())), @@ -310,7 +297,6 @@ fn op_fsync_sync( async fn op_fsync_async( state: Rc>, rid: ResourceId, - _: (), ) -> Result<(), AnyError> { let resource = state .borrow_mut() @@ -333,7 +319,6 @@ async fn op_fsync_async( fn op_fstat_sync( state: &mut OpState, rid: ResourceId, - _: (), ) -> Result { let metadata = StdFileResource::with(state, rid, |r| match r { Ok(std_file) => std_file.metadata().map_err(AnyError::from), @@ -346,7 +331,6 @@ fn op_fstat_sync( async fn op_fstat_async( state: Rc>, rid: ResourceId, - _: (), ) -> Result { let resource = state .borrow_mut() @@ -432,7 +416,6 @@ async fn op_flock_async( fn op_funlock_sync( state: &mut OpState, rid: ResourceId, - _: (), ) -> Result<(), AnyError> { use fs3::FileExt; super::check_unstable(state, "Deno.funlockSync"); @@ -450,7 +433,6 @@ fn op_funlock_sync( async fn op_funlock_async( state: Rc>, rid: ResourceId, - _: (), ) -> Result<(), AnyError> { use fs3::FileExt; super::check_unstable2(&state, "Deno.funlock"); @@ -484,11 +466,7 @@ async fn op_funlock_async( } #[op] -fn op_umask( - state: &mut OpState, - mask: Option, - _: (), -) -> Result { +fn op_umask(state: &mut OpState, mask: Option) -> Result { super::check_unstable(state, "Deno.umask"); // TODO implement umask for Windows // see https://github.com/nodejs/node/blob/master/src/node_process_methods.cc @@ -517,11 +495,7 @@ fn op_umask( } #[op] -fn op_chdir( - state: &mut OpState, - directory: String, - _: (), -) -> Result<(), AnyError> { +fn op_chdir(state: &mut OpState, directory: String) -> Result<(), AnyError> { let d = PathBuf::from(&directory); state.borrow_mut::().read.check(&d)?; set_current_dir(&d).map_err(|err| { @@ -539,11 +513,7 @@ pub struct MkdirArgs { } #[op] -fn op_mkdir_sync( - state: &mut OpState, - args: MkdirArgs, - _: (), -) -> Result<(), AnyError> { +fn op_mkdir_sync(state: &mut OpState, args: MkdirArgs) -> Result<(), AnyError> { let path = Path::new(&args.path).to_path_buf(); let mode = args.mode.unwrap_or(0o777) & 0o777; state.borrow_mut::().write.check(&path)?; @@ -565,7 +535,6 @@ fn op_mkdir_sync( async fn op_mkdir_async( state: Rc>, args: MkdirArgs, - _: (), ) -> Result<(), AnyError> { let path = Path::new(&args.path).to_path_buf(); let mode = args.mode.unwrap_or(0o777) & 0o777; @@ -601,11 +570,7 @@ pub struct ChmodArgs { } #[op] -fn op_chmod_sync( - state: &mut OpState, - args: ChmodArgs, - _: (), -) -> Result<(), AnyError> { +fn op_chmod_sync(state: &mut OpState, args: ChmodArgs) -> Result<(), AnyError> { let path = Path::new(&args.path).to_path_buf(); let mode = args.mode & 0o777; let err_mapper = |err: Error| { @@ -634,7 +599,6 @@ fn op_chmod_sync( async fn op_chmod_async( state: Rc>, args: ChmodArgs, - _: (), ) -> Result<(), AnyError> { let path = Path::new(&args.path).to_path_buf(); let mode = args.mode & 0o777; @@ -677,11 +641,7 @@ pub struct ChownArgs { } #[op] -fn op_chown_sync( - state: &mut OpState, - args: ChownArgs, - _: (), -) -> Result<(), AnyError> { +fn op_chown_sync(state: &mut OpState, args: ChownArgs) -> Result<(), AnyError> { let path = Path::new(&args.path).to_path_buf(); state.borrow_mut::().write.check(&path)?; debug!( @@ -715,7 +675,6 @@ fn op_chown_sync( async fn op_chown_async( state: Rc>, args: ChownArgs, - _: (), ) -> Result<(), AnyError> { let path = Path::new(&args.path).to_path_buf(); @@ -764,7 +723,6 @@ pub struct RemoveArgs { fn op_remove_sync( state: &mut OpState, args: RemoveArgs, - _: (), ) -> Result<(), AnyError> { let path = PathBuf::from(&args.path); let recursive = args.recursive; @@ -810,7 +768,6 @@ fn op_remove_sync( async fn op_remove_async( state: Rc>, args: RemoveArgs, - _: (), ) -> Result<(), AnyError> { let path = PathBuf::from(&args.path); let recursive = args.recursive; @@ -869,7 +826,6 @@ pub struct CopyFileArgs { fn op_copy_file_sync( state: &mut OpState, args: CopyFileArgs, - _: (), ) -> Result<(), AnyError> { let from = PathBuf::from(&args.from); let to = PathBuf::from(&args.to); @@ -908,7 +864,6 @@ fn op_copy_file_sync( async fn op_copy_file_async( state: Rc>, args: CopyFileArgs, - _: (), ) -> Result<(), AnyError> { let from = PathBuf::from(&args.from); let to = PathBuf::from(&args.to); @@ -1037,7 +992,6 @@ pub struct StatArgs { fn op_stat_sync( state: &mut OpState, args: StatArgs, - _: (), ) -> Result { let path = PathBuf::from(&args.path); let lstat = args.lstat; @@ -1058,7 +1012,6 @@ fn op_stat_sync( async fn op_stat_async( state: Rc>, args: StatArgs, - _: (), ) -> Result { let path = PathBuf::from(&args.path); let lstat = args.lstat; @@ -1088,7 +1041,6 @@ async fn op_stat_async( fn op_realpath_sync( state: &mut OpState, path: String, - _: (), ) -> Result { let path = PathBuf::from(&path); @@ -1110,7 +1062,6 @@ fn op_realpath_sync( async fn op_realpath_async( state: Rc>, path: String, - _: (), ) -> Result { let path = PathBuf::from(&path); @@ -1148,7 +1099,6 @@ pub struct DirEntry { fn op_read_dir_sync( state: &mut OpState, path: String, - _: (), ) -> Result, AnyError> { let path = PathBuf::from(&path); @@ -1189,7 +1139,6 @@ fn op_read_dir_sync( async fn op_read_dir_async( state: Rc>, path: String, - _: (), ) -> Result, AnyError> { let path = PathBuf::from(&path); { @@ -1242,7 +1191,6 @@ pub struct RenameArgs { fn op_rename_sync( state: &mut OpState, args: RenameArgs, - _: (), ) -> Result<(), AnyError> { let oldpath = PathBuf::from(&args.oldpath); let newpath = PathBuf::from(&args.newpath); @@ -1271,7 +1219,6 @@ fn op_rename_sync( async fn op_rename_async( state: Rc>, args: RenameArgs, - _: (), ) -> Result<(), AnyError> { let oldpath = PathBuf::from(&args.oldpath); let newpath = PathBuf::from(&args.newpath); @@ -1314,11 +1261,7 @@ pub struct LinkArgs { } #[op] -fn op_link_sync( - state: &mut OpState, - args: LinkArgs, - _: (), -) -> Result<(), AnyError> { +fn op_link_sync(state: &mut OpState, args: LinkArgs) -> Result<(), AnyError> { let oldpath = PathBuf::from(&args.oldpath); let newpath = PathBuf::from(&args.newpath); @@ -1348,7 +1291,6 @@ fn op_link_sync( async fn op_link_async( state: Rc>, args: LinkArgs, - _: (), ) -> Result<(), AnyError> { let oldpath = PathBuf::from(&args.oldpath); let newpath = PathBuf::from(&args.newpath); @@ -1402,7 +1344,6 @@ pub struct SymlinkOptions { fn op_symlink_sync( state: &mut OpState, args: SymlinkArgs, - _: (), ) -> Result<(), AnyError> { let oldpath = PathBuf::from(&args.oldpath); let newpath = PathBuf::from(&args.newpath); @@ -1464,7 +1405,6 @@ fn op_symlink_sync( async fn op_symlink_async( state: Rc>, args: SymlinkArgs, - _: (), ) -> Result<(), AnyError> { let oldpath = PathBuf::from(&args.oldpath); let newpath = PathBuf::from(&args.newpath); @@ -1529,7 +1469,6 @@ async fn op_symlink_async( fn op_read_link_sync( state: &mut OpState, path: String, - _: (), ) -> Result { let path = PathBuf::from(&path); @@ -1553,7 +1492,6 @@ fn op_read_link_sync( async fn op_read_link_async( state: Rc>, path: String, - _: (), ) -> Result { let path = PathBuf::from(&path); { @@ -1589,7 +1527,6 @@ pub struct FtruncateArgs { fn op_ftruncate_sync( state: &mut OpState, args: FtruncateArgs, - _: (), ) -> Result<(), AnyError> { let rid = args.rid; let len = args.len as u64; @@ -1604,7 +1541,6 @@ fn op_ftruncate_sync( async fn op_ftruncate_async( state: Rc>, args: FtruncateArgs, - _: (), ) -> Result<(), AnyError> { let rid = args.rid; let len = args.len as u64; @@ -1637,7 +1573,6 @@ pub struct TruncateArgs { fn op_truncate_sync( state: &mut OpState, args: TruncateArgs, - _: (), ) -> Result<(), AnyError> { let path = PathBuf::from(&args.path); let len = args.len; @@ -1663,7 +1598,6 @@ fn op_truncate_sync( async fn op_truncate_async( state: Rc>, args: TruncateArgs, - _: (), ) -> Result<(), AnyError> { let path = PathBuf::from(&args.path); let len = args.len; @@ -1747,7 +1681,6 @@ pub struct MakeTempArgs { fn op_make_temp_dir_sync( state: &mut OpState, args: MakeTempArgs, - _: (), ) -> Result { let dir = args.dir.map(|s| PathBuf::from(&s)); let prefix = args.prefix.map(String::from); @@ -1777,7 +1710,6 @@ fn op_make_temp_dir_sync( async fn op_make_temp_dir_async( state: Rc>, args: MakeTempArgs, - _: (), ) -> Result { let dir = args.dir.map(|s| PathBuf::from(&s)); let prefix = args.prefix.map(String::from); @@ -1812,7 +1744,6 @@ async fn op_make_temp_dir_async( fn op_make_temp_file_sync( state: &mut OpState, args: MakeTempArgs, - _: (), ) -> Result { let dir = args.dir.map(|s| PathBuf::from(&s)); let prefix = args.prefix.map(String::from); @@ -1842,7 +1773,6 @@ fn op_make_temp_file_sync( async fn op_make_temp_file_async( state: Rc>, args: MakeTempArgs, - _: (), ) -> Result { let dir = args.dir.map(|s| PathBuf::from(&s)); let prefix = args.prefix.map(String::from); @@ -1885,7 +1815,6 @@ pub struct FutimeArgs { fn op_futime_sync( state: &mut OpState, args: FutimeArgs, - _: (), ) -> Result<(), AnyError> { super::check_unstable(state, "Deno.futimeSync"); let rid = args.rid; @@ -1909,7 +1838,6 @@ fn op_futime_sync( async fn op_futime_async( state: Rc>, args: FutimeArgs, - _: (), ) -> Result<(), AnyError> { super::check_unstable2(&state, "Deno.futime"); let rid = args.rid; @@ -1955,11 +1883,7 @@ pub struct UtimeArgs { } #[op] -fn op_utime_sync( - state: &mut OpState, - args: UtimeArgs, - _: (), -) -> Result<(), AnyError> { +fn op_utime_sync(state: &mut OpState, args: UtimeArgs) -> Result<(), AnyError> { super::check_unstable(state, "Deno.utime"); let path = PathBuf::from(&args.path); @@ -1977,7 +1901,6 @@ fn op_utime_sync( async fn op_utime_async( state: Rc>, args: UtimeArgs, - _: (), ) -> Result<(), AnyError> { super::check_unstable(&state.borrow(), "Deno.utime"); @@ -2002,7 +1925,7 @@ async fn op_utime_async( } #[op] -fn op_cwd(state: &mut OpState, _: (), _: ()) -> Result { +fn op_cwd(state: &mut OpState) -> Result { let path = current_dir()?; state .borrow_mut::() diff --git a/runtime/ops/fs_events.rs b/runtime/ops/fs_events.rs index 8909b2636f..02acbd0cc4 100644 --- a/runtime/ops/fs_events.rs +++ b/runtime/ops/fs_events.rs @@ -98,7 +98,6 @@ pub struct OpenArgs { fn op_fs_events_open( state: &mut OpState, args: OpenArgs, - _: (), ) -> Result { let (sender, receiver) = mpsc::channel::>(16); let sender = Mutex::new(sender); @@ -133,7 +132,6 @@ fn op_fs_events_open( async fn op_fs_events_poll( state: Rc>, rid: ResourceId, - _: (), ) -> Result, AnyError> { let resource = state.borrow().resource_table.get::(rid)?; let mut receiver = RcRef::map(&resource, |r| &r.receiver).borrow_mut().await; diff --git a/runtime/ops/http.rs b/runtime/ops/http.rs index 25f123b323..47ec317514 100644 --- a/runtime/ops/http.rs +++ b/runtime/ops/http.rs @@ -20,7 +20,6 @@ pub fn init() -> Extension { fn op_http_start( state: &mut OpState, tcp_stream_rid: ResourceId, - _: (), ) -> Result { if let Ok(resource_rc) = state .resource_table diff --git a/runtime/ops/os.rs b/runtime/ops/os.rs index d9abbb2212..ad2ff60ea3 100644 --- a/runtime/ops/os.rs +++ b/runtime/ops/os.rs @@ -40,7 +40,7 @@ pub fn init(maybe_exit_code: Option>) -> Extension { } #[op] -fn op_exec_path(state: &mut OpState, _: (), _: ()) -> Result { +fn op_exec_path(state: &mut OpState) -> Result { let current_exe = env::current_exe().unwrap(); state .borrow_mut::() @@ -71,11 +71,7 @@ fn op_set_env( } #[op] -fn op_env( - state: &mut OpState, - _: (), - _: (), -) -> Result, AnyError> { +fn op_env(state: &mut OpState) -> Result, AnyError> { state.borrow_mut::().env.check_all()?; Ok(env::vars().collect()) } @@ -84,7 +80,6 @@ fn op_env( fn op_get_env( state: &mut OpState, key: String, - _: (), ) -> Result, AnyError> { state.borrow_mut::().env.check(&key)?; if key.is_empty() || key.contains(&['=', '\0'] as &[char]) { @@ -98,11 +93,7 @@ fn op_get_env( } #[op] -fn op_delete_env( - state: &mut OpState, - key: String, - _: (), -) -> Result<(), AnyError> { +fn op_delete_env(state: &mut OpState, key: String) -> Result<(), AnyError> { state.borrow_mut::().env.check(&key)?; if key.is_empty() || key.contains(&['=', '\0'] as &[char]) { return Err(type_error("Key contains invalid characters.")); @@ -112,27 +103,19 @@ fn op_delete_env( } #[op] -fn op_set_exit_code( - state: &mut OpState, - code: i32, - _: (), -) -> Result<(), AnyError> { +fn op_set_exit_code(state: &mut OpState, code: i32) -> Result<(), AnyError> { state.borrow_mut::>().store(code, Relaxed); Ok(()) } #[op] -fn op_exit(state: &mut OpState, _: (), _: ()) -> Result<(), AnyError> { +fn op_exit(state: &mut OpState) -> Result<(), AnyError> { let code = state.borrow::>().load(Relaxed); std::process::exit(code) } #[op] -fn op_loadavg( - state: &mut OpState, - _: (), - _: (), -) -> Result<(f64, f64, f64), AnyError> { +fn op_loadavg(state: &mut OpState) -> Result<(f64, f64, f64), AnyError> { super::check_unstable(state, "Deno.loadavg"); state.borrow_mut::().env.check_all()?; match sys_info::loadavg() { @@ -142,7 +125,7 @@ fn op_loadavg( } #[op] -fn op_hostname(state: &mut OpState, _: (), _: ()) -> Result { +fn op_hostname(state: &mut OpState) -> Result { super::check_unstable(state, "Deno.hostname"); state.borrow_mut::().env.check_all()?; let hostname = sys_info::hostname().unwrap_or_else(|_| "".to_string()); @@ -150,11 +133,7 @@ fn op_hostname(state: &mut OpState, _: (), _: ()) -> Result { } #[op] -fn op_os_release( - state: &mut OpState, - _: (), - _: (), -) -> Result { +fn op_os_release(state: &mut OpState) -> Result { super::check_unstable(state, "Deno.osRelease"); state.borrow_mut::().env.check_all()?; let release = sys_info::os_release().unwrap_or_else(|_| "".to_string()); @@ -164,8 +143,6 @@ fn op_os_release( #[op] fn op_network_interfaces( state: &mut OpState, - _: (), - _: (), ) -> Result, AnyError> { super::check_unstable(state, "Deno.networkInterfaces"); state.borrow_mut::().env.check_all()?; @@ -232,8 +209,6 @@ struct MemInfo { #[op] fn op_system_memory_info( state: &mut OpState, - _: (), - _: (), ) -> Result, AnyError> { super::check_unstable(state, "Deno.systemMemoryInfo"); state.borrow_mut::().env.check_all()?; @@ -253,11 +228,7 @@ fn op_system_memory_info( #[cfg(not(windows))] #[op] -fn op_getuid( - state: &mut OpState, - _: (), - _: (), -) -> Result, AnyError> { +fn op_getuid(state: &mut OpState) -> Result, AnyError> { super::check_unstable(state, "Deno.getUid"); state.borrow_mut::().env.check_all()?; unsafe { Ok(Some(libc::getuid())) } @@ -265,11 +236,7 @@ fn op_getuid( #[cfg(windows)] #[op] -fn op_getuid( - state: &mut OpState, - _: (), - _: (), -) -> Result, AnyError> { +fn op_getuid(state: &mut OpState) -> Result, AnyError> { super::check_unstable(state, "Deno.getUid"); state.borrow_mut::().env.check_all()?; Ok(None) diff --git a/runtime/ops/permissions.rs b/runtime/ops/permissions.rs index 4015624390..ed17977012 100644 --- a/runtime/ops/permissions.rs +++ b/runtime/ops/permissions.rs @@ -34,7 +34,6 @@ pub struct PermissionArgs { pub fn op_query_permission( state: &mut OpState, args: PermissionArgs, - _: (), ) -> Result { let permissions = state.borrow::(); let path = args.path.as_deref(); @@ -66,7 +65,6 @@ pub fn op_query_permission( pub fn op_revoke_permission( state: &mut OpState, args: PermissionArgs, - _: (), ) -> Result { let permissions = state.borrow_mut::(); let path = args.path.as_deref(); @@ -98,7 +96,6 @@ pub fn op_revoke_permission( pub fn op_request_permission( state: &mut OpState, args: PermissionArgs, - _: (), ) -> Result { let permissions = state.borrow_mut::(); let path = args.path.as_deref(); diff --git a/runtime/ops/process.rs b/runtime/ops/process.rs index 7c45c47fc1..3bc516a807 100644 --- a/runtime/ops/process.rs +++ b/runtime/ops/process.rs @@ -99,11 +99,7 @@ struct RunInfo { } #[op] -fn op_run( - state: &mut OpState, - run_args: RunArgs, - _: (), -) -> Result { +fn op_run(state: &mut OpState, run_args: RunArgs) -> Result { let args = run_args.cmd; state.borrow_mut::().run.check(&args[0])?; let env = run_args.env; @@ -227,7 +223,6 @@ struct ProcessStatus { async fn op_run_status( state: Rc>, rid: ResourceId, - _: (), ) -> Result { let resource = state .borrow_mut() diff --git a/runtime/ops/runtime.rs b/runtime/ops/runtime.rs index 4f951383eb..31f9d27320 100644 --- a/runtime/ops/runtime.rs +++ b/runtime/ops/runtime.rs @@ -19,11 +19,7 @@ pub fn init(main_module: ModuleSpecifier) -> Extension { } #[op] -fn op_main_module( - state: &mut OpState, - _: (), - _: (), -) -> Result { +fn op_main_module(state: &mut OpState) -> Result { let main = state.borrow::().to_string(); let main_url = deno_core::resolve_url_or_path(&main)?; if main_url.scheme() == "file" { diff --git a/runtime/ops/signal.rs b/runtime/ops/signal.rs index d9f05a7775..efab5a932e 100644 --- a/runtime/ops/signal.rs +++ b/runtime/ops/signal.rs @@ -178,7 +178,6 @@ pub fn signal_str_to_int(s: &str) -> Result { fn op_signal_bind( state: &mut OpState, sig: String, - _: (), ) -> Result { let signo = signal_str_to_int(&sig)?; if signal_hook_registry::FORBIDDEN.contains(&signo) { @@ -200,7 +199,6 @@ fn op_signal_bind( async fn op_signal_poll( state: Rc>, rid: ResourceId, - _: (), ) -> Result { let resource = state .borrow_mut() @@ -220,7 +218,6 @@ async fn op_signal_poll( pub fn op_signal_unbind( state: &mut OpState, rid: ResourceId, - _: (), ) -> Result<(), AnyError> { state.resource_table.close(rid)?; Ok(()) @@ -228,30 +225,18 @@ pub fn op_signal_unbind( #[cfg(not(unix))] #[op] -pub fn op_signal_bind( - _state: &mut OpState, - _: (), - _: (), -) -> Result<(), AnyError> { +pub fn op_signal_bind(_state: &mut OpState) -> Result<(), AnyError> { Err(generic_error("not implemented")) } #[cfg(not(unix))] #[op] -fn op_signal_unbind( - _state: &mut OpState, - _: (), - _: (), -) -> Result<(), AnyError> { +fn op_signal_unbind(_state: &mut OpState) -> Result<(), AnyError> { Err(generic_error("not implemented")) } #[cfg(not(unix))] #[op] -async fn op_signal_poll( - _state: Rc>, - _: (), - _: (), -) -> Result<(), AnyError> { +async fn op_signal_poll(_state: Rc>) -> Result<(), AnyError> { Err(generic_error("not implemented")) } diff --git a/runtime/ops/tty.rs b/runtime/ops/tty.rs index bbf6bd4126..465fb1679a 100644 --- a/runtime/ops/tty.rs +++ b/runtime/ops/tty.rs @@ -68,11 +68,7 @@ pub struct SetRawArgs { } #[op] -fn op_set_raw( - state: &mut OpState, - args: SetRawArgs, - _: (), -) -> Result<(), AnyError> { +fn op_set_raw(state: &mut OpState, args: SetRawArgs) -> Result<(), AnyError> { super::check_unstable(state, "Deno.setRaw"); let rid = args.rid; @@ -213,11 +209,7 @@ fn op_set_raw( } #[op] -fn op_isatty( - state: &mut OpState, - rid: ResourceId, - _: (), -) -> Result { +fn op_isatty(state: &mut OpState, rid: ResourceId) -> Result { let isatty: bool = StdFileResource::with(state, rid, move |r| match r { Ok(std_file) => { #[cfg(windows)] @@ -251,7 +243,6 @@ struct ConsoleSize { fn op_console_size( state: &mut OpState, rid: ResourceId, - _: (), ) -> Result { super::check_unstable(state, "Deno.consoleSize"); diff --git a/runtime/ops/web_worker.rs b/runtime/ops/web_worker.rs index 3c64cf1f6d..4137217bdd 100644 --- a/runtime/ops/web_worker.rs +++ b/runtime/ops/web_worker.rs @@ -33,7 +33,6 @@ pub fn init() -> Extension { fn op_worker_post_message( state: &mut OpState, data: JsMessageData, - _: (), ) -> Result<(), AnyError> { let handle = state.borrow::().clone(); handle.port.send(state, data)?; @@ -43,8 +42,6 @@ fn op_worker_post_message( #[op] async fn op_worker_recv_message( state: Rc>, - _: (), - _: (), ) -> Result, AnyError> { let handle = { let state = state.borrow(); @@ -58,7 +55,7 @@ async fn op_worker_recv_message( } #[op] -fn op_worker_close(state: &mut OpState, _: (), _: ()) -> Result<(), AnyError> { +fn op_worker_close(state: &mut OpState) -> Result<(), AnyError> { // Notify parent that we're finished let mut handle = state.borrow_mut::().clone(); @@ -67,11 +64,7 @@ fn op_worker_close(state: &mut OpState, _: (), _: ()) -> Result<(), AnyError> { } #[op] -fn op_worker_get_type( - state: &mut OpState, - _: (), - _: (), -) -> Result { +fn op_worker_get_type(state: &mut OpState) -> Result { let handle = state.borrow::().clone(); Ok(handle.worker_type) } diff --git a/runtime/ops/worker_host.rs b/runtime/ops/worker_host.rs index cebce81a4b..6c691c5a06 100644 --- a/runtime/ops/worker_host.rs +++ b/runtime/ops/worker_host.rs @@ -148,7 +148,6 @@ pub struct CreateWorkerArgs { fn op_create_worker( state: &mut OpState, args: CreateWorkerArgs, - _: (), ) -> Result { let specifier = args.specifier.clone(); let maybe_source_code = if args.has_source_code { @@ -265,7 +264,6 @@ fn op_create_worker( fn op_host_terminate_worker( state: &mut OpState, id: WorkerId, - _: (), ) -> Result<(), AnyError> { if let Some(worker_thread) = state.borrow_mut::().remove(&id) { worker_thread.terminate(); @@ -320,7 +318,6 @@ fn close_channel( async fn op_host_recv_ctrl( state: Rc>, id: WorkerId, - _: (), ) -> Result { let worker_handle = { let state = state.borrow(); @@ -352,7 +349,6 @@ async fn op_host_recv_ctrl( async fn op_host_recv_message( state: Rc>, id: WorkerId, - _: (), ) -> Result, AnyError> { let worker_handle = { let s = state.borrow();