Skip to content

Commit

Permalink
kas_macros: remove redundant error checking
Browse files Browse the repository at this point in the history
  • Loading branch information
dhardy committed Mar 31, 2022
1 parent b0f7765 commit d1f85db
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions crates/kas-macros/src/make_widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ pub(crate) fn make_widget(mut args: MakeWidget) -> Result<TokenStream> {
}
}

let mut x: Option<(Ident, Type)> = None;

for impl_ in impls {
if impl_.trait_.is_some() {
continue;
Expand All @@ -40,13 +38,6 @@ pub(crate) fn make_widget(mut args: MakeWidget) -> Result<TokenStream> {
syn::ImplItem::Method(syn::ImplItemMethod { sig, .. })
if sig.ident == *handler =>
{
if let Some(_x) = x {
abort!(
handler.span(), "multiple methods with this name";
help = _x.0.span() => "first method with this name";
help = sig.ident.span() => "second method with this name";
);
}
if sig.inputs.len() != 3 {
abort!(
sig.span(),
Expand All @@ -58,18 +49,16 @@ pub(crate) fn make_widget(mut args: MakeWidget) -> Result<TokenStream> {
syn::FnArg::Typed(arg) => (*arg.ty).clone(),
_ => panic!("expected typed argument"), // nothing else is possible here?
};
x = Some((sig.ident.clone(), ty));

find_handler_ty_buf.push((handler.clone(), ty.clone()));
return ty;
}
_ => (),
}
}
}
if let Some(x) = x {
find_handler_ty_buf.push((handler.clone(), x.1.clone()));
x.1
} else {
abort!(handler.span(), "no methods with this name found");
}

abort!(handler.span(), "no methods with this name found");
};

// Used to make fresh identifiers for generic types
Expand Down

0 comments on commit d1f85db

Please sign in to comment.