Fix clippy lints
Automated using `cargo clippy --fix`.
This commit is contained in:
parent
f22857e682
commit
c7e84c5249
@ -433,7 +433,7 @@ mod tests {
|
||||
#[test]
|
||||
fn room_filter_definition_roundtrip() -> serde_json::Result<()> {
|
||||
let filter = RoomFilter::default();
|
||||
let room_filter = to_json_value(&filter)?;
|
||||
let room_filter = to_json_value(filter)?;
|
||||
|
||||
let incoming_room_filter = from_json_value::<IncomingRoomFilter>(room_filter)?;
|
||||
assert!(incoming_room_filter.is_empty());
|
||||
|
@ -315,6 +315,6 @@ mod tests {
|
||||
json!({ "city": "London", "street": "10 Downing Street" }).try_into().unwrap();
|
||||
|
||||
assert_eq!(format!("{json}"), CANONICAL_STR);
|
||||
assert_eq!(format!("{:#}", json), CANONICAL_STR);
|
||||
assert_eq!(format!("{json:#}"), CANONICAL_STR);
|
||||
}
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ mod tests {
|
||||
}
|
||||
});
|
||||
|
||||
assert_eq!(to_json_value(&content).unwrap(), json);
|
||||
assert_eq!(to_json_value(content).unwrap(), json);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -49,8 +49,7 @@ impl EventId {
|
||||
#[cfg(feature = "rand")]
|
||||
#[allow(clippy::new_ret_no_self)]
|
||||
pub fn new(server_name: &ServerName) -> OwnedEventId {
|
||||
Self::from_borrowed(&format!("${}:{}", super::generate_localpart(18), server_name))
|
||||
.to_owned()
|
||||
Self::from_borrowed(&format!("${}:{server_name}", super::generate_localpart(18))).to_owned()
|
||||
}
|
||||
|
||||
/// Returns the event's unique ID.
|
||||
|
@ -30,8 +30,7 @@ impl RoomId {
|
||||
#[cfg(feature = "rand")]
|
||||
#[allow(clippy::new_ret_no_self)]
|
||||
pub fn new(server_name: &ServerName) -> OwnedRoomId {
|
||||
Self::from_borrowed(&format!("!{}:{}", super::generate_localpart(18), server_name))
|
||||
.to_owned()
|
||||
Self::from_borrowed(&format!("!{}:{server_name}", super::generate_localpart(18))).to_owned()
|
||||
}
|
||||
|
||||
/// Returns the rooms's unique ID.
|
||||
|
@ -206,7 +206,7 @@ impl StrExt for str {
|
||||
let end = index + self.char_len(index);
|
||||
let char_str = &self[index..end];
|
||||
char::from_str(char_str)
|
||||
.unwrap_or_else(|_| panic!("Could not convert str '{}' to char", char_str))
|
||||
.unwrap_or_else(|_| panic!("Could not convert str '{char_str}' to char"))
|
||||
}
|
||||
|
||||
fn find_prev_char(&self, index: usize) -> Option<char> {
|
||||
|
@ -772,7 +772,7 @@ fn lang_serialization() {
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(
|
||||
to_json_value(&content).unwrap(),
|
||||
to_json_value(content).unwrap(),
|
||||
json!({
|
||||
"org.matrix.msc1767.message": [
|
||||
{ "body": "Bonjour le monde !", "mimetype": "text/plain", "lang": "fr"},
|
||||
|
@ -100,7 +100,7 @@ impl Parse for Metadata {
|
||||
}
|
||||
|
||||
let missing_field =
|
||||
|name| syn::Error::new_spanned(metadata_kw, format!("missing field `{}`", name));
|
||||
|name| syn::Error::new_spanned(metadata_kw, format!("missing field `{name}`"));
|
||||
|
||||
// Construct the History object.
|
||||
let history = {
|
||||
|
@ -393,7 +393,7 @@ fn generate_redacted_event_content<'a>(
|
||||
let serde = quote! { #ruma_common::exports::serde };
|
||||
let serde_json = quote! { #ruma_common::exports::serde_json };
|
||||
|
||||
let doc = format!("Redacted form of [`{}`]", ident);
|
||||
let doc = format!("Redacted form of [`{ident}`]");
|
||||
let redacted_ident = format_ident!("Redacted{ident}");
|
||||
|
||||
let kept_redacted_fields: Vec<_> = fields
|
||||
@ -450,7 +450,7 @@ fn generate_redacted_event_content<'a>(
|
||||
};
|
||||
|
||||
let constructor = kept_redacted_fields.is_empty().then(|| {
|
||||
let doc = format!("Creates an empty {}.", redacted_ident);
|
||||
let doc = format!("Creates an empty {redacted_ident}.");
|
||||
quote! {
|
||||
impl #redacted_ident {
|
||||
#[doc = #doc]
|
||||
@ -642,7 +642,7 @@ fn generate_event_type_aliases(
|
||||
}
|
||||
EventKindVariation::Initial => " for creating a room",
|
||||
};
|
||||
let ev_type_doc = format!("An `{}` event{}.", event_type, doc_text);
|
||||
let ev_type_doc = format!("An `{event_type}` event{doc_text}.");
|
||||
|
||||
let content_struct = if var.is_redacted() {
|
||||
Cow::Owned(format_ident!("Redacted{ident}"))
|
||||
|
@ -541,7 +541,7 @@ fn expand_accessor_methods(
|
||||
|
||||
let methods = EVENT_FIELDS.iter().map(|(name, has_field)| {
|
||||
has_field(kind, var).then(|| {
|
||||
let docs = format!("Returns this event's `{}` field.", name);
|
||||
let docs = format!("Returns this event's `{name}` field.");
|
||||
let ident = Ident::new(name, Span::call_site());
|
||||
let field_type = field_return_type(name, ruma_common);
|
||||
let variants = variants.iter().map(|v| v.match_arm(quote! { Self }));
|
||||
|
@ -53,8 +53,8 @@ pub fn expand_id_zst(input: ItemStruct) -> syn::Result<TokenStream> {
|
||||
// So we don't have to insert #where_clause everywhere when it is always None in practice
|
||||
assert_eq!(where_clause, None, "where clauses on identifier types are not currently supported");
|
||||
|
||||
let as_str_docs = format!("Creates a string slice from this `{}`.", id);
|
||||
let as_bytes_docs = format!("Creates a byte slice from this `{}`.", id);
|
||||
let as_str_docs = format!("Creates a string slice from this `{id}`.");
|
||||
let as_bytes_docs = format!("Creates a byte slice from this `{id}`.");
|
||||
|
||||
let as_str_impl = match &input.fields {
|
||||
Fields::Named(_) | Fields::Unit => {
|
||||
@ -440,10 +440,10 @@ fn expand_checked_impls(input: &ItemStruct, validate: Path) -> TokenStream {
|
||||
let (impl_generics, ty_generics, _where_clause) = input.generics.split_for_impl();
|
||||
let generic_params = &input.generics.params;
|
||||
|
||||
let parse_doc_header = format!("Try parsing a `&str` into an `Owned{}`.", id);
|
||||
let parse_box_doc_header = format!("Try parsing a `&str` into a `Box<{}>`.", id);
|
||||
let parse_rc_docs = format!("Try parsing a `&str` into an `Rc<{}>`.", id);
|
||||
let parse_arc_docs = format!("Try parsing a `&str` into an `Arc<{}>`.", id);
|
||||
let parse_doc_header = format!("Try parsing a `&str` into an `Owned{id}`.");
|
||||
let parse_box_doc_header = format!("Try parsing a `&str` into a `Box<{id}>`.");
|
||||
let parse_rc_docs = format!("Try parsing a `&str` into an `Rc<{id}>`.");
|
||||
let parse_arc_docs = format!("Try parsing a `&str` into an `Arc<{id}>`.");
|
||||
|
||||
let id_ty = quote! { #id #ty_generics };
|
||||
let owned_ty = quote! { #owned #ty_generics };
|
||||
|
@ -2,7 +2,7 @@ use proc_macro2::{Ident, TokenStream};
|
||||
use quote::quote;
|
||||
|
||||
pub fn expand_as_str_as_ref_str(ident: &Ident) -> syn::Result<TokenStream> {
|
||||
let as_str_doc = format!("Creates a string slice from this `{}`.", ident);
|
||||
let as_str_doc = format!("Creates a string slice from this `{ident}`.");
|
||||
Ok(quote! {
|
||||
#[automatically_derived]
|
||||
#[allow(deprecated)]
|
||||
|
@ -42,8 +42,8 @@ pub fn expand_derive_incoming(mut ty_def: DeriveInput) -> syn::Result<TokenStrea
|
||||
|
||||
if !found_lifetime {
|
||||
let doc = format!(
|
||||
"Convenience type alias for [{}], for consistency with other [{}] types.",
|
||||
&ty_def.ident, ident
|
||||
"Convenience type alias for [{}], for consistency with other [{ident}] types.",
|
||||
&ty_def.ident
|
||||
);
|
||||
|
||||
let mut type_alias: ItemType = parse_quote! { type X = Y; };
|
||||
|
@ -42,7 +42,7 @@ pub(crate) fn m_prefix_name_to_type_name(name: &LitStr) -> syn::Result<Ident> {
|
||||
let name = name.strip_prefix("m.").ok_or_else(|| {
|
||||
syn::Error::new(
|
||||
span,
|
||||
format!("well-known matrix events have to start with `m.` found `{}`", name),
|
||||
format!("well-known matrix events have to start with `m.` found `{name}`"),
|
||||
)
|
||||
})?;
|
||||
|
||||
|
@ -227,8 +227,8 @@ impl Credentials for XMatrix {
|
||||
fn encode(&self) -> HeaderValue {
|
||||
if let Some(destination) = &self.destination {
|
||||
format!(
|
||||
"X-Matrix origin=\"{}\",destination=\"{}\",key=\"{}\",sig=\"{}\"",
|
||||
self.origin, destination, self.key, self.sig
|
||||
"X-Matrix origin=\"{}\",destination=\"{destination}\",key=\"{}\",sig=\"{}\"",
|
||||
self.origin, self.key, self.sig
|
||||
)
|
||||
} else {
|
||||
format!("X-Matrix origin=\"{}\",key=\"{}\",sig=\"{}\"", self.origin, self.key, self.sig)
|
||||
|
@ -299,7 +299,7 @@ impl ReleaseTask {
|
||||
|
||||
/// Create the release on GitHub with the given `config` and `credentials`.
|
||||
fn release(&self, body: &str) -> Result<()> {
|
||||
let request = Request::post(format!("{}/releases", GITHUB_API_RUMA))
|
||||
let request = Request::post(format!("{GITHUB_API_RUMA}/releases"))
|
||||
.authentication(Authentication::basic())
|
||||
.credentials(Credentials::new(&self.config.user, &self.config.token))
|
||||
.header("Accept", "application/vnd.github.v3+json")
|
||||
|
Loading…
x
Reference in New Issue
Block a user