Skip to content

Commit

Permalink
server: Enable rust_2018_idioms lint
Browse files Browse the repository at this point in the history
  • Loading branch information
svix-jplatte committed Feb 28, 2024
1 parent c0e44d5 commit 0a28132
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 11 deletions.
3 changes: 3 additions & 0 deletions server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
members = ["svix-server", "svix-server_derive"]
resolver = "2"

[workspace.lints.rust]
rust_2018_idioms = "warn"

[workspace.lints.clippy]
dbg_macro = "warn"
todo = "warn"
Expand Down
2 changes: 1 addition & 1 deletion server/svix-server/src/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ pub enum Environment {
}

impl std::fmt::Display for Environment {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"{}",
Expand Down
2 changes: 1 addition & 1 deletion server/svix-server/src/core/webhook_http_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl WebhookClient {
&self,
request: Request,
retry: bool,
) -> BoxFuture<Result<Response<Body>, Error>> {
) -> BoxFuture<'_, Result<Response<Body>, Error>> {
async move {
let org_req = request.clone();
if let Some(auth) = request.uri.authority() {
Expand Down
6 changes: 3 additions & 3 deletions server/svix-server/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ impl Error {
}

impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.typ.fmt(f)
}
}
Expand Down Expand Up @@ -229,7 +229,7 @@ pub enum ErrorType {
}

impl fmt::Display for ErrorType {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Generic(s) => s.fmt(f),
Self::Database(s) => s.fmt(f),
Expand Down Expand Up @@ -372,7 +372,7 @@ impl From<HttpError> for Error {
}

impl fmt::Display for HttpError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match &self.body {
HttpErrorBody::Standard(StandardHttpError { code, detail }) => write!(
f,
Expand Down
6 changes: 3 additions & 3 deletions server/svix-server/src/redis/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub enum RedisPool {
}

impl RedisPool {
pub async fn get(&self) -> Result<PooledConnection, RunError<RedisError>> {
pub async fn get(&self) -> Result<PooledConnection<'_>, RunError<RedisError>> {
match self {
Self::Clustered(pool) => pool.get().await,
Self::NonClustered(pool) => pool.get().await,
Expand All @@ -28,7 +28,7 @@ pub struct ClusteredRedisPool {
}

impl ClusteredRedisPool {
pub async fn get(&self) -> Result<PooledConnection, RunError<RedisError>> {
pub async fn get(&self) -> Result<PooledConnection<'_>, RunError<RedisError>> {
let con = ClusteredPooledConnection {
con: self.pool.get().await?,
};
Expand All @@ -42,7 +42,7 @@ pub struct NonClusteredRedisPool {
}

impl NonClusteredRedisPool {
pub async fn get(&self) -> Result<PooledConnection, RunError<RedisError>> {
pub async fn get(&self) -> Result<PooledConnection<'_>, RunError<RedisError>> {
let con = self.pool.get().await?;
let con = NonClusteredPooledConnection { con };
Ok(PooledConnection::NonClustered(con))
Expand Down
2 changes: 1 addition & 1 deletion server/svix-server/src/v1/endpoints/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ Logout an app token.
Trying to log out other tokens will fail.
"#;

fn logout_operation(op: TransformOperation) -> TransformOperation {
fn logout_operation(op: TransformOperation<'_>) -> TransformOperation<'_> {
op.id("logout_api_v1_auth_logout__post")
.summary("Logout")
.description(LOGOUT_DESCRIPTION)
Expand Down
8 changes: 6 additions & 2 deletions server/svix-server/src/v1/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -630,11 +630,15 @@ pub fn validate_no_control_characters_unrequired(
}
}

pub fn openapi_tag<T: AsRef<str>>(tag: T) -> impl Fn(TransformPathItem) -> TransformPathItem {
pub fn openapi_tag<T: AsRef<str>>(
tag: T,
) -> impl Fn(TransformPathItem<'_>) -> TransformPathItem<'_> {
move |op| op.tag(tag.as_ref())
}

pub fn openapi_desc<T: AsRef<str>>(desc: T) -> impl Fn(TransformOperation) -> TransformOperation {
pub fn openapi_desc<T: AsRef<str>>(
desc: T,
) -> impl Fn(TransformOperation<'_>) -> TransformOperation<'_> {
move |op| op.description(desc.as_ref())
}

Expand Down

0 comments on commit 0a28132

Please sign in to comment.