From 619af1e22cb71b981fde4cedbf6ebce9b3488028 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 27 Jan 2019 00:23:07 +0300 Subject: fix AST for if expressions then is not always a block... --- .../ra_hir/src/ty/snapshots/tests__infer_in_elseif.snap | 17 +++++++++++++++++ crates/ra_hir/src/ty/tests.rs | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 crates/ra_hir/src/ty/snapshots/tests__infer_in_elseif.snap (limited to 'crates/ra_hir/src/ty') 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 @@ +--- +created: "2019-01-26T21:36:52.714121185+00:00" +creator: insta@0.5.2 +expression: "&result" +source: crates/ra_hir/src/ty/tests.rs +--- +[35; 38) 'foo': Foo +[45; 109) '{ ... } }': () +[51; 107) 'if tru... }': () +[54; 58) 'true': bool +[59; 67) '{ }': () +[73; 107) 'if fal... }': i32 +[76; 81) 'false': bool +[82; 107) '{ ... }': i32 +[92; 95) 'foo': Foo +[92; 101) 'foo.field': i32 + 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 @@ -284,6 +284,23 @@ fn test() { ); } +#[test] +fn infer_in_elseif() { + check_inference( + "infer_in_elseif", + r#" +struct Foo { field: i32 } +fn main(foo: Foo) { + if true { + + } else if false { + foo.field + } +} +"#, + ) +} + #[test] fn infer_inherent_method() { check_inference( -- cgit v1.2.3