Fix new clippy warnings

This commit is contained in:
Jonas Platte 2020-11-10 16:48:35 +01:00
parent f2a8dd7a55
commit 0f64a6ea39
No known key found for this signature in database
GPG Key ID: 7D261D771D915378
5 changed files with 42 additions and 41 deletions

View File

@ -149,7 +149,7 @@ fn deserialize_custom_state_event() {
&& origin_server_ts == UNIX_EPOCH + Duration::from_millis(10) && origin_server_ts == UNIX_EPOCH + Duration::from_millis(10)
&& sender == user_id!("@carl:example.com") && sender == user_id!("@carl:example.com")
&& room_id == room_id!("!room:room.com") && room_id == room_id!("!room:room.com")
&& state_key == "" && state_key.is_empty()
&& !unsigned.is_empty() && !unsigned.is_empty()
); );
} }
@ -183,7 +183,7 @@ fn deserialize_custom_state_sync_event() {
&& event_id == event_id!("$h29iv0s8:example.com") && event_id == event_id!("$h29iv0s8:example.com")
&& origin_server_ts == UNIX_EPOCH + Duration::from_millis(10) && origin_server_ts == UNIX_EPOCH + Duration::from_millis(10)
&& sender == user_id!("@carl:example.com") && sender == user_id!("@carl:example.com")
&& state_key == "" && state_key.is_empty()
&& !unsigned.is_empty() && !unsigned.is_empty()
); );
} }

View File

@ -51,7 +51,7 @@ fn serialize_stub_as_v1() {
let json = json!({ let json = json!({
"sender": "@sender:example.com", "sender": "@sender:example.com",
"origin": "matrix.org", "origin": "matrix.org",
"origin_server_ts": 1_592_050_773_658 as usize, "origin_server_ts": 1_592_050_773_658usize,
"type": "m.room.power_levels", "type": "m.room.power_levels",
"content": { "content": {
"testing": 123 "testing": 123
@ -108,7 +108,7 @@ fn serialize_stub_as_v3() {
let json = json!({ let json = json!({
"sender": "@sender:example.com", "sender": "@sender:example.com",
"origin": "matrix.org", "origin": "matrix.org",
"origin_server_ts": 1_592_050_773_658 as usize, "origin_server_ts": 1_592_050_773_658usize,
"type": "m.room.power_levels", "type": "m.room.power_levels",
"content": { "content": {
"testing": 123 "testing": 123
@ -271,7 +271,7 @@ fn serialize_pdu_as_v1() {
"event_id": "$somejoinevent:matrix.org", "event_id": "$somejoinevent:matrix.org",
"sender": "@sender:example.com", "sender": "@sender:example.com",
"origin": "matrix.org", "origin": "matrix.org",
"origin_server_ts": 1_592_050_773_658 as usize, "origin_server_ts": 1_592_050_773_658usize,
"type": "m.room.power_levels", "type": "m.room.power_levels",
"content": { "content": {
"testing": 123 "testing": 123
@ -330,7 +330,7 @@ fn serialize_pdu_as_v3() {
"room_id": "!n8f893n9:example.com", "room_id": "!n8f893n9:example.com",
"sender": "@sender:example.com", "sender": "@sender:example.com",
"origin": "matrix.org", "origin": "matrix.org",
"origin_server_ts": 1_592_050_773_658 as usize, "origin_server_ts": 1_592_050_773_658usize,
"type": "m.room.power_levels", "type": "m.room.power_levels",
"content": { "content": {
"testing": 123 "testing": 123

View File

@ -124,7 +124,7 @@ fn deserialize_aliases_with_prev_content() {
&& prev_content.aliases == vec![room_alias_id!("#inner:localhost")] && prev_content.aliases == vec![room_alias_id!("#inner:localhost")]
&& room_id == room_id!("!roomid:room.com") && room_id == room_id!("!roomid:room.com")
&& sender == user_id!("@carl:example.com") && sender == user_id!("@carl:example.com")
&& state_key == "" && state_key.is_empty()
&& unsigned.is_empty() && unsigned.is_empty()
); );
} }
@ -150,7 +150,7 @@ fn deserialize_aliases_sync_with_room_id() {
&& origin_server_ts == UNIX_EPOCH + Duration::from_millis(1) && origin_server_ts == UNIX_EPOCH + Duration::from_millis(1)
&& prev_content.aliases == vec![room_alias_id!("#inner:localhost")] && prev_content.aliases == vec![room_alias_id!("#inner:localhost")]
&& sender == user_id!("@carl:example.com") && sender == user_id!("@carl:example.com")
&& state_key == "" && state_key.is_empty()
&& unsigned.is_empty() && unsigned.is_empty()
); );
} }
@ -204,7 +204,7 @@ fn deserialize_avatar_without_prev_content() {
&& origin_server_ts == UNIX_EPOCH + Duration::from_millis(1) && origin_server_ts == UNIX_EPOCH + Duration::from_millis(1)
&& room_id == room_id!("!roomid:room.com") && room_id == room_id!("!roomid:room.com")
&& sender == user_id!("@carl:example.com") && sender == user_id!("@carl:example.com")
&& state_key == "" && state_key.is_empty()
&& matches!( && matches!(
info.as_ref(), info.as_ref(),
ImageInfo { ImageInfo {
@ -311,7 +311,7 @@ fn deserialize_full_event_convert_to_sync() {
&& origin_server_ts == UNIX_EPOCH + Duration::from_millis(1) && origin_server_ts == UNIX_EPOCH + Duration::from_millis(1)
&& prev_content.aliases == vec![room_alias_id!("#inner:localhost")] && prev_content.aliases == vec![room_alias_id!("#inner:localhost")]
&& sender == "@carl:example.com" && sender == "@carl:example.com"
&& state_key == "" && state_key.is_empty()
&& unsigned.is_empty() && unsigned.is_empty()
); );
} }

View File

@ -150,7 +150,7 @@ mod tests {
assert_matches!( assert_matches!(
deserialize(json).unwrap(), deserialize(json).unwrap(),
RoomState { origin, auth_chain, state } RoomState { origin, auth_chain, state }
if origin == "" if origin.is_empty()
&& auth_chain.is_empty() && auth_chain.is_empty()
&& state.is_empty() && state.is_empty()
); );

View File

@ -294,6 +294,7 @@ mod tweak_serde {
mod test { mod test {
use std::time::{Duration, SystemTime}; use std::time::{Duration, SystemTime};
use js_int::uint;
use ruma_events::EventType; use ruma_events::EventType;
use ruma_identifiers::{event_id, room_alias_id, room_id, user_id}; use ruma_identifiers::{event_id, room_alias_id, room_id, user_id};
use serde_json::{ use serde_json::{
@ -335,38 +336,38 @@ mod test {
let uid = user_id!("@exampleuser:matrix.org"); let uid = user_id!("@exampleuser:matrix.org");
let alias = room_alias_id!("#exampleroom:matrix.org"); let alias = room_alias_id!("#exampleroom:matrix.org");
let mut count = NotificationCounts::default(); let count = NotificationCounts { unread: uint!(2), ..NotificationCounts::default() };
count.unread = js_int::uint!(2);
// test default values are ignored
count.missed_calls = js_int::uint!(0);
let mut device = Device::new( let device = Device {
"org.matrix.matrixConsole.ios".into(), pushkey_ts: Some(SystemTime::UNIX_EPOCH + Duration::from_secs(123)),
"V2h5IG9uIGVhcnRoIGRpZCB5b3UgZGVjb2RlIHRoaXM/".into(), tweaks: vec![
);
device.pushkey_ts = Some(SystemTime::UNIX_EPOCH + Duration::from_secs(123));
device.tweaks = vec![
Tweak::Highlight(true), Tweak::Highlight(true),
Tweak::Sound("silence".into()), Tweak::Sound("silence".into()),
Tweak::Custom { Tweak::Custom {
name: "custom".into(), name: "custom".into(),
value: from_json_value(JsonValue::String("go wild".into())).unwrap(), value: from_json_value(JsonValue::String("go wild".into())).unwrap(),
}, },
]; ],
..Device::new(
"org.matrix.matrixConsole.ios".into(),
"V2h5IG9uIGVhcnRoIGRpZCB5b3UgZGVjb2RlIHRoaXM/".into(),
)
};
let devices = &[device];
let devices = vec![device]; let notice = Notification {
event_id: Some(&eid),
let mut notice = Notification::default(); room_id: Some(&rid),
notice.event_id = Some(&eid); event_type: Some(&EventType::RoomMessage),
notice.room_id = Some(&rid); sender: Some(&uid),
notice.event_type = Some(&EventType::RoomMessage); sender_display_name: Some("Major Tom"),
notice.sender = Some(&uid); room_alias: Some(&alias),
notice.sender_display_name = Some("Major Tom"); content: Some(serde_json::from_str("{}").unwrap()),
notice.room_alias = Some(&alias); counts: count,
notice.content = Some(serde_json::from_str("{}").unwrap()); prio: NotificationPriority::Low,
notice.counts = count; devices,
notice.prio = NotificationPriority::Low; ..Notification::default()
notice.devices = &devices; };
assert_eq!(expected, to_json_value(notice).unwrap()) assert_eq!(expected, to_json_value(notice).unwrap())
} }