mirror of
https://github.com/tokio-rs/axum.git
synced 2025-01-19 07:33:11 +01:00
Enable and fix warnings from clippy::uninlined_format_args (#3063)
This commit is contained in:
parent
b5a0109221
commit
99c07e4d86
8 changed files with 17 additions and 17 deletions
1
.clippy.toml
Normal file
1
.clippy.toml
Normal file
|
@ -0,0 +1 @@
|
|||
allow-mixed-uninlined-format-args = false
|
|
@ -43,6 +43,7 @@ rest_pat_in_fully_bound_structs = "warn"
|
|||
str_to_string = "warn"
|
||||
suboptimal_flops = "warn"
|
||||
todo = "warn"
|
||||
uninlined_format_args = "warn"
|
||||
unnested_or_patterns = "warn"
|
||||
unused_self = "warn"
|
||||
verbose_file_reads = "warn"
|
||||
|
|
|
@ -34,7 +34,7 @@ impl IntoResponse for MultipartForm {
|
|||
// see RFC5758 for details
|
||||
let boundary = generate_boundary();
|
||||
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,
|
||||
// Realistically this should never happen unless the boundary generation code
|
||||
// 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();
|
||||
for part in self.parts {
|
||||
// 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(format!("--{}--", boundary).as_bytes());
|
||||
serialized_form.extend_from_slice(format!("--{boundary}--").as_bytes());
|
||||
(headers, serialized_form).into_response()
|
||||
}
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ impl Part {
|
|||
let mut serialized_part = format!("Content-Disposition: form-data; name=\"{}\"", self.name);
|
||||
// specify a filename if one was set
|
||||
if let Some(filename) = &self.filename {
|
||||
serialized_part += &format!("; filename=\"{}\"", filename);
|
||||
serialized_part += &format!("; filename=\"{filename}\"");
|
||||
}
|
||||
serialized_part += "\r\n";
|
||||
// specify the MIME type
|
||||
|
@ -256,7 +256,7 @@ mod tests {
|
|||
let body: &[u8] = &response.into_body().collect().await?.to_bytes();
|
||||
assert_eq!(
|
||||
std::str::from_utf8(body)?,
|
||||
&format!(
|
||||
format!(
|
||||
"--{boundary}\r\n\
|
||||
Content-Disposition: form-data; name=\"part1\"\r\n\
|
||||
Content-Type: text/plain; charset=utf-8\r\n\
|
||||
|
@ -273,7 +273,6 @@ mod tests {
|
|||
\r\n\
|
||||
rawpart\r\n\
|
||||
--{boundary}--",
|
||||
boundary = boundary
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -285,7 +284,7 @@ mod tests {
|
|||
for _ in 0..256 {
|
||||
let boundary = generate_boundary();
|
||||
let mime_type: Result<Mime, _> =
|
||||
format!("multipart/form-data; boundary={}", boundary).parse();
|
||||
format!("multipart/form-data; boundary={boundary}").parse();
|
||||
assert!(
|
||||
mime_type.is_ok(),
|
||||
"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))
|
||||
.unwrap_or_else(|err| {
|
||||
panic!(
|
||||
"failed to URL encode value of type `{}`: {}",
|
||||
"failed to URL encode value of type `{}`: {err}",
|
||||
type_name::<T>(),
|
||||
err
|
||||
)
|
||||
});
|
||||
f.write_str(&out)?;
|
||||
|
|
|
@ -168,7 +168,7 @@ impl std::fmt::Display for TypedHeaderRejection {
|
|||
write!(f, "Header of type `{}` was missing", self.name)
|
||||
}
|
||||
TypedHeaderRejectionReason::Error(err) => {
|
||||
write!(f, "{} ({})", err, self.name)
|
||||
write!(f, "{err} ({})", self.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -172,7 +172,7 @@ impl BenchmarkBuilder {
|
|||
cmd.stdout(Stdio::piped());
|
||||
|
||||
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(["--threads", "10"]);
|
||||
|
|
|
@ -995,7 +995,7 @@ mod tests {
|
|||
if status != 200 {
|
||||
let body = response.into_body().collect().await.unwrap().to_bytes();
|
||||
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 = TokioIo::new(upgraded);
|
||||
|
|
|
@ -54,33 +54,33 @@ impl TestClient {
|
|||
|
||||
pub(crate) fn get(&self, url: &str) -> 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 {
|
||||
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 {
|
||||
RequestBuilder {
|
||||
builder: self.client.post(format!("http://{}{}", self.addr, url)),
|
||||
builder: self.client.post(format!("http://{}{url}", self.addr)),
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub(crate) fn put(&self, url: &str) -> RequestBuilder {
|
||||
RequestBuilder {
|
||||
builder: self.client.put(format!("http://{}{}", self.addr, url)),
|
||||
builder: self.client.put(format!("http://{}{url}", self.addr)),
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub(crate) fn patch(&self, url: &str) -> RequestBuilder {
|
||||
RequestBuilder {
|
||||
builder: self.client.patch(format!("http://{}{}", self.addr, url)),
|
||||
builder: self.client.patch(format!("http://{}{url}", self.addr)),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue