From c3dfce79c9c0c7bae4e3ed3423f02b61aa12d123 Mon Sep 17 00:00:00 2001 From: richarddavison <89518095+richarddavison@users.noreply.github.com> Date: Mon, 26 Aug 2024 14:36:44 +0200 Subject: [PATCH] chore: remove unused ctx params (#556) * Remove unused ctx params * Fix errors * elided lifetimes * Clippy --- llrt_core/build.rs | 4 ++-- llrt_core/src/modules/llrt/xml.rs | 2 +- llrt_core/src/vm.rs | 2 +- llrt_modules/src/modules/child_process.rs | 2 +- llrt_modules/src/modules/crypto/crc32.rs | 4 ++-- llrt_modules/src/modules/crypto/mod.rs | 2 +- llrt_modules/src/modules/events/custom_event.rs | 2 +- llrt_modules/src/modules/fs/read_dir.rs | 12 ++---------- llrt_modules/src/modules/fs/rm.rs | 2 +- llrt_modules/src/modules/net/socket.rs | 10 +++------- llrt_modules/src/stream/readable.rs | 6 +----- llrt_modules/src/stream/writable.rs | 6 +----- 12 files changed, 17 insertions(+), 37 deletions(-) diff --git a/llrt_core/build.rs b/llrt_core/build.rs index 3875d8b83b..54c0d5982f 100644 --- a/llrt_core/build.rs +++ b/llrt_core/build.rs @@ -130,8 +130,8 @@ async fn main() -> StdResult<(), Box> { info!("Done!"); ph_map.entry( - module_name.replace("\\", "/"), - &format!("include_bytes!(\"{}\")", &lrt_filename).replace("\\", "/"), + module_name.replace('\\', "/"), + &format!("include_bytes!(\"{}\")", &lrt_filename).replace('\\', "/"), ); } diff --git a/llrt_core/src/modules/llrt/xml.rs b/llrt_core/src/modules/llrt/xml.rs index ff6b752957..3feee31993 100644 --- a/llrt_core/src/modules/llrt/xml.rs +++ b/llrt_core/src/modules/llrt/xml.rs @@ -78,7 +78,7 @@ impl<'js> StackObject<'js> { #[rquickjs::methods(rename_all = "camelCase")] impl<'js> XMLParser<'js> { #[qjs(constructor)] - pub fn new(_ctx: Ctx<'js>, options: Opt>) -> Result { + pub fn new(options: Opt>) -> Result { let mut tag_value_processor = None; let mut attribute_value_processor = None; let mut attribute_name_prefix = String::from("@_"); diff --git a/llrt_core/src/vm.rs b/llrt_core/src/vm.rs index 427682431a..5446e24a2b 100644 --- a/llrt_core/src/vm.rs +++ b/llrt_core/src/vm.rs @@ -563,7 +563,7 @@ fn init(ctx: &Ctx<'_>, module_names: HashSet<&'static str>) -> Result<()> { js_bootstrap.set( "moduleExport", Func::from(move |ctx, obj, prop, value| { - let ExportArgs(_ctx, _, _, value) = ExportArgs(ctx, obj, prop, value); + let ExportArgs(_, _, _, value) = ExportArgs(ctx, obj, prop, value); let mut exports = require_exports.lock().unwrap(); exports.replace(value); Result::Ok(true) diff --git a/llrt_modules/src/modules/child_process.rs b/llrt_modules/src/modules/child_process.rs index 1ffc954dab..6947af8489 100644 --- a/llrt_modules/src/modules/child_process.rs +++ b/llrt_modules/src/modules/child_process.rs @@ -155,7 +155,7 @@ impl<'js> ChildProcess<'js> { self.pid.into_js(&ctx) } - fn kill(&mut self, _ctx: Ctx<'js>, signal: Opt>) -> Result { + fn kill(&mut self, signal: Opt>) -> Result { #[cfg(unix)] let signal = if let Some(signal) = signal.0 { if signal.is_number() { diff --git a/llrt_modules/src/modules/crypto/crc32.rs b/llrt_modules/src/modules/crypto/crc32.rs index a049ce2b54..3930780b45 100644 --- a/llrt_modules/src/modules/crypto/crc32.rs +++ b/llrt_modules/src/modules/crypto/crc32.rs @@ -23,7 +23,7 @@ impl Crc32c { } #[qjs(rename = "digest")] - fn crc32c_digest(&self, _ctx: Ctx<'_>) -> u64 { + fn crc32c_digest(&self) -> u64 { self.hasher.finish() } @@ -56,7 +56,7 @@ impl Crc32 { } #[qjs(rename = "digest")] - fn crc32_digest(&self, _ctx: Ctx<'_>) -> u64 { + fn crc32_digest(&self) -> u64 { self.hasher.finish() } diff --git a/llrt_modules/src/modules/crypto/mod.rs b/llrt_modules/src/modules/crypto/mod.rs index 9066fe3613..4d1416dfc5 100644 --- a/llrt_modules/src/modules/crypto/mod.rs +++ b/llrt_modules/src/modules/crypto/mod.rs @@ -65,7 +65,7 @@ fn get_random_bytes(ctx: Ctx, length: usize) -> Result { Buffer(random_bytes).into_js(&ctx) } -fn get_random_int(_ctx: Ctx, first: i64, second: Opt) -> Result { +fn get_random_int(first: i64, second: Opt) -> Result { let mut rng = ThreadRng::default(); let random_number = match second.0 { Some(max) => rng.gen_range(first..max), diff --git a/llrt_modules/src/modules/events/custom_event.rs b/llrt_modules/src/modules/events/custom_event.rs index ec137a743e..5a1feaf61d 100644 --- a/llrt_modules/src/modules/events/custom_event.rs +++ b/llrt_modules/src/modules/events/custom_event.rs @@ -14,7 +14,7 @@ pub struct CustomEvent<'js> { #[rquickjs::methods] impl<'js> CustomEvent<'js> { #[qjs(constructor)] - pub fn new(_ctx: Ctx<'js>, event_type: String, options: Opt>) -> Result { + pub fn new(event_type: String, options: Opt>) -> Result { let mut detail = None; if let Some(options) = options.0 { if let Some(opt) = options.get_optional("detail")? { diff --git a/llrt_modules/src/modules/fs/read_dir.rs b/llrt_modules/src/modules/fs/read_dir.rs index 30650d5cfd..9d67115fdd 100644 --- a/llrt_modules/src/modules/fs/read_dir.rs +++ b/llrt_modules/src/modules/fs/read_dir.rs @@ -106,11 +106,7 @@ impl<'js> IntoJs<'js> for ReadDir { } } -pub async fn read_dir<'js>( - _ctx: Ctx<'js>, - mut path: String, - options: Opt>, -) -> Result { +pub async fn read_dir(mut path: String, options: Opt>) -> Result { let (with_file_types, skip_root_pos, mut directory_walker) = process_options_and_create_directory_walker(&mut path, options); @@ -131,11 +127,7 @@ pub async fn read_dir<'js>( Ok(ReadDir { items, root: path }) } -pub fn read_dir_sync<'js>( - _ctx: Ctx<'js>, - mut path: String, - options: Opt>, -) -> Result { +pub fn read_dir_sync(mut path: String, options: Opt>) -> Result { let (with_file_types, skip_root_pos, mut directory_walker) = process_options_and_create_directory_walker(&mut path, options); diff --git a/llrt_modules/src/modules/fs/rm.rs b/llrt_modules/src/modules/fs/rm.rs index 8acf762143..312b0a00b5 100644 --- a/llrt_modules/src/modules/fs/rm.rs +++ b/llrt_modules/src/modules/fs/rm.rs @@ -61,7 +61,7 @@ pub async fn rmfile<'js>(ctx: Ctx<'js>, path: String, options: Opt>) Ok(()) } -pub fn rmfile_sync<'js>(_ctx: Ctx<'js>, path: String, options: Opt>) -> Result<()> { +pub fn rmfile_sync(path: String, options: Opt>) -> Result<()> { let (recursive, force) = get_params_rm(options); let res = (|| -> Result<()> { diff --git a/llrt_modules/src/modules/net/socket.rs b/llrt_modules/src/modules/net/socket.rs index 92f5a90514..f3082f8206 100644 --- a/llrt_modules/src/modules/net/socket.rs +++ b/llrt_modules/src/modules/net/socket.rs @@ -139,14 +139,10 @@ impl<'js> Socket<'js> { Ok(()) } - pub fn destroy( - this: This>, - ctx: Ctx<'js>, - error: Opt>, - ) -> Class<'js, Self> { + pub fn destroy(this: This>, error: Opt>) -> Class<'js, Self> { this.borrow_mut().destroyed = true; - ReadableStream::destroy(This(this.clone()), ctx.clone(), Opt(None)); - WritableStream::destroy(This(this.clone()), ctx.clone(), error); + ReadableStream::destroy(This(this.clone()), Opt(None)); + WritableStream::destroy(This(this.clone()), error); this.0 } diff --git a/llrt_modules/src/stream/readable.rs b/llrt_modules/src/stream/readable.rs index cbf5f8c70c..e7d76ccc1b 100644 --- a/llrt_modules/src/stream/readable.rs +++ b/llrt_modules/src/stream/readable.rs @@ -163,11 +163,7 @@ where Ok(()) } - fn destroy( - this: This>, - _ctx: Ctx<'js>, - error: Opt>, - ) -> Class<'js, Self> { + fn destroy(this: This>, error: Opt>) -> Class<'js, Self> { let mut borrow = this.borrow_mut(); let inner = borrow.inner_mut(); inner.is_destroyed = true; diff --git a/llrt_modules/src/stream/writable.rs b/llrt_modules/src/stream/writable.rs index fab8a8abb7..f3fc0bade6 100644 --- a/llrt_modules/src/stream/writable.rs +++ b/llrt_modules/src/stream/writable.rs @@ -127,11 +127,7 @@ where Ok(()) } - fn destroy( - this: This>, - _ctx: Ctx<'js>, - error: Opt>, - ) -> Class<'js, Self> { + fn destroy(this: This>, error: Opt>) -> Class<'js, Self> { if !this.borrow().inner().is_finished { let mut borrow = this.borrow_mut(); let inner = borrow.inner_mut();