Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CI #2610

Merged
merged 7 commits into from
Nov 20, 2023
Merged

Fix CI #2610

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: [push, pull_request]

env:
rust_min: 1.53.0
rust_nightly: nightly-2022-08-11
rust_nightly: nightly-2023-01-26

jobs:
test:
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ version = "1.0.7"
optional = true

[dependencies.simd-json]
version = "0.4.14"
version = "0.10.3"
optional = true

[dependencies.tracing]
Expand Down
2 changes: 1 addition & 1 deletion examples/e15_simple_dashboard/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ async fn before_hook(ctx: &Context, _: &Message, cmd_name: &str) -> bool {

let command_count_value = {
let mut count_write = elements.command_usage_values.lock().await;
let mut command_count_value = count_write.get_mut(cmd_name).unwrap();
let command_count_value = count_write.get_mut(cmd_name).unwrap();
command_count_value.use_count += 1;
command_count_value.clone()
};
Expand Down
8 changes: 3 additions & 5 deletions src/cache/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,10 +457,8 @@ impl CacheUpdate for MessageCreateEvent {
return None;
}

let messages =
cache.messages.entry(self.message.channel_id).or_insert_with(Default::default);
let mut queue =
cache.message_queue.entry(self.message.channel_id).or_insert_with(Default::default);
let messages = cache.messages.entry(self.message.channel_id).or_default();
let mut queue = cache.message_queue.entry(self.message.channel_id).or_default();

let mut removed_msg = None;

Expand Down Expand Up @@ -594,7 +592,7 @@ impl CacheUpdate for ReadyEvent {
let ready_guilds_hashset =
self.ready.guilds.iter().map(|status| status.id).collect::<HashSet<_>>();
let shard_data = self.ready.shard.unwrap_or([1, 1]);
for guild_entry in cache.guilds.iter() {
for guild_entry in &cache.guilds {
let guild = guild_entry.key();
// Only handle data for our shard.
if crate::utils::shard_id(guild.0, shard_data[1]) == shard_data[0]
Expand Down
2 changes: 1 addition & 1 deletion src/cache/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ impl Cache {
pub fn unknown_members(&self) -> u64 {
let mut total = 0;

for guild_entry in self.guilds.iter() {
for guild_entry in &self.guilds {
let guild = guild_entry.value();

let members = guild.members.len() as u64;
Expand Down
1 change: 1 addition & 0 deletions src/client/bridge/gateway/shard_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ pub struct ShardManager {
impl ShardManager {
/// Creates a new shard manager, returning both the manager and a monitor
/// for usage in a separate thread.
#[allow(clippy::unused_async)]
pub async fn new(opt: ShardManagerOptions<'_>) -> (Arc<Mutex<Self>>, ShardManagerMonitor) {
let (thread_tx, thread_rx) = mpsc::unbounded();
let (shard_queue_tx, shard_queue_rx) = mpsc::unbounded();
Expand Down
14 changes: 5 additions & 9 deletions src/client/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,12 +212,12 @@ pub(crate) fn dispatch<'rec>(
#[cfg(not(feature = "framework"))]
{
// Avoid cloning if there will be no framework dispatch.
dispatch_message(context, event.message, h).await;
dispatch_message(context, event.message, h);
}

#[cfg(feature = "framework")]
{
dispatch_message(context.clone(), event.message.clone(), h).await;
dispatch_message(context.clone(), event.message.clone(), h);

let framework = Arc::clone(framework);

Expand Down Expand Up @@ -290,12 +290,12 @@ pub(crate) fn dispatch<'rec>(
#[cfg(not(feature = "framework"))]
{
// Avoid cloning if there will be no framework dispatch.
dispatch_message(context, event.message, handler).await;
dispatch_message(context, event.message, handler);
}

#[cfg(feature = "framework")]
{
dispatch_message(context.clone(), event.message.clone(), handler).await;
dispatch_message(context.clone(), event.message.clone(), handler);

let framework = Arc::clone(framework);
let message = event.message;
Expand All @@ -315,11 +315,7 @@ pub(crate) fn dispatch<'rec>(
.boxed()
}

async fn dispatch_message(
context: Context,
mut message: Message,
event_handler: &Arc<dyn EventHandler>,
) {
fn dispatch_message(context: Context, mut message: Message, event_handler: &Arc<dyn EventHandler>) {
#[cfg(feature = "model")]
{
message.transform_content();
Expand Down
4 changes: 2 additions & 2 deletions src/collector/component_interaction_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ impl fmt::Debug for FilterOptions {
.field("channel_id", &self.channel_id)
.field("guild_id", &self.guild_id)
.field("author_id", &self.author_id)
.finish()
.finish_non_exhaustive()
}
}

Expand Down Expand Up @@ -294,7 +294,7 @@ impl Stream for ComponentInteractionCollector {
fn poll_next(mut self: Pin<&mut Self>, ctx: &mut FutContext<'_>) -> Poll<Option<Self::Item>> {
if let Some(ref mut timeout) = self.timeout {
match timeout.as_mut().poll(ctx) {
Poll::Ready(_) => {
Poll::Ready(()) => {
return Poll::Ready(None);
},
Poll::Pending => (),
Expand Down
54 changes: 23 additions & 31 deletions src/collector/event_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ impl Stream for EventCollector {
fn poll_next(mut self: Pin<&mut Self>, ctx: &mut FutContext<'_>) -> Poll<Option<Self::Item>> {
if let Some(ref mut timeout) = self.timeout {
match timeout.as_mut().poll(ctx) {
Poll::Ready(_) => {
Poll::Ready(()) => {
return Poll::Ready(None);
},
Poll::Pending => (),
Expand Down Expand Up @@ -354,21 +354,17 @@ mod test {
Err(Error::Collector(CollectorError::InvalidEventIdFilters))
));

assert!(matches!(
EventCollectorBuilder::new(&msg)
.add_event_type(EventType::GuildBanAdd)
.add_user_id(UserId::default())
.build(),
Ok(_)
));
assert!(matches!(
EventCollectorBuilder::new(&msg)
.add_event_type(EventType::GuildBanAdd)
.add_event_type(EventType::GuildCreate)
.add_user_id(UserId::default())
.build(),
Ok(_)
));
assert!(EventCollectorBuilder::new(&msg)
.add_event_type(EventType::GuildBanAdd)
.add_user_id(UserId::default())
.build()
.is_ok());
assert!(EventCollectorBuilder::new(&msg)
.add_event_type(EventType::GuildBanAdd)
.add_event_type(EventType::GuildCreate)
.add_user_id(UserId::default())
.build()
.is_ok());
}

#[test]
Expand All @@ -384,13 +380,11 @@ mod test {
.build(),
Err(Error::Collector(CollectorError::InvalidEventIdFilters))
));
assert!(matches!(
EventCollectorBuilder::new(&msg)
.add_event_type(EventType::UserUpdate)
.add_user_id(UserId::default())
.build(),
Ok(_)
));
assert!(EventCollectorBuilder::new(&msg)
.add_event_type(EventType::UserUpdate)
.add_user_id(UserId::default())
.build()
.is_ok());
}

#[test]
Expand All @@ -400,14 +394,12 @@ mod test {

// If at least one event type has the filtered ID type(s), we go ahead and build the
// collector, even though one or more of the event types may never be yielded.
assert!(matches!(
EventCollectorBuilder::new(&msg)
.add_event_type(EventType::GuildCreate)
.add_event_type(EventType::GuildMemberAdd)
.add_user_id(UserId::default())
.build(),
Ok(_)
));
assert!(EventCollectorBuilder::new(&msg)
.add_event_type(EventType::GuildCreate)
.add_event_type(EventType::GuildMemberAdd)
.add_user_id(UserId::default())
.build()
.is_ok());
// But if none of the events have that ID type, that's an error.
assert!(matches!(
EventCollectorBuilder::new(&msg)
Expand Down
4 changes: 2 additions & 2 deletions src/collector/message_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ impl fmt::Debug for FilterOptions {
.field("channel_id", &self.channel_id)
.field("guild_id", &self.guild_id)
.field("author_id", &self.author_id)
.finish()
.finish_non_exhaustive()
}
}

Expand All @@ -286,7 +286,7 @@ impl Stream for MessageCollector {
fn poll_next(mut self: Pin<&mut Self>, ctx: &mut FutContext<'_>) -> Poll<Option<Self::Item>> {
if let Some(ref mut timeout) = self.timeout {
match timeout.as_mut().poll(ctx) {
Poll::Ready(_) => {
Poll::Ready(()) => {
return Poll::Ready(None);
},
Poll::Pending => (),
Expand Down
4 changes: 2 additions & 2 deletions src/collector/modal_interaction_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ impl fmt::Debug for FilterOptions {
.field("channel_id", &self.channel_id)
.field("guild_id", &self.guild_id)
.field("author_id", &self.author_id)
.finish()
.finish_non_exhaustive()
}
}

Expand Down Expand Up @@ -297,7 +297,7 @@ impl Stream for ModalInteractionCollector {
fn poll_next(mut self: Pin<&mut Self>, ctx: &mut FutContext<'_>) -> Poll<Option<Self::Item>> {
if let Some(ref mut timeout) = self.timeout {
match timeout.as_mut().poll(ctx) {
Poll::Ready(_) => {
Poll::Ready(()) => {
return Poll::Ready(None);
},
Poll::Pending => (),
Expand Down
4 changes: 2 additions & 2 deletions src/collector/reaction_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ impl fmt::Debug for FilterOptions {
.field("channel_id", &self.channel_id)
.field("guild_id", &self.guild_id)
.field("author_id", &self.author_id)
.finish()
.finish_non_exhaustive()
}
}

Expand All @@ -402,7 +402,7 @@ impl Stream for ReactionCollector {
fn poll_next(mut self: Pin<&mut Self>, ctx: &mut FutContext<'_>) -> Poll<Option<Self::Item>> {
if let Some(ref mut timeout) = self.timeout {
match timeout.as_mut().poll(ctx) {
Poll::Ready(_) => {
Poll::Ready(()) => {
return Poll::Ready(None);
},
Poll::Pending => (),
Expand Down
2 changes: 1 addition & 1 deletion src/framework/standard/structures/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pub struct Command {

impl fmt::Debug for Command {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Command").field("options", &self.options).finish()
f.debug_struct("Command").field("options", &self.options).finish_non_exhaustive()
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/http/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ impl fmt::Debug for Http {
.field("ratelimiter", &self.ratelimiter)
.field("ratelimiter_disabled", &self.ratelimiter_disabled)
.field("proxy", &self.proxy)
.finish()
.finish_non_exhaustive()
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/http/ratelimiting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl fmt::Debug for Ratelimiter {
.field("client", &self.client)
.field("global", &self.global)
.field("routes", &self.routes)
.finish()
.finish_non_exhaustive()
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/http/typing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl Typing {
spawn_named("typing::start", async move {
loop {
match rx.try_recv() {
Ok(_) | Err(TryRecvError::Closed) => break,
Ok(()) | Err(TryRecvError::Closed) => break,
_ => (),
}

Expand Down
2 changes: 1 addition & 1 deletion src/http/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub fn deserialize_errors<'de, D: Deserializer<'de>>(
}

fn loop_errors(value: &Value, errors: &mut Vec<DiscordJsonSingleError>, path: &[String]) {
for (key, looped) in value.as_object().expect("expected object").iter() {
for (key, looped) in value.as_object().expect("expected object") {
let object = looped.as_object().expect("expected object");
if object.contains_key("_errors") {
let found_errors = object
Expand Down
2 changes: 1 addition & 1 deletion src/internal/ws_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub(crate) fn convert_ws_message(message: Option<Message>) -> Result<Option<Valu
why
})?
},
Some(Message::Text(mut payload)) => from_str(&mut payload).map(Some).map_err(|why| {
Some(Message::Text(payload)) => from_str(&payload).map(Some).map_err(|why| {
warn!("Err deserializing text: {:?}; text: {}", why, payload,);

why
Expand Down
12 changes: 5 additions & 7 deletions src/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
use std::collections::HashMap;
use std::hash::{BuildHasher, Hash};

#[cfg(feature = "gateway")]
use serde::de::Deserialize;
use serde::de::DeserializeOwned;
use serde::ser::Serialize;

Expand Down Expand Up @@ -62,19 +60,19 @@ where
}

#[cfg(all(feature = "gateway", not(feature = "simd_json")))]
pub(crate) fn from_str<'a, T>(s: &'a mut str) -> Result<T>
pub(crate) fn from_str<'a, T>(s: &'a str) -> Result<T>
where
T: Deserialize<'a>,
T: serde::de::Deserialize<'a>,
{
Ok(serde_json::from_str(s)?)
}

#[cfg(all(feature = "gateway", feature = "simd_json"))]
pub(crate) fn from_str<'a, T>(s: &'a mut str) -> Result<T>
pub(crate) fn from_str<T>(s: &str) -> Result<T>
where
T: Deserialize<'a>,
T: DeserializeOwned,
{
Ok(simd_json::from_str(s)?)
Ok(simd_json::from_slice(&mut s.to_owned().into_bytes())?)
}

#[cfg(not(feature = "simd_json"))]
Expand Down
2 changes: 1 addition & 1 deletion src/model/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ impl fmt::Debug for VoiceServerUpdateEvent {
.field("channel_id", &self.channel_id)
.field("endpoint", &self.endpoint)
.field("guild_id", &self.guild_id)
.finish()
.finish_non_exhaustive()
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/model/guild/emoji.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ impl Emoji {
#[cfg(feature = "cache")]
#[must_use]
pub fn find_guild_id(&self, cache: impl AsRef<Cache>) -> Option<GuildId> {
for guild_entry in cache.as_ref().guilds.iter() {
for guild_entry in &cache.as_ref().guilds {
let guild = guild_entry.value();

if guild.emojis.contains_key(&self.id) {
Expand Down
2 changes: 1 addition & 1 deletion src/model/guild/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ impl Guild {
let name = name.as_ref();
let guild_channels = cache.as_ref().guild_channels(self.id)?;

for channel_entry in guild_channels.iter() {
for channel_entry in &guild_channels {
let (id, channel) = channel_entry.pair();

if channel.name == name {
Expand Down
2 changes: 1 addition & 1 deletion src/model/guild/partial_guild.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ impl PartialGuild {
let name = name.as_ref();
let guild_channels = cache.as_ref().guild_channels(self.id)?;

for channel_entry in guild_channels.iter() {
for channel_entry in &guild_channels {
let (id, channel) = channel_entry.pair();

if channel.name == name {
Expand Down
2 changes: 1 addition & 1 deletion src/model/guild/role.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ impl RoleId {
/// Tries to find the [`Role`] by its Id in the cache.
#[cfg(feature = "cache")]
pub fn to_role_cached(self, cache: impl AsRef<Cache>) -> Option<Role> {
for guild_entry in cache.as_ref().guilds.iter() {
for guild_entry in &cache.as_ref().guilds {
let guild = guild_entry.value();

if !guild.roles.contains_key(&self) {
Expand Down
Loading
Loading