diff --git a/config/derive/src/configmeta.rs b/config/derive/src/configmeta.rs index 05a02ab2f..d9e15de85 100644 --- a/config/derive/src/configmeta.rs +++ b/config/derive/src/configmeta.rs @@ -1,7 +1,7 @@ use crate::{attr, bound}; use proc_macro2::{Span, TokenStream}; use quote::quote; -use syn::{parse_quote, Data, DataStruct, DeriveInput, Error, Fields, FieldsNamed, Ident, Result}; +use syn::{parse_quote, Data, DataStruct, DeriveInput, Error, Fields, FieldsNamed, Result}; pub fn derive(input: DeriveInput) -> Result { match &input.data { @@ -24,10 +24,6 @@ fn derive_struct(input: &DeriveInput, fields: &FieldsNamed) -> Result Result &'static [crate::meta::ConfigOption] - { - &[ - #( #options, )* - ] - } + impl #impl_generics crate::meta::ConfigMeta for #ident #ty_generics #bounded_where_clause { + fn get_config_options(&self) -> &'static [crate::meta::ConfigOption] + { + &[ + #( #options, )* + ] } - }; + } }; if info.debug { diff --git a/lua-api-crates/serde-funcs/src/lib.rs b/lua-api-crates/serde-funcs/src/lib.rs index f3c5b841d..0e6499770 100644 --- a/lua-api-crates/serde-funcs/src/lib.rs +++ b/lua-api-crates/serde-funcs/src/lib.rs @@ -80,7 +80,7 @@ fn toml_decode(lua: &Lua, text: String) -> mlua::Result { json_value_to_lua_value(lua, value) } -fn json_value_to_lua_value<'lua>(lua: &'lua Lua, value: JValue) -> mlua::Result { +fn json_value_to_lua_value<'lua>(lua: &'lua Lua, value: JValue) -> mlua::Result> { Ok(match value { JValue::Null => LuaValue::Nil, JValue::Bool(b) => LuaValue::Boolean(b), diff --git a/luahelper/src/lib.rs b/luahelper/src/lib.rs index 80e78432c..7306e56d1 100644 --- a/luahelper/src/lib.rs +++ b/luahelper/src/lib.rs @@ -63,7 +63,7 @@ macro_rules! impl_lua_conversion_dynamic { pub fn dynamic_to_lua_value<'lua>( lua: &'lua mlua::Lua, value: DynValue, -) -> mlua::Result { +) -> mlua::Result> { Ok(match value { DynValue::Null => LuaValue::Nil, DynValue::Bool(b) => LuaValue::Boolean(b), diff --git a/wezterm-dynamic/derive/src/fromdynamic.rs b/wezterm-dynamic/derive/src/fromdynamic.rs index 57ec10380..505430c80 100644 --- a/wezterm-dynamic/derive/src/fromdynamic.rs +++ b/wezterm-dynamic/derive/src/fromdynamic.rs @@ -2,7 +2,7 @@ use crate::{attr, bound}; use proc_macro2::{Span, TokenStream}; use quote::quote; use syn::{ - parse_quote, Data, DataEnum, DataStruct, DeriveInput, Error, Fields, FieldsNamed, Ident, Result, + parse_quote, Data, DataEnum, DataStruct, DeriveInput, Error, Fields, FieldsNamed, Result, }; pub fn derive(input: DeriveInput) -> Result { @@ -28,10 +28,6 @@ fn derive_struct(input: &DeriveInput, fields: &FieldsNamed) -> Result Result std::result::Result { - use wezterm_dynamic::{Value, BorrowedKey, ObjectKeyTrait}; - #adjust_options - #from_dynamic - } + impl #impl_generics wezterm_dynamic::FromDynamic for #ident #ty_generics #bounded_where_clause { + fn from_dynamic(value: &wezterm_dynamic::Value, options: wezterm_dynamic::FromDynamicOptions) -> std::result::Result { + use wezterm_dynamic::{Value, BorrowedKey, ObjectKeyTrait}; + #adjust_options + #from_dynamic + } + } + impl #impl_generics #ident #ty_generics #bounded_where_clause { + pub const fn possible_field_names() -> &'static [&'static str] { + #field_names } - impl #impl_generics #ident #ty_generics #bounded_where_clause { - pub const fn possible_field_names() -> &'static [&'static str] { - #field_names - } - } - }; + } }; if info.debug { @@ -154,10 +147,6 @@ fn derive_enum(input: &DeriveInput, enumeration: &DataEnum) -> Result Result std::result::Result { - use wezterm_dynamic::{Value, BorrowedKey, ObjectKeyTrait}; - #from_dynamic - } + impl wezterm_dynamic::FromDynamic for #ident { + fn from_dynamic(value: &wezterm_dynamic::Value, options: wezterm_dynamic::FromDynamicOptions) -> std::result::Result { + use wezterm_dynamic::{Value, BorrowedKey, ObjectKeyTrait}; + #from_dynamic } + } - impl #ident { - pub fn variants() -> &'static [&'static str] { - &[ - #( #variant_names, )* - ] - } + impl #ident { + pub fn variants() -> &'static [&'static str] { + &[ + #( #variant_names, )* + ] } - }; + } }; if info.debug { diff --git a/wezterm-dynamic/derive/src/todynamic.rs b/wezterm-dynamic/derive/src/todynamic.rs index 676aac63b..f574f5717 100644 --- a/wezterm-dynamic/derive/src/todynamic.rs +++ b/wezterm-dynamic/derive/src/todynamic.rs @@ -27,10 +27,6 @@ fn derive_struct(input: &DeriveInput, fields: &FieldsNamed) -> Result Result { quote!( - - #[allow(non_upper_case_globals)] - const #dummy: () = { - impl #impl_generics wezterm_dynamic::ToDynamic for #ident #ty_generics #bounded_where_clause { fn to_dynamic(&self) -> wezterm_dynamic::Value { let target: #into = self.into(); target.to_dynamic() } } - }; ) } None => { quote!( - #[allow(non_upper_case_globals)] - const #dummy: () = { impl #impl_generics wezterm_dynamic::PlaceDynamic for #ident #ty_generics #bounded_where_clause { fn place_dynamic(&self, place: &mut wezterm_dynamic::Object) { #( @@ -82,7 +71,6 @@ fn derive_struct(input: &DeriveInput, fields: &FieldsNamed) -> Result Result { quote! { - #[allow(non_upper_case_globals)] - const #dummy: () = { - impl wezterm_dynamic::ToDynamic for #ident { - fn to_dynamic(&self) -> wezterm_dynamic::Value { - let target : #into = self.into(); - target.to_dynamic() - } + impl wezterm_dynamic::ToDynamic for #ident { + fn to_dynamic(&self) -> wezterm_dynamic::Value { + let target : #into = self.into(); + target.to_dynamic() } - }; + } } } None => { @@ -207,19 +191,16 @@ fn derive_enum(input: &DeriveInput, enumeration: &DataEnum) -> Result>>()?; quote! { - #[allow(non_upper_case_globals)] - const #dummy: () = { - impl wezterm_dynamic::ToDynamic for #ident { - fn to_dynamic(&self) -> wezterm_dynamic::Value { - use wezterm_dynamic::Value; - match self { - #( - #variants - )* - } + impl wezterm_dynamic::ToDynamic for #ident { + fn to_dynamic(&self) -> wezterm_dynamic::Value { + use wezterm_dynamic::Value; + match self { + #( + #variants + )* } } - }; + } } } };