Don't put a newline before ? when it is the second sub-expression in a chain (#1012)

Fixes #1003
This commit is contained in:
Nick Cameron 2016-05-27 20:33:19 +12:00 committed by Marcus Klaas de Vries
parent 775de8a62b
commit d6bcfceb7e
3 changed files with 21 additions and 1 deletions

View file

@ -179,7 +179,9 @@ pub fn rewrite_chain(expr: &ast::Expr,
format!("\n{}", indent.to_string(context.config))
};
let first_connector = if extend {
let first_connector = if extend || subexpr_list.len() == 0 {
""
} else if let ast::ExprKind::Try(_) = subexpr_list[0].node {
""
} else {
&*connector

View file

@ -124,4 +124,12 @@ fn try_shorthand() {
let y = a.very .loooooooooooooooooooooooooooooooooooooong() .chain()
.inside() .weeeeeeeeeeeeeee()? .test() .0
.x;
parameterized(f,
substs,
def_id,
Ns::Value,
&[],
|tcx| tcx.lookup_item_type(def_id).generics)?;
fooooooooooooooooooooooooooo()?.bar()?.baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaz()?;
}

View file

@ -151,4 +151,14 @@ fn try_shorthand() {
.test()
.0
.x;
parameterized(f,
substs,
def_id,
Ns::Value,
&[],
|tcx| tcx.lookup_item_type(def_id).generics)?;
fooooooooooooooooooooooooooo()?
.bar()?
.baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaz()?;
}