Skip to content

Commit

Permalink
Forgot enums (while applying non_exhaustive)
Browse files Browse the repository at this point in the history
  • Loading branch information
kangalio authored and GnomedDev committed Nov 26, 2023
1 parent 035e035 commit 6c08cfb
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions macros/src/command/slash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ pub fn generate_slash_action(inv: &Invocation) -> Result<proc_macro2::TokenStrea
input: Some(input),
}
},
poise::SlashArgError::__NonExhaustive => unreachable!(),
})?;

if !ctx.framework.options.manual_cooldowns {
Expand Down
1 change: 1 addition & 0 deletions src/builtins/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ async fn help_all_commands<U, E>(
let kind = match command.context_menu_action {
Some(crate::ContextMenuCommandAction::User(_)) => "user",
Some(crate::ContextMenuCommandAction::Message(_)) => "message",
Some(crate::ContextMenuCommandAction::__NonExhaustive) => unreachable!(),
None => continue,
};
let name = command.context_menu_name.unwrap_or(&command.name);
Expand Down
1 change: 1 addition & 0 deletions src/dispatch/prefix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ async fn strip_prefix<'a, U, E>(
None
}
}
crate::Prefix::__NonExhaustive => unreachable!(),
})
{
return Some((prefix, content));
Expand Down
4 changes: 4 additions & 0 deletions src/slash_argument/slash_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ pub enum SlashArgError {
/// Original input string
input: String,
},
#[doc(hidden)]
__NonExhaustive,
}
impl std::fmt::Display for SlashArgError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
Expand All @@ -35,6 +37,7 @@ impl std::fmt::Display for SlashArgError {
Self::Parse { error, input } => {
write!(f, "Failed to parse `{}` as argument: {}", input, error)
}
Self::__NonExhaustive => unreachable!(),
}
}
}
Expand All @@ -43,6 +46,7 @@ impl std::error::Error for SlashArgError {
match self {
Self::Parse { error, input: _ } => Some(&**error),
Self::CommandStructureMismatch(_) => None,
Self::__NonExhaustive => unreachable!(),
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/structs/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ impl<U, E> Command<U, E> {
.kind(match context_menu_action {
crate::ContextMenuCommandAction::User(_) => serenity::CommandType::User,
crate::ContextMenuCommandAction::Message(_) => serenity::CommandType::Message,
crate::ContextMenuCommandAction::__NonExhaustive => unreachable!(),
});

if self.guild_only {
Expand Down
2 changes: 2 additions & 0 deletions src/structs/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pub enum Context<'a, U, E> {
Application(crate::ApplicationContext<'a, U, E>),
/// Prefix command context
Prefix(crate::PrefixContext<'a, U, E>),
// Not non_exhaustive.. adding a whole new category of commands would justify breakage lol
}
impl<U, E> Clone for Context<'_, U, E> {
fn clone(&self) -> Self {
Expand Down Expand Up @@ -554,6 +555,7 @@ impl<'a, U, E> Context<'a, U, E> {
Ok(())
}
}
crate::ContextMenuCommandAction::__NonExhaustive => unreachable!(),
};
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/structs/prefix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ pub enum MessageDispatchTrigger {
/// The message was edited, and was not a valid invocation pre-edit (i.e. user typoed the
/// command, then fixed it)
MessageEditFromInvalid,
#[doc(hidden)]
__NonExhaustive,
}

/// Prefix-specific context passed to command invocations.
Expand Down Expand Up @@ -77,6 +79,8 @@ pub enum Prefix {
Literal(&'static str),
/// Regular expression which matches the prefix
Regex(regex::Regex),
#[doc(hidden)]
__NonExhaustive,
}

/// Prefix-specific framework configuration
Expand Down
3 changes: 3 additions & 0 deletions src/structs/slash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub enum ApplicationCommandOrAutocompleteInteraction<'a> {
ApplicationCommand(&'a serenity::ApplicationCommandInteraction),
/// An autocomplete interaction
Autocomplete(&'a serenity::AutocompleteInteraction),
// Not non_exhaustive, this type is deliberately just two possible variants
}

impl<'a> ApplicationCommandOrAutocompleteInteraction<'a> {
Expand Down Expand Up @@ -178,6 +179,8 @@ pub enum ContextMenuCommandAction<U, E> {
serenity::Message,
) -> BoxFuture<'_, Result<(), crate::FrameworkError<'_, U, E>>>,
),
#[doc(hidden)]
__NonExhaustive,
}
impl<U, E> Copy for ContextMenuCommandAction<U, E> {}
impl<U, E> Clone for ContextMenuCommandAction<U, E> {
Expand Down

0 comments on commit 6c08cfb

Please sign in to comment.