Don't put a newline before ? when it is the second sub-expression in a chain (#1012)
Fixes #1003
This commit is contained in:
parent
775de8a62b
commit
d6bcfceb7e
3 changed files with 21 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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()?;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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()?;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue