Skip to content

Commit

Permalink
Allow unreachable_code lint in command! macro
Browse files Browse the repository at this point in the history
If a user returns at the end of a `command!` macro block, the library's return
value will never be processed, as it's unreachable. Instead of warning for this,
allow it.
  • Loading branch information
Ken Swenson authored and zeyla committed May 19, 2017
1 parent ae395f4 commit eb43b9c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/ext/framework/mod.rs
Expand Up @@ -117,31 +117,31 @@ use ::model::Channel;
#[macro_export]
macro_rules! command {
($fname:ident($c:ident) $b:block) => {
#[allow(unused_mut)]
#[allow(unreachable_code, unused_mut)]
pub fn $fname(mut $c: &mut $crate::client::Context, _: &$crate::model::Message, _: Vec<String>) -> ::std::result::Result<(), String> {
$b

Ok(())
}
};
($fname:ident($c:ident, $m:ident) $b:block) => {
#[allow(unused_mut)]
#[allow(unreachable_code, unused_mut)]
pub fn $fname(mut $c: &mut $crate::client::Context, $m: &$crate::model::Message, _: Vec<String>) -> ::std::result::Result<(), String> {
$b

Ok(())
}
};
($fname:ident($c:ident, $m:ident, $a:ident) $b:block) => {
#[allow(unused_mut)]
#[allow(unreachable_code, unused_mut)]
pub fn $fname(mut $c: &mut $crate::client::Context, $m: &$crate::model::Message, $a: Vec<String>) -> ::std::result::Result<(), String> {
$b

Ok(())
}
};
($fname:ident($c:ident, $m:ident, $a:ident, $($name:ident: $t:ty),*) $b:block) => {
#[allow(unreachable_patterns, unused_mut)]
#[allow(unreachable_code, unreachable_patterns, unused_mut)]
pub fn $fname(mut $c: &mut $crate::client::Context, $m: &$crate::model::Message, $a: Vec<String>) -> ::std::result::Result<(), String> {
let mut i = $a.iter();
let mut arg_counter = 0;
Expand Down

0 comments on commit eb43b9c

Please sign in to comment.