aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__bug_484.snap (renamed from crates/ra_hir/src/ty/tests/data/bug_484.txt)5
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__bug_585.snap (renamed from crates/ra_hir/src/ty/tests/data/bug_585.txt)5
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_adt_pattern.snap (renamed from crates/ra_hir/src/ty/tests/data/adt_pattern.txt)5
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_array.snap (renamed from crates/ra_hir/src/ty/tests/data/array.txt)5
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_backwards.snap (renamed from crates/ra_hir/src/ty/tests/data/backwards.txt)5
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_basics.snap (renamed from crates/ra_hir/src/ty/tests/data/basics.txt)5
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_binary_op.snap (renamed from crates/ra_hir/src/ty/tests/data/binary_op.txt)5
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_enum.snap9
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_field_autoderef.snap (renamed from crates/ra_hir/src/ty/tests/data/field_autoderef.txt)5
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_function_generics.snap (renamed from crates/ra_hir/src/ty/tests/data/function_generics.txt)5
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_generic_chain.snap (renamed from crates/ra_hir/src/ty/tests/data/generic_chain.txt)5
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_generics_in_patterns.snap (renamed from crates/ra_hir/src/ty/tests/data/generics_in_patterns.txt)5
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_inherent_method.snap (renamed from crates/ra_hir/src/ty/tests/data/inherent_method.txt)5
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_let.snap (renamed from crates/ra_hir/src/ty/tests/data/let.txt)5
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_literals.snap (renamed from crates/ra_hir/src/ty/tests/data/literals.txt)5
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_paths.snap (renamed from crates/ra_hir/src/ty/tests/data/paths.txt)5
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_pattern.snap (renamed from crates/ra_hir/src/ty/tests/data/pattern.txt)5
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_refs.snap (renamed from crates/ra_hir/src/ty/tests/data/refs_and_ptrs.txt)5
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_self.snap (renamed from crates/ra_hir/src/ty/tests/data/self.txt)5
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_struct.snap (renamed from crates/ra_hir/src/ty/tests/data/struct.txt)5
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_struct_generics.snap (renamed from crates/ra_hir/src/ty/tests/data/struct_generics.txt)5
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_tuple.snap (renamed from crates/ra_hir/src/ty/tests/data/tuple.txt)5
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_unary_op.snap (renamed from crates/ra_hir/src/ty/tests/data/unary_op.txt)5
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__no_panic_on_field_of_enum.snap9
-rw-r--r--crates/ra_hir/src/ty/tests.rs76
-rw-r--r--crates/ra_hir/src/ty/tests/data/enum.txt4
-rw-r--r--crates/ra_hir/src/ty/tests/data/no_panic_on_field_of_enum.txt4
27 files changed, 157 insertions, 55 deletions
diff --git a/crates/ra_hir/src/ty/tests/data/bug_484.txt b/crates/ra_hir/src/ty/snapshots/tests__bug_484.snap
index 300530551..eeb3061d3 100644
--- a/crates/ra_hir/src/ty/tests/data/bug_484.txt
+++ b/crates/ra_hir/src/ty/snapshots/tests__bug_484.snap
@@ -1,5 +1,10 @@
1Created: 2019-01-21T21:48:20.662863951+00:00
2Creator: [email protected]
3Source: crates/ra_hir/src/ty/tests.rs
4
1[11; 37) '{ l... {}; }': () 5[11; 37) '{ l... {}; }': ()
2[20; 21) 'x': () 6[20; 21) 'x': ()
3[24; 34) 'if true {}': () 7[24; 34) 'if true {}': ()
4[27; 31) 'true': bool 8[27; 31) 'true': bool
5[32; 34) '{}': () 9[32; 34) '{}': ()
10
diff --git a/crates/ra_hir/src/ty/tests/data/bug_585.txt b/crates/ra_hir/src/ty/snapshots/tests__bug_585.snap
index 627702a38..073009bbc 100644
--- a/crates/ra_hir/src/ty/tests/data/bug_585.txt
+++ b/crates/ra_hir/src/ty/snapshots/tests__bug_585.snap
@@ -1,3 +1,7 @@
1Created: 2019-01-21T21:48:20.662863969+00:00
2Creator: [email protected]
3Source: crates/ra_hir/src/ty/tests.rs
4
1[11; 89) '{ ... } }': () 5[11; 89) '{ ... } }': ()
2[17; 21) 'X {}': [unknown] 6[17; 21) 'X {}': [unknown]
3[27; 87) 'match ... }': () 7[27; 87) 'match ... }': ()
@@ -6,3 +10,4 @@
6[56; 58) '()': () 10[56; 58) '()': ()
7[68; 74) 'A::Y()': [unknown] 11[68; 74) 'A::Y()': [unknown]
8[78; 80) '()': () 12[78; 80) '()': ()
13
diff --git a/crates/ra_hir/src/ty/tests/data/adt_pattern.txt b/crates/ra_hir/src/ty/snapshots/tests__infer_adt_pattern.snap
index 2daf9647b..fb261f1c0 100644
--- a/crates/ra_hir/src/ty/tests/data/adt_pattern.txt
+++ b/crates/ra_hir/src/ty/snapshots/tests__infer_adt_pattern.snap
@@ -1,3 +1,7 @@
1Created: 2019-01-21T21:48:20.662935249+00:00
2Creator: [email protected]
3Source: crates/ra_hir/src/ty/tests.rs
4
1[68; 262) '{ ... d; }': () 5[68; 262) '{ ... d; }': ()
2[78; 79) 'e': E 6[78; 79) 'e': E
3[82; 95) 'E::A { x: 3 }': E 7[82; 95) 'E::A { x: 3 }': E
@@ -20,3 +24,4 @@
20[237; 248) 'E::A { .. }': E 24[237; 248) 'E::A { .. }': E
21[251; 252) 'e': E 25[251; 252) 'e': E
22[258; 259) 'd': &E 26[258; 259) 'd': &E
27
diff --git a/crates/ra_hir/src/ty/tests/data/array.txt b/crates/ra_hir/src/ty/snapshots/tests__infer_array.snap
index acdf74ba4..2fc613e26 100644
--- a/crates/ra_hir/src/ty/tests/data/array.txt
+++ b/crates/ra_hir/src/ty/snapshots/tests__infer_array.snap
@@ -1,3 +1,7 @@
1Created: 2019-01-21T21:48:20.662961921+00:00
2Creator: [email protected]
3Source: crates/ra_hir/src/ty/tests.rs
4
1[9; 10) 'x': &str 5[9; 10) 'x': &str
2[18; 19) 'y': isize 6[18; 19) 'y': isize
3[28; 293) '{ ... []; }': () 7[28; 293) '{ ... []; }': ()
@@ -50,3 +54,4 @@
50[260; 263) '"b"': &str 54[260; 263) '"b"': &str
51[275; 276) 'x': [u8] 55[275; 276) 'x': [u8]
52[288; 290) '[]': [u8] 56[288; 290) '[]': [u8]
57
diff --git a/crates/ra_hir/src/ty/tests/data/backwards.txt b/crates/ra_hir/src/ty/snapshots/tests__infer_backwards.snap
index b8593cfd1..12f0d8c90 100644
--- a/crates/ra_hir/src/ty/tests/data/backwards.txt
+++ b/crates/ra_hir/src/ty/snapshots/tests__infer_backwards.snap
@@ -1,3 +1,7 @@
1Created: 2019-01-21T21:48:20.662902243+00:00
2Creator: [email protected]
3Source: crates/ra_hir/src/ty/tests.rs
4
1[14; 15) 'x': u32 5[14; 15) 'x': u32
2[22; 24) '{}': () 6[22; 24) '{}': ()
3[78; 231) '{ ...t &c }': &mut &f64 7[78; 231) '{ ...t &c }': &mut &f64
@@ -18,3 +22,4 @@
18[222; 229) '&mut &c': &mut &f64 22[222; 229) '&mut &c': &mut &f64
19[227; 229) '&c': &f64 23[227; 229) '&c': &f64
20[228; 229) 'c': f64 24[228; 229) 'c': f64
25
diff --git a/crates/ra_hir/src/ty/tests/data/basics.txt b/crates/ra_hir/src/ty/snapshots/tests__infer_basics.snap
index e65fe07aa..eba8126e9 100644
--- a/crates/ra_hir/src/ty/tests/data/basics.txt
+++ b/crates/ra_hir/src/ty/snapshots/tests__infer_basics.snap
@@ -1,3 +1,7 @@
1Created: 2019-01-21T21:48:20.662874226+00:00
2Creator: [email protected]
3Source: crates/ra_hir/src/ty/tests.rs
4
1[9; 10) 'a': u32 5[9; 10) 'a': u32
2[17; 18) 'b': isize 6[17; 18) 'b': isize
3[27; 28) 'c': ! 7[27; 28) 'c': !
@@ -11,3 +15,4 @@
11[88; 94) '1isize': isize 15[88; 94) '1isize': isize
12[100; 106) '"test"': &str 16[100; 106) '"test"': &str
13[112; 118) '1.0f32': f32 17[112; 118) '1.0f32': f32
18
diff --git a/crates/ra_hir/src/ty/tests/data/binary_op.txt b/crates/ra_hir/src/ty/snapshots/tests__infer_binary_op.snap
index 58a727691..3b750ec45 100644
--- a/crates/ra_hir/src/ty/tests/data/binary_op.txt
+++ b/crates/ra_hir/src/ty/snapshots/tests__infer_binary_op.snap
@@ -1,3 +1,7 @@
1Created: 2019-01-21T21:48:20.662972146+00:00
2Creator: [email protected]
3Source: crates/ra_hir/src/ty/tests.rs
4
1[6; 7) 'x': bool 5[6; 7) 'x': bool
2[22; 34) '{ 0i32 }': i32 6[22; 34) '{ 0i32 }': i32
3[28; 32) '0i32': i32 7[28; 32) '0i32': i32
@@ -44,3 +48,4 @@
44[341; 344) 'ten': usize 48[341; 344) 'ten': usize
45[341; 348) 'ten < 3': bool 49[341; 348) 'ten < 3': bool
46[347; 348) '3': usize 50[347; 348) '3': usize
51
diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_enum.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_enum.snap
new file mode 100644
index 000000000..8018ff025
--- /dev/null
+++ b/crates/ra_hir/src/ty/snapshots/tests__infer_enum.snap
@@ -0,0 +1,9 @@
1Created: 2019-01-21T21:48:20.662949719+00:00
2Creator: [email protected]
3Source: crates/ra_hir/src/ty/tests.rs
4
5[48; 82) '{ E:...:V2; }': ()
6[52; 70) 'E::V1 ...d: 1 }': E
7[67; 68) '1': u32
8[74; 79) 'E::V2': E
9
diff --git a/crates/ra_hir/src/ty/tests/data/field_autoderef.txt b/crates/ra_hir/src/ty/snapshots/tests__infer_field_autoderef.snap
index e1db1db40..1943ef079 100644
--- a/crates/ra_hir/src/ty/tests/data/field_autoderef.txt
+++ b/crates/ra_hir/src/ty/snapshots/tests__infer_field_autoderef.snap
@@ -1,3 +1,7 @@
1Created: 2019-01-21T21:48:20.671554939+00:00
2Creator: [email protected]
3Source: crates/ra_hir/src/ty/tests.rs
4
1[44; 45) 'a': A 5[44; 45) 'a': A
2[50; 213) '{ ...5.b; }': () 6[50; 213) '{ ...5.b; }': ()
3[60; 62) 'a1': A 7[60; 62) 'a1': A
@@ -41,3 +45,4 @@
41[256; 260) 'a1.b': B 45[256; 260) 'a1.b': B
42[266; 268) 'a2': *mut A 46[266; 268) 'a2': *mut A
43[266; 270) 'a2.b': B 47[266; 270) 'a2.b': B
48
diff --git a/crates/ra_hir/src/ty/tests/data/function_generics.txt b/crates/ra_hir/src/ty/snapshots/tests__infer_function_generics.snap
index e44d26cfd..386acc0b3 100644
--- a/crates/ra_hir/src/ty/tests/data/function_generics.txt
+++ b/crates/ra_hir/src/ty/snapshots/tests__infer_function_generics.snap
@@ -1,3 +1,7 @@
1Created: 2019-01-21T21:48:20.669112954+00:00
2Creator: [email protected]
3Source: crates/ra_hir/src/ty/tests.rs
4
1[10; 11) 't': [unknown] 5[10; 11) 't': [unknown]
2[21; 26) '{ t }': [unknown] 6[21; 26) '{ t }': [unknown]
3[23; 24) 't': [unknown] 7[23; 24) 't': [unknown]
@@ -12,3 +16,4 @@
12[90; 92) 'id': fn(T) -> T 16[90; 92) 'id': fn(T) -> T
13[90; 95) 'id(1)': T 17[90; 95) 'id(1)': T
14[93; 94) '1': T 18[93; 94) '1': T
19
diff --git a/crates/ra_hir/src/ty/tests/data/generic_chain.txt b/crates/ra_hir/src/ty/snapshots/tests__infer_generic_chain.snap
index 568e00846..7a64e4f95 100644
--- a/crates/ra_hir/src/ty/tests/data/generic_chain.txt
+++ b/crates/ra_hir/src/ty/snapshots/tests__infer_generic_chain.snap
@@ -1,3 +1,7 @@
1Created: 2019-01-21T21:48:20.672467086+00:00
2Creator: [email protected]
3Source: crates/ra_hir/src/ty/tests.rs
4
1[53; 57) 'self': A<[unknown]> 5[53; 57) 'self': A<[unknown]>
2[65; 87) '{ ... }': [unknown] 6[65; 87) '{ ... }': [unknown]
3[75; 79) 'self': A<[unknown]> 7[75; 79) 'self': A<[unknown]>
@@ -27,3 +31,4 @@
27[244; 245) 'z': T 31[244; 245) 'z': T
28[254; 255) 'b': A<T> 32[254; 255) 'b': A<T>
29[254; 259) 'b.x()': i128 33[254; 259) 'b.x()': i128
34
diff --git a/crates/ra_hir/src/ty/tests/data/generics_in_patterns.txt b/crates/ra_hir/src/ty/snapshots/tests__infer_generics_in_patterns.snap
index 1b01ef19e..ae38ec2fb 100644
--- a/crates/ra_hir/src/ty/tests/data/generics_in_patterns.txt
+++ b/crates/ra_hir/src/ty/snapshots/tests__infer_generics_in_patterns.snap
@@ -1,3 +1,7 @@
1Created: 2019-01-21T21:48:20.683908196+00:00
2Creator: [email protected]
3Source: crates/ra_hir/src/ty/tests.rs
4
1[79; 81) 'a1': A<u32> 5[79; 81) 'a1': A<u32>
2[91; 92) 'o': Option<u64> 6[91; 92) 'o': Option<u64>
3[107; 244) '{ ... }; }': () 7[107; 244) '{ ... }; }': ()
@@ -15,3 +19,4 @@
15[217; 218) 't': u64 19[217; 218) 't': u64
16[228; 229) '_': Option<u64> 20[228; 229) '_': Option<u64>
17[233; 234) '1': u64 21[233; 234) '1': u64
22
diff --git a/crates/ra_hir/src/ty/tests/data/inherent_method.txt b/crates/ra_hir/src/ty/snapshots/tests__infer_inherent_method.snap
index 6e6f70357..298dac585 100644
--- a/crates/ra_hir/src/ty/tests/data/inherent_method.txt
+++ b/crates/ra_hir/src/ty/snapshots/tests__infer_inherent_method.snap
@@ -1,3 +1,7 @@
1Created: 2019-01-21T21:48:20.670255659+00:00
2Creator: [email protected]
3Source: crates/ra_hir/src/ty/tests.rs
4
1[32; 36) 'self': A 5[32; 36) 'self': A
2[38; 39) 'x': u32 6[38; 39) 'x': u32
3[53; 55) '{}': () 7[53; 55) '{}': ()
@@ -16,3 +20,4 @@
16[187; 188) 'a': A 20[187; 188) 'a': A
17[187; 195) 'a.bar(1)': i64 21[187; 195) 'a.bar(1)': i64
18[193; 194) '1': u64 22[193; 194) '1': u64
23
diff --git a/crates/ra_hir/src/ty/tests/data/let.txt b/crates/ra_hir/src/ty/snapshots/tests__infer_let.snap
index 8815dba41..aa4e4cc63 100644
--- a/crates/ra_hir/src/ty/tests/data/let.txt
+++ b/crates/ra_hir/src/ty/snapshots/tests__infer_let.snap
@@ -1,3 +1,7 @@
1Created: 2019-01-21T21:48:20.666406651+00:00
2Creator: [email protected]
3Source: crates/ra_hir/src/ty/tests.rs
4
1[11; 71) '{ ...= b; }': () 5[11; 71) '{ ...= b; }': ()
2[21; 22) 'a': isize 6[21; 22) 'a': isize
3[25; 31) '1isize': isize 7[25; 31) '1isize': isize
@@ -5,3 +9,4 @@
5[52; 53) '1': usize 9[52; 53) '1': usize
6[63; 64) 'c': usize 10[63; 64) 'c': usize
7[67; 68) 'b': usize 11[67; 68) 'b': usize
12
diff --git a/crates/ra_hir/src/ty/tests/data/literals.txt b/crates/ra_hir/src/ty/snapshots/tests__infer_literals.snap
index 84ee2c11b..00c7e639e 100644
--- a/crates/ra_hir/src/ty/tests/data/literals.txt
+++ b/crates/ra_hir/src/ty/snapshots/tests__infer_literals.snap
@@ -1,3 +1,7 @@
1Created: 2019-01-21T21:48:20.666200994+00:00
2Creator: [email protected]
3Source: crates/ra_hir/src/ty/tests.rs
4
1[11; 201) '{ ...o"#; }': () 5[11; 201) '{ ...o"#; }': ()
2[17; 21) '5i32': i32 6[17; 21) '5i32': i32
3[27; 34) '"hello"': &str 7[27; 34) '"hello"': &str
@@ -10,3 +14,4 @@
10[104; 108) 'true': bool 14[104; 108) 'true': bool
11[114; 182) 'r#" ... "#': &str 15[114; 182) 'r#" ... "#': &str
12[188; 198) 'br#"yolo"#': &[u8] 16[188; 198) 'br#"yolo"#': &[u8]
17
diff --git a/crates/ra_hir/src/ty/tests/data/paths.txt b/crates/ra_hir/src/ty/snapshots/tests__infer_paths.snap
index b22f4d4a5..0924cdc80 100644
--- a/crates/ra_hir/src/ty/tests/data/paths.txt
+++ b/crates/ra_hir/src/ty/snapshots/tests__infer_paths.snap
@@ -1,3 +1,7 @@
1Created: 2019-01-21T21:48:20.671399345+00:00
2Creator: [email protected]
3Source: crates/ra_hir/src/ty/tests.rs
4
1[15; 20) '{ 1 }': u32 5[15; 20) '{ 1 }': u32
2[17; 18) '1': u32 6[17; 18) '1': u32
3[48; 53) '{ 1 }': u32 7[48; 53) '{ 1 }': u32
@@ -7,3 +11,4 @@
7[73; 76) 'a()': u32 11[73; 76) 'a()': u32
8[82; 86) 'b::c': fn() -> u32 12[82; 86) 'b::c': fn() -> u32
9[82; 88) 'b::c()': u32 13[82; 88) 'b::c()': u32
14
diff --git a/crates/ra_hir/src/ty/tests/data/pattern.txt b/crates/ra_hir/src/ty/snapshots/tests__infer_pattern.snap
index 966289aaf..b22b71765 100644
--- a/crates/ra_hir/src/ty/tests/data/pattern.txt
+++ b/crates/ra_hir/src/ty/snapshots/tests__infer_pattern.snap
@@ -1,3 +1,7 @@
1Created: 2019-01-21T21:48:20.677661229+00:00
2Creator: [email protected]
3Source: crates/ra_hir/src/ty/tests.rs
4
1[9; 10) 'x': &i32 5[9; 10) 'x': &i32
2[18; 369) '{ ...o_x; }': () 6[18; 369) '{ ...o_x; }': ()
3[28; 29) 'y': &i32 7[28; 29) 'y': &i32
@@ -45,3 +49,4 @@
45[339; 340) 'x': &i32 49[339; 340) 'x': &i32
46[350; 351) 'k': &mut &i32 50[350; 351) 'k': &mut &i32
47[354; 366) 'mut_ref_to_x': &mut &i32 51[354; 366) 'mut_ref_to_x': &mut &i32
52
diff --git a/crates/ra_hir/src/ty/tests/data/refs_and_ptrs.txt b/crates/ra_hir/src/ty/snapshots/tests__infer_refs.snap
index afab343ea..fc5bfe677 100644
--- a/crates/ra_hir/src/ty/tests/data/refs_and_ptrs.txt
+++ b/crates/ra_hir/src/ty/snapshots/tests__infer_refs.snap
@@ -1,3 +1,7 @@
1Created: 2019-01-21T21:48:20.674183006+00:00
2Creator: [email protected]
3Source: crates/ra_hir/src/ty/tests.rs
4
1[9; 10) 'a': &u32 5[9; 10) 'a': &u32
2[18; 19) 'b': &mut u32 6[18; 19) 'b': &mut u32
3[31; 32) 'c': *const u32 7[31; 32) 'c': *const u32
@@ -21,3 +25,4 @@
21[138; 139) 'd': *mut u32 25[138; 139) 'd': *mut u32
22[145; 147) '*d': u32 26[145; 147) '*d': u32
23[146; 147) 'd': *mut u32 27[146; 147) 'd': *mut u32
28
diff --git a/crates/ra_hir/src/ty/tests/data/self.txt b/crates/ra_hir/src/ty/snapshots/tests__infer_self.snap
index c38029f97..76cb62055 100644
--- a/crates/ra_hir/src/ty/tests/data/self.txt
+++ b/crates/ra_hir/src/ty/snapshots/tests__infer_self.snap
@@ -1,6 +1,11 @@
1Created: 2019-01-21T21:50:17.870325361+00:00
2Creator: [email protected]
3Source: crates/ra_hir/src/ty/tests.rs
4
1[34; 38) 'self': &S 5[34; 38) 'self': &S
2[40; 61) '{ ... }': () 6[40; 61) '{ ... }': ()
3[50; 54) 'self': &S 7[50; 54) 'self': &S
4[75; 79) 'self': &S 8[75; 79) 'self': &S
5[88; 109) '{ ... }': () 9[88; 109) '{ ... }': ()
6[98; 102) 'self': &S 10[98; 102) 'self': &S
11
diff --git a/crates/ra_hir/src/ty/tests/data/struct.txt b/crates/ra_hir/src/ty/snapshots/tests__infer_struct.snap
index be9e12d02..0c94d6837 100644
--- a/crates/ra_hir/src/ty/tests/data/struct.txt
+++ b/crates/ra_hir/src/ty/snapshots/tests__infer_struct.snap
@@ -1,3 +1,7 @@
1Created: 2019-01-21T21:48:20.677495622+00:00
2Creator: [email protected]
3Source: crates/ra_hir/src/ty/tests.rs
4
1[72; 154) '{ ...a.c; }': () 5[72; 154) '{ ...a.c; }': ()
2[82; 83) 'c': [unknown] 6[82; 83) 'c': [unknown]
3[86; 87) 'C': [unknown] 7[86; 87) 'C': [unknown]
@@ -14,3 +18,4 @@
14[139; 142) 'a.b': B 18[139; 142) 'a.b': B
15[148; 149) 'a': A 19[148; 149) 'a': A
16[148; 151) 'a.c': C 20[148; 151) 'a.c': C
21
diff --git a/crates/ra_hir/src/ty/tests/data/struct_generics.txt b/crates/ra_hir/src/ty/snapshots/tests__infer_struct_generics.snap
index 1024a39a9..7cf947d4d 100644
--- a/crates/ra_hir/src/ty/tests/data/struct_generics.txt
+++ b/crates/ra_hir/src/ty/snapshots/tests__infer_struct_generics.snap
@@ -1,3 +1,7 @@
1Created: 2019-01-21T21:48:20.678274444+00:00
2Creator: [email protected]
3Source: crates/ra_hir/src/ty/tests.rs
4
1[36; 38) 'a1': A<u32> 5[36; 38) 'a1': A<u32>
2[48; 49) 'i': i32 6[48; 49) 'i': i32
3[56; 147) '{ ...3.x; }': () 7[56; 147) '{ ...3.x; }': ()
@@ -13,3 +17,4 @@
13[131; 132) '1': i128 17[131; 132) '1': i128
14[140; 142) 'a3': A<i128> 18[140; 142) 'a3': A<i128>
15[140; 144) 'a3.x': i128 19[140; 144) 'a3.x': i128
20
diff --git a/crates/ra_hir/src/ty/tests/data/tuple.txt b/crates/ra_hir/src/ty/snapshots/tests__infer_tuple.snap
index a95d3c286..862644145 100644
--- a/crates/ra_hir/src/ty/tests/data/tuple.txt
+++ b/crates/ra_hir/src/ty/snapshots/tests__infer_tuple.snap
@@ -1,3 +1,7 @@
1Created: 2019-01-21T21:48:20.676903109+00:00
2Creator: [email protected]
3Source: crates/ra_hir/src/ty/tests.rs
4
1[9; 10) 'x': &str 5[9; 10) 'x': &str
2[18; 19) 'y': isize 6[18; 19) 'y': isize
3[28; 170) '{ ...d"); }': () 7[28; 170) '{ ...d"); }': ()
@@ -25,3 +29,4 @@
25[159; 167) '(e, "d")': ((i32, &str), &str) 29[159; 167) '(e, "d")': ((i32, &str), &str)
26[160; 161) 'e': (i32, &str) 30[160; 161) 'e': (i32, &str)
27[163; 166) '"d"': &str 31[163; 166) '"d"': &str
32
diff --git a/crates/ra_hir/src/ty/tests/data/unary_op.txt b/crates/ra_hir/src/ty/snapshots/tests__infer_unary_op.snap
index 203022e82..8906bb9c0 100644
--- a/crates/ra_hir/src/ty/tests/data/unary_op.txt
+++ b/crates/ra_hir/src/ty/snapshots/tests__infer_unary_op.snap
@@ -1,3 +1,7 @@
1Created: 2019-01-21T21:48:20.676213204+00:00
2Creator: [email protected]
3Source: crates/ra_hir/src/ty/tests.rs
4
1[27; 28) 'x': SomeType 5[27; 28) 'x': SomeType
2[40; 197) '{ ...lo"; }': () 6[40; 197) '{ ...lo"; }': ()
3[50; 51) 'b': bool 7[50; 51) 'b': bool
@@ -26,3 +30,4 @@
26[179; 180) 'x': SomeType 30[179; 180) 'x': SomeType
27[186; 194) '-"hello"': [unknown] 31[186; 194) '-"hello"': [unknown]
28[187; 194) '"hello"': &str 32[187; 194) '"hello"': &str
33
diff --git a/crates/ra_hir/src/ty/snapshots/tests__no_panic_on_field_of_enum.snap b/crates/ra_hir/src/ty/snapshots/tests__no_panic_on_field_of_enum.snap
new file mode 100644
index 000000000..024fbf929
--- /dev/null
+++ b/crates/ra_hir/src/ty/snapshots/tests__no_panic_on_field_of_enum.snap
@@ -0,0 +1,9 @@
1Created: 2019-01-21T21:48:20.676654355+00:00
2Creator: [email protected]
3Source: crates/ra_hir/src/ty/tests.rs
4
5[20; 21) 'x': X
6[26; 47) '{ ...eld; }': ()
7[32; 33) 'x': X
8[32; 44) 'x.some_field': [unknown]
9
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs
index dc9b626dc..9bf1fd3b2 100644
--- a/crates/ra_hir/src/ty/tests.rs
+++ b/crates/ra_hir/src/ty/tests.rs
@@ -1,11 +1,8 @@
1use std::sync::Arc; 1use std::sync::Arc;
2use std::fmt::Write; 2use std::fmt::Write;
3use std::path::{PathBuf, Path};
4use std::fs;
5 3
6use ra_db::{SyntaxDatabase, salsa::Database}; 4use ra_db::{SyntaxDatabase, salsa::Database};
7use ra_syntax::ast::{self, AstNode}; 5use ra_syntax::ast::{self, AstNode};
8use test_utils::{project_dir, assert_eq_text, read_text};
9 6
10use crate::{ 7use crate::{
11 source_binder, 8 source_binder,
@@ -13,14 +10,13 @@ use crate::{
13}; 10};
14 11
15// These tests compare the inference results for all expressions in a file 12// These tests compare the inference results for all expressions in a file
16// against snapshots of the expected results. If you change something and these 13// against snapshots of the expected results using insta. Run the tests with
17// tests fail expectedly, you can update the comparison files by deleting them 14// INSTA_UPDATE=1 to update the snapshots.
18// and running the tests again. Similarly, to add a new test, just write the
19// test here in the same pattern and it will automatically write the snapshot.
20 15
21#[test] 16#[test]
22fn infer_basics() { 17fn infer_basics() {
23 check_inference( 18 check_inference(
19 "infer_basics",
24 r#" 20 r#"
25fn test(a: u32, b: isize, c: !, d: &str) { 21fn test(a: u32, b: isize, c: !, d: &str) {
26 a; 22 a;
@@ -32,13 +28,13 @@ fn test(a: u32, b: isize, c: !, d: &str) {
32 "test"; 28 "test";
33 1.0f32; 29 1.0f32;
34}"#, 30}"#,
35 "basics.txt",
36 ); 31 );
37} 32}
38 33
39#[test] 34#[test]
40fn infer_let() { 35fn infer_let() {
41 check_inference( 36 check_inference(
37 "infer_let",
42 r#" 38 r#"
43fn test() { 39fn test() {
44 let a = 1isize; 40 let a = 1isize;
@@ -46,13 +42,13 @@ fn test() {
46 let c = b; 42 let c = b;
47} 43}
48}"#, 44}"#,
49 "let.txt",
50 ); 45 );
51} 46}
52 47
53#[test] 48#[test]
54fn infer_paths() { 49fn infer_paths() {
55 check_inference( 50 check_inference(
51 "infer_paths",
56 r#" 52 r#"
57fn a() -> u32 { 1 } 53fn a() -> u32 { 1 }
58 54
@@ -65,13 +61,13 @@ fn test() {
65 b::c(); 61 b::c();
66} 62}
67}"#, 63}"#,
68 "paths.txt",
69 ); 64 );
70} 65}
71 66
72#[test] 67#[test]
73fn infer_struct() { 68fn infer_struct() {
74 check_inference( 69 check_inference(
70 "infer_struct",
75 r#" 71 r#"
76struct A { 72struct A {
77 b: B, 73 b: B,
@@ -88,13 +84,13 @@ fn test() {
88 a.c; 84 a.c;
89} 85}
90"#, 86"#,
91 "struct.txt",
92 ); 87 );
93} 88}
94 89
95#[test] 90#[test]
96fn infer_enum() { 91fn infer_enum() {
97 check_inference( 92 check_inference(
93 "infer_enum",
98 r#" 94 r#"
99enum E { 95enum E {
100 V1 { field: u32 }, 96 V1 { field: u32 },
@@ -104,13 +100,13 @@ fn test() {
104 E::V1 { field: 1 }; 100 E::V1 { field: 1 };
105 E::V2; 101 E::V2;
106}"#, 102}"#,
107 "enum.txt",
108 ); 103 );
109} 104}
110 105
111#[test] 106#[test]
112fn infer_refs() { 107fn infer_refs() {
113 check_inference( 108 check_inference(
109 "infer_refs",
114 r#" 110 r#"
115fn test(a: &u32, b: &mut u32, c: *const u32, d: *mut u32) { 111fn test(a: &u32, b: &mut u32, c: *const u32, d: *mut u32) {
116 a; 112 a;
@@ -126,13 +122,13 @@ fn test(a: &u32, b: &mut u32, c: *const u32, d: *mut u32) {
126 *d; 122 *d;
127} 123}
128"#, 124"#,
129 "refs_and_ptrs.txt",
130 ); 125 );
131} 126}
132 127
133#[test] 128#[test]
134fn infer_literals() { 129fn infer_literals() {
135 check_inference( 130 check_inference(
131 "infer_literals",
136 r##" 132 r##"
137fn test() { 133fn test() {
138 5i32; 134 5i32;
@@ -152,13 +148,13 @@ fn test() {
152 br#"yolo"#; 148 br#"yolo"#;
153} 149}
154"##, 150"##,
155 "literals.txt",
156 ); 151 );
157} 152}
158 153
159#[test] 154#[test]
160fn infer_unary_op() { 155fn infer_unary_op() {
161 check_inference( 156 check_inference(
157 "infer_unary_op",
162 r#" 158 r#"
163enum SomeType {} 159enum SomeType {}
164 160
@@ -175,13 +171,13 @@ fn test(x: SomeType) {
175 -"hello"; 171 -"hello";
176} 172}
177"#, 173"#,
178 "unary_op.txt",
179 ); 174 );
180} 175}
181 176
182#[test] 177#[test]
183fn infer_backwards() { 178fn infer_backwards() {
184 check_inference( 179 check_inference(
180 "infer_backwards",
185 r#" 181 r#"
186fn takes_u32(x: u32) {} 182fn takes_u32(x: u32) {}
187 183
@@ -196,13 +192,13 @@ fn test() -> &mut &f64 {
196 &mut &c 192 &mut &c
197} 193}
198"#, 194"#,
199 "backwards.txt",
200 ); 195 );
201} 196}
202 197
203#[test] 198#[test]
204fn infer_self() { 199fn infer_self() {
205 check_inference( 200 check_inference(
201 "infer_self",
206 r#" 202 r#"
207struct S; 203struct S;
208 204
@@ -215,13 +211,13 @@ impl S {
215 } 211 }
216} 212}
217"#, 213"#,
218 "self.txt",
219 ); 214 );
220} 215}
221 216
222#[test] 217#[test]
223fn infer_binary_op() { 218fn infer_binary_op() {
224 check_inference( 219 check_inference(
220 "infer_binary_op",
225 r#" 221 r#"
226fn f(x: bool) -> i32 { 222fn f(x: bool) -> i32 {
227 0i32 223 0i32
@@ -242,13 +238,13 @@ fn test() -> bool {
242 ten < 3 238 ten < 3
243} 239}
244"#, 240"#,
245 "binary_op.txt",
246 ); 241 );
247} 242}
248 243
249#[test] 244#[test]
250fn infer_field_autoderef() { 245fn infer_field_autoderef() {
251 check_inference( 246 check_inference(
247 "infer_field_autoderef",
252 r#" 248 r#"
253struct A { 249struct A {
254 b: B, 250 b: B,
@@ -273,25 +269,25 @@ fn test2(a1: *const A, a2: *mut A) {
273 a2.b; 269 a2.b;
274} 270}
275"#, 271"#,
276 "field_autoderef.txt",
277 ); 272 );
278} 273}
279 274
280#[test] 275#[test]
281fn infer_bug_484() { 276fn bug_484() {
282 check_inference( 277 check_inference(
278 "bug_484",
283 r#" 279 r#"
284fn test() { 280fn test() {
285 let x = if true {}; 281 let x = if true {};
286} 282}
287"#, 283"#,
288 "bug_484.txt",
289 ); 284 );
290} 285}
291 286
292#[test] 287#[test]
293fn infer_inherent_method() { 288fn infer_inherent_method() {
294 check_inference( 289 check_inference(
290 "infer_inherent_method",
295 r#" 291 r#"
296struct A; 292struct A;
297 293
@@ -311,13 +307,13 @@ fn test(a: A) {
311 a.bar(1); 307 a.bar(1);
312} 308}
313"#, 309"#,
314 "inherent_method.txt",
315 ); 310 );
316} 311}
317 312
318#[test] 313#[test]
319fn infer_tuple() { 314fn infer_tuple() {
320 check_inference( 315 check_inference(
316 "infer_tuple",
321 r#" 317 r#"
322fn test(x: &str, y: isize) { 318fn test(x: &str, y: isize) {
323 let a: (u32, &str) = (1, "a"); 319 let a: (u32, &str) = (1, "a");
@@ -328,13 +324,13 @@ fn test(x: &str, y: isize) {
328 let f = (e, "d"); 324 let f = (e, "d");
329} 325}
330"#, 326"#,
331 "tuple.txt",
332 ); 327 );
333} 328}
334 329
335#[test] 330#[test]
336fn infer_array() { 331fn infer_array() {
337 check_inference( 332 check_inference(
333 "infer_array",
338 r#" 334 r#"
339fn test(x: &str, y: isize) { 335fn test(x: &str, y: isize) {
340 let a = [x]; 336 let a = [x];
@@ -354,13 +350,13 @@ fn test(x: &str, y: isize) {
354 let x: [u8; 0] = []; 350 let x: [u8; 0] = [];
355} 351}
356"#, 352"#,
357 "array.txt",
358 ); 353 );
359} 354}
360 355
361#[test] 356#[test]
362fn infer_pattern() { 357fn infer_pattern() {
363 check_inference( 358 check_inference(
359 "infer_pattern",
364 r#" 360 r#"
365fn test(x: &i32) { 361fn test(x: &i32) {
366 let y = x; 362 let y = x;
@@ -384,13 +380,13 @@ fn test(x: &i32) {
384 let k = mut_ref_to_x; 380 let k = mut_ref_to_x;
385} 381}
386"#, 382"#,
387 "pattern.txt",
388 ); 383 );
389} 384}
390 385
391#[test] 386#[test]
392fn infer_adt_pattern() { 387fn infer_adt_pattern() {
393 check_inference( 388 check_inference(
389 "infer_adt_pattern",
394 r#" 390 r#"
395enum E { 391enum E {
396 A { x: usize }, 392 A { x: usize },
@@ -414,13 +410,13 @@ fn test() {
414 d; 410 d;
415} 411}
416"#, 412"#,
417 "adt_pattern.txt",
418 ); 413 );
419} 414}
420 415
421#[test] 416#[test]
422fn infer_struct_generics() { 417fn infer_struct_generics() {
423 check_inference( 418 check_inference(
419 "infer_struct_generics",
424 r#" 420 r#"
425struct A<T> { 421struct A<T> {
426 x: T, 422 x: T,
@@ -434,13 +430,13 @@ fn test(a1: A<u32>, i: i32) {
434 a3.x; 430 a3.x;
435} 431}
436"#, 432"#,
437 "struct_generics.txt",
438 ); 433 );
439} 434}
440 435
441#[test] 436#[test]
442fn infer_generics_in_patterns() { 437fn infer_generics_in_patterns() {
443 check_inference( 438 check_inference(
439 "infer_generics_in_patterns",
444 r#" 440 r#"
445struct A<T> { 441struct A<T> {
446 x: T, 442 x: T,
@@ -460,13 +456,13 @@ fn test(a1: A<u32>, o: Option<u64>) {
460 }; 456 };
461} 457}
462"#, 458"#,
463 "generics_in_patterns.txt",
464 ); 459 );
465} 460}
466 461
467#[test] 462#[test]
468fn infer_function_generics() { 463fn infer_function_generics() {
469 check_inference( 464 check_inference(
465 "infer_function_generics",
470 r#" 466 r#"
471fn id<T>(t: T) -> T { t } 467fn id<T>(t: T) -> T { t }
472 468
@@ -476,13 +472,13 @@ fn test() {
476 let x: u64 = id(1); 472 let x: u64 = id(1);
477} 473}
478"#, 474"#,
479 "function_generics.txt",
480 ); 475 );
481} 476}
482 477
483#[test] 478#[test]
484fn infer_generic_chain() { 479fn infer_generic_chain() {
485 check_inference( 480 check_inference(
481 "infer_generic_chain",
486 r#" 482 r#"
487struct A<T> { 483struct A<T> {
488 x: T, 484 x: T,
@@ -503,13 +499,13 @@ fn test() -> i128 {
503 b.x() 499 b.x()
504} 500}
505"#, 501"#,
506 "generic_chain.txt",
507 ); 502 );
508} 503}
509 504
510#[test] 505#[test]
511fn no_panic_on_field_of_enum() { 506fn no_panic_on_field_of_enum() {
512 check_inference( 507 check_inference(
508 "no_panic_on_field_of_enum",
513 r#" 509 r#"
514enum X {} 510enum X {}
515 511
@@ -517,13 +513,13 @@ fn test(x: X) {
517 x.some_field; 513 x.some_field;
518} 514}
519"#, 515"#,
520 "no_panic_on_field_of_enum.txt",
521 ); 516 );
522} 517}
523 518
524#[test] 519#[test]
525fn bug_585() { 520fn bug_585() {
526 check_inference( 521 check_inference(
522 "bug_585",
527 r#" 523 r#"
528fn test() { 524fn test() {
529 X {}; 525 X {};
@@ -533,7 +529,6 @@ fn test() {
533 } 529 }
534} 530}
535"#, 531"#,
536 "bug_585.txt",
537 ); 532 );
538} 533}
539 534
@@ -581,19 +576,10 @@ fn infer(content: &str) -> String {
581 acc 576 acc
582} 577}
583 578
584fn check_inference(content: &str, data_file: impl AsRef<Path>) { 579fn check_inference(name: &str, content: &str) {
585 let data_file_path = test_data_dir().join(data_file);
586 let result = infer(content); 580 let result = infer(content);
587 581
588 if !data_file_path.exists() { 582 insta::assert_snapshot_matches!(&name, &result);
589 println!("File with expected result doesn't exist, creating...\n");
590 println!("{}\n{}", content, result);
591 fs::write(&data_file_path, &result).unwrap();
592 panic!("File {:?} with expected result was created", data_file_path);
593 }
594
595 let expected = read_text(&data_file_path);
596 assert_eq_text!(&expected, &result);
597} 583}
598 584
599fn ellipsize(mut text: String, max_len: usize) -> String { 585fn ellipsize(mut text: String, max_len: usize) -> String {
@@ -614,10 +600,6 @@ fn ellipsize(mut text: String, max_len: usize) -> String {
614 text 600 text
615} 601}
616 602
617fn test_data_dir() -> PathBuf {
618 project_dir().join("crates/ra_hir/src/ty/tests/data")
619}
620
621#[test] 603#[test]
622fn typing_whitespace_inside_a_function_should_not_invalidate_types() { 604fn typing_whitespace_inside_a_function_should_not_invalidate_types() {
623 let (mut db, pos) = MockDatabase::with_position( 605 let (mut db, pos) = MockDatabase::with_position(
diff --git a/crates/ra_hir/src/ty/tests/data/enum.txt b/crates/ra_hir/src/ty/tests/data/enum.txt
deleted file mode 100644
index 481eb0bc7..000000000
--- a/crates/ra_hir/src/ty/tests/data/enum.txt
+++ /dev/null
@@ -1,4 +0,0 @@
1[48; 82) '{ E:...:V2; }': ()
2[52; 70) 'E::V1 ...d: 1 }': E
3[67; 68) '1': u32
4[74; 79) 'E::V2': E
diff --git a/crates/ra_hir/src/ty/tests/data/no_panic_on_field_of_enum.txt b/crates/ra_hir/src/ty/tests/data/no_panic_on_field_of_enum.txt
deleted file mode 100644
index 4dca0b7f4..000000000
--- a/crates/ra_hir/src/ty/tests/data/no_panic_on_field_of_enum.txt
+++ /dev/null
@@ -1,4 +0,0 @@
1[20; 21) 'x': X
2[26; 47) '{ ...eld; }': ()
3[32; 33) 'x': X
4[32; 44) 'x.some_field': [unknown]