2015-11-09 19:03:01 +00:00
|
|
|
// rustfmt-wrap_comments: true
|
2015-07-02 20:40:20 +00:00
|
|
|
// Test expressions
|
|
|
|
|
|
|
|
fn foo() -> bool {
|
2015-07-23 21:08:41 +00:00
|
|
|
let boxed: Box<i32> = box 5;
|
|
|
|
let referenced = &5;
|
|
|
|
|
2015-07-02 20:40:20 +00:00
|
|
|
let very_long_variable_name = (a + first + simple + test);
|
2015-08-19 03:15:54 +00:00
|
|
|
let very_long_variable_name = (a + first + simple + test + AAAAAAAAAAAAA +
|
|
|
|
BBBBBBBBBBBBBBBBB + b + c);
|
2015-07-02 20:40:20 +00:00
|
|
|
|
2015-08-21 11:31:09 +00:00
|
|
|
let is_internalxxxx = self.codemap.span_to_filename(s) ==
|
|
|
|
self.codemap.span_to_filename(m.inner);
|
2015-07-24 13:29:04 +00:00
|
|
|
|
2015-07-02 20:40:20 +00:00
|
|
|
let some_val = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa * bbbb /
|
|
|
|
(bbbbbb - function_call(x, *very_long_pointer, y)) + 1000;
|
|
|
|
|
|
|
|
some_ridiculously_loooooooooooooooooooooong_function(10000 * 30000000000 +
|
2015-08-19 03:15:54 +00:00
|
|
|
40000 / 1002200000000 -
|
|
|
|
50000 * sqrt(-1),
|
2015-07-02 22:50:55 +00:00
|
|
|
trivial_value);
|
|
|
|
(((((((((aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
|
2015-08-19 03:15:54 +00:00
|
|
|
a +
|
|
|
|
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
|
2015-07-19 21:42:54 +00:00
|
|
|
aaaaa)))))))));
|
|
|
|
|
2015-07-20 21:29:25 +00:00
|
|
|
{
|
2015-08-16 04:13:55 +00:00
|
|
|
for _ in 0..10 {}
|
2015-07-20 21:29:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
{
|
2015-08-16 04:13:55 +00:00
|
|
|
{}
|
2015-07-20 21:29:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-19 21:42:54 +00:00
|
|
|
if 1 + 2 > 0 {
|
|
|
|
let result = 5;
|
|
|
|
result
|
|
|
|
} else {
|
|
|
|
4
|
2015-11-09 00:23:19 +00:00
|
|
|
};
|
2015-07-19 21:42:54 +00:00
|
|
|
|
2015-07-19 20:25:44 +00:00
|
|
|
if let Some(x) = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa {
|
|
|
|
// Nothing
|
|
|
|
}
|
|
|
|
|
|
|
|
if let Some(x) = (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
|
2015-08-16 04:13:55 +00:00
|
|
|
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}
|
2015-07-19 20:25:44 +00:00
|
|
|
|
|
|
|
if let (some_very_large,
|
|
|
|
tuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuple) = 1 + 2 + 3 {
|
|
|
|
}
|
|
|
|
|
|
|
|
if let (some_very_large,
|
|
|
|
tuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuple) = 1111 +
|
2015-08-16 04:13:55 +00:00
|
|
|
2222 {}
|
2015-07-19 20:25:44 +00:00
|
|
|
|
2015-10-17 13:56:53 +00:00
|
|
|
if let (some_very_large,
|
|
|
|
tuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuple) = 1 + 2 + 3 {
|
2015-07-20 21:29:25 +00:00
|
|
|
}
|
|
|
|
|
2015-08-25 19:46:58 +00:00
|
|
|
let test = if true {
|
|
|
|
5
|
|
|
|
} else {
|
|
|
|
3
|
|
|
|
};
|
|
|
|
|
2015-07-19 21:42:54 +00:00
|
|
|
if cond() {
|
|
|
|
something();
|
|
|
|
} else if different_cond() {
|
|
|
|
something_else();
|
|
|
|
} else {
|
|
|
|
// Check subformatting
|
|
|
|
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
|
|
|
|
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
|
|
|
}
|
2015-07-02 20:40:20 +00:00
|
|
|
}
|
2015-07-20 21:29:25 +00:00
|
|
|
|
|
|
|
fn bar() {
|
|
|
|
let range = (111111111 + 333333333333333333 + 1111 + 400000000000000000)..(2222 +
|
|
|
|
2333333333333333);
|
|
|
|
|
|
|
|
let another_range = 5..some_func(a, b /* comment */);
|
|
|
|
|
|
|
|
for _ in 1.. {
|
|
|
|
call_forever();
|
|
|
|
}
|
|
|
|
|
|
|
|
syntactically_correct(loop {
|
2015-09-09 21:09:39 +00:00
|
|
|
sup('?');
|
|
|
|
},
|
2015-07-20 21:29:25 +00:00
|
|
|
if cond {
|
2015-09-09 21:09:39 +00:00
|
|
|
0
|
|
|
|
} else {
|
|
|
|
1
|
|
|
|
});
|
2015-07-20 21:29:25 +00:00
|
|
|
|
|
|
|
let third = ..10;
|
|
|
|
let infi_range = ..;
|
|
|
|
let foo = 1..;
|
|
|
|
let bar = 5;
|
|
|
|
let nonsense = (10..0)..(0..10);
|
2015-07-25 21:28:31 +00:00
|
|
|
|
2015-09-03 18:15:24 +00:00
|
|
|
loop {
|
|
|
|
if true {
|
2015-10-13 06:17:51 +00:00
|
|
|
break;
|
2015-09-03 18:15:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-25 21:28:31 +00:00
|
|
|
let x = (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa && aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
|
|
|
|
a);
|
2015-07-02 20:40:20 +00:00
|
|
|
}
|
2015-08-01 12:22:31 +00:00
|
|
|
|
|
|
|
fn baz() {
|
|
|
|
unsafe /* {}{}{}{{{{}} */ {
|
|
|
|
let foo = 1u32;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsafe /* very looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong
|
|
|
|
* comment */ {
|
|
|
|
}
|
|
|
|
|
|
|
|
unsafe /* So this is a very long comment.
|
|
|
|
* Multi-line, too.
|
|
|
|
* Will it still format correctly? */ {
|
|
|
|
}
|
|
|
|
|
|
|
|
unsafe {
|
|
|
|
// Regular unsafe block
|
|
|
|
}
|
2015-09-05 06:26:28 +00:00
|
|
|
|
|
|
|
unsafe { foo() }
|
|
|
|
|
|
|
|
unsafe {
|
|
|
|
foo();
|
|
|
|
}
|
2015-08-01 12:22:31 +00:00
|
|
|
}
|
2015-08-16 04:13:55 +00:00
|
|
|
|
|
|
|
// Test some empty blocks.
|
|
|
|
fn qux() {
|
|
|
|
{}
|
|
|
|
// FIXME this one could be done better.
|
2015-10-19 19:41:47 +00:00
|
|
|
{
|
|
|
|
// a block with a comment
|
2015-08-16 04:13:55 +00:00
|
|
|
}
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
{
|
|
|
|
// A block with a comment.
|
|
|
|
}
|
|
|
|
}
|
2015-08-31 17:15:40 +00:00
|
|
|
|
|
|
|
fn issue227() {
|
|
|
|
{
|
|
|
|
let handler = box DocumentProgressHandler::new(addr,
|
|
|
|
DocumentProgressTask::DOMContentLoaded);
|
|
|
|
}
|
|
|
|
}
|
2015-09-11 21:32:13 +00:00
|
|
|
|
|
|
|
fn issue184(source: &str) {
|
|
|
|
for c in source.chars() {
|
|
|
|
if index < 'a' {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-09-11 22:06:17 +00:00
|
|
|
|
|
|
|
fn arrays() {
|
2015-10-16 20:54:32 +00:00
|
|
|
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];
|
2015-09-11 22:06:17 +00:00
|
|
|
|
|
|
|
let y = [// comment
|
|
|
|
1,
|
|
|
|
2, // post comment
|
|
|
|
3];
|
|
|
|
|
2015-10-12 19:14:12 +00:00
|
|
|
let xy = [strukt {
|
|
|
|
test123: value_one_two_three_four,
|
|
|
|
turbo: coolio(),
|
|
|
|
},
|
|
|
|
// comment
|
|
|
|
1];
|
|
|
|
|
|
|
|
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,
|
|
|
|
}]);
|
|
|
|
|
2015-09-11 22:06:17 +00:00
|
|
|
let z = [xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,
|
|
|
|
yyyyyyyyyyyyyyyyyyyyyyyyyyy,
|
|
|
|
zzzzzzzzzzzzzzzzzz,
|
|
|
|
q];
|
|
|
|
|
|
|
|
[1 + 3, 4, 5, 6, 7, 7, fncall::<Vec<_>>(3 - 1)]
|
|
|
|
}
|
2015-09-24 05:51:37 +00:00
|
|
|
|
|
|
|
fn returns() {
|
|
|
|
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &&
|
|
|
|
return;
|
|
|
|
|
|
|
|
return aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
|
|
|
|
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
|
|
|
}
|
2015-09-24 08:13:57 +00:00
|
|
|
|
|
|
|
fn addrof() {
|
|
|
|
&mut (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
|
|
|
|
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb);
|
|
|
|
&(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
|
|
|
|
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb);
|
|
|
|
}
|
2015-10-02 09:31:40 +00:00
|
|
|
|
|
|
|
fn casts() {
|
|
|
|
fn unpack(packed: u32) -> [u16; 2] {
|
|
|
|
[(packed >> 16) as u16, (packed >> 0) as u16]
|
|
|
|
}
|
|
|
|
|
|
|
|
let some_trait_xxx = xxxxxxxxxxx + xxxxxxxxxxxxx as SomeTraitXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX;
|
|
|
|
let slightly_longer_trait = yyyyyyyyy +
|
|
|
|
yyyyyyyyyyy as SomeTraitYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY;
|
|
|
|
}
|
2015-10-02 09:47:03 +00:00
|
|
|
|
|
|
|
fn indices() {
|
|
|
|
let x = (aaaaaaaaaaaaaaaaaaaaaaaaaaaa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb + cccccccccccccccc)[x +
|
|
|
|
y +
|
|
|
|
z];
|
|
|
|
let y = (aaaaaaaaaaaaaaaaaaaaaaaaaaaa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb +
|
|
|
|
cccccccccccccccc)[xxxxx + yyyyy + zzzzz];
|
|
|
|
}
|
2015-10-02 10:00:28 +00:00
|
|
|
|
|
|
|
fn repeats() {
|
|
|
|
let x = [aaaaaaaaaaaaaaaaaaaaaaaaaaaa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb + cccccccccccccccc; x +
|
|
|
|
y +
|
|
|
|
z];
|
|
|
|
let y = [aaaaaaaaaaaaaaaaaaaaaaaaaaaa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb +
|
|
|
|
cccccccccccccccc; xxxxx + yyyyy + zzzzz];
|
|
|
|
}
|
2015-10-14 20:28:17 +00:00
|
|
|
|
|
|
|
fn blocks() {
|
|
|
|
if 1 + 1 == 2 {
|
|
|
|
println!("yay arithmetix!");
|
2015-11-09 00:23:19 +00:00
|
|
|
};
|
2015-10-14 20:28:17 +00:00
|
|
|
}
|