test_should_parse.rs 915 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. should_parse!(generic_associated_type, {
  11. impl Foo {
  12. type Item = &'a i32;
  13. fn foo<'a>(&'a self) -> Self::Item<'a> {}
  14. }
  15. });
  16. #[rustfmt::skip]
  17. should_parse!(const_generics_use, {
  18. type X = Foo<5>;
  19. type Y = Foo<"foo">;
  20. type Z = Foo<X>;
  21. type W = Foo<{ X + 10 }>;
  22. });
  23. should_parse!(trailing_plus_type, {
  24. type A = Box<Foo>;
  25. type A = Box<Foo + 'a>;
  26. type A = Box<'a + Foo>;
  27. });
  28. should_parse!(generic_associated_type_where, {
  29. trait Foo {
  30. type Item;
  31. fn foo<T>(&self, t: T) -> Self::Item<T>;
  32. }
  33. });
  34. should_parse!(match_with_block_expr, {
  35. fn main() {
  36. match false {
  37. _ => {}.a(),
  38. }
  39. }
  40. });