summaryrefslogtreecommitdiffstats
path: root/src/tools/rustfmt/tests/target/comment-not-disappear.rs
blob: b1fa0ff6fe119a5d8c9d08952d9f6979d20087c7 (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
33
34
35
36
37
38
// All the comments here should not disappear.

fn a() {
    match x {
        X |
        // A comment
        Y => {}
    };
}

fn b() {
    match x {
        X =>
        // A comment
        {
            y
        }
    }
}

fn c() {
    a() /* ... */;
}

fn foo() -> Vec<i32> {
    (0..11)
        .map(|x|
        // This comment disappears.
        if x % 2 == 0 { x } else { x * 2 })
        .collect()
}

fn calc_page_len(prefix_len: usize, sofar: usize) -> usize {
    2 // page type and flags
    + 1 // stored depth
    + 2 // stored count
    + prefix_len + sofar // sum of size of all the actual items
}