aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2018-12-24 18:07:48 +0000
committerFlorian Diebold <[email protected]>2018-12-25 14:16:42 +0000
commitb5b68f2094d49cacde6d7f0c49f521a0b25f34bd (patch)
tree5439bb80896c211b3cadb2c037383243fe1fc140 /crates/ra_hir/src/ty
parent5fb426cb9eeefa69a53d7c8c3367f7c6b714b9b8 (diff)
Add basic HIR and types for structs/enums
Diffstat (limited to 'crates/ra_hir/src/ty')
-rw-r--r--crates/ra_hir/src/ty/tests.rs23
-rw-r--r--crates/ra_hir/src/ty/tests/data/0004_struct.txt10
2 files changed, 33 insertions, 0 deletions
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs
index b6c02cd80..170eef147 100644
--- a/crates/ra_hir/src/ty/tests.rs
+++ b/crates/ra_hir/src/ty/tests.rs
@@ -68,6 +68,29 @@ fn test() {
68 ); 68 );
69} 69}
70 70
71#[test]
72fn infer_struct() {
73 check_inference(
74 r#"
75struct A {
76 b: B,
77 c: C,
78}
79struct B;
80struct C(usize);
81
82fn test() {
83 let c = C(1);
84 B;
85 let a: A = A { b: B, c: C() };
86 a.b;
87 a.c;
88}
89"#,
90 "0004_struct.txt",
91 );
92}
93
71fn infer(content: &str) -> String { 94fn infer(content: &str) -> String {
72 let (db, _, file_id) = MockDatabase::with_single_file(content); 95 let (db, _, file_id) = MockDatabase::with_single_file(content);
73 let source_file = db.source_file(file_id); 96 let source_file = db.source_file(file_id);
diff --git a/crates/ra_hir/src/ty/tests/data/0004_struct.txt b/crates/ra_hir/src/ty/tests/data/0004_struct.txt
new file mode 100644
index 000000000..70ad055ff
--- /dev/null
+++ b/crates/ra_hir/src/ty/tests/data/0004_struct.txt
@@ -0,0 +1,10 @@
1[86; 90) 'C(1)': [unknown]
2[72; 153) '{ ...a.c; }': ()
3[86; 87) 'C': C
4[107; 108) 'a': A
5[114; 132) 'A { b:... C() }': [unknown]
6[138; 141) 'a.b': [unknown]
7[147; 150) 'a.c': [unknown]
8[96; 97) 'B': B
9[88; 89) '1': [unknown]
10[82; 83) 'c': [unknown]