Upgrade to Rust 1.83.0 and fix new warnings

This commit is contained in:
Quentin Gliech
2024-12-05 17:03:26 +01:00
parent 02eabc3554
commit ee6472178a
34 changed files with 52 additions and 54 deletions

View File

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

View File

@@ -8,11 +8,11 @@
# 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.82.0 ARG RUSTC_VERSION=1.83.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.4 ARG CARGO_AUDITABLE_VERSION=0.6.6
ARG CARGO_CHEF_VERSION=0.1.67 ARG CARGO_CHEF_VERSION=0.1.68
########################################## ##########################################
## Build stage that builds the frontend ## ## Build stage that builds the frontend ##

View File

@@ -19,7 +19,7 @@ pub fn find_in_stmt<'a>(context: &mut Context, stmt: &'a Stmt<'a>) -> Result<(),
Stmt::EmitRaw(_raw) => {} Stmt::EmitRaw(_raw) => {}
Stmt::ForLoop(for_loop) => { Stmt::ForLoop(for_loop) => {
find_in_expr(context, &for_loop.iter)?; find_in_expr(context, &for_loop.iter)?;
find_in_optional_expr(context, &for_loop.filter_expr)?; find_in_optional_expr(context, for_loop.filter_expr.as_ref())?;
find_in_expr(context, &for_loop.target)?; find_in_expr(context, &for_loop.target)?;
find_in_stmts(context, &for_loop.body)?; find_in_stmts(context, &for_loop.body)?;
find_in_stmts(context, &for_loop.else_body)?; find_in_stmts(context, &for_loop.else_body)?;
@@ -66,7 +66,7 @@ pub fn find_in_stmt<'a>(context: &mut Context, stmt: &'a Stmt<'a>) -> Result<(),
find_in_expr(context, &from_import.expr)?; find_in_expr(context, &from_import.expr)?;
for (name, alias) in &from_import.names { for (name, alias) in &from_import.names {
find_in_expr(context, name)?; find_in_expr(context, name)?;
find_in_optional_expr(context, alias)?; find_in_optional_expr(context, alias.as_ref())?;
} }
} }
Stmt::Extends(extends) => { Stmt::Extends(extends) => {
@@ -185,9 +185,9 @@ fn find_in_expr<'a>(context: &mut Context, expr: &'a Expr<'a>) -> Result<(), min
Expr::Const(_const) => {} Expr::Const(_const) => {}
Expr::Slice(slice) => { Expr::Slice(slice) => {
find_in_expr(context, &slice.expr)?; find_in_expr(context, &slice.expr)?;
find_in_optional_expr(context, &slice.start)?; find_in_optional_expr(context, slice.start.as_ref())?;
find_in_optional_expr(context, &slice.stop)?; find_in_optional_expr(context, slice.stop.as_ref())?;
find_in_optional_expr(context, &slice.step)?; find_in_optional_expr(context, slice.step.as_ref())?;
} }
Expr::UnaryOp(unary_op) => { Expr::UnaryOp(unary_op) => {
find_in_expr(context, &unary_op.expr)?; find_in_expr(context, &unary_op.expr)?;
@@ -199,10 +199,10 @@ fn find_in_expr<'a>(context: &mut Context, expr: &'a Expr<'a>) -> Result<(), min
Expr::IfExpr(if_expr) => { Expr::IfExpr(if_expr) => {
find_in_expr(context, &if_expr.test_expr)?; find_in_expr(context, &if_expr.test_expr)?;
find_in_expr(context, &if_expr.true_expr)?; find_in_expr(context, &if_expr.true_expr)?;
find_in_optional_expr(context, &if_expr.false_expr)?; find_in_optional_expr(context, if_expr.false_expr.as_ref())?;
} }
Expr::Filter(filter) => { Expr::Filter(filter) => {
find_in_optional_expr(context, &filter.expr)?; find_in_optional_expr(context, filter.expr.as_ref())?;
find_in_call_args(context, &filter.args)?; find_in_call_args(context, &filter.args)?;
} }
Expr::Test(test) => { Expr::Test(test) => {
@@ -241,7 +241,7 @@ fn find_in_exprs<'a>(context: &mut Context, exprs: &'a [Expr<'a>]) -> Result<(),
fn find_in_optional_expr<'a>( fn find_in_optional_expr<'a>(
context: &mut Context, context: &mut Context,
expr: &'a Option<Expr<'a>>, expr: Option<&'a Expr<'a>>,
) -> Result<(), minijinja::Error> { ) -> Result<(), minijinja::Error> {
if let Some(expr) = expr { if let Some(expr) = expr {
find_in_expr(context, expr)?; find_in_expr(context, expr)?;

View File

@@ -483,7 +483,7 @@ pub enum FormattedMessagePart<'a> {
Placeholder(String), Placeholder(String),
} }
impl<'a> FormattedMessagePart<'a> { impl FormattedMessagePart<'_> {
fn len(&self) -> usize { fn len(&self) -> usize {
match self { match self {
FormattedMessagePart::Text(text) => text.len(), FormattedMessagePart::Text(text) => text.len(),

View File

@@ -334,7 +334,7 @@ impl<'a> TokenHash<'a> {
} }
} }
impl<'a> Validator<String> for TokenHash<'a> { impl Validator<String> for TokenHash<'_> {
type Error = TokenHashError; type Error = TokenHashError;
fn validate(&self, value: &String) -> Result<(), Self::Error> { fn validate(&self, value: &String) -> Result<(), Self::Error> {
if hash_token(self.alg, self.token)? == *value { if hash_token(self.alg, self.token)? == *value {
@@ -362,7 +362,7 @@ impl<'a, T: ?Sized> Equality<'a, T> {
} }
} }
impl<'a, T1, T2> Validator<T1> for Equality<'a, T2> impl<T1, T2> Validator<T1> for Equality<'_, T2>
where where
T2: PartialEq<T1> + ?Sized, T2: PartialEq<T1> + ?Sized,
{ {
@@ -399,7 +399,7 @@ impl<'a, T> Contains<'a, T> {
#[error("OneOrMany doesn't contain value")] #[error("OneOrMany doesn't contain value")]
pub struct ContainsError; pub struct ContainsError;
impl<'a, T> Validator<OneOrMany<T>> for Contains<'a, T> impl<T> Validator<OneOrMany<T>> for Contains<'_, T>
where where
T: PartialEq, T: PartialEq,
{ {

View File

@@ -91,7 +91,7 @@ pub trait Constrainable {
fn kty(&self) -> JsonWebKeyType; fn kty(&self) -> JsonWebKeyType;
} }
impl<'a> Constraint<'a> { impl Constraint<'_> {
fn decide<T: Constrainable>(&self, constrainable: &T) -> ConstraintDecision { fn decide<T: Constrainable>(&self, constrainable: &T) -> ConstraintDecision {
match self { match self {
Constraint::Alg { constraint_alg } => { Constraint::Alg { constraint_alg } => {

View File

@@ -25,7 +25,7 @@ impl RawJwt<'static> {
} }
} }
impl<'a> std::fmt::Display for RawJwt<'a> { impl std::fmt::Display for RawJwt<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.inner) write!(f, "{}", self.inner)
} }
@@ -57,7 +57,7 @@ impl<'a> RawJwt<'a> {
} }
} }
impl<'a> Deref for RawJwt<'a> { impl Deref for RawJwt<'_> {
type Target = str; type Target = str;
fn deref(&self) -> &Self::Target { fn deref(&self) -> &Self::Target {

View File

@@ -21,13 +21,13 @@ pub struct Jwt<'a, T> {
signature: Vec<u8>, signature: Vec<u8>,
} }
impl<'a, T> std::fmt::Display for Jwt<'a, T> { impl<T> std::fmt::Display for Jwt<'_, T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.raw) write!(f, "{}", self.raw)
} }
} }
impl<'a, T> std::fmt::Debug for Jwt<'a, T> impl<T> std::fmt::Debug for Jwt<'_, T>
where where
T: std::fmt::Debug, T: std::fmt::Debug,
{ {

View File

@@ -354,11 +354,9 @@ impl PrivateKey {
pkcs8::EncryptedPrivateKeyInfo::PEM_LABEL => { pkcs8::EncryptedPrivateKeyInfo::PEM_LABEL => {
let info = pkcs8::EncryptedPrivateKeyInfo::from_der(&doc)?; let info = pkcs8::EncryptedPrivateKeyInfo::from_der(&doc)?;
let decrypted = info.decrypt(password)?; let decrypted = info.decrypt(password)?;
return Self::load_der(decrypted.as_bytes()).map_err(|inner| { Self::load_der(decrypted.as_bytes()).map_err(|inner| LoadError::InEncrypted {
LoadError::InEncrypted { inner: Box::new(inner),
inner: Box::new(inner), })
}
});
} }
pkcs1::RsaPrivateKey::PEM_LABEL pkcs1::RsaPrivateKey::PEM_LABEL

View File

@@ -229,7 +229,7 @@ impl Manifest {
&'a self, &'a self,
current_entry: &'a ManifestEntry, current_entry: &'a ManifestEntry,
entries: &mut BTreeSet<Asset<'a>>, entries: &mut BTreeSet<Asset<'a>>,
) -> Result<Asset, InvalidManifest<'a>> { ) -> Result<Asset<'a>, InvalidManifest<'a>> {
let asset = Asset::new(current_entry)?; let asset = Asset::new(current_entry)?;
let inserted = entries.insert(asset); let inserted = entries.insert(asset);

View File

@@ -245,7 +245,7 @@ fn split_filter(
} }
#[async_trait] #[async_trait]
impl<'c> AppSessionRepository for PgAppSessionRepository<'c> { impl AppSessionRepository for PgAppSessionRepository<'_> {
type Error = DatabaseError; type Error = DatabaseError;
#[allow(clippy::too_many_lines)] #[allow(clippy::too_many_lines)]

View File

@@ -50,7 +50,7 @@ impl From<CompatAccessTokenLookup> for CompatAccessToken {
} }
#[async_trait] #[async_trait]
impl<'c> CompatAccessTokenRepository for PgCompatAccessTokenRepository<'c> { impl CompatAccessTokenRepository for PgCompatAccessTokenRepository<'_> {
type Error = DatabaseError; type Error = DatabaseError;
#[tracing::instrument( #[tracing::instrument(

View File

@@ -59,7 +59,7 @@ impl From<CompatRefreshTokenLookup> for CompatRefreshToken {
} }
#[async_trait] #[async_trait]
impl<'c> CompatRefreshTokenRepository for PgCompatRefreshTokenRepository<'c> { impl CompatRefreshTokenRepository for PgCompatRefreshTokenRepository<'_> {
type Error = DatabaseError; type Error = DatabaseError;
#[tracing::instrument( #[tracing::instrument(

View File

@@ -260,7 +260,7 @@ impl Filter for CompatSessionFilter<'_> {
} }
#[async_trait] #[async_trait]
impl<'c> CompatSessionRepository for PgCompatSessionRepository<'c> { impl CompatSessionRepository for PgCompatSessionRepository<'_> {
type Error = DatabaseError; type Error = DatabaseError;
#[tracing::instrument( #[tracing::instrument(

View File

@@ -128,7 +128,7 @@ impl Filter for CompatSsoLoginFilter<'_> {
} }
#[async_trait] #[async_trait]
impl<'c> CompatSsoLoginRepository for PgCompatSsoLoginRepository<'c> { impl CompatSsoLoginRepository for PgCompatSsoLoginRepository<'_> {
type Error = DatabaseError; type Error = DatabaseError;
#[tracing::instrument( #[tracing::instrument(

View File

@@ -26,7 +26,7 @@ impl<'c> PgJobRepository<'c> {
} }
#[async_trait] #[async_trait]
impl<'c> JobRepository for PgJobRepository<'c> { impl JobRepository for PgJobRepository<'_> {
type Error = DatabaseError; type Error = DatabaseError;
#[tracing::instrument( #[tracing::instrument(

View File

@@ -57,7 +57,7 @@ impl From<OAuth2AccessTokenLookup> for AccessToken {
} }
#[async_trait] #[async_trait]
impl<'c> OAuth2AccessTokenRepository for PgOAuth2AccessTokenRepository<'c> { impl OAuth2AccessTokenRepository for PgOAuth2AccessTokenRepository<'_> {
type Error = DatabaseError; type Error = DatabaseError;
async fn lookup(&mut self, id: Ulid) -> Result<Option<AccessToken>, Self::Error> { async fn lookup(&mut self, id: Ulid) -> Result<Option<AccessToken>, Self::Error> {

View File

@@ -192,7 +192,7 @@ impl TryFrom<GrantLookup> for AuthorizationGrant {
} }
#[async_trait] #[async_trait]
impl<'c> OAuth2AuthorizationGrantRepository for PgOAuth2AuthorizationGrantRepository<'c> { impl OAuth2AuthorizationGrantRepository for PgOAuth2AuthorizationGrantRepository<'_> {
type Error = DatabaseError; type Error = DatabaseError;
#[tracing::instrument( #[tracing::instrument(

View File

@@ -251,7 +251,7 @@ impl TryInto<Client> for OAuth2ClientLookup {
} }
#[async_trait] #[async_trait]
impl<'c> OAuth2ClientRepository for PgOAuth2ClientRepository<'c> { impl OAuth2ClientRepository for PgOAuth2ClientRepository<'_> {
type Error = DatabaseError; type Error = DatabaseError;
#[tracing::instrument( #[tracing::instrument(

View File

@@ -138,7 +138,7 @@ impl TryFrom<OAuth2DeviceGrantLookup> for DeviceCodeGrant {
} }
#[async_trait] #[async_trait]
impl<'c> OAuth2DeviceCodeGrantRepository for PgOAuth2DeviceCodeGrantRepository<'c> { impl OAuth2DeviceCodeGrantRepository for PgOAuth2DeviceCodeGrantRepository<'_> {
type Error = DatabaseError; type Error = DatabaseError;
#[tracing::instrument( #[tracing::instrument(

View File

@@ -57,7 +57,7 @@ impl From<OAuth2RefreshTokenLookup> for RefreshToken {
} }
#[async_trait] #[async_trait]
impl<'c> OAuth2RefreshTokenRepository for PgOAuth2RefreshTokenRepository<'c> { impl OAuth2RefreshTokenRepository for PgOAuth2RefreshTokenRepository<'_> {
type Error = DatabaseError; type Error = DatabaseError;
#[tracing::instrument( #[tracing::instrument(

View File

@@ -137,7 +137,7 @@ impl Filter for OAuth2SessionFilter<'_> {
} }
#[async_trait] #[async_trait]
impl<'c> OAuth2SessionRepository for PgOAuth2SessionRepository<'c> { impl OAuth2SessionRepository for PgOAuth2SessionRepository<'_> {
type Error = DatabaseError; type Error = DatabaseError;
#[tracing::instrument( #[tracing::instrument(

View File

@@ -105,7 +105,7 @@ impl Filter for UpstreamOAuthLinkFilter<'_> {
} }
#[async_trait] #[async_trait]
impl<'c> UpstreamOAuthLinkRepository for PgUpstreamOAuthLinkRepository<'c> { impl UpstreamOAuthLinkRepository for PgUpstreamOAuthLinkRepository<'_> {
type Error = DatabaseError; type Error = DatabaseError;
#[tracing::instrument( #[tracing::instrument(

View File

@@ -209,7 +209,7 @@ impl Filter for UpstreamOAuthProviderFilter<'_> {
} }
#[async_trait] #[async_trait]
impl<'c> UpstreamOAuthProviderRepository for PgUpstreamOAuthProviderRepository<'c> { impl UpstreamOAuthProviderRepository for PgUpstreamOAuthProviderRepository<'_> {
type Error = DatabaseError; type Error = DatabaseError;
#[tracing::instrument( #[tracing::instrument(

View File

@@ -110,7 +110,7 @@ impl TryFrom<SessionLookup> for UpstreamOAuthAuthorizationSession {
} }
#[async_trait] #[async_trait]
impl<'c> UpstreamOAuthSessionRepository for PgUpstreamOAuthSessionRepository<'c> { impl UpstreamOAuthSessionRepository for PgUpstreamOAuthSessionRepository<'_> {
type Error = DatabaseError; type Error = DatabaseError;
#[tracing::instrument( #[tracing::instrument(

View File

@@ -116,7 +116,7 @@ impl Filter for UserEmailFilter<'_> {
} }
#[async_trait] #[async_trait]
impl<'c> UserEmailRepository for PgUserEmailRepository<'c> { impl UserEmailRepository for PgUserEmailRepository<'_> {
type Error = DatabaseError; type Error = DatabaseError;
#[tracing::instrument( #[tracing::instrument(

View File

@@ -110,7 +110,7 @@ impl Filter for UserFilter<'_> {
} }
#[async_trait] #[async_trait]
impl<'c> UserRepository for PgUserRepository<'c> { impl UserRepository for PgUserRepository<'_> {
type Error = DatabaseError; type Error = DatabaseError;
#[tracing::instrument( #[tracing::instrument(

View File

@@ -37,7 +37,7 @@ struct UserPasswordLookup {
} }
#[async_trait] #[async_trait]
impl<'c> UserPasswordRepository for PgUserPasswordRepository<'c> { impl UserPasswordRepository for PgUserPasswordRepository<'_> {
type Error = DatabaseError; type Error = DatabaseError;
#[tracing::instrument( #[tracing::instrument(

View File

@@ -77,7 +77,7 @@ impl From<UserRecoveryTicketRow> for UserRecoveryTicket {
} }
#[async_trait] #[async_trait]
impl<'c> UserRecoveryRepository for PgUserRecoveryRepository<'c> { impl UserRecoveryRepository for PgUserRecoveryRepository<'_> {
type Error = DatabaseError; type Error = DatabaseError;
#[tracing::instrument( #[tracing::instrument(

View File

@@ -149,7 +149,7 @@ impl crate::filter::Filter for BrowserSessionFilter<'_> {
} }
#[async_trait] #[async_trait]
impl<'c> BrowserSessionRepository for PgBrowserSessionRepository<'c> { impl BrowserSessionRepository for PgBrowserSessionRepository<'_> {
type Error = DatabaseError; type Error = DatabaseError;
#[tracing::instrument( #[tracing::instrument(

View File

@@ -29,7 +29,7 @@ impl<'c> PgUserTermsRepository<'c> {
} }
#[async_trait] #[async_trait]
impl<'c> UserTermsRepository for PgUserTermsRepository<'c> { impl UserTermsRepository for PgUserTermsRepository<'_> {
type Error = DatabaseError; type Error = DatabaseError;
#[tracing::instrument( #[tracing::instrument(

View File

@@ -95,7 +95,7 @@ pub struct UpstreamOAuthProviderFilter<'a> {
_lifetime: PhantomData<&'a ()>, _lifetime: PhantomData<&'a ()>,
} }
impl<'a> UpstreamOAuthProviderFilter<'a> { impl UpstreamOAuthProviderFilter<'_> {
/// Create a new [`UpstreamOAuthProviderFilter`] with default values /// Create a new [`UpstreamOAuthProviderFilter`] with default values
#[must_use] #[must_use]
pub fn new() -> Self { pub fn new() -> Self {

View File

@@ -63,7 +63,7 @@ pub struct UserFilter<'a> {
_phantom: std::marker::PhantomData<&'a ()>, _phantom: std::marker::PhantomData<&'a ()>,
} }
impl<'a> UserFilter<'a> { impl UserFilter<'_> {
/// Create a new [`UserFilter`] with default values /// Create a new [`UserFilter`] with default values
#[must_use] #[must_use]
pub fn new() -> Self { pub fn new() -> Self {

View File

@@ -56,7 +56,7 @@ where
T: 'static, T: 'static,
{ {
type Iter<'a> = Box<dyn Iterator<Item = KeyValue> + 'a>; type Iter<'a> = Box<dyn Iterator<Item = KeyValue> + 'a>;
fn attributes<'a>(&'a self, t: &'a T) -> Self::Iter<'_> { fn attributes<'a>(&'a self, t: &'a T) -> Self::Iter<'a> {
Box::new(self.iter().flat_map(|v| v.attributes(t))) Box::new(self.iter().flat_map(|v| v.attributes(t)))
} }
} }
@@ -67,7 +67,7 @@ where
T: 'static, T: 'static,
{ {
type Iter<'a> = Box<dyn Iterator<Item = KeyValue> + 'a>; type Iter<'a> = Box<dyn Iterator<Item = KeyValue> + 'a>;
fn attributes<'a>(&'a self, t: &'a T) -> Self::Iter<'_> { fn attributes<'a>(&'a self, t: &'a T) -> Self::Iter<'a> {
Box::new(self.iter().flat_map(|v| v.attributes(t))) Box::new(self.iter().flat_map(|v| v.attributes(t)))
} }
} }
@@ -100,7 +100,7 @@ where
{ {
type Iter<'a> = std::iter::Flatten<std::option::IntoIter<V::Iter<'a>>>; type Iter<'a> = std::iter::Flatten<std::option::IntoIter<V::Iter<'a>>>;
fn attributes<'a>(&'a self, t: &'a T) -> Self::Iter<'_> { fn attributes<'a>(&'a self, t: &'a T) -> Self::Iter<'a> {
self.as_ref().map(|v| v.attributes(t)).into_iter().flatten() self.as_ref().map(|v| v.attributes(t)).into_iter().flatten()
} }
} }