diff options
-rw-r--r-- | crates/ra_hir/src/ty/tests.rs | 25 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/tests/data/backwards.txt (renamed from crates/ra_hir/src/ty/tests/data/0006_backwards.txt) | 30 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/tests/data/basics.txt (renamed from crates/ra_hir/src/ty/tests/data/0001_basics.txt) | 16 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/tests/data/boolean_op.txt (renamed from crates/ra_hir/src/ty/tests/data/0008_boolean_op.txt) | 46 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/tests/data/let.txt (renamed from crates/ra_hir/src/ty/tests/data/0002_let.txt) | 6 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/tests/data/paths.txt (renamed from crates/ra_hir/src/ty/tests/data/0003_paths.txt) | 4 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/tests/data/refs_and_ptrs.txt (renamed from crates/ra_hir/src/ty/tests/data/0005_refs.txt) | 32 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/tests/data/self.txt (renamed from crates/ra_hir/src/ty/tests/data/0007_self.txt) | 4 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/tests/data/struct.txt (renamed from crates/ra_hir/src/ty/tests/data/0004_struct.txt) | 22 |
9 files changed, 93 insertions, 92 deletions
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index e46f309ae..20fb783b8 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs | |||
@@ -4,7 +4,6 @@ use std::path::{PathBuf, Path}; | |||
4 | use std::fs; | 4 | use std::fs; |
5 | 5 | ||
6 | use salsa::Database; | 6 | use salsa::Database; |
7 | use rustc_hash::FxHashMap; | ||
8 | 7 | ||
9 | use ra_db::SyntaxDatabase; | 8 | use ra_db::SyntaxDatabase; |
10 | use ra_syntax::ast::{self, AstNode}; | 9 | use ra_syntax::ast::{self, AstNode}; |
@@ -35,7 +34,7 @@ fn test(a: u32, b: isize, c: !, d: &str) { | |||
35 | "test"; | 34 | "test"; |
36 | 1.0f32; | 35 | 1.0f32; |
37 | }"#, | 36 | }"#, |
38 | "0001_basics.txt", | 37 | "basics.txt", |
39 | ); | 38 | ); |
40 | } | 39 | } |
41 | 40 | ||
@@ -49,7 +48,7 @@ fn test() { | |||
49 | let c = b; | 48 | let c = b; |
50 | } | 49 | } |
51 | }"#, | 50 | }"#, |
52 | "0002_let.txt", | 51 | "let.txt", |
53 | ); | 52 | ); |
54 | } | 53 | } |
55 | 54 | ||
@@ -68,7 +67,7 @@ fn test() { | |||
68 | b::c(); | 67 | b::c(); |
69 | } | 68 | } |
70 | }"#, | 69 | }"#, |
71 | "0003_paths.txt", | 70 | "paths.txt", |
72 | ); | 71 | ); |
73 | } | 72 | } |
74 | 73 | ||
@@ -91,7 +90,7 @@ fn test() { | |||
91 | a.c; | 90 | a.c; |
92 | } | 91 | } |
93 | "#, | 92 | "#, |
94 | "0004_struct.txt", | 93 | "struct.txt", |
95 | ); | 94 | ); |
96 | } | 95 | } |
97 | 96 | ||
@@ -113,7 +112,7 @@ fn test(a: &u32, b: &mut u32, c: *const u32, d: *mut u32) { | |||
113 | *d; | 112 | *d; |
114 | } | 113 | } |
115 | "#, | 114 | "#, |
116 | "0005_refs.txt", | 115 | "refs_and_ptrs.txt", |
117 | ); | 116 | ); |
118 | } | 117 | } |
119 | 118 | ||
@@ -134,7 +133,7 @@ fn test() -> &mut &f64 { | |||
134 | &mut &c | 133 | &mut &c |
135 | } | 134 | } |
136 | "#, | 135 | "#, |
137 | "0006_backwards.txt", | 136 | "backwards.txt", |
138 | ); | 137 | ); |
139 | } | 138 | } |
140 | 139 | ||
@@ -153,7 +152,7 @@ impl S { | |||
153 | } | 152 | } |
154 | } | 153 | } |
155 | "#, | 154 | "#, |
156 | "0007_self.txt", | 155 | "self.txt", |
157 | ); | 156 | ); |
158 | } | 157 | } |
159 | 158 | ||
@@ -177,7 +176,7 @@ fn test() { | |||
177 | 10 < 3 | 176 | 10 < 3 |
178 | } | 177 | } |
179 | "#, | 178 | "#, |
180 | "0008_boolean_op.txt", | 179 | "boolean_op.txt", |
181 | ); | 180 | ); |
182 | } | 181 | } |
183 | 182 | ||
@@ -195,14 +194,14 @@ fn infer(content: &str) -> String { | |||
195 | .unwrap(); | 194 | .unwrap(); |
196 | let inference_result = func.infer(&db).unwrap(); | 195 | let inference_result = func.infer(&db).unwrap(); |
197 | let body_syntax_mapping = func.body_syntax_mapping(&db).unwrap(); | 196 | let body_syntax_mapping = func.body_syntax_mapping(&db).unwrap(); |
198 | let mut types = FxHashMap::default(); | 197 | let mut types = Vec::new(); |
199 | for (pat, ty) in &inference_result.type_of_pat { | 198 | for (pat, ty) in &inference_result.type_of_pat { |
200 | let syntax_ptr = if let Some(sp) = body_syntax_mapping.pat_syntax(*pat) { | 199 | let syntax_ptr = if let Some(sp) = body_syntax_mapping.pat_syntax(*pat) { |
201 | sp | 200 | sp |
202 | } else { | 201 | } else { |
203 | continue; | 202 | continue; |
204 | }; | 203 | }; |
205 | types.insert(syntax_ptr, ty); | 204 | types.push((syntax_ptr, ty)); |
206 | } | 205 | } |
207 | for (expr, ty) in &inference_result.type_of_expr { | 206 | for (expr, ty) in &inference_result.type_of_expr { |
208 | let syntax_ptr = if let Some(sp) = body_syntax_mapping.expr_syntax(*expr) { | 207 | let syntax_ptr = if let Some(sp) = body_syntax_mapping.expr_syntax(*expr) { |
@@ -210,8 +209,10 @@ fn infer(content: &str) -> String { | |||
210 | } else { | 209 | } else { |
211 | continue; | 210 | continue; |
212 | }; | 211 | }; |
213 | types.insert(syntax_ptr, ty); | 212 | types.push((syntax_ptr, ty)); |
214 | } | 213 | } |
214 | // sort ranges for consistency | ||
215 | types.sort_by_key(|(ptr, _)| (ptr.range().start(), ptr.range().end())); | ||
215 | for (syntax_ptr, ty) in &types { | 216 | for (syntax_ptr, ty) in &types { |
216 | let node = syntax_ptr.resolve(&source_file); | 217 | let node = syntax_ptr.resolve(&source_file); |
217 | write!( | 218 | write!( |
diff --git a/crates/ra_hir/src/ty/tests/data/0006_backwards.txt b/crates/ra_hir/src/ty/tests/data/backwards.txt index 0efae598e..b6807fb2a 100644 --- a/crates/ra_hir/src/ty/tests/data/0006_backwards.txt +++ b/crates/ra_hir/src/ty/tests/data/backwards.txt | |||
@@ -1,20 +1,20 @@ | |||
1 | [22; 24) '{}': () | ||
2 | [14; 15) 'x': u32 | 1 | [14; 15) 'x': u32 |
3 | [142; 158) 'unknow...nction': [unknown] | 2 | [22; 24) '{}': () |
4 | [228; 229) 'c': f64 | ||
5 | [198; 216) 'unknow...tion()': f64 | ||
6 | [126; 127) 'a': u32 | ||
7 | [198; 214) 'unknow...nction': [unknown] | ||
8 | [222; 229) '&mut &c': &mut &f64 | ||
9 | [166; 184) 'S { i3...d: b }': S | ||
10 | [194; 195) 'c': f64 | ||
11 | [92; 110) 'unknow...tion()': u32 | ||
12 | [142; 160) 'unknow...tion()': i32 | ||
13 | [92; 108) 'unknow...nction': [unknown] | ||
14 | [116; 128) 'takes_u32(a)': () | ||
15 | [78; 231) '{ ...t &c }': &mut &f64 | 3 | [78; 231) '{ ...t &c }': &mut &f64 |
16 | [227; 229) '&c': &f64 | ||
17 | [88; 89) 'a': u32 | 4 | [88; 89) 'a': u32 |
18 | [181; 182) 'b': i32 | 5 | [92; 108) 'unknow...nction': [unknown] |
6 | [92; 110) 'unknow...tion()': u32 | ||
19 | [116; 125) 'takes_u32': fn(u32,) -> () | 7 | [116; 125) 'takes_u32': fn(u32,) -> () |
8 | [116; 128) 'takes_u32(a)': () | ||
9 | [126; 127) 'a': u32 | ||
20 | [138; 139) 'b': i32 | 10 | [138; 139) 'b': i32 |
11 | [142; 158) 'unknow...nction': [unknown] | ||
12 | [142; 160) 'unknow...tion()': i32 | ||
13 | [166; 184) 'S { i3...d: b }': S | ||
14 | [181; 182) 'b': i32 | ||
15 | [194; 195) 'c': f64 | ||
16 | [198; 214) 'unknow...nction': [unknown] | ||
17 | [198; 216) 'unknow...tion()': f64 | ||
18 | [222; 229) '&mut &c': &mut &f64 | ||
19 | [227; 229) '&c': &f64 | ||
20 | [228; 229) 'c': f64 | ||
diff --git a/crates/ra_hir/src/ty/tests/data/0001_basics.txt b/crates/ra_hir/src/ty/tests/data/basics.txt index 4df6b42c9..8ea244ba8 100644 --- a/crates/ra_hir/src/ty/tests/data/0001_basics.txt +++ b/crates/ra_hir/src/ty/tests/data/basics.txt | |||
@@ -1,13 +1,13 @@ | |||
1 | [9; 10) 'a': u32 | ||
2 | [17; 18) 'b': isize | ||
3 | [27; 28) 'c': ! | ||
1 | [33; 34) 'd': &[unknown] | 4 | [33; 34) 'd': &[unknown] |
2 | [88; 94) '1isize': [unknown] | 5 | [42; 121) '{ ...f32; }': () |
3 | [48; 49) 'a': u32 | 6 | [48; 49) 'a': u32 |
4 | [55; 56) 'b': isize | 7 | [55; 56) 'b': isize |
5 | [112; 118) '1.0f32': [unknown] | ||
6 | [76; 82) '1usize': [unknown] | ||
7 | [9; 10) 'a': u32 | ||
8 | [27; 28) 'c': ! | ||
9 | [62; 63) 'c': ! | 8 | [62; 63) 'c': ! |
10 | [17; 18) 'b': isize | ||
11 | [42; 121) '{ ...f32; }': () | ||
12 | [100; 106) '"test"': [unknown] | ||
13 | [69; 70) 'd': &[unknown] | 9 | [69; 70) 'd': &[unknown] |
10 | [76; 82) '1usize': [unknown] | ||
11 | [88; 94) '1isize': [unknown] | ||
12 | [100; 106) '"test"': [unknown] | ||
13 | [112; 118) '1.0f32': [unknown] | ||
diff --git a/crates/ra_hir/src/ty/tests/data/0008_boolean_op.txt b/crates/ra_hir/src/ty/tests/data/boolean_op.txt index 0ae172914..cce8d68fb 100644 --- a/crates/ra_hir/src/ty/tests/data/0008_boolean_op.txt +++ b/crates/ra_hir/src/ty/tests/data/boolean_op.txt | |||
@@ -1,31 +1,31 @@ | |||
1 | [28; 32) '0i32': i32 | ||
2 | [22; 34) '{ 0i32 }': i32 | ||
3 | [6; 7) 'x': [unknown] | 1 | [6; 7) 'x': [unknown] |
4 | [201; 205) '3i32': bool | 2 | [22; 34) '{ 0i32 }': i32 |
5 | [127; 134) 'CONST_1': [unknown] | 3 | [28; 32) '0i32': i32 |
6 | [76; 77) 'y': bool | 4 | [46; 237) '{ ... < 3 }': bool |
5 | [56; 57) 'x': bool | ||
6 | [60; 61) 'a': bool | ||
7 | [60; 66) 'a && b': bool | 7 | [60; 66) 'a && b': bool |
8 | [65; 66) 'b': bool | 8 | [65; 66) 'b': bool |
9 | [229; 231) '10': [unknown] | 9 | [76; 77) 'y': bool |
10 | [80; 84) 'true': bool | ||
11 | [80; 93) 'true || false': bool | ||
12 | [88; 93) 'false': bool | ||
13 | [103; 104) 'z': bool | ||
14 | [107; 108) 'x': bool | ||
15 | [107; 113) 'x == y': bool | ||
16 | [112; 113) 'y': bool | ||
17 | [123; 124) 'h': bool | ||
18 | [127; 134) 'CONST_1': [unknown] | ||
10 | [127; 145) 'CONST_...ONST_2': bool | 19 | [127; 145) 'CONST_...ONST_2': bool |
20 | [138; 145) 'CONST_2': [unknown] | ||
21 | [155; 156) 'c': [unknown] | ||
22 | [159; 172) 'f(z || y) + 5': [unknown] | ||
11 | [182; 183) 'd': [unknown] | 23 | [182; 183) 'd': [unknown] |
24 | [186; 187) 'b': [unknown] | ||
25 | [197; 198) 'e': bool | ||
26 | [201; 205) '3i32': bool | ||
27 | [201; 222) '3i32 &...world"': bool | ||
12 | [209; 222) '"hello world"': bool | 28 | [209; 222) '"hello world"': bool |
29 | [229; 231) '10': [unknown] | ||
13 | [229; 235) '10 < 3': bool | 30 | [229; 235) '10 < 3': bool |
14 | [186; 187) 'b': [unknown] | ||
15 | [56; 57) 'x': bool | ||
16 | [159; 172) 'f(z || y) + 5': [unknown] | ||
17 | [112; 113) 'y': bool | ||
18 | [234; 235) '3': [unknown] | 31 | [234; 235) '3': [unknown] |
19 | [201; 222) '3i32 &...world"': bool | ||
20 | [138; 145) 'CONST_2': [unknown] | ||
21 | [80; 93) 'true || false': bool | ||
22 | [46; 237) '{ ... < 3 }': bool | ||
23 | [197; 198) 'e': bool | ||
24 | [107; 113) 'x == y': bool | ||
25 | [88; 93) 'false': bool | ||
26 | [155; 156) 'c': [unknown] | ||
27 | [123; 124) 'h': bool | ||
28 | [80; 84) 'true': bool | ||
29 | [103; 104) 'z': bool | ||
30 | [60; 61) 'a': bool | ||
31 | [107; 108) 'x': bool | ||
diff --git a/crates/ra_hir/src/ty/tests/data/0002_let.txt b/crates/ra_hir/src/ty/tests/data/let.txt index 916ca25a1..30f4a2cf5 100644 --- a/crates/ra_hir/src/ty/tests/data/0002_let.txt +++ b/crates/ra_hir/src/ty/tests/data/let.txt | |||
@@ -1,7 +1,7 @@ | |||
1 | [21; 22) 'a': [unknown] | ||
2 | [52; 53) '1': usize | ||
3 | [11; 71) '{ ...= b; }': () | 1 | [11; 71) '{ ...= b; }': () |
4 | [63; 64) 'c': usize | 2 | [21; 22) 'a': [unknown] |
5 | [25; 31) '1isize': [unknown] | 3 | [25; 31) '1isize': [unknown] |
6 | [41; 42) 'b': usize | 4 | [41; 42) 'b': usize |
5 | [52; 53) '1': usize | ||
6 | [63; 64) 'c': usize | ||
7 | [67; 68) 'b': usize | 7 | [67; 68) 'b': usize |
diff --git a/crates/ra_hir/src/ty/tests/data/0003_paths.txt b/crates/ra_hir/src/ty/tests/data/paths.txt index 2a12d264f..b22f4d4a5 100644 --- a/crates/ra_hir/src/ty/tests/data/0003_paths.txt +++ b/crates/ra_hir/src/ty/tests/data/paths.txt | |||
@@ -1,9 +1,9 @@ | |||
1 | [15; 20) '{ 1 }': u32 | 1 | [15; 20) '{ 1 }': u32 |
2 | [17; 18) '1': u32 | 2 | [17; 18) '1': u32 |
3 | [50; 51) '1': u32 | ||
4 | [48; 53) '{ 1 }': u32 | 3 | [48; 53) '{ 1 }': u32 |
5 | [82; 88) 'b::c()': u32 | 4 | [50; 51) '1': u32 |
6 | [67; 91) '{ ...c(); }': () | 5 | [67; 91) '{ ...c(); }': () |
7 | [73; 74) 'a': fn() -> u32 | 6 | [73; 74) 'a': fn() -> u32 |
8 | [73; 76) 'a()': u32 | 7 | [73; 76) 'a()': u32 |
9 | [82; 86) 'b::c': fn() -> u32 | 8 | [82; 86) 'b::c': fn() -> u32 |
9 | [82; 88) 'b::c()': u32 | ||
diff --git a/crates/ra_hir/src/ty/tests/data/0005_refs.txt b/crates/ra_hir/src/ty/tests/data/refs_and_ptrs.txt index cc32162a1..afab343ea 100644 --- a/crates/ra_hir/src/ty/tests/data/0005_refs.txt +++ b/crates/ra_hir/src/ty/tests/data/refs_and_ptrs.txt | |||
@@ -1,23 +1,23 @@ | |||
1 | [115; 117) '&b': &&mut u32 | 1 | [9; 10) 'a': &u32 |
2 | [88; 94) '&mut a': &mut &u32 | 2 | [18; 19) 'b': &mut u32 |
3 | [146; 147) 'd': *mut u32 | 3 | [31; 32) 'c': *const u32 |
4 | [145; 147) '*d': u32 | ||
5 | [65; 66) 'a': &u32 | ||
6 | [46; 47) 'd': *mut u32 | 4 | [46; 47) 'd': *mut u32 |
7 | [59; 150) '{ ... *d; }': () | 5 | [59; 150) '{ ... *d; }': () |
8 | [116; 117) 'b': &mut u32 | 6 | [65; 66) 'a': &u32 |
9 | [72; 74) '*a': u32 | 7 | [72; 74) '*a': u32 |
10 | [131; 132) 'c': *const u32 | 8 | [73; 74) 'a': &u32 |
11 | [130; 132) '*c': u32 | 9 | [80; 82) '&a': &&u32 |
12 | [107; 109) '*b': u32 | 10 | [81; 82) 'a': &u32 |
13 | [108; 109) 'b': &mut u32 | 11 | [88; 94) '&mut a': &mut &u32 |
14 | [9; 10) 'a': &u32 | ||
15 | [18; 19) 'b': &mut u32 | ||
16 | [93; 94) 'a': &u32 | 12 | [93; 94) 'a': &u32 |
17 | [100; 101) 'b': &mut u32 | 13 | [100; 101) 'b': &mut u32 |
18 | [81; 82) 'a': &u32 | 14 | [107; 109) '*b': u32 |
19 | [80; 82) '&a': &&u32 | 15 | [108; 109) 'b': &mut u32 |
16 | [115; 117) '&b': &&mut u32 | ||
17 | [116; 117) 'b': &mut u32 | ||
20 | [123; 124) 'c': *const u32 | 18 | [123; 124) 'c': *const u32 |
21 | [73; 74) 'a': &u32 | 19 | [130; 132) '*c': u32 |
22 | [31; 32) 'c': *const u32 | 20 | [131; 132) 'c': *const u32 |
23 | [138; 139) 'd': *mut u32 | 21 | [138; 139) 'd': *mut u32 |
22 | [145; 147) '*d': u32 | ||
23 | [146; 147) 'd': *mut u32 | ||
diff --git a/crates/ra_hir/src/ty/tests/data/0007_self.txt b/crates/ra_hir/src/ty/tests/data/self.txt index db4ba17d0..c38029f97 100644 --- a/crates/ra_hir/src/ty/tests/data/0007_self.txt +++ b/crates/ra_hir/src/ty/tests/data/self.txt | |||
@@ -1,6 +1,6 @@ | |||
1 | [50; 54) 'self': &S | ||
2 | [34; 38) 'self': &S | 1 | [34; 38) 'self': &S |
3 | [40; 61) '{ ... }': () | 2 | [40; 61) '{ ... }': () |
3 | [50; 54) 'self': &S | ||
4 | [75; 79) 'self': &S | ||
4 | [88; 109) '{ ... }': () | 5 | [88; 109) '{ ... }': () |
5 | [98; 102) 'self': &S | 6 | [98; 102) 'self': &S |
6 | [75; 79) 'self': &S | ||
diff --git a/crates/ra_hir/src/ty/tests/data/0004_struct.txt b/crates/ra_hir/src/ty/tests/data/struct.txt index 6f919b332..7b324c82f 100644 --- a/crates/ra_hir/src/ty/tests/data/0004_struct.txt +++ b/crates/ra_hir/src/ty/tests/data/struct.txt | |||
@@ -1,16 +1,16 @@ | |||
1 | [86; 90) 'C(1)': [unknown] | 1 | [72; 154) '{ ...a.c; }': () |
2 | [121; 122) 'B': B | 2 | [82; 83) 'c': [unknown] |
3 | [86; 87) 'C': [unknown] | 3 | [86; 87) 'C': [unknown] |
4 | [86; 90) 'C(1)': [unknown] | ||
5 | [88; 89) '1': [unknown] | ||
6 | [96; 97) 'B': [unknown] | ||
4 | [107; 108) 'a': A | 7 | [107; 108) 'a': A |
5 | [129; 130) '1': [unknown] | 8 | [114; 133) 'A { b:...C(1) }': A |
9 | [121; 122) 'B': B | ||
6 | [127; 128) 'C': [unknown] | 10 | [127; 128) 'C': [unknown] |
11 | [127; 131) 'C(1)': C | ||
12 | [129; 130) '1': [unknown] | ||
13 | [139; 140) 'a': A | ||
7 | [139; 142) 'a.b': B | 14 | [139; 142) 'a.b': B |
8 | [114; 133) 'A { b:...C(1) }': A | ||
9 | [148; 151) 'a.c': C | ||
10 | [148; 149) 'a': A | 15 | [148; 149) 'a': A |
11 | [139; 140) 'a': A | 16 | [148; 151) 'a.c': C |
12 | [72; 154) '{ ...a.c; }': () | ||
13 | [96; 97) 'B': [unknown] | ||
14 | [88; 89) '1': [unknown] | ||
15 | [82; 83) 'c': [unknown] | ||
16 | [127; 131) 'C(1)': C | ||