aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_hir/src/ty.rs2
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__bug_484.snap12
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__bug_585.snap15
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__bug_651.snap13
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_adt_pattern.snap32
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_array.snap65
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_associated_const.snap14
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_associated_method_enum.snap20
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_associated_method_generics.snap16
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_associated_method_struct.snap16
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_associated_method_with_modules.snap23
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_backwards.snap27
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_basics.snap20
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_binary_op.snap57
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_const.snap14
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_enum.snap11
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_field_autoderef.snap50
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_function_generics.snap21
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_generic_chain.snap36
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_generics_in_patterns.snap24
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_impl_generics.snap39
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_impl_generics_with_autoderef.snap16
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_in_elseif.snap17
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_inherent_method.snap25
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_let.snap14
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_literals.snap19
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_nested_generics_crash.snap12
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_paths.snap16
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_pattern.snap54
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_refs.snap30
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_self.snap17
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_static.snap16
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_std_crash_1.snap13
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_std_crash_2.snap14
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_std_crash_3.snap13
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_std_crash_4.snap16
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_std_crash_5.snap30
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_struct.snap23
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_struct_generics.snap22
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_tuple.snap34
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_tuple_struct_generics.snap23
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_type_alias.snap23
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_type_param.snap26
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_unary_op.snap48
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__no_panic_on_field_of_enum.snap11
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__recursive_vars.snap14
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__recursive_vars_2.snap21
-rw-r--r--crates/ra_hir/src/ty/tests.rs1479
-rw-r--r--crates/ra_ide_api/src/hover.rs2
-rw-r--r--editors/emacs/ra-emacs-lsp.el2
50 files changed, 1286 insertions, 1291 deletions
diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs
index 78270a9b7..bad811a56 100644
--- a/crates/ra_hir/src/ty.rs
+++ b/crates/ra_hir/src/ty.rs
@@ -339,7 +339,7 @@ impl fmt::Display for Ty {
339 Ok(()) 339 Ok(())
340 } 340 }
341 Ty::Param { name, .. } => write!(f, "{}", name), 341 Ty::Param { name, .. } => write!(f, "{}", name),
342 Ty::Unknown => write!(f, "[unknown]"), 342 Ty::Unknown => write!(f, "{{unknown}}"),
343 Ty::Infer(..) => write!(f, "_"), 343 Ty::Infer(..) => write!(f, "_"),
344 } 344 }
345 } 345 }
diff --git a/crates/ra_hir/src/ty/snapshots/tests__bug_484.snap b/crates/ra_hir/src/ty/snapshots/tests__bug_484.snap
deleted file mode 100644
index 28f57623d..000000000
--- a/crates/ra_hir/src/ty/snapshots/tests__bug_484.snap
+++ /dev/null
@@ -1,12 +0,0 @@
1---
2created: "2019-01-22T14:44:59.880187500+00:00"
3creator: [email protected]
4expression: "&result"
5source: "crates\\ra_hir\\src\\ty\\tests.rs"
6---
7[11; 37) '{ l... {}; }': ()
8[20; 21) 'x': ()
9[24; 34) 'if true {}': ()
10[27; 31) 'true': bool
11[32; 34) '{}': ()
12
diff --git a/crates/ra_hir/src/ty/snapshots/tests__bug_585.snap b/crates/ra_hir/src/ty/snapshots/tests__bug_585.snap
deleted file mode 100644
index e7b42e413..000000000
--- a/crates/ra_hir/src/ty/snapshots/tests__bug_585.snap
+++ /dev/null
@@ -1,15 +0,0 @@
1---
2created: "2019-01-22T14:44:59.880187500+00:00"
3creator: [email protected]
4expression: "&result"
5source: "crates\\ra_hir\\src\\ty\\tests.rs"
6---
7[11; 89) '{ ... } }': ()
8[17; 21) 'X {}': [unknown]
9[27; 87) 'match ... }': ()
10[33; 34) 'x': [unknown]
11[45; 52) 'A::B {}': [unknown]
12[56; 58) '()': ()
13[68; 74) 'A::Y()': [unknown]
14[78; 80) '()': ()
15
diff --git a/crates/ra_hir/src/ty/snapshots/tests__bug_651.snap b/crates/ra_hir/src/ty/snapshots/tests__bug_651.snap
deleted file mode 100644
index d23d3f139..000000000
--- a/crates/ra_hir/src/ty/snapshots/tests__bug_651.snap
+++ /dev/null
@@ -1,13 +0,0 @@
1---
2created: "2019-01-25T20:31:47.275112244+00:00"
3creator: [email protected]
4expression: "&result"
5source: crates/ra_hir/src/ty/tests.rs
6---
7[11; 41) '{ ...+ y; }': ()
8[21; 22) 'y': i32
9[25; 27) '92': i32
10[33; 34) '1': i32
11[33; 38) '1 + y': i32
12[37; 38) 'y': i32
13
diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_adt_pattern.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_adt_pattern.snap
deleted file mode 100644
index 48c83cbb2..000000000
--- a/crates/ra_hir/src/ty/snapshots/tests__infer_adt_pattern.snap
+++ /dev/null
@@ -1,32 +0,0 @@
1---
2created: "2019-01-28T21:58:55.559331849+00:00"
3creator: [email protected]
4expression: "&result"
5source: crates/ra_hir/src/ty/tests.rs
6---
7[68; 289) '{ ... d; }': ()
8[78; 79) 'e': E
9[82; 95) 'E::A { x: 3 }': E
10[92; 93) '3': usize
11[106; 113) 'S(y, z)': S
12[108; 109) 'y': u32
13[111; 112) 'z': E
14[116; 119) 'foo': S
15[129; 148) 'E::A {..._var }': E
16[139; 146) 'new_var': usize
17[151; 152) 'e': E
18[159; 245) 'match ... }': usize
19[165; 166) 'e': E
20[177; 187) 'E::A { x }': E
21[184; 185) 'x': usize
22[191; 192) 'x': usize
23[202; 206) 'E::B': E
24[210; 213) 'foo': bool
25[217; 218) '1': usize
26[228; 232) 'E::B': E
27[236; 238) '10': usize
28[256; 275) 'ref d ...{ .. }': &E
29[264; 275) 'E::A { .. }': E
30[278; 279) 'e': E
31[285; 286) 'd': &E
32
diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_array.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_array.snap
deleted file mode 100644
index 042248c35..000000000
--- a/crates/ra_hir/src/ty/snapshots/tests__infer_array.snap
+++ /dev/null
@@ -1,65 +0,0 @@
1---
2created: "2019-01-30T20:08:05.185312835+00:00"
3creator: [email protected]
4expression: "&result"
5source: crates/ra_hir/src/ty/tests.rs
6---
7[9; 10) 'x': &str
8[18; 19) 'y': isize
9[28; 324) '{ ... 3]; }': ()
10[38; 39) 'a': [&str]
11[42; 45) '[x]': [&str]
12[43; 44) 'x': &str
13[55; 56) 'b': [[&str]]
14[59; 65) '[a, a]': [[&str]]
15[60; 61) 'a': [&str]
16[63; 64) 'a': [&str]
17[75; 76) 'c': [[[&str]]]
18[79; 85) '[b, b]': [[[&str]]]
19[80; 81) 'b': [[&str]]
20[83; 84) 'b': [[&str]]
21[96; 97) 'd': [isize]
22[100; 112) '[y, 1, 2, 3]': [isize]
23[101; 102) 'y': isize
24[104; 105) '1': isize
25[107; 108) '2': isize
26[110; 111) '3': isize
27[122; 123) 'd': [isize]
28[126; 138) '[1, y, 2, 3]': [isize]
29[127; 128) '1': isize
30[130; 131) 'y': isize
31[133; 134) '2': isize
32[136; 137) '3': isize
33[148; 149) 'e': [isize]
34[152; 155) '[y]': [isize]
35[153; 154) 'y': isize
36[165; 166) 'f': [[isize]]
37[169; 175) '[d, d]': [[isize]]
38[170; 171) 'd': [isize]
39[173; 174) 'd': [isize]
40[185; 186) 'g': [[isize]]
41[189; 195) '[e, e]': [[isize]]
42[190; 191) 'e': [isize]
43[193; 194) 'e': [isize]
44[206; 207) 'h': [i32]
45[210; 216) '[1, 2]': [i32]
46[211; 212) '1': i32
47[214; 215) '2': i32
48[226; 227) 'i': [&str]
49[230; 240) '["a", "b"]': [&str]
50[231; 234) '"a"': &str
51[236; 239) '"b"': &str
52[251; 252) 'b': [[&str]]
53[255; 265) '[a, ["b"]]': [[&str]]
54[256; 257) 'a': [&str]
55[259; 264) '["b"]': [&str]
56[260; 263) '"b"': &str
57[275; 276) 'x': [u8]
58[288; 290) '[]': [u8]
59[300; 301) 'z': &[u8]
60[311; 321) '&[1, 2, 3]': &[u8]
61[312; 321) '[1, 2, 3]': [u8]
62[313; 314) '1': u8
63[316; 317) '2': u8
64[319; 320) '3': u8
65
diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_associated_const.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_associated_const.snap
deleted file mode 100644
index 51f3fd4c0..000000000
--- a/crates/ra_hir/src/ty/snapshots/tests__infer_associated_const.snap
+++ /dev/null
@@ -1,14 +0,0 @@
1---
2created: "2019-02-25T08:36:33.885804400Z"
3creator: [email protected]
4source: crates/ra_hir/src/ty/tests.rs
5expression: "&result"
6---
7[227; 305) '{ ...:ID; }': ()
8[237; 238) 'x': u32
9[241; 252) 'Struct::FOO': u32
10[262; 263) 'y': u32
11[266; 275) 'Enum::BAR': u32
12[285; 286) 'z': u32
13[289; 302) 'TraitTest::ID': u32
14
diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_associated_method_enum.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_associated_method_enum.snap
deleted file mode 100644
index 8f27af88c..000000000
--- a/crates/ra_hir/src/ty/snapshots/tests__infer_associated_method_enum.snap
+++ /dev/null
@@ -1,20 +0,0 @@
1---
2created: "2019-02-20T11:04:56.553382800Z"
3creator: [email protected]
4source: crates/ra_hir/src/ty/tests.rs
5expression: "&result"
6---
7[48; 68) '{ ... }': A
8[58; 62) 'A::B': A
9[89; 109) '{ ... }': A
10[99; 103) 'A::C': A
11[122; 179) '{ ... c; }': ()
12[132; 133) 'a': A
13[136; 140) 'A::b': fn b() -> A
14[136; 142) 'A::b()': A
15[148; 149) 'a': A
16[159; 160) 'c': A
17[163; 167) 'A::c': fn c() -> A
18[163; 169) 'A::c()': A
19[175; 176) 'c': A
20
diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_associated_method_generics.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_associated_method_generics.snap
deleted file mode 100644
index 44694dfdb..000000000
--- a/crates/ra_hir/src/ty/snapshots/tests__infer_associated_method_generics.snap
+++ /dev/null
@@ -1,16 +0,0 @@
1---
2created: "2019-02-23T21:58:35.844769207Z"
3creator: [email protected]
4source: crates/ra_hir/src/ty/tests.rs
5expression: "&result"
6---
7[64; 67) 'val': T
8[82; 109) '{ ... }': Gen<T>
9[92; 103) 'Gen { val }': Gen<T>
10[98; 101) 'val': T
11[123; 155) '{ ...32); }': ()
12[133; 134) 'a': Gen<u32>
13[137; 146) 'Gen::make': fn make<u32>(T) -> Gen<T>
14[137; 152) 'Gen::make(0u32)': Gen<u32>
15[147; 151) '0u32': u32
16
diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_associated_method_struct.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_associated_method_struct.snap
deleted file mode 100644
index 29ca9b0ea..000000000
--- a/crates/ra_hir/src/ty/snapshots/tests__infer_associated_method_struct.snap
+++ /dev/null
@@ -1,16 +0,0 @@
1---
2created: "2019-02-20T11:04:56.553382800Z"
3creator: [email protected]
4source: crates/ra_hir/src/ty/tests.rs
5expression: "&result"
6---
7[50; 76) '{ ... }': A
8[60; 70) 'A { x: 0 }': A
9[67; 68) '0': u32
10[89; 123) '{ ...a.x; }': ()
11[99; 100) 'a': A
12[103; 109) 'A::new': fn new() -> A
13[103; 111) 'A::new()': A
14[117; 118) 'a': A
15[117; 120) 'a.x': u32
16
diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_associated_method_with_modules.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_associated_method_with_modules.snap
deleted file mode 100644
index 6584bef39..000000000
--- a/crates/ra_hir/src/ty/snapshots/tests__infer_associated_method_with_modules.snap
+++ /dev/null
@@ -1,23 +0,0 @@
1---
2created: "2019-02-21T08:55:53.926725400Z"
3creator: [email protected]
4source: crates/ra_hir/src/ty/tests.rs
5expression: "&result"
6---
7[56; 64) '{ A {} }': A
8[58; 62) 'A {}': A
9[126; 132) '{ 99 }': u32
10[128; 130) '99': u32
11[202; 210) '{ C {} }': C
12[204; 208) 'C {}': C
13[241; 325) '{ ...g(); }': ()
14[251; 252) 'x': A
15[255; 266) 'a::A::thing': fn thing() -> A
16[255; 268) 'a::A::thing()': A
17[278; 279) 'y': u32
18[282; 293) 'b::B::thing': fn thing() -> u32
19[282; 295) 'b::B::thing()': u32
20[305; 306) 'z': C
21[309; 320) 'c::C::thing': fn thing() -> C
22[309; 322) 'c::C::thing()': C
23
diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_backwards.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_backwards.snap
deleted file mode 100644
index f5840a934..000000000
--- a/crates/ra_hir/src/ty/snapshots/tests__infer_backwards.snap
+++ /dev/null
@@ -1,27 +0,0 @@
1---
2created: "2019-01-26T17:46:03.842478456+00:00"
3creator: [email protected]
4expression: "&result"
5source: crates/ra_hir/src/ty/tests.rs
6---
7[14; 15) 'x': u32
8[22; 24) '{}': ()
9[78; 231) '{ ...t &c }': &mut &f64
10[88; 89) 'a': u32
11[92; 108) 'unknow...nction': [unknown]
12[92; 110) 'unknow...tion()': u32
13[116; 125) 'takes_u32': fn takes_u32(u32) -> ()
14[116; 128) 'takes_u32(a)': ()
15[126; 127) 'a': u32
16[138; 139) 'b': i32
17[142; 158) 'unknow...nction': [unknown]
18[142; 160) 'unknow...tion()': i32
19[166; 184) 'S { i3...d: b }': S
20[181; 182) 'b': i32
21[194; 195) 'c': f64
22[198; 214) 'unknow...nction': [unknown]
23[198; 216) 'unknow...tion()': f64
24[222; 229) '&mut &c': &mut &f64
25[227; 229) '&c': &f64
26[228; 229) 'c': f64
27
diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_basics.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_basics.snap
deleted file mode 100644
index 4b0863558..000000000
--- a/crates/ra_hir/src/ty/snapshots/tests__infer_basics.snap
+++ /dev/null
@@ -1,20 +0,0 @@
1---
2created: "2019-01-22T14:44:59.880187500+00:00"
3creator: [email protected]
4expression: "&result"
5source: "crates\\ra_hir\\src\\ty\\tests.rs"
6---
7[9; 10) 'a': u32
8[17; 18) 'b': isize
9[27; 28) 'c': !
10[33; 34) 'd': &str
11[42; 121) '{ ...f32; }': ()
12[48; 49) 'a': u32
13[55; 56) 'b': isize
14[62; 63) 'c': !
15[69; 70) 'd': &str
16[76; 82) '1usize': usize
17[88; 94) '1isize': isize
18[100; 106) '"test"': &str
19[112; 118) '1.0f32': f32
20
diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_binary_op.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_binary_op.snap
deleted file mode 100644
index 80ffe6e11..000000000
--- a/crates/ra_hir/src/ty/snapshots/tests__infer_binary_op.snap
+++ /dev/null
@@ -1,57 +0,0 @@
1---
2created: "2019-02-18T07:03:52.524808301Z"
3creator: [email protected]
4source: crates/ra_hir/src/ty/tests.rs
5expression: "&result"
6---
7[6; 7) 'x': bool
8[22; 34) '{ 0i32 }': i32
9[28; 32) '0i32': i32
10[54; 370) '{ ... < 3 }': bool
11[64; 65) 'x': bool
12[68; 69) 'a': bool
13[68; 74) 'a && b': bool
14[73; 74) 'b': bool
15[84; 85) 'y': bool
16[88; 92) 'true': bool
17[88; 101) 'true || false': bool
18[96; 101) 'false': bool
19[111; 112) 'z': bool
20[115; 116) 'x': bool
21[115; 121) 'x == y': bool
22[120; 121) 'y': bool
23[131; 132) 't': bool
24[135; 136) 'x': bool
25[135; 141) 'x != y': bool
26[140; 141) 'y': bool
27[151; 162) 'minus_forty': isize
28[172; 180) '-40isize': isize
29[173; 180) '40isize': isize
30[190; 191) 'h': bool
31[194; 205) 'minus_forty': isize
32[194; 216) 'minus_...ONST_2': bool
33[209; 216) 'CONST_2': isize
34[226; 227) 'c': i32
35[230; 231) 'f': fn f(bool) -> i32
36[230; 239) 'f(z || y)': i32
37[230; 243) 'f(z || y) + 5': i32
38[232; 233) 'z': bool
39[232; 238) 'z || y': bool
40[237; 238) 'y': bool
41[242; 243) '5': i32
42[253; 254) 'd': [unknown]
43[257; 258) 'b': [unknown]
44[268; 269) 'g': ()
45[272; 283) 'minus_forty': isize
46[272; 288) 'minus_...y ^= i': ()
47[287; 288) 'i': isize
48[298; 301) 'ten': usize
49[311; 313) '10': usize
50[323; 336) 'ten_is_eleven': bool
51[339; 342) 'ten': usize
52[339; 354) 'ten == some_num': bool
53[346; 354) 'some_num': usize
54[361; 364) 'ten': usize
55[361; 368) 'ten < 3': bool
56[367; 368) '3': usize
57
diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_const.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_const.snap
deleted file mode 100644
index a5eba3980..000000000
--- a/crates/ra_hir/src/ty/snapshots/tests__infer_const.snap
+++ /dev/null
@@ -1,14 +0,0 @@
1---
2created: "2019-02-25T07:26:34.115351100Z"
3creator: [email protected]
4source: crates/ra_hir/src/ty/tests.rs
5expression: "&result"
6---
7[95; 213) '{ ...NST; }': ()
8[138; 139) 'x': [unknown]
9[142; 153) 'LOCAL_CONST': [unknown]
10[163; 164) 'z': u32
11[167; 179) 'GLOBAL_CONST': u32
12[189; 191) 'id': u32
13[194; 210) 'Foo::A..._CONST': u32
14
diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_enum.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_enum.snap
deleted file mode 100644
index bc8b84272..000000000
--- a/crates/ra_hir/src/ty/snapshots/tests__infer_enum.snap
+++ /dev/null
@@ -1,11 +0,0 @@
1---
2created: "2019-01-22T14:44:59.880187500+00:00"
3creator: [email protected]
4expression: "&result"
5source: "crates\\ra_hir\\src\\ty\\tests.rs"
6---
7[48; 82) '{ E:...:V2; }': ()
8[52; 70) 'E::V1 ...d: 1 }': E
9[67; 68) '1': u32
10[74; 79) 'E::V2': E
11
diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_field_autoderef.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_field_autoderef.snap
deleted file mode 100644
index f092fd319..000000000
--- a/crates/ra_hir/src/ty/snapshots/tests__infer_field_autoderef.snap
+++ /dev/null
@@ -1,50 +0,0 @@
1---
2created: "2019-01-22T14:44:59.955954900+00:00"
3creator: [email protected]
4expression: "&result"
5source: "crates\\ra_hir\\src\\ty\\tests.rs"
6---
7[44; 45) 'a': A
8[50; 213) '{ ...5.b; }': ()
9[60; 62) 'a1': A
10[65; 66) 'a': A
11[72; 74) 'a1': A
12[72; 76) 'a1.b': B
13[86; 88) 'a2': &A
14[91; 93) '&a': &A
15[92; 93) 'a': A
16[99; 101) 'a2': &A
17[99; 103) 'a2.b': B
18[113; 115) 'a3': &mut A
19[118; 124) '&mut a': &mut A
20[123; 124) 'a': A
21[130; 132) 'a3': &mut A
22[130; 134) 'a3.b': B
23[144; 146) 'a4': &&&&&&&A
24[149; 157) '&&&&&&&a': &&&&&&&A
25[150; 157) '&&&&&&a': &&&&&&A
26[151; 157) '&&&&&a': &&&&&A
27[152; 157) '&&&&a': &&&&A
28[153; 157) '&&&a': &&&A
29[154; 157) '&&a': &&A
30[155; 157) '&a': &A
31[156; 157) 'a': A
32[163; 165) 'a4': &&&&&&&A
33[163; 167) 'a4.b': B
34[177; 179) 'a5': &mut &&mut &&mut A
35[182; 200) '&mut &...&mut a': &mut &&mut &&mut A
36[187; 200) '&&mut &&mut a': &&mut &&mut A
37[188; 200) '&mut &&mut a': &mut &&mut A
38[193; 200) '&&mut a': &&mut A
39[194; 200) '&mut a': &mut A
40[199; 200) 'a': A
41[206; 208) 'a5': &mut &&mut &&mut A
42[206; 210) 'a5.b': B
43[224; 226) 'a1': *const A
44[238; 240) 'a2': *mut A
45[250; 273) '{ ...2.b; }': ()
46[256; 258) 'a1': *const A
47[256; 260) 'a1.b': B
48[266; 268) 'a2': *mut A
49[266; 270) 'a2.b': B
50
diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_function_generics.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_function_generics.snap
deleted file mode 100644
index 91c48897c..000000000
--- a/crates/ra_hir/src/ty/snapshots/tests__infer_function_generics.snap
+++ /dev/null
@@ -1,21 +0,0 @@
1---
2created: "2019-01-27T14:52:29.934503829+00:00"
3creator: [email protected]
4expression: "&result"
5source: crates/ra_hir/src/ty/tests.rs
6---
7[10; 11) 't': T
8[21; 26) '{ t }': T
9[23; 24) 't': T
10[38; 98) '{ ...(1); }': ()
11[44; 46) 'id': fn id<u32>(T) -> T
12[44; 52) 'id(1u32)': u32
13[47; 51) '1u32': u32
14[58; 68) 'id::<i128>': fn id<i128>(T) -> T
15[58; 71) 'id::<i128>(1)': i128
16[69; 70) '1': i128
17[81; 82) 'x': u64
18[90; 92) 'id': fn id<u64>(T) -> T
19[90; 95) 'id(1)': u64
20[93; 94) '1': u64
21
diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_generic_chain.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_generic_chain.snap
deleted file mode 100644
index d1ce87b0a..000000000
--- a/crates/ra_hir/src/ty/snapshots/tests__infer_generic_chain.snap
+++ /dev/null
@@ -1,36 +0,0 @@
1---
2created: "2019-02-16T20:53:59.655361804Z"
3creator: [email protected]
4source: crates/ra_hir/src/ty/tests.rs
5expression: "&result"
6---
7[53; 57) 'self': A<T2>
8[65; 87) '{ ... }': T2
9[75; 79) 'self': A<T2>
10[75; 81) 'self.x': T2
11[99; 100) 't': T
12[110; 115) '{ t }': T
13[112; 113) 't': T
14[135; 261) '{ ....x() }': i128
15[146; 147) 'x': i128
16[150; 151) '1': i128
17[162; 163) 'y': i128
18[166; 168) 'id': fn id<i128>(T) -> T
19[166; 171) 'id(x)': i128
20[169; 170) 'x': i128
21[182; 183) 'a': A<i128>
22[186; 200) 'A { x: id(y) }': A<i128>
23[193; 195) 'id': fn id<i128>(T) -> T
24[193; 198) 'id(y)': i128
25[196; 197) 'y': i128
26[211; 212) 'z': i128
27[215; 217) 'id': fn id<i128>(T) -> T
28[215; 222) 'id(a.x)': i128
29[218; 219) 'a': A<i128>
30[218; 221) 'a.x': i128
31[233; 234) 'b': A<i128>
32[237; 247) 'A { x: z }': A<i128>
33[244; 245) 'z': i128
34[254; 255) 'b': A<i128>
35[254; 259) 'b.x()': i128
36
diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_generics_in_patterns.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_generics_in_patterns.snap
deleted file mode 100644
index fae7ab0dd..000000000
--- a/crates/ra_hir/src/ty/snapshots/tests__infer_generics_in_patterns.snap
+++ /dev/null
@@ -1,24 +0,0 @@
1---
2created: "2019-01-22T14:44:59.970913200+00:00"
3creator: [email protected]
4expression: "&result"
5source: "crates\\ra_hir\\src\\ty\\tests.rs"
6---
7[79; 81) 'a1': A<u32>
8[91; 92) 'o': Option<u64>
9[107; 244) '{ ... }; }': ()
10[117; 128) 'A { x: x2 }': A<u32>
11[124; 126) 'x2': u32
12[131; 133) 'a1': A<u32>
13[143; 161) 'A::<i6...: x3 }': A<i64>
14[157; 159) 'x3': i64
15[164; 174) 'A { x: 1 }': A<i64>
16[171; 172) '1': i64
17[180; 241) 'match ... }': u64
18[186; 187) 'o': Option<u64>
19[198; 213) 'Option::Some(t)': Option<u64>
20[211; 212) 't': u64
21[217; 218) 't': u64
22[228; 229) '_': Option<u64>
23[233; 234) '1': u64
24
diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_impl_generics.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_impl_generics.snap
deleted file mode 100644
index 44f00a52e..000000000
--- a/crates/ra_hir/src/ty/snapshots/tests__infer_impl_generics.snap
+++ /dev/null
@@ -1,39 +0,0 @@
1---
2created: "2019-02-16T21:58:14.029368845Z"
3creator: [email protected]
4source: crates/ra_hir/src/ty/tests.rs
5expression: "&result"
6---
7[74; 78) 'self': A<X, Y>
8[85; 107) '{ ... }': X
9[95; 99) 'self': A<X, Y>
10[95; 101) 'self.x': X
11[117; 121) 'self': A<X, Y>
12[128; 150) '{ ... }': Y
13[138; 142) 'self': A<X, Y>
14[138; 144) 'self.y': Y
15[163; 167) 'self': A<X, Y>
16[169; 170) 't': T
17[188; 223) '{ ... }': (X, Y, T)
18[198; 217) '(self.....y, t)': (X, Y, T)
19[199; 203) 'self': A<X, Y>
20[199; 205) 'self.x': X
21[207; 211) 'self': A<X, Y>
22[207; 213) 'self.y': Y
23[215; 216) 't': T
24[245; 342) '{ ...(1); }': ()
25[255; 256) 'a': A<u64, i64>
26[259; 281) 'A { x:...1i64 }': A<u64, i64>
27[266; 270) '1u64': u64
28[275; 279) '1i64': i64
29[287; 288) 'a': A<u64, i64>
30[287; 292) 'a.x()': u64
31[298; 299) 'a': A<u64, i64>
32[298; 303) 'a.y()': i64
33[309; 310) 'a': A<u64, i64>
34[309; 319) 'a.z(1i128)': (u64, i64, i128)
35[313; 318) '1i128': i128
36[325; 326) 'a': A<u64, i64>
37[325; 339) 'a.z::<u128>(1)': (u64, i64, u128)
38[337; 338) '1': u128
39
diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_impl_generics_with_autoderef.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_impl_generics_with_autoderef.snap
deleted file mode 100644
index f609eaf7c..000000000
--- a/crates/ra_hir/src/ty/snapshots/tests__infer_impl_generics_with_autoderef.snap
+++ /dev/null
@@ -1,16 +0,0 @@
1---
2created: "2019-02-17T13:35:06.385679926Z"
3creator: [email protected]
4source: crates/ra_hir/src/ty/tests.rs
5expression: "&result"
6---
7[78; 82) 'self': &Option<T>
8[98; 100) '{}': ()
9[111; 112) 'o': Option<u32>
10[127; 165) '{ ...f(); }': ()
11[133; 146) '(&o).as_ref()': Option<&u32>
12[134; 136) '&o': &Option<u32>
13[135; 136) 'o': Option<u32>
14[152; 153) 'o': Option<u32>
15[152; 162) 'o.as_ref()': Option<&u32>
16
diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_in_elseif.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_in_elseif.snap
deleted file mode 100644
index 6a435e5cf..000000000
--- a/crates/ra_hir/src/ty/snapshots/tests__infer_in_elseif.snap
+++ /dev/null
@@ -1,17 +0,0 @@
1---
2created: "2019-01-26T21:36:52.714121185+00:00"
3creator: [email protected]
4expression: "&result"
5source: crates/ra_hir/src/ty/tests.rs
6---
7[35; 38) 'foo': Foo
8[45; 109) '{ ... } }': ()
9[51; 107) 'if tru... }': ()
10[54; 58) 'true': bool
11[59; 67) '{ }': ()
12[73; 107) 'if fal... }': i32
13[76; 81) 'false': bool
14[82; 107) '{ ... }': i32
15[92; 95) 'foo': Foo
16[92; 101) 'foo.field': i32
17
diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_inherent_method.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_inherent_method.snap
deleted file mode 100644
index b3c706aca..000000000
--- a/crates/ra_hir/src/ty/snapshots/tests__infer_inherent_method.snap
+++ /dev/null
@@ -1,25 +0,0 @@
1---
2created: "2019-01-22T14:44:59.968918800+00:00"
3creator: [email protected]
4expression: "&result"
5source: "crates\\ra_hir\\src\\ty\\tests.rs"
6---
7[32; 36) 'self': A
8[38; 39) 'x': u32
9[53; 55) '{}': ()
10[103; 107) 'self': &A
11[109; 110) 'x': u64
12[124; 126) '{}': ()
13[144; 145) 'a': A
14[150; 198) '{ ...(1); }': ()
15[156; 157) 'a': A
16[156; 164) 'a.foo(1)': i32
17[162; 163) '1': u32
18[170; 181) '(&a).bar(1)': i64
19[171; 173) '&a': &A
20[172; 173) 'a': A
21[179; 180) '1': u64
22[187; 188) 'a': A
23[187; 195) 'a.bar(1)': i64
24[193; 194) '1': u64
25
diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_let.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_let.snap
deleted file mode 100644
index 0d085071a..000000000
--- a/crates/ra_hir/src/ty/snapshots/tests__infer_let.snap
+++ /dev/null
@@ -1,14 +0,0 @@
1---
2created: "2019-01-22T14:44:59.963931700+00:00"
3creator: [email protected]
4expression: "&result"
5source: "crates\\ra_hir\\src\\ty\\tests.rs"
6---
7[11; 71) '{ ...= b; }': ()
8[21; 22) 'a': isize
9[25; 31) '1isize': isize
10[41; 42) 'b': usize
11[52; 53) '1': usize
12[63; 64) 'c': usize
13[67; 68) 'b': usize
14
diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_literals.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_literals.snap
deleted file mode 100644
index e287a100e..000000000
--- a/crates/ra_hir/src/ty/snapshots/tests__infer_literals.snap
+++ /dev/null
@@ -1,19 +0,0 @@
1---
2created: "2019-01-22T14:44:59.974903100+00:00"
3creator: [email protected]
4expression: "&result"
5source: "crates\\ra_hir\\src\\ty\\tests.rs"
6---
7[11; 201) '{ ...o"#; }': ()
8[17; 21) '5i32': i32
9[27; 34) '"hello"': &str
10[40; 48) 'b"bytes"': &[u8]
11[54; 57) ''c'': char
12[63; 67) 'b'b'': u8
13[73; 77) '3.14': f64
14[83; 87) '5000': i32
15[93; 98) 'false': bool
16[104; 108) 'true': bool
17[114; 182) 'r#" ... "#': &str
18[188; 198) 'br#"yolo"#': &[u8]
19
diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_nested_generics_crash.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_nested_generics_crash.snap
deleted file mode 100644
index 209454a91..000000000
--- a/crates/ra_hir/src/ty/snapshots/tests__infer_nested_generics_crash.snap
+++ /dev/null
@@ -1,12 +0,0 @@
1---
2created: "2019-02-11T21:59:04.302375838Z"
3creator: [email protected]
4source: crates/ra_hir/src/ty/tests.rs
5expression: "&result"
6---
7[92; 106) 'query_response': Canonical<QueryResponse<R>>
8[137; 167) '{ ...lue; }': ()
9[143; 164) '&query....value': &QueryResponse<R>
10[144; 158) 'query_response': Canonical<QueryResponse<R>>
11[144; 164) 'query_....value': QueryResponse<R>
12
diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_paths.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_paths.snap
deleted file mode 100644
index afbe2f747..000000000
--- a/crates/ra_hir/src/ty/snapshots/tests__infer_paths.snap
+++ /dev/null
@@ -1,16 +0,0 @@
1---
2created: "2019-01-26T17:46:03.928773630+00:00"
3creator: [email protected]
4expression: "&result"
5source: crates/ra_hir/src/ty/tests.rs
6---
7[15; 20) '{ 1 }': u32
8[17; 18) '1': u32
9[48; 53) '{ 1 }': u32
10[50; 51) '1': u32
11[67; 91) '{ ...c(); }': ()
12[73; 74) 'a': fn a() -> u32
13[73; 76) 'a()': u32
14[82; 86) 'b::c': fn c() -> u32
15[82; 88) 'b::c()': u32
16
diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_pattern.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_pattern.snap
deleted file mode 100644
index 1da46daf8..000000000
--- a/crates/ra_hir/src/ty/snapshots/tests__infer_pattern.snap
+++ /dev/null
@@ -1,54 +0,0 @@
1---
2created: "2019-01-22T14:45:00.037734500+00:00"
3creator: [email protected]
4expression: "&result"
5source: "crates\\ra_hir\\src\\ty\\tests.rs"
6---
7[9; 10) 'x': &i32
8[18; 369) '{ ...o_x; }': ()
9[28; 29) 'y': &i32
10[32; 33) 'x': &i32
11[43; 45) '&z': &i32
12[44; 45) 'z': i32
13[48; 49) 'x': &i32
14[59; 60) 'a': i32
15[63; 64) 'z': i32
16[74; 80) '(c, d)': (i32, &str)
17[75; 76) 'c': i32
18[78; 79) 'd': &str
19[83; 95) '(1, "hello")': (i32, &str)
20[84; 85) '1': i32
21[87; 94) '"hello"': &str
22[102; 152) 'for (e... }': ()
23[106; 112) '(e, f)': ([unknown], [unknown])
24[107; 108) 'e': [unknown]
25[110; 111) 'f': [unknown]
26[116; 125) 'some_iter': [unknown]
27[126; 152) '{ ... }': ()
28[140; 141) 'g': [unknown]
29[144; 145) 'e': [unknown]
30[158; 205) 'if let... }': ()
31[165; 170) '[val]': [unknown]
32[173; 176) 'opt': [unknown]
33[177; 205) '{ ... }': ()
34[191; 192) 'h': [unknown]
35[195; 198) 'val': [unknown]
36[215; 221) 'lambda': [unknown]
37[224; 256) '|a: u6...b; c }': [unknown]
38[225; 226) 'a': u64
39[233; 234) 'b': u64
40[236; 237) 'c': i32
41[244; 256) '{ a + b; c }': i32
42[246; 247) 'a': u64
43[246; 251) 'a + b': u64
44[250; 251) 'b': u64
45[253; 254) 'c': i32
46[267; 279) 'ref ref_to_x': &&i32
47[282; 283) 'x': &i32
48[293; 302) 'mut mut_x': &i32
49[305; 306) 'x': &i32
50[316; 336) 'ref mu...f_to_x': &mut &i32
51[339; 340) 'x': &i32
52[350; 351) 'k': &mut &i32
53[354; 366) 'mut_ref_to_x': &mut &i32
54
diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_refs.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_refs.snap
deleted file mode 100644
index 56931bb3d..000000000
--- a/crates/ra_hir/src/ty/snapshots/tests__infer_refs.snap
+++ /dev/null
@@ -1,30 +0,0 @@
1---
2created: "2019-01-22T14:45:00.053692600+00:00"
3creator: [email protected]
4expression: "&result"
5source: "crates\\ra_hir\\src\\ty\\tests.rs"
6---
7[9; 10) 'a': &u32
8[18; 19) 'b': &mut u32
9[31; 32) 'c': *const u32
10[46; 47) 'd': *mut u32
11[59; 150) '{ ... *d; }': ()
12[65; 66) 'a': &u32
13[72; 74) '*a': u32
14[73; 74) 'a': &u32
15[80; 82) '&a': &&u32
16[81; 82) 'a': &u32
17[88; 94) '&mut a': &mut &u32
18[93; 94) 'a': &u32
19[100; 101) 'b': &mut u32
20[107; 109) '*b': u32
21[108; 109) 'b': &mut u32
22[115; 117) '&b': &&mut u32
23[116; 117) 'b': &mut u32
24[123; 124) 'c': *const u32
25[130; 132) '*c': u32
26[131; 132) 'c': *const u32
27[138; 139) 'd': *mut u32
28[145; 147) '*d': u32
29[146; 147) 'd': *mut u32
30
diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_self.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_self.snap
deleted file mode 100644
index 5c927f5c1..000000000
--- a/crates/ra_hir/src/ty/snapshots/tests__infer_self.snap
+++ /dev/null
@@ -1,17 +0,0 @@
1---
2created: "2019-02-04T19:40:48.826936500+00:00"
3creator: [email protected]
4expression: "&result"
5source: crates/ra_hir/src/ty/tests.rs
6---
7[34; 38) 'self': &S
8[40; 61) '{ ... }': ()
9[50; 54) 'self': &S
10[75; 79) 'self': &S
11[88; 109) '{ ... }': ()
12[98; 102) 'self': &S
13[133; 153) '{ ... }': S
14[143; 147) 'S {}': S
15[177; 200) '{ ... }': S
16[187; 194) 'Self {}': S
17
diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_static.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_static.snap
deleted file mode 100644
index 5d90f56ed..000000000
--- a/crates/ra_hir/src/ty/snapshots/tests__infer_static.snap
+++ /dev/null
@@ -1,16 +0,0 @@
1---
2created: "2019-02-25T08:20:17.807316Z"
3creator: [email protected]
4source: crates/ra_hir/src/ty/tests.rs
5expression: "&result"
6---
7[85; 280) '{ ...MUT; }': ()
8[173; 174) 'x': [unknown]
9[177; 189) 'LOCAL_STATIC': [unknown]
10[199; 200) 'y': [unknown]
11[203; 219) 'LOCAL_...IC_MUT': [unknown]
12[229; 230) 'z': u32
13[233; 246) 'GLOBAL_STATIC': u32
14[256; 257) 'w': u32
15[260; 277) 'GLOBAL...IC_MUT': u32
16
diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_std_crash_1.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_std_crash_1.snap
deleted file mode 100644
index 4b99788e4..000000000
--- a/crates/ra_hir/src/ty/snapshots/tests__infer_std_crash_1.snap
+++ /dev/null
@@ -1,13 +0,0 @@
1---
2created: "2019-02-09T16:56:24.803326529Z"
3creator: [email protected]
4source: crates/ra_hir/src/ty/tests.rs
5expression: "&result"
6---
7[54; 139) '{ ... } }': ()
8[60; 137) 'match ... }': ()
9[66; 83) 'someth...nknown': Maybe<[unknown]>
10[94; 124) 'Maybe:...thing)': Maybe<[unknown]>
11[106; 123) 'ref mu...ething': &mut [unknown]
12[128; 130) '()': ()
13
diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_std_crash_2.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_std_crash_2.snap
deleted file mode 100644
index fd0b39b7d..000000000
--- a/crates/ra_hir/src/ty/snapshots/tests__infer_std_crash_2.snap
+++ /dev/null
@@ -1,14 +0,0 @@
1---
2created: "2019-02-09T17:03:11.974225590Z"
3creator: [email protected]
4source: crates/ra_hir/src/ty/tests.rs
5expression: "&result"
6---
7[23; 53) '{ ...n']; }': ()
8[29; 50) '&[0, b...b'\n']': &[u8]
9[30; 50) '[0, b'...b'\n']': [u8]
10[31; 32) '0': u8
11[34; 39) 'b'\n'': u8
12[41; 42) '1': u8
13[44; 49) 'b'\n'': u8
14
diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_std_crash_3.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_std_crash_3.snap
deleted file mode 100644
index d15b77e17..000000000
--- a/crates/ra_hir/src/ty/snapshots/tests__infer_std_crash_3.snap
+++ /dev/null
@@ -1,13 +0,0 @@
1---
2created: "2019-02-09T18:02:37.377591660Z"
3creator: [email protected]
4source: crates/ra_hir/src/ty/tests.rs
5expression: "&result"
6---
7[18; 102) '{ ... } }': ()
8[24; 100) 'match ... }': ()
9[42; 88) 'SizeSk...tail }': [unknown]
10[76; 80) 'true': [unknown]
11[82; 86) 'tail': [unknown]
12[92; 94) '{}': ()
13
diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_std_crash_4.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_std_crash_4.snap
deleted file mode 100644
index fb31883ce..000000000
--- a/crates/ra_hir/src/ty/snapshots/tests__infer_std_crash_4.snap
+++ /dev/null
@@ -1,16 +0,0 @@
1---
2created: "2019-02-09T19:55:39.712470520Z"
3creator: [email protected]
4source: crates/ra_hir/src/ty/tests.rs
5expression: "&result"
6---
7[25; 110) '{ ... } }': ()
8[31; 108) 'match ... }': ()
9[37; 42) '*self': [unknown]
10[38; 42) 'self': [unknown]
11[53; 95) 'Borrow...), ..}': [unknown]
12[74; 77) 'box': [unknown]
13[78; 87) 'Primitive': [unknown]
14[88; 89) 'p': [unknown]
15[99; 101) '{}': ()
16
diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_std_crash_5.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_std_crash_5.snap
deleted file mode 100644
index 6bbf59fb6..000000000
--- a/crates/ra_hir/src/ty/snapshots/tests__infer_std_crash_5.snap
+++ /dev/null
@@ -1,30 +0,0 @@
1---
2created: "2019-02-09T20:28:37.294693728Z"
3creator: [email protected]
4source: crates/ra_hir/src/ty/tests.rs
5expression: "&result"
6---
7[27; 323) '{ ... } }': ()
8[33; 321) 'for co... }': ()
9[37; 44) 'content': &[unknown]
10[48; 61) 'doesnt_matter': [unknown]
11[62; 321) '{ ... }': ()
12[76; 80) 'name': &&[unknown]
13[83; 167) 'if doe... }': &&[unknown]
14[86; 99) 'doesnt_matter': bool
15[100; 129) '{ ... }': &&[unknown]
16[114; 119) 'first': &&[unknown]
17[135; 167) '{ ... }': &&[unknown]
18[149; 157) '&content': &&[unknown]
19[150; 157) 'content': &[unknown]
20[182; 189) 'content': &&[unknown]
21[192; 314) 'if ICE... }': &&[unknown]
22[195; 232) 'ICE_RE..._VALUE': [unknown]
23[195; 248) 'ICE_RE...&name)': bool
24[242; 247) '&name': &&&[unknown]
25[243; 247) 'name': &&[unknown]
26[249; 277) '{ ... }': &&[unknown]
27[263; 267) 'name': &&[unknown]
28[283; 314) '{ ... }': &[unknown]
29[297; 304) 'content': &[unknown]
30
diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_struct.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_struct.snap
deleted file mode 100644
index 32f1fa108..000000000
--- a/crates/ra_hir/src/ty/snapshots/tests__infer_struct.snap
+++ /dev/null
@@ -1,23 +0,0 @@
1---
2created: "2019-02-20T21:31:12.910924715Z"
3creator: [email protected]
4source: crates/ra_hir/src/ty/tests.rs
5expression: "&result"
6---
7[72; 154) '{ ...a.c; }': ()
8[82; 83) 'c': C
9[86; 87) 'C': C(usize) -> C
10[86; 90) 'C(1)': C
11[88; 89) '1': usize
12[96; 97) 'B': B
13[107; 108) 'a': A
14[114; 133) 'A { b:...C(1) }': A
15[121; 122) 'B': B
16[127; 128) 'C': C(usize) -> C
17[127; 131) 'C(1)': C
18[129; 130) '1': usize
19[139; 140) 'a': A
20[139; 142) 'a.b': B
21[148; 149) 'a': A
22[148; 151) 'a.c': C
23
diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_struct_generics.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_struct_generics.snap
deleted file mode 100644
index e07c7d36c..000000000
--- a/crates/ra_hir/src/ty/snapshots/tests__infer_struct_generics.snap
+++ /dev/null
@@ -1,22 +0,0 @@
1---
2created: "2019-01-22T14:45:00.058678600+00:00"
3creator: [email protected]
4expression: "&result"
5source: "crates\\ra_hir\\src\\ty\\tests.rs"
6---
7[36; 38) 'a1': A<u32>
8[48; 49) 'i': i32
9[56; 147) '{ ...3.x; }': ()
10[62; 64) 'a1': A<u32>
11[62; 66) 'a1.x': u32
12[76; 78) 'a2': A<i32>
13[81; 91) 'A { x: i }': A<i32>
14[88; 89) 'i': i32
15[97; 99) 'a2': A<i32>
16[97; 101) 'a2.x': i32
17[111; 113) 'a3': A<i128>
18[116; 134) 'A::<i1...x: 1 }': A<i128>
19[131; 132) '1': i128
20[140; 142) 'a3': A<i128>
21[140; 144) 'a3.x': i128
22
diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_tuple.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_tuple.snap
deleted file mode 100644
index cd11d41d3..000000000
--- a/crates/ra_hir/src/ty/snapshots/tests__infer_tuple.snap
+++ /dev/null
@@ -1,34 +0,0 @@
1---
2created: "2019-01-22T14:45:00.058678600+00:00"
3creator: [email protected]
4expression: "&result"
5source: "crates\\ra_hir\\src\\ty\\tests.rs"
6---
7[9; 10) 'x': &str
8[18; 19) 'y': isize
9[28; 170) '{ ...d"); }': ()
10[38; 39) 'a': (u32, &str)
11[55; 63) '(1, "a")': (u32, &str)
12[56; 57) '1': u32
13[59; 62) '"a"': &str
14[73; 74) 'b': ((u32, &str), &str)
15[77; 83) '(a, x)': ((u32, &str), &str)
16[78; 79) 'a': (u32, &str)
17[81; 82) 'x': &str
18[93; 94) 'c': (isize, &str)
19[97; 103) '(y, x)': (isize, &str)
20[98; 99) 'y': isize
21[101; 102) 'x': &str
22[113; 114) 'd': ((isize, &str), &str)
23[117; 123) '(c, x)': ((isize, &str), &str)
24[118; 119) 'c': (isize, &str)
25[121; 122) 'x': &str
26[133; 134) 'e': (i32, &str)
27[137; 145) '(1, "e")': (i32, &str)
28[138; 139) '1': i32
29[141; 144) '"e"': &str
30[155; 156) 'f': ((i32, &str), &str)
31[159; 167) '(e, "d")': ((i32, &str), &str)
32[160; 161) 'e': (i32, &str)
33[163; 166) '"d"': &str
34
diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_tuple_struct_generics.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_tuple_struct_generics.snap
deleted file mode 100644
index 783795cfd..000000000
--- a/crates/ra_hir/src/ty/snapshots/tests__infer_tuple_struct_generics.snap
+++ /dev/null
@@ -1,23 +0,0 @@
1---
2created: "2019-02-20T21:31:12.911275141Z"
3creator: [email protected]
4source: crates/ra_hir/src/ty/tests.rs
5expression: "&result"
6---
7[77; 185) '{ ...one; }': ()
8[83; 84) 'A': A<i32>(T) -> A<T>
9[83; 88) 'A(42)': A<i32>
10[85; 87) '42': i32
11[94; 95) 'A': A<u128>(T) -> A<T>
12[94; 103) 'A(42u128)': A<u128>
13[96; 102) '42u128': u128
14[109; 113) 'Some': Some<&str>(T) -> Option<T>
15[109; 118) 'Some("x")': Option<&str>
16[114; 117) '"x"': &str
17[124; 136) 'Option::Some': Some<&str>(T) -> Option<T>
18[124; 141) 'Option...e("x")': Option<&str>
19[137; 140) '"x"': &str
20[147; 151) 'None': Option<[unknown]>
21[161; 162) 'x': Option<i64>
22[178; 182) 'None': Option<i64>
23
diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_type_alias.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_type_alias.snap
deleted file mode 100644
index 241c08353..000000000
--- a/crates/ra_hir/src/ty/snapshots/tests__infer_type_alias.snap
+++ /dev/null
@@ -1,23 +0,0 @@
1---
2created: "2019-02-24T16:13:47.561870283Z"
3creator: [email protected]
4source: crates/ra_hir/src/ty/tests.rs
5expression: "&result"
6---
7[117; 118) 'x': A<u32, i128>
8[125; 126) 'y': A<&str, u128>
9[139; 140) 'z': A<u8, i8>
10[155; 212) '{ ...z.y; }': ()
11[161; 162) 'x': A<u32, i128>
12[161; 164) 'x.x': u32
13[170; 171) 'x': A<u32, i128>
14[170; 173) 'x.y': i128
15[179; 180) 'y': A<&str, u128>
16[179; 182) 'y.x': &str
17[188; 189) 'y': A<&str, u128>
18[188; 191) 'y.y': u128
19[197; 198) 'z': A<u8, i8>
20[197; 200) 'z.x': u8
21[206; 207) 'z': A<u8, i8>
22[206; 209) 'z.y': i8
23
diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_type_param.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_type_param.snap
deleted file mode 100644
index 216d1e41f..000000000
--- a/crates/ra_hir/src/ty/snapshots/tests__infer_type_param.snap
+++ /dev/null
@@ -1,26 +0,0 @@
1---
2created: "2019-01-27T20:38:32.153717698+00:00"
3creator: [email protected]
4expression: "&result"
5source: crates/ra_hir/src/ty/tests.rs
6---
7[10; 11) 'x': T
8[21; 30) '{ x }': T
9[27; 28) 'x': T
10[44; 45) 'x': &T
11[56; 65) '{ x }': &T
12[62; 63) 'x': &T
13[77; 157) '{ ...(1); }': ()
14[87; 88) 'y': u32
15[91; 96) '10u32': u32
16[102; 104) 'id': fn id<u32>(T) -> T
17[102; 107) 'id(y)': u32
18[105; 106) 'y': u32
19[117; 118) 'x': bool
20[127; 132) 'clone': fn clone<bool>(&T) -> T
21[127; 135) 'clone(z)': bool
22[133; 134) 'z': &bool
23[141; 151) 'id::<i128>': fn id<i128>(T) -> T
24[141; 154) 'id::<i128>(1)': i128
25[152; 153) '1': i128
26
diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_unary_op.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_unary_op.snap
deleted file mode 100644
index 5021d0eeb..000000000
--- a/crates/ra_hir/src/ty/snapshots/tests__infer_unary_op.snap
+++ /dev/null
@@ -1,48 +0,0 @@
1---
2created: "2019-01-28T14:51:16.185273502+00:00"
3creator: [email protected]
4expression: "&result"
5source: crates/ra_hir/src/ty/tests.rs
6---
7[27; 28) 'x': SomeType
8[40; 272) '{ ...lo"; }': ()
9[50; 51) 'b': bool
10[54; 59) 'false': bool
11[69; 70) 'c': bool
12[73; 75) '!b': bool
13[74; 75) 'b': bool
14[85; 86) 'a': i128
15[89; 92) '100': i128
16[102; 103) 'd': i128
17[112; 114) '-a': i128
18[113; 114) 'a': i128
19[124; 125) 'e': i32
20[128; 132) '-100': i32
21[129; 132) '100': i32
22[142; 143) 'f': bool
23[146; 153) '!!!true': bool
24[147; 153) '!!true': bool
25[148; 153) '!true': bool
26[149; 153) 'true': bool
27[163; 164) 'g': i32
28[167; 170) '!42': i32
29[168; 170) '42': i32
30[180; 181) 'h': u32
31[184; 190) '!10u32': u32
32[185; 190) '10u32': u32
33[200; 201) 'j': i128
34[204; 206) '!a': i128
35[205; 206) 'a': i128
36[212; 217) '-3.14': f64
37[213; 217) '3.14': f64
38[223; 225) '!3': i32
39[224; 225) '3': i32
40[231; 233) '-x': [unknown]
41[232; 233) 'x': SomeType
42[239; 241) '!x': [unknown]
43[240; 241) 'x': SomeType
44[247; 255) '-"hello"': [unknown]
45[248; 255) '"hello"': &str
46[261; 269) '!"hello"': [unknown]
47[262; 269) '"hello"': &str
48
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
deleted file mode 100644
index b6f404b4c..000000000
--- a/crates/ra_hir/src/ty/snapshots/tests__no_panic_on_field_of_enum.snap
+++ /dev/null
@@ -1,11 +0,0 @@
1---
2created: "2019-01-22T14:45:00.058678600+00:00"
3creator: [email protected]
4expression: "&result"
5source: "crates\\ra_hir\\src\\ty\\tests.rs"
6---
7[20; 21) 'x': X
8[26; 47) '{ ...eld; }': ()
9[32; 33) 'x': X
10[32; 44) 'x.some_field': [unknown]
11
diff --git a/crates/ra_hir/src/ty/snapshots/tests__recursive_vars.snap b/crates/ra_hir/src/ty/snapshots/tests__recursive_vars.snap
deleted file mode 100644
index c3227ff7e..000000000
--- a/crates/ra_hir/src/ty/snapshots/tests__recursive_vars.snap
+++ /dev/null
@@ -1,14 +0,0 @@
1---
2created: "2019-01-26T22:42:22.329980185+00:00"
3creator: [email protected]
4expression: "&result"
5source: crates/ra_hir/src/ty/tests.rs
6---
7[11; 48) '{ ...&y]; }': ()
8[21; 22) 'y': &[unknown]
9[25; 32) 'unknown': &[unknown]
10[38; 45) '[y, &y]': [&&[unknown]]
11[39; 40) 'y': &[unknown]
12[42; 44) '&y': &&[unknown]
13[43; 44) 'y': &[unknown]
14
diff --git a/crates/ra_hir/src/ty/snapshots/tests__recursive_vars_2.snap b/crates/ra_hir/src/ty/snapshots/tests__recursive_vars_2.snap
deleted file mode 100644
index de124da5b..000000000
--- a/crates/ra_hir/src/ty/snapshots/tests__recursive_vars_2.snap
+++ /dev/null
@@ -1,21 +0,0 @@
1---
2created: "2019-01-26T22:42:22.331805845+00:00"
3creator: [email protected]
4expression: "&result"
5source: crates/ra_hir/src/ty/tests.rs
6---
7[11; 80) '{ ...x)]; }': ()
8[21; 22) 'x': &&[unknown]
9[25; 32) 'unknown': &&[unknown]
10[42; 43) 'y': &&[unknown]
11[46; 53) 'unknown': &&[unknown]
12[59; 77) '[(x, y..., &x)]': [(&&[unknown], &&[unknown])]
13[60; 66) '(x, y)': (&&[unknown], &&[unknown])
14[61; 62) 'x': &&[unknown]
15[64; 65) 'y': &&[unknown]
16[68; 76) '(&y, &x)': (&&&[unknown], &&&[unknown])
17[69; 71) '&y': &&&[unknown]
18[70; 71) 'y': &&[unknown]
19[73; 75) '&x': &&&[unknown]
20[74; 75) 'x': &&[unknown]
21
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs
index 2fdfb54f4..c7d409e6d 100644
--- a/crates/ra_hir/src/ty/tests.rs
+++ b/crates/ra_hir/src/ty/tests.rs
@@ -1,6 +1,8 @@
1use std::sync::Arc; 1use std::sync::Arc;
2use std::fmt::Write; 2use std::fmt::Write;
3 3
4use insta::assert_snapshot_matches;
5
4use ra_db::{SourceDatabase, salsa::Database, FilePosition}; 6use ra_db::{SourceDatabase, salsa::Database, FilePosition};
5use ra_syntax::{algo, ast::{self, AstNode}}; 7use ra_syntax::{algo, ast::{self, AstNode}};
6use test_utils::covers; 8use test_utils::covers;
@@ -11,14 +13,13 @@ use crate::{
11}; 13};
12 14
13// These tests compare the inference results for all expressions in a file 15// These tests compare the inference results for all expressions in a file
14// against snapshots of the expected results using insta. Run the tests with 16// against snapshots of the expected results using insta. Use cargo-insta to
15// INSTA_UPDATE=1 to update the snapshots. 17// update the snapshots.
16 18
17#[test] 19#[test]
18fn infer_basics() { 20fn infer_basics() {
19 check_inference( 21 assert_snapshot_matches!(
20 "infer_basics", 22 infer(r#"
21 r#"
22fn test(a: u32, b: isize, c: !, d: &str) { 23fn test(a: u32, b: isize, c: !, d: &str) {
23 a; 24 a;
24 b; 25 b;
@@ -28,29 +29,49 @@ fn test(a: u32, b: isize, c: !, d: &str) {
28 1isize; 29 1isize;
29 "test"; 30 "test";
30 1.0f32; 31 1.0f32;
31}"#, 32}"#),
33 @r###"
34[9; 10) 'a': u32
35[17; 18) 'b': isize
36[27; 28) 'c': !
37[33; 34) 'd': &str
38[42; 121) '{ ...f32; }': ()
39[48; 49) 'a': u32
40[55; 56) 'b': isize
41[62; 63) 'c': !
42[69; 70) 'd': &str
43[76; 82) '1usize': usize
44[88; 94) '1isize': isize
45[100; 106) '"test"': &str
46[112; 118) '1.0f32': f32"###
32 ); 47 );
33} 48}
34 49
35#[test] 50#[test]
36fn infer_let() { 51fn infer_let() {
37 check_inference( 52 assert_snapshot_matches!(
38 "infer_let", 53 infer(r#"
39 r#"
40fn test() { 54fn test() {
41 let a = 1isize; 55 let a = 1isize;
42 let b: usize = 1; 56 let b: usize = 1;
43 let c = b; 57 let c = b;
44} 58}
45}"#, 59}"#),
60 @r###"
61[11; 71) '{ ...= b; }': ()
62[21; 22) 'a': isize
63[25; 31) '1isize': isize
64[41; 42) 'b': usize
65[52; 53) '1': usize
66[63; 64) 'c': usize
67[67; 68) 'b': usize"###
46 ); 68 );
47} 69}
48 70
49#[test] 71#[test]
50fn infer_paths() { 72fn infer_paths() {
51 check_inference( 73 assert_snapshot_matches!(
52 "infer_paths", 74 infer(r#"
53 r#"
54fn a() -> u32 { 1 } 75fn a() -> u32 { 1 }
55 76
56mod b { 77mod b {
@@ -61,15 +82,24 @@ fn test() {
61 a(); 82 a();
62 b::c(); 83 b::c();
63} 84}
64}"#, 85}"#),
86 @r###"
87[15; 20) '{ 1 }': u32
88[17; 18) '1': u32
89[48; 53) '{ 1 }': u32
90[50; 51) '1': u32
91[67; 91) '{ ...c(); }': ()
92[73; 74) 'a': fn a() -> u32
93[73; 76) 'a()': u32
94[82; 86) 'b::c': fn c() -> u32
95[82; 88) 'b::c()': u32"###
65 ); 96 );
66} 97}
67 98
68#[test] 99#[test]
69fn infer_struct() { 100fn infer_struct() {
70 check_inference( 101 assert_snapshot_matches!(
71 "infer_struct", 102 infer(r#"
72 r#"
73struct A { 103struct A {
74 b: B, 104 b: B,
75 c: C, 105 c: C,
@@ -84,15 +114,31 @@ fn test() {
84 a.b; 114 a.b;
85 a.c; 115 a.c;
86} 116}
87"#, 117"#),
118 @r###"
119[72; 154) '{ ...a.c; }': ()
120[82; 83) 'c': C
121[86; 87) 'C': C(usize) -> C
122[86; 90) 'C(1)': C
123[88; 89) '1': usize
124[96; 97) 'B': B
125[107; 108) 'a': A
126[114; 133) 'A { b:...C(1) }': A
127[121; 122) 'B': B
128[127; 128) 'C': C(usize) -> C
129[127; 131) 'C(1)': C
130[129; 130) '1': usize
131[139; 140) 'a': A
132[139; 142) 'a.b': B
133[148; 149) 'a': A
134[148; 151) 'a.c': C"###
88 ); 135 );
89} 136}
90 137
91#[test] 138#[test]
92fn infer_enum() { 139fn infer_enum() {
93 check_inference( 140 assert_snapshot_matches!(
94 "infer_enum", 141 infer(r#"
95 r#"
96enum E { 142enum E {
97 V1 { field: u32 }, 143 V1 { field: u32 },
98 V2 144 V2
@@ -100,15 +146,19 @@ enum E {
100fn test() { 146fn test() {
101 E::V1 { field: 1 }; 147 E::V1 { field: 1 };
102 E::V2; 148 E::V2;
103}"#, 149}"#),
150 @r###"
151[48; 82) '{ E:...:V2; }': ()
152[52; 70) 'E::V1 ...d: 1 }': E
153[67; 68) '1': u32
154[74; 79) 'E::V2': E"###
104 ); 155 );
105} 156}
106 157
107#[test] 158#[test]
108fn infer_refs() { 159fn infer_refs() {
109 check_inference( 160 assert_snapshot_matches!(
110 "infer_refs", 161 infer(r#"
111 r#"
112fn test(a: &u32, b: &mut u32, c: *const u32, d: *mut u32) { 162fn test(a: &u32, b: &mut u32, c: *const u32, d: *mut u32) {
113 a; 163 a;
114 *a; 164 *a;
@@ -122,15 +172,38 @@ fn test(a: &u32, b: &mut u32, c: *const u32, d: *mut u32) {
122 d; 172 d;
123 *d; 173 *d;
124} 174}
125"#, 175"#),
176 @r###"
177[9; 10) 'a': &u32
178[18; 19) 'b': &mut u32
179[31; 32) 'c': *const u32
180[46; 47) 'd': *mut u32
181[59; 150) '{ ... *d; }': ()
182[65; 66) 'a': &u32
183[72; 74) '*a': u32
184[73; 74) 'a': &u32
185[80; 82) '&a': &&u32
186[81; 82) 'a': &u32
187[88; 94) '&mut a': &mut &u32
188[93; 94) 'a': &u32
189[100; 101) 'b': &mut u32
190[107; 109) '*b': u32
191[108; 109) 'b': &mut u32
192[115; 117) '&b': &&mut u32
193[116; 117) 'b': &mut u32
194[123; 124) 'c': *const u32
195[130; 132) '*c': u32
196[131; 132) 'c': *const u32
197[138; 139) 'd': *mut u32
198[145; 147) '*d': u32
199[146; 147) 'd': *mut u32"###
126 ); 200 );
127} 201}
128 202
129#[test] 203#[test]
130fn infer_literals() { 204fn infer_literals() {
131 check_inference( 205 assert_snapshot_matches!(
132 "infer_literals", 206 infer(r##"
133 r##"
134fn test() { 207fn test() {
135 5i32; 208 5i32;
136 "hello"; 209 "hello";
@@ -148,15 +221,27 @@ fn test() {
148 "#; 221 "#;
149 br#"yolo"#; 222 br#"yolo"#;
150} 223}
151"##, 224"##),
225 @r###"
226[11; 201) '{ ...o"#; }': ()
227[17; 21) '5i32': i32
228[27; 34) '"hello"': &str
229[40; 48) 'b"bytes"': &[u8]
230[54; 57) ''c'': char
231[63; 67) 'b'b'': u8
232[73; 77) '3.14': f64
233[83; 87) '5000': i32
234[93; 98) 'false': bool
235[104; 108) 'true': bool
236[114; 182) 'r#" ... "#': &str
237[188; 198) 'br#"yolo"#': &[u8]"###
152 ); 238 );
153} 239}
154 240
155#[test] 241#[test]
156fn infer_unary_op() { 242fn infer_unary_op() {
157 check_inference( 243 assert_snapshot_matches!(
158 "infer_unary_op", 244 infer(r#"
159 r#"
160enum SomeType {} 245enum SomeType {}
161 246
162fn test(x: SomeType) { 247fn test(x: SomeType) {
@@ -176,15 +261,56 @@ fn test(x: SomeType) {
176 -"hello"; 261 -"hello";
177 !"hello"; 262 !"hello";
178} 263}
179"#, 264"#),
265 @r###"
266[27; 28) 'x': SomeType
267[40; 272) '{ ...lo"; }': ()
268[50; 51) 'b': bool
269[54; 59) 'false': bool
270[69; 70) 'c': bool
271[73; 75) '!b': bool
272[74; 75) 'b': bool
273[85; 86) 'a': i128
274[89; 92) '100': i128
275[102; 103) 'd': i128
276[112; 114) '-a': i128
277[113; 114) 'a': i128
278[124; 125) 'e': i32
279[128; 132) '-100': i32
280[129; 132) '100': i32
281[142; 143) 'f': bool
282[146; 153) '!!!true': bool
283[147; 153) '!!true': bool
284[148; 153) '!true': bool
285[149; 153) 'true': bool
286[163; 164) 'g': i32
287[167; 170) '!42': i32
288[168; 170) '42': i32
289[180; 181) 'h': u32
290[184; 190) '!10u32': u32
291[185; 190) '10u32': u32
292[200; 201) 'j': i128
293[204; 206) '!a': i128
294[205; 206) 'a': i128
295[212; 217) '-3.14': f64
296[213; 217) '3.14': f64
297[223; 225) '!3': i32
298[224; 225) '3': i32
299[231; 233) '-x': {unknown}
300[232; 233) 'x': SomeType
301[239; 241) '!x': {unknown}
302[240; 241) 'x': SomeType
303[247; 255) '-"hello"': {unknown}
304[248; 255) '"hello"': &str
305[261; 269) '!"hello"': {unknown}
306[262; 269) '"hello"': &str"###
180 ); 307 );
181} 308}
182 309
183#[test] 310#[test]
184fn infer_backwards() { 311fn infer_backwards() {
185 check_inference( 312 assert_snapshot_matches!(
186 "infer_backwards", 313 infer(r#"
187 r#"
188fn takes_u32(x: u32) {} 314fn takes_u32(x: u32) {}
189 315
190struct S { i32_field: i32 } 316struct S { i32_field: i32 }
@@ -197,15 +323,35 @@ fn test() -> &mut &f64 {
197 let c = unknown_function(); 323 let c = unknown_function();
198 &mut &c 324 &mut &c
199} 325}
200"#, 326"#),
327 @r###"
328[14; 15) 'x': u32
329[22; 24) '{}': ()
330[78; 231) '{ ...t &c }': &mut &f64
331[88; 89) 'a': u32
332[92; 108) 'unknow...nction': {unknown}
333[92; 110) 'unknow...tion()': u32
334[116; 125) 'takes_u32': fn takes_u32(u32) -> ()
335[116; 128) 'takes_u32(a)': ()
336[126; 127) 'a': u32
337[138; 139) 'b': i32
338[142; 158) 'unknow...nction': {unknown}
339[142; 160) 'unknow...tion()': i32
340[166; 184) 'S { i3...d: b }': S
341[181; 182) 'b': i32
342[194; 195) 'c': f64
343[198; 214) 'unknow...nction': {unknown}
344[198; 216) 'unknow...tion()': f64
345[222; 229) '&mut &c': &mut &f64
346[227; 229) '&c': &f64
347[228; 229) 'c': f64"###
201 ); 348 );
202} 349}
203 350
204#[test] 351#[test]
205fn infer_self() { 352fn infer_self() {
206 check_inference( 353 assert_snapshot_matches!(
207 "infer_self", 354 infer(r#"
208 r#"
209struct S; 355struct S;
210 356
211impl S { 357impl S {
@@ -222,15 +368,25 @@ impl S {
222 Self {} 368 Self {}
223 } 369 }
224} 370}
225"#, 371"#),
372 @r###"
373[34; 38) 'self': &S
374[40; 61) '{ ... }': ()
375[50; 54) 'self': &S
376[75; 79) 'self': &S
377[88; 109) '{ ... }': ()
378[98; 102) 'self': &S
379[133; 153) '{ ... }': S
380[143; 147) 'S {}': S
381[177; 200) '{ ... }': S
382[187; 194) 'Self {}': S"###
226 ); 383 );
227} 384}
228 385
229#[test] 386#[test]
230fn infer_binary_op() { 387fn infer_binary_op() {
231 check_inference( 388 assert_snapshot_matches!(
232 "infer_binary_op", 389 infer(r#"
233 r#"
234fn f(x: bool) -> i32 { 390fn f(x: bool) -> i32 {
235 0i32 391 0i32
236} 392}
@@ -250,15 +406,65 @@ fn test() -> bool {
250 406
251 ten < 3 407 ten < 3
252} 408}
253"#, 409"#),
410 @r###"
411[6; 7) 'x': bool
412[22; 34) '{ 0i32 }': i32
413[28; 32) '0i32': i32
414[54; 370) '{ ... < 3 }': bool
415[64; 65) 'x': bool
416[68; 69) 'a': bool
417[68; 74) 'a && b': bool
418[73; 74) 'b': bool
419[84; 85) 'y': bool
420[88; 92) 'true': bool
421[88; 101) 'true || false': bool
422[96; 101) 'false': bool
423[111; 112) 'z': bool
424[115; 116) 'x': bool
425[115; 121) 'x == y': bool
426[120; 121) 'y': bool
427[131; 132) 't': bool
428[135; 136) 'x': bool
429[135; 141) 'x != y': bool
430[140; 141) 'y': bool
431[151; 162) 'minus_forty': isize
432[172; 180) '-40isize': isize
433[173; 180) '40isize': isize
434[190; 191) 'h': bool
435[194; 205) 'minus_forty': isize
436[194; 216) 'minus_...ONST_2': bool
437[209; 216) 'CONST_2': isize
438[226; 227) 'c': i32
439[230; 231) 'f': fn f(bool) -> i32
440[230; 239) 'f(z || y)': i32
441[230; 243) 'f(z || y) + 5': i32
442[232; 233) 'z': bool
443[232; 238) 'z || y': bool
444[237; 238) 'y': bool
445[242; 243) '5': i32
446[253; 254) 'd': {unknown}
447[257; 258) 'b': {unknown}
448[268; 269) 'g': ()
449[272; 283) 'minus_forty': isize
450[272; 288) 'minus_...y ^= i': ()
451[287; 288) 'i': isize
452[298; 301) 'ten': usize
453[311; 313) '10': usize
454[323; 336) 'ten_is_eleven': bool
455[339; 342) 'ten': usize
456[339; 354) 'ten == some_num': bool
457[346; 354) 'some_num': usize
458[361; 364) 'ten': usize
459[361; 368) 'ten < 3': bool
460[367; 368) '3': usize"###
254 ); 461 );
255} 462}
256 463
257#[test] 464#[test]
258fn infer_field_autoderef() { 465fn infer_field_autoderef() {
259 check_inference( 466 assert_snapshot_matches!(
260 "infer_field_autoderef", 467 infer(r#"
261 r#"
262struct A { 468struct A {
263 b: B, 469 b: B,
264} 470}
@@ -281,27 +487,75 @@ fn test2(a1: *const A, a2: *mut A) {
281 a1.b; 487 a1.b;
282 a2.b; 488 a2.b;
283} 489}
284"#, 490"#),
491 @r###"
492[44; 45) 'a': A
493[50; 213) '{ ...5.b; }': ()
494[60; 62) 'a1': A
495[65; 66) 'a': A
496[72; 74) 'a1': A
497[72; 76) 'a1.b': B
498[86; 88) 'a2': &A
499[91; 93) '&a': &A
500[92; 93) 'a': A
501[99; 101) 'a2': &A
502[99; 103) 'a2.b': B
503[113; 115) 'a3': &mut A
504[118; 124) '&mut a': &mut A
505[123; 124) 'a': A
506[130; 132) 'a3': &mut A
507[130; 134) 'a3.b': B
508[144; 146) 'a4': &&&&&&&A
509[149; 157) '&&&&&&&a': &&&&&&&A
510[150; 157) '&&&&&&a': &&&&&&A
511[151; 157) '&&&&&a': &&&&&A
512[152; 157) '&&&&a': &&&&A
513[153; 157) '&&&a': &&&A
514[154; 157) '&&a': &&A
515[155; 157) '&a': &A
516[156; 157) 'a': A
517[163; 165) 'a4': &&&&&&&A
518[163; 167) 'a4.b': B
519[177; 179) 'a5': &mut &&mut &&mut A
520[182; 200) '&mut &...&mut a': &mut &&mut &&mut A
521[187; 200) '&&mut &&mut a': &&mut &&mut A
522[188; 200) '&mut &&mut a': &mut &&mut A
523[193; 200) '&&mut a': &&mut A
524[194; 200) '&mut a': &mut A
525[199; 200) 'a': A
526[206; 208) 'a5': &mut &&mut &&mut A
527[206; 210) 'a5.b': B
528[224; 226) 'a1': *const A
529[238; 240) 'a2': *mut A
530[250; 273) '{ ...2.b; }': ()
531[256; 258) 'a1': *const A
532[256; 260) 'a1.b': B
533[266; 268) 'a2': *mut A
534[266; 270) 'a2.b': B"###
285 ); 535 );
286} 536}
287 537
288#[test] 538#[test]
289fn bug_484() { 539fn bug_484() {
290 check_inference( 540 assert_snapshot_matches!(
291 "bug_484", 541 infer(r#"
292 r#"
293fn test() { 542fn test() {
294 let x = if true {}; 543 let x = if true {};
295} 544}
296"#, 545"#),
546 @r###"
547[11; 37) '{ l... {}; }': ()
548[20; 21) 'x': ()
549[24; 34) 'if true {}': ()
550[27; 31) 'true': bool
551[32; 34) '{}': ()"###
297 ); 552 );
298} 553}
299 554
300#[test] 555#[test]
301fn infer_in_elseif() { 556fn infer_in_elseif() {
302 check_inference( 557 assert_snapshot_matches!(
303 "infer_in_elseif", 558 infer(r#"
304 r#"
305struct Foo { field: i32 } 559struct Foo { field: i32 }
306fn main(foo: Foo) { 560fn main(foo: Foo) {
307 if true { 561 if true {
@@ -310,15 +564,25 @@ fn main(foo: Foo) {
310 foo.field 564 foo.field
311 } 565 }
312} 566}
313"#, 567"#),
568 @r###"
569[35; 38) 'foo': Foo
570[45; 109) '{ ... } }': ()
571[51; 107) 'if tru... }': ()
572[54; 58) 'true': bool
573[59; 67) '{ }': ()
574[73; 107) 'if fal... }': i32
575[76; 81) 'false': bool
576[82; 107) '{ ... }': i32
577[92; 95) 'foo': Foo
578[92; 101) 'foo.field': i32"###
314 ) 579 )
315} 580}
316 581
317#[test] 582#[test]
318fn infer_inherent_method() { 583fn infer_inherent_method() {
319 check_inference( 584 assert_snapshot_matches!(
320 "infer_inherent_method", 585 infer(r#"
321 r#"
322struct A; 586struct A;
323 587
324impl A { 588impl A {
@@ -336,15 +600,33 @@ fn test(a: A) {
336 (&a).bar(1); 600 (&a).bar(1);
337 a.bar(1); 601 a.bar(1);
338} 602}
339"#, 603"#),
604 @r###"
605[32; 36) 'self': A
606[38; 39) 'x': u32
607[53; 55) '{}': ()
608[103; 107) 'self': &A
609[109; 110) 'x': u64
610[124; 126) '{}': ()
611[144; 145) 'a': A
612[150; 198) '{ ...(1); }': ()
613[156; 157) 'a': A
614[156; 164) 'a.foo(1)': i32
615[162; 163) '1': u32
616[170; 181) '(&a).bar(1)': i64
617[171; 173) '&a': &A
618[172; 173) 'a': A
619[179; 180) '1': u64
620[187; 188) 'a': A
621[187; 195) 'a.bar(1)': i64
622[193; 194) '1': u64"###
340 ); 623 );
341} 624}
342 625
343#[test] 626#[test]
344fn infer_tuple() { 627fn infer_tuple() {
345 check_inference( 628 assert_snapshot_matches!(
346 "infer_tuple", 629 infer(r#"
347 r#"
348fn test(x: &str, y: isize) { 630fn test(x: &str, y: isize) {
349 let a: (u32, &str) = (1, "a"); 631 let a: (u32, &str) = (1, "a");
350 let b = (a, x); 632 let b = (a, x);
@@ -353,15 +635,42 @@ fn test(x: &str, y: isize) {
353 let e = (1, "e"); 635 let e = (1, "e");
354 let f = (e, "d"); 636 let f = (e, "d");
355} 637}
356"#, 638"#),
639 @r###"
640[9; 10) 'x': &str
641[18; 19) 'y': isize
642[28; 170) '{ ...d"); }': ()
643[38; 39) 'a': (u32, &str)
644[55; 63) '(1, "a")': (u32, &str)
645[56; 57) '1': u32
646[59; 62) '"a"': &str
647[73; 74) 'b': ((u32, &str), &str)
648[77; 83) '(a, x)': ((u32, &str), &str)
649[78; 79) 'a': (u32, &str)
650[81; 82) 'x': &str
651[93; 94) 'c': (isize, &str)
652[97; 103) '(y, x)': (isize, &str)
653[98; 99) 'y': isize
654[101; 102) 'x': &str
655[113; 114) 'd': ((isize, &str), &str)
656[117; 123) '(c, x)': ((isize, &str), &str)
657[118; 119) 'c': (isize, &str)
658[121; 122) 'x': &str
659[133; 134) 'e': (i32, &str)
660[137; 145) '(1, "e")': (i32, &str)
661[138; 139) '1': i32
662[141; 144) '"e"': &str
663[155; 156) 'f': ((i32, &str), &str)
664[159; 167) '(e, "d")': ((i32, &str), &str)
665[160; 161) 'e': (i32, &str)
666[163; 166) '"d"': &str"###
357 ); 667 );
358} 668}
359 669
360#[test] 670#[test]
361fn infer_array() { 671fn infer_array() {
362 check_inference( 672 assert_snapshot_matches!(
363 "infer_array", 673 infer(r#"
364 r#"
365fn test(x: &str, y: isize) { 674fn test(x: &str, y: isize) {
366 let a = [x]; 675 let a = [x];
367 let b = [a, a]; 676 let b = [a, a];
@@ -380,15 +689,73 @@ fn test(x: &str, y: isize) {
380 let x: [u8; 0] = []; 689 let x: [u8; 0] = [];
381 let z: &[u8] = &[1, 2, 3]; 690 let z: &[u8] = &[1, 2, 3];
382} 691}
383"#, 692"#),
693 @r###"
694[9; 10) 'x': &str
695[18; 19) 'y': isize
696[28; 324) '{ ... 3]; }': ()
697[38; 39) 'a': [&str]
698[42; 45) '[x]': [&str]
699[43; 44) 'x': &str
700[55; 56) 'b': [[&str]]
701[59; 65) '[a, a]': [[&str]]
702[60; 61) 'a': [&str]
703[63; 64) 'a': [&str]
704[75; 76) 'c': [[[&str]]]
705[79; 85) '[b, b]': [[[&str]]]
706[80; 81) 'b': [[&str]]
707[83; 84) 'b': [[&str]]
708[96; 97) 'd': [isize]
709[100; 112) '[y, 1, 2, 3]': [isize]
710[101; 102) 'y': isize
711[104; 105) '1': isize
712[107; 108) '2': isize
713[110; 111) '3': isize
714[122; 123) 'd': [isize]
715[126; 138) '[1, y, 2, 3]': [isize]
716[127; 128) '1': isize
717[130; 131) 'y': isize
718[133; 134) '2': isize
719[136; 137) '3': isize
720[148; 149) 'e': [isize]
721[152; 155) '[y]': [isize]
722[153; 154) 'y': isize
723[165; 166) 'f': [[isize]]
724[169; 175) '[d, d]': [[isize]]
725[170; 171) 'd': [isize]
726[173; 174) 'd': [isize]
727[185; 186) 'g': [[isize]]
728[189; 195) '[e, e]': [[isize]]
729[190; 191) 'e': [isize]
730[193; 194) 'e': [isize]
731[206; 207) 'h': [i32]
732[210; 216) '[1, 2]': [i32]
733[211; 212) '1': i32
734[214; 215) '2': i32
735[226; 227) 'i': [&str]
736[230; 240) '["a", "b"]': [&str]
737[231; 234) '"a"': &str
738[236; 239) '"b"': &str
739[251; 252) 'b': [[&str]]
740[255; 265) '[a, ["b"]]': [[&str]]
741[256; 257) 'a': [&str]
742[259; 264) '["b"]': [&str]
743[260; 263) '"b"': &str
744[275; 276) 'x': [u8]
745[288; 290) '[]': [u8]
746[300; 301) 'z': &[u8]
747[311; 321) '&[1, 2, 3]': &[u8]
748[312; 321) '[1, 2, 3]': [u8]
749[313; 314) '1': u8
750[316; 317) '2': u8
751[319; 320) '3': u8"###
384 ); 752 );
385} 753}
386 754
387#[test] 755#[test]
388fn infer_pattern() { 756fn infer_pattern() {
389 check_inference( 757 assert_snapshot_matches!(
390 "infer_pattern", 758 infer(r#"
391 r#"
392fn test(x: &i32) { 759fn test(x: &i32) {
393 let y = x; 760 let y = x;
394 let &z = x; 761 let &z = x;
@@ -410,15 +777,62 @@ fn test(x: &i32) {
410 let ref mut mut_ref_to_x = x; 777 let ref mut mut_ref_to_x = x;
411 let k = mut_ref_to_x; 778 let k = mut_ref_to_x;
412} 779}
413"#, 780"#),
781 @r###"
782[9; 10) 'x': &i32
783[18; 369) '{ ...o_x; }': ()
784[28; 29) 'y': &i32
785[32; 33) 'x': &i32
786[43; 45) '&z': &i32
787[44; 45) 'z': i32
788[48; 49) 'x': &i32
789[59; 60) 'a': i32
790[63; 64) 'z': i32
791[74; 80) '(c, d)': (i32, &str)
792[75; 76) 'c': i32
793[78; 79) 'd': &str
794[83; 95) '(1, "hello")': (i32, &str)
795[84; 85) '1': i32
796[87; 94) '"hello"': &str
797[102; 152) 'for (e... }': ()
798[106; 112) '(e, f)': ({unknown}, {unknown})
799[107; 108) 'e': {unknown}
800[110; 111) 'f': {unknown}
801[116; 125) 'some_iter': {unknown}
802[126; 152) '{ ... }': ()
803[140; 141) 'g': {unknown}
804[144; 145) 'e': {unknown}
805[158; 205) 'if let... }': ()
806[165; 170) '[val]': {unknown}
807[173; 176) 'opt': {unknown}
808[177; 205) '{ ... }': ()
809[191; 192) 'h': {unknown}
810[195; 198) 'val': {unknown}
811[215; 221) 'lambda': {unknown}
812[224; 256) '|a: u6...b; c }': {unknown}
813[225; 226) 'a': u64
814[233; 234) 'b': u64
815[236; 237) 'c': i32
816[244; 256) '{ a + b; c }': i32
817[246; 247) 'a': u64
818[246; 251) 'a + b': u64
819[250; 251) 'b': u64
820[253; 254) 'c': i32
821[267; 279) 'ref ref_to_x': &&i32
822[282; 283) 'x': &i32
823[293; 302) 'mut mut_x': &i32
824[305; 306) 'x': &i32
825[316; 336) 'ref mu...f_to_x': &mut &i32
826[339; 340) 'x': &i32
827[350; 351) 'k': &mut &i32
828[354; 366) 'mut_ref_to_x': &mut &i32"###
414 ); 829 );
415} 830}
416 831
417#[test] 832#[test]
418fn infer_adt_pattern() { 833fn infer_adt_pattern() {
419 check_inference( 834 assert_snapshot_matches!(
420 "infer_adt_pattern", 835 infer(r#"
421 r#"
422enum E { 836enum E {
423 A { x: usize }, 837 A { x: usize },
424 B 838 B
@@ -441,15 +855,40 @@ fn test() {
441 let ref d @ E::A { .. } = e; 855 let ref d @ E::A { .. } = e;
442 d; 856 d;
443} 857}
444"#, 858"#),
859 @r###"
860[68; 289) '{ ... d; }': ()
861[78; 79) 'e': E
862[82; 95) 'E::A { x: 3 }': E
863[92; 93) '3': usize
864[106; 113) 'S(y, z)': S
865[108; 109) 'y': u32
866[111; 112) 'z': E
867[116; 119) 'foo': S
868[129; 148) 'E::A {..._var }': E
869[139; 146) 'new_var': usize
870[151; 152) 'e': E
871[159; 245) 'match ... }': usize
872[165; 166) 'e': E
873[177; 187) 'E::A { x }': E
874[184; 185) 'x': usize
875[191; 192) 'x': usize
876[202; 206) 'E::B': E
877[210; 213) 'foo': bool
878[217; 218) '1': usize
879[228; 232) 'E::B': E
880[236; 238) '10': usize
881[256; 275) 'ref d ...{ .. }': &E
882[264; 275) 'E::A { .. }': E
883[278; 279) 'e': E
884[285; 286) 'd': &E"###
445 ); 885 );
446} 886}
447 887
448#[test] 888#[test]
449fn infer_struct_generics() { 889fn infer_struct_generics() {
450 check_inference( 890 assert_snapshot_matches!(
451 "infer_struct_generics", 891 infer(r#"
452 r#"
453struct A<T> { 892struct A<T> {
454 x: T, 893 x: T,
455} 894}
@@ -461,15 +900,30 @@ fn test(a1: A<u32>, i: i32) {
461 let a3 = A::<i128> { x: 1 }; 900 let a3 = A::<i128> { x: 1 };
462 a3.x; 901 a3.x;
463} 902}
464"#, 903"#),
904 @r###"
905[36; 38) 'a1': A<u32>
906[48; 49) 'i': i32
907[56; 147) '{ ...3.x; }': ()
908[62; 64) 'a1': A<u32>
909[62; 66) 'a1.x': u32
910[76; 78) 'a2': A<i32>
911[81; 91) 'A { x: i }': A<i32>
912[88; 89) 'i': i32
913[97; 99) 'a2': A<i32>
914[97; 101) 'a2.x': i32
915[111; 113) 'a3': A<i128>
916[116; 134) 'A::<i1...x: 1 }': A<i128>
917[131; 132) '1': i128
918[140; 142) 'a3': A<i128>
919[140; 144) 'a3.x': i128"###
465 ); 920 );
466} 921}
467 922
468#[test] 923#[test]
469fn infer_tuple_struct_generics() { 924fn infer_tuple_struct_generics() {
470 check_inference( 925 assert_snapshot_matches!(
471 "infer_tuple_struct_generics", 926 infer(r#"
472 r#"
473struct A<T>(T); 927struct A<T>(T);
474enum Option<T> { Some(T), None }; 928enum Option<T> { Some(T), None };
475use Option::*; 929use Option::*;
@@ -482,15 +936,31 @@ fn test() {
482 None; 936 None;
483 let x: Option<i64> = None; 937 let x: Option<i64> = None;
484} 938}
485"#, 939"#),
940 @r###"
941[77; 185) '{ ...one; }': ()
942[83; 84) 'A': A<i32>(T) -> A<T>
943[83; 88) 'A(42)': A<i32>
944[85; 87) '42': i32
945[94; 95) 'A': A<u128>(T) -> A<T>
946[94; 103) 'A(42u128)': A<u128>
947[96; 102) '42u128': u128
948[109; 113) 'Some': Some<&str>(T) -> Option<T>
949[109; 118) 'Some("x")': Option<&str>
950[114; 117) '"x"': &str
951[124; 136) 'Option::Some': Some<&str>(T) -> Option<T>
952[124; 141) 'Option...e("x")': Option<&str>
953[137; 140) '"x"': &str
954[147; 151) 'None': Option<{unknown}>
955[161; 162) 'x': Option<i64>
956[178; 182) 'None': Option<i64>"###
486 ); 957 );
487} 958}
488 959
489#[test] 960#[test]
490fn infer_generics_in_patterns() { 961fn infer_generics_in_patterns() {
491 check_inference( 962 assert_snapshot_matches!(
492 "infer_generics_in_patterns", 963 infer(r#"
493 r#"
494struct A<T> { 964struct A<T> {
495 x: T, 965 x: T,
496} 966}
@@ -508,15 +978,32 @@ fn test(a1: A<u32>, o: Option<u64>) {
508 _ => 1, 978 _ => 1,
509 }; 979 };
510} 980}
511"#, 981"#),
982 @r###"
983[79; 81) 'a1': A<u32>
984[91; 92) 'o': Option<u64>
985[107; 244) '{ ... }; }': ()
986[117; 128) 'A { x: x2 }': A<u32>
987[124; 126) 'x2': u32
988[131; 133) 'a1': A<u32>
989[143; 161) 'A::<i6...: x3 }': A<i64>
990[157; 159) 'x3': i64
991[164; 174) 'A { x: 1 }': A<i64>
992[171; 172) '1': i64
993[180; 241) 'match ... }': u64
994[186; 187) 'o': Option<u64>
995[198; 213) 'Option::Some(t)': Option<u64>
996[211; 212) 't': u64
997[217; 218) 't': u64
998[228; 229) '_': Option<u64>
999[233; 234) '1': u64"###
512 ); 1000 );
513} 1001}
514 1002
515#[test] 1003#[test]
516fn infer_function_generics() { 1004fn infer_function_generics() {
517 check_inference( 1005 assert_snapshot_matches!(
518 "infer_function_generics", 1006 infer(r#"
519 r#"
520fn id<T>(t: T) -> T { t } 1007fn id<T>(t: T) -> T { t }
521 1008
522fn test() { 1009fn test() {
@@ -524,15 +1011,29 @@ fn test() {
524 id::<i128>(1); 1011 id::<i128>(1);
525 let x: u64 = id(1); 1012 let x: u64 = id(1);
526} 1013}
527"#, 1014"#),
1015 @r###"
1016[10; 11) 't': T
1017[21; 26) '{ t }': T
1018[23; 24) 't': T
1019[38; 98) '{ ...(1); }': ()
1020[44; 46) 'id': fn id<u32>(T) -> T
1021[44; 52) 'id(1u32)': u32
1022[47; 51) '1u32': u32
1023[58; 68) 'id::<i128>': fn id<i128>(T) -> T
1024[58; 71) 'id::<i128>(1)': i128
1025[69; 70) '1': i128
1026[81; 82) 'x': u64
1027[90; 92) 'id': fn id<u64>(T) -> T
1028[90; 95) 'id(1)': u64
1029[93; 94) '1': u64"###
528 ); 1030 );
529} 1031}
530 1032
531#[test] 1033#[test]
532fn infer_impl_generics() { 1034fn infer_impl_generics() {
533 check_inference( 1035 assert_snapshot_matches!(
534 "infer_impl_generics", 1036 infer(r#"
535 r#"
536struct A<T1, T2> { 1037struct A<T1, T2> {
537 x: T1, 1038 x: T1,
538 y: T2, 1039 y: T2,
@@ -556,15 +1057,47 @@ fn test() -> i128 {
556 a.z(1i128); 1057 a.z(1i128);
557 a.z::<u128>(1); 1058 a.z::<u128>(1);
558} 1059}
559"#, 1060"#),
1061 @r###"
1062[74; 78) 'self': A<X, Y>
1063[85; 107) '{ ... }': X
1064[95; 99) 'self': A<X, Y>
1065[95; 101) 'self.x': X
1066[117; 121) 'self': A<X, Y>
1067[128; 150) '{ ... }': Y
1068[138; 142) 'self': A<X, Y>
1069[138; 144) 'self.y': Y
1070[163; 167) 'self': A<X, Y>
1071[169; 170) 't': T
1072[188; 223) '{ ... }': (X, Y, T)
1073[198; 217) '(self.....y, t)': (X, Y, T)
1074[199; 203) 'self': A<X, Y>
1075[199; 205) 'self.x': X
1076[207; 211) 'self': A<X, Y>
1077[207; 213) 'self.y': Y
1078[215; 216) 't': T
1079[245; 342) '{ ...(1); }': ()
1080[255; 256) 'a': A<u64, i64>
1081[259; 281) 'A { x:...1i64 }': A<u64, i64>
1082[266; 270) '1u64': u64
1083[275; 279) '1i64': i64
1084[287; 288) 'a': A<u64, i64>
1085[287; 292) 'a.x()': u64
1086[298; 299) 'a': A<u64, i64>
1087[298; 303) 'a.y()': i64
1088[309; 310) 'a': A<u64, i64>
1089[309; 319) 'a.z(1i128)': (u64, i64, i128)
1090[313; 318) '1i128': i128
1091[325; 326) 'a': A<u64, i64>
1092[325; 339) 'a.z::<u128>(1)': (u64, i64, u128)
1093[337; 338) '1': u128"###
560 ); 1094 );
561} 1095}
562 1096
563#[test] 1097#[test]
564fn infer_impl_generics_with_autoderef() { 1098fn infer_impl_generics_with_autoderef() {
565 check_inference( 1099 assert_snapshot_matches!(
566 "infer_impl_generics_with_autoderef", 1100 infer(r#"
567 r#"
568enum Option<T> { 1101enum Option<T> {
569 Some(T), 1102 Some(T),
570 None, 1103 None,
@@ -576,15 +1109,24 @@ fn test(o: Option<u32>) {
576 (&o).as_ref(); 1109 (&o).as_ref();
577 o.as_ref(); 1110 o.as_ref();
578} 1111}
579"#, 1112"#),
1113 @r###"
1114[78; 82) 'self': &Option<T>
1115[98; 100) '{}': ()
1116[111; 112) 'o': Option<u32>
1117[127; 165) '{ ...f(); }': ()
1118[133; 146) '(&o).as_ref()': Option<&u32>
1119[134; 136) '&o': &Option<u32>
1120[135; 136) 'o': Option<u32>
1121[152; 153) 'o': Option<u32>
1122[152; 162) 'o.as_ref()': Option<&u32>"###
580 ); 1123 );
581} 1124}
582 1125
583#[test] 1126#[test]
584fn infer_generic_chain() { 1127fn infer_generic_chain() {
585 check_inference( 1128 assert_snapshot_matches!(
586 "infer_generic_chain", 1129 infer(r#"
587 r#"
588struct A<T> { 1130struct A<T> {
589 x: T, 1131 x: T,
590} 1132}
@@ -603,15 +1145,44 @@ fn test() -> i128 {
603 let b = A { x: z }; 1145 let b = A { x: z };
604 b.x() 1146 b.x()
605} 1147}
606"#, 1148"#),
1149 @r###"
1150[53; 57) 'self': A<T2>
1151[65; 87) '{ ... }': T2
1152[75; 79) 'self': A<T2>
1153[75; 81) 'self.x': T2
1154[99; 100) 't': T
1155[110; 115) '{ t }': T
1156[112; 113) 't': T
1157[135; 261) '{ ....x() }': i128
1158[146; 147) 'x': i128
1159[150; 151) '1': i128
1160[162; 163) 'y': i128
1161[166; 168) 'id': fn id<i128>(T) -> T
1162[166; 171) 'id(x)': i128
1163[169; 170) 'x': i128
1164[182; 183) 'a': A<i128>
1165[186; 200) 'A { x: id(y) }': A<i128>
1166[193; 195) 'id': fn id<i128>(T) -> T
1167[193; 198) 'id(y)': i128
1168[196; 197) 'y': i128
1169[211; 212) 'z': i128
1170[215; 217) 'id': fn id<i128>(T) -> T
1171[215; 222) 'id(a.x)': i128
1172[218; 219) 'a': A<i128>
1173[218; 221) 'a.x': i128
1174[233; 234) 'b': A<i128>
1175[237; 247) 'A { x: z }': A<i128>
1176[244; 245) 'z': i128
1177[254; 255) 'b': A<i128>
1178[254; 259) 'b.x()': i128"###
607 ); 1179 );
608} 1180}
609 1181
610#[test] 1182#[test]
611fn infer_associated_const() { 1183fn infer_associated_const() {
612 check_inference( 1184 assert_snapshot_matches!(
613 "infer_associated_const", 1185 infer(r#"
614 r#"
615struct Struct; 1186struct Struct;
616 1187
617impl Struct { 1188impl Struct {
@@ -639,15 +1210,22 @@ fn test() {
639 let y = Enum::BAR; 1210 let y = Enum::BAR;
640 let z = TraitTest::ID; 1211 let z = TraitTest::ID;
641} 1212}
642"#, 1213"#),
1214 @r###"
1215[227; 305) '{ ...:ID; }': ()
1216[237; 238) 'x': u32
1217[241; 252) 'Struct::FOO': u32
1218[262; 263) 'y': u32
1219[266; 275) 'Enum::BAR': u32
1220[285; 286) 'z': u32
1221[289; 302) 'TraitTest::ID': u32"###
643 ); 1222 );
644} 1223}
645 1224
646#[test] 1225#[test]
647fn infer_associated_method_struct() { 1226fn infer_associated_method_struct() {
648 check_inference( 1227 assert_snapshot_matches!(
649 "infer_associated_method_struct", 1228 infer(r#"
650 r#"
651struct A { x: u32 }; 1229struct A { x: u32 };
652 1230
653impl A { 1231impl A {
@@ -659,15 +1237,24 @@ fn test() {
659 let a = A::new(); 1237 let a = A::new();
660 a.x; 1238 a.x;
661} 1239}
662"#, 1240"#),
1241 @r###"
1242[50; 76) '{ ... }': A
1243[60; 70) 'A { x: 0 }': A
1244[67; 68) '0': u32
1245[89; 123) '{ ...a.x; }': ()
1246[99; 100) 'a': A
1247[103; 109) 'A::new': fn new() -> A
1248[103; 111) 'A::new()': A
1249[117; 118) 'a': A
1250[117; 120) 'a.x': u32"###
663 ); 1251 );
664} 1252}
665 1253
666#[test] 1254#[test]
667fn infer_associated_method_enum() { 1255fn infer_associated_method_enum() {
668 check_inference( 1256 assert_snapshot_matches!(
669 "infer_associated_method_enum", 1257 infer(r#"
670 r#"
671enum A { B, C }; 1258enum A { B, C };
672 1259
673impl A { 1260impl A {
@@ -684,15 +1271,28 @@ fn test() {
684 let c = A::c(); 1271 let c = A::c();
685 c; 1272 c;
686} 1273}
687"#, 1274"#),
1275 @r###"
1276[48; 68) '{ ... }': A
1277[58; 62) 'A::B': A
1278[89; 109) '{ ... }': A
1279[99; 103) 'A::C': A
1280[122; 179) '{ ... c; }': ()
1281[132; 133) 'a': A
1282[136; 140) 'A::b': fn b() -> A
1283[136; 142) 'A::b()': A
1284[148; 149) 'a': A
1285[159; 160) 'c': A
1286[163; 167) 'A::c': fn c() -> A
1287[163; 169) 'A::c()': A
1288[175; 176) 'c': A"###
688 ); 1289 );
689} 1290}
690 1291
691#[test] 1292#[test]
692fn infer_associated_method_with_modules() { 1293fn infer_associated_method_with_modules() {
693 check_inference( 1294 assert_snapshot_matches!(
694 "infer_associated_method_with_modules", 1295 infer(r#"
695 r#"
696mod a { 1296mod a {
697 struct A; 1297 struct A;
698 impl A { pub fn thing() -> A { A {} }} 1298 impl A { pub fn thing() -> A { A {} }}
@@ -714,15 +1314,31 @@ fn test() {
714 let y = b::B::thing(); 1314 let y = b::B::thing();
715 let z = c::C::thing(); 1315 let z = c::C::thing();
716} 1316}
717"#, 1317"#),
1318 @r###"
1319[56; 64) '{ A {} }': A
1320[58; 62) 'A {}': A
1321[126; 132) '{ 99 }': u32
1322[128; 130) '99': u32
1323[202; 210) '{ C {} }': C
1324[204; 208) 'C {}': C
1325[241; 325) '{ ...g(); }': ()
1326[251; 252) 'x': A
1327[255; 266) 'a::A::thing': fn thing() -> A
1328[255; 268) 'a::A::thing()': A
1329[278; 279) 'y': u32
1330[282; 293) 'b::B::thing': fn thing() -> u32
1331[282; 295) 'b::B::thing()': u32
1332[305; 306) 'z': C
1333[309; 320) 'c::C::thing': fn thing() -> C
1334[309; 322) 'c::C::thing()': C"###
718 ); 1335 );
719} 1336}
720 1337
721#[test] 1338#[test]
722fn infer_associated_method_generics() { 1339fn infer_associated_method_generics() {
723 check_inference( 1340 assert_snapshot_matches!(
724 "infer_associated_method_generics", 1341 infer(r#"
725 r#"
726struct Gen<T> { 1342struct Gen<T> {
727 val: T 1343 val: T
728} 1344}
@@ -736,15 +1352,24 @@ impl<T> Gen<T> {
736fn test() { 1352fn test() {
737 let a = Gen::make(0u32); 1353 let a = Gen::make(0u32);
738} 1354}
739"#, 1355"#),
1356 @r###"
1357[64; 67) 'val': T
1358[82; 109) '{ ... }': Gen<T>
1359[92; 103) 'Gen { val }': Gen<T>
1360[98; 101) 'val': T
1361[123; 155) '{ ...32); }': ()
1362[133; 134) 'a': Gen<u32>
1363[137; 146) 'Gen::make': fn make<u32>(T) -> Gen<T>
1364[137; 152) 'Gen::make(0u32)': Gen<u32>
1365[147; 151) '0u32': u32"###
740 ); 1366 );
741} 1367}
742 1368
743#[test] 1369#[test]
744fn infer_type_alias() { 1370fn infer_type_alias() {
745 check_inference( 1371 assert_snapshot_matches!(
746 "infer_type_alias", 1372 infer(r#"
747 r#"
748struct A<X, Y> { x: X, y: Y }; 1373struct A<X, Y> { x: X, y: Y };
749type Foo = A<u32, i128>; 1374type Foo = A<u32, i128>;
750type Bar<T> = A<T, u128>; 1375type Bar<T> = A<T, u128>;
@@ -757,43 +1382,63 @@ fn test(x: Foo, y: Bar<&str>, z: Baz<i8, u8>) {
757 z.x; 1382 z.x;
758 z.y; 1383 z.y;
759} 1384}
760"#, 1385"#),
1386 @r###"
1387[117; 118) 'x': A<u32, i128>
1388[125; 126) 'y': A<&str, u128>
1389[139; 140) 'z': A<u8, i8>
1390[155; 212) '{ ...z.y; }': ()
1391[161; 162) 'x': A<u32, i128>
1392[161; 164) 'x.x': u32
1393[170; 171) 'x': A<u32, i128>
1394[170; 173) 'x.y': i128
1395[179; 180) 'y': A<&str, u128>
1396[179; 182) 'y.x': &str
1397[188; 189) 'y': A<&str, u128>
1398[188; 191) 'y.y': u128
1399[197; 198) 'z': A<u8, i8>
1400[197; 200) 'z.x': u8
1401[206; 207) 'z': A<u8, i8>
1402[206; 209) 'z.y': i8"###
761 ) 1403 )
762} 1404}
763 1405
764#[test] 1406#[test]
765#[should_panic] // we currently can't handle this 1407#[should_panic] // we currently can't handle this
766fn recursive_type_alias() { 1408fn recursive_type_alias() {
767 check_inference( 1409 assert_snapshot_matches!(
768 "recursive_type_alias", 1410 infer(r#"
769 r#"
770struct A<X> {}; 1411struct A<X> {};
771type Foo = Foo; 1412type Foo = Foo;
772type Bar = A<Bar>; 1413type Bar = A<Bar>;
773fn test(x: Foo) {} 1414fn test(x: Foo) {}
774"#, 1415"#),
1416 @""
775 ) 1417 )
776} 1418}
777 1419
778#[test] 1420#[test]
779fn no_panic_on_field_of_enum() { 1421fn no_panic_on_field_of_enum() {
780 check_inference( 1422 assert_snapshot_matches!(
781 "no_panic_on_field_of_enum", 1423 infer(r#"
782 r#"
783enum X {} 1424enum X {}
784 1425
785fn test(x: X) { 1426fn test(x: X) {
786 x.some_field; 1427 x.some_field;
787} 1428}
788"#, 1429"#),
1430 @r###"
1431[20; 21) 'x': X
1432[26; 47) '{ ...eld; }': ()
1433[32; 33) 'x': X
1434[32; 44) 'x.some_field': {unknown}"###
789 ); 1435 );
790} 1436}
791 1437
792#[test] 1438#[test]
793fn bug_585() { 1439fn bug_585() {
794 check_inference( 1440 assert_snapshot_matches!(
795 "bug_585", 1441 infer(r#"
796 r#"
797fn test() { 1442fn test() {
798 X {}; 1443 X {};
799 match x { 1444 match x {
@@ -801,20 +1446,35 @@ fn test() {
801 A::Y() => (), 1446 A::Y() => (),
802 } 1447 }
803} 1448}
804"#, 1449"#),
1450 @r###"
1451[11; 89) '{ ... } }': ()
1452[17; 21) 'X {}': {unknown}
1453[27; 87) 'match ... }': ()
1454[33; 34) 'x': {unknown}
1455[45; 52) 'A::B {}': {unknown}
1456[56; 58) '()': ()
1457[68; 74) 'A::Y()': {unknown}
1458[78; 80) '()': ()"###
805 ); 1459 );
806} 1460}
807 1461
808#[test] 1462#[test]
809fn bug_651() { 1463fn bug_651() {
810 check_inference( 1464 assert_snapshot_matches!(
811 "bug_651", 1465 infer(r#"
812 r#"
813fn quux() { 1466fn quux() {
814 let y = 92; 1467 let y = 92;
815 1 + y; 1468 1 + y;
816} 1469}
817"#, 1470"#),
1471 @r###"
1472[11; 41) '{ ...+ y; }': ()
1473[21; 22) 'y': i32
1474[25; 27) '92': i32
1475[33; 34) '1': i32
1476[33; 38) '1 + y': i32
1477[37; 38) 'y': i32"###
818 ); 1478 );
819} 1479}
820 1480
@@ -822,14 +1482,21 @@ fn quux() {
822fn recursive_vars() { 1482fn recursive_vars() {
823 covers!(type_var_cycles_resolve_completely); 1483 covers!(type_var_cycles_resolve_completely);
824 covers!(type_var_cycles_resolve_as_possible); 1484 covers!(type_var_cycles_resolve_as_possible);
825 check_inference( 1485 assert_snapshot_matches!(
826 "recursive_vars", 1486 infer(r#"
827 r#"
828fn test() { 1487fn test() {
829 let y = unknown; 1488 let y = unknown;
830 [y, &y]; 1489 [y, &y];
831} 1490}
832"#, 1491"#),
1492 @r###"
1493[11; 48) '{ ...&y]; }': ()
1494[21; 22) 'y': &{unknown}
1495[25; 32) 'unknown': &{unknown}
1496[38; 45) '[y, &y]': [&&{unknown}]
1497[39; 40) 'y': &{unknown}
1498[42; 44) '&y': &&{unknown}
1499[43; 44) 'y': &{unknown}"###
833 ); 1500 );
834} 1501}
835 1502
@@ -837,23 +1504,36 @@ fn test() {
837fn recursive_vars_2() { 1504fn recursive_vars_2() {
838 covers!(type_var_cycles_resolve_completely); 1505 covers!(type_var_cycles_resolve_completely);
839 covers!(type_var_cycles_resolve_as_possible); 1506 covers!(type_var_cycles_resolve_as_possible);
840 check_inference( 1507 assert_snapshot_matches!(
841 "recursive_vars_2", 1508 infer(r#"
842 r#"
843fn test() { 1509fn test() {
844 let x = unknown; 1510 let x = unknown;
845 let y = unknown; 1511 let y = unknown;
846 [(x, y), (&y, &x)]; 1512 [(x, y), (&y, &x)];
847} 1513}
848"#, 1514"#),
1515 @r###"
1516[11; 80) '{ ...x)]; }': ()
1517[21; 22) 'x': &&{unknown}
1518[25; 32) 'unknown': &&{unknown}
1519[42; 43) 'y': &&{unknown}
1520[46; 53) 'unknown': &&{unknown}
1521[59; 77) '[(x, y..., &x)]': [(&&{unknown}, &&{unknown})]
1522[60; 66) '(x, y)': (&&{unknown}, &&{unknown})
1523[61; 62) 'x': &&{unknown}
1524[64; 65) 'y': &&{unknown}
1525[68; 76) '(&y, &x)': (&&&{unknown}, &&&{unknown})
1526[69; 71) '&y': &&&{unknown}
1527[70; 71) 'y': &&{unknown}
1528[73; 75) '&x': &&&{unknown}
1529[74; 75) 'x': &&{unknown}"###
849 ); 1530 );
850} 1531}
851 1532
852#[test] 1533#[test]
853fn infer_type_param() { 1534fn infer_type_param() {
854 check_inference( 1535 assert_snapshot_matches!(
855 "infer_type_param", 1536 infer(r#"
856 r#"
857fn id<T>(x: T) -> T { 1537fn id<T>(x: T) -> T {
858 x 1538 x
859} 1539}
@@ -868,16 +1548,35 @@ fn test() {
868 let x: bool = clone(z); 1548 let x: bool = clone(z);
869 id::<i128>(1); 1549 id::<i128>(1);
870} 1550}
871"#, 1551"#),
1552 @r###"
1553[10; 11) 'x': T
1554[21; 30) '{ x }': T
1555[27; 28) 'x': T
1556[44; 45) 'x': &T
1557[56; 65) '{ x }': &T
1558[62; 63) 'x': &T
1559[77; 157) '{ ...(1); }': ()
1560[87; 88) 'y': u32
1561[91; 96) '10u32': u32
1562[102; 104) 'id': fn id<u32>(T) -> T
1563[102; 107) 'id(y)': u32
1564[105; 106) 'y': u32
1565[117; 118) 'x': bool
1566[127; 132) 'clone': fn clone<bool>(&T) -> T
1567[127; 135) 'clone(z)': bool
1568[133; 134) 'z': &bool
1569[141; 151) 'id::<i128>': fn id<i128>(T) -> T
1570[141; 154) 'id::<i128>(1)': i128
1571[152; 153) '1': i128"###
872 ); 1572 );
873} 1573}
874 1574
875#[test] 1575#[test]
876fn infer_std_crash_1() { 1576fn infer_std_crash_1() {
877 // caused stack overflow, taken from std 1577 // caused stack overflow, taken from std
878 check_inference( 1578 assert_snapshot_matches!(
879 "infer_std_crash_1", 1579 infer(r#"
880 r#"
881enum Maybe<T> { 1580enum Maybe<T> {
882 Real(T), 1581 Real(T),
883 Fake, 1582 Fake,
@@ -888,7 +1587,14 @@ fn write() {
888 Maybe::Real(ref mut something) => (), 1587 Maybe::Real(ref mut something) => (),
889 } 1588 }
890} 1589}
891"#, 1590"#),
1591 @r###"
1592[54; 139) '{ ... } }': ()
1593[60; 137) 'match ... }': ()
1594[66; 83) 'someth...nknown': Maybe<{unknown}>
1595[94; 124) 'Maybe:...thing)': Maybe<{unknown}>
1596[106; 123) 'ref mu...ething': &mut {unknown}
1597[128; 130) '()': ()"###
892 ); 1598 );
893} 1599}
894 1600
@@ -896,52 +1602,73 @@ fn write() {
896fn infer_std_crash_2() { 1602fn infer_std_crash_2() {
897 covers!(type_var_resolves_to_int_var); 1603 covers!(type_var_resolves_to_int_var);
898 // caused "equating two type variables, ...", taken from std 1604 // caused "equating two type variables, ...", taken from std
899 check_inference( 1605 assert_snapshot_matches!(
900 "infer_std_crash_2", 1606 infer(r#"
901 r#"
902fn test_line_buffer() { 1607fn test_line_buffer() {
903 &[0, b'\n', 1, b'\n']; 1608 &[0, b'\n', 1, b'\n'];
904} 1609}
905"#, 1610"#),
1611 @r###"
1612[23; 53) '{ ...n']; }': ()
1613[29; 50) '&[0, b...b'\n']': &[u8]
1614[30; 50) '[0, b'...b'\n']': [u8]
1615[31; 32) '0': u8
1616[34; 39) 'b'\n'': u8
1617[41; 42) '1': u8
1618[44; 49) 'b'\n'': u8"###
906 ); 1619 );
907} 1620}
908 1621
909#[test] 1622#[test]
910fn infer_std_crash_3() { 1623fn infer_std_crash_3() {
911 // taken from rustc 1624 // taken from rustc
912 check_inference( 1625 assert_snapshot_matches!(
913 "infer_std_crash_3", 1626 infer(r#"
914 r#"
915pub fn compute() { 1627pub fn compute() {
916 match _ { 1628 match _ {
917 SizeSkeleton::Pointer { non_zero: true, tail } => {} 1629 SizeSkeleton::Pointer { non_zero: true, tail } => {}
918 } 1630 }
919} 1631}
920"#, 1632"#),
1633 @r###"
1634[18; 102) '{ ... } }': ()
1635[24; 100) 'match ... }': ()
1636[42; 88) 'SizeSk...tail }': {unknown}
1637[76; 80) 'true': {unknown}
1638[82; 86) 'tail': {unknown}
1639[92; 94) '{}': ()"###
921 ); 1640 );
922} 1641}
923 1642
924#[test] 1643#[test]
925fn infer_std_crash_4() { 1644fn infer_std_crash_4() {
926 // taken from rustc 1645 // taken from rustc
927 check_inference( 1646 assert_snapshot_matches!(
928 "infer_std_crash_4", 1647 infer(r#"
929 r#"
930pub fn primitive_type() { 1648pub fn primitive_type() {
931 match *self { 1649 match *self {
932 BorrowedRef { type_: box Primitive(p), ..} => {}, 1650 BorrowedRef { type_: box Primitive(p), ..} => {},
933 } 1651 }
934} 1652}
935"#, 1653"#),
1654 @r###"
1655[25; 110) '{ ... } }': ()
1656[31; 108) 'match ... }': ()
1657[37; 42) '*self': {unknown}
1658[38; 42) 'self': {unknown}
1659[53; 95) 'Borrow...), ..}': {unknown}
1660[74; 77) 'box': {unknown}
1661[78; 87) 'Primitive': {unknown}
1662[88; 89) 'p': {unknown}
1663[99; 101) '{}': ()"###
936 ); 1664 );
937} 1665}
938 1666
939#[test] 1667#[test]
940fn infer_std_crash_5() { 1668fn infer_std_crash_5() {
941 // taken from rustc 1669 // taken from rustc
942 check_inference( 1670 assert_snapshot_matches!(
943 "infer_std_crash_5", 1671 infer(r#"
944 r#"
945fn extra_compiler_flags() { 1672fn extra_compiler_flags() {
946 for content in doesnt_matter { 1673 for content in doesnt_matter {
947 let name = if doesnt_matter { 1674 let name = if doesnt_matter {
@@ -957,16 +1684,39 @@ fn extra_compiler_flags() {
957 }; 1684 };
958 } 1685 }
959} 1686}
960"#, 1687"#),
1688 @r###"
1689[27; 323) '{ ... } }': ()
1690[33; 321) 'for co... }': ()
1691[37; 44) 'content': &{unknown}
1692[48; 61) 'doesnt_matter': {unknown}
1693[62; 321) '{ ... }': ()
1694[76; 80) 'name': &&{unknown}
1695[83; 167) 'if doe... }': &&{unknown}
1696[86; 99) 'doesnt_matter': bool
1697[100; 129) '{ ... }': &&{unknown}
1698[114; 119) 'first': &&{unknown}
1699[135; 167) '{ ... }': &&{unknown}
1700[149; 157) '&content': &&{unknown}
1701[150; 157) 'content': &{unknown}
1702[182; 189) 'content': &&{unknown}
1703[192; 314) 'if ICE... }': &&{unknown}
1704[195; 232) 'ICE_RE..._VALUE': {unknown}
1705[195; 248) 'ICE_RE...&name)': bool
1706[242; 247) '&name': &&&{unknown}
1707[243; 247) 'name': &&{unknown}
1708[249; 277) '{ ... }': &&{unknown}
1709[263; 267) 'name': &&{unknown}
1710[283; 314) '{ ... }': &{unknown}
1711[297; 304) 'content': &{unknown}"###
961 ); 1712 );
962} 1713}
963 1714
964#[test] 1715#[test]
965fn infer_nested_generics_crash() { 1716fn infer_nested_generics_crash() {
966 // another crash found typechecking rustc 1717 // another crash found typechecking rustc
967 check_inference( 1718 assert_snapshot_matches!(
968 "infer_nested_generics_crash", 1719 infer(r#"
969 r#"
970struct Canonical<V> { 1720struct Canonical<V> {
971 value: V, 1721 value: V,
972} 1722}
@@ -976,7 +1726,13 @@ struct QueryResponse<V> {
976fn test<R>(query_response: Canonical<QueryResponse<R>>) { 1726fn test<R>(query_response: Canonical<QueryResponse<R>>) {
977 &query_response.value; 1727 &query_response.value;
978} 1728}
979"#, 1729"#),
1730 @r###"
1731[92; 106) 'query_response': Canonical<QueryResponse<R>>
1732[137; 167) '{ ...lue; }': ()
1733[143; 164) '&query....value': &QueryResponse<R>
1734[144; 158) 'query_response': Canonical<QueryResponse<R>>
1735[144; 164) 'query_....value': QueryResponse<R>"###
980 ); 1736 );
981} 1737}
982 1738
@@ -1008,9 +1764,8 @@ mod foo {
1008 1764
1009#[test] 1765#[test]
1010fn infer_const() { 1766fn infer_const() {
1011 check_inference( 1767 assert_snapshot_matches!(
1012 "infer_const", 1768 infer(r#"
1013 r#"
1014struct Foo; 1769struct Foo;
1015impl Foo { const ASSOC_CONST: u32 = 0; } 1770impl Foo { const ASSOC_CONST: u32 = 0; }
1016const GLOBAL_CONST: u32 = 101; 1771const GLOBAL_CONST: u32 = 101;
@@ -1020,15 +1775,22 @@ fn test() {
1020 let z = GLOBAL_CONST; 1775 let z = GLOBAL_CONST;
1021 let id = Foo::ASSOC_CONST; 1776 let id = Foo::ASSOC_CONST;
1022} 1777}
1023"#, 1778"#),
1779 @r###"
1780[95; 213) '{ ...NST; }': ()
1781[138; 139) 'x': {unknown}
1782[142; 153) 'LOCAL_CONST': {unknown}
1783[163; 164) 'z': u32
1784[167; 179) 'GLOBAL_CONST': u32
1785[189; 191) 'id': u32
1786[194; 210) 'Foo::A..._CONST': u32"###
1024 ); 1787 );
1025} 1788}
1026 1789
1027#[test] 1790#[test]
1028fn infer_static() { 1791fn infer_static() {
1029 check_inference( 1792 assert_snapshot_matches!(
1030 "infer_static", 1793 infer(r#"
1031 r#"
1032static GLOBAL_STATIC: u32 = 101; 1794static GLOBAL_STATIC: u32 = 101;
1033static mut GLOBAL_STATIC_MUT: u32 = 101; 1795static mut GLOBAL_STATIC_MUT: u32 = 101;
1034fn test() { 1796fn test() {
@@ -1039,7 +1801,336 @@ fn test() {
1039 let z = GLOBAL_STATIC; 1801 let z = GLOBAL_STATIC;
1040 let w = GLOBAL_STATIC_MUT; 1802 let w = GLOBAL_STATIC_MUT;
1041} 1803}
1042"#, 1804"#),
1805 @r###"
1806[85; 280) '{ ...MUT; }': ()
1807[173; 174) 'x': {unknown}
1808[177; 189) 'LOCAL_STATIC': {unknown}
1809[199; 200) 'y': {unknown}
1810[203; 219) 'LOCAL_...IC_MUT': {unknown}
1811[229; 230) 'z': u32
1812[233; 246) 'GLOBAL_STATIC': u32
1813[256; 257) 'w': u32
1814[260; 277) 'GLOBAL...IC_MUT': u32"###
1815 );
1816}
1817
1818#[test]
1819fn infer_trait_method_simple() {
1820 // the trait implementation is intentionally incomplete -- it shouldn't matter
1821 assert_snapshot_matches!(
1822 infer(r#"
1823trait Trait1 {
1824 fn method(&self) -> u32;
1825}
1826struct S1;
1827impl Trait1 for S1 {}
1828trait Trait2 {
1829 fn method(&self) -> i128;
1830}
1831struct S2;
1832impl Trait2 for S2 {}
1833fn test() {
1834 S1.method(); // -> u32
1835 S2.method(); // -> i128
1836}
1837"#),
1838 @r###"
1839[31; 35) 'self': &{unknown}
1840[110; 114) 'self': &{unknown}
1841[170; 228) '{ ...i128 }': ()
1842[176; 178) 'S1': S1
1843[176; 187) 'S1.method()': {unknown}
1844[203; 205) 'S2': S2
1845[203; 214) 'S2.method()': {unknown}"###
1846 );
1847}
1848
1849#[test]
1850fn infer_trait_method_scoped() {
1851 // the trait implementation is intentionally incomplete -- it shouldn't matter
1852 assert_snapshot_matches!(
1853 infer(r#"
1854struct S;
1855mod foo {
1856 pub trait Trait1 {
1857 fn method(&self) -> u32;
1858 }
1859 impl Trait1 for super::S {}
1860}
1861mod bar {
1862 pub trait Trait2 {
1863 fn method(&self) -> i128;
1864 }
1865 impl Trait2 for super::S {}
1866}
1867
1868mod foo_test {
1869 use super::S;
1870 use super::foo::Trait1;
1871 fn test() {
1872 S.method(); // -> u32
1873 }
1874}
1875
1876mod bar_test {
1877 use super::S;
1878 use super::bar::Trait2;
1879 fn test() {
1880 S.method(); // -> i128
1881 }
1882}
1883"#),
1884 @r###"
1885[63; 67) 'self': &{unknown}
1886[169; 173) 'self': &{unknown}
1887[300; 337) '{ ... }': ()
1888[310; 311) 'S': S
1889[310; 320) 'S.method()': {unknown}
1890[416; 454) '{ ... }': ()
1891[426; 427) 'S': S
1892[426; 436) 'S.method()': {unknown}"###
1893 );
1894}
1895
1896#[test]
1897fn infer_trait_method_generic_1() {
1898 // the trait implementation is intentionally incomplete -- it shouldn't matter
1899 assert_snapshot_matches!(
1900 infer(r#"
1901trait Trait<T> {
1902 fn method(&self) -> T;
1903}
1904struct S;
1905impl Trait<u32> for S {}
1906fn test() {
1907 S.method();
1908}
1909"#),
1910 @r###"
1911[33; 37) 'self': &{unknown}
1912[92; 111) '{ ...d(); }': ()
1913[98; 99) 'S': S
1914[98; 108) 'S.method()': {unknown}"###
1915 );
1916}
1917
1918#[test]
1919fn infer_trait_method_generic_2() {
1920 // the trait implementation is intentionally incomplete -- it shouldn't matter
1921 assert_snapshot_matches!(
1922 infer(r#"
1923trait Trait<T> {
1924 fn method(&self) -> T;
1925}
1926struct S<T>(T);
1927impl<U> Trait<U> for S<U> {}
1928fn test() {
1929 S(1u32).method();
1930}
1931"#),
1932 @r###"
1933[33; 37) 'self': &{unknown}
1934[102; 127) '{ ...d(); }': ()
1935[108; 109) 'S': S<u32>(T) -> S<T>
1936[108; 115) 'S(1u32)': S<u32>
1937[108; 124) 'S(1u32...thod()': {unknown}
1938[110; 114) '1u32': u32"###
1939 );
1940}
1941
1942#[test]
1943fn infer_trait_assoc_method() {
1944 assert_snapshot_matches!(
1945 infer(r#"
1946trait Default {
1947 fn default() -> Self;
1948}
1949struct S;
1950impl Default for S {}
1951fn test() {
1952 let s1: S = Default::default();
1953 let s2 = S::default();
1954 let s3 = <S as Default>::default();
1955}
1956"#),
1957 @r###"
1958[87; 193) '{ ...t(); }': ()
1959[97; 99) 's1': S
1960[105; 121) 'Defaul...efault': {unknown}
1961[105; 123) 'Defaul...ault()': S
1962[133; 135) 's2': {unknown}
1963[138; 148) 'S::default': {unknown}
1964[138; 150) 'S::default()': {unknown}
1965[160; 162) 's3': {unknown}
1966[165; 188) '<S as ...efault': {unknown}
1967[165; 190) '<S as ...ault()': {unknown}"###
1968 );
1969}
1970
1971#[test]
1972fn infer_from_bound_1() {
1973 assert_snapshot_matches!(
1974 infer(r#"
1975trait Trait<T> {}
1976struct S<T>(T);
1977impl<U> Trait<U> for S<U> {}
1978fn foo<T: Trait<u32>>(t: T) {}
1979fn test() {
1980 let s = S(unknown);
1981 foo(s);
1982}
1983"#),
1984 @r###"
1985[86; 87) 't': T
1986[92; 94) '{}': ()
1987[105; 144) '{ ...(s); }': ()
1988[115; 116) 's': S<{unknown}>
1989[119; 120) 'S': S<{unknown}>(T) -> S<T>
1990[119; 129) 'S(unknown)': S<{unknown}>
1991[121; 128) 'unknown': {unknown}
1992[135; 138) 'foo': fn foo<S<{unknown}>>(T) -> ()
1993[135; 141) 'foo(s)': ()
1994[139; 140) 's': S<{unknown}>"###
1995 );
1996}
1997
1998#[test]
1999fn infer_from_bound_2() {
2000 assert_snapshot_matches!(
2001 infer(r#"
2002trait Trait<T> {}
2003struct S<T>(T);
2004impl<U> Trait<U> for S<U> {}
2005fn foo<U, T: Trait<U>>(t: T) -> U {}
2006fn test() {
2007 let s = S(unknown);
2008 let x: u32 = foo(s);
2009}
2010"#),
2011 @r###"
2012[87; 88) 't': T
2013[98; 100) '{}': ()
2014[111; 163) '{ ...(s); }': ()
2015[121; 122) 's': S<{unknown}>
2016[125; 126) 'S': S<{unknown}>(T) -> S<T>
2017[125; 135) 'S(unknown)': S<{unknown}>
2018[127; 134) 'unknown': {unknown}
2019[145; 146) 'x': u32
2020[154; 157) 'foo': fn foo<u32, S<{unknown}>>(T) -> U
2021[154; 160) 'foo(s)': u32
2022[158; 159) 's': S<{unknown}>"###
2023 );
2024}
2025
2026#[test]
2027fn infer_call_trait_method_on_generic_param_1() {
2028 assert_snapshot_matches!(
2029 infer(r#"
2030trait Trait {
2031 fn method() -> u32;
2032}
2033fn test<T: Trait>(t: T) {
2034 t.method();
2035}
2036"#),
2037 @r###"
2038[59; 60) 't': T
2039[65; 84) '{ ...d(); }': ()
2040[71; 72) 't': T
2041[71; 81) 't.method()': {unknown}"###
2042 );
2043}
2044
2045#[test]
2046fn infer_call_trait_method_on_generic_param_2() {
2047 assert_snapshot_matches!(
2048 infer(r#"
2049trait Trait<T> {
2050 fn method() -> T;
2051}
2052fn test<U, T: Trait<U>>(t: T) {
2053 t.method();
2054}
2055"#),
2056 @r###"
2057[66; 67) 't': T
2058[72; 91) '{ ...d(); }': ()
2059[78; 79) 't': T
2060[78; 88) 't.method()': {unknown}"###
2061 );
2062}
2063
2064#[test]
2065fn infer_with_multiple_trait_impls() {
2066 assert_snapshot_matches!(
2067 infer(r#"
2068trait Into<T> {
2069 fn into(self) -> T;
2070}
2071struct S;
2072impl Into<u32> for S;
2073impl Into<u64> for S;
2074fn test() {
2075 let x: u32 = S.into();
2076 let y: u64 = S.into();
2077 let z = Into::<u64>::into(S);
2078}
2079"#),
2080 @r###"
2081[29; 33) 'self': {unknown}
2082[107; 198) '{ ...(S); }': ()
2083[117; 118) 'x': u32
2084[126; 127) 'S': S
2085[126; 134) 'S.into()': u32
2086[144; 145) 'y': u64
2087[153; 154) 'S': S
2088[153; 161) 'S.into()': u64
2089[171; 172) 'z': {unknown}
2090[175; 192) 'Into::...::into': {unknown}
2091[175; 195) 'Into::...nto(S)': {unknown}
2092[193; 194) 'S': S"###
2093 );
2094}
2095
2096#[test]
2097fn infer_project_associated_type() {
2098 assert_snapshot_matches!(
2099 infer(r#"
2100trait Iterable {
2101 type Item;
2102}
2103struct S;
2104impl Iterable for S { type Item = u32; }
2105fn test<T: Iterable>() {
2106 let x: <S as Iterable>::Item = 1;
2107 let y: T::Item = no_matter;
2108}
2109"#),
2110 @r###"
2111[108; 181) '{ ...ter; }': ()
2112[118; 119) 'x': i32
2113[145; 146) '1': i32
2114[156; 157) 'y': {unknown}
2115[169; 178) 'no_matter': {unknown}"###
2116 );
2117}
2118
2119#[test]
2120fn infer_associated_type_bound() {
2121 assert_snapshot_matches!(
2122 infer(r#"
2123trait Iterable {
2124 type Item;
2125}
2126fn test<T: Iterable<Item=u32>>() {
2127 let y: T::Item = unknown;
2128}
2129"#),
2130 @r###"
2131[67; 100) '{ ...own; }': ()
2132[77; 78) 'y': {unknown}
2133[90; 97) 'unknown': {unknown}"###
1043 ); 2134 );
1044} 2135}
1045 2136
@@ -1058,6 +2149,7 @@ fn infer(content: &str) -> String {
1058 let (db, _, file_id) = MockDatabase::with_single_file(content); 2149 let (db, _, file_id) = MockDatabase::with_single_file(content);
1059 let source_file = db.parse(file_id); 2150 let source_file = db.parse(file_id);
1060 let mut acc = String::new(); 2151 let mut acc = String::new();
2152 acc.push_str("\n");
1061 for fn_def in source_file.syntax().descendants().filter_map(ast::FnDef::cast) { 2153 for fn_def in source_file.syntax().descendants().filter_map(ast::FnDef::cast) {
1062 let func = source_binder::function_from_source(&db, file_id, fn_def).unwrap(); 2154 let func = source_binder::function_from_source(&db, file_id, fn_def).unwrap();
1063 let inference_result = func.infer(&db); 2155 let inference_result = func.infer(&db);
@@ -1091,15 +2183,10 @@ fn infer(content: &str) -> String {
1091 .unwrap(); 2183 .unwrap();
1092 } 2184 }
1093 } 2185 }
2186 acc.truncate(acc.trim_end().len());
1094 acc 2187 acc
1095} 2188}
1096 2189
1097fn check_inference(name: &str, content: &str) {
1098 let result = infer(content);
1099
1100 insta::assert_snapshot_matches!(&name, &result);
1101}
1102
1103fn ellipsize(mut text: String, max_len: usize) -> String { 2190fn ellipsize(mut text: String, max_len: usize) -> String {
1104 if text.len() <= max_len { 2191 if text.len() <= max_len {
1105 return text; 2192 return text;
diff --git a/crates/ra_ide_api/src/hover.rs b/crates/ra_ide_api/src/hover.rs
index 4722206e2..8ec60090d 100644
--- a/crates/ra_ide_api/src/hover.rs
+++ b/crates/ra_ide_api/src/hover.rs
@@ -474,7 +474,7 @@ mod tests {
474 ); 474 );
475 475
476 let type_name = analysis.type_of(range).unwrap().unwrap(); 476 let type_name = analysis.type_of(range).unwrap().unwrap();
477 assert_eq!("[unknown]", &type_name); 477 assert_eq!("{unknown}", &type_name);
478 } 478 }
479 479
480 #[test] 480 #[test]
diff --git a/editors/emacs/ra-emacs-lsp.el b/editors/emacs/ra-emacs-lsp.el
index 4af65c7f0..780182f8a 100644
--- a/editors/emacs/ra-emacs-lsp.el
+++ b/editors/emacs/ra-emacs-lsp.el
@@ -138,7 +138,7 @@
138 (add-hook 'rust-mode-hook 'rust-analyzer--add-er-expansion)) 138 (add-hook 'rust-mode-hook 'rust-analyzer--add-er-expansion))
139 139
140;; runnables 140;; runnables
141(defvar rust-analyzer--last-runnable) 141(defvar rust-analyzer--last-runnable nil)
142 142
143(defun rust-analyzer--runnables-params () 143(defun rust-analyzer--runnables-params ()
144 (list :textDocument (lsp--text-document-identifier) 144 (list :textDocument (lsp--text-document-identifier)