Repository: intellij-rust/intellij-rust
Issue: Closure type inference seems incorrect

Here is a piece of code:
```rust
let f = |x: i32| {
    if x > 0 {
        return x;
    }
    panic!("Negative!");
};
```
Plugin infers a type `f: fn() -> !`, since I think it is `fn() -> i32`.

Changed files:
src/test/kotlin/org/rust/lang/core/type/RsEnumPatternTypeInferenceTest.kt, src/test/kotlin/org/rust/lang/core/type/RsGenericExpressionTypeInferenceTest.kt, src/test/kotlin/org/rust/lang/core/type/RsExpressionTypeInferenceTest.kt, src/main/kotlin/org/rust/lang/core/types/infer/TypeInference.kt, src/main/kotlin/org/rust/lang/core/resolve/ImplLookup.kt, src/test/kotlin/org/rust/lang/core/type/RsArithmeticOpsTest.kt, src/test/kotlin/org/rust/lang/core/type/RsIndexTypeInferenceTest.kt, src/test/kotlin/org/rust/lang/core/type/RsPatternMatchingTest.kt, src/test/kotlin/org/rust/lang/core/type/RsNumericLiteralTypeInferenceTest.kt, src/test/kotlin/org/rust/lang/core/type/RsDivergingTypeInferenceTest.kt

diff --git a/src/main/kotlin/org/rust/lang/core/resolve/ImplLookup.kt b/src/main/kotlin/org/rust/lang/core/resolve/ImplLookup.kt
index d3583fd5d..258efefca 100644
--- a/src/main/kotlin/org/rust/lang/core/resolve/ImplLookup.kt
+++ b/src/main/kotlin/org/rust/lang/core/resolve/ImplLookup.kt
@@ -51,8 +51,7 @@ const val DEFAULT_RECURSION_LIMIT = 64
 
 class ImplLookup(
     private val project: Project,
-    private val items: StdKnownItems,
-    private var _ctx: RsInferenceContext? = null
+    private val items: StdKnownItems
 ) {
     // Non-concurrent HashMap and lazy(NONE) are safe here because this class isn't shared between threads
     private val primitiveTyHardcodedImplsCache = mutableMapOf<TyPrimitive, Collection<BoundElement<RsTraitItem>>>()
@@ -90,11 +89,9 @@ class ImplLookup(
         findAssociatedType(trait, "Item")?.let { trait to it }
     }
 
-    private val ctx: RsInferenceContext
-        get() {
-            if (_ctx == null) _ctx = RsInferenceContext()
-            return _ctx!!
-        }
+    val ctx: RsInferenceContext by lazy(NONE) {
+        RsInferenceContext(this, items)
+    }
 
     fun findImplsAndTraits(ty: Ty): Set<RsTraitOrImpl> {
         return findImplsAndTraitsCache.getOrPut(project, freshen(ty)) { rawFindImplsAndTraits(ty) }
diff --git a/src/main/kotlin/org/rust/lang/core/types/infer/TypeInference.kt b/src/main/kotlin/org/rust/lang/core/types/infer/TypeInference.kt
index 73dbdd762..afcca45d1 100644
--- a/src/main/kotlin/org/rust/lang/core/types/infer/TypeInference.kt
+++ b/src/main/kotlin/org/rust/lang/core/types/infer/TypeInference.kt
@@ -32,8 +32,11 @@ import org.rust.stdext.singleOrFilter
 import org.rust.stdext.singleOrLet
 import org.rust.stdext.zipValues
 
-fun inferTypesIn(fn: RsFunction): RsInferenceResult =
-    RsInferenceContext().run { preventRecursion { infer(fn) } }
+fun inferTypesIn(fn: RsFunction): RsInferenceResult {
+    val items = StdKnownItems.relativeTo(fn)
+    val lookup = ImplLookup(fn.project, items)
+    return preventRecursion { lookup.ctx.infer(fn) }
+}
 
 /**
  * [RsInferenceResult] is an immutable per-function map
@@ -69,7 +72,11 @@ class RsInferenceResult(
 /**
  * A mutable object, which is filled while we walk function body top down.
  */
-class RsInferenceContext {
+class RsInferenceContext(
+    val lookup: ImplLookup,
+    val items: StdKnownItems
+) {
+    val fulfill: FulfillmentContext = FulfillmentContext(this, lookup)
     private val bindings: MutableMap<RsPatBinding, Ty> = HashMap()
     private val exprTypes: MutableMap<RsExpr, Ty> = HashMap()
     private val resolvedPaths: MutableMap<RsPathExpr, List<RsElement>> = HashMap()
@@ -124,10 +131,8 @@ class RsInferenceContext {
 
         val block = fn.block
         if (block != null) {
-            val items = StdKnownItems.relativeTo(fn)
-            val lookup = ImplLookup(fn.project, items, this)
-            val fctx = RsFnInferenceContext(this, lookup, items)
-            fctx.inferBlockType(block)
+            val fctx = RsFnInferenceContext(this, fn.returnType)
+            fctx.inferFnBody(block)
 
             fctx.selectObligationsWherePossible()
             exprTypes.replaceAll { _, ty -> fullyResolve(ty) }
@@ -388,10 +393,11 @@ class RsInferenceContext {
 
 private class RsFnInferenceContext(
     private val ctx: RsInferenceContext,
-    private val lookup: ImplLookup,
-    private val items: StdKnownItems
+    private val returnTy: Ty
 ) {
-    private val fulfill: FulfillmentContext = FulfillmentContext(ctx, lookup)
+    private val lookup get() = ctx.lookup
+    private val items get() = ctx.items
+    private val fulfill get() = ctx.fulfill
     private val RsStructLiteralField.type: Ty get() = resolveToDeclaration?.typeReference?.type ?: TyUnknown
 
     private fun resolveTypeVarsWithObligations(ty: Ty): Ty {
@@ -404,15 +410,21 @@ private class RsFnInferenceContext(
         fulfill.selectWherePossible()
     }
 
-    fun inferBlockType(block: RsBlock): Ty =
-        block.inferType()
+    fun inferFnBody(block: RsBlock): Ty =
+        block.inferTypeCoercableTo(returnTy)
+
+    fun inferLambdaBody(expr: RsExpr): Ty =
+        if (expr is RsBlockExpr) inferFnBody(expr.block) else expr.inferTypeCoercableTo(returnTy)
 
-    private fun RsBlock.inferType(expected: Ty? = null): Ty {
+    private fun RsBlock.inferTypeCoercableTo(expected: Ty): Ty =
+        inferType(expected, true)
+
+    private fun RsBlock.inferType(expected: Ty? = null, coerce: Boolean = false): Ty {
         var isDiverging = false
         for (stmt in stmtList) {
             isDiverging = processStatement(stmt) || isDiverging
         }
-        val type = expr?.inferType(expected) ?: TyUnit
+        val type = (if (coerce) expr?.inferTypeCoercableTo(expected!!) else expr?.inferType(expected)) ?: TyUnit
         return if (isDiverging) TyNever else type
     }
 
@@ -1182,9 +1194,12 @@ private class RsFnInferenceContext(
             ctx.extractBindings(actualArg.pat, paramTy)
             paramTy
         }.toList()
+        val retTy = expr.retType?.typeReference?.type
+            ?: expectedFnTy.retType.takeIf { it != TyUnknown }
+            ?: TyInfer.TyVar()
 
-        val inferredRetTy = expr.expr?.inferType()
-        return TyFunction(paramTypes, inferredRetTy ?: expectedFnTy.retType)
+        expr.expr?.let { RsFnInferenceContext(ctx, retTy).inferLambdaBody(it) }
+        return TyFunction(paramTypes, retTy)
     }
 
     private fun deduceLambdaType(expected: Ty): TyFunction? {
@@ -1236,7 +1251,7 @@ private class RsFnInferenceContext(
     }
 
     private fun inferRetExprType(expr: RsRetExpr): Ty {
-        expr.expr?.inferType()
+        expr.expr?.inferTypeCoercableTo(returnTy)
         return TyNever
     }
 
diff --git a/src/test/kotlin/org/rust/lang/core/type/RsArithmeticOpsTest.kt b/src/test/kotlin/org/rust/lang/core/type/RsArithmeticOpsTest.kt
index 1294c9e69..9b8051b48 100644
--- a/src/test/kotlin/org/rust/lang/core/type/RsArithmeticOpsTest.kt
+++ b/src/test/kotlin/org/rust/lang/core/type/RsArithmeticOpsTest.kt
@@ -26,7 +26,7 @@ class RsArithmeticOpsTest : RsTypificationTestBase() {
 
         fn foo(lhs: Foo, rhs: Foo) {
             let x = lhs $sign rhs;
-            x
+            x;
           //^ Foo
         }
         """
@@ -49,7 +49,7 @@ class RsArithmeticOpsTest : RsTypificationTestBase() {
 
         fn foo(lhs: Foo, rhs: Foo) {
             let x = lhs $sign rhs;
-            x
+            x;
           //^ Foo
         }
         """
@@ -73,7 +73,7 @@ class RsArithmeticOpsTest : RsTypificationTestBase() {
 
         fn foo(lhs: Foo, rhs: i32) {
             let x = lhs $sign rhs;
-            x
+            x;
           //^ Bar
         }
         """
@@ -103,7 +103,7 @@ class RsArithmeticOpsTest : RsTypificationTestBase() {
 
         fn foo(lhs: Foo, rhs: i32) {
             let x = lhs $sign rhs;
-            x
+            x;
           //^ FooBar
         }
         """
@@ -128,7 +128,7 @@ class RsArithmeticOpsTest : RsTypificationTestBase() {
 
         fn foo(lhs: Foo<i32>, rhs: Bar) {
             let x = lhs $sign rhs;
-            x
+            x;
           //^ FooBar<i32>
         }
         """
diff --git a/src/test/kotlin/org/rust/lang/core/type/RsDivergingTypeInferenceTest.kt b/src/test/kotlin/org/rust/lang/core/type/RsDivergingTypeInferenceTest.kt
index 49f90129f..b4c4f53ad 100644
--- a/src/test/kotlin/org/rust/lang/core/type/RsDivergingTypeInferenceTest.kt
+++ b/src/test/kotlin/org/rust/lang/core/type/RsDivergingTypeInferenceTest.kt
@@ -42,4 +42,18 @@ class RsDivergingTypeInferenceTest : RsTypificationTestBase() {
             full
         }  //^ u32
     """)
+
+    fun `test closure with divergence`() = testExpr("""
+        fn main() {
+            let f = || {
+                if 2 > 1 {
+                    return 1;
+                }
+                unreachable!();
+            };
+            let a = f();
+            a;
+          //^ i32
+        }
+    """)
 }
diff --git a/src/test/kotlin/org/rust/lang/core/type/RsEnumPatternTypeInferenceTest.kt b/src/test/kotlin/org/rust/lang/core/type/RsEnumPatternTypeInferenceTest.kt
index 3b1e9a796..0b57d7c20 100644
--- a/src/test/kotlin/org/rust/lang/core/type/RsEnumPatternTypeInferenceTest.kt
+++ b/src/test/kotlin/org/rust/lang/core/type/RsEnumPatternTypeInferenceTest.kt
@@ -79,7 +79,7 @@ class RsEnumPatternTypeInferenceTest : RsTypificationTestBase() {
 
         fn foo(r: Result) {
             let Result::Ok(s @ S { x, .. }) = r;
-            s
+            s;
           //^ S
         }
     """)
@@ -94,7 +94,7 @@ class RsEnumPatternTypeInferenceTest : RsTypificationTestBase() {
 
         fn foo(r: Result) {
             let Result::Ok(s @ S { j /* non-existing field */ }) = r;
-            s
+            s;
           //^ S
         }
     """)
@@ -109,7 +109,7 @@ class RsEnumPatternTypeInferenceTest : RsTypificationTestBase() {
 
         fn foo(r: Result) {
             let Result::Ok(s @ S { x /* missing fields */ }) = r;
-            s
+            s;
           //^ S
         }
     """)
diff --git a/src/test/kotlin/org/rust/lang/core/type/RsExpressionTypeInferenceTest.kt b/src/test/kotlin/org/rust/lang/core/type/RsExpressionTypeInferenceTest.kt
index f341d468b..810e2f7cb 100644
--- a/src/test/kotlin/org/rust/lang/core/type/RsExpressionTypeInferenceTest.kt
+++ b/src/test/kotlin/org/rust/lang/core/type/RsExpressionTypeInferenceTest.kt
@@ -45,7 +45,7 @@ class RsExpressionTypeInferenceTest : RsTypificationTestBase() {
         fn foo() -> S {}
         fn main() {
             let x = { foo() };
-            x
+            x;
           //^ S
         }
     """)
@@ -88,7 +88,7 @@ class RsExpressionTypeInferenceTest : RsTypificationTestBase() {
     fun `test if`() = testExpr("""
         fn main() {
             let x = if true { 92 } else { 62 };
-            x
+            x;
           //^ i32
         }
     """)
@@ -96,14 +96,14 @@ class RsExpressionTypeInferenceTest : RsTypificationTestBase() {
     fun `test if else with return 1`() = testExpr("""
         fn main() {
             let a = if true { return } else { 1 };
-            a
+            a;
         } //^ i32
     """)
 
     fun `test if else with return 2`() = testExpr("""
         fn main() {
             let a = if true { return } else if true { return } else { 1 };
-            a
+            a;
         } //^ i32
     """)
 
@@ -113,14 +113,14 @@ class RsExpressionTypeInferenceTest : RsTypificationTestBase() {
                 true => return,
                 false => 1,
             };
-            a
+            a;
         } //^ i32
     """)
 
     fun `test loop`() = testExpr("""
         fn main() {
             let x = loop { break; };
-            x
+            x;
           //^ ()
         }
     """)
@@ -128,7 +128,7 @@ class RsExpressionTypeInferenceTest : RsTypificationTestBase() {
     fun `test endless loop`() = testExpr("""
         fn main() {
             let x = loop { };
-            x
+            x;
           //^ !
         }
     """)
@@ -136,7 +136,7 @@ class RsExpressionTypeInferenceTest : RsTypificationTestBase() {
     fun `test loop break value`() = testExpr("""
         fn main() {
             let x = loop { break 7; };
-            x
+            x;
           //^ i32
         }
     """)
@@ -146,7 +146,7 @@ class RsExpressionTypeInferenceTest : RsTypificationTestBase() {
             let x = loop {
                 if v { break 7; }
             };
-            x
+            x;
           //^ i32
         }
     """)
@@ -160,7 +160,7 @@ class RsExpressionTypeInferenceTest : RsTypificationTestBase() {
                     break 0u32;
                 }
             };
-            x
+            x;
           //^ u32
         }
     """)
@@ -171,7 +171,7 @@ class RsExpressionTypeInferenceTest : RsTypificationTestBase() {
                 loop { break "bar"; }
                 break 7;
             };
-            x
+            x;
           //^ i32
         }
     """)
@@ -186,7 +186,7 @@ class RsExpressionTypeInferenceTest : RsTypificationTestBase() {
                     }
                 }
             };
-            x
+            x;
           //^ u32
         }
     """)
@@ -198,7 +198,7 @@ class RsExpressionTypeInferenceTest : RsTypificationTestBase() {
                     if v { break 'outer "bar"; }
                     break 7;
                 };
-                y
+                y;
               //^ i32
             };
         }
@@ -212,7 +212,7 @@ class RsExpressionTypeInferenceTest : RsTypificationTestBase() {
                     break 7;
                 }
             };
-            x
+            x;
           //^ u32
         }
     """)
@@ -314,7 +314,7 @@ class RsExpressionTypeInferenceTest : RsTypificationTestBase() {
     fun `test enum variant A`() = testExpr("""
         enum E { A(i32), B { val: bool }, C }
         fn main() {
-            (E::A(92))
+            (E::A(92));
           //^ E
         }
     """)
@@ -322,7 +322,7 @@ class RsExpressionTypeInferenceTest : RsTypificationTestBase() {
     fun `test enum variant B`() = testExpr("""
         enum E { A(i32), B { val: bool }, C }
         fn main() {
-            (E::B { val: false })
+            (E::B { val: false });
           //^ E
         }
     """)
@@ -330,7 +330,7 @@ class RsExpressionTypeInferenceTest : RsTypificationTestBase() {
     fun `test enum variant C`() = testExpr("""
         enum E { A(i32), B { val: bool }, C }
         fn main() {
-            (E::C)
+            (E::C);
           //^ E
         }
     """)
@@ -345,13 +345,13 @@ class RsExpressionTypeInferenceTest : RsTypificationTestBase() {
                 E::A(ref x) => x,
                 E::B => panic!(),
             };
-            s
+            s;
         } //^ &S
     """)
 
     fun `test parens`() = testExpr("""
         type T = (i32);
-        fn foo(x: T) { x }
+        fn foo(x: T) { x; }
                      //^ i32
     """)
 
@@ -365,7 +365,7 @@ class RsExpressionTypeInferenceTest : RsTypificationTestBase() {
 
         fn main() {
             let x = P(92);
-            x
+            x;
           //^ P<i32>
         }
     """)
@@ -404,7 +404,7 @@ class RsExpressionTypeInferenceTest : RsTypificationTestBase() {
             testExpr("""
                 fn main() {
                     let x = ${case.first};
-                    x
+                    x;
                   //^ ${case.second}
                 }
                 """
@@ -429,7 +429,7 @@ class RsExpressionTypeInferenceTest : RsTypificationTestBase() {
         fn main() {
             let y = 42;
             let x = &y as *const i32;
-            x
+            x;
           //^ *const i32
         }
     """)
@@ -438,7 +438,7 @@ class RsExpressionTypeInferenceTest : RsTypificationTestBase() {
         fn main() {
             let y = 42;
             let x = &y as i64;
-            x
+            x;
           //^ i64
         }
     """)
@@ -452,8 +452,8 @@ class RsExpressionTypeInferenceTest : RsTypificationTestBase() {
     fun `test pointer deref`() = testExpr("""
         fn main() {
             let x : *const i32;
-            let y = *x; // it should be in unsafe
-            y
+            let y = unsafe { *x };
+            y;
           //^ i32
         }
     """)
@@ -467,14 +467,14 @@ class RsExpressionTypeInferenceTest : RsTypificationTestBase() {
 
         fn foo(a: A) {
             let b = *a;
-            b
+            b;
         } //^ B
     """)
 
     fun `test slice type`() = testExpr("""
         fn main() {
             let x : [i32];
-            x
+            x;
           //^ [i32]
         }
     """)
@@ -482,7 +482,7 @@ class RsExpressionTypeInferenceTest : RsTypificationTestBase() {
     fun `test array type`() = testExpr("""
         fn main() {
             let x : [i32; 8];
-            x
+            x;
           //^ [i32; 8]
         }
     """)
@@ -490,7 +490,7 @@ class RsExpressionTypeInferenceTest : RsTypificationTestBase() {
     fun `test array type2`() = testExpr("""
         fn main() {
             let x : [bool; 8];
-            x
+            x;
           //^ [bool; 8]
         }
     """)
@@ -498,7 +498,7 @@ class RsExpressionTypeInferenceTest : RsTypificationTestBase() {
     fun `test array type3`() = testExpr("""
         fn main() {
             let x : [bool; 8usize];
-            x
+            x;
           //^ [bool; 8]
         }
     """)
@@ -506,14 +506,14 @@ class RsExpressionTypeInferenceTest : RsTypificationTestBase() {
     fun `test array expression type1`() = testExpr("""
         fn main() {
             let x = [""];
-            x
+            x;
         } //^ [&str; 1]
     """)
 
     fun `test array expression type2`() = testExpr("""
         fn main() {
             let x = [1, 2, 3];
-            x
+            x;
           //^ [i32; 3]
         }
     """)
@@ -521,7 +521,7 @@ class RsExpressionTypeInferenceTest : RsTypificationTestBase() {
     fun `test array expression type3`() = testExpr("""
         fn main() {
             let x = [0; 8];
-            x
+            x;
           //^ [i32; 8]
         }
     """)
@@ -529,7 +529,7 @@ class RsExpressionTypeInferenceTest : RsTypificationTestBase() {
     fun `test array expression type4`() = testExpr("""
         fn main() {
             let x = [0; 8usize];
-            x
+            x;
           //^ [i32; 8]
         }
     """)
@@ -537,7 +537,7 @@ class RsExpressionTypeInferenceTest : RsTypificationTestBase() {
     fun `test array expression type5`() = testExpr("""
         fn main() {
             let x = [1, 2u16, 3];
-            x
+            x;
           //^ [u16; 3]
         }
     """)
@@ -547,7 +547,7 @@ class RsExpressionTypeInferenceTest : RsTypificationTestBase() {
         const COUNT: usize = 2;
         fn main() {
             let x = [1; COUNT];
-            x
+            x;
           //^ [i32; <unknown>]
         }
     """)
@@ -556,7 +556,7 @@ class RsExpressionTypeInferenceTest : RsTypificationTestBase() {
         const COUNT: i32 = 2;
         fn main() {
             let x = [1; COUNT];
-            x
+            x;
           //^ [i32; <unknown>]
         }
     """)
@@ -565,7 +565,7 @@ class RsExpressionTypeInferenceTest : RsTypificationTestBase() {
     fun `test binary expr as array size`() = testExpr("""
         fn main() {
             let x = [1; 2 + 3];
-            x
+            x;
           //^ [i32; <unknown>]
         }
     """)
@@ -573,7 +573,7 @@ class RsExpressionTypeInferenceTest : RsTypificationTestBase() {
     fun `test negative binary expr as array size`() = testExpr("""
         fn main() {
             let x = [1; 2 - 3];
-            x
+            x;
           //^ [i32; <unknown>]
         }
     """)
@@ -583,7 +583,7 @@ class RsExpressionTypeInferenceTest : RsTypificationTestBase() {
         const COUNT: usize = 2;
         fn main() {
             let x = [1; (2 * COUNT + 3) << (4 / 2)];
-            x
+            x;
           //^ [i32; <unknown>]
         }
     """)
@@ -721,7 +721,7 @@ class RsExpressionTypeInferenceTest : RsTypificationTestBase() {
     fun `test unresolved field expr`() = testExpr("""
         struct S;
         fn main() {
-            S { f: 1 }
+            S { f: 1 };
         }        //^ i32
     """)
 
@@ -730,7 +730,7 @@ class RsExpressionTypeInferenceTest : RsTypificationTestBase() {
         type T1 = S;
         type T2 = T1;
         fn main() {
-            T2 { }
+            T2 { };
         } //^ S
     """)
     // More struct alias tests in [RsGenericExpressionTypeInferenceTest]
@@ -793,7 +793,7 @@ class RsExpressionTypeInferenceTest : RsTypificationTestBase() {
         fn main() {
             loop {
                 break 1;
-            }       //^ i32
+            };      //^ i32
         }
     """)
 
@@ -807,7 +807,7 @@ class RsExpressionTypeInferenceTest : RsTypificationTestBase() {
         fn main() {
             loop {
                 break 1;
-            } //^ !
+            };//^ !
         }
     """)
 
@@ -828,7 +828,7 @@ class RsExpressionTypeInferenceTest : RsTypificationTestBase() {
     fun `test infer lambda type with explicit parameters`() = testExpr("""
         fn main() {
             let a = |x: u8| x;
-            a
+            a;
         } //^ fn(u8) -> u8
     """)
 
@@ -862,4 +862,61 @@ class RsExpressionTypeInferenceTest : RsTypificationTestBase() {
             a
         } //^ <unknown>
     """)
+
+    fun `test infer return expr from fn return type`() = testExpr("""
+        fn foo() -> u8 {
+            return 0;
+        }        //^ u8
+    """)
+
+    fun `test infer tail expr from fn return type`() = testExpr("""
+        fn foo() -> u8 {
+            0
+        } //^ u8
+    """)
+
+    fun `test infer return expr from explicit closure return type`() = testExpr("""
+        fn main() {
+            || -> u8 {
+                return 0;
+            };       //^ u8
+        }
+    """)
+
+    fun `test infer tail expr from explicit closure return type`() = testExpr("""
+        fn main() {
+            || -> u8 {
+                0
+            };//^ u8
+        }
+    """)
+
+    fun `test infer return expr from expected closure return type`() = testExpr("""
+        fn main() {
+            let _: fn() -> u8 = || {
+                return 0;
+            };       //^ u8
+        }
+    """)
+
+    fun `test infer return expr from another return expr in closure`() = testExpr("""
+        fn main() {
+            || {
+                if 2 > 1 {
+                    return 0;
+                } else { //^ u8
+                    return 1u8;
+                }
+            };
+        }
+    """)
+
+    fun `test infer return expr from inferred-later closure return type`() = testExpr("""
+        fn main() {
+            let a = || {
+                return 0;
+            };       //^ u8
+            let b: u8 = a();
+        }
+    """)
 }
diff --git a/src/test/kotlin/org/rust/lang/core/type/RsGenericExpressionTypeInferenceTest.kt b/src/test/kotlin/org/rust/lang/core/type/RsGenericExpressionTypeInferenceTest.kt
index 795d48ac9..f628c6072 100644
--- a/src/test/kotlin/org/rust/lang/core/type/RsGenericExpressionTypeInferenceTest.kt
+++ b/src/test/kotlin/org/rust/lang/core/type/RsGenericExpressionTypeInferenceTest.kt
@@ -13,7 +13,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
 
         fn foo(s: S<f64>) {
             let x = s.field;
-            x
+            x;
           //^ f64
         }
     """)
@@ -23,7 +23,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
 
         fn foo(s: S<'static, f64>) {
             let x = s.field;
-            x
+            x;
           //^ &f64
         }
     """)
@@ -34,7 +34,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
 
         fn foo(s: A<B<f64>>) {
             let x = s.field.field;
-            x
+            x;
           //^ f64
         }
     """)
@@ -44,7 +44,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
 
         fn foo(s: S<S<u64>>) {
             let x = s.field.field;
-            x
+            x;
           //^ u64
         }
     """)
@@ -54,7 +54,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
 
         fn foo(s: S<f64>) {
             let x = s.field;
-            x
+            x;
           //^ [f64; 1]
         }
     """)
@@ -64,7 +64,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
 
         fn foo(s: S<f64>) {
             let x = s.field;
-            x
+            x;
           //^ &[f64]
         }
     """)
@@ -74,7 +74,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
 
         fn foo(s: S<f64>) {
             let x = s.field;
-            x
+            x;
           //^ *const f64
         }
     """)
@@ -84,7 +84,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
 
         fn foo(s: S<f64>) {
             let x = s.field;
-            x
+            x;
           //^ *mut f64
         }
     """)
@@ -98,7 +98,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
 
         fn foo(s: B<i32>) {
             let x = s.unwrap();
-            x
+            x;
           //^ i32
         }
     """)
@@ -111,7 +111,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
 
          fn foo(r: Result<(u32, u32), ()>) {
              let x = r.unwrap();
-             x
+             x;
            //^ (u32, u32)
          }
     """)
@@ -125,7 +125,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
 
         fn f(s: S<i32, ()>) {
             let x = s.swap();
-            x
+            x;
           //^ ((), i32)
         }
     """)
@@ -139,7 +139,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
 
         fn f(s: S<i32, i32>) {
             let x = s.foo();
-            x
+            x;
           //^ (i32, i32)
         }
     """)
@@ -153,7 +153,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
 
         fn f(s: S<i32, ()>) {
             let x = s.foo();
-            x
+            x;
           //^ ()
         }
     """)
@@ -163,7 +163,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
 
         fn main() {
             let a = f(0i32);
-            a
+            a;
           //^ i32
         }
     """)
@@ -173,7 +173,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
 
         fn main() {
             let a = f(0u8, 1u16);
-            a
+            a;
           //^ (u8, u16)
         }
     """)
@@ -183,7 +183,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
 
         fn main() {
             let a = f::<u8>(1);
-            a
+            a;
           //^ u8
         }
     """)
@@ -194,7 +194,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
         fn main() {
             let f = f::<u8>;
             let r = f(1);
-            r
+            r;
           //^ u8
         }
     """)
@@ -205,7 +205,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
         fn main() {
             let f = f::<u8, _>;
             let r = f(1, 2);
-            r
+            r;
           //^ (u8, i32)
         }
     """)
@@ -218,7 +218,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
 
         fn main() {
             let a = S::new(0i32);
-            a.value
+            a.value;
             //^ i32
         }
     """)
@@ -231,7 +231,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
 
         fn foo(s: S<char>) {
             let x = s.rec.field;
-            x
+            x;
           //^ char
         }
     """)
@@ -329,7 +329,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
         struct S<T> { a: T }
         fn main() {
             let x = S { a: 5u16 };
-            x.a
+            x.a;
             //^ u16
         }
     """)
@@ -339,7 +339,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
         struct S<T> { a: T, b: T }
         fn main() {
             let x = S { a: X, b: unimplemented!() };
-            x.b
+            x.b;
             //^ X
         }
     """)
@@ -349,7 +349,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
         struct S<T> { a: T, b: T }
         fn main() {
             let x = S { a: 0, b: 1u8 };
-            x.a
+            x.a;
             //^ u8
         }
     """)
@@ -359,7 +359,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
         struct S<T1, T2> { a: T1, b: T2 }
         fn main() {
             let x = S { a: X, b: Y };
-            (x.a, x.b)
+            (x.a, x.b);
           //^ (X, Y)
         }
     """)
@@ -368,7 +368,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
         struct S<T> {a: T}
         fn main() {
             let x = S::<u8>{a: 1};
-            x.a
+            x.a;
             //^ u8
         }
     """)
@@ -377,7 +377,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
         struct S<T1, T2> {a: T1, b: T2}
         fn main() {
             let x = S::<u8, _>{a: 1, b: 2};
-            (x.a, x.b)
+            (x.a, x.b);
           //^ (u8, i32)
         }
     """)
@@ -417,7 +417,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
         struct S<T> (T);
         fn main() {
             let x = S(5u16);
-            x.0
+            x.0;
             //^ u16
         }
     """)
@@ -426,7 +426,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
         struct S<T> (T);
         fn main() {
             let x = S::<u8>(1);
-            x.0
+            x.0;
             //^ u8
         }
     """)
@@ -435,7 +435,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
         struct S<T1, T2> (T1, T2);
         fn main() {
             let x = S::<u8, _>(1, 2);
-            (x.0, x.1)
+            (x.0, x.1);
           //^ (u8, i32)
         }
     """)
@@ -444,7 +444,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
         struct S<T>(T);
         fn main() {
             let f = S::<u8>;
-            f(1).0
+            f(1).0;
         }      //^ u8
     """)
 
@@ -455,7 +455,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
         }
         fn main() {
             let x = Foo::<u16>::new();
-            x
+            x;
           //^ Foo<u16>
         }
     """)
@@ -468,7 +468,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
         type B = A<u16, u8>;
 
         fn f(b: B) {
-            (b.0, (b.1).0, ((b.2).0).0)
+            (b.0, (b.1).0, ((b.2).0).0);
           //^ (u8, u16, u8)
         }
     """)
@@ -478,7 +478,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
         type T1 = S<u8>;
         type T2 = T1;
         fn main() {
-            T2 { a: 1 }
+            T2 { a: 1 };
         } //^ S<u8>
     """)
 
@@ -487,7 +487,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
         type T1<U> = S<U>;
         type T2 = T1<u8>;
         fn main() {
-            T2 { a: 1 }
+            T2 { a: 1 };
         } //^ S<u8>
     """)
 
@@ -496,7 +496,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
         type T1<U> = S<U>;
         type T2<V> = T1<V>;
         fn main() {
-            T2 { a: 1u8 }
+            T2 { a: 1u8 };
         } //^ S<u8>
     """)
 
@@ -505,7 +505,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
         fn foo<T>(xs: Foo<T>) -> T { unimplemented!() }
         fn main() {
             let x = foo(Foo(123));
-            x
+            x;
           //^ i32
         }
     """)
@@ -515,7 +515,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
         fn foo<T>(xs: Foo<T>) -> T { unimplemented!() }
         fn main() {
             let x = foo(Foo::V(123));
-            x
+            x;
           //^ i32
         }
     """)
@@ -524,7 +524,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
         fn foo<T, F>(xs: (T, F)) -> F { unimplemented!() }
         fn main() {
             let x = foo((123, "str"));
-            x
+            x;
           //^ &str
         }
     """)
@@ -533,7 +533,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
         fn foo<T>(xs: &T) -> T { unimplemented!() }
         fn main() {
             let x = foo(&8u64);
-            x
+            x;
           //^ u64
         }
     """)
@@ -542,7 +542,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
         fn foo<T>(xs: *const T) -> T { unimplemented!() }
         fn main() {
             let x = foo(&8u16 as *const u16);
-            x
+            x;
           //^ u16
         }
     """)
@@ -551,7 +551,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
         fn foo<T>(xs: [T; 4]) -> T { unimplemented!() }
         fn main() {
             let x = foo([1, 2, 3, 4]);
-            x
+            x;
           //^ i32
         }
     """)
@@ -583,7 +583,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
         fn foo<T>(xs: &[T]) -> T { unimplemented!() }
         fn main() {
             let x = foo(&[1, 2, 3]);
-            x
+            x;
           //^ i32
         }
     """)
@@ -593,7 +593,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
         fn main() {
             let a = [1, 2, 3];
             let x = foo(&a);
-            x
+            x;
           //^ i32
         }
     """)
@@ -606,7 +606,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
         }
         fn main() {
             let x = Foo("foo").foo(Bar(123));
-            x
+            x;
           //^ (&str, i32)
         }
     """)
@@ -619,7 +619,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
         }
         fn main() {
             let x = Foo(0.0).foo(Bar::V("bar"));
-            x
+            x;
           //^ (f64, &str)
         }
     """)
@@ -631,7 +631,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
         }
         fn main() {
             let x = Foo(123).foo((true, "str"));
-            x
+            x;
           //^ (i32, bool, &str)
         }
     """)
@@ -643,7 +643,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
         }
         fn main() {
             let x = Foo((1, 2)).foo(&8u64);
-            x
+            x;
           //^ (u64, (i32, i32))
         }
     """)
@@ -655,7 +655,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
         }
         fn main() {
             let x = Foo("foo").foo(&8u16 as *const u16);
-            x
+            x;
           //^ (u16, &str)
         }
     """)
@@ -667,7 +667,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
         }
         fn main() {
             let x = Foo(0.0).foo([1, 2, 3, 4]);
-            x
+            x;
           //^ (i32, f64)
         }
     """)
@@ -680,7 +680,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
         fn main() {
             let slice: &[&str] = &["foo", "bar"];
             let x = Foo(64u8).foo(slice);
-            x
+            x;
           //^ (&str, u8)
         }
     """)
@@ -695,7 +695,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
         }
         fn main() {
             let x = Foo(123, "foo").foo(FooBar(Bar::V([0.0; 3], (0, false))));
-            x
+            x;
           //^ (Bar<(i32, bool), i32>, Foo<[f64; 3], &str>)
         }
     """)
@@ -707,7 +707,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
         fn bar<A, B: Tr<A>>(b: B) -> A { b.foo() }
         fn main() {
             let a = bar(S(1));
-            a
+            a;
         } //^ i32
     """)
 
@@ -718,7 +718,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
         fn bar<E, F, G: Tr<(E, F)>>(b: G) -> (E, F) { b.foo() }
         fn main() {
             let a = bar(S((1u8, 1u16)));
-            a
+            a;
         } //^ (u8, u16)
     """)
 
@@ -748,7 +748,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
         impl<D> Tr<D> for S<D> {}
         fn main() {
             let a = S(X).wrap().wrap().wrap();
-            a
+            a;
         } //^ S<S<S<S<X>>>>
     """)
 
@@ -759,7 +759,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
         impl<D> Tr<D> for S<D> {}
         fn main() {
             let a = (&S(X)).wrap().wrap().wrap();
-            a
+            a;
         } //^ S<S<S<S<X>>>>
     """)
 
@@ -770,7 +770,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
         impl<D> Tr<D> for S<D> { fn wrap(self) -> S<Self> where Self: Sized { unimplemented!() } }
         fn main() {
             let a = S(X).wrap().wrap().wrap();
-            a
+            a;
         } //^ S<S<S<S<X>>>>
     """)
 
@@ -789,7 +789,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
 
         fn main() {
             let a = S1(X).wrap().wrap().wrap().fold();
-            a
+            a;
         } //^ X
     """)
 
@@ -802,7 +802,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
         impl Tr for X { type Item = u8; }
         fn main() {
             let a = S(X).foo();
-            a
+            a;
         } //^ u8
     """)
 
@@ -815,7 +815,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
         impl Tr for X { type Item = u8; }
         fn main() {
             let a = S(X).foo();
-            a
+            a;
         } //^ u8
     """)
 
@@ -830,7 +830,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
         impl Tr2 for X {}
         fn main() {
             let a = S(X).foo();
-            a
+            a;
         } //^ u8
     """)
 
@@ -845,7 +845,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
         impl Tr2 for X {}
         fn main() {
             let a = S(X).foo();
-            a
+            a;
         } //^ u8
     """)
 
@@ -860,7 +860,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
         impl Tr for Y { type Item = u16; }
         fn main() {
             let a = S(X, Y).foo();
-            a
+            a;
         } //^ (u8, u16)
     """)
 
@@ -880,7 +880,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
 
         fn main() {
             let a = S1(X).wrap().wrap().wrap().fold();
-            a
+            a;
         } //^ X
     """)
 
@@ -904,7 +904,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
 
         fn main() {
             let a = S1(X).wrap().wrap().wrap().fold();
-            a
+            a;
         } //^ X
     """)
 
@@ -941,7 +941,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
         }
         fn foo<T: Tr>(t: T) {
             let a = t.bar();
-            a
+            a;
         } //^ <T as Tr>::Item
     """)
 
@@ -954,7 +954,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
         fn foo<T: Tr>(t: T) -> T::Item { unimplemented!() }
         fn main() {
             let x = foo(S);
-            x
+            x;
           //^ i32
         }
     """)
@@ -970,9 +970,10 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
             where T1: Tr,
                   T1::Item: Tr2<T2>,
         { unimplemented!() }
+
         fn main() {
             let x = foo(S2);
-            x
+            x;
           //^ i32
         }
     """)
@@ -982,14 +983,14 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
 
         fn main() {
             let a: S<_> = S(0i32);
-            a
+            a;
         } //^ S<i32>
     """)
 
     fun `test simple unification 1`() = testExpr("""
         fn main() {
             let a: _ = 0i32;
-            a
+            a;
         } //^ i32
     """)
 
@@ -1028,14 +1029,14 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
         struct S<A, B> {a: A, b: B}
         fn main() {
             let a: S<u8, _> = S::<_, u16> {a: 0, b: 1};
-            a
+            a;
         } //^ S<u8, u16>
     """)
 
     fun `test unify struct fields`() = testExpr("""
         struct S<A> {a: A, b: A}
         fn main() {
-            S {a: 0, b: 1u8}
+            S {a: 0, b: 1u8};
         }       //^ u8
     """)
 
@@ -1063,7 +1064,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
             let b = collect::<S<_>>();
             let c = collect();
             foo(c);
-            (a, b, c)
+            (a, b, c);
         } //^ (S<i32>, S<i32>, S<i32>)
     """)
 
@@ -1084,7 +1085,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
             let b = it.collect::<S<_>>();
             let c = it.collect();
             foo(c);
-            (a, b, c)
+            (a, b, c);
         } //^ (S<X>, S<X>, S<X>)
     """)
 
@@ -1095,7 +1096,7 @@ class RsGenericExpressionTypeInferenceTest : RsTypificationTestBase() {
         fn main() {
             let a = 0;
             foo(S(X, a), S(Y, 1u8));
-            a
+            a;
         } //^ u8
     """, allowErrors = true)
 
diff --git a/src/test/kotlin/org/rust/lang/core/type/RsIndexTypeInferenceTest.kt b/src/test/kotlin/org/rust/lang/core/type/RsIndexTypeInferenceTest.kt
index 775b27c2e..34b74fafe 100644
--- a/src/test/kotlin/org/rust/lang/core/type/RsIndexTypeInferenceTest.kt
+++ b/src/test/kotlin/org/rust/lang/core/type/RsIndexTypeInferenceTest.kt
@@ -21,7 +21,7 @@ class RsIndexTypeInferenceTest : RsTypificationTestBase() {
 
         fn foo(s: S) {
             let x = s[0];
-            x
+            x;
           //^ i32
         }
     """)
@@ -38,7 +38,7 @@ class RsIndexTypeInferenceTest : RsTypificationTestBase() {
 
         fn foo(s: S<i64>) {
             let x = s[0];
-            x
+            x;
           //^ i64
         }
     """)
@@ -56,7 +56,7 @@ class RsIndexTypeInferenceTest : RsTypificationTestBase() {
 
         fn foo(s: S<i32, f64>) {
             let x = s[Key(10)];
-            x
+            x;
           //^ f64
         }
     """)
@@ -80,7 +80,7 @@ class RsIndexTypeInferenceTest : RsTypificationTestBase() {
 
         fn foo(s: S) {
             let x = s[0i64];
-            x
+            x;
           //^ i32
         }
     """)
@@ -97,7 +97,7 @@ class RsIndexTypeInferenceTest : RsTypificationTestBase() {
 
         fn foo(s: Vec<i32>) {
             let x = s[0];
-            x
+            x;
           //^ i32
         }
     """)
@@ -113,7 +113,7 @@ class RsIndexTypeInferenceTest : RsTypificationTestBase() {
         fn foo(v: Vec<u32>) -> u32 {
             let p = &v;
             let m = p[0];
-            m
+            m;
           //^ u32
         }
     """)
diff --git a/src/test/kotlin/org/rust/lang/core/type/RsNumericLiteralTypeInferenceTest.kt b/src/test/kotlin/org/rust/lang/core/type/RsNumericLiteralTypeInferenceTest.kt
index afa9aaca6..ff049ef9f 100644
--- a/src/test/kotlin/org/rust/lang/core/type/RsNumericLiteralTypeInferenceTest.kt
+++ b/src/test/kotlin/org/rust/lang/core/type/RsNumericLiteralTypeInferenceTest.kt
@@ -353,9 +353,9 @@ class RsNumericLiteralTypeInferenceTest : RsTypificationTestBase() {
 
     fun `test integer unification block`() = testExpr("""
         fn main() {
-        let a = 0;
-              //^ u8
-        let b: u8 = { a };
+            let a = 0;
+                  //^ u8
+            let b: u8 = { a };
         }
     """)
 
@@ -369,24 +369,24 @@ class RsNumericLiteralTypeInferenceTest : RsTypificationTestBase() {
 
     fun `test integer unification if else 2`() = testExpr("""
         fn main() {
-        let a = 0;
-              //^ u8
+            let a = 0;
+                  //^ u8
             let b: u8 = if true { 1 } else { a };
         }
     """)
 
     fun `test integer unification if else 3`() = testExpr("""
         fn main() {
-        let a = 0;
-              //^ u8
+            let a = 0;
+                  //^ u8
             let b: u8 = if true { 1 } else if true { a } else { 1 };
         }
     """)
 
     fun `test integer unification match`() = testExpr("""
         fn main() {
-        let a = 0;
-              //^ u8
+            let a = 0;
+                  //^ u8
             let b: u8 = match true {
                 true => a,
                 false => 1,
diff --git a/src/test/kotlin/org/rust/lang/core/type/RsPatternMatchingTest.kt b/src/test/kotlin/org/rust/lang/core/type/RsPatternMatchingTest.kt
index d1fb8c003..ea0cdeb09 100644
--- a/src/test/kotlin/org/rust/lang/core/type/RsPatternMatchingTest.kt
+++ b/src/test/kotlin/org/rust/lang/core/type/RsPatternMatchingTest.kt
@@ -64,7 +64,7 @@ class RsPatternMatchingTest : RsTypificationTestBase() {
 
         fn main() {
             let x: E = unimplemented!();
-            match x { E::S { foo } => foo }
+            match x { E::S { foo } => foo };
         }                           //^ i32
     """)
 
@@ -138,7 +138,7 @@ class RsPatternMatchingTest : RsTypificationTestBase() {
     fun `test literal pattern`() = testExpr("""
     fn main() {
         let x: (i32, String) = unimplemented!();
-        match x { (x, "foo") => x }
+        match x { (x, "foo") => x };
     }                         //^ i32
     """)
 
@@ -155,7 +155,7 @@ class RsPatternMatchingTest : RsTypificationTestBase() {
         struct S<T> { s: T }
         fn main() {
             let s = S { s: 123 };
-            match s { S { s: x } => x }
+            match s { S { s: x } => x };
                                   //^ i32
         }
     """)
@@ -167,7 +167,7 @@ class RsPatternMatchingTest : RsTypificationTestBase() {
                 E::L(x) => x,
                          //^ i32
                 E::R { r: x } => x
-            }
+            };
         }
     """)
 
@@ -178,7 +178,7 @@ class RsPatternMatchingTest : RsTypificationTestBase() {
                 E::L(x) => x,
                 E::R { r: x } => x
                                //^ bool
-            }
+            };
         }
     """)
 }