matrix-sdk: Fix a bunch of clippy warnings.

master
Damir Jelić 2020-07-15 15:53:17 +02:00
parent 497b973eb5
commit a2a87b9fff
6 changed files with 25 additions and 18 deletions

View File

@ -152,6 +152,12 @@ impl RoomBuilder {
} }
} }
impl Default for RoomBuilder {
fn default() -> Self {
Self::new()
}
}
impl Into<create_room::Request> for RoomBuilder { impl Into<create_room::Request> for RoomBuilder {
fn into(mut self) -> create_room::Request { fn into(mut self) -> create_room::Request {
self.req.creation_content = Some(self.creation_content); self.req.creation_content = Some(self.creation_content);

View File

@ -374,12 +374,12 @@ impl Room {
self.invited_members.remove(target_member); self.invited_members.remove(target_member);
self.joined_members self.joined_members
.insert(target_member.clone(), new_member.clone()) .insert(target_member.clone(), new_member)
} }
MembershipState::Invite => self MembershipState::Invite => self
.invited_members .invited_members
.insert(target_member.clone(), new_member.clone()), .insert(target_member.clone(), new_member),
_ => panic!("Room::add_member called on event that is neither `join` nor `invite`."), _ => panic!("Room::add_member called on event that is neither `join` nor `invite`."),
}; };
@ -416,7 +416,7 @@ impl Room {
// Perform display name disambiguations, if necessary. // Perform display name disambiguations, if necessary.
let disambiguations = let disambiguations =
self.disambiguation_updates(target_member, leaving_member.display_name.clone(), None); self.disambiguation_updates(target_member, leaving_member.display_name, None);
debug!("remove_member: disambiguations: {:#?}", disambiguations); debug!("remove_member: disambiguations: {:#?}", disambiguations);
@ -970,7 +970,7 @@ impl Room {
} }
let disambiguations = let disambiguations =
self.disambiguation_updates(target_member, old_name.clone(), new_name.clone()); self.disambiguation_updates(target_member, old_name, new_name.clone());
for (id, is_ambiguous) in disambiguations.iter() { for (id, is_ambiguous) in disambiguations.iter() {
if self.get_member_mut(id).is_none() { if self.get_member_mut(id).is_none() {
debug!("update_member_profile [{}]: Tried disambiguating display name for {} but he's not there", debug!("update_member_profile [{}]: Tried disambiguating display name for {} but he's not there",

View File

@ -143,9 +143,9 @@ impl RoomMember {
/// `RoomMember::unique_name` in certain situations. /// `RoomMember::unique_name` in certain situations.
pub fn disambiguated_name(&self) -> String { pub fn disambiguated_name(&self) -> String {
if self.display_name_ambiguous { if self.display_name_ambiguous {
self.unique_name().into() self.unique_name()
} else { } else {
self.name().into() self.name()
} }
} }
} }

View File

@ -98,6 +98,7 @@ impl OlmMachine {
/// * `user_id` - The unique id of the user that owns this machine. /// * `user_id` - The unique id of the user that owns this machine.
/// ///
/// * `device_id` - The unique id of the device that owns this machine. /// * `device_id` - The unique id of the device that owns this machine.
#[allow(clippy::ptr_arg)]
pub fn new(user_id: &UserId, device_id: &DeviceId) -> Self { pub fn new(user_id: &UserId, device_id: &DeviceId) -> Self {
OlmMachine { OlmMachine {
user_id: user_id.clone(), user_id: user_id.clone(),

View File

@ -87,6 +87,7 @@ impl Account {
]; ];
/// Create a fresh new account, this will generate the identity key-pair. /// Create a fresh new account, this will generate the identity key-pair.
#[allow(clippy::ptr_arg)]
pub fn new(user_id: &UserId, device_id: &DeviceId) -> Self { pub fn new(user_id: &UserId, device_id: &DeviceId) -> Self {
let account = OlmAccount::new(); let account = OlmAccount::new();
let identity_keys = account.parsed_identity_keys(); let identity_keys = account.parsed_identity_keys();
@ -252,6 +253,7 @@ impl Account {
/// ///
/// * `shared` - Boolean determining if the account was uploaded to the /// * `shared` - Boolean determining if the account was uploaded to the
/// server. /// server.
#[allow(clippy::ptr_arg)]
pub fn from_pickle( pub fn from_pickle(
pickle: String, pickle: String,
pickle_mode: PicklingMode, pickle_mode: PicklingMode,
@ -426,14 +428,12 @@ impl Account {
device: Device, device: Device,
key_map: &BTreeMap<AlgorithmAndDeviceId, OneTimeKey>, key_map: &BTreeMap<AlgorithmAndDeviceId, OneTimeKey>,
) -> Result<Session, SessionCreationError> { ) -> Result<Session, SessionCreationError> {
let one_time_key = let one_time_key = key_map.values().next().ok_or_else(|| {
key_map SessionCreationError::OneTimeKeyMissing(
.values() device.user_id().to_owned(),
.next() device.device_id().to_owned(),
.ok_or(SessionCreationError::OneTimeKeyMissing( )
device.user_id().to_owned(), })?;
device.device_id().to_owned(),
))?;
let one_time_key = match one_time_key { let one_time_key = match one_time_key {
OneTimeKey::SignedKey(k) => k, OneTimeKey::SignedKey(k) => k,
@ -453,12 +453,12 @@ impl Account {
) )
})?; })?;
let curve_key = device.get_key(KeyAlgorithm::Curve25519).ok_or( let curve_key = device.get_key(KeyAlgorithm::Curve25519).ok_or_else(|| {
SessionCreationError::DeviceMissingCurveKey( SessionCreationError::DeviceMissingCurveKey(
device.user_id().to_owned(), device.user_id().to_owned(),
device.device_id().to_owned(), device.device_id().to_owned(),
), )
)?; })?;
self.create_outbound_session_helper(curve_key, &one_time_key) self.create_outbound_session_helper(curve_key, &one_time_key)
.await .await

View File

@ -87,7 +87,7 @@ pub enum CryptoStoreError {
pub type Result<T> = std::result::Result<T, CryptoStoreError>; pub type Result<T> = std::result::Result<T, CryptoStoreError>;
#[async_trait] #[async_trait]
#[warn(clippy::type_complexity)] #[allow(clippy::type_complexity)]
#[cfg_attr(not(target_arch = "wasm32"), send_sync)] #[cfg_attr(not(target_arch = "wasm32"), send_sync)]
/// Trait abstracting a store that the `OlmMachine` uses to store cryptographic /// Trait abstracting a store that the `OlmMachine` uses to store cryptographic
/// keys. /// keys.