diff --git a/ion-proc/src/trace.rs b/ion-proc/src/trace.rs index 7d994f42..45eb5986 100644 --- a/ion-proc/src/trace.rs +++ b/ion-proc/src/trace.rs @@ -34,10 +34,8 @@ fn impl_body(span: Span, data: &Data) -> Result { match data { Data::Struct(r#struct) => { let (idents, skip) = field_idents(&r#struct.fields); - let traced = idents - .iter() - .enumerate() - .filter_map(|(index, ident)| (!skip.contains(&index)).then_some(ident)); + let traced = + idents.iter().enumerate().filter_map(|(index, ident)| (!skip.contains(&index)).then_some(ident)); parse2(quote_spanned!(span => { let Self { #(#idents),* } = self; #(::mozjs::gc::Traceable::trace(#traced, __ion_tracer));* diff --git a/ion/src/string/byte.rs b/ion/src/string/byte.rs index d939a9f3..2d502ffe 100644 --- a/ion/src/string/byte.rs +++ b/ion/src/string/byte.rs @@ -72,11 +72,7 @@ pub struct ByteString { impl ByteString { pub fn from(bytes: Vec) -> Option> { - bytes - .iter() - .copied() - .all(T::predicate) - .then(|| unsafe { ByteString::from_unchecked(bytes) }) + bytes.iter().copied().all(T::predicate).then(|| unsafe { ByteString::from_unchecked(bytes) }) } pub unsafe fn from_unchecked(bytes: Vec) -> ByteString { diff --git a/runtime/src/globals/file/mod.rs b/runtime/src/globals/file/mod.rs index de622034..dc39bbf3 100644 --- a/runtime/src/globals/file/mod.rs +++ b/runtime/src/globals/file/mod.rs @@ -38,10 +38,7 @@ impl File { pub fn constructor(parts: Vec, name: String, options: Option) -> File { let options = options.unwrap_or_default(); let blob = Blob::constructor(Some(parts), Some(options.blob)); - let modified = options - .modified - .and_then(|d| Utc.timestamp_millis_opt(d).single()) - .unwrap_or_else(Utc::now); + let modified = options.modified.and_then(|d| Utc.timestamp_millis_opt(d).single()).unwrap_or_else(Utc::now); File { blob, name, modified } } diff --git a/runtime/src/runtime.rs b/runtime/src/runtime.rs index 0e70ad14..428e8923 100644 --- a/runtime/src/runtime.rs +++ b/runtime/src/runtime.rs @@ -37,7 +37,7 @@ impl ContextExt for Context { } pub struct Runtime<'cx> { - global: Object, + global: Option, cx: &'cx Context, #[allow(dead_code)] realm: JSAutoRealm, @@ -49,11 +49,11 @@ impl<'cx> Runtime<'cx> { } pub fn global(&self) -> &Object { - &self.global + self.global.as_ref().unwrap() } pub fn global_mut(&mut self) -> &mut Object { - &mut self.global + self.global.as_mut().unwrap() } pub async fn run_event_loop(&self) -> Result<(), Option> { @@ -64,6 +64,7 @@ impl<'cx> Runtime<'cx> { impl Drop for Runtime<'_> { fn drop(&mut self) { + let _ = self.global.take(); let private = self.cx.get_private(); let _ = unsafe { Box::from_raw(private.as_ptr()) }; let inner_private = self.cx.get_inner_data(); @@ -156,7 +157,7 @@ impl RuntimeBuilder< } } - Runtime { global, cx, realm } + Runtime { global: Some(global), cx, realm } } } diff --git a/rustfmt.toml b/rustfmt.toml index a5d51df2..0a945bec 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,4 +1,4 @@ -chain_width = 120 +chain_width = 100 edition = "2021" force_explicit_abi = true fn_params_layout = "Compressed"