-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This patch checks if there is any top level attribute macro expansion, and if there it, we report it as an error. fixes: #1 Signed-off-by: Ahmed Abdelraoof <ahmed.abdelraoof@huawei.com>
- Loading branch information
Showing
5 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
use safe_discriminant::Discriminant; | ||
use safe_discriminant_derive::remove_repr; | ||
|
||
#[remove_repr] | ||
#[derive(Discriminant)] | ||
#[repr(u8)] | ||
pub enum Foo { | ||
A = 0, | ||
B = 1, | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
error: Discriminant requires a `#[repr(x)] where x is one of u8, i8, u16, i16, u32, i32, u64, i64, u128, i128. | ||
--> tests/fail/remove_repr_disc1.rs:7:10 | ||
| | ||
7 | pub enum Foo { | ||
| ^^^ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
use safe_discriminant::Discriminant; | ||
use safe_discriminant_derive::remove_repr; | ||
|
||
#[derive(Discriminant)] | ||
#[remove_repr] | ||
#[repr(u8)] | ||
pub enum Foo { | ||
A = 0, | ||
B = 1, | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
error: Discriminant is not compatiable with any top level `#[attr]` except `#[repr(_)]`. | ||
--> tests/fail/remove_repr_disc2.rs:7:10 | ||
| | ||
7 | pub enum Foo { | ||
| ^^^ |