fix lints revealed by tracing change

<https://github.com/tokio-rs/tracing/pull/3108> changes #[instrument] so
that several lints that were previously hidden on instrumented functions
are now visible.
This commit is contained in:
Olivia Lee 2025-07-20 13:55:06 -07:00 committed by Charles Hall
parent 13203d3b45
commit 2648991092
12 changed files with 37 additions and 40 deletions

View file

@ -320,7 +320,7 @@ async fn get_remote_content_via_legacy_api(
}
#[tracing::instrument]
pub(crate) async fn get_remote_content(
async fn get_remote_content(
mxc: &MxcData<'_>,
) -> Result<RemoteResponse, Error> {
let fed_result = get_remote_content_via_federation_api(mxc).await;
@ -785,7 +785,7 @@ async fn get_remote_thumbnail_via_legacy_api(
}
#[tracing::instrument]
pub(crate) async fn get_remote_thumbnail(
async fn get_remote_thumbnail(
server_name: &ruma::ServerName,
request: authenticated_media_fed::get_content_thumbnail::v1::Request,
) -> Result<RemoteResponse, Error> {

View file

@ -1521,7 +1521,7 @@ pub(crate) async fn leave_room(
services().rooms.state_cache.update_membership(
room_id,
user_id,
MembershipState::Leave,
&MembershipState::Leave,
user_id,
None,
true,
@ -1575,7 +1575,7 @@ pub(crate) async fn leave_room(
services().rooms.state_cache.update_membership(
room_id,
user_id,
MembershipState::Leave,
&MembershipState::Leave,
user_id,
last_state,
true,

View file

@ -915,6 +915,7 @@ async fn load_joined_room(
})
}
#[allow(clippy::too_many_lines)]
#[tracing::instrument(skip_all)]
async fn collect_left_rooms(
ctx: &SyncContext<'_>,

View file

@ -147,6 +147,7 @@ pub(crate) enum AllowLoopbackRequests {
No,
}
#[allow(clippy::too_many_lines)]
#[tracing::instrument(skip(request, log_error, allow_loopback), fields(url))]
pub(crate) async fn send_request<T>(
destination: &ServerName,
@ -1883,7 +1884,7 @@ pub(crate) async fn create_invite_route(
services().rooms.state_cache.update_membership(
&body.room_id,
&invited_user,
MembershipState::Invite,
&MembershipState::Invite,
&sender,
Some(invite_state),
true,

View file

@ -4,10 +4,9 @@ use ruma::{
canonical_json::redact_content_in_place,
events::{
room::member::RoomMemberEventContent,
space::child::HierarchySpaceChildEvent, AnyEphemeralRoomEvent,
AnyMessageLikeEvent, AnyStateEvent, AnyStrippedStateEvent,
AnySyncStateEvent, AnySyncTimelineEvent, AnyTimelineEvent, StateEvent,
TimelineEventType,
space::child::HierarchySpaceChildEvent, AnyMessageLikeEvent,
AnyStateEvent, AnyStrippedStateEvent, AnySyncStateEvent,
AnySyncTimelineEvent, AnyTimelineEvent, StateEvent, TimelineEventType,
},
serde::Raw,
state_res, CanonicalJsonObject, CanonicalJsonValue, EventId,
@ -60,7 +59,7 @@ impl PduEvent {
#[tracing::instrument(skip(self))]
pub(crate) fn redact(
&mut self,
room_version_id: RoomVersionId,
room_version_id: &RoomVersionId,
reason: &PduEvent,
) -> crate::Result<()> {
self.unsigned = None;
@ -71,7 +70,7 @@ impl PduEvent {
})?;
redact_content_in_place(
&mut content,
&room_version_id,
room_version_id,
self.kind.to_string(),
)
.map_err(|e| {
@ -222,31 +221,6 @@ impl PduEvent {
serde_json::from_value(json).expect("Raw::from_value always works")
}
/// This only works for events that are also AnyRoomEvents.
#[tracing::instrument(skip(self))]
pub(crate) fn to_any_event(&self) -> Raw<AnyEphemeralRoomEvent> {
let mut json = json!({
"content": self.content,
"type": self.kind,
"event_id": self.event_id,
"sender": self.sender,
"origin_server_ts": self.origin_server_ts,
"room_id": self.room_id,
});
if let Some(unsigned) = &self.unsigned {
json["unsigned"] = json!(unsigned);
}
if let Some(state_key) = &self.state_key {
json["state_key"] = json!(state_key);
}
if let Some(redacts) = &self.redacts {
json["redacts"] = json!(redacts);
}
serde_json::from_value(json).expect("Raw::from_value always works")
}
#[tracing::instrument(skip(self))]
pub(crate) fn to_room_event(&self) -> Raw<AnyTimelineEvent> {
let (redacts, content) = self.copy_redacts();

View file

@ -210,6 +210,8 @@ impl Service {
Ok(())
}
// Allowed because this function uses `services()`
#[allow(clippy::unused_self)]
#[tracing::instrument(skip(self, user, ruleset, pdu))]
pub(crate) fn get_actions<'a>(
&self,

View file

@ -182,6 +182,8 @@ impl Service {
}))
}
// Allowed because this function uses `services()`
#[allow(clippy::unused_self)]
#[tracing::instrument(skip(self))]
fn get_auth_chain_inner(
&self,

View file

@ -82,6 +82,7 @@ impl Service {
/// 13. Use state resolution to find new room state
/// 14. Check if the event passes auth based on the "current state" of the
/// room, if not soft fail it
#[allow(clippy::too_many_lines)]
#[tracing::instrument(skip(self, value, is_timeline_event, pub_key_map))]
pub(crate) async fn handle_incoming_pdu<'a>(
&self,
@ -535,6 +536,7 @@ impl Service {
})
}
#[allow(clippy::too_many_lines)]
#[tracing::instrument(skip_all, fields(
incoming_pdu = %incoming_pdu.event_id,
))]
@ -1869,6 +1871,7 @@ impl Service {
/// Search the DB for the signing keys of the given server, if we don't have
/// them fetch them from the server and save to our DB.
#[allow(clippy::too_many_lines)]
#[tracing::instrument(
skip(self, signature_ids),
fields(signature_ids = debug_slice_truncated(&signature_ids, 3))

View file

@ -142,7 +142,7 @@ impl Service {
services().rooms.state_cache.update_membership(
room_id,
&user_id,
membership,
&membership,
&pdu.sender,
None,
false,
@ -319,6 +319,8 @@ impl Service {
/// Gather events to help the invited user identify the room
///
/// Also includes the invite event itself.
// Allowed because this function uses `services()`
#[allow(clippy::unused_self)]
#[tracing::instrument(skip(self, invite_event))]
pub(crate) fn get_helpful_invite_events(
&self,
@ -365,6 +367,8 @@ impl Service {
}
/// Returns the value of a field of an `m.room.create` event's `content`.
// Allowed because this function uses `services()`
#[allow(clippy::unused_self)]
#[tracing::instrument(skip(self))]
pub(crate) fn get_create_content<T: ExtractCreateContent>(
&self,

View file

@ -140,6 +140,8 @@ impl Service {
/// Returns a single PDU from `room_id` with key (`event_type`,
/// `state_key`).
// Allowed because this function uses `services()`
#[allow(clippy::unused_self)]
#[tracing::instrument(skip(self))]
pub(crate) fn state_get_id(
&self,

View file

@ -47,12 +47,14 @@ impl Service {
}
/// Update current membership data.
// Allowed because this function uses `services()`
#[allow(clippy::unused_self)]
#[tracing::instrument(skip(self, last_state))]
pub(crate) fn update_membership(
&self,
room_id: &RoomId,
user_id: &UserId,
membership: MembershipState,
membership: &MembershipState,
sender: &UserId,
last_state: Option<Vec<Raw<AnyStrippedStateEvent>>>,
update_joined_count: bool,
@ -404,6 +406,8 @@ impl Service {
}
/// Returns an iterator over all invited members of a room.
// Unused, but needed for consistency with other methods
#[allow(dead_code)]
#[tracing::instrument(skip(self))]
pub(crate) fn room_members_invited<'a>(
&'a self,
@ -504,6 +508,8 @@ impl Service {
self.db.is_invited(user_id, room_id)
}
// Unused, but needed for consistency with other methods
#[allow(dead_code)]
#[tracing::instrument(skip(self))]
pub(crate) fn is_left(
&self,

View file

@ -277,6 +277,7 @@ impl Service {
/// happens in `append_pdu`.
///
/// Returns pdu id
#[allow(clippy::too_many_lines)]
#[tracing::instrument(skip(self, pdu, pdu_json, leaves))]
pub(crate) async fn append_pdu(
&self,
@ -572,7 +573,7 @@ impl Service {
services().rooms.state_cache.update_membership(
&pdu.room_id,
&target_user_id,
membership,
&membership,
&pdu.sender,
invite_state,
true,
@ -937,6 +938,7 @@ impl Service {
/// Creates a new persisted data unit and adds it to a room. This function
/// takes a roomid_mutex_state, meaning that only this function is able
/// to mutate the room state.
#[allow(clippy::too_many_lines)]
#[tracing::instrument(skip(self))]
pub(crate) async fn build_and_append_pdu(
&self,
@ -1259,7 +1261,7 @@ impl Service {
.rooms
.state
.get_create_content::<ExtractVersion>(&pdu.room_id)?;
pdu.redact(room_version_id, reason)?;
pdu.redact(&room_version_id, reason)?;
self.replace_pdu(
&pdu_id,