2017-01-16 14:50:27 +13:00
|
|
|
// rustfmt-normalize_comments: true
|
2016-05-29 17:58:38 +02:00
|
|
|
// rustfmt-single_line_if_else_max_width: 0
|
2017-03-28 11:12:15 +13:00
|
|
|
// rustfmt-chain_one_line_max: 100
|
2015-09-09 23:13:37 +02:00
|
|
|
// Test chain formatting.
|
|
|
|
|
|
|
|
fn main() {
|
2017-03-28 11:25:59 +13:00
|
|
|
let a = b.c.d.1.foo(|x| x + 1);
|
2015-09-09 23:13:37 +02:00
|
|
|
|
2017-03-07 11:28:25 +13:00
|
|
|
bbbbbbbbbbbbbbbbbbb.ccccccccccccccccccccccccccccccccccccc.ddddddddddddddddddddddddddd();
|
2015-09-09 23:13:37 +02:00
|
|
|
|
2017-03-28 11:01:44 +13:00
|
|
|
bbbbbbbbbbbbbbbbbbb
|
|
|
|
.ccccccccccccccccccccccccccccccccccccc
|
2016-04-22 19:03:36 +12:00
|
|
|
.ddddddddddddddddddddddddddd
|
|
|
|
.eeeeeeee();
|
2015-09-09 23:13:37 +02:00
|
|
|
|
2015-09-11 00:53:21 +02:00
|
|
|
// Test case where first chain element isn't a path, but is shorter than
|
|
|
|
// the size of a tab.
|
2016-04-14 08:36:59 +12:00
|
|
|
x().y(|| match cond() {
|
2017-02-23 08:52:52 +13:00
|
|
|
true => (),
|
|
|
|
false => (),
|
|
|
|
});
|
2015-09-09 23:17:31 +02:00
|
|
|
|
2016-04-14 08:36:59 +12:00
|
|
|
loong_func().quux(move || if true {
|
2017-02-23 08:52:52 +13:00
|
|
|
1
|
|
|
|
} else {
|
|
|
|
2
|
|
|
|
});
|
2015-09-09 23:13:37 +02:00
|
|
|
|
2015-10-08 23:07:19 +02:00
|
|
|
some_fuuuuuuuuunction().method_call_a(aaaaa, bbbbb, |c| {
|
|
|
|
let x = c;
|
|
|
|
x
|
|
|
|
});
|
|
|
|
|
|
|
|
some_fuuuuuuuuunction()
|
|
|
|
.method_call_a(aaaaa, bbbbb, |c| {
|
|
|
|
let x = c;
|
|
|
|
x
|
|
|
|
})
|
|
|
|
.method_call_b(aaaaa, bbbbb, |c| {
|
|
|
|
let x = c;
|
|
|
|
x
|
|
|
|
});
|
|
|
|
|
|
|
|
fffffffffffffffffffffffffffffffffff(a, {
|
2016-11-21 08:37:35 +13:00
|
|
|
SCRIPT_TASK_ROOT.with(|root| { *root.borrow_mut() = Some(&script_task); });
|
2015-10-08 23:07:19 +02:00
|
|
|
});
|
2015-09-09 23:14:09 +02:00
|
|
|
|
2017-03-07 11:28:25 +13:00
|
|
|
let suuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuum =
|
|
|
|
xxxxxxx.map(|x| x + 5).map(|x| x / 2).fold(0, |acc, x| acc + x);
|
2015-09-09 23:14:54 +02:00
|
|
|
|
2017-03-28 11:01:44 +13:00
|
|
|
aaaaaaaaaaaaaaaa
|
|
|
|
.map(|x| {
|
|
|
|
x += 1;
|
|
|
|
x
|
|
|
|
})
|
2016-04-22 19:03:36 +12:00
|
|
|
.filter(some_mod::some_filter)
|
2015-09-09 23:13:37 +02:00
|
|
|
}
|
2015-10-18 17:56:13 +02:00
|
|
|
|
|
|
|
fn floaters() {
|
|
|
|
let z = Foo {
|
|
|
|
field1: val1,
|
|
|
|
field2: val2,
|
|
|
|
};
|
|
|
|
|
|
|
|
let x = Foo {
|
2016-04-22 19:03:36 +12:00
|
|
|
field1: val1,
|
|
|
|
field2: val2,
|
|
|
|
}
|
|
|
|
.method_call()
|
|
|
|
.method_call();
|
2015-10-18 17:56:13 +02:00
|
|
|
|
|
|
|
let y = if cond {
|
2016-04-22 19:03:36 +12:00
|
|
|
val1
|
|
|
|
} else {
|
|
|
|
val2
|
|
|
|
}
|
|
|
|
.method_call();
|
2015-10-18 17:56:13 +02:00
|
|
|
|
|
|
|
{
|
|
|
|
match x {
|
|
|
|
PushParam => {
|
|
|
|
// params are 1-indexed
|
|
|
|
stack.push(mparams[match cur.to_digit(10) {
|
2017-02-23 08:52:52 +13:00
|
|
|
Some(d) => d as usize - 1,
|
|
|
|
None => return Err("bad param number".to_owned()),
|
|
|
|
}]
|
|
|
|
.clone());
|
2015-10-18 17:56:13 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if cond {
|
2016-04-22 19:03:36 +12:00
|
|
|
some();
|
|
|
|
} else {
|
|
|
|
none();
|
|
|
|
}
|
|
|
|
.bar()
|
|
|
|
.baz();
|
2015-10-18 17:56:13 +02:00
|
|
|
|
|
|
|
Foo { x: val }
|
|
|
|
.baz(|| {
|
2017-02-23 08:52:52 +13:00
|
|
|
force();
|
|
|
|
multiline();
|
|
|
|
})
|
2015-10-18 17:56:13 +02:00
|
|
|
.quux();
|
|
|
|
|
|
|
|
Foo {
|
2016-04-22 19:03:36 +12:00
|
|
|
y: i_am_multi_line,
|
|
|
|
z: ok,
|
|
|
|
}
|
|
|
|
.baz(|| {
|
2017-02-23 08:52:52 +13:00
|
|
|
force();
|
|
|
|
multiline();
|
|
|
|
})
|
2016-04-22 19:03:36 +12:00
|
|
|
.quux();
|
2015-10-18 17:56:13 +02:00
|
|
|
|
|
|
|
a +
|
|
|
|
match x {
|
2016-04-22 19:03:36 +12:00
|
|
|
true => "yay!",
|
|
|
|
false => "boo!",
|
|
|
|
}
|
|
|
|
.bar()
|
2015-10-18 17:56:13 +02:00
|
|
|
}
|
2015-10-23 20:36:38 +02:00
|
|
|
|
|
|
|
fn is_replaced_content() -> bool {
|
2017-03-07 11:28:25 +13:00
|
|
|
constellat.send(ConstellationMsg::ViewportConstrained(self.id, constraints)).unwrap();
|
2015-10-23 20:36:38 +02:00
|
|
|
}
|
2015-11-13 14:53:34 +01:00
|
|
|
|
|
|
|
fn issue587() {
|
|
|
|
a.b::<()>(c);
|
|
|
|
|
|
|
|
std::mem::transmute(dl.symbol::<()>("init").unwrap())
|
|
|
|
}
|
2016-05-09 20:07:59 +02:00
|
|
|
|
|
|
|
fn try_shorthand() {
|
|
|
|
let x = expr?;
|
|
|
|
let y = expr.kaas()?.test();
|
2017-03-28 11:25:59 +13:00
|
|
|
let loooooooooooooooooooooooooooooooooooooooooong =
|
|
|
|
does_this?.look?.good?.should_we_break?.after_the_first_question_mark?;
|
2017-04-24 16:50:11 +09:00
|
|
|
let yyyy = expr?.another?.another?.another?.another?.another?.another?.another?.another?.test();
|
2017-03-28 11:25:59 +13:00
|
|
|
let zzzz = expr?.another?.another?.another?.another?;
|
2016-05-09 20:07:59 +02:00
|
|
|
let aaa = x??????????????????????????????????????????????????????????????????????????;
|
2016-05-09 20:11:25 +02:00
|
|
|
|
|
|
|
let y = a.very
|
2016-05-12 21:50:43 +02:00
|
|
|
.loooooooooooooooooooooooooooooooooooooong()
|
|
|
|
.chain()
|
|
|
|
.inside()
|
|
|
|
.weeeeeeeeeeeeeee()?
|
|
|
|
.test()
|
|
|
|
.0
|
|
|
|
.x;
|
2016-05-27 20:33:19 +12:00
|
|
|
|
|
|
|
parameterized(f,
|
|
|
|
substs,
|
|
|
|
def_id,
|
|
|
|
Ns::Value,
|
|
|
|
&[],
|
|
|
|
|tcx| tcx.lookup_item_type(def_id).generics)?;
|
|
|
|
fooooooooooooooooooooooooooo()?
|
|
|
|
.bar()?
|
|
|
|
.baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaz()?;
|
2016-05-09 20:07:59 +02:00
|
|
|
}
|
2016-05-28 21:50:25 +01:00
|
|
|
|
|
|
|
fn issue_1004() {
|
|
|
|
match *self {
|
|
|
|
ty::ImplOrTraitItem::MethodTraitItem(ref i) => write!(f, "{:?}", i),
|
|
|
|
ty::ImplOrTraitItem::ConstTraitItem(ref i) => write!(f, "{:?}", i),
|
|
|
|
ty::ImplOrTraitItem::TypeTraitItem(ref i) => write!(f, "{:?}", i),
|
|
|
|
}?;
|
|
|
|
|
|
|
|
ty::tls::with(|tcx| {
|
2017-02-23 08:52:52 +13:00
|
|
|
let tap = ty::Binder(TraitAndProjections(principal, projections));
|
|
|
|
in_binder(f, tcx, &ty::Binder(""), Some(tap))
|
|
|
|
})?;
|
2016-05-28 21:50:25 +01:00
|
|
|
}
|