summaryrefslogtreecommitdiffstats
path: root/src/tools/rustfmt/tests/source/chains-visual.rs
blob: 20a96311e34142fbf6b790d4e047a8e56dc7d075 (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
// rustfmt-indent_style: Visual
// Test chain formatting.

fn main() {
    // Don't put chains on a single line if it wasn't so in source.
    let a = b .c
    .d.1
                .foo(|x| x + 1);

    bbbbbbbbbbbbbbbbbbb.ccccccccccccccccccccccccccccccccccccc
                       .ddddddddddddddddddddddddddd();

    bbbbbbbbbbbbbbbbbbb.ccccccccccccccccccccccccccccccccccccc.ddddddddddddddddddddddddddd.eeeeeeee();

    // Test case where first chain element isn't a path, but is shorter than
    // the size of a tab.
    x()
        .y(|| match cond() { true => (), false => () });

    loong_func()
        .quux(move || if true {
            1
        } else {
            2
        });

    some_fuuuuuuuuunction()
        .method_call_a(aaaaa, bbbbb, |c| {
            let x = c;
            x
        });

    some_fuuuuuuuuunction().method_call_a(aaaaa, bbbbb, |c| {
        let x = c;
        x
    }).method_call_b(aaaaa, bbbbb, |c| {
        let x = c;
        x
    });

    fffffffffffffffffffffffffffffffffff(a,
                                        {
                                            SCRIPT_TASK_ROOT
                                            .with(|root| {
                                                *root.borrow_mut()  =   Some(&script_task);
                                            });
                                        });                                        

    let suuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuum = xxxxxxx
        .map(|x| x + 5)
        .map(|x| x / 2)
        .fold(0, |acc, x| acc + x);

    aaaaaaaaaaaaaaaa.map(|x| {
                         x += 1;
                         x
                     }).filter(some_mod::some_filter)
}

fn floaters() {
    let z = Foo {
        field1: val1,
        field2: val2,
    };

    let x = Foo {
        field1: val1,
        field2: val2,
    }.method_call().method_call();

    let y = if cond {
                val1
            } else {
                val2
            }
                .method_call();

    {
        match x {
            PushParam => {
                // params are 1-indexed
                stack.push(mparams[match cur.to_digit(10) {
                    Some(d) => d as usize - 1,
                    None => return Err("bad param number".to_owned()),
                }]
                               .clone());
            }
        }
    }

    if cond { some(); } else { none(); }
        .bar()
        .baz();

    Foo { x: val } .baz(|| { force(); multiline();    }) .quux(); 

    Foo { y: i_am_multi_line, z: ok }
        .baz(|| {
            force(); multiline();
        })
        .quux(); 

    a + match x { true => "yay!", false => "boo!" }.bar()
}

fn is_replaced_content() -> bool {
    constellat.send(ConstellationMsg::ViewportConstrained(
            self.id, constraints)).unwrap();
}

fn issue587() {
    a.b::<()>(c);

    std::mem::transmute(dl.symbol::<()>("init").unwrap())
}

fn issue_1389() {
    let names = String::from_utf8(names)?.split('|').map(str::to_owned).collect();
}

fn issue1217() -> Result<Mnemonic, Error> {
let random_chars: String = OsRng::new()?
    .gen_ascii_chars()
    .take(self.bit_length)
    .collect();

    Ok(Mnemonic::new(&random_chars))
}

fn issue1236(options: Vec<String>) -> Result<Option<String>> {
let process = Command::new("dmenu").stdin(Stdio::piped())
    .stdout(Stdio::piped())
    .spawn()
    .chain_err(|| "failed to spawn dmenu")?;
}

fn issue1434() {
    for _ in 0..100 {
        let prototype_id = PrototypeIdData::from_reader::<_, B>(&mut self.file_cursor).chain_err(|| {
            format!("could not read prototype ID at offset {:#010x}",
                    current_offset)
        })?;
    }
}

fn issue2264() {
    {
        something.function()
            .map(|| {
                if let a_very_very_very_very_very_very_very_very_long_variable =
                    compute_this_variable()
                {
                    println!("Hello");
                }
            })
            .collect();
    }
}