make clippy happy

/I wish someone made *me* happy/
This commit is contained in:
Maybe Waffle 2022-08-14 23:03:56 +04:00
parent b8dc2c7b31
commit c854081dce
5 changed files with 15 additions and 14 deletions

View file

@ -239,7 +239,7 @@ fn intra_links(doc: &mut Doc) {
match () { match () {
_ if k == "games" => {} _ if k == "games" => {}
_ if k == "unbanned" => *v = String::from("crate::payloads::UnbanChatMember"), _ if k == "unbanned" => *v = String::from("crate::payloads::UnbanChatMember"),
_ if c.is_lowercase() && !["update"].contains(&&&**k) => { _ if c.is_lowercase() && !["update"].contains(&&**k) => {
repls_m.push(k.clone()); repls_m.push(k.clone());
*v = format!("crate::payloads::{}", to_uppercase(k)); *v = format!("crate::payloads::{}", to_uppercase(k));
} }

View file

@ -88,6 +88,7 @@
#![cfg_attr(all(feature = "full", docsrs), deny(rustdoc::broken_intra_doc_links))] #![cfg_attr(all(feature = "full", docsrs), deny(rustdoc::broken_intra_doc_links))]
//#![deny(missing_docs)] //#![deny(missing_docs)]
#![warn(clippy::print_stdout, clippy::dbg_macro)] #![warn(clippy::print_stdout, clippy::dbg_macro)]
#![allow(clippy::let_and_return)]
// Unless this becomes machine applicable, I'm not adding 334 #[must_use]s (waffle) // Unless this becomes machine applicable, I'm not adding 334 #[must_use]s (waffle)
#![allow(clippy::return_self_not_must_use)] #![allow(clippy::return_self_not_must_use)]
// Workaround for CI // Workaround for CI

View file

@ -1251,7 +1251,7 @@ fn codegen_requester_forward() {
.map(|(name, _)| &**name) .map(|(name, _)| &**name)
.collect::<Vec<_>>(); .collect::<Vec<_>>();
convert_params.sort(); convert_params.sort_unstable();
let prefixes: IndexMap<_, _> = convert_params let prefixes: IndexMap<_, _> = convert_params
.iter() .iter()
@ -1259,7 +1259,7 @@ fn codegen_requester_forward() {
// Workaround to output the last type as the first letter // Workaround to output the last type as the first letter
.chain(["\0"]) .chain(["\0"])
.tuple_windows() .tuple_windows()
.map(|(l, r)| (l, min_prefix(&l, &r))) .map(|(l, r)| (l, min_prefix(l, r)))
.collect(); .collect();
let args = m let args = m
@ -1287,12 +1287,12 @@ fn codegen_requester_forward() {
Convert::Id(_) => None, Convert::Id(_) => None,
Convert::Into(ty) => Some(format!( Convert::Into(ty) => Some(format!(
"{}: Into<{}>", "{}: Into<{}>",
&to_uppercase(&prefixes[&*p.name]), &to_uppercase(prefixes[&*p.name]),
ty ty
)), )),
Convert::Collect(ty) => Some(format!( Convert::Collect(ty) => Some(format!(
"{}: IntoIterator<Item = {}>", "{}: IntoIterator<Item = {}>",
&to_uppercase(&prefixes[&*p.name]), &to_uppercase(prefixes[&*p.name]),
ty ty
)), )),
}) })

View file

@ -58,14 +58,14 @@ fn codegen_payloads() {
let multipart = multipart_input_file_fields(&method) let multipart = multipart_input_file_fields(&method)
.map(|field| format!(" @[multipart = {}]\n", field.join(", "))) .map(|field| format!(" @[multipart = {}]\n", field.join(", ")))
.unwrap_or(String::new()); .unwrap_or_else(String::new);
let derive = if !multipart.is_empty() let derive = if !multipart.is_empty()
|| matches!( || matches!(
&*method.names.1, &*method.names.1,
"SendMediaGroup" | "EditMessageMedia" | "EditMessageMediaInline" "SendMediaGroup" | "EditMessageMedia" | "EditMessageMediaInline"
) { ) {
format!("#[derive(Debug, Clone, Serialize)]") "#[derive(Debug, Clone, Serialize)]".to_owned()
} else { } else {
format!("#[derive(Debug, PartialEq,{eq_hash_derive}{default_derive} Clone, Serialize)]") format!("#[derive(Debug, PartialEq,{eq_hash_derive}{default_derive} Clone, Serialize)]")
}; };
@ -116,7 +116,7 @@ fn uses(method: &Method) -> String {
| Type::bool | Type::bool
| Type::String => Use::Prelude, | Type::String => Use::Prelude,
Type::Option(inner) | Type::ArrayOf(inner) => ty_use(inner), Type::Option(inner) | Type::ArrayOf(inner) => ty_use(inner),
Type::RawTy(raw) => Use::Crate(["use crate::types::", &raw, ";"].concat()), Type::RawTy(raw) => Use::Crate(["use crate::types::", raw, ";"].concat()),
Type::Url => Use::External(String::from("use url::Url;")), Type::Url => Use::External(String::from("use url::Url;")),
Type::DateTime => Use::External(String::from("use chrono::{DateTime, Utc};")), Type::DateTime => Use::External(String::from("use chrono::{DateTime, Utc};")),
} }
@ -175,7 +175,7 @@ fn render_doc(doc: &Doc, sibling: Option<&str>) -> String {
[ [
" /// ", " /// ",
&doc.md.replace("\n", "\n /// "), &doc.md.replace('\n', "\n /// "),
&sibling_note, &sibling_note,
&links, &links,
] ]
@ -218,7 +218,7 @@ fn params(params: impl Iterator<Item = impl Borrow<Param>>) -> String {
params params
.map(|param| { .map(|param| {
let param = param.borrow(); let param = param.borrow();
let doc = render_doc(&param.descr, None).replace("\n", "\n "); let doc = render_doc(&param.descr, None).replace('\n', "\n ");
let field = &param.name; let field = &param.name;
let ty = &param.ty; let ty = &param.ty;
let flatten = match ty { let flatten = match ty {

View file

@ -1142,7 +1142,7 @@ fn codegen_requester_methods() {
.map(|(name, _)| &**name) .map(|(name, _)| &**name)
.collect::<Vec<_>>(); .collect::<Vec<_>>();
convert_params.sort(); convert_params.sort_unstable();
let prefixes: IndexMap<_, _> = convert_params let prefixes: IndexMap<_, _> = convert_params
.iter() .iter()
@ -1150,7 +1150,7 @@ fn codegen_requester_methods() {
// Workaround to output the last type as the first letter // Workaround to output the last type as the first letter
.chain(["\0"]) .chain(["\0"])
.tuple_windows() .tuple_windows()
.map(|(l, r)| (l, min_prefix(&l, &r))) .map(|(l, r)| (l, min_prefix(l, r)))
.collect(); .collect();
let args = m let args = m
@ -1178,12 +1178,12 @@ fn codegen_requester_methods() {
Convert::Id(_) => None, Convert::Id(_) => None,
Convert::Into(ty) => Some(format!( Convert::Into(ty) => Some(format!(
"{}: Into<{}>", "{}: Into<{}>",
&to_uppercase(&prefixes[&*p.name]), &to_uppercase(prefixes[&*p.name]),
ty ty
)), )),
Convert::Collect(ty) => Some(format!( Convert::Collect(ty) => Some(format!(
"{}: IntoIterator<Item = {}>", "{}: IntoIterator<Item = {}>",
&to_uppercase(&prefixes[&*p.name]), &to_uppercase(prefixes[&*p.name]),
ty ty
)), )),
}) })