avm2: Resolve review notes in `enum_trait_object` macro

This commit is contained in:
Lord-McSweeney 2024-08-06 15:44:45 -07:00 committed by Lord-McSweeney
parent 53347ed088
commit 117df6e3c2
1 changed files with 12 additions and 23 deletions

View File

@ -69,31 +69,20 @@ pub fn enum_trait_object(args: TokenStream, item: TokenStream) -> TokenStream {
let mut is_no_dynamic = false;
let new_attrs = method
.attrs
.iter()
.filter(|attr| match &attr.meta {
Meta::Path(path) => {
if let Some(ident) = path.get_ident() {
if ident == "no_dynamic" {
is_no_dynamic = true;
method.attrs.retain(|attr| match &attr.meta {
Meta::Path(path) => {
if path.is_ident("no_dynamic") {
is_no_dynamic = true;
// Remove the #[no_dynamic] attribute from the
// list of method attributes.
false
} else {
true
}
} else {
true
}
// Remove the #[no_dynamic] attribute from the
// list of method attributes.
false
} else {
true
}
_ => true,
})
.map(|o| o.clone())
.collect::<Vec<_>>();
method.attrs = new_attrs;
}
_ => true,
});
if is_no_dynamic {
// Don't create this method as a dynamic-dispatch method