diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-01-19 18:03:36 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-01-19 18:03:36 +0000 |
commit | 1c296d54e3dcc36c1a778873f26035000a352ba2 (patch) | |
tree | 0a6ce660ee32080287284c93bffaaaada91f3584 /crates/ra_hir/src/ty/tests/data | |
parent | bade91db081a3465dea3547ab8ab669f78fde9dc (diff) | |
parent | 5f3509e140d19b989db418a00ac6778c622cde5d (diff) |
Merge #576
576: Beginnings of generics r=matklad a=flodiebold
This implements the beginnings of the generics infrastructure; generic parameters for structs work and are correctly substituted in fields. Functions and methods aren't handled at all yet (as the tests show).
The name resolution in `ty` really needs refactoring now, I hope to do that next ;)
Co-authored-by: Florian Diebold <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/ty/tests/data')
4 files changed, 75 insertions, 0 deletions
diff --git a/crates/ra_hir/src/ty/tests/data/function_generics.txt b/crates/ra_hir/src/ty/tests/data/function_generics.txt new file mode 100644 index 000000000..e44d26cfd --- /dev/null +++ b/crates/ra_hir/src/ty/tests/data/function_generics.txt | |||
@@ -0,0 +1,14 @@ | |||
1 | [10; 11) 't': [unknown] | ||
2 | [21; 26) '{ t }': [unknown] | ||
3 | [23; 24) 't': [unknown] | ||
4 | [38; 98) '{ ...(1); }': () | ||
5 | [44; 46) 'id': fn(T) -> T | ||
6 | [44; 52) 'id(1u32)': T | ||
7 | [47; 51) '1u32': u32 | ||
8 | [58; 68) 'id::<i128>': fn(T) -> T | ||
9 | [58; 71) 'id::<i128>(1)': T | ||
10 | [69; 70) '1': T | ||
11 | [81; 82) 'x': T | ||
12 | [90; 92) 'id': fn(T) -> T | ||
13 | [90; 95) 'id(1)': T | ||
14 | [93; 94) '1': T | ||
diff --git a/crates/ra_hir/src/ty/tests/data/generic_chain.txt b/crates/ra_hir/src/ty/tests/data/generic_chain.txt new file mode 100644 index 000000000..568e00846 --- /dev/null +++ b/crates/ra_hir/src/ty/tests/data/generic_chain.txt | |||
@@ -0,0 +1,29 @@ | |||
1 | [53; 57) 'self': A<[unknown]> | ||
2 | [65; 87) '{ ... }': [unknown] | ||
3 | [75; 79) 'self': A<[unknown]> | ||
4 | [75; 81) 'self.x': [unknown] | ||
5 | [99; 100) 't': [unknown] | ||
6 | [110; 115) '{ t }': [unknown] | ||
7 | [112; 113) 't': [unknown] | ||
8 | [135; 261) '{ ....x() }': i128 | ||
9 | [146; 147) 'x': T | ||
10 | [150; 151) '1': T | ||
11 | [162; 163) 'y': T | ||
12 | [166; 168) 'id': fn(T) -> T | ||
13 | [166; 171) 'id(x)': T | ||
14 | [169; 170) 'x': T | ||
15 | [182; 183) 'a': A<T> | ||
16 | [186; 200) 'A { x: id(y) }': A<T> | ||
17 | [193; 195) 'id': fn(T) -> T | ||
18 | [193; 198) 'id(y)': T | ||
19 | [196; 197) 'y': T | ||
20 | [211; 212) 'z': T | ||
21 | [215; 217) 'id': fn(T) -> T | ||
22 | [215; 222) 'id(a.x)': T | ||
23 | [218; 219) 'a': A<T> | ||
24 | [218; 221) 'a.x': T | ||
25 | [233; 234) 'b': A<T> | ||
26 | [237; 247) 'A { x: z }': A<T> | ||
27 | [244; 245) 'z': T | ||
28 | [254; 255) 'b': A<T> | ||
29 | [254; 259) 'b.x()': i128 | ||
diff --git a/crates/ra_hir/src/ty/tests/data/generics_in_patterns.txt b/crates/ra_hir/src/ty/tests/data/generics_in_patterns.txt new file mode 100644 index 000000000..1b01ef19e --- /dev/null +++ b/crates/ra_hir/src/ty/tests/data/generics_in_patterns.txt | |||
@@ -0,0 +1,17 @@ | |||
1 | [79; 81) 'a1': A<u32> | ||
2 | [91; 92) 'o': Option<u64> | ||
3 | [107; 244) '{ ... }; }': () | ||
4 | [117; 128) 'A { x: x2 }': A<u32> | ||
5 | [124; 126) 'x2': u32 | ||
6 | [131; 133) 'a1': A<u32> | ||
7 | [143; 161) 'A::<i6...: x3 }': A<i64> | ||
8 | [157; 159) 'x3': i64 | ||
9 | [164; 174) 'A { x: 1 }': A<i64> | ||
10 | [171; 172) '1': i64 | ||
11 | [180; 241) 'match ... }': u64 | ||
12 | [186; 187) 'o': Option<u64> | ||
13 | [198; 213) 'Option::Some(t)': Option<u64> | ||
14 | [211; 212) 't': u64 | ||
15 | [217; 218) 't': u64 | ||
16 | [228; 229) '_': Option<u64> | ||
17 | [233; 234) '1': u64 | ||
diff --git a/crates/ra_hir/src/ty/tests/data/struct_generics.txt b/crates/ra_hir/src/ty/tests/data/struct_generics.txt new file mode 100644 index 000000000..1024a39a9 --- /dev/null +++ b/crates/ra_hir/src/ty/tests/data/struct_generics.txt | |||
@@ -0,0 +1,15 @@ | |||
1 | [36; 38) 'a1': A<u32> | ||
2 | [48; 49) 'i': i32 | ||
3 | [56; 147) '{ ...3.x; }': () | ||
4 | [62; 64) 'a1': A<u32> | ||
5 | [62; 66) 'a1.x': u32 | ||
6 | [76; 78) 'a2': A<i32> | ||
7 | [81; 91) 'A { x: i }': A<i32> | ||
8 | [88; 89) 'i': i32 | ||
9 | [97; 99) 'a2': A<i32> | ||
10 | [97; 101) 'a2.x': i32 | ||
11 | [111; 113) 'a3': A<i128> | ||
12 | [116; 134) 'A::<i1...x: 1 }': A<i128> | ||
13 | [131; 132) '1': i128 | ||
14 | [140; 142) 'a3': A<i128> | ||
15 | [140; 144) 'a3.x': i128 | ||