Upgrade Rust to 1.84 and fix new clippy lints

This commit is contained in:
Quentin Gliech
2025-01-23 13:21:59 +01:00
parent e51989b96a
commit 4451cbfe86
10 changed files with 46 additions and 46 deletions

View File

@@ -225,8 +225,8 @@ jobs:
- name: Install toolchain - name: Install toolchain
run: | run: |
rustup toolchain install 1.83.0 rustup toolchain install 1.84.0
rustup default 1.83.0 rustup default 1.84.0
rustup component add clippy rustup component add clippy
- name: Setup OPA - name: Setup OPA

View File

@@ -8,7 +8,7 @@
# The Debian version and version name must be in sync # The Debian version and version name must be in sync
ARG DEBIAN_VERSION=12 ARG DEBIAN_VERSION=12
ARG DEBIAN_VERSION_NAME=bookworm ARG DEBIAN_VERSION_NAME=bookworm
ARG RUSTC_VERSION=1.83.0 ARG RUSTC_VERSION=1.84.0
ARG NODEJS_VERSION=20.15.0 ARG NODEJS_VERSION=20.15.0
ARG OPA_VERSION=0.64.1 ARG OPA_VERSION=0.64.1
ARG CARGO_AUDITABLE_VERSION=0.6.6 ARG CARGO_AUDITABLE_VERSION=0.6.6

View File

@@ -47,8 +47,8 @@ See {DOCS_BASE}/setup/homeserver.html",
if !issuer.starts_with("https://") { if !issuer.starts_with("https://") {
warn!( warn!(
r#"⚠️ The issuer in the config (`http.issuer`/`http.public_base`) is not an HTTPS URL. r"⚠️ The issuer in the config (`http.issuer`/`http.public_base`) is not an HTTPS URL.
This means some clients will refuse to use it."# This means some clients will refuse to use it."
); );
} }

View File

@@ -41,9 +41,9 @@ impl<'a> LazyProviderInfos<'a> {
/// Trigger the discovery process and return the metadata if discovery is /// Trigger the discovery process and return the metadata if discovery is
/// enabled. /// enabled.
pub async fn maybe_discover<'b>( pub async fn maybe_discover(
&'b mut self, &mut self,
) -> Result<Option<&'b VerifiedProviderMetadata>, DiscoveryError> { ) -> Result<Option<&VerifiedProviderMetadata>, DiscoveryError> {
match self.load().await { match self.load().await {
Ok(metadata) => Ok(Some(metadata)), Ok(metadata) => Ok(Some(metadata)),
Err(DiscoveryError::Disabled) => Ok(None), Err(DiscoveryError::Disabled) => Ok(None),
@@ -51,7 +51,7 @@ impl<'a> LazyProviderInfos<'a> {
} }
} }
async fn load<'b>(&'b mut self) -> Result<&'b VerifiedProviderMetadata, DiscoveryError> { async fn load(&mut self) -> Result<&VerifiedProviderMetadata, DiscoveryError> {
if self.loaded_metadata.is_none() { if self.loaded_metadata.is_none() {
let verify = match self.provider.discovery_mode { let verify = match self.provider.discovery_mode {
UpstreamOAuthProviderDiscoveryMode::Oidc => true, UpstreamOAuthProviderDiscoveryMode::Oidc => true,

View File

@@ -429,8 +429,8 @@ pub(crate) async fn get(
let ctx = ErrorContext::new() let ctx = ErrorContext::new()
.with_code("User exists") .with_code("User exists")
.with_description(format!( .with_description(format!(
r#"Upstream account provider returned {localpart:?} as username, r"Upstream account provider returned {localpart:?} as username,
which is not linked to that upstream account"# which is not linked to that upstream account"
)) ))
.with_language(&locale); .with_language(&locale);
@@ -449,8 +449,8 @@ pub(crate) async fn get(
let ctx = ErrorContext::new() let ctx = ErrorContext::new()
.with_code("Policy error") .with_code("Policy error")
.with_description(format!( .with_description(format!(
r#"Upstream account provider returned {localpart:?} as username, r"Upstream account provider returned {localpart:?} as username,
which does not pass the policy check: {res}"# which does not pass the policy check: {res}"
)) ))
.with_language(&locale); .with_language(&locale);
@@ -593,7 +593,7 @@ pub(crate) async fn post(
// Is the email verified according to the upstream provider? // Is the email verified according to the upstream provider?
let provider_email_verified = env let provider_email_verified = env
.render_str("{{ user.email_verified | string }}", &context) .render_str("{{ user.email_verified | string }}", &context)
.map_or(false, |v| v == "true"); .is_ok_and(|v| v == "true");
// Create a template context in case we need to re-render because of an error // Create a template context in case we need to re-render because of an error
let ctx = UpstreamRegister::new(link.clone(), provider.clone()); let ctx = UpstreamRegister::new(link.clone(), provider.clone());

View File

@@ -22,10 +22,10 @@ pub fn struct_def(
) -> std::fmt::Result { ) -> std::fmt::Result {
write!( write!(
f, f,
r#"/// {} r"/// {}
/// ///
/// Source: <{}> /// Source: <{}>
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]"#, #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]",
section.doc, section.doc,
section.url.unwrap(), section.url.unwrap(),
)?; )?;
@@ -33,15 +33,15 @@ pub fn struct_def(
if !is_exhaustive { if !is_exhaustive {
write!( write!(
f, f,
r#" r"
#[non_exhaustive]"# #[non_exhaustive]"
)?; )?;
} }
write!( write!(
f, f,
r#" r"
pub enum {} {{"#, pub enum {} {{",
section.key, section.key,
)?; )?;
for member in list { for member in list {
@@ -72,9 +72,9 @@ pub fn display_impl(
) -> std::fmt::Result { ) -> std::fmt::Result {
write!( write!(
f, f,
r#"impl core::fmt::Display for {} {{ r"impl core::fmt::Display for {} {{
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {{ fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {{
match self {{"#, match self {{",
section.key, section.key,
)?; )?;
@@ -97,10 +97,10 @@ pub fn display_impl(
writeln!( writeln!(
f, f,
r#" r"
}} }}
}} }}
}}"#, }}",
) )
} }
@@ -117,11 +117,11 @@ pub fn from_str_impl(
}; };
write!( write!(
f, f,
r#"impl core::str::FromStr for {} {{ r"impl core::str::FromStr for {} {{
type Err = {err_ty}; type Err = {err_ty};
fn from_str(s: &str) -> Result<Self, Self::Err> {{ fn from_str(s: &str) -> Result<Self, Self::Err> {{
match s {{"#, match s {{",
section.key, section.key,
)?; )?;
@@ -137,23 +137,23 @@ pub fn from_str_impl(
if is_exhaustive { if is_exhaustive {
write!( write!(
f, f,
r#" r"
_ => Err(crate::ParseError::new()),"# _ => Err(crate::ParseError::new()),"
)?; )?;
} else { } else {
write!( write!(
f, f,
r#" r"
value => Ok(Self::Unknown(value.to_owned())),"#, value => Ok(Self::Unknown(value.to_owned())),",
)?; )?;
} }
writeln!( writeln!(
f, f,
r#" r"
}} }}
}} }}
}}"#, }}",
) )
} }
@@ -179,22 +179,22 @@ impl schemars::JsonSchema for {} {{
for member in list { for member in list {
write!( write!(
f, f,
r#" r"
// --- // ---
schemars::schema::SchemaObject {{"#, schemars::schema::SchemaObject {{",
)?; )?;
if let Some(description) = &member.description { if let Some(description) = &member.description {
write!( write!(
f, f,
r#" r"
metadata: Some(Box::new(schemars::schema::Metadata {{ metadata: Some(Box::new(schemars::schema::Metadata {{
description: Some( description: Some(
// --- // ---
{}.to_owned(), {}.to_owned(),
), ),
..Default::default() ..Default::default()
}})),"#, }})),",
raw_string(description), raw_string(description),
)?; )?;
} }
@@ -212,7 +212,7 @@ impl schemars::JsonSchema for {} {{
writeln!( writeln!(
f, f,
r#" r"
]; ];
let description = {}; let description = {};
@@ -229,7 +229,7 @@ impl schemars::JsonSchema for {} {{
}} }}
.into() .into()
}} }}
}}"#, }}",
raw_string(section.doc), raw_string(section.doc),
) )
} }

View File

@@ -75,7 +75,7 @@ impl Display for File {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
writeln!( writeln!(
f, f,
r#"// Copyright 2024 New Vector Ltd. r"// Copyright 2024 New Vector Ltd.
// Copyright 2023, 2024 The Matrix.org Foundation C.I.C. // Copyright 2023, 2024 The Matrix.org Foundation C.I.C.
// //
// SPDX-License-Identifier: AGPL-3.0-only // SPDX-License-Identifier: AGPL-3.0-only
@@ -86,7 +86,7 @@ impl Display for File {
//! Enums from the {:?} IANA registry //! Enums from the {:?} IANA registry
//! See <{}> //! See <{}>
// Do not edit this file manually"#, // Do not edit this file manually",
self.registry_name, self.registry_url, self.registry_name, self.registry_url,
)?; )?;

View File

@@ -217,7 +217,7 @@ where
let tls = stream.tls_info(); let tls = stream.tls_info();
// Figure out if it's HTTP/2 based on the negociated ALPN info // Figure out if it's HTTP/2 based on the negociated ALPN info
let is_h2 = tls.as_ref().map_or(false, TlsStreamInfo::is_alpn_h2); let is_h2 = tls.as_ref().is_some_and(TlsStreamInfo::is_alpn_h2);
let info = ConnectionInfo { let info = ConnectionInfo {
tls, tls,

View File

@@ -1,11 +1,11 @@
{ {
"db_name": "PostgreSQL", "db_name": "PostgreSQL",
"query": "\n SELECT\n queue_schedules.schedule_name,\n queue_schedules.last_scheduled_at,\n queue_jobs.status IN ('completed', 'failed') as last_scheduled_job_completed\n FROM queue_schedules\n LEFT JOIN queue_jobs\n ON queue_jobs.queue_job_id = queue_schedules.last_scheduled_job_id\n ", "query": "\n SELECT\n queue_schedules.schedule_name as \"schedule_name!\",\n queue_schedules.last_scheduled_at,\n queue_jobs.status IN ('completed', 'failed') as last_scheduled_job_completed\n FROM queue_schedules\n LEFT JOIN queue_jobs\n ON queue_jobs.queue_job_id = queue_schedules.last_scheduled_job_id\n ",
"describe": { "describe": {
"columns": [ "columns": [
{ {
"ordinal": 0, "ordinal": 0,
"name": "schedule_name", "name": "schedule_name!",
"type_info": "Text" "type_info": "Text"
}, },
{ {
@@ -23,10 +23,10 @@
"Left": [] "Left": []
}, },
"nullable": [ "nullable": [
false, true,
true, true,
null null
] ]
}, },
"hash": "9ad4e6e9bfedea476d1f47753e4738455e94eade48ad5f577e53278cc70dc266" "hash": "fcd8b4b9e003d1540357c6bf1ff9c715560d011d4c01112703a9c046170c84f1"
} }

View File

@@ -69,7 +69,7 @@ impl QueueScheduleRepository for PgQueueScheduleRepository<'_> {
ScheduleLookup, ScheduleLookup,
r#" r#"
SELECT SELECT
queue_schedules.schedule_name, queue_schedules.schedule_name as "schedule_name!",
queue_schedules.last_scheduled_at, queue_schedules.last_scheduled_at,
queue_jobs.status IN ('completed', 'failed') as last_scheduled_job_completed queue_jobs.status IN ('completed', 'failed') as last_scheduled_job_completed
FROM queue_schedules FROM queue_schedules