]> 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
9              .d
10              .1
11              .foo(|x| x + 1);
12
13     bbbbbbbbbbbbbbbbbbb.ccccccccccccccccccccccccccccccccccccc.ddddddddddddddddddddddddddd();
14
15     bbbbbbbbbbbbbbbbbbb.ccccccccccccccccccccccccccccccccccccc
16                        .ddddddddddddddddddddddddddd
17                        .eeeeeeee();
18
19     // Test case where first chain element isn't a path, but is shorter than
20     // the size of a tab.
21     x().y(|| match cond() {
22               true => (),
23               false => (),
24           });
25
26     loong_func().quux(move || if true {
27                           1
28                       } else {
29                           2
30                       });
31
32     some_fuuuuuuuuunction().method_call_a(aaaaa, bbbbb, |c| {
33         let x = c;
34         x
35     });
36
37     some_fuuuuuuuuunction()
38         .method_call_a(aaaaa, bbbbb, |c| {
39             let x = c;
40             x
41         })
42         .method_call_b(aaaaa, bbbbb, |c| {
43             let x = c;
44             x
45         });
46
47     fffffffffffffffffffffffffffffffffff(a, {
48         SCRIPT_TASK_ROOT.with(|root| { *root.borrow_mut() = Some(&script_task); });
49     });
50
51     let suuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuum =
52         xxxxxxx.map(|x| x + 5).map(|x| x / 2).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)).unwrap();
129 }
130
131 fn issue587() {
132     a.b::<()>(c);
133
134     std::mem::transmute(dl.symbol::<()>("init").unwrap())
135 }