about summary refs log tree commit diff
path: root/tests/coverage/closure_unit_return.coverage
blob: 02ea63b6dc394f75224efde058bdf15ad3aaebd5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
   LL|       |#![feature(coverage_attribute)]
   LL|       |//@ edition: 2021
   LL|       |
   LL|       |// Regression test for an inconsistency between functions that return the value
   LL|       |// of their trailing expression, and functions that implicitly return `()`.
   LL|       |
   LL|      1|fn explicit_unit() {
   LL|      1|    let closure = || {
                                   ^0
   LL|      0|        ();
   LL|      0|    };
   LL|       |
   LL|      1|    drop(closure);
   LL|      1|    () // explicit return of trailing value
   LL|      1|}
   LL|       |
   LL|      1|fn implicit_unit() {
   LL|      1|    let closure = || {
                                   ^0
   LL|      0|        ();
   LL|      0|    };
   LL|       |
   LL|      1|    drop(closure);
   LL|       |    // implicit return of `()`
   LL|      1|}
   LL|       |
   LL|       |#[coverage(off)]
   LL|       |fn main() {
   LL|       |    explicit_unit();
   LL|       |    implicit_unit();
   LL|       |}