From eeef4bdfd779ab0bfae1de61f49eef8c0abaf85a Mon Sep 17 00:00:00 2001 From: Robert Bastian <4706271+robertbastian@users.noreply.github.com> Date: Wed, 22 Nov 2023 18:31:53 +0100 Subject: [PATCH] clippy --- core/src/ast/types.rs | 1 + macro/src/lib.rs | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/core/src/ast/types.rs b/core/src/ast/types.rs index 328b18dde..74d50aa97 100644 --- a/core/src/ast/types.rs +++ b/core/src/ast/types.rs @@ -392,6 +392,7 @@ pub enum TypeName { } #[derive(Clone, PartialEq, Eq, Hash, Serialize, Deserialize, Debug, Copy)] +#[non_exhaustive] pub enum StringEncoding { UnvalidatedUtf8, UnvalidatedUtf16, diff --git a/macro/src/lib.rs b/macro/src/lib.rs index a33236d21..7c42ad00a 100644 --- a/macro/src/lib.rs +++ b/macro/src/lib.rs @@ -15,14 +15,21 @@ fn cfgs_to_stream(attrs: &[Attribute]) -> proc_macro2::TokenStream { fn gen_params_at_boundary(param: &ast::Param, expanded_params: &mut Vec) { match ¶m.ty { - ast::TypeName::StrReference(..) | ast::TypeName::PrimitiveSlice(..) => { + ast::TypeName::StrReference( + .., + ast::StringEncoding::UnvalidatedUtf8 | ast::StringEncoding::UnvalidatedUtf16, + ) + | ast::TypeName::PrimitiveSlice(..) => { let data_type = if let ast::TypeName::PrimitiveSlice(.., prim) = ¶m.ty { ast::TypeName::Primitive(*prim).to_syn().to_token_stream() - } else if let ast::TypeName::StrReference(_, e) = ¶m.ty { - match e { - ast::StringEncoding::UnvalidatedUtf8 => quote! { u8 }, - ast::StringEncoding::UnvalidatedUtf16 => quote! { u16 }, - } + } else if let ast::TypeName::StrReference(_, ast::StringEncoding::UnvalidatedUtf8) = + ¶m.ty + { + quote! { u8 } + } else if let ast::TypeName::StrReference(_, ast::StringEncoding::UnvalidatedUtf16) = + ¶m.ty + { + quote! { u16 } } else { unreachable!() };