diff --git a/.builds/1.43.yml b/.builds/1.45.yml similarity index 92% rename from .builds/1.43.yml rename to .builds/1.45.yml index 8968a62e..8b03beeb 100644 --- a/.builds/1.43.yml +++ b/.builds/1.45.yml @@ -6,8 +6,8 @@ sources: tasks: - rustup: | # We specify --profile minimal because we'd otherwise download docs - rustup toolchain install 1.43 --profile minimal - rustup default 1.43 + rustup toolchain install 1.45 --profile minimal + rustup default 1.45 - test: | cd ruma @@ -15,7 +15,7 @@ tasks: # tools, so capture tool exit codes and set the task exit code manually set +e - # We don't want to try building ruma-signatures on 1.43, since it depends + # We don't want to try building ruma-signatures on 1.45, since it depends # on ring (MSRV 'stable') and is exempt from our MSRV policy. Instead, # enable all other dependencies on the ruma crate and try building that # (usually you would enable the higher-level features, but we're only diff --git a/README.md b/README.md index 2eeb2f47..03149ec9 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md). ## Minimum Rust version -Ruma currently requires Rust 1.43. In general, we will never require beta or +Ruma currently requires Rust 1.45. In general, we will never require beta or nightly for crates.io releases of our crates, and we will try to avoid releasing crates that depend on features that were only just stabilized. diff --git a/ruma-api-macros/src/api.rs b/ruma-api-macros/src/api.rs index b05e8476..56c98d78 100644 --- a/ruma-api-macros/src/api.rs +++ b/ruma-api-macros/src/api.rs @@ -367,12 +367,7 @@ pub fn expand_all(api: Api) -> syn::Result { .method(#http::Method::#method) .uri(::std::format!( "{}{}{}", - // FIXME: Once MSRV is >= 1.45.0, switch to - // base_url.strip_suffix('/').unwrap_or(base_url), - match base_url.as_bytes().last() { - Some(b'/') => &base_url[..base_url.len() - 1], - _ => base_url, - }, + base_url.strip_suffix('/').unwrap_or(base_url), #request_path_string, #request_query_string, )) diff --git a/ruma-client-api/src/r0/message/send_message_event.rs b/ruma-client-api/src/r0/message/send_message_event.rs index b443261d..9dbe1dee 100644 --- a/ruma-client-api/src/r0/message/send_message_event.rs +++ b/ruma-client-api/src/r0/message/send_message_event.rs @@ -131,12 +131,7 @@ impl<'a> ruma_api::OutgoingRequest for Request<'a> { .method(http::Method::PUT) .uri(format!( "{}/_matrix/client/r0/rooms/{}/send/{}/{}", - // FIXME: Once MSRV is >= 1.45.0, switch to - // base_url.strip_suffix('/').unwrap_or(base_url), - match base_url.as_bytes().last() { - Some(b'/') => &base_url[..base_url.len() - 1], - _ => base_url, - }, + base_url.strip_suffix('/').unwrap_or(base_url), utf8_percent_encode(self.room_id.as_str(), NON_ALPHANUMERIC), utf8_percent_encode(self.content.event_type(), NON_ALPHANUMERIC), utf8_percent_encode(&self.txn_id, NON_ALPHANUMERIC), diff --git a/ruma-client-api/src/r0/state/send_state_event_for_empty_key.rs b/ruma-client-api/src/r0/state/send_state_event_for_empty_key.rs index bc5c9dfb..2cfbe95b 100644 --- a/ruma-client-api/src/r0/state/send_state_event_for_empty_key.rs +++ b/ruma-client-api/src/r0/state/send_state_event_for_empty_key.rs @@ -124,12 +124,7 @@ impl<'a> ruma_api::OutgoingRequest for Request<'a> { .method(http::Method::PUT) .uri(format!( "{}/_matrix/client/r0/rooms/{}/state/{}", - // FIXME: Once MSRV is >= 1.45.0, switch to - // base_url.strip_suffix('/').unwrap_or(base_url), - match base_url.as_bytes().last() { - Some(b'/') => &base_url[..base_url.len() - 1], - _ => base_url, - }, + base_url.strip_suffix('/').unwrap_or(base_url), utf8_percent_encode(self.room_id.as_str(), NON_ALPHANUMERIC), utf8_percent_encode(self.content.event_type(), NON_ALPHANUMERIC), )) diff --git a/ruma-client-api/src/r0/state/send_state_event_for_key.rs b/ruma-client-api/src/r0/state/send_state_event_for_key.rs index a5eb6142..69163139 100644 --- a/ruma-client-api/src/r0/state/send_state_event_for_key.rs +++ b/ruma-client-api/src/r0/state/send_state_event_for_key.rs @@ -127,12 +127,7 @@ impl<'a> ruma_api::OutgoingRequest for Request<'a> { .method(http::Method::PUT) .uri(format!( "{}/_matrix/client/r0/rooms/{}/state/{}/{}", - // FIXME: Once MSRV is >= 1.45.0, switch to - // base_url.strip_suffix('/').unwrap_or(base_url), - match base_url.as_bytes().last() { - Some(b'/') => &base_url[..base_url.len() - 1], - _ => base_url, - }, + base_url.strip_suffix('/').unwrap_or(base_url), utf8_percent_encode(self.room_id.as_str(), NON_ALPHANUMERIC), utf8_percent_encode(self.content.event_type(), NON_ALPHANUMERIC), utf8_percent_encode(&self.state_key, NON_ALPHANUMERIC), diff --git a/ruma-signatures/src/functions.rs b/ruma-signatures/src/functions.rs index b8ab4ba4..ce098f70 100644 --- a/ruma-signatures/src/functions.rs +++ b/ruma-signatures/src/functions.rs @@ -1,6 +1,7 @@ //! Functions for signing and verifying JSON and events. use std::{ + borrow::Cow, collections::{BTreeMap, BTreeSet}, mem, str::FromStr, @@ -138,14 +139,13 @@ pub fn sign_json( where K: KeyPair, { - // FIXME: Once MSRV >= 1.45.0, use remove_key and don't allocate new `String`s below. - let mut signature_map = match object.remove("signatures") { - Some(CanonicalJsonValue::Object(signatures)) => signatures, + let (signatures_key, mut signature_map) = match object.remove_entry("signatures") { + Some((key, CanonicalJsonValue::Object(signatures))) => (Cow::Owned(key), signatures), Some(_) => return Err(Error::new("field `signatures` must be a JSON object")), - None => BTreeMap::new(), + None => (Cow::Borrowed("signatures"), BTreeMap::new()), }; - let maybe_unsigned = object.remove("unsigned"); + let maybe_unsigned_entry = object.remove_entry("unsigned"); // Get the canonical JSON string. let json = to_canonical_json_string(object)?; @@ -166,10 +166,10 @@ where signature_set.insert(signature.id(), CanonicalJsonValue::String(signature.base64())); // Put `signatures` and `unsigned` back in. - object.insert("signatures".into(), CanonicalJsonValue::Object(signature_map)); + object.insert(signatures_key.into(), CanonicalJsonValue::Object(signature_map)); - if let Some(unsigned) = maybe_unsigned { - object.insert("unsigned".into(), unsigned); + if let Some((k, v)) = maybe_unsigned_entry { + object.insert(k, v); } Ok(())