diff options
author | Lukas Wirth <[email protected]> | 2021-04-07 10:31:50 +0100 |
---|---|---|
committer | Lukas Wirth <[email protected]> | 2021-04-07 10:31:50 +0100 |
commit | 41563fd6128e94e1fe1ae4006e4e183dff1a645c (patch) | |
tree | 6de6740ca7f028b1e58ce107f414d7a4b67eb5ac /crates/hir_ty/src/tests | |
parent | e6a1c9ca60c19bf3b02b302e21d9f9fd9bd8a466 (diff) |
Infer variants through type aliased enums
Diffstat (limited to 'crates/hir_ty/src/tests')
-rw-r--r-- | crates/hir_ty/src/tests/simple.rs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/crates/hir_ty/src/tests/simple.rs b/crates/hir_ty/src/tests/simple.rs index 361cd6302..84c5c05fd 100644 --- a/crates/hir_ty/src/tests/simple.rs +++ b/crates/hir_ty/src/tests/simple.rs | |||
@@ -2564,3 +2564,36 @@ fn f() { | |||
2564 | "#, | 2564 | "#, |
2565 | ) | 2565 | ) |
2566 | } | 2566 | } |
2567 | |||
2568 | #[test] | ||
2569 | fn infer_type_alias_variant() { | ||
2570 | check_infer( | ||
2571 | r#" | ||
2572 | type Qux = Foo; | ||
2573 | enum Foo { | ||
2574 | Bar(i32), | ||
2575 | Baz { baz: f32 } | ||
2576 | } | ||
2577 | |||
2578 | fn f() { | ||
2579 | match Foo::Bar(3) { | ||
2580 | Qux::Bar(bar) => (), | ||
2581 | Qux::Baz { baz } => (), | ||
2582 | } | ||
2583 | } | ||
2584 | "#, | ||
2585 | expect![[r#" | ||
2586 | 72..166 '{ ... } }': () | ||
2587 | 78..164 'match ... }': () | ||
2588 | 84..92 'Foo::Bar': Bar(i32) -> Foo | ||
2589 | 84..95 'Foo::Bar(3)': Foo | ||
2590 | 93..94 '3': i32 | ||
2591 | 106..119 'Qux::Bar(bar)': Foo | ||
2592 | 115..118 'bar': i32 | ||
2593 | 123..125 '()': () | ||
2594 | 135..151 'Qux::B... baz }': Foo | ||
2595 | 146..149 'baz': f32 | ||
2596 | 155..157 '()': () | ||
2597 | "#]], | ||
2598 | ) | ||
2599 | } | ||