]> git.lizzy.rs Git - rust.git/blob - tests/ui/macros/macro-as-fn-body.rs
Rollup merge of #106323 - starkat99:stabilize-f16c_target_feature, r=petrochenkov
[rust.git] / tests / ui / macros / macro-as-fn-body.rs
1 //
2 // run-pass
3 //
4 // Description - ensure Interpolated blocks can act as valid function bodies
5 // Covered cases: free functions, struct methods, and default trait functions
6
7 macro_rules! def_fn {
8     ($body:block) => {
9         fn bar() $body
10     }
11 }
12
13 trait Foo {
14     def_fn!({ println!("foo"); });
15 }
16
17 struct Baz {}
18
19 impl Foo for Baz {}
20
21 struct Qux {}
22
23 impl Qux {
24     def_fn!({ println!("qux"); });
25 }
26
27 def_fn!({ println!("quux"); });
28
29 pub fn main() {
30     Baz::bar();
31     Qux::bar();
32     bar();
33 }