Fix clippy warnings (#3085)

* Run clippy fix

* Clippy v2

* Make const item static

* Cargo fmt
This commit is contained in:
Dennis Kobert
2025-08-23 11:45:47 +02:00
committed by GitHub
parent c6ec3a27ca
commit 7377871106
47 changed files with 218 additions and 258 deletions
+5 -8
View File
@@ -101,14 +101,11 @@ pub fn derive_discriminant_impl(input_item: TokenStream) -> syn::Result<TokenStr
let (pattern, value) = is_sub_discriminant
.into_iter()
.map(|b| {
(
if b {
quote::quote! { (x) }
} else {
quote::quote! { { .. } }
},
b.then(|| quote::quote! { (x.to_discriminant()) }).unwrap_or_default(),
)
if b {
(quote::quote! {(x)}, quote::quote! {(x.to_discriminant())})
} else {
(quote::quote! {{..}}, Default::default())
}
})
.unzip::<_, _, Vec<_>, Vec<_>>();
#[cfg(feature = "serde-discriminant")]
+4 -4
View File
@@ -55,7 +55,7 @@ pub fn clean_rust_type_syntax(input: String) -> String {
}
}
'<' => {
while let Some(' ') = result.chars().rev().next() {
while let Some(' ') = result.chars().next_back() {
result.pop();
}
result.push('<');
@@ -64,7 +64,7 @@ pub fn clean_rust_type_syntax(input: String) -> String {
}
}
'>' => {
while let Some(' ') = result.chars().rev().next() {
while let Some(' ') = result.chars().next_back() {
result.pop();
}
result.push('>');
@@ -74,7 +74,7 @@ pub fn clean_rust_type_syntax(input: String) -> String {
}
'-' => {
if let Some('>') = chars.peek() {
while let Some(' ') = result.chars().rev().next() {
while let Some(' ') = result.chars().next_back() {
result.pop();
}
result.push_str(" -> ");
@@ -88,7 +88,7 @@ pub fn clean_rust_type_syntax(input: String) -> String {
}
':' => {
if let Some(':') = chars.peek() {
while let Some(' ') = result.chars().rev().next() {
while let Some(' ') = result.chars().next_back() {
result.pop();
}
}
+4 -6
View File
@@ -47,22 +47,20 @@ pub fn generate_hierarchical_tree(input: TokenStream) -> syn::Result<TokenStream
})
} else {
let error_msg = match fields.unnamed.len() {
0 => format!("Remove the unnecessary `()` from the `{}` message enum variant.", variant_type),
0 => format!("Remove the unnecessary `()` from the `{variant_type}` message enum variant."),
1 => {
let field_type = &fields.unnamed.first().unwrap().ty;
format!(
"The `{}` message should be defined as a struct-style (not tuple-style) enum variant to maintain consistent formatting across all editor messages.\n\
"The `{variant_type}` message should be defined as a struct-style (not tuple-style) enum variant to maintain consistent formatting across all editor messages.\n\
Replace `{}` with a named field using {{curly braces}} instead of a positional field using (parentheses).",
variant_type,
field_type.to_token_stream()
)
}
_ => {
let field_types = fields.unnamed.iter().map(|f| f.ty.to_token_stream().to_string()).collect::<Vec<_>>().join(", ");
format!(
"The `{}` message should be defined as a struct-style (not tuple-style) enum variant to maintain consistent formatting across all editor messages.\n\
Replace `{}` with named fields using {{curly braces}} instead of positional fields using (parentheses).",
variant_type, field_types
"The `{variant_type}` message should be defined as a struct-style (not tuple-style) enum variant to maintain consistent formatting across all editor messages.\n\
Replace `{field_types}` with named fields using {{curly braces}} instead of positional fields using (parentheses)."
)
}
};