]> git.lizzy.rs Git - rust.git/blob - tests/target/chains-visual.rs
test fallout
[rust.git] / tests / target / chains-visual.rs
1 // rustfmt-normalize_comments: true
2 // rustfmt-single_line_if_else_max_width: 0
3 // rustfmt-chain_indent: Visual
4 // Test chain formatting.
5
6 fn main() {
7     // Don't put chains on a single line if it wasn't so in source.
8     let a = b.c.d.1.foo(|x| x + 1);
9
10     bbbbbbbbbbbbbbbbbbb.ccccccccccccccccccccccccccccccccccccc
11                        .ddddddddddddddddddddddddddd();
12
13     bbbbbbbbbbbbbbbbbbb.ccccccccccccccccccccccccccccccccccccc
14                        .ddddddddddddddddddddddddddd
15                        .eeeeeeee();
16
17     // Test case where first chain element isn't a path, but is shorter than
18     // the size of a tab.
19     x().y(|| match cond() {
20               true => (),
21               false => (),
22           });
23
24     loong_func().quux(move || if true {
25                           1
26                       } else {
27                           2
28                       });
29
30     some_fuuuuuuuuunction().method_call_a(aaaaa, bbbbb, |c| {
31         let x = c;
32         x
33     });
34
35     some_fuuuuuuuuunction()
36         .method_call_a(aaaaa, bbbbb, |c| {
37             let x = c;
38             x
39         })
40         .method_call_b(aaaaa, bbbbb, |c| {
41             let x = c;
42             x
43         });
44
45     fffffffffffffffffffffffffffffffffff(a, {
46         SCRIPT_TASK_ROOT.with(|root| { *root.borrow_mut() = Some(&script_task); });
47     });
48
49     let suuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuum =
50         xxxxxxx.map(|x| x + 5)
51                .map(|x| x / 2)
52                .fold(0, |acc, x| acc + x);
53
54     aaaaaaaaaaaaaaaa.map(|x| {
55                              x += 1;
56                              x
57                          })
58                     .filter(some_mod::some_filter)
59 }
60
61 fn floaters() {
62     let z = Foo {
63         field1: val1,
64         field2: val2,
65     };
66
67     let x = Foo {
68                 field1: val1,
69                 field2: val2,
70             }
71             .method_call()
72             .method_call();
73
74     let y = if cond {
75                 val1
76             } else {
77                 val2
78             }
79             .method_call();
80
81     {
82         match x {
83             PushParam => {
84                 // params are 1-indexed
85                 stack.push(mparams[match cur.to_digit(10) {
86                                Some(d) => d as usize - 1,
87                                None => return Err("bad param number".to_owned()),
88                            }]
89                            .clone());
90             }
91         }
92     }
93
94     if cond {
95         some();
96     } else {
97         none();
98     }
99     .bar()
100     .baz();
101
102     Foo { x: val }
103         .baz(|| {
104                  force();
105                  multiline();
106              })
107         .quux();
108
109     Foo {
110         y: i_am_multi_line,
111         z: ok,
112     }
113     .baz(|| {
114              force();
115              multiline();
116          })
117     .quux();
118
119     a +
120     match x {
121         true => "yay!",
122         false => "boo!",
123     }
124     .bar()
125 }
126
127 fn is_replaced_content() -> bool {
128     constellat.send(ConstellationMsg::ViewportConstrained(self.id, constraints))
129               .unwrap();
130 }
131
132 fn issue587() {
133     a.b::<()>(c);
134
135     std::mem::transmute(dl.symbol::<()>("init").unwrap())
136 }