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