Enforce the redundant_clone Clippy lint rule.

Fixes #3683
This commit is contained in:
Alexis Métaireau
2024-07-10 19:08:04 +02:00
committed by Benjamin Bouvier
parent d9b2b53f83
commit 48f11ea025
22 changed files with 33 additions and 41 deletions
+1
View File
@@ -39,6 +39,7 @@ rustflags = [
"-Wclippy::str_to_string",
"-Wclippy::todo",
"-Wclippy::unused_async",
"-Wclippy::redundant_clone",
]
[target.'cfg(target_arch = "wasm32")']
+1 -1
View File
@@ -434,7 +434,7 @@ fn collect_sessions(
// the session cache after migration) so we don't need to worry about
// signatures.
let device_keys = DeviceKeys::new(
user_id.clone(),
user_id,
device_id.clone(),
Default::default(),
BTreeMap::from([
+1 -1
View File
@@ -287,7 +287,7 @@ pub fn get_element_call_required_permissions(own_user_id: String) -> WidgetCapab
send: vec![
WidgetEventFilter::StateWithTypeAndStateKey {
event_type: StateEventType::CallMember.to_string(),
state_key: own_user_id.clone(),
state_key: own_user_id,
},
WidgetEventFilter::MessageLikeWithType {
event_type: "org.matrix.rageshake_request".to_owned(),
+1 -1
View File
@@ -1413,7 +1413,7 @@ impl BaseClient {
events.get(&StateEventType::RoomMember)?.get(user_id.as_str())?.deserialize().ok()
})
{
member.content.displayname.clone().unwrap_or_else(|| user_id.localpart().to_owned())
member.content.displayname.unwrap_or_else(|| user_id.localpart().to_owned())
} else if let Some(member) = Box::pin(room.get_member(user_id)).await? {
member.name().to_owned()
} else {
+1 -1
View File
@@ -674,7 +674,7 @@ async fn cache_latest_events(
));
// Store it in the return RoomInfo (it will be saved for us in the room later).
room_info.latest_event = Some(latest_event.clone());
room_info.latest_event = Some(latest_event);
// We don't need any of the older encrypted events because we have a new
// decrypted one.
room.latest_encrypted_events.write().unwrap().clear();
@@ -842,7 +842,7 @@ pub(crate) mod tests {
)
.unwrap();
let mut master_key_updated_signature = master_key.clone();
let mut master_key_updated_signature = master_key;
master_key_updated_signature.signatures = Signatures::new();
let updated_identity = ReadOnlyOwnUserIdentity::new(
+1 -1
View File
@@ -152,7 +152,7 @@ pub(crate) mod tests {
let message = bob_session.encrypt_helper(plaintext).await;
let prekey_message = match message.clone() {
let prekey_message = match message {
OlmMessage::PreKey(m) => m,
OlmMessage::Normal(_) => panic!("Incorrect message type"),
};
@@ -342,7 +342,7 @@ impl SecretStorageKey {
}
pub(crate) fn from_bytes(key_id: String, key: Box<[u8; KEY_SIZE]>) -> Self {
let storage_key_info = Self::create_event_content(key_id.to_owned(), &key);
let storage_key_info = Self::create_event_content(key_id, &key);
Self { storage_key_info, secret_key: key }
}
@@ -768,7 +768,7 @@ mod test {
content.passphrase =
Some(PassPhrase::new("salty goodness".to_owned(), UInt::new_saturating(100)));
SecretStorageKey::from_account_data("It's a secret to nobody", content.to_owned())
SecretStorageKey::from_account_data("It's a secret to nobody", content)
.expect("Should accept any passphrase");
}
@@ -50,7 +50,7 @@ pub fn new_filter(pattern: &str) -> impl Filter {
move |room| -> bool {
let Some(room_name) = room.cached_display_name() else { return false };
searcher.matches(&room_name.to_string())
searcher.matches(&room_name)
}
}
@@ -49,7 +49,7 @@ pub fn new_filter(pattern: &str) -> impl Filter {
move |room| -> bool {
let Some(room_name) = room.cached_display_name() else { return false };
searcher.matches(&room_name.to_string())
searcher.matches(&room_name)
}
}
@@ -178,10 +178,7 @@ impl EstablishedSecureChannel {
if response == LOGIN_OK_MESSAGE {
Ok(ret)
} else {
Err(Error::SecureChannelMessage {
expected: LOGIN_OK_MESSAGE,
received: response.to_owned(),
})
Err(Error::SecureChannelMessage { expected: LOGIN_OK_MESSAGE, received: response })
}
}
}
+4 -5
View File
@@ -347,7 +347,7 @@ impl Client {
thumbnail_source,
thumbnail_info
});
let content = assign!(ImageMessageEventContent::encrypted(body.to_owned(), file), {
let content = assign!(ImageMessageEventContent::encrypted(body, file), {
info: Some(Box::new(info)),
formatted: config.formatted_caption,
filename
@@ -355,8 +355,7 @@ impl Client {
MessageType::Image(content)
}
mime::AUDIO => {
let audio_message_event_content =
AudioMessageEventContent::encrypted(body.to_owned(), file);
let audio_message_event_content = AudioMessageEventContent::encrypted(body, file);
MessageType::Audio(crate::media::update_audio_message_event(
audio_message_event_content,
content_type,
@@ -369,7 +368,7 @@ impl Client {
thumbnail_source,
thumbnail_info
});
let content = assign!(VideoMessageEventContent::encrypted(body.to_owned(), file), {
let content = assign!(VideoMessageEventContent::encrypted(body, file), {
info: Some(Box::new(info)),
formatted: config.formatted_caption,
filename
@@ -382,7 +381,7 @@ impl Client {
thumbnail_source,
thumbnail_info
});
let content = assign!(FileMessageEventContent::encrypted(body.to_owned(), file), {
let content = assign!(FileMessageEventContent::encrypted(body, file), {
info: Some(Box::new(info))
});
MessageType::File(content)
@@ -675,7 +675,7 @@ mod tests {
};
return Ok(Messages {
start: opts.from.unwrap().to_owned(),
start: opts.from.unwrap(),
end,
chunk: events,
state: Vec::new(),
+4 -5
View File
@@ -507,14 +507,13 @@ impl Media {
thumbnail_info,
});
let mut image_message_event_content =
ImageMessageEventContent::plain(body.to_owned(), url).info(Box::new(info));
ImageMessageEventContent::plain(body, url).info(Box::new(info));
image_message_event_content.filename = filename;
image_message_event_content.formatted = config.formatted_caption;
MessageType::Image(image_message_event_content)
}
mime::AUDIO => {
let mut audio_message_event_content =
AudioMessageEventContent::plain(body.to_owned(), url);
let mut audio_message_event_content = AudioMessageEventContent::plain(body, url);
audio_message_event_content.filename = filename;
audio_message_event_content.formatted = config.formatted_caption;
MessageType::Audio(update_audio_message_event(
@@ -530,7 +529,7 @@ impl Media {
thumbnail_info
});
let mut video_message_event_content =
VideoMessageEventContent::plain(body.to_owned(), url).info(Box::new(info));
VideoMessageEventContent::plain(body, url).info(Box::new(info));
video_message_event_content.filename = filename;
video_message_event_content.formatted = config.formatted_caption;
MessageType::Video(video_message_event_content)
@@ -542,7 +541,7 @@ impl Media {
thumbnail_info
});
let mut file_message_event_content =
FileMessageEventContent::plain(body.to_owned(), url).info(Box::new(info));
FileMessageEventContent::plain(body, url).info(Box::new(info));
file_message_event_content.filename = filename;
file_message_event_content.formatted = config.formatted_caption;
MessageType::File(file_message_event_content)
+1 -2
View File
@@ -535,8 +535,7 @@ impl Oidc {
// The format of the credentials changes according to the client metadata that
// was sent. Public clients only get a client ID.
let credentials =
ClientCredentials::None { client_id: registration_response.client_id.clone() };
let credentials = ClientCredentials::None { client_id: registration_response.client_id };
self.restore_registered_client(issuer, client_metadata, credentials);
tracing::info!("Persisting OIDC registration data.");
+2 -4
View File
@@ -96,10 +96,8 @@ pub async fn mock_environment(
};
let oidc = Oidc {
client: client.clone(),
backend: Arc::new(
MockImpl::new().mark_insecure().next_session_tokens(session_tokens.clone()),
),
client,
backend: Arc::new(MockImpl::new().mark_insecure().next_session_tokens(session_tokens)),
};
let (client_credentials, client_metadata) = mock_registered_client_data();
+4 -4
View File
@@ -2023,10 +2023,10 @@ mod tests {
// partial overlap).
already_limited.to_owned(),
SlidingSyncRoom::new(
client.clone(),
client,
already_limited.to_owned(),
None,
vec![event_a.clone(), event_b.clone(), event_c.clone()],
vec![event_a, event_b, event_c.clone()],
),
),
]);
@@ -2076,7 +2076,7 @@ mod tests {
assign!(v4::SlidingSyncRoom::default(), {
initial: Some(true),
limited: true,
timeline: vec![event_c.event.clone(), event_d.event.clone()],
timeline: vec![event_c.event, event_d.event],
}),
),
]);
@@ -2248,7 +2248,7 @@ mod tests {
account_data: assign!(v4::AccountData::default(), {
rooms: BTreeMap::from([
(
room_id.clone(),
room_id,
vec![
Raw::from_json_string(
json!({
+1 -1
View File
@@ -80,7 +80,7 @@ pub async fn logged_in_client(homeserver_url: Option<String>) -> Client {
#[cfg(not(target_arch = "wasm32"))]
pub async fn test_client_builder_with_server() -> (ClientBuilder, wiremock::MockServer) {
let server = wiremock::MockServer::start().await;
let builder = test_client_builder(Some(server.uri().to_string()));
let builder = test_client_builder(Some(server.uri()));
(builder, server)
}
+1 -1
View File
@@ -346,7 +346,7 @@ impl WidgetMachine {
let (request, action) = self.send_matrix_driver_request(request);
request.then(|mut result, machine| {
if let Ok(r) = result.as_mut() {
r.set_room_id(machine.room_id.clone().to_owned());
r.set_room_id(machine.room_id.clone());
}
vec![machine.send_from_widget_result_response(raw_request, result)]
});
@@ -80,7 +80,7 @@ fn openid_request_handling_works() {
request_openid_token::v3::Response::new(
"access_token".to_owned(),
TokenType::Bearer,
ServerName::parse("example.org").unwrap().to_owned(),
ServerName::parse("example.org").unwrap(),
Duration::from_secs(3600),
),
)),
+1 -1
View File
@@ -126,7 +126,7 @@ impl MatrixDriver {
(None, Some(future_event_parameters)) => {
let r = future::send_future_message_event::unstable::Request::new_raw(
self.room.room_id().to_owned(),
TransactionId::new().to_owned(),
TransactionId::new(),
MessageLikeEventType::from(type_str),
future_event_parameters,
Raw::<AnyMessageLikeEventContent>::from_json(content),
@@ -244,8 +244,7 @@ impl ClientWrapper {
room.send(RoomMessageEventContent::text_plain(message.to_owned()))
.await
.expect("Sending message failed")
.event_id
.to_owned(),
.event_id,
message.to_owned(),
)
}