diff options
Diffstat (limited to 'crates/hir_ty/src/tests/simple.rs')
-rw-r--r-- | crates/hir_ty/src/tests/simple.rs | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/crates/hir_ty/src/tests/simple.rs b/crates/hir_ty/src/tests/simple.rs index 361cd6302..5948d0bc2 100644 --- a/crates/hir_ty/src/tests/simple.rs +++ b/crates/hir_ty/src/tests/simple.rs | |||
@@ -1765,6 +1765,24 @@ fn main() { | |||
1765 | } | 1765 | } |
1766 | 1766 | ||
1767 | #[test] | 1767 | #[test] |
1768 | fn shadowing_primitive_with_inner_items() { | ||
1769 | check_types( | ||
1770 | r#" | ||
1771 | struct i32; | ||
1772 | struct Foo; | ||
1773 | |||
1774 | impl i32 { fn foo(&self) -> Foo { Foo } } | ||
1775 | |||
1776 | fn main() { | ||
1777 | fn inner() {} | ||
1778 | let x: i32 = i32; | ||
1779 | x.foo(); | ||
1780 | //^ Foo | ||
1781 | }"#, | ||
1782 | ); | ||
1783 | } | ||
1784 | |||
1785 | #[test] | ||
1768 | fn not_shadowing_primitive_by_module() { | 1786 | fn not_shadowing_primitive_by_module() { |
1769 | check_types( | 1787 | check_types( |
1770 | r#" | 1788 | r#" |
@@ -2564,3 +2582,36 @@ fn f() { | |||
2564 | "#, | 2582 | "#, |
2565 | ) | 2583 | ) |
2566 | } | 2584 | } |
2585 | |||
2586 | #[test] | ||
2587 | fn infer_type_alias_variant() { | ||
2588 | check_infer( | ||
2589 | r#" | ||
2590 | type Qux = Foo; | ||
2591 | enum Foo { | ||
2592 | Bar(i32), | ||
2593 | Baz { baz: f32 } | ||
2594 | } | ||
2595 | |||
2596 | fn f() { | ||
2597 | match Foo::Bar(3) { | ||
2598 | Qux::Bar(bar) => (), | ||
2599 | Qux::Baz { baz } => (), | ||
2600 | } | ||
2601 | } | ||
2602 | "#, | ||
2603 | expect![[r#" | ||
2604 | 72..166 '{ ... } }': () | ||
2605 | 78..164 'match ... }': () | ||
2606 | 84..92 'Foo::Bar': Bar(i32) -> Foo | ||
2607 | 84..95 'Foo::Bar(3)': Foo | ||
2608 | 93..94 '3': i32 | ||
2609 | 106..119 'Qux::Bar(bar)': Foo | ||
2610 | 115..118 'bar': i32 | ||
2611 | 123..125 '()': () | ||
2612 | 135..151 'Qux::B... baz }': Foo | ||
2613 | 146..149 'baz': f32 | ||
2614 | 155..157 '()': () | ||
2615 | "#]], | ||
2616 | ) | ||
2617 | } | ||