Enforce consistent semicolons after ()
-typed expressions in blocks
This commit is contained in:
parent
c1737eb20d
commit
73c2963ebd
@ -28,6 +28,7 @@ rustflags = [
|
||||
"-Wclippy::needless_borrow",
|
||||
"-Aclippy::new_without_default",
|
||||
"-Wclippy::nonstandard_macro_braces",
|
||||
"-Wclippy::semicolon_if_nothing_returned",
|
||||
"-Wclippy::str_to_string",
|
||||
"-Wclippy::todo",
|
||||
"-Wclippy::unreadable_literal",
|
||||
|
@ -47,13 +47,13 @@ mod tests {
|
||||
#[test]
|
||||
fn serialize_filter_events_with_url() {
|
||||
let events_with_url = UrlFilter::EventsWithUrl;
|
||||
assert_eq!(to_json_value(events_with_url).unwrap(), json!(true))
|
||||
assert_eq!(to_json_value(events_with_url).unwrap(), json!(true));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn serialize_filter_events_without_url() {
|
||||
let events_without_url = UrlFilter::EventsWithoutUrl;
|
||||
assert_eq!(to_json_value(events_without_url).unwrap(), json!(false))
|
||||
assert_eq!(to_json_value(events_without_url).unwrap(), json!(false));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -667,7 +667,7 @@ pub mod v3 {
|
||||
assert!(query.contains("since=s72594_4483_1934"));
|
||||
assert!(query.contains("full_state=true"));
|
||||
assert!(query.contains("set_presence=offline"));
|
||||
assert!(query.contains("timeout=30000"))
|
||||
assert!(query.contains("timeout=30000"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -209,7 +209,7 @@ impl<'de> Visitor<'de> for RoomNetworkVisitor {
|
||||
}
|
||||
}
|
||||
"third_party_instance_id" => {
|
||||
third_party_instance_id = value.as_str().map(|v| v.to_owned())
|
||||
third_party_instance_id = value.as_str().map(|v| v.to_owned());
|
||||
}
|
||||
_ => {}
|
||||
};
|
||||
|
@ -622,7 +622,7 @@ mod tests {
|
||||
&& sender == "@alice:example.org"
|
||||
&& state_key == "@alice:example.org"
|
||||
&& unsigned.is_empty()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -231,7 +231,7 @@ mod test {
|
||||
if secret == "org.example.some.secret".into()
|
||||
&& requesting_device_id == "ABCDEFG"
|
||||
&& request_id == "randomly_generated_id_9573"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -251,7 +251,7 @@ mod test {
|
||||
}
|
||||
if requesting_device_id.as_str() == "ABCDEFG"
|
||||
&& request_id == "randomly_generated_id_9573"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -274,7 +274,7 @@ mod test {
|
||||
}
|
||||
if requesting_device_id == "XYZxyz"
|
||||
&& request_id == "this_is_a_request_id"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -295,6 +295,6 @@ mod test {
|
||||
if action == RequestAction::_Custom(PrivOwnedStr("my_custom_action".into()))
|
||||
&& requesting_device_id == "XYZxyz"
|
||||
&& request_id == "this_is_a_request_id"
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ mod tests {
|
||||
if name == *"my_key"
|
||||
&& iv == Base64::parse("YWJjZGVmZ2hpamtsbW5vcA").unwrap()
|
||||
&& mac == Base64::parse("aWRvbnRrbm93d2hhdGFtYWNsb29rc2xpa2U").unwrap()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -216,7 +216,7 @@ mod tests {
|
||||
&& salt == *"rocksalt"
|
||||
&& iterations == uint!(8)
|
||||
&& bits == uint!(256)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -274,6 +274,6 @@ mod tests {
|
||||
&& name == *"my_key"
|
||||
&& iv == Base64::parse("YWJjZGVmZ2hpamtsbW5vcA").unwrap()
|
||||
&& mac == Base64::parse("aWRvbnRrbm93d2hhdGFtYWNsb29rc2xpa2U").unwrap()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ mod tests {
|
||||
if iv == &Base64::parse("YWJjZGVmZ2hpamtsbW5vcA").unwrap()
|
||||
&& ciphertext == &Base64::parse("dGhpc2lzZGVmaW5pdGVseWNpcGhlcnRleHQ").unwrap()
|
||||
&& mac == &Base64::parse("aWRvbnRrbm93d2hhdGFtYWNsb29rc2xpa2U").unwrap()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,6 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn valid_secret() {
|
||||
assert!(<&ClientSecret>::try_from("this_=_a_valid_secret_1337").is_ok())
|
||||
assert!(<&ClientSecret>::try_from("this_=_a_valid_secret_1337").is_ok());
|
||||
}
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ mod tests {
|
||||
<&EventId>::try_from("$acR1l0raoZnm60CBwAVgqbZqoO/mYU81xysh1u7XcJk")
|
||||
.expect("Failed to create EventId."),
|
||||
"$acR1l0raoZnm60CBwAVgqbZqoO/mYU81xysh1u7XcJk"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -103,7 +103,7 @@ mod tests {
|
||||
<&EventId>::try_from("$Rqnc-F-dvnEYJTyHq_iKxU2bZ1CI92-kuZq3a5lr5Zg")
|
||||
.expect("Failed to create EventId."),
|
||||
"$Rqnc-F-dvnEYJTyHq_iKxU2bZ1CI92-kuZq3a5lr5Zg"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(feature = "rand")]
|
||||
|
@ -738,7 +738,7 @@ mod tests {
|
||||
)
|
||||
.unwrap_err(),
|
||||
MatrixToError::UnknownArgument.into()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -33,6 +33,6 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn try_from() {
|
||||
assert!(<&VoipId>::try_from("this_-_a_valid_secret_1337").is_ok())
|
||||
assert!(<&VoipId>::try_from("this_-_a_valid_secret_1337").is_ok());
|
||||
}
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ mod tests {
|
||||
assert_eq!(
|
||||
to_json_string(&json).unwrap(),
|
||||
r#"{"auth":{"mxid":"@john.doe:example.com","profile":{"display_name":"John Doe","three_pids":[{"address":"john.doe@example.org","medium":"email"},{"address":"123456789","medium":"msisdn"}]},"success":true}}"#
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -30,7 +30,7 @@ impl<T> ValOrVec<T> {
|
||||
let existing_val = ptr::read(val);
|
||||
vec.push(existing_val);
|
||||
vec.push(new_val);
|
||||
ptr::write(self, ValOrVec::Vec(vec))
|
||||
ptr::write(self, ValOrVec::Vec(vec));
|
||||
}
|
||||
}
|
||||
ValOrVec::Vec(vec) => vec.push(new_val),
|
||||
|
@ -468,7 +468,7 @@ fn negotiate_event_deserialization() {
|
||||
assert_eq!(content.party_id, "9876");
|
||||
assert_eq!(content.lifetime, uint!(30000));
|
||||
assert_eq!(content.description.session_type, SessionDescriptionType::PrAnswer);
|
||||
assert_eq!(content.description.sdp, "not a real sdp")
|
||||
assert_eq!(content.description.sdp, "not a real sdp");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -131,7 +131,7 @@ fn redacted_aliases_deserialize() {
|
||||
}),
|
||||
)) if event_id == event_id!("$h29iv0s8:example.com")
|
||||
&& aliases.is_none()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -156,7 +156,7 @@ fn redacted_deserialize_any_room() {
|
||||
}),
|
||||
)) if event_id == event_id!("$h29iv0s8:example.com")
|
||||
&& room_id == room_id!("!roomid:room.com")
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -194,7 +194,7 @@ fn redacted_deserialize_any_room_sync() {
|
||||
..
|
||||
}),
|
||||
)) if event_id == event_id!("$h29iv0s8:example.com")
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -226,7 +226,7 @@ fn redacted_state_event_deserialize() {
|
||||
)) if event_id == event_id!("$h29iv0s8:example.com")
|
||||
&& unsigned.redacted_because.is_some()
|
||||
&& creator == user_id!("@carl:example.com")
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -246,7 +246,7 @@ fn redacted_custom_event_serialize() {
|
||||
);
|
||||
|
||||
let x = from_json_value::<AnySyncStateEvent>(redacted).unwrap();
|
||||
assert_eq!(x.event_id(), event_id!("$h29iv0s8:example.com"))
|
||||
assert_eq!(x.event_id(), event_id!("$h29iv0s8:example.com"));
|
||||
}
|
||||
|
||||
/* #[test]
|
||||
|
@ -100,7 +100,7 @@ fn deserialize_list_of_str() {
|
||||
Err(error) if error.to_string().contains("unsupported")
|
||||
);
|
||||
|
||||
assert_eq!(urlencoded::from_str("a=a&a=b"), Ok(vec![("a", vec!["a", "b"])]))
|
||||
assert_eq!(urlencoded::from_str("a=a&a=b"), Ok(vec![("a", vec!["a", "b"])]));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -92,7 +92,7 @@ fn serialize_nested_list() {
|
||||
assert_matches!(
|
||||
urlencoded::to_string(params),
|
||||
Err(Error::Custom(s)) if s.contains("unsupported")
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -329,6 +329,6 @@ impl Parse for EndpointPath {
|
||||
|
||||
impl ToTokens for EndpointPath {
|
||||
fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
|
||||
self.0.to_tokens(tokens)
|
||||
self.0.to_tokens(tokens);
|
||||
}
|
||||
}
|
||||
|
@ -489,6 +489,6 @@ impl Parse for RequestField {
|
||||
|
||||
impl ToTokens for RequestField {
|
||||
fn to_tokens(&self, tokens: &mut TokenStream) {
|
||||
self.field().to_tokens(tokens)
|
||||
self.field().to_tokens(tokens);
|
||||
}
|
||||
}
|
||||
|
@ -256,7 +256,7 @@ impl Parse for ResponseField {
|
||||
|
||||
impl ToTokens for ResponseField {
|
||||
fn to_tokens(&self, tokens: &mut TokenStream) {
|
||||
self.field().to_tokens(tokens)
|
||||
self.field().to_tokens(tokens);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ pub fn collect_lifetime_idents(lifetimes: &mut BTreeSet<Lifetime>, ty: &Type) {
|
||||
}
|
||||
}
|
||||
|
||||
Visitor(lifetimes).visit_type(ty)
|
||||
Visitor(lifetimes).visit_type(ty);
|
||||
}
|
||||
|
||||
pub fn all_cfgs_expr(cfgs: &[Attribute]) -> Option<TokenStream> {
|
||||
|
@ -658,7 +658,7 @@ impl EventEnumVariant {
|
||||
}
|
||||
}
|
||||
if let Some(p) = prefix {
|
||||
tokens.extend(quote! { #p :: })
|
||||
tokens.extend(quote! { #p :: });
|
||||
}
|
||||
self.ident.to_tokens(&mut tokens);
|
||||
|
||||
|
@ -256,7 +256,7 @@ impl Parse for EventEnumEntry {
|
||||
let alias = alias_attr.into_inner();
|
||||
|
||||
if alias.value().ends_with(".*") == has_suffix {
|
||||
aliases.push(alias)
|
||||
aliases.push(alias);
|
||||
} else {
|
||||
return Err(syn::Error::new_spanned(
|
||||
&attr_list,
|
||||
|
@ -160,10 +160,10 @@ fn generate_enum(
|
||||
_s if _s.starts_with(#prefix) => {
|
||||
#ctor(::std::convert::From::from(_s.strip_prefix(#prefix).unwrap()))
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
} else {
|
||||
from_str_match_arms.extend(quote! { #(#attrs)* #(#ev_types)|* => #ctor, })
|
||||
from_str_match_arms.extend(quote! { #(#attrs)* #(#ev_types)|* => #ctor, });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -453,7 +453,7 @@ pub mod v1 {
|
||||
..Notification::default()
|
||||
};
|
||||
|
||||
assert_eq!(expected, to_json_value(notice).unwrap())
|
||||
assert_eq!(expected, to_json_value(notice).unwrap());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -783,7 +783,7 @@ pub fn redact_content_in_place(
|
||||
version: &RoomVersionId,
|
||||
event_type: impl AsRef<str>,
|
||||
) {
|
||||
object_retain_keys(object, allowed_content_keys_for(event_type.as_ref(), version))
|
||||
object_retain_keys(object, allowed_content_keys_for(event_type.as_ref(), version));
|
||||
}
|
||||
|
||||
fn object_retain_keys(object: &mut CanonicalJsonObject, keys: &[&str]) {
|
||||
@ -1065,8 +1065,8 @@ mod tests {
|
||||
|
||||
let verification_result = verify_event(&public_key_map, &signed_event, &RoomVersionId::V9);
|
||||
|
||||
assert!(verification_result.is_err()) // Should be Err(VerificationError::
|
||||
// signature_not_found("domain-authorized")));
|
||||
// Should be Err(VerificationError::signature_not_found("domain-authorized")));
|
||||
assert!(verification_result.is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -1152,7 +1152,9 @@ mod tests {
|
||||
if let Error::Verification(VerificationError::Signature(error)) = error_msg {
|
||||
// dalek doesn't expose InternalError :(
|
||||
// https://github.com/dalek-cryptography/ed25519-dalek/issues/174
|
||||
assert!(format!("{:?}", error).contains("Some(Verification equation was not satisfied)"))
|
||||
assert!(
|
||||
format!("{:?}", error).contains("Some(Verification equation was not satisfied)")
|
||||
);
|
||||
} else {
|
||||
panic!("Error was not VerificationError::Signature: {:?}", error_msg);
|
||||
};
|
||||
|
@ -53,7 +53,7 @@ fn lexico_topo_sort(c: &mut Criterion) {
|
||||
let _ = state_res::lexicographical_topological_sort(&graph, |_id| {
|
||||
Ok((int!(0), MilliSecondsSinceUnixEpoch(uint!(0))))
|
||||
});
|
||||
})
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@ -81,7 +81,7 @@ fn resolution_shallow_auth_chain(c: &mut Criterion) {
|
||||
Ok(state) => state,
|
||||
Err(e) => panic!("{}", e),
|
||||
};
|
||||
})
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@ -139,7 +139,7 @@ fn resolve_deeper_event_set(c: &mut Criterion) {
|
||||
Ok(state) => state,
|
||||
Err(_) => panic!("resolution failed during benchmarking"),
|
||||
};
|
||||
})
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -738,7 +738,7 @@ mod tests {
|
||||
"$END:foo"
|
||||
],
|
||||
sorted_event_ids.iter().map(|id| id.to_string()).collect::<Vec<_>>()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -746,7 +746,7 @@ mod tests {
|
||||
for _ in 0..20 {
|
||||
// since we shuffle the eventIds before we sort them introducing randomness
|
||||
// seems like we should test this a few times
|
||||
test_event_sort()
|
||||
test_event_sort();
|
||||
}
|
||||
}
|
||||
|
||||
@ -794,7 +794,7 @@ mod tests {
|
||||
let expected_state_ids =
|
||||
vec!["PA", "MA", "MB"].into_iter().map(event_id).collect::<Vec<_>>();
|
||||
|
||||
do_check(events, edges, expected_state_ids)
|
||||
do_check(events, edges, expected_state_ids);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -855,7 +855,7 @@ mod tests {
|
||||
|
||||
let expected_state_ids = vec!["PA2", "T2"].into_iter().map(event_id).collect::<Vec<_>>();
|
||||
|
||||
do_check(events, edges, expected_state_ids)
|
||||
do_check(events, edges, expected_state_ids);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -902,7 +902,7 @@ mod tests {
|
||||
let expected_state_ids =
|
||||
vec!["T1", "MB", "PA"].into_iter().map(event_id).collect::<Vec<_>>();
|
||||
|
||||
do_check(events, edges, expected_state_ids)
|
||||
do_check(events, edges, expected_state_ids);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -934,7 +934,7 @@ mod tests {
|
||||
|
||||
let expected_state_ids = vec![event_id("JR")];
|
||||
|
||||
do_check(events, edges, expected_state_ids)
|
||||
do_check(events, edges, expected_state_ids);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -975,7 +975,7 @@ mod tests {
|
||||
|
||||
let expected_state_ids = vec!["PC"].into_iter().map(event_id).collect::<Vec<_>>();
|
||||
|
||||
do_check(events, edges, expected_state_ids)
|
||||
do_check(events, edges, expected_state_ids);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -1052,7 +1052,7 @@ mod tests {
|
||||
|
||||
let expected_state_ids = vec!["T4", "PA2"].into_iter().map(event_id).collect::<Vec<_>>();
|
||||
|
||||
do_check(events, edges, expected_state_ids)
|
||||
do_check(events, edges, expected_state_ids);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -1082,7 +1082,7 @@ mod tests {
|
||||
Err(e) => panic!("{}", e),
|
||||
};
|
||||
|
||||
assert_eq!(expected, resolved)
|
||||
assert_eq!(expected, resolved);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -1109,7 +1109,7 @@ mod tests {
|
||||
.map(ToString::to_string)
|
||||
.map(|s| s.replace('$', "").replace(":foo", ""))
|
||||
.collect::<Vec<_>>()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -1202,9 +1202,9 @@ mod tests {
|
||||
|
||||
for id in expected.iter().map(|i| event_id(i)) {
|
||||
// make sure our resolved events are equal to the expected list
|
||||
assert!(resolved.values().any(|eid| eid == &id) || init.contains_key(&id), "{}", id)
|
||||
assert!(resolved.values().any(|eid| eid == &id) || init.contains_key(&id), "{}", id);
|
||||
}
|
||||
assert_eq!(expected.len(), resolved.len())
|
||||
assert_eq!(expected.len(), resolved.len());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -50,7 +50,11 @@ async fn run() -> Result<(), Box<dyn Error>> {
|
||||
})
|
||||
.await
|
||||
{
|
||||
eprintln!("Failed to persist access token to disk. Re-authentication will be required on the next startup: {}", err)
|
||||
eprintln!(
|
||||
"Failed to persist access token to disk. \
|
||||
Re-authentication will be required on the next startup: {}",
|
||||
err
|
||||
);
|
||||
}
|
||||
client
|
||||
} else {
|
||||
@ -91,14 +95,14 @@ async fn run() -> Result<(), Box<dyn Error>> {
|
||||
if let Err(err) =
|
||||
handle_message(http_client, matrix_client, e, room_id, user_id).await
|
||||
{
|
||||
eprintln!("failed to respond to message: {}", err)
|
||||
eprintln!("failed to respond to message: {}", err);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
let invite_futures = response.rooms.invite.iter().map(|(room_id, _)| async move {
|
||||
if let Err(err) = handle_invitations(http_client, matrix_client, room_id).await {
|
||||
eprintln!("failed to accept invitation for room {}: {}", &room_id, err)
|
||||
eprintln!("failed to accept invitation for room {}: {}", &room_id, err);
|
||||
}
|
||||
});
|
||||
|
||||
@ -240,10 +244,9 @@ async fn read_config() -> io::Result<Config> {
|
||||
"homeserver" => homeserver = Some(value.trim().to_owned()),
|
||||
// TODO: infer domain from `homeserver`
|
||||
"username" => {
|
||||
username =
|
||||
value.trim().to_owned().try_into().map_err(|e| {
|
||||
format!("invalid Matrix user ID format for `username`: {}", e)
|
||||
})
|
||||
username = value.trim().to_owned().try_into().map_err(|e| {
|
||||
format!("invalid Matrix user ID format for `username`: {}", e)
|
||||
});
|
||||
}
|
||||
"password" => password = Some(value.trim().to_owned()),
|
||||
_ => {}
|
||||
@ -256,7 +259,7 @@ async fn read_config() -> io::Result<Config> {
|
||||
(homeserver, username) => {
|
||||
let mut error = String::from("Invalid config specified:");
|
||||
if homeserver.is_none() {
|
||||
error.push_str("\n required field `homeserver` is missing")
|
||||
error.push_str("\n required field `homeserver` is missing");
|
||||
}
|
||||
if let Err(e) = username {
|
||||
error.push_str("\n ");
|
||||
|
Loading…
x
Reference in New Issue
Block a user