From 5d72b96988587699e0a1c62c08bd76d2a7fed100 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sun, 24 Feb 2019 17:25:41 +0100 Subject: Implement support for type aliases --- crates/ra_hir/src/ty/tests.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'crates/ra_hir/src/ty/tests.rs') diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index d0da34677..490c087f9 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs @@ -740,6 +740,27 @@ fn test() { ); } +#[test] +fn infer_type_alias() { + check_inference( + "infer_type_alias", + r#" +struct A { x: X, y: Y }; +type Foo = A; +type Bar = A; +type Baz = A; +fn test(x: Foo, y: Bar<&str>, z: Baz) { + x.x; + x.y; + y.x; + y.y; + z.x; + z.y; +} +"#, + ) +} + #[test] fn no_panic_on_field_of_enum() { check_inference( -- cgit v1.2.3 From c3c09795614f31f988edc9cb051ce024d1996d89 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sun, 24 Feb 2019 17:29:07 +0100 Subject: Add test for recursive type aliases --- crates/ra_hir/src/ty/tests.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'crates/ra_hir/src/ty/tests.rs') diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index 490c087f9..642259225 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs @@ -761,6 +761,20 @@ fn test(x: Foo, y: Bar<&str>, z: Baz) { ) } +#[test] +#[should_panic] // we currently can't handle this +fn recursive_type_alias() { + check_inference( + "recursive_type_alias", + r#" +struct A {}; +type Foo = Foo; +type Bar = A; +fn test(x: Foo) {} +"#, + ) +} + #[test] fn no_panic_on_field_of_enum() { check_inference( -- cgit v1.2.3