2017-03-19 16:25:37 -05:00
|
|
|
// rustfmt-array_layout: Block
|
2017-03-27 16:43:46 -05:00
|
|
|
// rustfmt-fn_call_style: Block
|
2017-05-04 21:29:18 -05:00
|
|
|
// rustfmt-control_style: Rfc
|
2017-03-19 16:25:37 -05:00
|
|
|
// Test expressions with block formatting.
|
|
|
|
|
|
|
|
fn arrays() {
|
|
|
|
[];
|
|
|
|
let empty = [];
|
|
|
|
|
2017-04-05 20:06:11 -05:00
|
|
|
let foo = [a_long_name, a_very_lng_name, a_long_name];
|
2017-03-19 16:25:37 -05:00
|
|
|
|
|
|
|
let foo = [
|
|
|
|
a_long_name,
|
|
|
|
a_very_lng_name,
|
|
|
|
a_long_name,
|
|
|
|
a_very_lng_name,
|
|
|
|
a_long_name,
|
|
|
|
a_very_lng_name,
|
|
|
|
a_long_name,
|
|
|
|
a_very_lng_name,
|
|
|
|
];
|
|
|
|
|
|
|
|
vec![
|
|
|
|
a_long_name,
|
|
|
|
a_very_lng_name,
|
|
|
|
a_long_name,
|
|
|
|
a_very_lng_name,
|
|
|
|
a_long_name,
|
|
|
|
a_very_lng_name,
|
|
|
|
a_very_lng_name,
|
|
|
|
];
|
|
|
|
|
|
|
|
[
|
|
|
|
a_long_name,
|
|
|
|
a_very_lng_name,
|
|
|
|
a_long_name,
|
|
|
|
a_very_lng_name,
|
|
|
|
a_long_name,
|
|
|
|
a_very_lng_name,
|
|
|
|
a_very_lng_name,
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
fn arrays() {
|
|
|
|
let x = [
|
|
|
|
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,
|
|
|
|
6,
|
|
|
|
7,
|
|
|
|
8,
|
|
|
|
9,
|
|
|
|
0,
|
|
|
|
];
|
|
|
|
|
2017-08-27 00:41:30 -05:00
|
|
|
let y = [/* comment */ 1, 2 /* post comment */, 3];
|
2017-03-19 16:25:37 -05:00
|
|
|
|
|
|
|
let xy = [
|
|
|
|
strukt {
|
|
|
|
test123: value_one_two_three_four,
|
|
|
|
turbo: coolio(),
|
|
|
|
},
|
2017-08-08 04:24:06 -05:00
|
|
|
/* comment */ 1,
|
2017-03-19 16:25:37 -05:00
|
|
|
];
|
|
|
|
|
2017-06-28 21:01:22 -05:00
|
|
|
let a = WeightedChoice::new(&mut [
|
|
|
|
Weighted { weight: x, item: 0 },
|
|
|
|
Weighted { weight: 1, item: 1 },
|
|
|
|
Weighted { weight: x, item: 2 },
|
|
|
|
Weighted { weight: 1, item: 3 },
|
|
|
|
]);
|
2017-03-19 16:25:37 -05:00
|
|
|
|
2017-04-05 20:06:11 -05:00
|
|
|
let z = [
|
|
|
|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,
|
|
|
|
yyyyyyyyyyyyyyyyyyyyyyyyyyy,
|
|
|
|
zzzzzzzzzzzzzzzzz,
|
|
|
|
q,
|
|
|
|
];
|
2017-03-19 16:25:37 -05:00
|
|
|
|
|
|
|
[1 + 3, 4, 5, 6, 7, 7, fncall::<Vec<_>>(3 - 1)]
|
|
|
|
}
|
2017-03-27 16:43:46 -05:00
|
|
|
|
|
|
|
fn function_calls() {
|
|
|
|
let items = itemize_list(
|
|
|
|
context.codemap,
|
|
|
|
args.iter(),
|
|
|
|
")",
|
2017-08-19 13:47:40 -05:00
|
|
|
|item| item.span.lo(),
|
|
|
|
|item| item.span.hi(),
|
2017-03-27 16:43:46 -05:00
|
|
|
|item| {
|
|
|
|
item.rewrite(
|
|
|
|
context,
|
|
|
|
Shape {
|
|
|
|
width: remaining_width,
|
|
|
|
..nested_shape
|
|
|
|
},
|
|
|
|
)
|
|
|
|
},
|
2017-08-19 13:47:40 -05:00
|
|
|
span.lo(),
|
|
|
|
span.hi(),
|
2017-03-27 16:43:46 -05:00
|
|
|
);
|
|
|
|
|
|
|
|
itemize_list(
|
|
|
|
context.codemap,
|
|
|
|
args.iter(),
|
|
|
|
")",
|
2017-08-19 13:47:40 -05:00
|
|
|
|item| item.span.lo(),
|
|
|
|
|item| item.span.hi(),
|
2017-03-27 16:43:46 -05:00
|
|
|
|item| {
|
|
|
|
item.rewrite(
|
|
|
|
context,
|
|
|
|
Shape {
|
|
|
|
width: remaining_width,
|
|
|
|
..nested_shape
|
|
|
|
},
|
|
|
|
)
|
|
|
|
},
|
2017-08-19 13:47:40 -05:00
|
|
|
span.lo(),
|
|
|
|
span.hi(),
|
2017-03-27 16:43:46 -05:00
|
|
|
)
|
|
|
|
}
|
2017-04-03 17:15:11 -05:00
|
|
|
|
|
|
|
fn macros() {
|
|
|
|
baz!(
|
|
|
|
do_not,
|
|
|
|
add,
|
|
|
|
trailing,
|
|
|
|
commas,
|
|
|
|
inside,
|
|
|
|
of,
|
|
|
|
function,
|
|
|
|
like,
|
|
|
|
macros,
|
|
|
|
even,
|
|
|
|
if_they,
|
|
|
|
are,
|
|
|
|
long
|
|
|
|
);
|
|
|
|
|
|
|
|
baz!(one_item_macro_which_is_also_loooooooooooooooooooooooooooooooooooooooooooooooong);
|
|
|
|
|
|
|
|
let _ = match option {
|
2017-07-11 07:53:48 -05:00
|
|
|
None => baz!(
|
|
|
|
function,
|
|
|
|
like,
|
|
|
|
macro_as,
|
|
|
|
expression,
|
|
|
|
which,
|
|
|
|
is,
|
|
|
|
loooooooooooooooong
|
|
|
|
),
|
2017-04-03 17:15:11 -05:00
|
|
|
Some(p) => baz!(one_item_macro_as_expression_which_is_also_loooooooooooooooong),
|
|
|
|
};
|
|
|
|
}
|
2017-05-04 21:29:18 -05:00
|
|
|
|
|
|
|
fn issue_1450() {
|
|
|
|
if selfstate
|
|
|
|
.compare_exchandsfasdsdfgsdgsdfgsdfgsdfgsdfgsdfgfsfdsage_weak(
|
|
|
|
STATE_PARKED,
|
|
|
|
STATE_UNPARKED,
|
|
|
|
Release,
|
|
|
|
Relaxed,
|
|
|
|
Release,
|
|
|
|
Relaxed,
|
|
|
|
)
|
|
|
|
.is_ok()
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn foo() {
|
2017-09-14 22:20:58 -05:00
|
|
|
if real_total <= limit && !pre_line_comments
|
|
|
|
&& !items.into_iter().any(|item| item.as_ref().is_multiline())
|
2017-05-04 21:29:18 -05:00
|
|
|
{
|
|
|
|
DefinitiveListTactic::Horizontal
|
|
|
|
}
|
|
|
|
}
|
2017-05-21 05:56:37 -05:00
|
|
|
|
|
|
|
fn combine_block() {
|
|
|
|
foo(Bar {
|
|
|
|
x: value,
|
|
|
|
y: value2,
|
|
|
|
});
|
|
|
|
|
2017-05-22 21:20:29 -05:00
|
|
|
foo((Bar {
|
|
|
|
x: value,
|
|
|
|
y: value2,
|
|
|
|
},));
|
|
|
|
|
|
|
|
foo((
|
|
|
|
1,
|
|
|
|
2,
|
|
|
|
3,
|
|
|
|
Bar {
|
|
|
|
x: value,
|
|
|
|
y: value2,
|
|
|
|
},
|
|
|
|
));
|
|
|
|
|
|
|
|
foo((1, 2, 3, |x| {
|
|
|
|
let y = x + 1;
|
|
|
|
let z = y + 1;
|
|
|
|
z
|
|
|
|
}));
|
|
|
|
|
2017-05-21 05:56:37 -05:00
|
|
|
let opt = Some(Struct(
|
|
|
|
long_argument_one,
|
|
|
|
long_argument_two,
|
|
|
|
long_argggggggg,
|
|
|
|
));
|
|
|
|
|
|
|
|
do_thing(|param| {
|
|
|
|
action();
|
|
|
|
foo(param)
|
|
|
|
});
|
|
|
|
|
|
|
|
do_thing(x, |param| {
|
|
|
|
action();
|
|
|
|
foo(param)
|
|
|
|
});
|
|
|
|
|
2017-06-18 21:25:21 -05:00
|
|
|
do_thing(
|
|
|
|
x,
|
|
|
|
(1, 2, 3, |param| {
|
|
|
|
action();
|
|
|
|
foo(param)
|
|
|
|
}),
|
|
|
|
);
|
2017-05-22 22:03:04 -05:00
|
|
|
|
2017-05-21 05:56:37 -05:00
|
|
|
Ok(some_function(
|
|
|
|
lllllllllong_argument_one,
|
|
|
|
lllllllllong_argument_two,
|
|
|
|
lllllllllllllllllllllllllllllong_argument_three,
|
|
|
|
));
|
|
|
|
|
|
|
|
foo(
|
|
|
|
thing,
|
|
|
|
bar(
|
|
|
|
param2,
|
|
|
|
pparam1param1param1param1param1param1param1param1param1param1aram1,
|
|
|
|
param3,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
foo.map_or(|| {
|
|
|
|
Ok(SomeStruct {
|
|
|
|
f1: 0,
|
|
|
|
f2: 0,
|
|
|
|
f3: 0,
|
|
|
|
})
|
|
|
|
});
|
|
|
|
|
|
|
|
match opt {
|
|
|
|
Some(x) => somefunc(anotherfunc(
|
|
|
|
long_argument_one,
|
|
|
|
long_argument_two,
|
|
|
|
long_argument_three,
|
|
|
|
)),
|
2017-05-22 22:03:04 -05:00
|
|
|
Some(x) => |x| {
|
|
|
|
let y = x + 1;
|
|
|
|
let z = y + 1;
|
|
|
|
z
|
|
|
|
},
|
|
|
|
Some(x) => (1, 2, |x| {
|
|
|
|
let y = x + 1;
|
|
|
|
let z = y + 1;
|
|
|
|
z
|
|
|
|
}),
|
|
|
|
Some(x) => SomeStruct {
|
|
|
|
f1: long_argument_one,
|
|
|
|
f2: long_argument_two,
|
|
|
|
f3: long_argument_three,
|
|
|
|
},
|
2017-05-21 05:56:37 -05:00
|
|
|
None => Ok(SomeStruct {
|
|
|
|
f1: long_argument_one,
|
|
|
|
f2: long_argument_two,
|
|
|
|
f3: long_argument_three,
|
|
|
|
}),
|
|
|
|
};
|
|
|
|
|
|
|
|
match x {
|
2017-09-18 21:41:50 -05:00
|
|
|
y => func(xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx),
|
2017-07-11 07:53:48 -05:00
|
|
|
_ => func(
|
|
|
|
x,
|
|
|
|
yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy,
|
|
|
|
zzz,
|
|
|
|
),
|
2017-05-21 05:56:37 -05:00
|
|
|
}
|
|
|
|
}
|
2017-08-08 04:24:06 -05:00
|
|
|
|
|
|
|
fn issue_1862() {
|
|
|
|
foo(
|
|
|
|
/* bar = */ None,
|
|
|
|
something_something,
|
|
|
|
/* baz = */ None,
|
|
|
|
/* This comment waaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaay too long to be kept on the same line */
|
|
|
|
None,
|
|
|
|
/* com */
|
|
|
|
this_last_arg_is_tooooooooooooooooooooooooooooooooo_long_to_be_kept_with_the_pre_comment,
|
|
|
|
)
|
|
|
|
}
|
2017-08-12 20:17:52 -05:00
|
|
|
|
|
|
|
fn issue_1878() {
|
|
|
|
let channel: &str = seq.next_element()?
|
|
|
|
.ok_or_else(|| de::Error::invalid_length(2, &self))?;
|
|
|
|
}
|