1 // rustfmt-normalize_comments: true
2 // rustfmt-wrap_comments: true
6 let boxed: Box<i32> = box 5;
9 let very_long_variable_name = (a + first + simple + test);
10 let very_long_variable_name =
11 (a + first + simple + test + AAAAAAAAAAAAA + BBBBBBBBBBBBBBBBB + b + c);
14 self.source_map.span_to_filename(s) == self.source_map.span_to_filename(m.inner);
16 let some_val = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa * bbbb
17 / (bbbbbb - function_call(x, *very_long_pointer, y))
20 some_ridiculously_loooooooooooooooooooooong_function(
21 10000 * 30000000000 + 40000 / 1002200000000 - 50000 * sqrt(-1),
24 (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
26 + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
48 if let Some(x) = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa {
53 (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)
58 tuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuple,
64 tuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuple,
70 tuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuple,
74 if let ast::ItemKind::Trait(_, unsafety, ref generics, ref type_param_bounds, ref trait_items) =
80 let test = if true { 5 } else { 3 };
84 } else if different_cond() {
87 // Check subformatting
88 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
89 + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
96 const fn get(&self) -> usize {
106 (111111111 + 333333333333333333 + 1111 + 400000000000000000)..(2222 + 2333333333333333);
108 let another_range = 5..some_func(a, b /* comment */);
114 syntactically_correct(
118 if cond { 0 } else { 1 },
125 let nonsense = (10..0)..(0..10);
134 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa && aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
140 unsafe /* {}{}{}{{{{}} */ {
144 unsafe /* very looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong
148 unsafe /* So this is a very long comment.
150 * Will it still format correctly? */ {
154 // Regular unsafe block
164 let identifier_0 = unsafe { this_is_58_chars_long_and_line_is_93_chars_long_xxxxxxxxxx };
165 let identifier_1 = unsafe { this_is_59_chars_long_and_line_is_94_chars_long_xxxxxxxxxxx };
166 let identifier_2 = unsafe { this_is_65_chars_long_and_line_is_100_chars_long_xxxxxxxxxxxxxxxx };
168 unsafe { this_is_66_chars_long_and_line_is_101_chars_long_xxxxxxxxxxxxxxxxx };
171 // Test some empty blocks.
174 // FIXME this one could be done better.
175 { /* a block with a comment */ }
178 // A block with a comment.
185 box DocumentProgressHandler::new(addr, DocumentProgressTask::DOMContentLoaded);
189 fn issue184(source: &str) {
190 for c in source.chars() {
199 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 7, 8, 9, 0, 1, 2, 3, 4, 5,
203 let y = [/* comment */ 1, 2 /* post comment */, 3];
207 test123: value_one_two_three_four,
214 let a = WeightedChoice::new(&mut [
234 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,
235 yyyyyyyyyyyyyyyyyyyyyyyyyyy,
240 [1 + 3, 4, 5, 6, 7, 7, fncall::<Vec<_>>(3 - 1)]
244 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
247 return aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
248 + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
252 &mut (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
253 + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb);
254 &(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
255 + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb);
259 fn unpack(packed: u32) -> [u16; 2] {
260 [(packed >> 16) as u16, (packed >> 0) as u16]
263 let some_trait_xxx = xxxxxxxxxxx + xxxxxxxxxxxxx as SomeTraitXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX;
264 let slightly_longer_trait =
265 yyyyyyyyy + yyyyyyyyyyy as SomeTraitYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY;
269 let x = (aaaaaaaaaaaaaaaaaaaaaaaaaaaa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb + cccccccccccccccc)
271 let y = (aaaaaaaaaaaaaaaaaaaaaaaaaaaa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb + cccccccccccccccc)
272 [xxxxx + yyyyy + zzzzz];
276 .zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz()[aaaaa];
280 .zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz()
285 let x = [aaaaaaaaaaaaaaaaaaaaaaaaaaaa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb + cccccccccccccccc;
287 let y = [aaaaaaaaaaaaaaaaaaaaaaaaaaaa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb + cccccccccccccccc;
288 xxxxx + yyyyy + zzzzz];
293 println!("yay arithmetix!");
301 // A let binding here seems necessary to trigger it.
304 } else if let false = false {
309 let x = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa..bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb;
311 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa..=bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb;
316 let x = [0. ..=10.0];
320 // the expr below won't compile because inclusive ranges need a defined end
325 let exact = diff / (if size == 0 { 1 } else { size });
327 let cx = tp1.x + any * radius * if anticlockwise { 1.0 } else { -1.0 };
330 fn complex_if_else() {
331 if let Some(x) = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx {
332 } else if let Some(x) = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx {
334 } else if xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxx {
336 } else if let Some(x) = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
339 } else if xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxx
347 if let hir::ItemEnum(ref enum_def, ref generics) =
348 self.ast_map.expect_item(enum_node_id).node
352 for entry in WalkDir::new(path)
354 .filter_entry(|entry| exclusions.filter_entry(entry))
359 a_very_long_function_name({ some_func(1, { 1 }) })
363 v = &mut { v }[mid..];
364 let (left, right) = { v }.split_at_mut(mid);
367 // Multi-lined index should be put on the next line if it fits in one line.
372 if self.shape[(r as f32 + self.x_offset) as usize]
373 [(c as f32 + self.y_offset) as usize]
384 fn newlines_between_list_like_expr() {
386 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,
387 yyyyyyyyyyyyyyyyyyyyyyyyyyyyyy,
388 zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz,
392 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,
393 yyyyyyyyyyyyyyyyyyyyyyyyyyyyyy,
394 zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz,
398 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
399 | yyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
400 | zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz => foo(a, b, c),
408 .map(|item| ls_util::rls_to_location(item))
422 .experimental_compressed_block_size as usize
430 .. .. ..; // (.. (.. (..)))
432 (..).. ..; // ((..) .. (..))
436 // A function call with a large single argument.
438 let my_var = Mutex::new(
439 RpcClientType::connect(server_iddd).chain_err(|| "Unable to create RPC client")?,
444 // Method call with prefix and suffix.
446 // We should not combine the callee with a multi-lined method call.
447 let requires = requires.set(
453 let requires = requires.set(
459 let requires = requires.set(
463 .distinct_total() as u32,
465 let requires = requires.set(
471 let requires = requires.set(
477 // We should combine a small callee with an argument.
483 // But we should not combine a long callee with an argument.
525 function_to_fill_this_line(some_arg, some_arg, some_arg)
526 * a_very_specific_length(specific_length_arg)
527 * very_specific_length(Foo {
528 a: some_much_much_longer_value,
534 let mut path: PathBuf = [
535 env!("CARGO_MANIFEST_DIR"),
538 "dejavu-fonts-ttf-2.37",