Skip to content

Commit

Permalink
Add test for bitflags! {}
Browse files Browse the repository at this point in the history
  • Loading branch information
konsumlamm committed Feb 11, 2021
1 parent 6bbbaab commit 380d3c0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
5 changes: 5 additions & 0 deletions src/lib.rs
Expand Up @@ -1455,4 +1455,9 @@ mod tests {
assert_eq!(format!("{:?}", Flags::empty()), "NONE");
assert_eq!(format!("{:?}", Flags::SOME), "SOME");
}

#[test]
fn test_empty_bitflags() {
bitflags! {}
}
}
3 changes: 1 addition & 2 deletions test_suite/tests/compile-fail/private_flags.rs
Expand Up @@ -6,8 +6,7 @@ mod example {
pub struct Flags1: u32 {
const FLAG_A = 0b00000001;
}
}
bitflags! {

struct Flags2: u32 {
const FLAG_B = 0b00000010;
}
Expand Down
18 changes: 10 additions & 8 deletions test_suite/tests/compile-fail/private_flags.stderr
@@ -1,16 +1,18 @@
error[E0603]: struct `Flags2` is private
--> $DIR/private_flags.rs:19:26
--> $DIR/private_flags.rs:18:26
|
19 | let flag2 = example::Flags2::FLAG_B;
18 | let flag2 = example::Flags2::FLAG_B;
| ^^^^^^ private struct
|
note: the struct `Flags2` is defined here
--> $DIR/private_flags.rs:10:5
--> $DIR/private_flags.rs:5:5
|
10 | / bitflags! {
11 | | struct Flags2: u32 {
12 | | const FLAG_B = 0b00000010;
13 | | }
14 | | }
5 | / bitflags! {
6 | | pub struct Flags1: u32 {
7 | | const FLAG_A = 0b00000001;
8 | | }
... |
12 | | }
13 | | }
| |_____^
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

0 comments on commit 380d3c0

Please sign in to comment.