Skip to content
This repository has been archived by the owner on Aug 16, 2023. It is now read-only.

Commit

Permalink
Elide lifetime in trait def
Browse files Browse the repository at this point in the history
  • Loading branch information
0nkery committed Jun 7, 2023
1 parent 79b4227 commit 7cbd69b
Show file tree
Hide file tree
Showing 17 changed files with 72 additions and 76 deletions.
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## -----------------------------------------------------------------------------
## Build
## -----------------------------------------------------------------------------
FROM rust:1.68.0-slim-buster as build-stage
FROM rust:1.70.0-slim-buster as build-stage

RUN apt update && apt install -y --no-install-recommends \
pkg-config \
Expand Down
4 changes: 2 additions & 2 deletions docker/migration.dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM rust:1.68.0-slim-buster
FROM rust:1.70.0-slim-buster

RUN apt update && apt install -y --no-install-recommends \
pkg-config \
libssl-dev \
libcurl4-openssl-dev \
libpq-dev

RUN cargo install sqlx-cli --version 0.5.7 --no-default-features --features postgres
RUN cargo install sqlx-cli --version 0.6.3 --no-default-features --features postgres
WORKDIR /app
CMD ["cargo", "sqlx", "migrate", "run"]
COPY ./migrations /app/migrations
Expand Down
12 changes: 6 additions & 6 deletions src/app/endpoint/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ pub(crate) struct ListHandler;
impl RequestHandler for ListHandler {
type Payload = ListRequest;

async fn handle<'a, C: Context + Sync + Send>(
context: &'a mut C,
async fn handle<C: Context + Sync + Send>(
context: &mut C,
Self::Payload { room_id, payload }: Self::Payload,
reqp: RequestParams<'a>,
reqp: RequestParams<'_>,
) -> RequestResult {
let room = helpers::find_room(context, room_id, helpers::RoomTimeRequirement::Open).await?;

Expand Down Expand Up @@ -173,10 +173,10 @@ impl RequestHandler for UpdateHandler {
type Payload = UpdateRequest;

#[instrument(skip_all, fields(scope, room_id, classroom_id))]
async fn handle<'a, C: Context + Sync + Send>(
context: &'a mut C,
async fn handle<C: Context + Sync + Send>(
context: &mut C,
Self::Payload { room_id, payload }: Self::Payload,
reqp: RequestParams<'a>,
reqp: RequestParams<'_>,
) -> RequestResult {
let room = helpers::find_room(context, room_id, helpers::RoomTimeRequirement::Open).await?;

Expand Down
6 changes: 3 additions & 3 deletions src/app/endpoint/ban.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ pub(crate) struct ListHandler;
impl RequestHandler for ListHandler {
type Payload = ListRequest;

async fn handle<'a, C: Context + Sync + Send>(
context: &'a mut C,
async fn handle<C: Context + Sync + Send>(
context: &mut C,
Self::Payload { room_id }: Self::Payload,
reqp: RequestParams<'a>,
reqp: RequestParams<'_>,
) -> RequestResult {
let room = helpers::find_room(context, room_id, helpers::RoomTimeRequirement::Open).await?;

Expand Down
6 changes: 3 additions & 3 deletions src/app/endpoint/change/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ impl RequestHandler for CreateHandler {
scope, room_id, classroom_id, change_id
)
)]
async fn handle<'a, C: Context + Sync + Send>(
context: &'a mut C,
async fn handle<C: Context + Sync + Send>(
context: &mut C,
payload: Self::Payload,
reqp: RequestParams<'a>,
reqp: RequestParams<'_>,
) -> RequestResult {
let (_edition, room) = {
let query = db::edition::FindWithRoomQuery::new(payload.edition_id);
Expand Down
6 changes: 3 additions & 3 deletions src/app/endpoint/change/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ impl RequestHandler for DeleteHandler {
scope, room_id, classroom_id, edition_id
)
)]
async fn handle<'a, C: Context + Sync + Send>(
context: &'a mut C,
async fn handle<C: Context + Sync + Send>(
context: &mut C,
payload: Self::Payload,
reqp: RequestParams<'a>,
reqp: RequestParams<'_>,
) -> RequestResult {
let (change, room) = {
let query = db::change::FindWithRoomQuery::new(payload.id);
Expand Down
6 changes: 3 additions & 3 deletions src/app/endpoint/change/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ impl RequestHandler for ListHandler {
type Payload = ListRequest;

#[instrument(skip_all, fields(edition_id, scope, room_id, classroom_id, change_id))]
async fn handle<'a, C: Context + Sync + Send>(
context: &'a mut C,
async fn handle<C: Context + Sync + Send>(
context: &mut C,
Self::Payload { id, payload }: Self::Payload,
reqp: RequestParams<'a>,
reqp: RequestParams<'_>,
) -> RequestResult {
Span::current().record("edition_id", &display(id));
let (edition, room) = {
Expand Down
6 changes: 3 additions & 3 deletions src/app/endpoint/edition/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ impl RequestHandler for CommitHandler {
type Payload = CommitRequest;

#[instrument(skip_all, fields(edition_id, offset, room_id, scope, classroom_id,))]
async fn handle<'a, C: Context + Sync + Send>(
context: &'a mut C,
async fn handle<C: Context + Sync + Send>(
context: &mut C,
CommitRequest {
id,
payload: CommitPayload { offset },
}: Self::Payload,
reqp: RequestParams<'a>,
reqp: RequestParams<'_>,
) -> RequestResult {
Span::current().record("edition_id", &display(id));
Span::current().record("offset", &display(offset));
Expand Down
6 changes: 3 additions & 3 deletions src/app/endpoint/edition/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ impl RequestHandler for CreateHandler {
scope, classroom_id, edition_id
)
)]
async fn handle<'a, C: Context + Sync + Send>(
context: &'a mut C,
async fn handle<C: Context + Sync + Send>(
context: &mut C,
payload: Self::Payload,
reqp: RequestParams<'a>,
reqp: RequestParams<'_>,
) -> RequestResult {
let room =
helpers::find_room(context, payload.room_id, helpers::RoomTimeRequirement::Any).await?;
Expand Down
6 changes: 3 additions & 3 deletions src/app/endpoint/edition/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ impl RequestHandler for DeleteHandler {
room_id, scope, classroom_id
)
)]
async fn handle<'a, C: Context + Sync + Send>(
context: &'a mut C,
async fn handle<C: Context + Sync + Send>(
context: &mut C,
payload: Self::Payload,
reqp: RequestParams<'a>,
reqp: RequestParams<'_>,
) -> RequestResult {
let (edition, room) = {
let query = db::edition::FindWithRoomQuery::new(payload.id);
Expand Down
6 changes: 3 additions & 3 deletions src/app/endpoint/edition/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ impl RequestHandler for ListHandler {
type Payload = ListRequest;

#[instrument(skip_all, fields(room_id, scope, classroom_id))]
async fn handle<'a, C: Context + Sync + Send>(
context: &'a mut C,
async fn handle<C: Context + Sync + Send>(
context: &mut C,
Self::Payload { room_id, payload }: Self::Payload,
reqp: RequestParams<'a>,
reqp: RequestParams<'_>,
) -> RequestResult {
let room = helpers::find_room(context, room_id, helpers::RoomTimeRequirement::Any).await?;

Expand Down
12 changes: 6 additions & 6 deletions src/app/endpoint/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ impl RequestHandler for CreateHandler {
type Payload = CreateRequest;

#[instrument(skip_all, fields(room_id, scope, classroom_id))]
async fn handle<'a, C: Context + Sync + Send>(
context: &'a mut C,
async fn handle<C: Context + Sync + Send>(
context: &mut C,
Self::Payload { room_id, payload }: Self::Payload,
reqp: RequestParams<'a>,
reqp: RequestParams<'_>,
) -> RequestResult {
let (room, author) = {
let room =
Expand Down Expand Up @@ -355,10 +355,10 @@ impl RequestHandler for ListHandler {
type Payload = ListRequest;

#[instrument(skip_all, fields(room_id, scope, classroom_id))]
async fn handle<'a, C: Context + Sync + Send>(
context: &'a mut C,
async fn handle<C: Context + Sync + Send>(
context: &mut C,
Self::Payload { room_id, payload }: Self::Payload,
reqp: RequestParams<'a>,
reqp: RequestParams<'_>,
) -> RequestResult {
let room = helpers::find_room(context, room_id, helpers::RoomTimeRequirement::Any).await?;

Expand Down
10 changes: 3 additions & 7 deletions src/app/endpoint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,10 @@ pub(crate) type MqttResult = StdResult<MessageStream, AppError>;
pub(crate) trait RequestHandler {
type Payload: Send + DeserializeOwned;

// this lifetime is not elided (e.g. RequestParams<'_')
// to avoid ICE with some rustc versions
// tested on 1.67 and 1.69
// maybe other versions have this ICE as well
async fn handle<'a, C: Context + Sync + Send>(
context: &'a mut C,
async fn handle<C: Context + Sync + Send>(
context: &mut C,
payload: Self::Payload,
reqp: RequestParams<'a>,
reqp: RequestParams<'_>,
) -> RequestResult;
}

Expand Down
42 changes: 21 additions & 21 deletions src/app/endpoint/room.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ impl RequestHandler for CreateHandler {
type Payload = CreateRequest;

#[instrument(skip_all, fields(room_id, scope, classroom_id))]
async fn handle<'a, C: Context + Sync + Send>(
context: &'a mut C,
async fn handle<C: Context + Sync + Send>(
context: &mut C,
payload: Self::Payload,
reqp: RequestParams<'a>,
reqp: RequestParams<'_>,
) -> RequestResult {
// Validate opening time.
match RoomTime::new(payload.time) {
Expand Down Expand Up @@ -195,10 +195,10 @@ impl RequestHandler for ReadHandler {
room_id = %payload.id, scope, classroom_id
)
)]
async fn handle<'a, C: Context + Sync + Send>(
context: &'a mut C,
async fn handle<C: Context + Sync + Send>(
context: &mut C,
payload: Self::Payload,
reqp: RequestParams<'a>,
reqp: RequestParams<'_>,
) -> RequestResult {
let room =
helpers::find_room(context, payload.id, helpers::RoomTimeRequirement::Any).await?;
Expand Down Expand Up @@ -269,10 +269,10 @@ impl RequestHandler for UpdateHandler {
type Payload = UpdateRequest;

#[instrument(skip_all, fields(room_id, scope, classroom_id))]
async fn handle<'a, C: Context + Sync + Send>(
context: &'a mut C,
async fn handle<C: Context + Sync + Send>(
context: &mut C,
Self::Payload { id, payload }: Self::Payload,
reqp: RequestParams<'a>,
reqp: RequestParams<'_>,
) -> RequestResult {
let time_requirement = if payload.time.is_some() {
// Forbid changing time of a closed room.
Expand Down Expand Up @@ -430,10 +430,10 @@ impl RequestHandler for EnterHandler {
room_id = %payload.id, scope, classroom_id
)
)]
async fn handle<'a, C: Context + Sync + Send>(
context: &'a mut C,
async fn handle<C: Context + Sync + Send>(
context: &mut C,
payload: Self::Payload,
reqp: RequestParams<'a>,
reqp: RequestParams<'_>,
) -> RequestResult {
let room =
helpers::find_room(context, payload.id, helpers::RoomTimeRequirement::Open).await?;
Expand Down Expand Up @@ -582,10 +582,10 @@ impl RequestHandler for LockedTypesHandler {
type Payload = LockedTypesRequest;

#[instrument(skip_all, fields(room_id, scope, classroom_id))]
async fn handle<'a, C: Context + Sync + Send>(
context: &'a mut C,
async fn handle<C: Context + Sync + Send>(
context: &mut C,
Self::Payload { id, payload }: Self::Payload,
reqp: RequestParams<'a>,
reqp: RequestParams<'_>,
) -> RequestResult {
// Find realtime room.
let room = helpers::find_room(context, id, helpers::RoomTimeRequirement::Any).await?;
Expand Down Expand Up @@ -696,10 +696,10 @@ impl RequestHandler for WhiteboardAccessHandler {
type Payload = WhiteboardAccessRequest;

#[instrument(skip_all, fields(room_id, scope, classroom_id))]
async fn handle<'a, C: Context + Sync + Send>(
context: &'a mut C,
async fn handle<C: Context + Sync + Send>(
context: &mut C,
Self::Payload { id, payload }: Self::Payload,
reqp: RequestParams<'a>,
reqp: RequestParams<'_>,
) -> RequestResult {
// Find realtime room.
let room = helpers::find_room(context, id, helpers::RoomTimeRequirement::Any).await?;
Expand Down Expand Up @@ -819,10 +819,10 @@ impl RequestHandler for AdjustHandler {
type Payload = AdjustRequest;

#[instrument(skip_all, fields(room_id, scope, classroom_id))]
async fn handle<'a, C: Context + Sync + Send>(
context: &'a mut C,
async fn handle<C: Context + Sync + Send>(
context: &mut C,
Self::Payload { id, payload }: Self::Payload,
reqp: RequestParams<'a>,
reqp: RequestParams<'_>,
) -> RequestResult {
// Find realtime room.
let room = helpers::find_room(context, id, helpers::RoomTimeRequirement::Any).await?;
Expand Down
6 changes: 3 additions & 3 deletions src/app/endpoint/room/dump_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ pub(crate) struct EventsDumpHandler;
impl RequestHandler for EventsDumpHandler {
type Payload = EventsDumpRequest;

async fn handle<'a, C: Context + Sync + Send>(
context: &'a mut C,
async fn handle<C: Context + Sync + Send>(
context: &mut C,
payload: Self::Payload,
reqp: RequestParams<'a>,
reqp: RequestParams<'_>,
) -> RequestResult {
let room =
helpers::find_room(context, payload.id, helpers::RoomTimeRequirement::Any).await?;
Expand Down
6 changes: 3 additions & 3 deletions src/app/endpoint/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ impl RequestHandler for ReadHandler {
type Payload = ReadRequest;

#[instrument(skip_all, fields(room_id, scope, classroom_id))]
async fn handle<'a, C: Context + Sync + Send>(
context: &'a mut C,
async fn handle<C: Context + Sync + Send>(
context: &mut C,
Self::Payload { room_id, payload }: Self::Payload,
reqp: RequestParams<'a>,
reqp: RequestParams<'_>,
) -> RequestResult {
Span::current().record("room_id", &display(room_id));

Expand Down
6 changes: 3 additions & 3 deletions src/app/endpoint/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ pub(crate) struct VacuumHandler;
impl RequestHandler for VacuumHandler {
type Payload = VacuumRequest;

async fn handle<'a, C: Context + Sync + Send>(
context: &'a mut C,
async fn handle<C: Context + Sync + Send>(
context: &mut C,
_payload: Self::Payload,
reqp: RequestParams<'a>,
reqp: RequestParams<'_>,
) -> RequestResult {
// Authz: only trusted subjects.
let authz_time = context
Expand Down

0 comments on commit 7cbd69b

Please sign in to comment.