修复内核的clippy检查报错 (#637)

修复内核的clippy检查报错
---------

Co-authored-by: Samuel Dai <947309196@qq.com>
Co-authored-by: Donkey Kane <109840258+xiaolin2004@users.noreply.github.com>
Co-authored-by: themildwind <107623059+themildwind@users.noreply.github.com>
Co-authored-by: GnoCiYeH <heyicong@dragonos.org>
Co-authored-by: MemoryShore <105195940+MemoryShore@users.noreply.github.com>
Co-authored-by: 曾俊 <110876916+ZZJJWarth@users.noreply.github.com>
Co-authored-by: sun5etop <146408999+sun5etop@users.noreply.github.com>
Co-authored-by: hmt <114841534+1037827920@users.noreply.github.com>
Co-authored-by: laokengwt <143977175+laokengwt@users.noreply.github.com>
Co-authored-by: TTaq <103996388+TTaq@users.noreply.github.com>
Co-authored-by: Jomo <2512364506@qq.com>
Co-authored-by: Samuel Dai <samuka007@qq.com>
Co-authored-by: sspphh <112558065+sspphh@users.noreply.github.com>
This commit is contained in:
LoGin
2024-03-22 23:26:39 +08:00
committed by GitHub
parent 4695947e1b
commit b5b571e026
175 changed files with 1820 additions and 2155 deletions

View File

@ -61,8 +61,8 @@ impl<T: BitOps> BitMapCore<T> {
pub(crate) fn first_index(&self, data: &[T]) -> Option<usize> {
for (i, element) in data.iter().enumerate() {
let bit = <T as BitOps>::first_index(element);
if bit.is_some() {
return Some(i * T::bit_size() + bit.unwrap());
if let Some(b) = bit {
return Some(i * T::bit_size() + b);
}
}
@ -237,10 +237,8 @@ impl<T: BitOps> BitMapCore<T> {
if element == mask {
return true;
}
} else {
if element != &T::make_mask(T::bit_size()) {
return false;
}
} else if element != &T::make_mask(T::bit_size()) {
return false;
}
}

View File

@ -309,6 +309,9 @@ pub trait BitMapOps<T: BitOps> {
/// 判断bitmap是否为空
fn is_empty(&self) -> bool;
/// # Safety
/// *不应直接修改字节数组*
///
/// 将bitmap转换为字节数组
unsafe fn as_bytes(&self) -> &[u8];
}

View File

@ -42,7 +42,7 @@ use uuid::Uuid;
#[proc_macro_attribute]
pub fn unified_init(args: TokenStream, input: TokenStream) -> TokenStream {
do_unified_init(args, input)
.unwrap_or_else(|e| e.to_compile_error().into())
.unwrap_or_else(|e| e.to_compile_error())
.into()
}
@ -59,7 +59,7 @@ fn do_unified_init(args: TokenStream, input: TokenStream) -> syn::Result<proc_ma
// 在旁边添加一个UnifiedInitializer
let initializer =
generate_unified_initializer(&function, &target_slice, function.sig.ident.to_string())?;
generate_unified_initializer(&function, target_slice, function.sig.ident.to_string())?;
// 拼接
let mut output = proc_macro2::TokenStream::new();
@ -80,7 +80,7 @@ fn do_unified_init(args: TokenStream, input: TokenStream) -> syn::Result<proc_ma
/// ```
fn check_function_signature(function: &ItemFn) -> syn::Result<()> {
// 检查函数签名
if function.sig.inputs.len() != 0 {
if !function.sig.inputs.is_empty() {
return Err(syn::Error::new(
function.sig.inputs.span(),
"Expected no arguments",
@ -111,7 +111,7 @@ fn check_function_signature(function: &ItemFn) -> syn::Result<()> {
if let syn::GenericArgument::Type(type_arg) = generic_args.args.first().unwrap()
{
if let syn::Type::Tuple(tuple) = type_arg {
if tuple.elems.len() != 0 {
if !tuple.elems.is_empty() {
return Err(syn::Error::new(tuple.span(), "Expected empty tuple"));
}
} else {
@ -166,7 +166,7 @@ fn generate_unified_initializer(
let initializer_name = format!(
"unified_initializer_{}_{}",
raw_initializer_name,
Uuid::new_v4().to_simple().to_string().to_ascii_uppercase()[..8].to_string()
&Uuid::new_v4().to_simple().to_string().to_ascii_uppercase()[..8]
)
.to_ascii_uppercase();