Skip to content

Commit

Permalink
fix emission of some expected warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
KodrAus committed May 4, 2022
1 parent 00bcfc8 commit 8c67a43
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/lib.rs
Expand Up @@ -456,7 +456,14 @@ macro_rules! __impl_bitflags {
}
}

#[allow(dead_code)]
#[allow(
dead_code,
deprecated,
unused_doc_comments,
unused_attributes,
unused_mut,
non_upper_case_globals
)]
impl $BitFlags {
$(
$(#[$attr $($args)*])*
Expand Down Expand Up @@ -502,11 +509,9 @@ macro_rules! __impl_bitflags {
return Self { bits }
}

#[allow(unused_mut)]
let mut truncated = <$T as $crate::__private::Bits>::EMPTY;

$(
#[allow(unused_doc_comments, unused_attributes)]
$(#[$attr $($args)*])*
if bits & Self::$Flag.bits == Self::$Flag.bits {
truncated |= Self::$Flag.bits
Expand Down Expand Up @@ -678,11 +683,9 @@ macro_rules! __impl_bitflags {
use $crate::__private::core::iter::Iterator as _;

const NUM_FLAGS: usize = {
#[allow(unused_mut)]
let mut num_flags = 0;

$(
#[allow(unused_doc_comments, unused_attributes)]
$(#[$attr $($args)*])*
{
num_flags += 1;
Expand All @@ -694,13 +697,11 @@ macro_rules! __impl_bitflags {

const OPTIONS: [$BitFlags; NUM_FLAGS] = [
$(
#[allow(unused_doc_comments, unused_attributes)]
$(#[$attr $($args)*])*
$BitFlags::$Flag,
)*
];

#[allow(unused_doc_comments, unused_attributes)]
const OPTIONS_NAMES: [&'static str; NUM_FLAGS] = [
$(
$(#[$attr $($args)*])*
Expand Down
14 changes: 14 additions & 0 deletions tests/compile-pass/deprecated.rs
@@ -0,0 +1,14 @@
#![deny(warnings)]

#[macro_use]
extern crate bitflags;

bitflags! {
pub struct Flags: u32 {
#[deprecated = "Use something else"]
const A = 0b00000001;
const B = 0b00000010;
}
}

fn main() {}
13 changes: 13 additions & 0 deletions tests/compile-pass/non_snake_case.rs
@@ -0,0 +1,13 @@
#![deny(warnings)]

#[macro_use]
extern crate bitflags;

bitflags! {
pub struct Flags: u32 {
const CamelCase = 0b00000001;
const B = 0b00000010;
}
}

fn main() {}

0 comments on commit 8c67a43

Please sign in to comment.