Skip to content

Commit 1a6bfec

Browse files
committed
Add test case for mem::discriminant inside a macro
1 parent 5dbca1f commit 1a6bfec

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

tests/ui/mem_discriminant.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ fn main() {
3434
mem::discriminant(rro);
3535
mem::discriminant(&rro);
3636

37+
macro_rules! mem_discriminant_but_in_a_macro {
38+
($param:expr) => (mem::discriminant($param))
39+
}
40+
41+
mem_discriminant_but_in_a_macro!(&rro);
3742

3843
// ok
3944
mem::discriminant(&Some(2));

tests/ui/mem_discriminant.stderr

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,17 @@ error: calling `mem::discriminant` on non-enum type `&&std::option::Option<i32>`
7272
| |
7373
| help: try dereferencing: `*rro`
7474

75-
error: aborting due to 9 previous errors
75+
error: calling `mem::discriminant` on non-enum type `&&std::option::Option<i32>`
76+
--> $DIR/mem_discriminant.rs:38:27
77+
|
78+
38 | ($param:expr) => (mem::discriminant($param))
79+
| ^^^^^^^^^^^^^^^^^^^^^^^^^
80+
...
81+
41 | mem_discriminant_but_in_a_macro!(&rro);
82+
| ---------------------------------------
83+
| | |
84+
| | help: try dereferencing: `*rro`
85+
| in this macro invocation
86+
87+
error: aborting due to 10 previous errors
7688

0 commit comments

Comments
 (0)