You've already forked authentication-service
mirror of
https://github.com/matrix-org/matrix-authentication-service.git
synced 2025-07-29 22:01:14 +03:00
ci: Update clippy to 1.66 and fix new warnings
This commit is contained in:
4
.github/workflows/ci.yaml
vendored
4
.github/workflows/ci.yaml
vendored
@ -182,8 +182,8 @@ jobs:
|
||||
|
||||
- name: Install toolchain
|
||||
run: |
|
||||
rustup toolchain install 1.65.0
|
||||
rustup default 1.65.0
|
||||
rustup toolchain install 1.66.0
|
||||
rustup default 1.66.0
|
||||
rustup component add clippy
|
||||
|
||||
- name: Setup OPA
|
||||
|
@ -201,7 +201,7 @@ impl Header for WwwAuthenticate {
|
||||
}
|
||||
};
|
||||
|
||||
let params = params.into_iter().map(|(k, v)| format!(" {}={:?}", k, v));
|
||||
let params = params.into_iter().map(|(k, v)| format!(" {k}={v:?}"));
|
||||
let value: String = std::iter::once(scheme.to_owned()).chain(params).collect();
|
||||
let value = HeaderValue::from_str(&value).unwrap();
|
||||
values.extend(std::iter::once(value));
|
||||
|
@ -58,7 +58,7 @@ fn print_headers(parts: &hyper::http::response::Parts) {
|
||||
);
|
||||
|
||||
for (header, value) in &parts.headers {
|
||||
println!("{}: {:?}", header, value);
|
||||
println!("{header}: {value:?}");
|
||||
}
|
||||
println!();
|
||||
}
|
||||
@ -116,7 +116,7 @@ impl Options {
|
||||
}
|
||||
|
||||
let body = serde_json::to_string_pretty(&body)?;
|
||||
println!("{}", body);
|
||||
println!("{body}");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -90,10 +90,10 @@ impl TokenType {
|
||||
.map(char::from)
|
||||
.collect();
|
||||
|
||||
let base = format!("{}_{}", self.prefix(), random_part);
|
||||
let base = format!("{prefix}_{random_part}", prefix = self.prefix());
|
||||
let crc = CRC.checksum(base.as_bytes());
|
||||
let crc = base62_encode(crc);
|
||||
format!("{}_{}", base, crc)
|
||||
format!("{base}_{crc}")
|
||||
}
|
||||
|
||||
/// Check the format of a token and determine its type
|
||||
@ -126,7 +126,7 @@ impl TokenType {
|
||||
prefix: prefix.to_owned(),
|
||||
})?;
|
||||
|
||||
let base = format!("{}_{}", token_type.prefix(), random_part);
|
||||
let base = format!("{prefix}_{random_part}", prefix = token_type.prefix());
|
||||
let expected_crc = CRC.checksum(base.as_bytes());
|
||||
let expected_crc = base62_encode(expected_crc);
|
||||
if crc != expected_crc {
|
||||
@ -164,7 +164,7 @@ fn base62_encode(mut num: u32) -> String {
|
||||
num /= 62;
|
||||
}
|
||||
|
||||
format!("{:0>6}", res)
|
||||
format!("{res:0>6}")
|
||||
}
|
||||
|
||||
const CRC: Crc<u32> = Crc::<u32>::new(&CRC_32_ISO_HDLC);
|
||||
|
@ -210,7 +210,7 @@ pub(crate) async fn post(
|
||||
}
|
||||
};
|
||||
|
||||
let user_id = format!("@{}:{}", session.user.username, homeserver);
|
||||
let user_id = format!("@{username}:{homeserver}", username = session.user.username);
|
||||
|
||||
// If the client asked for a refreshable token, make it expire
|
||||
let expires_in = if input.refresh_token {
|
||||
|
@ -52,7 +52,7 @@ impl_from_error_for_route!(sqlx::Error);
|
||||
|
||||
impl IntoResponse for RouteError {
|
||||
fn into_response(self) -> axum::response::Response {
|
||||
(StatusCode::INTERNAL_SERVER_ERROR, format!("{}", self)).into_response()
|
||||
(StatusCode::INTERNAL_SERVER_ERROR, format!("{self}")).into_response()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ impl IntoResponse for RouteError {
|
||||
}
|
||||
RouteError::UnknownRedirectUri(e) => (
|
||||
StatusCode::BAD_REQUEST,
|
||||
format!("Invalid redirect URI ({})", e),
|
||||
format!("Invalid redirect URI ({e})"),
|
||||
)
|
||||
.into_response(),
|
||||
}
|
||||
|
@ -40,6 +40,6 @@ pub(super) fn http_flavor(version: Version) -> Cow<'static, str> {
|
||||
Version::HTTP_11 => "1.1".into(),
|
||||
Version::HTTP_2 => "2.0".into(),
|
||||
Version::HTTP_3 => "3.0".into(),
|
||||
other => format!("{:?}", other).into(),
|
||||
other => format!("{other:?}").into(),
|
||||
}
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ impl File {
|
||||
.await?;
|
||||
|
||||
tracing::info!("Writing file");
|
||||
file.write_all(format!("{}", self).as_bytes()).await?;
|
||||
file.write_all(format!("{self}").as_bytes()).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@ -154,7 +154,7 @@ pub enum {} {{"#,
|
||||
for member in list {
|
||||
writeln!(f)?;
|
||||
if let Some(description) = &member.description {
|
||||
writeln!(f, " /// {}", description)?;
|
||||
writeln!(f, " /// {description}")?;
|
||||
} else {
|
||||
writeln!(f, " /// `{}`", member.value)?;
|
||||
}
|
||||
|
@ -333,9 +333,9 @@ impl<'a, T: ?Sized> Equality<'a, T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T1, T2: ?Sized> Validator<T1> for Equality<'a, T2>
|
||||
impl<'a, T1, T2> Validator<T1> for Equality<'a, T2>
|
||||
where
|
||||
T2: PartialEq<T1>,
|
||||
T2: PartialEq<T1> + ?Sized,
|
||||
{
|
||||
type Error = EqualityError;
|
||||
fn validate(&self, value: &T1) -> Result<(), Self::Error> {
|
||||
|
@ -331,7 +331,7 @@ impl<T> Jwt<'static, T> {
|
||||
let payload_ = serde_json::to_vec(&payload).map_err(JwtSignatureError::encode_payload)?;
|
||||
let payload_ = Base64UrlUnpadded::encode_string(&payload_);
|
||||
|
||||
let mut inner = format!("{}.{}", header_, payload_);
|
||||
let mut inner = format!("{header_}.{payload_}");
|
||||
|
||||
let first_dot = header_.len();
|
||||
let second_dot = inner.len();
|
||||
|
@ -84,7 +84,7 @@ mod tests {
|
||||
let res = WebFingerResponse::new("acct:john@example.com".to_owned())
|
||||
.with_issuer(Url::parse("https://account.example.com/").unwrap());
|
||||
|
||||
let res = serde_json::to_value(&res).unwrap();
|
||||
let res = serde_json::to_value(res).unwrap();
|
||||
|
||||
assert_eq!(
|
||||
res,
|
||||
|
@ -406,7 +406,7 @@ fn prepare_claims(
|
||||
/// A request with client credentials added to it.
|
||||
#[derive(Clone, Serialize)]
|
||||
#[skip_serializing_none]
|
||||
pub struct RequestWithClientCredentials<T: Serialize> {
|
||||
pub struct RequestWithClientCredentials<T> {
|
||||
#[serde(flatten)]
|
||||
pub(crate) body: T,
|
||||
#[serde(flatten)]
|
||||
|
@ -32,7 +32,7 @@ pub trait Route {
|
||||
let path = self.path();
|
||||
if let Some(query) = self.query() {
|
||||
let query = serde_urlencoded::to_string(query).unwrap();
|
||||
format!("{}?{}", path, query).into()
|
||||
format!("{path}?{query}").into()
|
||||
} else {
|
||||
path
|
||||
}
|
||||
|
@ -208,7 +208,7 @@ mod tests {
|
||||
};
|
||||
|
||||
let state = form.to_form_state();
|
||||
let state = serde_json::to_value(&state).unwrap();
|
||||
let state = serde_json::to_value(state).unwrap();
|
||||
assert_eq!(
|
||||
state,
|
||||
serde_json::json!({
|
||||
@ -236,7 +236,7 @@ mod tests {
|
||||
.with_error_on_field(TestFormField::Bar, FieldError::Required)
|
||||
.with_error_on_form(FormError::InvalidCredentials);
|
||||
|
||||
let state = serde_json::to_value(&state).unwrap();
|
||||
let state = serde_json::to_value(state).unwrap();
|
||||
assert_eq!(
|
||||
state,
|
||||
serde_json::json!({
|
||||
|
@ -132,7 +132,7 @@ fn function_merge(params: &HashMap<String, Value>) -> Result<Value, tera::Error>
|
||||
for (k, v) in params {
|
||||
let v = v
|
||||
.as_object()
|
||||
.ok_or_else(|| tera::Error::msg(format!("Parameter {:?} should be an object", k)))?;
|
||||
.ok_or_else(|| tera::Error::msg(format!("Parameter {k:?} should be an object")))?;
|
||||
ret.extend(v.clone());
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,7 @@ impl Templates {
|
||||
// This uses blocking I/Os, do that in a blocking task
|
||||
let mut tera = tokio::task::spawn_blocking(move || {
|
||||
let path = path.canonicalize_utf8()?;
|
||||
let path = format!("{}/**/*.{{html,txt,subject}}", path);
|
||||
let path = format!("{path}/**/*.{{html,txt,subject}}");
|
||||
|
||||
info!(%path, "Loading templates from filesystem");
|
||||
Tera::new(&path)
|
||||
|
Reference in New Issue
Block a user