Skip to content

Commit

Permalink
Fix unused warnings when model feature is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
mkrasnitski committed Sep 13, 2024
1 parent 5622721 commit c5eb108
Show file tree
Hide file tree
Showing 20 changed files with 35 additions and 15 deletions.
1 change: 1 addition & 0 deletions src/builder/create_attachment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ impl<'a> EditAttachments<'a> {
/// Clones all new attachments into a new Vec, keeping only data and filename, because those
/// are needed for the multipart form data. The data is taken out of `self` in the process, so
/// this method can only be called once.
#[cfg(feature = "http")]
pub(crate) fn take_files(&mut self) -> Vec<CreateAttachment<'a>> {
let mut files = Vec::new();
for attachment in &mut self.new_and_existing_attachments {
Expand Down
1 change: 0 additions & 1 deletion src/builder/edit_role.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use std::borrow::Cow;
use super::CreateAttachment;
#[cfg(feature = "http")]
use crate::http::Http;
use crate::internal::prelude::*;
use crate::model::prelude::*;

/// A builder to create or edit a [`Role`] for use via a number of model methods.
Expand Down
1 change: 1 addition & 0 deletions src/builder/get_messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ impl GetMessages {
}
}

#[cfg_attr(not(feature = "http"), allow(dead_code))]
#[derive(Clone, Copy, Debug)]
enum SearchFilter {
After(MessageId),
Expand Down
1 change: 1 addition & 0 deletions src/gateway/sharding/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ use std::fmt;
use std::sync::Arc;
use std::time::{Duration as StdDuration, Instant};

use aformat::{aformat, CapStr};
use secrecy::{ExposeSecret as _, Secret};
use tokio_tungstenite::tungstenite::error::Error as TungsteniteError;
use tokio_tungstenite::tungstenite::protocol::frame::CloseFrame;
Expand Down
1 change: 1 addition & 0 deletions src/http/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::cell::Cell;
use std::sync::atomic::{AtomicU64, Ordering};
use std::sync::Arc;

use aformat::{aformat, CapStr};
use arrayvec::ArrayVec;
use nonmax::{NonMaxU16, NonMaxU8};
use percent_encoding::{utf8_percent_encode, NON_ALPHANUMERIC};
Expand Down
7 changes: 4 additions & 3 deletions src/internal/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@

pub use std::result::Result as StdResult;

pub use aformat::{aformat, aformat_into, ArrayString, CapStr};
pub use extract_map::{ExtractKey, ExtractMap, LendingIterator};
pub use serde_json::Value;
pub use small_fixed_array::{FixedArray, FixedString, TruncatingInto};
pub use to_arraystring::ToArrayString;

pub(crate) use super::utils::join_to_string;
pub use crate::error::{Error, Result};
pub use super::utils::join_to_string;
#[cfg(feature = "http")]
pub use crate::error::Error;
pub use crate::error::Result;

pub type JsonMap = serde_json::Map<String, Value>;
2 changes: 1 addition & 1 deletion src/internal/utils.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::fmt::Write;

pub(crate) fn join_to_string(
pub fn join_to_string(
sep: impl std::fmt::Display,
iter: impl IntoIterator<Item = impl std::fmt::Display>,
) -> String {
Expand Down
2 changes: 1 addition & 1 deletion src/model/channel/channel_id.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[cfg(feature = "model")]
use std::borrow::Cow;
#[cfg(feature = "model")]
use std::sync::Arc;
Expand Down Expand Up @@ -28,7 +29,6 @@ use crate::collector::{MessageCollector, ReactionCollector};
use crate::gateway::ShardMessenger;
#[cfg(feature = "model")]
use crate::http::{CacheHttp, Http, Typing};
use crate::internal::prelude::*;
use crate::model::prelude::*;

#[cfg(feature = "model")]
Expand Down
1 change: 1 addition & 0 deletions src/model/channel/guild_channel.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[cfg(feature = "model")]
use std::borrow::Cow;
use std::fmt;
#[cfg(feature = "model")]
Expand Down
1 change: 1 addition & 0 deletions src/model/channel/message.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Models relating to Discord channels.

#[cfg(feature = "model")]
use std::borrow::Cow;

use nonmax::NonMaxU64;
Expand Down
1 change: 1 addition & 0 deletions src/model/channel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use serde::de::{Error as DeError, Unexpected};
use serde_json::from_value;

pub use self::attachment::*;
#[cfg(feature = "model")]
pub use self::channel_id::*;
pub use self::embed::*;
pub use self::guild_channel::*;
Expand Down
2 changes: 1 addition & 1 deletion src/model/channel/private_channel.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[cfg(feature = "model")]
use std::borrow::Cow;
use std::fmt;
#[cfg(feature = "model")]
Expand All @@ -9,7 +10,6 @@ use crate::builder::{CreateAttachment, CreateMessage, EditMessage, GetMessages};
use crate::http::CacheHttp;
#[cfg(feature = "model")]
use crate::http::{Http, Typing};
use crate::internal::prelude::*;
use crate::model::prelude::*;
use crate::model::utils::single_recipient;

Expand Down
1 change: 1 addition & 0 deletions src/model/channel/reaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::fmt::Display as _;
use std::fmt::{self, Write as _};
use std::str::FromStr;

#[cfg(feature = "model")]
use nonmax::NonMaxU8;
#[cfg(feature = "http")]
use percent_encoding::{utf8_percent_encode, NON_ALPHANUMERIC};
Expand Down
2 changes: 2 additions & 0 deletions src/model/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub enum Maximum {
BulkDeleteAmount,
}

#[cfg(feature = "http")]
impl Maximum {
pub(crate) fn check_overflow(self, value: usize) -> Result<(), Error> {
let max = self.value();
Expand Down Expand Up @@ -64,6 +65,7 @@ pub enum Minimum {
BulkDeleteAmount,
}

#[cfg(feature = "http")]
impl Minimum {
pub(crate) fn check_underflow(self, value: usize) -> Result<(), Error> {
let min = self.value();
Expand Down
2 changes: 2 additions & 0 deletions src/model/guild/guild_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::fmt;

#[cfg(feature = "model")]
use futures::stream::Stream;
#[cfg(feature = "model")]
use nonmax::{NonMaxU16, NonMaxU8};

#[cfg(feature = "model")]
Expand Down Expand Up @@ -31,6 +32,7 @@ use crate::gateway::ShardMessenger;
use crate::http::{CacheHttp, Http, UserPagination};
#[cfg(feature = "model")]
use crate::internal::prelude::*;
#[cfg(feature = "model")]
use crate::model::error::Maximum;
use crate::model::prelude::*;

Expand Down
5 changes: 4 additions & 1 deletion src/model/guild/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ mod welcome_screen;
#[cfg(feature = "model")]
use std::borrow::Cow;

use nonmax::{NonMaxU16, NonMaxU64, NonMaxU8};
use nonmax::NonMaxU64;
#[cfg(feature = "model")]
use nonmax::{NonMaxU16, NonMaxU8};
#[cfg(feature = "model")]
use tracing::{error, warn};

Expand Down Expand Up @@ -59,6 +61,7 @@ use crate::gateway::ShardMessenger;
use crate::http::{CacheHttp, Http, UserPagination};
use crate::internal::prelude::*;
use crate::model::prelude::*;
#[cfg(feature = "model")]
use crate::model::utils::*;

/// A representation of a banning of a user.
Expand Down
4 changes: 3 additions & 1 deletion src/model/guild/partial_guild.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use nonmax::{NonMaxU16, NonMaxU64, NonMaxU8};
use nonmax::NonMaxU64;
#[cfg(feature = "model")]
use nonmax::{NonMaxU16, NonMaxU8};
use serde::Serialize;

#[cfg(feature = "model")]
Expand Down
5 changes: 3 additions & 2 deletions src/model/mention.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ use std::fmt;
#[cfg(all(feature = "model", feature = "utils"))]
use std::str::FromStr;

use aformat::{aformat_into, ArrayString, ToArrayString};

use super::prelude::*;
use crate::internal::prelude::*;
#[cfg(all(feature = "model", feature = "utils"))]
use crate::utils;

Expand Down Expand Up @@ -113,7 +114,7 @@ impl fmt::Display for Mention {

impl ToArrayString for Mention {
const MAX_LENGTH: usize = 20 + 4;
type ArrayString = ArrayString<{ 20 + 4 }>;
type ArrayString = ArrayString<{ Self::MAX_LENGTH }>;

fn to_arraystring(self) -> Self::ArrayString {
let mut out = Self::ArrayString::new();
Expand Down
3 changes: 2 additions & 1 deletion src/model/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ use std::fmt::Write;
use std::result::Result as StdResult;
use std::str::FromStr;

use aformat::ArrayString;

use super::prelude::*;
use crate::internal::prelude::*;
#[cfg(all(feature = "model", any(feature = "cache", feature = "utils")))]
use crate::utils;

Expand Down
7 changes: 4 additions & 3 deletions src/utils/formatted_timestamp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ use std::error::Error as StdError;
use std::fmt;
use std::str::FromStr;

use aformat::{ArrayString, ToArrayString};
use aformat::{aformat_into, ArrayString, ToArrayString};

use crate::all::Timestamp;
use crate::internal::prelude::*;
use crate::model::Timestamp;

/// Represents a combination of a timestamp and a style for formatting time in messages.
///
Expand Down Expand Up @@ -195,6 +194,8 @@ impl FromStr for FormattedTimestampStyle {

#[cfg(test)]
mod tests {
use aformat::aformat;

use super::*;

#[test]
Expand Down

0 comments on commit c5eb108

Please sign in to comment.