aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/tests/patterns.rs
diff options
context:
space:
mode:
authorJonas Schievink <[email protected]>2021-04-10 22:12:02 +0100
committerJonas Schievink <[email protected]>2021-04-11 00:25:50 +0100
commite2c1da36f59cd99d4da4c1d5f8f323626d3dbe61 (patch)
treee06290db93699c71d1e4c752de6563ff787bd5fa /crates/hir_ty/src/tests/patterns.rs
parentbd675c8a8bdd3fda239bee3d3f31acd8679655b9 (diff)
Support macros in pattern position
Diffstat (limited to 'crates/hir_ty/src/tests/patterns.rs')
-rw-r--r--crates/hir_ty/src/tests/patterns.rs28
1 files changed, 27 insertions, 1 deletions
diff --git a/crates/hir_ty/src/tests/patterns.rs b/crates/hir_ty/src/tests/patterns.rs
index 85a28e76b..f514b3efe 100644
--- a/crates/hir_ty/src/tests/patterns.rs
+++ b/crates/hir_ty/src/tests/patterns.rs
@@ -1,6 +1,6 @@
1use expect_test::expect; 1use expect_test::expect;
2 2
3use super::{check_infer, check_infer_with_mismatches}; 3use super::{check_infer, check_infer_with_mismatches, check_types};
4 4
5#[test] 5#[test]
6fn infer_pattern() { 6fn infer_pattern() {
@@ -825,3 +825,29 @@ fn foo(foo: Foo) {
825 "#]], 825 "#]],
826 ); 826 );
827} 827}
828
829#[test]
830fn macro_pat() {
831 check_types(
832 r#"
833macro_rules! pat {
834 ($name:ident) => { Enum::Variant1($name) }
835}
836
837enum Enum {
838 Variant1(u8),
839 Variant2,
840}
841
842fn f(e: Enum) {
843 match e {
844 pat!(bind) => {
845 bind;
846 //^^^^ u8
847 }
848 Enum::Variant2 => {}
849 }
850}
851 "#,
852 )
853}