1 | macro_rules! should_parse { |
2 | ($name:ident, { $($in:tt)* }) => { |
3 | #[test] |
4 | fn $name() { |
5 | // Make sure we can parse the file! |
6 | syn::parse_file(stringify!($($in)*)).unwrap(); |
7 | } |
8 | } |
9 | } |
10 | |
11 | should_parse!(generic_associated_type, { |
12 | impl Foo { |
13 | type Item = &'a i32; |
14 | fn foo<'a>(&'a self) -> Self::Item<'a> {} |
15 | } |
16 | }); |
17 | |
18 | #[rustfmt::skip] |
19 | should_parse!(const_generics_use, { |
20 | type X = Foo<5>; |
21 | type Y = Foo<"foo" >; |
22 | type Z = Foo<X>; |
23 | type W = Foo<{ X + 10 }>; |
24 | }); |
25 | |
26 | should_parse!(trailing_plus_type, { |
27 | type A = Box<Foo>; |
28 | type A = Box<Foo + 'a>; |
29 | type A = Box<'a + Foo>; |
30 | }); |
31 | |
32 | should_parse!(generic_associated_type_where, { |
33 | trait Foo { |
34 | type Item; |
35 | fn foo<T>(&self, t: T) -> Self::Item<T>; |
36 | } |
37 | }); |
38 | |
39 | should_parse!(match_with_block_expr, { |
40 | fn main() { |
41 | match false { |
42 | _ => {}.a(), |
43 | } |
44 | } |
45 | }); |
46 | |