aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/tests/simple.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_ty/src/tests/simple.rs')
-rw-r--r--crates/hir_ty/src/tests/simple.rs54
1 files changed, 54 insertions, 0 deletions
diff --git a/crates/hir_ty/src/tests/simple.rs b/crates/hir_ty/src/tests/simple.rs
index 84c5c05fd..0eefd70f2 100644
--- a/crates/hir_ty/src/tests/simple.rs
+++ b/crates/hir_ty/src/tests/simple.rs
@@ -1029,6 +1029,42 @@ fn infer_in_elseif() {
1029} 1029}
1030 1030
1031#[test] 1031#[test]
1032fn infer_closure_unify() {
1033 check_infer(
1034 r#"
1035 fn foo(f: bool) {
1036 let a = |x| x;
1037 let b = |x| x;
1038 let id = if f { a } else { b };
1039 id(123);
1040 }
1041 "#,
1042 expect![[r#"
1043 7..8 'f': bool
1044 16..106 '{ ...23); }': ()
1045 26..27 'a': |i32| -> i32
1046 30..35 '|x| x': |i32| -> i32
1047 31..32 'x': i32
1048 34..35 'x': i32
1049 45..46 'b': |i32| -> i32
1050 49..54 '|x| x': |i32| -> i32
1051 50..51 'x': i32
1052 53..54 'x': i32
1053 64..66 'id': |i32| -> i32
1054 69..90 'if f {... { b }': |i32| -> i32
1055 72..73 'f': bool
1056 74..79 '{ a }': |i32| -> i32
1057 76..77 'a': |i32| -> i32
1058 85..90 '{ b }': |i32| -> i32
1059 87..88 'b': |i32| -> i32
1060 96..98 'id': |i32| -> i32
1061 96..103 'id(123)': i32
1062 99..102 '123': i32
1063 "#]],
1064 )
1065}
1066
1067#[test]
1032fn infer_if_match_with_return() { 1068fn infer_if_match_with_return() {
1033 check_infer( 1069 check_infer(
1034 r#" 1070 r#"
@@ -1765,6 +1801,24 @@ fn main() {
1765} 1801}
1766 1802
1767#[test] 1803#[test]
1804fn shadowing_primitive_with_inner_items() {
1805 check_types(
1806 r#"
1807struct i32;
1808struct Foo;
1809
1810impl i32 { fn foo(&self) -> Foo { Foo } }
1811
1812fn main() {
1813 fn inner() {}
1814 let x: i32 = i32;
1815 x.foo();
1816 //^ Foo
1817}"#,
1818 );
1819}
1820
1821#[test]
1768fn not_shadowing_primitive_by_module() { 1822fn not_shadowing_primitive_by_module() {
1769 check_types( 1823 check_types(
1770 r#" 1824 r#"