From 9d114b9707fd3d6aaa3224cd1794e8e49e433f36 Mon Sep 17 00:00:00 2001 From: Otavio Salvador Date: Sat, 11 Jul 2020 19:28:07 -0300 Subject: infer: Add type inference support for Union types This adds the type inference to Union types and add a small test case for it, ensuring it keeps working in future. Fixes: #5277 Signed-off-by: Otavio Salvador --- crates/ra_hir_ty/src/tests/simple.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'crates/ra_hir_ty/src/tests') diff --git a/crates/ra_hir_ty/src/tests/simple.rs b/crates/ra_hir_ty/src/tests/simple.rs index de63f4cce..6d3e264af 100644 --- a/crates/ra_hir_ty/src/tests/simple.rs +++ b/crates/ra_hir_ty/src/tests/simple.rs @@ -324,6 +324,29 @@ fn test() { ); } +#[test] +fn infer_union() { + assert_snapshot!( + infer(r#" +union MyUnion { + foo: u32, + bar: f32, +} + +unsafe fn baz(u: MyUnion) { + let inner = u.foo; +} +"#), + @r###" + 61..62 'u': MyUnion + 73..99 '{ ...foo; }': () + 83..88 'inner': u32 + 91..92 'u': MyUnion + 91..96 'u.foo': u32 + "### + ); +} + #[test] fn infer_refs() { assert_snapshot!( -- cgit v1.2.3