]> git.lizzy.rs Git - rust.git/blob - tests/target/chains-visual.rs
Format source codes and update tests
[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(
86                     mparams[match cur.to_digit(10) {
87                                 Some(d) => d as usize - 1,
88                                 None => return Err("bad param number".to_owned()),
89                             }]
90                     .clone(),
91                 );
92             }
93         }
94     }
95
96     if cond {
97         some();
98     } else {
99         none();
100     }
101     .bar()
102     .baz();
103
104     Foo { x: val }
105         .baz(|| {
106             force();
107             multiline();
108         })
109         .quux();
110
111     Foo {
112         y: i_am_multi_line,
113         z: ok,
114     }
115     .baz(|| {
116         force();
117         multiline();
118     })
119     .quux();
120
121     a + match x {
122         true => "yay!",
123         false => "boo!",
124     }
125     .bar()
126 }
127
128 fn is_replaced_content() -> bool {
129     constellat.send(ConstellationMsg::ViewportConstrained(self.id, constraints))
130               .unwrap();
131 }
132
133 fn issue587() {
134     a.b::<()>(c);
135
136     std::mem::transmute(dl.symbol::<()>("init").unwrap())
137 }
138
139 fn issue_1389() {
140     let names = String::from_utf8(names)?
141         .split('|')
142         .map(str::to_owned)
143         .collect();
144 }
145
146 fn issue1217() -> Result<Mnemonic, Error> {
147     let random_chars: String = OsRng::new()?
148         .gen_ascii_chars()
149         .take(self.bit_length)
150         .collect();
151
152     Ok(Mnemonic::new(&random_chars))
153 }
154
155 fn issue1236(options: Vec<String>) -> Result<Option<String>> {
156     let process = Command::new("dmenu")
157         .stdin(Stdio::piped())
158         .stdout(Stdio::piped())
159         .spawn()
160         .chain_err(|| "failed to spawn dmenu")?;
161 }
162
163 fn issue1434() {
164     for _ in 0..100 {
165         let prototype_id = PrototypeIdData::from_reader::<_, B>(&mut self.file_cursor)
166             .chain_err(|| {
167                 format!(
168                     "could not read prototype ID at offset {:#010x}",
169                     current_offset
170                 )
171             })?;
172     }
173 }