mirror of
https://github.com/tokio-rs/axum.git
synced 2026-09-09 00:00:12 +02:00
Enable and fix warnings from clippy::uninlined_format_args (#3063)
This commit is contained in:
@@ -0,0 +1 @@
|
|||||||
|
allow-mixed-uninlined-format-args = false
|
||||||
@@ -43,6 +43,7 @@ rest_pat_in_fully_bound_structs = "warn"
|
|||||||
str_to_string = "warn"
|
str_to_string = "warn"
|
||||||
suboptimal_flops = "warn"
|
suboptimal_flops = "warn"
|
||||||
todo = "warn"
|
todo = "warn"
|
||||||
|
uninlined_format_args = "warn"
|
||||||
unnested_or_patterns = "warn"
|
unnested_or_patterns = "warn"
|
||||||
unused_self = "warn"
|
unused_self = "warn"
|
||||||
verbose_file_reads = "warn"
|
verbose_file_reads = "warn"
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ impl IntoResponse for MultipartForm {
|
|||||||
// see RFC5758 for details
|
// see RFC5758 for details
|
||||||
let boundary = generate_boundary();
|
let boundary = generate_boundary();
|
||||||
let mut headers = HeaderMap::new();
|
let mut headers = HeaderMap::new();
|
||||||
let mime_type: Mime = match format!("multipart/form-data; boundary={}", boundary).parse() {
|
let mime_type: Mime = match format!("multipart/form-data; boundary={boundary}").parse() {
|
||||||
Ok(m) => m,
|
Ok(m) => m,
|
||||||
// Realistically this should never happen unless the boundary generation code
|
// Realistically this should never happen unless the boundary generation code
|
||||||
// is modified, and that will be caught by unit tests
|
// is modified, and that will be caught by unit tests
|
||||||
@@ -51,10 +51,10 @@ impl IntoResponse for MultipartForm {
|
|||||||
let mut serialized_form: Vec<u8> = Vec::new();
|
let mut serialized_form: Vec<u8> = Vec::new();
|
||||||
for part in self.parts {
|
for part in self.parts {
|
||||||
// for each part, the boundary is preceded by two dashes
|
// for each part, the boundary is preceded by two dashes
|
||||||
serialized_form.extend_from_slice(format!("--{}\r\n", boundary).as_bytes());
|
serialized_form.extend_from_slice(format!("--{boundary}\r\n").as_bytes());
|
||||||
serialized_form.extend_from_slice(&part.serialize());
|
serialized_form.extend_from_slice(&part.serialize());
|
||||||
}
|
}
|
||||||
serialized_form.extend_from_slice(format!("--{}--", boundary).as_bytes());
|
serialized_form.extend_from_slice(format!("--{boundary}--").as_bytes());
|
||||||
(headers, serialized_form).into_response()
|
(headers, serialized_form).into_response()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -184,7 +184,7 @@ impl Part {
|
|||||||
let mut serialized_part = format!("Content-Disposition: form-data; name=\"{}\"", self.name);
|
let mut serialized_part = format!("Content-Disposition: form-data; name=\"{}\"", self.name);
|
||||||
// specify a filename if one was set
|
// specify a filename if one was set
|
||||||
if let Some(filename) = &self.filename {
|
if let Some(filename) = &self.filename {
|
||||||
serialized_part += &format!("; filename=\"{}\"", filename);
|
serialized_part += &format!("; filename=\"{filename}\"");
|
||||||
}
|
}
|
||||||
serialized_part += "\r\n";
|
serialized_part += "\r\n";
|
||||||
// specify the MIME type
|
// specify the MIME type
|
||||||
@@ -256,7 +256,7 @@ mod tests {
|
|||||||
let body: &[u8] = &response.into_body().collect().await?.to_bytes();
|
let body: &[u8] = &response.into_body().collect().await?.to_bytes();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
std::str::from_utf8(body)?,
|
std::str::from_utf8(body)?,
|
||||||
&format!(
|
format!(
|
||||||
"--{boundary}\r\n\
|
"--{boundary}\r\n\
|
||||||
Content-Disposition: form-data; name=\"part1\"\r\n\
|
Content-Disposition: form-data; name=\"part1\"\r\n\
|
||||||
Content-Type: text/plain; charset=utf-8\r\n\
|
Content-Type: text/plain; charset=utf-8\r\n\
|
||||||
@@ -273,7 +273,6 @@ mod tests {
|
|||||||
\r\n\
|
\r\n\
|
||||||
rawpart\r\n\
|
rawpart\r\n\
|
||||||
--{boundary}--",
|
--{boundary}--",
|
||||||
boundary = boundary
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -285,7 +284,7 @@ mod tests {
|
|||||||
for _ in 0..256 {
|
for _ in 0..256 {
|
||||||
let boundary = generate_boundary();
|
let boundary = generate_boundary();
|
||||||
let mime_type: Result<Mime, _> =
|
let mime_type: Result<Mime, _> =
|
||||||
format!("multipart/form-data; boundary={}", boundary).parse();
|
format!("multipart/form-data; boundary={boundary}").parse();
|
||||||
assert!(
|
assert!(
|
||||||
mime_type.is_ok(),
|
mime_type.is_ok(),
|
||||||
"The generated boundary was unable to be parsed into a valid mime type."
|
"The generated boundary was unable to be parsed into a valid mime type."
|
||||||
|
|||||||
@@ -299,9 +299,8 @@ where
|
|||||||
.serialize(serde_html_form::ser::Serializer::new(&mut urlencoder))
|
.serialize(serde_html_form::ser::Serializer::new(&mut urlencoder))
|
||||||
.unwrap_or_else(|err| {
|
.unwrap_or_else(|err| {
|
||||||
panic!(
|
panic!(
|
||||||
"failed to URL encode value of type `{}`: {}",
|
"failed to URL encode value of type `{}`: {err}",
|
||||||
type_name::<T>(),
|
type_name::<T>(),
|
||||||
err
|
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
f.write_str(&out)?;
|
f.write_str(&out)?;
|
||||||
|
|||||||
@@ -168,7 +168,7 @@ impl std::fmt::Display for TypedHeaderRejection {
|
|||||||
write!(f, "Header of type `{}` was missing", self.name)
|
write!(f, "Header of type `{}` was missing", self.name)
|
||||||
}
|
}
|
||||||
TypedHeaderRejectionReason::Error(err) => {
|
TypedHeaderRejectionReason::Error(err) => {
|
||||||
write!(f, "{} ({})", err, self.name)
|
write!(f, "{err} ({})", self.name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ impl BenchmarkBuilder {
|
|||||||
cmd.stdout(Stdio::piped());
|
cmd.stdout(Stdio::piped());
|
||||||
|
|
||||||
cmd.arg("--host");
|
cmd.arg("--host");
|
||||||
cmd.arg(format!("http://{}{}", addr, self.path.unwrap_or("")));
|
cmd.arg(format!("http://{addr}{}", self.path.unwrap_or("")));
|
||||||
|
|
||||||
cmd.args(["--connections", "10"]);
|
cmd.args(["--connections", "10"]);
|
||||||
cmd.args(["--threads", "10"]);
|
cmd.args(["--threads", "10"]);
|
||||||
|
|||||||
@@ -995,7 +995,7 @@ mod tests {
|
|||||||
if status != 200 {
|
if status != 200 {
|
||||||
let body = response.into_body().collect().await.unwrap().to_bytes();
|
let body = response.into_body().collect().await.unwrap().to_bytes();
|
||||||
let body = std::str::from_utf8(&body).unwrap();
|
let body = std::str::from_utf8(&body).unwrap();
|
||||||
panic!("response status was {}: {body}", status);
|
panic!("response status was {status}: {body}");
|
||||||
}
|
}
|
||||||
let upgraded = hyper::upgrade::on(response).await.unwrap();
|
let upgraded = hyper::upgrade::on(response).await.unwrap();
|
||||||
let upgraded = TokioIo::new(upgraded);
|
let upgraded = TokioIo::new(upgraded);
|
||||||
|
|||||||
@@ -54,33 +54,33 @@ impl TestClient {
|
|||||||
|
|
||||||
pub(crate) fn get(&self, url: &str) -> RequestBuilder {
|
pub(crate) fn get(&self, url: &str) -> RequestBuilder {
|
||||||
RequestBuilder {
|
RequestBuilder {
|
||||||
builder: self.client.get(format!("http://{}{}", self.addr, url)),
|
builder: self.client.get(format!("http://{}{url}", self.addr)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn head(&self, url: &str) -> RequestBuilder {
|
pub(crate) fn head(&self, url: &str) -> RequestBuilder {
|
||||||
RequestBuilder {
|
RequestBuilder {
|
||||||
builder: self.client.head(format!("http://{}{}", self.addr, url)),
|
builder: self.client.head(format!("http://{}{url}", self.addr)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn post(&self, url: &str) -> RequestBuilder {
|
pub(crate) fn post(&self, url: &str) -> RequestBuilder {
|
||||||
RequestBuilder {
|
RequestBuilder {
|
||||||
builder: self.client.post(format!("http://{}{}", self.addr, url)),
|
builder: self.client.post(format!("http://{}{url}", self.addr)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub(crate) fn put(&self, url: &str) -> RequestBuilder {
|
pub(crate) fn put(&self, url: &str) -> RequestBuilder {
|
||||||
RequestBuilder {
|
RequestBuilder {
|
||||||
builder: self.client.put(format!("http://{}{}", self.addr, url)),
|
builder: self.client.put(format!("http://{}{url}", self.addr)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub(crate) fn patch(&self, url: &str) -> RequestBuilder {
|
pub(crate) fn patch(&self, url: &str) -> RequestBuilder {
|
||||||
RequestBuilder {
|
RequestBuilder {
|
||||||
builder: self.client.patch(format!("http://{}{}", self.addr, url)),
|
builder: self.client.patch(format!("http://{}{url}", self.addr)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user