From 5342a26fd014ef95a0f72f5016682b8a05254e95 Mon Sep 17 00:00:00 2001 From: Richard Dodd Date: Tue, 21 Aug 2018 13:11:53 +0100 Subject: [PATCH] Clean up checking code a bit --- crates/macro-support/src/parser.rs | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/crates/macro-support/src/parser.rs b/crates/macro-support/src/parser.rs index 9dd61eba..5fc0c05f 100644 --- a/crates/macro-support/src/parser.rs +++ b/crates/macro-support/src/parser.rs @@ -1115,18 +1115,14 @@ fn assert_last_param_is_slice(decl: &syn::FnDecl) -> Result<(), Diagnostic> { } let arg = decl.inputs.last().ok_or_else(|| not_slice_error(&decl.inputs))?; - let ty = match arg.value() { - syn::FnArg::Captured(ref arg_cap) => &arg_cap.ty, - _ => return Err(not_slice_error(&arg)) - }; - match ty { - syn::Type::Reference(ref ref_ty) => match &*ref_ty.elem { - syn::Type::Slice(_) => Ok(()), - _ => Err(not_slice_error(ty)) - }, - _ => Err(not_slice_error(ty)) + if let syn::FnArg::Captured(ref arg_cap) = arg.value() { + if let syn::Type::Reference(ref ref_ty) = arg_cap.ty { + if let syn::Type::Slice(_) = *ref_ty.elem { + return Ok(()) + } + } } - + Err(not_slice_error(&arg)) } /// If the path is a single ident, return it.