]> git.lizzy.rs Git - rust.git/blob - src/tools/rustfmt/tests/target/issue-4908.rs
:arrow_up: rust-analyzer
[rust.git] / src / tools / rustfmt / tests / target / issue-4908.rs
1 #![feature(more_qualified_paths)]
2
3 mod foo_bar {
4     pub enum Example {
5         Example1 {},
6         Example2 {},
7     }
8 }
9
10 fn main() {
11     foo!(crate::foo_bar::Example, Example1);
12
13     let i1 = foo_bar::Example::Example1 {};
14
15     assert_eq!(i1.foo_example(), 1);
16
17     let i2 = foo_bar::Example::Example2 {};
18
19     assert_eq!(i2.foo_example(), 2);
20 }
21
22 #[macro_export]
23 macro_rules! foo {
24     ($struct:path, $variant:ident) => {
25         impl $struct {
26             pub fn foo_example(&self) -> i32 {
27                 match self {
28                     <$struct>::$variant { .. } => 1,
29                     _ => 2,
30                 }
31             }
32         }
33     };
34 }