Skip to content

Commit

Permalink
Removed unused symbol and fixed feature gates to avoid compiler warni…
Browse files Browse the repository at this point in the history
…ngs.
  • Loading branch information
lupan committed Oct 31, 2023
1 parent a0031d3 commit c3aa230
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 23 deletions.
39 changes: 19 additions & 20 deletions crates/rune-macros/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -479,28 +479,27 @@ impl Context {
attr.from_value_params =
Some(syn::punctuated::Punctuated::parse_terminated(&content)?);
} else if meta.path == META_FIELDS {
if cfg!(not(feature = "dynamic_fields")) {
return Err(syn::Error::new_spanned(
&meta.path,
"Dynamic fields feature flag \"dynamic_fields\" is not enabled",
));
}
meta.input.parse::<Token![=]>()?;
let ty: syn::Ident = meta.input.parse()?;
let value = match ty.to_string().as_str() {
"never" => Some(format_ident!("Never")),
"first" => Some(format_ident!("First")),
"last" => Some(format_ident!("Last")),
"only" => Some(format_ident!("Only")),
_ => {
return Err(syn::Error::new_spanned(
&meta.path,
"Expected `never`, `only`, `first` or `last`",
))
}
};
#[cfg(not(feature = "dynamic_fields"))]
return Err(syn::Error::new_spanned(
&meta.path,
"Dynamic fields feature flag \"dynamic_fields\" is not enabled",
));
#[cfg(feature = "dynamic_fields")]
{
meta.input.parse::<Token![=]>()?;
let ty: syn::Ident = meta.input.parse()?;
let value = match ty.to_string().as_str() {
"never" => Some(format_ident!("Never")),
"first" => Some(format_ident!("First")),
"last" => Some(format_ident!("Last")),
"only" => Some(format_ident!("Only")),
_ => {
return Err(syn::Error::new_spanned(
&meta.path,
"Expected `never`, `only`, `first` or `last`",
))
}
};
attr.meta_fields = value;
}
} else {
Expand Down
3 changes: 0 additions & 3 deletions crates/rune-macros/src/internals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ pub const NAME: Symbol = Symbol("name");
pub const ITEM: Symbol = Symbol("item");
pub const MODULE: Symbol = Symbol("module");
pub const INSTALL_WITH: Symbol = Symbol("install_with");
#[cfg(feature = "dynamic_fields")]
pub const DYNAMIC_FIELDS: Symbol = Symbol("dynamic_fields");

pub const CONSTRUCTOR: Symbol = Symbol("constructor");
pub const BUILTIN: Symbol = Symbol("builtin");
pub const STATIC_TYPE: Symbol = Symbol("static_type");
Expand Down

0 comments on commit c3aa230

Please sign in to comment.