aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-01-26 21:23:07 +0000
committerAleksey Kladov <[email protected]>2019-01-26 21:37:11 +0000
commit619af1e22cb71b981fde4cedbf6ebce9b3488028 (patch)
treeb99f89f6e652e7f34519ef5f4f8bfeb71694f40d /crates/ra_hir/src/ty
parent2d337c88b07b6a67b24f4bff4d72025d9ea412a5 (diff)
fix AST for if expressions
then is not always a block...
Diffstat (limited to 'crates/ra_hir/src/ty')
-rw-r--r--crates/ra_hir/src/ty/snapshots/tests__infer_in_elseif.snap17
-rw-r--r--crates/ra_hir/src/ty/tests.rs17
2 files changed, 34 insertions, 0 deletions
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
new file mode 100644
index 000000000..6a435e5cf
--- /dev/null
+++ b/crates/ra_hir/src/ty/snapshots/tests__infer_in_elseif.snap
@@ -0,0 +1,17 @@
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/tests.rs b/crates/ra_hir/src/ty/tests.rs
index e0b0689f8..e1165f682 100644
--- a/crates/ra_hir/src/ty/tests.rs
+++ b/crates/ra_hir/src/ty/tests.rs
@@ -285,6 +285,23 @@ fn test() {
285} 285}
286 286
287#[test] 287#[test]
288fn infer_in_elseif() {
289 check_inference(
290 "infer_in_elseif",
291 r#"
292struct Foo { field: i32 }
293fn main(foo: Foo) {
294 if true {
295
296 } else if false {
297 foo.field
298 }
299}
300"#,
301 )
302}
303
304#[test]
288fn infer_inherent_method() { 305fn infer_inherent_method() {
289 check_inference( 306 check_inference(
290 "infer_inherent_method", 307 "infer_inherent_method",