From 8d9e3efebd4a7d42fbb6a1d3c4f019d17eba05c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20K=C4=85dzio=C5=82ka?= Date: Sun, 26 Dec 2021 21:35:52 +0100 Subject: [PATCH] Use Self whenever possible in generated code This silences `clippy::use_self`, and additionally simplifies the code. The ugly `repeated_names` is no more. --- enumflags_derive/src/lib.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/enumflags_derive/src/lib.rs b/enumflags_derive/src/lib.rs index 938a08c..1476897 100644 --- a/enumflags_derive/src/lib.rs +++ b/enumflags_derive/src/lib.rs @@ -295,14 +295,13 @@ fn gen_enumflags(ast: &mut ItemEnum, default: Vec) -> Result ::enumflags2::_internal::core); let variant_names = ast.variants.iter().map(|v| &v.ident).collect::>(); - let repeated_name = vec![&ident; ast.variants.len()]; Ok(quote_spanned! { span => #ast #(#deferred)* impl #std_path::ops::Not for #ident { - type Output = ::enumflags2::BitFlags<#ident>; + type Output = ::enumflags2::BitFlags; #[inline(always)] fn not(self) -> Self::Output { use ::enumflags2::{BitFlags, _internal::RawBitFlags}; @@ -311,7 +310,7 @@ fn gen_enumflags(ast: &mut ItemEnum, default: Vec) -> Result; + type Output = ::enumflags2::BitFlags; #[inline(always)] fn bitor(self, other: Self) -> Self::Output { use ::enumflags2::{BitFlags, _internal::RawBitFlags}; @@ -320,7 +319,7 @@ fn gen_enumflags(ast: &mut ItemEnum, default: Vec) -> Result; + type Output = ::enumflags2::BitFlags; #[inline(always)] fn bitand(self, other: Self) -> Self::Output { use ::enumflags2::{BitFlags, _internal::RawBitFlags}; @@ -329,7 +328,7 @@ fn gen_enumflags(ast: &mut ItemEnum, default: Vec) -> Result; + type Output = ::enumflags2::BitFlags; #[inline(always)] fn bitxor(self, other: Self) -> Self::Output { #std_path::convert::Into::::into(self) ^ #std_path::convert::Into::::into(other) @@ -342,13 +341,13 @@ fn gen_enumflags(ast: &mut ItemEnum, default: Vec) -> Result");