From 21518c8590c055d3eab6c99ebdd824721b7b0a73 Mon Sep 17 00:00:00 2001 From: Lakelezz <12222135+Lakelezz@users.noreply.github.com> Date: Fri, 7 Dec 2018 23:12:34 +0100 Subject: [PATCH] Update to Rust 2018 (#445) --- Cargo.toml | 2 +- examples/01_basic_ping_bot/Cargo.toml | 1 + examples/01_basic_ping_bot/src/main.rs | 2 - .../02_transparent_guild_sharding/Cargo.toml | 1 + .../02_transparent_guild_sharding/src/main.rs | 2 - examples/03_struct_utilities/Cargo.toml | 1 + examples/03_struct_utilities/src/main.rs | 2 - examples/04_message_builder/src/main.rs | 2 - examples/05_command_framework/Cargo.toml | 1 + examples/05_command_framework/src/main.rs | 6 +-- examples/06_voice/Cargo.toml | 4 ++ examples/06_voice/src/main.rs | 5 +- examples/07_sample_bot_structure/Cargo.toml | 7 +-- .../src/commands/math.rs | 2 + .../src/commands/meta.rs | 2 + .../src/commands/owner.rs | 2 + examples/07_sample_bot_structure/src/main.rs | 11 ++--- examples/08_env_logging/Cargo.toml | 5 +- examples/08_env_logging/src/main.rs | 9 ++-- examples/09_shard_manager/Cargo.toml | 5 +- examples/09_shard_manager/src/main.rs | 3 -- examples/10_voice_receive/Cargo.toml | 6 ++- examples/10_voice_receive/src/main.rs | 6 +-- examples/11_create_message_builder/Cargo.toml | 1 + .../11_create_message_builder/src/main.rs | 8 ++-- src/builder/create_embed.rs | 12 ++--- src/builder/create_invite.rs | 4 +- src/builder/create_message.rs | 8 ++-- src/builder/edit_channel.rs | 6 +-- src/builder/edit_guild.rs | 6 +-- src/builder/edit_member.rs | 6 +-- src/builder/edit_message.rs | 4 +- src/builder/edit_profile.rs | 4 +- src/builder/edit_role.rs | 6 +-- src/builder/execute_webhook.rs | 2 +- src/builder/get_messages.rs | 4 +- src/cache/cache_update.rs | 2 +- src/cache/mod.rs | 4 +- src/client/bridge/gateway/event.rs | 2 +- src/client/bridge/gateway/mod.rs | 2 +- src/client/bridge/gateway/shard_manager.rs | 8 ++-- src/client/bridge/gateway/shard_messenger.rs | 4 +- src/client/bridge/gateway/shard_queuer.rs | 10 ++-- src/client/bridge/gateway/shard_runner.rs | 10 ++-- .../bridge/gateway/shard_runner_message.rs | 2 +- src/client/bridge/voice/mod.rs | 8 ++-- src/client/context.rs | 18 ++++---- src/client/dispatch.rs | 16 +++---- src/client/error.rs | 2 +- src/client/event_handler.rs | 4 +- src/client/mod.rs | 16 +++---- src/error.rs | 12 ++--- src/framework/mod.rs | 10 ++-- src/framework/standard/buckets.rs | 4 +- src/framework/standard/command.rs | 14 +++--- src/framework/standard/configuration.rs | 6 +-- src/framework/standard/create_command.rs | 4 +- src/framework/standard/create_group.rs | 4 +- src/framework/standard/create_help_command.rs | 2 +- src/framework/standard/help_commands.rs | 46 +++++++++---------- src/framework/standard/mod.rs | 36 +++++++-------- src/gateway/mod.rs | 4 +- src/gateway/shard.rs | 10 ++-- src/gateway/ws_client_ext.rs | 10 ++-- src/http/mod.rs | 2 +- src/http/ratelimiting.rs | 4 +- src/http/raw.rs | 10 ++-- src/http/request.rs | 2 +- src/internal/prelude.rs | 4 +- src/internal/timer.rs | 2 +- src/internal/ws_impl.rs | 4 +- src/lib.rs | 16 +++---- src/model/channel/attachment.rs | 2 +- src/model/channel/channel_category.rs | 8 ++-- src/model/channel/channel_id.rs | 14 +++--- src/model/channel/embed.rs | 8 ++-- src/model/channel/group.rs | 8 ++-- src/model/channel/guild_channel.rs | 12 ++--- src/model/channel/message.rs | 8 ++-- src/model/channel/mod.rs | 10 ++-- src/model/channel/private_channel.rs | 8 ++-- src/model/channel/reaction.rs | 8 ++-- src/model/event.rs | 28 +++++------ src/model/guild/audit_log.rs | 2 +- src/model/guild/emoji.rs | 4 +- src/model/guild/guild_id.rs | 14 +++--- src/model/guild/member.rs | 10 ++-- src/model/guild/mod.rs | 16 +++---- src/model/guild/partial_guild.rs | 4 +- src/model/guild/role.rs | 12 ++--- src/model/id.rs | 22 ++++----- src/model/invite.rs | 10 ++-- src/model/misc.rs | 10 ++-- src/model/mod.rs | 4 +- src/model/user.rs | 18 ++++---- src/model/utils.rs | 4 +- src/model/webhook.rs | 6 +-- src/prelude.rs | 16 +++---- src/utils/colour.rs | 2 +- src/utils/message_builder.rs | 4 +- src/utils/mod.rs | 12 ++--- src/voice/connection.rs | 20 ++++---- src/voice/connection_info.rs | 2 +- src/voice/handler.rs | 6 +-- src/voice/manager.rs | 6 +-- src/voice/mod.rs | 2 +- src/voice/payload.rs | 2 +- src/voice/streamer.rs | 2 +- src/voice/threading.rs | 6 +-- 109 files changed, 394 insertions(+), 408 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3d3ea35d7fa..9af61fe5fb4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -103,7 +103,7 @@ http = ["reqwest", "lazy_static"] model = ["builder", "http"] standard_framework = ["framework"] utils = ["base64"] -voice = ["byteorder", "gateway", "opus", "sodiumoxide"] +voice = ["byteorder", "gateway", "opus", "rand", "sodiumoxide"] [package.metadata.docs.rs] all-features = true diff --git a/examples/01_basic_ping_bot/Cargo.toml b/examples/01_basic_ping_bot/Cargo.toml index 30ce62c0868..287b952d967 100644 --- a/examples/01_basic_ping_bot/Cargo.toml +++ b/examples/01_basic_ping_bot/Cargo.toml @@ -2,6 +2,7 @@ name = "01_basic_ping_bot" version = "0.1.0" authors = ["my name "] +edition = "2018" [dependencies] serenity = { path = "../../", default-features = true } diff --git a/examples/01_basic_ping_bot/src/main.rs b/examples/01_basic_ping_bot/src/main.rs index 63c932b6bb7..6eaae47af6f 100644 --- a/examples/01_basic_ping_bot/src/main.rs +++ b/examples/01_basic_ping_bot/src/main.rs @@ -1,5 +1,3 @@ -extern crate serenity; - use std::env; use serenity::{ diff --git a/examples/02_transparent_guild_sharding/Cargo.toml b/examples/02_transparent_guild_sharding/Cargo.toml index 808b5c15eda..ef430e4f72c 100644 --- a/examples/02_transparent_guild_sharding/Cargo.toml +++ b/examples/02_transparent_guild_sharding/Cargo.toml @@ -2,6 +2,7 @@ name = "02_transparent_guild_sharding" version = "0.1.0" authors = ["my name "] +edition = "2018" [dependencies] serenity = { path = "../../" } diff --git a/examples/02_transparent_guild_sharding/src/main.rs b/examples/02_transparent_guild_sharding/src/main.rs index 26e7afbd9c3..74113f9344a 100644 --- a/examples/02_transparent_guild_sharding/src/main.rs +++ b/examples/02_transparent_guild_sharding/src/main.rs @@ -1,5 +1,3 @@ -extern crate serenity; - use std::env; use serenity::{ diff --git a/examples/03_struct_utilities/Cargo.toml b/examples/03_struct_utilities/Cargo.toml index e9a563e30ba..25709fe8e60 100644 --- a/examples/03_struct_utilities/Cargo.toml +++ b/examples/03_struct_utilities/Cargo.toml @@ -2,6 +2,7 @@ name = "03_struct_utilities" version = "0.1.0" authors = ["my name "] +edition = "2018" [dependencies] serenity = { path = "../../" } diff --git a/examples/03_struct_utilities/src/main.rs b/examples/03_struct_utilities/src/main.rs index 52587efd790..7dac837bf4d 100644 --- a/examples/03_struct_utilities/src/main.rs +++ b/examples/03_struct_utilities/src/main.rs @@ -1,5 +1,3 @@ -extern crate serenity; - use std::env; use serenity::{ diff --git a/examples/04_message_builder/src/main.rs b/examples/04_message_builder/src/main.rs index d078496e529..ff758243b14 100644 --- a/examples/04_message_builder/src/main.rs +++ b/examples/04_message_builder/src/main.rs @@ -1,5 +1,3 @@ -extern crate serenity; - use std::env; use serenity::{ diff --git a/examples/05_command_framework/Cargo.toml b/examples/05_command_framework/Cargo.toml index 4e9e746d192..dbbabcf9f25 100644 --- a/examples/05_command_framework/Cargo.toml +++ b/examples/05_command_framework/Cargo.toml @@ -2,6 +2,7 @@ name = "05_command_framework" version = "0.1.0" authors = ["my name "] +edition = "2018" [dependencies.serenity] features = ["framework", "standard_framework"] diff --git a/examples/05_command_framework/src/main.rs b/examples/05_command_framework/src/main.rs index 151432f62ab..b451549ed7a 100644 --- a/examples/05_command_framework/src/main.rs +++ b/examples/05_command_framework/src/main.rs @@ -8,14 +8,10 @@ //! git = "https://github.com/serenity-rs/serenity.git" //! features = ["framework", "standard_framework"] //! ``` - -#[macro_use] -extern crate serenity; -extern crate typemap; - use std::{collections::HashMap, env, fmt::Write, sync::Arc}; use serenity::{ + command, client::bridge::gateway::{ShardId, ShardManager}, framework::standard::{ help_commands, Args, CommandOptions, DispatchError, HelpBehaviour, StandardFramework, diff --git a/examples/06_voice/Cargo.toml b/examples/06_voice/Cargo.toml index 410e717d8e8..92f1be1cf93 100644 --- a/examples/06_voice/Cargo.toml +++ b/examples/06_voice/Cargo.toml @@ -2,6 +2,10 @@ name = "06_voice" version = "0.1.0" authors = ["my name "] +edition = "2018" + +[dependencies] +typemap = "0.3" [dependencies.serenity] features = ["cache", "framework", "standard_framework", "voice"] diff --git a/examples/06_voice/src/main.rs b/examples/06_voice/src/main.rs index 67ab823b9aa..ecd5cf5878b 100644 --- a/examples/06_voice/src/main.rs +++ b/examples/06_voice/src/main.rs @@ -6,10 +6,6 @@ //! git = "https://github.com/serenity-rs/serenity.git" //! features = ["cache", "framework", "standard_framework", "voice"] //! ``` - -#[macro_use] extern crate serenity; -extern crate typemap; - use std::{env, sync::Arc}; // Import the client's bridge to the voice manager. Since voice is a standalone @@ -26,6 +22,7 @@ use serenity::client::bridge::voice::ClientVoiceManager; use serenity::{client::{Context}, prelude::Mutex}; use serenity::{ + command, client::{CACHE, Client, EventHandler}, framework::StandardFramework, model::{channel::Message, gateway::Ready, misc::Mentionable}, diff --git a/examples/07_sample_bot_structure/Cargo.toml b/examples/07_sample_bot_structure/Cargo.toml index b1dba53e3a5..ad683b57e49 100644 --- a/examples/07_sample_bot_structure/Cargo.toml +++ b/examples/07_sample_bot_structure/Cargo.toml @@ -2,11 +2,12 @@ name = "07_sample_bot_structure" version = "0.1.0" authors = ["my name "] +edition = "2018" [dependencies] -env_logger = "~0.4" -kankyo = "~0.1" -log = "~0.3" +env_logger = "0.6" +kankyo = "0.2" +log = "0.4" [dependencies.serenity] features = ["cache", "framework", "standard_framework"] diff --git a/examples/07_sample_bot_structure/src/commands/math.rs b/examples/07_sample_bot_structure/src/commands/math.rs index 3aaccc46131..efe6d56a86b 100644 --- a/examples/07_sample_bot_structure/src/commands/math.rs +++ b/examples/07_sample_bot_structure/src/commands/math.rs @@ -1,3 +1,5 @@ +use serenity::command; + command!(multiply(_ctx, msg, args) { let one = args.single::().unwrap(); let two = args.single::().unwrap(); diff --git a/examples/07_sample_bot_structure/src/commands/meta.rs b/examples/07_sample_bot_structure/src/commands/meta.rs index 49197a88410..51654f51245 100644 --- a/examples/07_sample_bot_structure/src/commands/meta.rs +++ b/examples/07_sample_bot_structure/src/commands/meta.rs @@ -1,3 +1,5 @@ +use serenity::command; + command!(ping(_ctx, msg) { let _ = msg.channel_id.say("Pong!"); }); diff --git a/examples/07_sample_bot_structure/src/commands/owner.rs b/examples/07_sample_bot_structure/src/commands/owner.rs index 7836b8fb59a..8a246cda89c 100644 --- a/examples/07_sample_bot_structure/src/commands/owner.rs +++ b/examples/07_sample_bot_structure/src/commands/owner.rs @@ -1,3 +1,5 @@ +use serenity::command; + command!(quit(ctx, msg, _args) { ctx.quit(); diff --git a/examples/07_sample_bot_structure/src/main.rs b/examples/07_sample_bot_structure/src/main.rs index e06285a9f00..9f365c12fd3 100644 --- a/examples/07_sample_bot_structure/src/main.rs +++ b/examples/07_sample_bot_structure/src/main.rs @@ -8,13 +8,6 @@ //! git = "https://github.com/serenity-rs/serenity.git" //! features = ["framework", "standard_framework"] //! ``` - -#[macro_use] extern crate log; -#[macro_use] extern crate serenity; - -extern crate env_logger; -extern crate kankyo; - mod commands; use std::{collections::HashSet, env}; @@ -26,6 +19,8 @@ use serenity::{ http, }; +use log::{error, info}; + struct Handler; impl EventHandler for Handler { @@ -47,7 +42,7 @@ fn main() { // // In this case, a good default is setting the environment variable // `RUST_LOG` to debug`. - env_logger::init().expect("Failed to initialize env_logger"); + env_logger::init(); let token = env::var("DISCORD_TOKEN") .expect("Expected a token in the environment"); diff --git a/examples/08_env_logging/Cargo.toml b/examples/08_env_logging/Cargo.toml index a17d55e45d2..19046b6d930 100644 --- a/examples/08_env_logging/Cargo.toml +++ b/examples/08_env_logging/Cargo.toml @@ -2,10 +2,11 @@ name = "08_env_logging" version = "0.1.0" authors = ["my name "] +edition = "2018" [dependencies] -env_logger = "~0.4" -log = "~0.3" +env_logger = "0.6" +log = "0.4" [dependencies.serenity] features = ["client"] diff --git a/examples/08_env_logging/src/main.rs b/examples/08_env_logging/src/main.rs index 8e2f664b70a..e1ca4ab9d0c 100644 --- a/examples/08_env_logging/src/main.rs +++ b/examples/08_env_logging/src/main.rs @@ -1,8 +1,3 @@ -#[macro_use] extern crate log; - -extern crate env_logger; -extern crate serenity; - use std::env; use serenity::{ @@ -10,6 +5,8 @@ use serenity::{ prelude::*, }; +use log::{debug, error, info}; + struct Handler; impl EventHandler for Handler { @@ -33,7 +30,7 @@ fn main() { // // For example, you can say to log all levels INFO and up via setting the // environment variable `RUST_LOG` to `INFO`. - env_logger::init().expect("Unable to init env_logger"); + env_logger::init(); // Configure the client with your Discord bot token in the environment. let token = env::var("DISCORD_TOKEN") diff --git a/examples/09_shard_manager/Cargo.toml b/examples/09_shard_manager/Cargo.toml index 3e3c13f0a5e..2a17731ec91 100644 --- a/examples/09_shard_manager/Cargo.toml +++ b/examples/09_shard_manager/Cargo.toml @@ -2,10 +2,11 @@ name = "09_shard_manager" version = "0.1.0" authors = ["my name "] +edition = "2018" [dependencies] -env_logger = "~0.4" -log = "~0.4" +env_logger = "0.6" +log = "0.4" [dependencies.serenity] features = ["client"] diff --git a/examples/09_shard_manager/src/main.rs b/examples/09_shard_manager/src/main.rs index ce6f64df285..0b8cba29983 100644 --- a/examples/09_shard_manager/src/main.rs +++ b/examples/09_shard_manager/src/main.rs @@ -22,9 +22,6 @@ //! //! Note that it may take a minute or more for a latency to be recorded or to //! update, depending on how often Discord tells the client to send a heartbeat. - -extern crate serenity; - use std::{env, thread, time::Duration}; use serenity::{ diff --git a/examples/10_voice_receive/Cargo.toml b/examples/10_voice_receive/Cargo.toml index 655f20eb929..a3d14ff9bd9 100644 --- a/examples/10_voice_receive/Cargo.toml +++ b/examples/10_voice_receive/Cargo.toml @@ -2,10 +2,12 @@ name = "10_voice_receive" version = "0.1.0" authors = ["my name "] +edition = "2018" [dependencies] -env_logger = "~0.4" -log = "~0.4" +env_logger = "0.6" +log = "0.4" +typemap = "0.3" [dependencies.serenity] features = ["client", "standard_framework", "voice"] diff --git a/examples/10_voice_receive/src/main.rs b/examples/10_voice_receive/src/main.rs index 669b4bc04b5..2020ef0e068 100644 --- a/examples/10_voice_receive/src/main.rs +++ b/examples/10_voice_receive/src/main.rs @@ -6,14 +6,10 @@ //! git = "https://github.com/serenity-rs/serenity.git" //! features = ["client", "standard_framework", "voice"] //! ``` - -#[macro_use] extern crate serenity; - -extern crate typemap; - use std::{env, sync::Arc}; use serenity::{ + command, client::{bridge::voice::ClientVoiceManager, CACHE, Client, Context, EventHandler}, framework::StandardFramework, model::{channel::Message, gateway::Ready, id::ChannelId, misc::Mentionable}, diff --git a/examples/11_create_message_builder/Cargo.toml b/examples/11_create_message_builder/Cargo.toml index 07d66a87994..b1ee453294d 100644 --- a/examples/11_create_message_builder/Cargo.toml +++ b/examples/11_create_message_builder/Cargo.toml @@ -2,6 +2,7 @@ name = "11_create_message_builder" version = "0.1.0" authors = ["my name "] +edition = "2018" [dependencies] serenity = { path = "../../" } diff --git a/examples/11_create_message_builder/src/main.rs b/examples/11_create_message_builder/src/main.rs index 2dd3915fb99..ddc0e58e2b9 100644 --- a/examples/11_create_message_builder/src/main.rs +++ b/examples/11_create_message_builder/src/main.rs @@ -1,5 +1,3 @@ -extern crate serenity; - use std::env; use serenity::{ @@ -16,9 +14,9 @@ impl EventHandler for Handler { // using a builder syntax. // This example will create a message that says "Hello, World!", with an embed that has // a title, description, three fields, and a footer. - let msg = msg.channel_id.send_message(|mut m| { + let msg = msg.channel_id.send_message(|m| { m.content("Hello, World!"); - m.embed(|mut e| { + m.embed(|e| { e.title("This is a title"); e.description("This is a description"); e.fields(vec![ @@ -26,7 +24,7 @@ impl EventHandler for Handler { ("This is the second field", "Both of these fields are inline", true), ]); e.field("This is the third field", "This is not an inline field", false); - e.footer(|mut f| { + e.footer(|f| { f.text("This is a footer"); f diff --git a/src/builder/create_embed.rs b/src/builder/create_embed.rs index 38b287e32c7..22bdd43828e 100644 --- a/src/builder/create_embed.rs +++ b/src/builder/create_embed.rs @@ -16,17 +16,17 @@ //! [here]: https://discordapp.com/developers/docs/resources/channel#embed-object use chrono::{DateTime, TimeZone}; -use internal::prelude::*; -use model::channel::Embed; +use crate::internal::prelude::*; +use crate::model::channel::Embed; use serde_json::Value; use std::{ default::Default, fmt::Display }; -use utils::{self, VecMap}; +use crate::utils::{self, VecMap}; #[cfg(feature = "utils")] -use utils::Colour; +use crate::utils::Colour; /// A builder to create a fake [`Embed`] object, for use with the /// [`ChannelId::send_message`] and [`ExecuteWebhook::embeds`] methods. @@ -526,10 +526,10 @@ impl<'a, Tz: TimeZone> From<&'a DateTime> for Timestamp #[cfg(test)] mod test { - use model::channel::{Embed, EmbedField, EmbedFooter, EmbedImage, EmbedVideo}; + use crate::model::channel::{Embed, EmbedField, EmbedFooter, EmbedImage, EmbedVideo}; use serde_json::Value; use super::CreateEmbed; - use utils::{self, Colour}; + use crate::utils::{self, Colour}; #[test] fn test_from_embed() { diff --git a/src/builder/create_invite.rs b/src/builder/create_invite.rs index d4f706fc022..e1b60512e8f 100644 --- a/src/builder/create_invite.rs +++ b/src/builder/create_invite.rs @@ -1,7 +1,7 @@ -use internal::prelude::*; +use crate::internal::prelude::*; use serde_json::Value; use std::default::Default; -use utils::VecMap; +use crate::utils::VecMap; /// A builder to create a [`RichInvite`] for use via [`GuildChannel::create_invite`]. /// diff --git a/src/builder/create_message.rs b/src/builder/create_message.rs index 16c183bdb80..e4fe241c2fd 100644 --- a/src/builder/create_message.rs +++ b/src/builder/create_message.rs @@ -1,9 +1,9 @@ -use internal::prelude::*; -use http::AttachmentType; -use model::channel::ReactionType; +use crate::internal::prelude::*; +use crate::http::AttachmentType; +use crate::model::channel::ReactionType; use std::fmt::Display; use super::CreateEmbed; -use utils::{self, VecMap}; +use crate::utils::{self, VecMap}; /// A builder to specify the contents of an [`http::send_message`] request, /// primarily meant for use through [`ChannelId::send_message`]. diff --git a/src/builder/edit_channel.rs b/src/builder/edit_channel.rs index 1e82916da8a..8c635ba70d9 100644 --- a/src/builder/edit_channel.rs +++ b/src/builder/edit_channel.rs @@ -1,6 +1,6 @@ -use internal::prelude::*; -use utils::VecMap; -use model::id::ChannelId; +use crate::internal::prelude::*; +use crate::utils::VecMap; +use crate::model::id::ChannelId; /// A builder to edit a [`GuildChannel`] for use via [`GuildChannel::edit`] /// diff --git a/src/builder/edit_guild.rs b/src/builder/edit_guild.rs index a5b9a2b3f3c..55b553758b9 100644 --- a/src/builder/edit_guild.rs +++ b/src/builder/edit_guild.rs @@ -1,6 +1,6 @@ -use internal::prelude::*; -use model::prelude::*; -use utils::VecMap; +use crate::internal::prelude::*; +use crate::model::prelude::*; +use crate::utils::VecMap; /// A builder to optionally edit certain fields of a [`Guild`]. This is meant /// for usage with [`Guild::edit`]. diff --git a/src/builder/edit_member.rs b/src/builder/edit_member.rs index 42d8e9f6685..ed66f59fba5 100644 --- a/src/builder/edit_member.rs +++ b/src/builder/edit_member.rs @@ -1,6 +1,6 @@ -use internal::prelude::*; -use model::id::{ChannelId, RoleId}; -use utils::VecMap; +use crate::internal::prelude::*; +use crate::model::id::{ChannelId, RoleId}; +use crate::utils::VecMap; /// A builder which edits the properties of a [`Member`], to be used in /// conjunction with [`Member::edit`]. diff --git a/src/builder/edit_message.rs b/src/builder/edit_message.rs index ba6d14c8be4..2410a13434f 100644 --- a/src/builder/edit_message.rs +++ b/src/builder/edit_message.rs @@ -1,7 +1,7 @@ -use internal::prelude::*; +use crate::internal::prelude::*; use std::fmt::Display; use super::CreateEmbed; -use utils::{self, VecMap}; +use crate::utils::{self, VecMap}; /// A builder to specify the fields to edit in an existing message. /// diff --git a/src/builder/edit_profile.rs b/src/builder/edit_profile.rs index ae2296ca097..a8a7b2aeb04 100644 --- a/src/builder/edit_profile.rs +++ b/src/builder/edit_profile.rs @@ -1,5 +1,5 @@ -use internal::prelude::*; -use utils::VecMap; +use crate::internal::prelude::*; +use crate::utils::VecMap; /// A builder to edit the current user's settings, to be used in conjunction /// with [`CurrentUser::edit`]. diff --git a/src/builder/edit_role.rs b/src/builder/edit_role.rs index 96f12fe26dd..34d2d17c95a 100644 --- a/src/builder/edit_role.rs +++ b/src/builder/edit_role.rs @@ -1,9 +1,9 @@ -use internal::prelude::*; -use model::{ +use crate::internal::prelude::*; +use crate::model::{ guild::Role, Permissions }; -use utils::VecMap; +use crate::utils::VecMap; /// A builder to create or edit a [`Role`] for use via a number of model methods. /// diff --git a/src/builder/execute_webhook.rs b/src/builder/execute_webhook.rs index d8a0da0e295..487a8a5c8df 100644 --- a/src/builder/execute_webhook.rs +++ b/src/builder/execute_webhook.rs @@ -1,6 +1,6 @@ use serde_json::Value; use std::default::Default; -use utils::VecMap; +use crate::utils::VecMap; /// A builder to create the inner content of a [`Webhook`]'s execution. /// diff --git a/src/builder/get_messages.rs b/src/builder/get_messages.rs index 0b809d6d394..6629f9ed9b9 100644 --- a/src/builder/get_messages.rs +++ b/src/builder/get_messages.rs @@ -1,5 +1,5 @@ -use model::id::MessageId; -use utils::VecMap; +use crate::model::id::MessageId; +use crate::utils::VecMap; /// Builds a request for a request to the API to retrieve messages. /// diff --git a/src/cache/cache_update.rs b/src/cache/cache_update.rs index ba79727e8d3..2abfd802193 100644 --- a/src/cache/cache_update.rs +++ b/src/cache/cache_update.rs @@ -101,5 +101,5 @@ pub trait CacheUpdate { type Output; /// Updates the cache with the implementation. - fn update(&mut self, &mut Cache) -> Option; + fn update(&mut self, _: &mut Cache) -> Option; } diff --git a/src/cache/mod.rs b/src/cache/mod.rs index f3f9fe42830..a2c133fb8df 100644 --- a/src/cache/mod.rs +++ b/src/cache/mod.rs @@ -42,7 +42,7 @@ //! [`CACHE`]: ../struct.CACHE.html //! [`http`]: ../http/index.html -use model::prelude::*; +use crate::model::prelude::*; use parking_lot::RwLock; use std::collections::{ hash_map::Entry, @@ -808,7 +808,7 @@ mod test { collections::HashMap, sync::Arc, }; - use { + use crate::{ cache::{Cache, CacheUpdate, Settings}, model::prelude::*, prelude::RwLock, diff --git a/src/client/bridge/gateway/event.rs b/src/client/bridge/gateway/event.rs index a967ab538fd..0f9dbec7498 100644 --- a/src/client/bridge/gateway/event.rs +++ b/src/client/bridge/gateway/event.rs @@ -2,7 +2,7 @@ //! itself. use super::ShardId; -use ::gateway::ConnectionStage; +use crate::gateway::ConnectionStage; #[derive(Clone, Debug)] pub(crate) enum ClientEvent { diff --git a/src/client/bridge/gateway/mod.rs b/src/client/bridge/gateway/mod.rs index a542dbc601d..65b47737402 100644 --- a/src/client/bridge/gateway/mod.rs +++ b/src/client/bridge/gateway/mod.rs @@ -73,7 +73,7 @@ use std::{ sync::mpsc::Sender, time::Duration as StdDuration }; -use ::gateway::{ConnectionStage, InterMessage}; +use crate::gateway::{ConnectionStage, InterMessage}; /// A message either for a [`ShardManager`] or a [`ShardRunner`]. /// diff --git a/src/client/bridge/gateway/shard_manager.rs b/src/client/bridge/gateway/shard_manager.rs index da4b6982d5c..81d1b9002b3 100644 --- a/src/client/bridge/gateway/shard_manager.rs +++ b/src/client/bridge/gateway/shard_manager.rs @@ -1,5 +1,5 @@ -use gateway::InterMessage; -use internal::prelude::*; +use crate::gateway::InterMessage; +use crate::internal::prelude::*; use parking_lot::Mutex; use std::{ collections::{HashMap, VecDeque}, @@ -23,9 +23,9 @@ use threadpool::ThreadPool; use typemap::ShareMap; #[cfg(feature = "framework")] -use framework::Framework; +use crate::framework::Framework; #[cfg(feature = "voice")] -use client::bridge::voice::ClientVoiceManager; +use crate::client::bridge::voice::ClientVoiceManager; /// A manager for handling the status of shards by starting them, restarting /// them, and stopping them when required. diff --git a/src/client/bridge/gateway/shard_messenger.rs b/src/client/bridge/gateway/shard_messenger.rs index c2236ed29bb..b29f14fadd8 100644 --- a/src/client/bridge/gateway/shard_messenger.rs +++ b/src/client/bridge/gateway/shard_messenger.rs @@ -1,5 +1,5 @@ -use gateway::InterMessage; -use model::prelude::*; +use crate::gateway::InterMessage; +use crate::model::prelude::*; use super::{ShardClientMessage, ShardRunnerMessage}; use std::sync::mpsc::{SendError, Sender}; use tungstenite::Message; diff --git a/src/client/bridge/gateway/shard_queuer.rs b/src/client/bridge/gateway/shard_queuer.rs index 07c6a2ff50f..5152249b742 100644 --- a/src/client/bridge/gateway/shard_queuer.rs +++ b/src/client/bridge/gateway/shard_queuer.rs @@ -1,5 +1,5 @@ -use gateway::Shard; -use internal::prelude::*; +use crate::gateway::Shard; +use crate::internal::prelude::*; use parking_lot::Mutex; use std::{ collections::{HashMap, VecDeque}, @@ -24,12 +24,12 @@ use super::{ }; use threadpool::ThreadPool; use typemap::ShareMap; -use ::gateway::ConnectionStage; +use crate::gateway::ConnectionStage; #[cfg(feature = "voice")] -use client::bridge::voice::ClientVoiceManager; +use crate::client::bridge::voice::ClientVoiceManager; #[cfg(feature = "framework")] -use framework::Framework; +use crate::framework::Framework; const WAIT_BETWEEN_BOOTS_IN_SECONDS: u64 = 5; diff --git a/src/client/bridge/gateway/shard_runner.rs b/src/client/bridge/gateway/shard_runner.rs index c462937f71f..5e2a1ff5d90 100644 --- a/src/client/bridge/gateway/shard_runner.rs +++ b/src/client/bridge/gateway/shard_runner.rs @@ -1,7 +1,7 @@ -use gateway::{InterMessage, ReconnectType, Shard, ShardAction}; -use internal::prelude::*; -use internal::ws_impl::{ReceiverExt, SenderExt}; -use model::event::{Event, GatewayEvent}; +use crate::gateway::{InterMessage, ReconnectType, Shard, ShardAction}; +use crate::internal::prelude::*; +use crate::internal::ws_impl::{ReceiverExt, SenderExt}; +use crate::model::event::{Event, GatewayEvent}; use parking_lot::Mutex; use serde::Deserialize; use std::{ @@ -28,7 +28,7 @@ use tungstenite::{ use typemap::ShareMap; #[cfg(feature = "framework")] -use framework::Framework; +use crate::framework::Framework; #[cfg(feature = "voice")] use super::super::voice::ClientVoiceManager; diff --git a/src/client/bridge/gateway/shard_runner_message.rs b/src/client/bridge/gateway/shard_runner_message.rs index 76fb1feab15..6a4abc4de57 100644 --- a/src/client/bridge/gateway/shard_runner_message.rs +++ b/src/client/bridge/gateway/shard_runner_message.rs @@ -1,4 +1,4 @@ -use model::{ +use crate::model::{ gateway::Activity, id::GuildId, user::OnlineStatus, diff --git a/src/client/bridge/voice/mod.rs b/src/client/bridge/voice/mod.rs index e67366b8d51..ae104a484ba 100644 --- a/src/client/bridge/voice/mod.rs +++ b/src/client/bridge/voice/mod.rs @@ -1,9 +1,9 @@ -use gateway::InterMessage; +use crate::gateway::InterMessage; use std::collections::HashMap; use std::sync::mpsc::Sender as MpscSender; -use ::model::id::{ChannelId, GuildId, UserId}; -use ::voice::{Handler, Manager}; -use ::utils; +use crate::model::id::{ChannelId, GuildId, UserId}; +use crate::voice::{Handler, Manager}; +use crate::utils; pub struct ClientVoiceManager { managers: HashMap, diff --git a/src/client/context.rs b/src/client/context.rs index 04fe642bbaf..8a08213f43a 100644 --- a/src/client/context.rs +++ b/src/client/context.rs @@ -1,10 +1,10 @@ -use builder::EditProfile; -use CACHE; -use client::bridge::gateway::ShardMessenger; -use error::Result; -use gateway::InterMessage; -use http; -use model::prelude::*; +use crate::builder::EditProfile; +use crate::CACHE; +use crate::client::bridge::gateway::ShardMessenger; +use crate::error::Result; +use crate::gateway::InterMessage; +use crate::http; +use crate::model::prelude::*; use parking_lot::Mutex; use serde_json::Value; use std::sync::{ @@ -12,8 +12,8 @@ use std::sync::{ mpsc::Sender }; use typemap::ShareMap; -use utils::VecMap; -use utils::vecmap_to_json_map; +use crate::utils::VecMap; +use crate::utils::vecmap_to_json_map; /// The context is a general utility struct provided on event dispatches, which /// helps with dealing with the current "context" of the event dispatch. diff --git a/src/client/dispatch.rs b/src/client/dispatch.rs index 7ac8148f7b5..5ed5f3e264b 100644 --- a/src/client/dispatch.rs +++ b/src/client/dispatch.rs @@ -1,5 +1,5 @@ -use gateway::InterMessage; -use model::{ +use crate::gateway::InterMessage; +use crate::model::{ channel::{Channel, Message}, event::Event, guild::Member, @@ -16,9 +16,9 @@ use threadpool::ThreadPool; use typemap::ShareMap; #[cfg(feature = "framework")] -use framework::Framework; +use crate::framework::Framework; #[cfg(feature = "cache")] -use model::id::GuildId; +use crate::model::id::GuildId; #[cfg(feature = "cache")] use std::time::Duration; @@ -70,7 +70,7 @@ pub(crate) enum DispatchEvent { } #[cfg(feature = "framework")] -#[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))] +#[clippy::too_many_arguments] pub(crate) fn dispatch( event: DispatchEvent, framework: &Arc>>>, @@ -108,7 +108,7 @@ pub(crate) fn dispatch( } #[cfg(not(feature = "framework"))] -#[allow(unused_mut)] +#[allow(clippy::unused_mut)] pub(crate) fn dispatch( event: DispatchEvent, data: &Arc>, @@ -135,7 +135,7 @@ pub(crate) fn dispatch( } } -#[allow(unused_mut)] +#[allow(clippy::unused_mut)] fn dispatch_message( context: Context, mut message: Message, @@ -154,7 +154,7 @@ fn dispatch_message( }); } -#[allow(cyclomatic_complexity, unused_assignments, unused_mut)] +#[allow(clippy::cyclomatic_complexity, unused_assignments, unused_mut)] fn handle_event( event: DispatchEvent, data: &Arc>, diff --git a/src/client/error.rs b/src/client/error.rs index 4858f29ada5..f07eeae4f85 100644 --- a/src/client/error.rs +++ b/src/client/error.rs @@ -16,7 +16,7 @@ use std::{ /// [`Error`]: ../enum.Error.html /// [`Error::Client`]: ../enum.Error.html#variant.Client /// [`GuildId::ban`]: ../model/id/struct.GuildId.html#method.ban -#[allow(enum_variant_names)] +#[allow(clippy::enum_variant_names)] #[derive(Clone, Debug, Eq, Hash, PartialEq)] pub enum Error { /// When the token provided is invalid. This is returned when validating a diff --git a/src/client/event_handler.rs b/src/client/event_handler.rs index 8b355de271e..be29563292b 100644 --- a/src/client/event_handler.rs +++ b/src/client/event_handler.rs @@ -1,4 +1,4 @@ -use model::prelude::*; +use crate::model::prelude::*; use parking_lot::RwLock; use serde_json::Value; use std::{ @@ -6,7 +6,7 @@ use std::{ sync::Arc }; use super::context::Context; -use ::client::bridge::gateway::event::*; +use crate::client::bridge::gateway::event::*; /// The core trait for handling events by serenity. pub trait EventHandler { diff --git a/src/client/mod.rs b/src/client/mod.rs index 34270772158..77de01ee832 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -17,7 +17,7 @@ //! [`Client`]: struct.Client.html#examples //! [`Context`]: struct.Context.html //! [Client examples]: struct.Client.html#examples -#![allow(zero_ptr)] +#![allow(clippy::zero_ptr)] pub mod bridge; @@ -33,14 +33,14 @@ pub use self::{ }; // Note: the following re-exports are here for backwards compatibility -pub use gateway; -pub use http as rest; +pub use crate::gateway; +pub use crate::http as rest; #[cfg(feature = "cache")] -pub use CACHE; +pub use crate::CACHE; -use http; -use internal::prelude::*; +use crate::http; +use crate::internal::prelude::*; use parking_lot::Mutex; use self::bridge::gateway::{ShardManager, ShardManagerMonitor, ShardManagerOptions}; use std::sync::Arc; @@ -48,9 +48,9 @@ use threadpool::ThreadPool; use typemap::ShareMap; #[cfg(feature = "framework")] -use framework::Framework; +use crate::framework::Framework; #[cfg(feature = "voice")] -use model::id::UserId; +use crate::model::id::UserId; #[cfg(feature = "voice")] use self::bridge::voice::ClientVoiceManager; diff --git a/src/error.rs b/src/error.rs index 3c9e61aba0e..0d5fdfa8cab 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,5 +1,5 @@ -use internal::prelude::*; -use model::ModelError; +use crate::internal::prelude::*; +use crate::model::ModelError; use serde_json::Error as JsonError; use std::{ error::Error as StdError, @@ -19,13 +19,13 @@ use opus::Error as OpusError; #[cfg(feature = "tungstenite")] use tungstenite::error::Error as TungsteniteError; #[cfg(feature = "client")] -use client::ClientError; +use crate::client::ClientError; #[cfg(feature = "gateway")] -use gateway::GatewayError; +use crate::gateway::GatewayError; #[cfg(feature = "http")] -use http::HttpError; +use crate::http::HttpError; #[cfg(feature = "voice")] -use voice::VoiceError; +use crate::voice::VoiceError; /// The common result type between most library functions. /// diff --git a/src/framework/mod.rs b/src/framework/mod.rs index 92adb99538f..9f072a6171c 100644 --- a/src/framework/mod.rs +++ b/src/framework/mod.rs @@ -66,20 +66,20 @@ pub mod standard; #[cfg(feature = "standard_framework")] pub use self::standard::StandardFramework; -use client::Context; -use model::channel::Message; +use crate::client::Context; +use crate::model::channel::Message; use threadpool::ThreadPool; #[cfg(feature = "standard_framework")] -use model::id::UserId; +use crate::model::id::UserId; /// This trait allows for serenity to either use its builtin framework, or yours. pub trait Framework { - fn dispatch(&mut self, Context, Message, &ThreadPool); + fn dispatch(&mut self, _: Context, _: Message, _: &ThreadPool); #[doc(hidden)] #[cfg(feature = "standard_framework")] - fn update_current_user(&mut self, UserId) {} + fn update_current_user(&mut self, _: UserId) {} } impl Framework for Box { diff --git a/src/framework/standard/buckets.rs b/src/framework/standard/buckets.rs index 22bcc23e6e6..ea66f7e64ba 100644 --- a/src/framework/standard/buckets.rs +++ b/src/framework/standard/buckets.rs @@ -1,6 +1,6 @@ use chrono::Utc; -use client::Context; -use model::id::{ChannelId, GuildId, UserId}; +use crate::client::Context; +use crate::model::id::{ChannelId, GuildId, UserId}; use std::{ collections::HashMap, default::Default diff --git a/src/framework/standard/command.rs b/src/framework/standard/command.rs index 5345f4b2085..964f78874ef 100644 --- a/src/framework/standard/command.rs +++ b/src/framework/standard/command.rs @@ -1,5 +1,5 @@ -use client::Context; -use model::{ +use crate::client::Context; +use crate::model::{ channel::{ Message, Channel, @@ -12,7 +12,7 @@ use std::{ fmt::{Debug, Formatter}, sync::Arc }; -use utils::Colour; +use crate::utils::Colour; use super::{Args, Configuration, HelpBehaviour}; type CheckFunction = Fn(&mut Context, &Message, &mut Args, &CommandOptions) -> bool @@ -228,7 +228,7 @@ pub struct HelpOptions { } pub trait HelpCommand: Send + Sync + 'static { - fn execute(&self, &mut Context, &Message, &HelpOptions, HashMap>, &Args) -> Result<(), Error>; + fn execute(&self, _: &mut Context, _: &Message, _: &HelpOptions, _: HashMap>, _: &Args) -> Result<(), Error>; fn options(&self) -> Arc { Arc::clone(&DEFAULT_OPTIONS) @@ -278,7 +278,7 @@ lazy_static! { /// A framework command. pub trait Command: Send + Sync + 'static { - fn execute(&self, &mut Context, &Message, Args) -> Result<(), Error>; + fn execute(&self, _: &mut Context, _: &Message, _: Args) -> Result<(), Error>; fn options(&self) -> Arc { Arc::clone(&DEFAULT_OPTIONS) @@ -288,10 +288,10 @@ pub trait Command: Send + Sync + 'static { fn init(&self) {} /// "before" middleware. Is called alongside the global middleware in the framework. - fn before(&self, &mut Context, &Message) -> bool { true } + fn before(&self, _: &mut Context, _: &Message) -> bool { true } /// "after" middleware. Is called alongside the global middleware in the framework. - fn after(&self, &mut Context, &Message, &Result<(), Error>) { } + fn after(&self, _: &mut Context, _: &Message, _: &Result<(), Error>) { } } impl Command for Arc { diff --git a/src/framework/standard/configuration.rs b/src/framework/standard/configuration.rs index 3465cd60332..80d1f50dae8 100644 --- a/src/framework/standard/configuration.rs +++ b/src/framework/standard/configuration.rs @@ -1,6 +1,6 @@ -use client::Context; -use http; -use model::{ +use crate::client::Context; +use crate::http; +use crate::model::{ channel::Message, id::{ChannelId, GuildId, UserId} }; diff --git a/src/framework/standard/create_command.rs b/src/framework/standard/create_command.rs index 3976f6d6244..0543fd92701 100644 --- a/src/framework/standard/create_command.rs +++ b/src/framework/standard/create_command.rs @@ -7,8 +7,8 @@ pub use super::{ Check, }; -use client::Context; -use model::{ +use crate::client::Context; +use crate::model::{ channel::Message, Permissions }; diff --git a/src/framework/standard/create_group.rs b/src/framework/standard/create_group.rs index 3c144798f39..39980c42715 100644 --- a/src/framework/standard/create_group.rs +++ b/src/framework/standard/create_group.rs @@ -12,8 +12,8 @@ pub use super::{ Check, }; -use client::Context; -use model::{ +use crate::client::Context; +use crate::model::{ channel::Message, Permissions, }; diff --git a/src/framework/standard/create_help_command.rs b/src/framework/standard/create_help_command.rs index c05cb32d697..40d0128b168 100644 --- a/src/framework/standard/create_help_command.rs +++ b/src/framework/standard/create_help_command.rs @@ -11,7 +11,7 @@ pub use super::{ HelpBehaviour }; -use utils::Colour; +use crate::utils::Colour; use std::{ fmt::Write, sync::Arc diff --git a/src/framework/standard/help_commands.rs b/src/framework/standard/help_commands.rs index 78fedf8f052..bde965bfa95 100644 --- a/src/framework/standard/help_commands.rs +++ b/src/framework/standard/help_commands.rs @@ -23,14 +23,14 @@ //! [`plain`]: fn.plain.html //! [`with_embeds`]: fn.with_embeds.html -use client::Context; +use crate::client::Context; #[cfg(feature = "cache")] -use framework::standard::{has_correct_roles, has_correct_permissions}; -use model::{ +use crate::framework::standard::{has_correct_roles, has_correct_permissions}; +use crate::model::{ channel::Message, id::ChannelId, }; -use Error; +use crate::Error; use std::{ borrow::Borrow, collections::HashMap, @@ -49,7 +49,7 @@ use super::{ CommandError, HelpBehaviour, }; -use utils::Colour; +use crate::utils::Colour; /// Macro to format a command according to a `HelpBehaviour` or /// continue to the next command-name upon hiding. @@ -317,7 +317,7 @@ fn fetch_single_command<'a, H: BuildHasher>( for (command_name, command) in &group.commands { - let search_command_name_matched = if let &Some(ref prefixes) = &group.prefixes { + let search_command_name_matched = if let Some(ref prefixes) = group.prefixes { prefixes.iter().any(|prefix| { format!("{} {}", prefix, command_name) == name }) @@ -361,7 +361,7 @@ fn fetch_single_command<'a, H: BuildHasher>( if let &CommandOrAlias::Command(ref cmd) = command { - let command_name = if let &Some(ref prefixes) = &group.prefixes { + let command_name = if let Some(ref prefixes) = group.prefixes { if let Some(first_prefix) = prefixes.get(0) { format!("{} {}", &first_prefix, &command_name).to_string() } else { @@ -589,7 +589,7 @@ pub fn create_customised_help_data<'a, H: BuildHasher>( &help_options.striked_commands_tip_in_dm }; - let description = if let &Some(ref striked_command_text) = strikethrough_command_tip { + let description = if let Some(ref striked_command_text) = strikethrough_command_tip { format!( "{}\n{}", &help_options.individual_command_tip, &striked_command_text @@ -663,11 +663,11 @@ fn send_single_command_embed( embed.title(&command.name); embed.colour(colour); - if let &Some(ref desc) = &command.description { + if let Some(ref desc) = command.description { embed.description(desc); } - if let &Some(ref usage) = &command.usage { + if let Some(ref usage) = command.usage { embed.field(&help_options.usage_label, usage, true); } @@ -753,21 +753,21 @@ pub fn with_embeds( ) -> Result<(), CommandError> { let formatted_help = create_customised_help_data(&groups, args, help_options, msg); - if let Err(why) = match &formatted_help { - &CustomisedHelpData::SuggestedCommands { ref help_description, ref suggestions } => + if let Err(why) = match formatted_help { + CustomisedHelpData::SuggestedCommands { ref help_description, ref suggestions } => send_suggestion_embed( msg.channel_id, &help_description, &suggestions, help_options.embed_error_colour, ), - &CustomisedHelpData::NoCommandFound { ref help_error_message } => + CustomisedHelpData::NoCommandFound { ref help_error_message } => send_error_embed( msg.channel_id, help_error_message, help_options.embed_error_colour, ), - &CustomisedHelpData::GroupedCommands { ref help_description, ref groups } => + CustomisedHelpData::GroupedCommands { ref help_description, ref groups } => send_grouped_commands_embed( &help_options, msg.channel_id, @@ -775,7 +775,7 @@ pub fn with_embeds( &groups, help_options.embed_success_colour, ), - &CustomisedHelpData::SingleCommand { ref command } => + CustomisedHelpData::SingleCommand { ref command } => send_single_command_embed( &help_options, msg.channel_id, @@ -820,15 +820,15 @@ fn single_command_to_plain_string(help_options: &HelpOptions, command: &Command) let _ = writeln!(result, "**{}**: `{}`", help_options.aliases_label, command.aliases.join("`, `")); } - if let &Some(ref description) = &command.description { + if let Some(ref description) = command.description { let _ = writeln!(result, "**{}**: {}", help_options.description_label, description); }; - if let &Some(ref usage) = &command.usage { + if let Some(ref usage) = command.usage { let _ = writeln!(result, "**{}**: {}", help_options.usage_label, usage); } - if let &Some(ref usage_sample) = &command.usage_sample { + if let Some(ref usage_sample) = command.usage_sample { let _ = writeln!(result, "**{}**: `{} {}`", help_options.usage_sample_label, command.name, usage_sample); } @@ -866,14 +866,14 @@ pub fn plain( ) -> Result<(), CommandError> { let formatted_help = create_customised_help_data(&groups, args, help_options, msg); - let result = match &formatted_help { - &CustomisedHelpData::SuggestedCommands { ref help_description, ref suggestions } => + let result = match formatted_help { + CustomisedHelpData::SuggestedCommands { ref help_description, ref suggestions } => format!("{}: `{}`", help_description, suggestions.join("`, `")), - &CustomisedHelpData::NoCommandFound { ref help_error_message } => + CustomisedHelpData::NoCommandFound { ref help_error_message } => help_error_message.to_string(), - &CustomisedHelpData::GroupedCommands { ref help_description, ref groups } => + CustomisedHelpData::GroupedCommands { ref help_description, ref groups } => grouped_commands_to_plain_string(&help_options, &help_description, &groups), - &CustomisedHelpData::SingleCommand { ref command } => { + CustomisedHelpData::SingleCommand { ref command } => { single_command_to_plain_string(&help_options, &command) }, }; diff --git a/src/framework/standard/mod.rs b/src/framework/standard/mod.rs index 43e5dc156b0..c23f8ce145a 100644 --- a/src/framework/standard/mod.rs +++ b/src/framework/standard/mod.rs @@ -31,9 +31,9 @@ pub use self::create_help_command::CreateHelpCommand; pub use self::create_command::{CreateCommand, FnOrCommand}; pub use self::create_group::CreateGroup; -use client::Context; -use internal::RwLockExt; -use model::{ +use crate::client::Context; +use crate::internal::RwLockExt; +use crate::model::{ channel::Message, guild::{Guild, Member}, id::{ChannelId, GuildId, UserId}, @@ -49,9 +49,9 @@ use super::Framework; use threadpool::ThreadPool; #[cfg(feature = "cache")] -use client::CACHE; +use crate::client::CACHE; #[cfg(feature = "cache")] -use model::channel::Channel; +use crate::model::channel::Channel; /// A convenience macro for generating a struct fulfilling the [`Command`][command trait] trait. /// @@ -95,11 +95,11 @@ use model::channel::Channel; #[macro_export] macro_rules! command { ($fname:ident($c:ident) $b:block) => { - #[allow(non_camel_case_types)] + #[allow(clippy::non_camel_case_types)] pub struct $fname; impl $crate::framework::standard::Command for $fname { - #[allow(unreachable_code, unused_mut)] + #[allow(clippy::unreachable_code, unused_mut)] fn execute(&self, mut $c: &mut $crate::client::Context, _: &$crate::model::channel::Message, _: $crate::framework::standard::Args) @@ -112,11 +112,11 @@ macro_rules! command { } }; ($fname:ident($c:ident, $m:ident) $b:block) => { - #[allow(non_camel_case_types)] + #[allow(clippy::non_camel_case_types)] pub struct $fname; impl $crate::framework::standard::Command for $fname { - #[allow(unreachable_code, unused_mut)] + #[allow(clippy::unreachable_code, unused_mut)] fn execute(&self, mut $c: &mut $crate::client::Context, $m: &$crate::model::channel::Message, _: $crate::framework::standard::Args) @@ -129,11 +129,11 @@ macro_rules! command { } }; ($fname:ident($c:ident, $m:ident, $a:ident) $b:block) => { - #[allow(non_camel_case_types)] + #[allow(clippy::non_camel_case_types)] pub struct $fname; impl $crate::framework::standard::Command for $fname { - #[allow(unreachable_code, unused_mut)] + #[allow(clippy::unreachable_code, unused_mut)] fn execute(&self, mut $c: &mut $crate::client::Context, $m: &$crate::model::channel::Message, mut $a: $crate::framework::standard::Args) @@ -498,8 +498,8 @@ impl StandardFramework { .contains(&message.channel_id) } - #[allow(too_many_arguments)] - #[cfg_attr(feature = "cargo-clippy", allow(cyclomatic_complexity))] + #[allow(clippy::too_many_arguments)] + #[allow(clippy::cyclomatic_complexity)] fn should_fail(&mut self, mut context: &mut Context, message: &Message, @@ -1074,7 +1074,7 @@ impl Framework for StandardFramework { positions }, None => { - if let &Some(ref message_without_command) = &self.message_without_command { + if let Some(ref message_without_command) = self.message_without_command { if !(self.configuration.ignore_bots && message.author.bot) { let message_without_command = message_without_command.clone(); @@ -1230,7 +1230,7 @@ impl Framework for StandardFramework { if check_contains_group_prefix { - if let &Some(CommandOrAlias::Command(ref command)) = &group.default_command { + if let Some(CommandOrAlias::Command(ref command)) = group.default_command { let command = Arc::clone(command); let mut args = { Args::new(&orginal_round[longest_matching_prefix_len..], &self.configuration.delimiters) @@ -1280,11 +1280,11 @@ impl Framework for StandardFramework { if !(self.configuration.ignore_bots && message.author.bot) { - if let &Some(ref unrecognised_command) = &self.unrecognised_command { + if let Some(ref unrecognised_command) = self.unrecognised_command { // If both functions are set, we need to clone `Context` and // `Message`, else we can avoid it. - if let &Some(ref message_without_command) = &self.message_without_command { + if let Some(ref message_without_command) = self.message_without_command { let mut context_unrecognised = context.clone(); let mut message_unrecognised = message.clone(); @@ -1304,7 +1304,7 @@ impl Framework for StandardFramework { (unrecognised_command)(&mut context, &message, &unrecognised_command_name); }); } - } else if let &Some(ref message_without_command) = &self.message_without_command { + } else if let Some(ref message_without_command) = self.message_without_command { let message_without_command = message_without_command.clone(); threadpool.execute(move || { (message_without_command)(&mut context, &message); diff --git a/src/gateway/mod.rs b/src/gateway/mod.rs index 75f083d6efe..bfc27c0e56b 100644 --- a/src/gateway/mod.rs +++ b/src/gateway/mod.rs @@ -56,7 +56,7 @@ pub use self::{ ws_client_ext::WebSocketGatewayClientExt }; -use model::{ +use crate::model::{ gateway::Activity, user::OnlineStatus, }; @@ -68,7 +68,7 @@ use tungstenite::{ }; #[cfg(feature = "client")] -use client::bridge::gateway::ShardClientMessage; +use crate::client::bridge::gateway::ShardClientMessage; pub type CurrentPresence = (Option, OnlineStatus); pub type WsClient = WebSocket; diff --git a/src/gateway/shard.rs b/src/gateway/shard.rs index bdcb4ac3505..8dbcf87d583 100644 --- a/src/gateway/shard.rs +++ b/src/gateway/shard.rs @@ -1,6 +1,6 @@ -use constants::{self, close_codes}; -use internal::prelude::*; -use model::{ +use crate::constants::{self, close_codes}; +use crate::internal::prelude::*; +use crate::model::{ event::{Event, GatewayEvent}, gateway::Activity, id::GuildId, @@ -361,7 +361,7 @@ impl Shard { /// /// Returns a `GatewayError::OverloadedShard` if the shard would have too /// many guilds assigned to it. - #[allow(cyclomatic_complexity)] + #[allow(clippy::cyclomatic_complexity)] pub(crate) fn handle_event(&mut self, event: &Result) -> Result> { match *event { @@ -841,7 +841,7 @@ fn set_client_timeout(client: &mut WsClient) -> Result<()> { tungstenite::stream::Stream::Plain(stream) => stream, tungstenite::stream::Stream::Tls(stream) => stream.get_mut(), }; - + stream.set_read_timeout(Some(StdDuration::from_millis(500)))?; stream.set_write_timeout(Some(StdDuration::from_secs(50)))?; diff --git a/src/gateway/ws_client_ext.rs b/src/gateway/ws_client_ext.rs index 27f11ee56ad..24cdf15e50d 100644 --- a/src/gateway/ws_client_ext.rs +++ b/src/gateway/ws_client_ext.rs @@ -1,9 +1,9 @@ use chrono::Utc; -use constants::{self, OpCode}; -use gateway::{CurrentPresence, WsClient}; -use internal::prelude::*; -use internal::ws_impl::SenderExt; -use model::id::GuildId; +use crate::constants::{self, OpCode}; +use crate::gateway::{CurrentPresence, WsClient}; +use crate::internal::prelude::*; +use crate::internal::ws_impl::SenderExt; +use crate::model::id::GuildId; use std::env::consts; pub trait WebSocketGatewayClientExt { diff --git a/src/http/mod.rs b/src/http/mod.rs index 8093843611c..141dc12dd32 100644 --- a/src/http/mod.rs +++ b/src/http/mod.rs @@ -38,7 +38,7 @@ use reqwest::{ Client as ReqwestClient, Method, }; -use model::prelude::*; +use crate::model::prelude::*; use parking_lot::Mutex; use self::{request::Request}; use std::{ diff --git a/src/http/ratelimiting.rs b/src/http/ratelimiting.rs index c2c2bbae804..168fa51584e 100644 --- a/src/http/ratelimiting.rs +++ b/src/http/ratelimiting.rs @@ -38,7 +38,7 @@ //! differentiating between different ratelimits. //! //! [Taken from]: https://discordapp.com/developers/docs/topics/rate-limits#rate-limits -#![allow(zero_ptr)] +#![allow(clippy::zero_ptr)] pub use super::routing::Route; @@ -48,7 +48,7 @@ use reqwest::{ header::HeaderMap as Headers, StatusCode, }; -use internal::prelude::*; +use crate::internal::prelude::*; use parking_lot::Mutex; use std::{ collections::HashMap, diff --git a/src/http/raw.rs b/src/http/raw.rs index 742ca5c4ec7..2e09abbfb66 100644 --- a/src/http/raw.rs +++ b/src/http/raw.rs @@ -1,4 +1,4 @@ -use constants; +use crate::constants; use reqwest::{ Client as ReqwestClient, header::{AUTHORIZATION, USER_AGENT, CONTENT_TYPE, HeaderValue, HeaderMap as Headers}, @@ -7,8 +7,8 @@ use reqwest::{ StatusCode, Url, }; -use internal::prelude::*; -use model::prelude::*; +use crate::internal::prelude::*; +use crate::model::prelude::*; use super::{ TOKEN, ratelimiting, @@ -1207,11 +1207,11 @@ pub fn get_guilds(target: &GuildPagination, limit: u64) -> Result } /// Gets information about a specific invite. -#[allow(unused_mut)] +#[allow(clippy::unused_mut)] pub fn get_invite(mut code: &str, stats: bool) -> Result { #[cfg(feature = "utils")] { - code = ::utils::parse_invite(code); + code = crate::utils::parse_invite(code); } fire(Request { diff --git a/src/http/request.rs b/src/http/request.rs index cbb8f79dc2f..b469b6d3ec4 100644 --- a/src/http/request.rs +++ b/src/http/request.rs @@ -1,4 +1,4 @@ -use constants; +use crate::constants; use reqwest::{ RequestBuilder as ReqwestRequestBuilder, header::{AUTHORIZATION, CONTENT_TYPE, USER_AGENT, HeaderMap as Headers, HeaderValue}, diff --git a/src/internal/prelude.rs b/src/internal/prelude.rs index e2482062144..63ea36d554b 100644 --- a/src/internal/prelude.rs +++ b/src/internal/prelude.rs @@ -6,9 +6,9 @@ pub type JsonMap = Map; -pub use error::{Error, Result}; +pub use crate::error::{Error, Result}; pub use serde_json::{Map, Number, Value}; pub use std::result::Result as StdResult; #[cfg(feature = "client")] -pub use client::ClientError; +pub use crate::client::ClientError; diff --git a/src/internal/timer.rs b/src/internal/timer.rs index 82cec0d543f..d126b086212 100644 --- a/src/internal/timer.rs +++ b/src/internal/timer.rs @@ -20,7 +20,7 @@ impl Timer { } } - pub fn await(&mut self) { + pub fn r#await(&mut self) { let due_time = (self.due.timestamp() * 1000) + i64::from(self.due.timestamp_subsec_millis()); let now_time = { let now = Utc::now(); diff --git a/src/internal/ws_impl.rs b/src/internal/ws_impl.rs index c8c74bb4058..5539f9028e1 100644 --- a/src/internal/ws_impl.rs +++ b/src/internal/ws_impl.rs @@ -1,6 +1,6 @@ use flate2::read::ZlibDecoder; -use gateway::WsClient; -use internal::prelude::*; +use crate::gateway::WsClient; +use crate::internal::prelude::*; use serde_json; use tungstenite::Message; diff --git a/src/lib.rs b/src/lib.rs index f4215def365..d7328340d08 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -105,17 +105,17 @@ //! [gateway docs]: gateway/index.html #![doc(html_root_url = "https://docs.rs/serenity/*")] #![allow(unknown_lints)] -#![allow(doc_markdown, inline_always)] -#![warn(enum_glob_use, if_not_else)] +#![allow(clippy::doc_markdown, clippy::inline_always)] +#![warn(clippy::enum_glob_use, clippy::if_not_else)] #[macro_use] extern crate bitflags; -#[allow(unused_imports)] +#[allow(clippy::unused_imports)] #[macro_use] extern crate log; #[macro_use] extern crate serde_derive; -#[allow(unused_imports)] +#[allow(clippy::unused_imports)] #[macro_use] extern crate serde_json; @@ -152,7 +152,7 @@ extern crate typemap; #[cfg(feature = "url")] extern crate url; -#[allow(unused_imports)] +#[allow(clippy::unused_imports)] #[cfg(test)] #[macro_use] extern crate matches; @@ -183,13 +183,13 @@ pub mod voice; mod error; -pub use error::{Error, Result}; +pub use crate::error::{Error, Result}; #[cfg(feature = "client")] -pub use client::Client; +pub use crate::client::Client; #[cfg(feature = "cache")] -use cache::Cache; +use crate::cache::Cache; #[cfg(feature = "cache")] use parking_lot::RwLock; diff --git a/src/model/channel/attachment.rs b/src/model/channel/attachment.rs index 64fe623452b..82ed3c41106 100644 --- a/src/model/channel/attachment.rs +++ b/src/model/channel/attachment.rs @@ -1,7 +1,7 @@ #[cfg(feature = "model")] use reqwest::Client as ReqwestClient; #[cfg(feature = "model")] -use internal::prelude::*; +use crate::internal::prelude::*; #[cfg(feature = "model")] use std::io::Read; diff --git a/src/model/channel/channel_category.rs b/src/model/channel/channel_category.rs index 97692865f2c..010734225fe 100644 --- a/src/model/channel/channel_category.rs +++ b/src/model/channel/channel_category.rs @@ -1,11 +1,11 @@ -use model::prelude::*; +use crate::model::prelude::*; #[cfg(all(feature = "builder", feature = "model"))] -use builder::EditChannel; +use crate::builder::EditChannel; #[cfg(all(feature = "builder", feature = "model"))] -use http; +use crate::http; #[cfg(all(feature = "model", feature = "utils"))] -use utils::{self as serenity_utils, VecMap}; +use crate::utils::{self as serenity_utils, VecMap}; /// A category of [`GuildChannel`]s. /// diff --git a/src/model/channel/channel_id.rs b/src/model/channel/channel_id.rs index 73145947c6a..63e1d1dea91 100644 --- a/src/model/channel/channel_id.rs +++ b/src/model/channel/channel_id.rs @@ -1,25 +1,25 @@ -use internal::RwLockExt; -use model::prelude::*; +use crate::internal::RwLockExt; +use crate::model::prelude::*; #[cfg(feature = "model")] use std::borrow::Cow; #[cfg(feature = "model")] use std::fmt::Write as FmtWrite; #[cfg(feature = "model")] -use builder::{ +use crate::builder::{ CreateMessage, EditChannel, EditMessage, GetMessages }; #[cfg(all(feature = "cache", feature = "model"))] -use CACHE; +use crate::CACHE; #[cfg(all(feature = "cache", feature = "model"))] -use Cache; +use crate::Cache; #[cfg(feature = "model")] -use http::{self, AttachmentType}; +use crate::http::{self, AttachmentType}; #[cfg(feature = "model")] -use utils; +use crate::utils; #[cfg(feature = "model")] impl ChannelId { diff --git a/src/model/channel/embed.rs b/src/model/channel/embed.rs index 8ce769665cb..9a7bda47540 100644 --- a/src/model/channel/embed.rs +++ b/src/model/channel/embed.rs @@ -1,11 +1,11 @@ #[cfg(feature = "model")] -use builder::CreateEmbed; +use crate::builder::CreateEmbed; #[cfg(feature = "model")] -use internal::prelude::*; +use crate::internal::prelude::*; #[cfg(feature = "utils")] -use utils::Colour; +use crate::utils::Colour; #[cfg(feature = "model")] -use utils; +use crate::utils; /// Represents a rich embed which allows using richer markdown, multiple fields /// and more. This was heavily inspired by [slack's attachments]. diff --git a/src/model/channel/group.rs b/src/model/channel/group.rs index 5607f3ca57d..52302a3a6fd 100644 --- a/src/model/channel/group.rs +++ b/src/model/channel/group.rs @@ -1,16 +1,16 @@ use chrono::{DateTime, FixedOffset}; -use model::prelude::*; +use crate::model::prelude::*; #[cfg(feature = "model")] -use builder::{ +use crate::builder::{ CreateMessage, EditMessage, GetMessages }; #[cfg(feature = "model")] -use http::{self, AttachmentType}; +use crate::http::{self, AttachmentType}; #[cfg(feature = "model")] -use internal::RwLockExt; +use crate::internal::RwLockExt; #[cfg(feature = "model")] use std::borrow::Cow; #[cfg(feature = "model")] diff --git a/src/model/channel/guild_channel.rs b/src/model/channel/guild_channel.rs index 33ebc8148f9..27a4bd0fa04 100644 --- a/src/model/channel/guild_channel.rs +++ b/src/model/channel/guild_channel.rs @@ -1,10 +1,10 @@ use chrono::{DateTime, FixedOffset}; -use model::prelude::*; +use crate::model::prelude::*; #[cfg(all(feature = "cache", feature = "model"))] -use CACHE; +use crate::CACHE; #[cfg(feature = "model")] -use builder::{ +use crate::builder::{ CreateInvite, CreateMessage, EditChannel, @@ -12,9 +12,9 @@ use builder::{ GetMessages }; #[cfg(feature = "model")] -use http::{self, AttachmentType}; +use crate::http::{self, AttachmentType}; #[cfg(all(feature = "cache", feature = "model"))] -use internal::prelude::*; +use crate::internal::prelude::*; #[cfg(feature = "model")] use std::fmt::{ Display, @@ -24,7 +24,7 @@ use std::fmt::{ #[cfg(feature = "model")] use std::mem; #[cfg(all(feature = "model", feature = "utils"))] -use utils::{self as serenity_utils, VecMap}; +use crate::utils::{self as serenity_utils, VecMap}; /// Represents a guild's text or voice channel. Some methods are available only /// for voice channels and some are only available for text channels. diff --git a/src/model/channel/message.rs b/src/model/channel/message.rs index 0439c153937..28c00fee8ba 100644 --- a/src/model/channel/message.rs +++ b/src/model/channel/message.rs @@ -1,19 +1,19 @@ //! Models relating to Discord channels. use chrono::{DateTime, FixedOffset}; -use model::prelude::*; +use crate::model::prelude::*; use serde_json::Value; #[cfg(feature = "model")] -use builder::{CreateEmbed, EditMessage}; +use crate::builder::{CreateEmbed, EditMessage}; #[cfg(all(feature = "cache", feature = "model"))] -use CACHE; +use crate::CACHE; #[cfg(all(feature = "cache", feature = "model"))] use std::fmt::Write; #[cfg(feature = "model")] use std::mem; #[cfg(feature = "model")] -use {constants, http, utils as serenity_utils}; +use crate::{constants, http, utils as serenity_utils}; /// A representation of a message over a guild's text channel, a group, or a /// private channel. diff --git a/src/model/channel/mod.rs b/src/model/channel/mod.rs index 650c2032f6b..9c913cb7fe4 100644 --- a/src/model/channel/mod.rs +++ b/src/model/channel/mod.rs @@ -20,8 +20,8 @@ pub use self::private_channel::*; pub use self::reaction::*; pub use self::channel_category::*; -use internal::RwLockExt; -use model::prelude::*; +use crate::internal::RwLockExt; +use crate::model::prelude::*; use serde::de::Error as DeError; use serde::ser::{SerializeStruct, Serialize, Serializer}; use serde_json; @@ -33,9 +33,9 @@ use std::fmt::{Display, Formatter, Result as FmtResult}; #[cfg(all(feature = "cache", feature = "model", feature = "utils"))] use std::str::FromStr; #[cfg(all(feature = "cache", feature = "model", feature = "utils"))] -use model::misc::ChannelParseError; +use crate::model::misc::ChannelParseError; #[cfg(all(feature = "cache", feature = "model", feature = "utils"))] -use utils::parse_channel; +use crate::utils::parse_channel; /// A container for any channel. #[derive(Clone, Debug)] @@ -476,7 +476,7 @@ pub enum PermissionOverwriteType { mod test { #[cfg(all(feature = "model", feature = "utils"))] mod model_utils { - use model::prelude::*; + use crate::model::prelude::*; use parking_lot::RwLock; use std::collections::HashMap; use std::sync::Arc; diff --git a/src/model/channel/private_channel.rs b/src/model/channel/private_channel.rs index 30defcaeafe..e3e83ed5d16 100644 --- a/src/model/channel/private_channel.rs +++ b/src/model/channel/private_channel.rs @@ -1,5 +1,5 @@ use chrono::{DateTime, FixedOffset}; -use model::prelude::*; +use crate::model::prelude::*; use std::fmt::{ Display, Formatter, @@ -8,15 +8,15 @@ use std::fmt::{ use super::deserialize_single_recipient; #[cfg(feature = "model")] -use builder::{ +use crate::builder::{ CreateMessage, EditMessage, GetMessages }; #[cfg(feature = "model")] -use http::AttachmentType; +use crate::http::AttachmentType; #[cfg(feature = "model")] -use internal::RwLockExt; +use crate::internal::RwLockExt; /// A Direct Message text channel with another user. #[derive(Clone, Debug, Deserialize, Serialize)] diff --git a/src/model/channel/reaction.rs b/src/model/channel/reaction.rs index 85878342168..6b8d77aba94 100644 --- a/src/model/channel/reaction.rs +++ b/src/model/channel/reaction.rs @@ -1,4 +1,4 @@ -use model::prelude::*; +use crate::model::prelude::*; use serde::de::{Deserialize, Error as DeError, MapAccess, Visitor}; use serde::ser::{SerializeMap, Serialize, Serializer}; use std::{ @@ -11,12 +11,12 @@ use std::{ }, str::FromStr }; -use internal::prelude::*; +use crate::internal::prelude::*; #[cfg(all(feature = "cache", feature = "model"))] -use CACHE; +use crate::CACHE; #[cfg(feature = "model")] -use http; +use crate::http; /// An emoji reaction to a message. #[derive(Clone, Debug, Deserialize, Serialize)] diff --git a/src/model/event.rs b/src/model/event.rs index 9e5c8928def..f1e7363f5a6 100644 --- a/src/model/event.rs +++ b/src/model/event.rs @@ -11,13 +11,13 @@ use serde_json; use std::collections::HashMap; use super::utils::deserialize_emojis; use super::prelude::*; -use constants::{OpCode, VoiceOpCode}; -use internal::prelude::*; +use crate::constants::{OpCode, VoiceOpCode}; +use crate::internal::prelude::*; #[cfg(feature = "cache")] -use cache::{Cache, CacheUpdate}; +use crate::cache::{Cache, CacheUpdate}; #[cfg(feature = "cache")] -use internal::RwLockExt; +use crate::internal::RwLockExt; #[cfg(feature = "cache")] use std::collections::hash_map::Entry; #[cfg(feature = "cache")] @@ -1247,7 +1247,7 @@ pub struct WebhookUpdateEvent { pub guild_id: GuildId, } -#[allow(large_enum_variant)] +#[allow(clippy::large_enum_variant)] #[derive(Debug, Clone, Serialize)] #[serde(untagged)] pub enum GatewayEvent { @@ -1327,7 +1327,7 @@ impl<'de> Deserialize<'de> for GatewayEvent { } /// Event received over a websocket connection -#[allow(large_enum_variant)] +#[allow(clippy::large_enum_variant)] #[derive(Clone, Debug, Deserialize, Serialize)] pub enum Event { /// A [`Channel`] was created. @@ -1868,19 +1868,19 @@ impl<'de> Deserialize<'de> for EventType { } } -#[allow(missing_docs)] +#[allow(clippy::missing_docs)] #[derive(Clone, Copy, Debug, Deserialize, Serialize)] pub struct VoiceHeartbeat { pub nonce: u64, } -#[allow(missing_docs)] +#[allow(clippy::missing_docs)] #[derive(Clone, Copy, Debug, Deserialize, Serialize)] pub struct VoiceHeartbeatAck { pub nonce: u64, } -#[allow(missing_docs)] +#[allow(clippy::missing_docs)] #[derive(Clone, Debug, Deserialize, Serialize)] pub struct VoiceReady { pub heartbeat_interval: u64, @@ -1889,20 +1889,20 @@ pub struct VoiceReady { pub ssrc: u32, } -#[allow(missing_docs)] +#[allow(clippy::missing_docs)] #[derive(Clone, Debug, Deserialize, Serialize)] pub struct VoiceHello { pub heartbeat_interval: u64, } -#[allow(missing_docs)] +#[allow(clippy::missing_docs)] #[derive(Clone, Debug, Deserialize, Serialize)] pub struct VoiceSessionDescription { pub mode: String, pub secret_key: Vec, } -#[allow(missing_docs)] +#[allow(clippy::missing_docs)] #[derive(Clone, Copy, Debug, Deserialize, Serialize)] pub struct VoiceSpeaking { pub speaking: bool, @@ -1910,7 +1910,7 @@ pub struct VoiceSpeaking { pub user_id: UserId, } -#[allow(missing_docs)] +#[allow(clippy::missing_docs)] #[derive(Clone, Debug, Deserialize, Serialize)] pub struct VoiceResume { pub server_id: String, @@ -1918,7 +1918,7 @@ pub struct VoiceResume { pub token: String, } -#[allow(missing_docs)] +#[allow(clippy::missing_docs)] #[derive(Clone, Copy, Debug, Deserialize, Serialize)] pub struct VoiceClientDisconnect { pub user_id: UserId, diff --git a/src/model/guild/audit_log.rs b/src/model/guild/audit_log.rs index e4a344c91c8..1ecc2c647e0 100644 --- a/src/model/guild/audit_log.rs +++ b/src/model/guild/audit_log.rs @@ -1,4 +1,4 @@ -use internal::prelude::*; +use crate::internal::prelude::*; use serde::de::{ self, Deserialize, diff --git a/src/model/guild/emoji.rs b/src/model/guild/emoji.rs index 607d1c1d5bd..6e4a385972c 100644 --- a/src/model/guild/emoji.rs +++ b/src/model/guild/emoji.rs @@ -7,7 +7,7 @@ use std::fmt::{ use super::super::id::{EmojiId, RoleId}; #[cfg(all(feature = "cache", feature = "model"))] -use internal::prelude::*; +use crate::internal::prelude::*; #[cfg(all(feature = "cache", feature = "model"))] use std::mem; #[cfg(all(feature = "cache", feature = "model"))] @@ -15,7 +15,7 @@ use super::super::ModelError; #[cfg(all(feature = "cache", feature = "model"))] use super::super::id::GuildId; #[cfg(all(feature = "cache", feature = "model"))] -use {CACHE, http}; +use crate::{CACHE, http}; /// Represents a custom guild emoji, which can either be created using the API, /// or via an integration. Emojis created using the API only work within the diff --git a/src/model/guild/guild_id.rs b/src/model/guild/guild_id.rs index 1375e4e8665..1012e87db96 100644 --- a/src/model/guild/guild_id.rs +++ b/src/model/guild/guild_id.rs @@ -1,15 +1,15 @@ -use model::prelude::*; +use crate::model::prelude::*; #[cfg(all(feature = "cache", feature = "model"))] -use CACHE; +use crate::CACHE; #[cfg(feature = "model")] -use builder::{EditGuild, EditMember, EditRole}; +use crate::builder::{EditGuild, EditMember, EditRole}; #[cfg(feature = "model")] -use internal::prelude::*; +use crate::internal::prelude::*; #[cfg(feature = "model")] -use model::guild::BanOptions; +use crate::model::guild::BanOptions; #[cfg(feature = "model")] -use {http, utils}; +use crate::{http, utils}; #[cfg(feature = "model")] impl GuildId { @@ -563,7 +563,7 @@ impl GuildId { /// [`utils::shard_id`]: ../../utils/fn.shard_id.html #[cfg(all(feature = "cache", feature = "utils"))] #[inline] - pub fn shard_id(&self) -> u64 { ::utils::shard_id(self.0, CACHE.read().shard_count) } + pub fn shard_id(&self) -> u64 { crate::utils::shard_id(self.0, CACHE.read().shard_count) } /// Returns the Id of the shard associated with the guild. /// diff --git a/src/model/guild/member.rs b/src/model/guild/member.rs index dae2b4177be..cbda4c3c113 100644 --- a/src/model/guild/member.rs +++ b/src/model/guild/member.rs @@ -1,4 +1,4 @@ -use model::prelude::*; +use crate::model::prelude::*; use chrono::{DateTime, FixedOffset}; use std::fmt::{ Display, @@ -8,15 +8,15 @@ use std::fmt::{ use super::deserialize_sync_user; #[cfg(all(feature = "builder", feature = "cache", feature = "model"))] -use builder::EditMember; +use crate::builder::EditMember; #[cfg(all(feature = "cache", feature = "model"))] -use internal::prelude::*; +use crate::internal::prelude::*; #[cfg(feature = "model")] use std::borrow::Cow; #[cfg(all(feature = "cache", feature = "model", feature = "utils"))] -use utils::Colour; +use crate::utils::Colour; #[cfg(all(feature = "cache", feature = "model"))] -use {CACHE, http, utils}; +use crate::{CACHE, http, utils}; /// A trait for allowing both u8 or &str or (u8, &str) to be passed into the `ban` methods in `Guild` and `Member`. pub trait BanOptions { diff --git a/src/model/guild/mod.rs b/src/model/guild/mod.rs index 6c4d3c40f9b..2f13e09acc1 100644 --- a/src/model/guild/mod.rs +++ b/src/model/guild/mod.rs @@ -17,19 +17,19 @@ pub use self::role::*; pub use self::audit_log::*; use chrono::{DateTime, FixedOffset}; -use model::prelude::*; +use crate::model::prelude::*; use serde::de::Error as DeError; use serde_json; use super::utils::*; #[cfg(all(feature = "cache", feature = "model"))] -use CACHE; +use crate::CACHE; #[cfg(feature = "model")] -use http; +use crate::http; #[cfg(feature = "model")] -use builder::{EditGuild, EditMember, EditRole}; +use crate::builder::{EditGuild, EditMember, EditRole}; #[cfg(feature = "model")] -use constants::LARGE_THRESHOLD; +use crate::constants::LARGE_THRESHOLD; #[cfg(feature = "model")] use std; #[cfg(feature = "model")] @@ -1724,7 +1724,7 @@ fn closest_to_origin(origin: &str, word_a: &str, word_b: &str) -> std::cmp::Orde /// /// This is used to differentiate whether a guild itself can be used or whether /// a guild needs to be retrieved from the cache. -#[allow(large_enum_variant)] +#[allow(clippy::large_enum_variant)] #[derive(Clone, Debug)] pub enum GuildContainer { /// A guild which can have its contents directly searched. @@ -1814,7 +1814,7 @@ pub struct GuildUnavailable { pub unavailable: bool, } -#[allow(large_enum_variant)] +#[allow(clippy::large_enum_variant)] #[derive(Clone, Debug, Deserialize, Serialize)] #[serde(untagged)] pub enum GuildStatus { @@ -2009,7 +2009,7 @@ mod test { #[cfg(feature = "model")] mod model { use chrono::prelude::*; - use model::prelude::*; + use crate::model::prelude::*; use std::collections::*; use std::sync::Arc; diff --git a/src/model/guild/partial_guild.rs b/src/model/guild/partial_guild.rs index dfe477572a1..cc277a0dde3 100644 --- a/src/model/guild/partial_guild.rs +++ b/src/model/guild/partial_guild.rs @@ -1,8 +1,8 @@ -use model::prelude::*; +use crate::model::prelude::*; use super::super::utils::{deserialize_emojis, deserialize_roles}; #[cfg(feature = "model")] -use builder::{EditGuild, EditMember, EditRole}; +use crate::builder::{EditGuild, EditMember, EditRole}; /// Partial information about a [`Guild`]. This does not include information /// like member data. diff --git a/src/model/guild/role.rs b/src/model/guild/role.rs index 5aa5fbbfc56..b68803b3e93 100644 --- a/src/model/guild/role.rs +++ b/src/model/guild/role.rs @@ -1,19 +1,19 @@ -use model::prelude::*; +use crate::model::prelude::*; use std::cmp::Ordering; #[cfg(all(feature = "builder", feature = "cache", feature = "model"))] -use builder::EditRole; +use crate::builder::EditRole; #[cfg(all(feature = "cache", feature = "model"))] -use internal::prelude::*; +use crate::internal::prelude::*; #[cfg(all(feature = "cache", feature = "model"))] -use {CACHE, Cache, http}; +use crate::{CACHE, Cache, http}; #[cfg(all(feature = "cache", feature = "model", feature = "utils"))] use std::str::FromStr; #[cfg(all(feature = "cache", feature = "model", feature = "utils"))] -use model::misc::RoleParseError; +use crate::model::misc::RoleParseError; #[cfg(all(feature = "cache", feature = "model", feature = "utils"))] -use utils::parse_role; +use crate::utils::parse_role; /// Information about a role within a guild. A role represents a set of /// permissions, and can be attached to one or multiple users. A role has diff --git a/src/model/id.rs b/src/model/id.rs index 84704aaec7e..81d2bbdc098 100644 --- a/src/model/id.rs +++ b/src/model/id.rs @@ -1,7 +1,7 @@ //! A collection of newtypes defining type-strong IDs. use chrono::NaiveDateTime; -use internal::prelude::*; +use crate::internal::prelude::*; use serde::de::{Deserialize, Deserializer}; use std::fmt::{Display, Formatter, Result as FmtResult}; use super::utils::U64Visitor; @@ -92,52 +92,52 @@ macro_rules! id_u64 { /// An identifier for an Application. #[derive(Copy, Clone, Default, Debug, Eq, Hash, PartialOrd, Ord, Serialize)] -#[allow(derive_hash_xor_eq)] +#[allow(clippy::derive_hash_xor_eq)] pub struct ApplicationId(pub u64); /// An identifier for a Channel #[derive(Copy, Clone, Default, Debug, Eq, Hash, PartialOrd, Ord, Serialize)] -#[allow(derive_hash_xor_eq)] +#[allow(clippy::derive_hash_xor_eq)] pub struct ChannelId(pub u64); /// An identifier for an Emoji #[derive(Copy, Clone, Default, Debug, Eq, Hash, PartialOrd, Ord, Serialize)] -#[allow(derive_hash_xor_eq)] +#[allow(clippy::derive_hash_xor_eq)] pub struct EmojiId(pub u64); /// An identifier for a Guild #[derive(Copy, Clone, Default, Debug, Eq, Hash, PartialOrd, Ord, Serialize)] -#[allow(derive_hash_xor_eq)] +#[allow(clippy::derive_hash_xor_eq)] pub struct GuildId(pub u64); /// An identifier for an Integration #[derive(Copy, Clone, Default, Debug, Eq, Hash, PartialOrd, Ord, Serialize)] -#[allow(derive_hash_xor_eq)] +#[allow(clippy::derive_hash_xor_eq)] pub struct IntegrationId(pub u64); /// An identifier for a Message #[derive(Copy, Clone, Default, Debug, Eq, Hash, PartialOrd, Ord, Serialize)] -#[allow(derive_hash_xor_eq)] +#[allow(clippy::derive_hash_xor_eq)] pub struct MessageId(pub u64); /// An identifier for a Role #[derive(Copy, Clone, Default, Debug, Eq, Hash, PartialOrd, Ord, Serialize)] -#[allow(derive_hash_xor_eq)] +#[allow(clippy::derive_hash_xor_eq)] pub struct RoleId(pub u64); /// An identifier for a User #[derive(Copy, Clone, Default, Debug, Eq, Hash, PartialOrd, Ord, Serialize)] -#[allow(derive_hash_xor_eq)] +#[allow(clippy::derive_hash_xor_eq)] pub struct UserId(pub u64); /// An identifier for a [`Webhook`](../webhook/struct.Webhook.html). #[derive(Copy, Clone, Default, Debug, Eq, Hash, PartialOrd, Ord, Serialize)] -#[allow(derive_hash_xor_eq)] +#[allow(clippy::derive_hash_xor_eq)] pub struct WebhookId(pub u64); /// An identifier for an audit log entry. #[derive(Copy, Clone, Default, Debug, Eq, Hash, PartialOrd, Ord, Serialize)] -#[allow(derive_hash_xor_eq)] +#[allow(clippy::derive_hash_xor_eq)] pub struct AuditLogEntryId(pub u64); id_u64! { diff --git a/src/model/invite.rs b/src/model/invite.rs index b391f9b676c..74a46dc3d4b 100644 --- a/src/model/invite.rs +++ b/src/model/invite.rs @@ -4,13 +4,13 @@ use chrono::{DateTime, FixedOffset}; use super::prelude::*; #[cfg(feature = "model")] -use builder::CreateInvite; +use crate::builder::CreateInvite; #[cfg(feature = "model")] -use internal::prelude::*; +use crate::internal::prelude::*; #[cfg(all(feature = "cache", feature = "model"))] use super::{Permissions, utils as model_utils}; #[cfg(feature = "model")] -use {http, utils}; +use crate::{http, utils}; /// Information about an invite code. /// @@ -117,13 +117,13 @@ impl Invite { } /// Gets the information about an invite. - #[allow(unused_mut)] + #[allow(clippy::unused_mut)] pub fn get(code: &str, stats: bool) -> Result { let mut invite = code; #[cfg(feature = "utils")] { - invite = ::utils::parse_invite(invite); + invite = crate::utils::parse_invite(invite); } http::get_invite(invite, stats) diff --git a/src/model/misc.rs b/src/model/misc.rs index 87c3c444921..e2adbcc8b58 100644 --- a/src/model/misc.rs +++ b/src/model/misc.rs @@ -1,7 +1,7 @@ //! Miscellaneous helper traits, enums, and structs for models. use super::prelude::*; -use internal::RwLockExt; +use crate::internal::RwLockExt; #[cfg(all(feature = "model", feature = "utils"))] use std::error::Error as StdError; @@ -12,7 +12,7 @@ use std::str::FromStr; #[cfg(all(feature = "model", feature = "utils"))] use std::fmt; #[cfg(all(feature = "model", any(feature = "cache", feature = "utils")))] -use utils; +use crate::utils; /// Allows something - such as a channel or role - to be mentioned in a message. pub trait Mentionable { @@ -296,7 +296,7 @@ pub struct Maintenance { #[cfg(test)] mod test { - use model::prelude::*; + use crate::model::prelude::*; #[test] fn test_formatters() { @@ -309,10 +309,10 @@ mod test { #[cfg(feature = "utils")] mod utils { - use model::prelude::*; + use crate::model::prelude::*; use parking_lot::RwLock; use std::sync::Arc; - use utils::Colour; + use crate::utils::Colour; #[test] fn test_mention() { diff --git a/src/model/mod.rs b/src/model/mod.rs index 8afa79ce6c0..a614f638861 100644 --- a/src/model/mod.rs +++ b/src/model/mod.rs @@ -40,7 +40,7 @@ pub mod webhook; pub use self::error::Error as ModelError; pub use self::permissions::Permissions; -use internal::prelude::*; +use crate::internal::prelude::*; use parking_lot::RwLock; use self::utils::*; use serde::de::Visitor; @@ -56,6 +56,6 @@ use std::{ }; #[cfg(feature = "utils")] -use utils::Colour; +use crate::utils::Colour; use serde::{Deserialize, Deserializer}; diff --git a/src/model/user.rs b/src/model/user.rs index fa112faa61e..689083052d7 100644 --- a/src/model/user.rs +++ b/src/model/user.rs @@ -4,17 +4,17 @@ use serde_json; use std::fmt; use super::utils::deserialize_u16; use super::prelude::*; -use internal::prelude::*; -use model::misc::Mentionable; +use crate::internal::prelude::*; +use crate::model::misc::Mentionable; #[cfg(all(feature = "cache", feature = "model"))] -use CACHE; +use crate::CACHE; #[cfg(feature = "model")] -use builder::{CreateMessage, EditProfile}; +use crate::builder::{CreateMessage, EditProfile}; #[cfg(feature = "model")] use chrono::NaiveDateTime; #[cfg(feature = "model")] -use http::{self, GuildPagination}; +use crate::http::{self, GuildPagination}; #[cfg(all(feature = "cache", feature = "model"))] use parking_lot::RwLock; #[cfg(feature = "model")] @@ -24,7 +24,7 @@ use std::mem; #[cfg(all(feature = "cache", feature = "model"))] use std::sync::Arc; #[cfg(feature = "model")] -use utils::{self, VecMap}; +use crate::utils::{self, VecMap}; /// Information about the current user. #[derive(Clone, Default, Debug, Deserialize, Serialize)] @@ -482,7 +482,7 @@ impl User { // The universe is still fine, and nothing implodes. // // (AKA: Clippy is wrong and so we have to mark as allowing this lint.) - #[allow(let_and_return)] + #[allow(clippy::let_and_return)] #[cfg(feature = "builder")] pub fn direct_message(&self, f: F) -> Result where for <'b> F: FnOnce(&'b mut CreateMessage<'b>) -> &'b mut CreateMessage<'b> { @@ -933,8 +933,8 @@ fn tag(name: &str, discriminator: u16) -> String { mod test { #[cfg(feature = "model")] mod model { - use model::id::UserId; - use model::user::User; + use crate::model::id::UserId; + use crate::model::user::User; fn gen() -> User { User { diff --git a/src/model/utils.rs b/src/model/utils.rs index 1cdf6dcf69d..233680db345 100644 --- a/src/model/utils.rs +++ b/src/model/utils.rs @@ -10,12 +10,12 @@ use std::{ use super::prelude::*; #[cfg(feature = "cache")] -use internal::prelude::*; +use crate::internal::prelude::*; #[cfg(all(feature = "cache", feature = "model"))] use super::permissions::Permissions; #[cfg(all(feature = "cache", feature = "model"))] -use CACHE; +use crate::CACHE; pub fn default_true() -> bool { true diff --git a/src/model/webhook.rs b/src/model/webhook.rs index b87bef87fa5..71347650be8 100644 --- a/src/model/webhook.rs +++ b/src/model/webhook.rs @@ -10,15 +10,15 @@ use super::{ }; #[cfg(feature = "model")] -use builder::ExecuteWebhook; +use crate::builder::ExecuteWebhook; #[cfg(feature = "model")] -use internal::prelude::*; +use crate::internal::prelude::*; #[cfg(feature = "model")] use std::mem; #[cfg(feature = "model")] use super::channel::Message; #[cfg(feature = "model")] -use {http, utils}; +use crate::{http, utils}; /// A representation of a webhook, which is a low-effort way to post messages to /// channels. They do not necessarily require a bot user or authentication to diff --git a/src/prelude.rs b/src/prelude.rs index dd1a5d1d4d4..d3fa1c63568 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -14,19 +14,17 @@ //! //! [`serenity::Error`]: ../enum.Error.html -pub use error::Error as SerenityError; -pub use model::misc::Mentionable; +pub use crate::error::Error as SerenityError; +pub use crate::model::misc::Mentionable; pub use parking_lot::{Mutex, RwLock}; #[cfg(feature = "client")] -pub use client::{Client, ClientError as ClientError, Context, EventHandler}; +pub use crate::client::{Client, ClientError as ClientError, Context, EventHandler}; #[cfg(feature = "gateway")] -pub use gateway::GatewayError; +pub use crate::gateway::GatewayError; #[cfg(feature = "http")] -pub use http::HttpError; +pub use crate::http::HttpError; #[cfg(feature = "model")] -pub use model::ModelError; -#[cfg(feature = "typemap")] -pub use typemap::{Key as TypeMapKey, ShareMap}; +pub use crate::model::ModelError; #[cfg(feature = "voice")] -pub use voice::VoiceError; +pub use crate::voice::VoiceError; diff --git a/src/utils/colour.rs b/src/utils/colour.rs index b877bcdd9bb..3b7c598df04 100644 --- a/src/utils/colour.rs +++ b/src/utils/colour.rs @@ -1,5 +1,5 @@ // Disable this lint to avoid it wanting to change `0xABCDEF` to `0xAB_CDEF`. -#![allow(unreadable_literal)] +#![allow(clippy::unreadable_literal)] macro_rules! colour { ($(#[$attr:meta] $constname:ident, $name:ident, $val:expr;)*) => { diff --git a/src/utils/message_builder.rs b/src/utils/message_builder.rs index 46501181216..3e289dc3b65 100644 --- a/src/utils/message_builder.rs +++ b/src/utils/message_builder.rs @@ -1,4 +1,4 @@ -use model::{ +use crate::model::{ guild::Emoji, id::{ChannelId, RoleId, UserId}, misc::Mentionable @@ -1087,7 +1087,7 @@ fn normalize(text: &str) -> String { #[cfg(test)] mod test { - use model::prelude::*; + use crate::model::prelude::*; use super::{ ContentModifier::*, MessageBuilder, diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 8b9c4827194..01620101b3b 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -12,9 +12,9 @@ pub use self::{ }; use base64; -use internal::prelude::*; -use prelude::RwLock; -use model::{ +use crate::internal::prelude::*; +use crate::prelude::RwLock; +use crate::model::{ channel::Channel, misc::EmojiIdentifier, id::{ @@ -36,9 +36,9 @@ use std::{ }; #[cfg(feature = "cache")] -use cache::Cache; +use crate::cache::Cache; #[cfg(feature = "cache")] -use CACHE; +use crate::CACHE; /// Converts a HashMap into a final `serde_json::Map` representation. pub fn hashmap_to_json_map(map: HashMap) @@ -858,7 +858,7 @@ mod test { #[test] fn test_content_safe() { - use model::{ + use crate::model::{ user::User, Permissions, prelude::*, diff --git a/src/voice/connection.rs b/src/voice/connection.rs index 841216c3ae2..a179018d1c6 100644 --- a/src/voice/connection.rs +++ b/src/voice/connection.rs @@ -5,14 +5,14 @@ use byteorder::{ ReadBytesExt, WriteBytesExt }; -use constants::VOICE_GATEWAY_VERSION; -use gateway::WsClient; -use internal::prelude::*; -use internal::{ +use crate::constants::VOICE_GATEWAY_VERSION; +use crate::gateway::WsClient; +use crate::internal::prelude::*; +use crate::internal::{ ws_impl::{ReceiverExt, SenderExt}, Timer }; -use model::{ +use crate::model::{ event::VoiceEvent, id::UserId }; @@ -59,7 +59,7 @@ enum ReceiverStatus { Websocket(VoiceEvent), } -#[allow(dead_code)] +#[allow(clippy::dead_code)] struct ThreadItems { rx: MpscReceiver, udp_close_sender: MpscSender, @@ -68,7 +68,7 @@ struct ThreadItems { ws_thread: JoinHandle<()>, } -#[allow(dead_code)] +#[allow(clippy::dead_code)] pub struct Connection { audio_timer: Timer, client: Arc>, @@ -212,7 +212,7 @@ impl Connection { }) } - #[allow(unused_variables)] + #[allow(clippy::unused_variables)] pub fn cycle(&mut self, sources: &mut Vec, receiver: &mut Option>, @@ -425,7 +425,7 @@ impl Connection { // Per official guidelines, send 5x silence BEFORE we stop speaking. self.set_speaking(false)?; - audio_timer.await(); + audio_timer.r#await(); return Ok(()); } @@ -440,7 +440,7 @@ impl Connection { self.set_speaking(true)?; let index = self.prep_packet(&mut packet, mix_buffer, &opus_frame, nonce)?; - audio_timer.await(); + audio_timer.r#await(); self.udp.send_to(&packet[..index], self.destination)?; self.audio_timer.reset(); diff --git a/src/voice/connection_info.rs b/src/voice/connection_info.rs index 29e08befb30..486c740e271 100644 --- a/src/voice/connection_info.rs +++ b/src/voice/connection_info.rs @@ -1,4 +1,4 @@ -use model::id::{GuildId, UserId}; +use crate::model::id::{GuildId, UserId}; #[derive(Clone, Debug)] pub struct ConnectionInfo { diff --git a/src/voice/handler.rs b/src/voice/handler.rs index 6e99023415b..259dd3b31c5 100644 --- a/src/voice/handler.rs +++ b/src/voice/handler.rs @@ -1,6 +1,6 @@ -use constants::VoiceOpCode; -use gateway::InterMessage; -use model::{ +use crate::constants::VoiceOpCode; +use crate::gateway::InterMessage; +use crate::model::{ id::{ ChannelId, GuildId, diff --git a/src/voice/manager.rs b/src/voice/manager.rs index 4d1a7c4a433..f8c199a7408 100644 --- a/src/voice/manager.rs +++ b/src/voice/manager.rs @@ -1,5 +1,5 @@ -use gateway::InterMessage; -use model::id::{ChannelId, GuildId, UserId}; +use crate::gateway::InterMessage; +use crate::model::id::{ChannelId, GuildId, UserId}; use std::{ collections::HashMap, sync::mpsc::Sender as MpscSender @@ -80,7 +80,7 @@ impl Manager { /// /// [`Handler`]: struct.Handler.html /// [`get`]: #method.get - #[allow(map_entry)] + #[allow(clippy::map_entry)] #[inline] pub fn join(&mut self, guild_id: G, channel_id: C) -> &mut Handler where C: Into, G: Into { diff --git a/src/voice/mod.rs b/src/voice/mod.rs index d03e0b08600..032ee5e1d65 100644 --- a/src/voice/mod.rs +++ b/src/voice/mod.rs @@ -34,7 +34,7 @@ const CRYPTO_MODE: &'static str = "xsalsa20_poly1305"; pub(crate) enum Status { Connect(ConnectionInfo), - #[allow(dead_code)] Disconnect, + #[allow(clippy::dead_code)] Disconnect, SetReceiver(Option>), SetSender(Option), AddSender(LockedAudio), diff --git a/src/voice/payload.rs b/src/voice/payload.rs index 7faf31b440e..7d2afc2e04b 100644 --- a/src/voice/payload.rs +++ b/src/voice/payload.rs @@ -1,4 +1,4 @@ -use constants::VoiceOpCode; +use crate::constants::VoiceOpCode; use serde_json::Value; use super::connection_info::ConnectionInfo; diff --git a/src/voice/streamer.rs b/src/voice/streamer.rs index 7dff09aba76..830b069c2b4 100644 --- a/src/voice/streamer.rs +++ b/src/voice/streamer.rs @@ -1,5 +1,5 @@ use byteorder::{LittleEndian, ReadBytesExt}; -use internal::prelude::*; +use crate::internal::prelude::*; use opus::{ Channels, Decoder as OpusDecoder, diff --git a/src/voice/threading.rs b/src/voice/threading.rs index 2e4da0c13c2..49bd14c5fc1 100644 --- a/src/voice/threading.rs +++ b/src/voice/threading.rs @@ -1,5 +1,5 @@ -use internal::Timer; -use model::id::GuildId; +use crate::internal::Timer; +use crate::model::id::GuildId; use std::{ sync::mpsc::{Receiver as MpscReceiver, TryRecvError}, thread::Builder as ThreadBuilder @@ -94,7 +94,7 @@ fn runner(rx: &MpscReceiver) { } }, None => { - timer.await(); + timer.r#await(); false },