Skip to content

Commit

Permalink
build: bump MSRV to 1.67 (twilight-rs#2208)
Browse files Browse the repository at this point in the history
  • Loading branch information
vilgotf authored May 12, 2023
1 parent c54dbcb commit f199ade
Show file tree
Hide file tree
Showing 20 changed files with 30 additions and 70 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ edition = "2021"
include = ["src/**/*.rs", "README.md"]
license = "ISC"
repository = "https://github.com/twilight-rs/twilight.git"
rust-version = "1.64"
rust-version = "1.67"
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ functionality. Please use the individual crates listed below instead!

## Installation

Twilight supports a MSRV of Rust 1.64+.
Twilight supports a MSRV of Rust 1.67.

We recommend that most users start out with these crates:

Expand Down Expand Up @@ -205,13 +205,12 @@ All first-party crates are licensed under [ISC][LICENSE.md]
[codecov link]: https://app.codecov.io/gh/twilight-rs/twilight/
[discord badge]: https://img.shields.io/discord/745809834183753828?color=%237289DA&label=discord%20server&logo=discord&style=for-the-badge
[discord link]: https://discord.gg/7jj8n7D
[docs:discord:sharding]: https://discord.com/developers/docs/topics/gateway#sharding
[github badge]: https://img.shields.io/badge/github-twilight-6f42c1.svg?style=for-the-badge&logo=github
[github link]: https://github.com/twilight-rs/twilight
[license badge]: https://img.shields.io/badge/license-ISC-blue.svg?style=for-the-badge&logo=pastebin
[license link]: https://github.com/twilight-rs/twilight/blob/main/LICENSE.md
[logo]: https://raw.githubusercontent.com/twilight-rs/twilight/main/logo.png
[rust badge]: https://img.shields.io/badge/rust-1.64+-93450a.svg?style=for-the-badge&logo=rust
[rust badge]: https://img.shields.io/badge/rust-1.67+-93450a.svg?style=for-the-badge&logo=rust
[`twilight-cache-inmemory`]: https://twilight.rs/chapter_1_crates/section_4_cache_inmemory.html
[`twilight-gateway-queue`]: https://twilight.rs/chapter_1_crates/section_7_first_party/section_5_gateway_queue.html
[`twilight-gateway`]: https://twilight.rs/chapter_1_crates/section_3_gateway.html
Expand Down
3 changes: 1 addition & 2 deletions twilight-cache-inmemory/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,8 @@ All first-party crates are licensed under [ISC][LICENSE.md]
[codecov link]: https://app.codecov.io/gh/twilight-rs/twilight/
[discord badge]: https://img.shields.io/discord/745809834183753828?color=%237289DA&label=discord%20server&logo=discord&style=for-the-badge
[discord link]: https://discord.gg/7jj8n7D
[docs:discord:sharding]: https://discord.com/developers/docs/topics/gateway#sharding
[github badge]: https://img.shields.io/badge/github-twilight-6f42c1.svg?style=for-the-badge&logo=github
[github link]: https://github.com/twilight-rs/twilight
[license badge]: https://img.shields.io/badge/license-ISC-blue.svg?style=for-the-badge&logo=pastebin
[license link]: https://github.com/twilight-rs/twilight/blob/main/LICENSE.md
[rust badge]: https://img.shields.io/badge/rust-1.64+-93450a.svg?style=for-the-badge&logo=rust
[rust badge]: https://img.shields.io/badge/rust-1.67+-93450a.svg?style=for-the-badge&logo=rust
4 changes: 1 addition & 3 deletions twilight-cache-inmemory/src/event/member.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,7 @@ impl UpdateCache for MemberUpdate {

let key = (self.guild_id, self.user.id);

let mut member = if let Some(member) = cache.members.get_mut(&key) {
member
} else {
let Some(mut member) = cache.members.get_mut(&key) else {
return;
};

Expand Down
16 changes: 4 additions & 12 deletions twilight-cache-inmemory/src/event/reaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ impl UpdateCache for ReactionAdd {

let key = self.0.message_id;

let mut message = if let Some(message) = cache.messages.get_mut(&key) {
message
} else {
let Some(mut message) = cache.messages.get_mut(&key) else {
return;
};

Expand Down Expand Up @@ -55,9 +53,7 @@ impl UpdateCache for ReactionRemove {
return;
}

let mut message = if let Some(message) = cache.messages.get_mut(&self.0.message_id) {
message
} else {
let Some(mut message) = cache.messages.get_mut(&self.0.message_id) else {
return;
};

Expand Down Expand Up @@ -91,9 +87,7 @@ impl UpdateCache for ReactionRemoveAll {
return;
}

let mut message = if let Some(message) = cache.messages.get_mut(&self.message_id) {
message
} else {
let Some(mut message) = cache.messages.get_mut(&self.message_id) else {
return;
};

Expand All @@ -107,9 +101,7 @@ impl UpdateCache for ReactionRemoveEmoji {
return;
}

let mut message = if let Some(message) = cache.messages.get_mut(&self.message_id) {
message
} else {
let Some(mut message) = cache.messages.get_mut(&self.message_id) else {
return;
};

Expand Down
4 changes: 1 addition & 3 deletions twilight-cache-inmemory/src/event/voice_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ impl InMemoryCache {

fn cache_voice_state(&self, voice_state: VoiceState) {
// This should always exist, but let's check just in case.
let guild_id = if let Some(id) = voice_state.guild_id {
id
} else {
let Some(guild_id) = voice_state.guild_id else {
return;
};

Expand Down
8 changes: 2 additions & 6 deletions twilight-cache-inmemory/src/permission.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,9 +533,7 @@ impl<'a> InMemoryCachePermissions<'a> {
return permissions;
};

let absolute = if let Ok(absolute) = micros.try_into() {
absolute
} else {
let Ok(absolute) = micros.try_into() else {
return permissions;
};

Expand Down Expand Up @@ -576,9 +574,7 @@ impl<'a> InMemoryCachePermissions<'a> {
let mut member_roles = Vec::with_capacity(member.roles.len());

for role_id in &member.roles {
let role = if let Some(role) = self.cache.roles.get(role_id) {
role
} else {
let Some(role) = self.cache.roles.get(role_id) else {
return Err(MemberRolesErrorType::RoleMissing { role_id: *role_id });
};

Expand Down
2 changes: 1 addition & 1 deletion twilight-gateway/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,4 @@ There are a few additional examples located in the
[github link]: https://github.com/twilight-rs/twilight
[license badge]: https://img.shields.io/badge/license-ISC-blue.svg?style=for-the-badge&logo=pastebin
[license link]: https://github.com/twilight-rs/twilight/blob/main/LICENSE.md
[rust badge]: https://img.shields.io/badge/rust-1.64+-93450a.svg?style=for-the-badge&logo=rust
[rust badge]: https://img.shields.io/badge/rust-1.67+-93450a.svg?style=for-the-badge&logo=rust
13 changes: 3 additions & 10 deletions twilight-gateway/src/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,7 @@ pub fn parse(
event: String,
wanted_event_types: EventTypeFlags,
) -> Result<Option<GatewayEvent>, ReceiveMessageError> {
let gateway_deserializer =
if let Some(gateway_deserializer) = GatewayEventDeserializer::from_json(&event) {
gateway_deserializer
} else {
let Some(gateway_deserializer) = GatewayEventDeserializer::from_json(&event) else {
return Err(ReceiveMessageError {
kind: ReceiveMessageErrorType::Deserializing { event },
source: Some(Box::new(UnknownEventError {
Expand All @@ -76,9 +73,7 @@ pub fn parse(
});
};

let opcode = if let Some(opcode) = OpCode::from(gateway_deserializer.op()) {
opcode
} else {
let Some(opcode) = OpCode::from(gateway_deserializer.op()) else {
let opcode = gateway_deserializer.op();

return Err(ReceiveMessageError {
Expand All @@ -92,9 +87,7 @@ pub fn parse(

let event_type = gateway_deserializer.event_type();

let event_type = if let Ok(event_type) = EventTypeFlags::try_from((opcode, event_type)) {
event_type
} else {
let Ok(event_type) = EventTypeFlags::try_from((opcode, event_type)) else {
let opcode = opcode as u8;
let owned_event_type = event_type.map(ToOwned::to_owned);

Expand Down
8 changes: 2 additions & 6 deletions twilight-http-ratelimiting/src/in_memory/bucket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,7 @@ impl Bucket {
let reset_after = self.reset_after();
let maybe_started_at = *self.started_at.lock().expect("bucket poisoned");

let started_at = if let Some(started_at) = maybe_started_at {
started_at
} else {
let Some(started_at) = maybe_started_at else {
return TimeRemaining::NotStarted;
};

Expand Down Expand Up @@ -222,9 +220,7 @@ impl BucketQueueTask {
drop(self.global.0.lock().await);
}

let ticket_headers = if let Some(ticket_headers) = queue_tx.available() {
ticket_headers
} else {
let Some(ticket_headers) = queue_tx.available() else {
continue;
};

Expand Down
2 changes: 1 addition & 1 deletion twilight-http/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,4 @@ async DNS resolver on the application level.
[github link]: https://github.com/twilight-rs/twilight
[license badge]: https://img.shields.io/badge/license-ISC-blue.svg?style=for-the-badge&logo=pastebin
[license link]: https://github.com/twilight-rs/twilight/blob/main/LICENSE.md
[rust badge]: https://img.shields.io/badge/rust-1.64+-93450a.svg?style=for-the-badge&logo=rust
[rust badge]: https://img.shields.io/badge/rust-1.67+-93450a.svg?style=for-the-badge&logo=rust
2 changes: 1 addition & 1 deletion twilight-lavalink/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,4 @@ There is also an example of a basic bot located in the [root of the
[license link]: https://github.com/twilight-rs/twilight/blob/main/LICENSE.md
[node]: Node
[process]: Lavalink::process
[rust badge]: https://img.shields.io/badge/rust-1.64+-93450a.svg?style=for-the-badge&logo=rust
[rust badge]: https://img.shields.io/badge/rust-1.67+-93450a.svg?style=for-the-badge&logo=rust
8 changes: 2 additions & 6 deletions twilight-lavalink/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -570,9 +570,7 @@ impl Connection {
}
};

let event = if let Ok(event) = serde_json::from_str(&text) {
event
} else {
let Ok(event) = serde_json::from_str(&text) else {
tracing::warn!("unknown message from lavalink node: {text}");

return Ok(true);
Expand All @@ -594,9 +592,7 @@ impl Connection {
}

fn player_update(&self, update: &PlayerUpdate) -> Result<(), NodeError> {
let player = if let Some(player) = self.players.get(&update.guild_id) {
player
} else {
let Some(player) = self.players.get(&update.guild_id) else {
tracing::warn!(
"invalid player update for guild {}: {update:?}",
update.guild_id,
Expand Down
2 changes: 1 addition & 1 deletion twilight-mention/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ let message = format!("Hey there, {}!", user_id.mention());
[github link]: https://github.com/twilight-rs/twilight
[license badge]: https://img.shields.io/badge/license-ISC-blue.svg?style=for-the-badge&logo=pastebin
[license link]: https://github.com/twilight-rs/twilight/blob/main/LICENSE.md
[rust badge]: https://img.shields.io/badge/rust-1.64+-93450a.svg?style=for-the-badge&logo=rust
[rust badge]: https://img.shields.io/badge/rust-1.67+-93450a.svg?style=for-the-badge&logo=rust
9 changes: 2 additions & 7 deletions twilight-mention/src/parse/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,7 @@ impl<'a, T: ParseMention> Iterator for MentionIter<'a, T> {
// chars here and not just individual bytes. We also want to not use
// consuming methods of the iterator, so this will get a little weird.
loop {
let start = match self.chars.next()? {
(idx, '<') => idx,
_ => continue,
};
let (start, '<') = self.chars.next()? else { continue };

let mut found = false;

Expand All @@ -84,9 +81,7 @@ impl<'a, T: ParseMention> Iterator for MentionIter<'a, T> {
continue;
}

let end = if let Some((idx, _)) = self.chars.find(|c| c.1 == '>') {
idx
} else {
let Some((end, _)) = self.chars.find(|c| c.1 == '>') else {
continue;
};

Expand Down
2 changes: 1 addition & 1 deletion twilight-model/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ Some models have associated builders, which can be found in the
[github link]: https://github.com/twilight-rs/twilight
[license badge]: https://img.shields.io/badge/license-ISC-blue.svg?style=for-the-badge&logo=pastebin
[license link]: https://github.com/twilight-rs/twilight/blob/main/LICENSE.md
[rust badge]: https://img.shields.io/badge/rust-1.64+-93450a.svg?style=for-the-badge&logo=rust
[rust badge]: https://img.shields.io/badge/rust-1.67+-93450a.svg?style=for-the-badge&logo=rust
2 changes: 1 addition & 1 deletion twilight-standby/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,4 @@ For more examples, check out each of the methods on [`Standby`].
[github link]: https://github.com/twilight-rs/twilight
[license badge]: https://img.shields.io/badge/license-ISC-blue.svg?style=for-the-badge&logo=pastebin
[license link]: https://github.com/twilight-rs/twilight/blob/main/LICENSE.md
[rust badge]: https://img.shields.io/badge/rust-1.64+-93450a.svg?style=for-the-badge&logo=rust
[rust badge]: https://img.shields.io/badge/rust-1.67+-93450a.svg?style=for-the-badge&logo=rust
4 changes: 1 addition & 3 deletions twilight-standby/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -882,9 +882,7 @@ impl Standby {
) -> ProcessStatus {
// We need to take the sender out because `OneshotSender`s consume
// themselves when calling `OneshotSender::send`.
let sender = if let Some(sender) = bystander.sender.take() {
sender
} else {
let Some(sender) = bystander.sender.take() else {
tracing::trace!("bystander has no sender, indicating for removal");

return ProcessStatus::AlreadyComplete;
Expand Down
2 changes: 1 addition & 1 deletion twilight-util/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ structured information from [Discord snowflakes].
[github link]: https://github.com/twilight-rs/twilight
[license badge]: https://img.shields.io/badge/license-ISC-blue.svg?style=for-the-badge&logo=pastebin
[license link]: https://github.com/twilight-rs/twilight/blob/main/LICENSE.md
[rust badge]: https://img.shields.io/badge/rust-1.64+-93450a.svg?style=for-the-badge&logo=rust
[rust badge]: https://img.shields.io/badge/rust-1.67+-93450a.svg?style=for-the-badge&logo=rust
[Discord snowflakes]: https://discord.com/developers/docs/reference#snowflakes
2 changes: 1 addition & 1 deletion twilight-validate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ manually validating any models from [`twilight-model`].
[github link]: https://github.com/twilight-rs/twilight
[license badge]: https://img.shields.io/badge/license-ISC-blue.svg?style=for-the-badge&logo=pastebin
[license link]: https://github.com/twilight-rs/twilight/blob/main/LICENSE.md
[rust badge]: https://img.shields.io/badge/rust-1.64+-93450a.svg?style=for-the-badge&logo=rust
[rust badge]: https://img.shields.io/badge/rust-1.67+-93450a.svg?style=for-the-badge&logo=rust

0 comments on commit f199ade

Please sign in to comment.