mirror of
https://github.com/wez/wezterm.git
synced 2024-12-22 21:01:36 +03:00
fix some warnings with rust 1.83
It's complaining about non-local impls and elided lifetimes that have names. I don't recall why I thought I needed these "dummy" enclosing scopes, and they are most likely cargo-cult copypasta from some other derive implementation that I used as inspiration.
This commit is contained in:
parent
a7ff718c7c
commit
74015a95c7
@ -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<TokenStream> {
|
||||
match &input.data {
|
||||
@ -24,10 +24,6 @@ fn derive_struct(input: &DeriveInput, fields: &FieldsNamed) -> Result<TokenStrea
|
||||
let info = attr::container_info(&input.attrs)?;
|
||||
let ident = &input.ident;
|
||||
let (impl_generics, ty_generics, _where_clause) = input.generics.split_for_impl();
|
||||
let dummy = Ident::new(
|
||||
&format!("_IMPL_CONFIGMETA_FOR_{}", ident),
|
||||
Span::call_site(),
|
||||
);
|
||||
|
||||
let options = fields
|
||||
.named
|
||||
@ -44,17 +40,14 @@ fn derive_struct(input: &DeriveInput, fields: &FieldsNamed) -> Result<TokenStrea
|
||||
let bounded_where_clause = bound::where_clause_with_bound(&input.generics, bound);
|
||||
|
||||
let tokens = quote! {
|
||||
#[allow(non_upper_case_globals)]
|
||||
const #dummy: () = {
|
||||
impl #impl_generics crate::meta::ConfigMeta for #ident #ty_generics #bounded_where_clause {
|
||||
fn get_config_options(&self) -> &'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 {
|
||||
|
@ -80,7 +80,7 @@ fn toml_decode(lua: &Lua, text: String) -> mlua::Result<LuaValue> {
|
||||
json_value_to_lua_value(lua, value)
|
||||
}
|
||||
|
||||
fn json_value_to_lua_value<'lua>(lua: &'lua Lua, value: JValue) -> mlua::Result<LuaValue> {
|
||||
fn json_value_to_lua_value<'lua>(lua: &'lua Lua, value: JValue) -> mlua::Result<LuaValue<'lua>> {
|
||||
Ok(match value {
|
||||
JValue::Null => LuaValue::Nil,
|
||||
JValue::Bool(b) => LuaValue::Boolean(b),
|
||||
|
@ -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::Value> {
|
||||
) -> mlua::Result<mlua::Value<'lua>> {
|
||||
Ok(match value {
|
||||
DynValue::Null => LuaValue::Nil,
|
||||
DynValue::Bool(b) => LuaValue::Boolean(b),
|
||||
|
@ -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<TokenStream> {
|
||||
@ -28,10 +28,6 @@ fn derive_struct(input: &DeriveInput, fields: &FieldsNamed) -> Result<TokenStrea
|
||||
let ident = &input.ident;
|
||||
let literal = ident.to_string();
|
||||
let (impl_generics, ty_generics, _where_clause) = input.generics.split_for_impl();
|
||||
let dummy = Ident::new(
|
||||
&format!("_IMPL_FROMDYNAMIC_FOR_{}", ident),
|
||||
Span::call_site(),
|
||||
);
|
||||
|
||||
let placements = fields
|
||||
.named
|
||||
@ -119,22 +115,19 @@ fn derive_struct(input: &DeriveInput, fields: &FieldsNamed) -> Result<TokenStrea
|
||||
};
|
||||
|
||||
let tokens = quote! {
|
||||
#[allow(non_upper_case_globals)]
|
||||
const #dummy: () = {
|
||||
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<Self, wezterm_dynamic::Error> {
|
||||
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<Self, wezterm_dynamic::Error> {
|
||||
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<TokenStrea
|
||||
|
||||
let ident = &input.ident;
|
||||
let literal = ident.to_string();
|
||||
let dummy = Ident::new(
|
||||
&format!("_IMPL_FROMDYNAMIC_FOR_{}", ident),
|
||||
Span::call_site(),
|
||||
);
|
||||
|
||||
let variant_names = enumeration
|
||||
.variants
|
||||
@ -321,23 +310,20 @@ fn derive_enum(input: &DeriveInput, enumeration: &DataEnum) -> Result<TokenStrea
|
||||
};
|
||||
|
||||
let tokens = quote! {
|
||||
#[allow(non_upper_case_globals)]
|
||||
const #dummy: () = {
|
||||
impl wezterm_dynamic::FromDynamic for #ident {
|
||||
fn from_dynamic(value: &wezterm_dynamic::Value, options: wezterm_dynamic::FromDynamicOptions) -> std::result::Result<Self, wezterm_dynamic::Error> {
|
||||
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<Self, wezterm_dynamic::Error> {
|
||||
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 {
|
||||
|
@ -27,10 +27,6 @@ fn derive_struct(input: &DeriveInput, fields: &FieldsNamed) -> Result<TokenStrea
|
||||
let ident = &input.ident;
|
||||
let info = attr::container_info(&input.attrs)?;
|
||||
let (impl_generics, ty_generics, _where_clause) = input.generics.split_for_impl();
|
||||
let dummy = Ident::new(
|
||||
&format!("_IMPL_PLACEDYNAMIC_FOR_{}", ident),
|
||||
Span::call_site(),
|
||||
);
|
||||
|
||||
let placements = fields
|
||||
.named
|
||||
@ -48,23 +44,16 @@ fn derive_struct(input: &DeriveInput, fields: &FieldsNamed) -> Result<TokenStrea
|
||||
let tokens = match info.into {
|
||||
Some(into) => {
|
||||
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<TokenStrea
|
||||
wezterm_dynamic::Value::Object(object)
|
||||
}
|
||||
}
|
||||
};
|
||||
)
|
||||
}
|
||||
};
|
||||
@ -102,21 +90,17 @@ fn derive_enum(input: &DeriveInput, enumeration: &DataEnum) -> Result<TokenStrea
|
||||
}
|
||||
|
||||
let ident = &input.ident;
|
||||
let dummy = Ident::new(&format!("_IMPL_TODYNAMIC_FOR_{}", ident), Span::call_site());
|
||||
let info = attr::container_info(&input.attrs)?;
|
||||
|
||||
let tokens = match info.into {
|
||||
Some(into) => {
|
||||
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<TokenStrea
|
||||
.collect::<Result<Vec<_>>>()?;
|
||||
|
||||
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
|
||||
)*
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user