mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 02:57:37 +00:00
Fix weird indentaion in chain
This commit is contained in:
parent
d16a0a399e
commit
13af774e55
@ -126,9 +126,7 @@ pub fn rewrite_chain(expr: &ast::Expr, context: &RewriteContext, shape: Shape) -
|
||||
// brace.
|
||||
(parent_shape, false)
|
||||
} else if parent_rewrite_contains_newline {
|
||||
(chain_indent(context,
|
||||
parent_shape.block_indent(context.config.tab_spaces())),
|
||||
false)
|
||||
(chain_indent(context, parent_shape), false)
|
||||
} else {
|
||||
(shape.block_indent(context.config.tab_spaces()), false)
|
||||
};
|
||||
@ -142,17 +140,11 @@ pub fn rewrite_chain(expr: &ast::Expr, context: &RewriteContext, shape: Shape) -
|
||||
..nested_shape
|
||||
};
|
||||
let first_child_shape = if extend {
|
||||
let mut shape = try_opt!(parent_shape.offset_left(last_line_width(&parent_rewrite)));
|
||||
let first_child_shape = try_opt!(parent_shape
|
||||
.offset_left(last_line_width(&parent_rewrite)));
|
||||
match context.config.chain_indent() {
|
||||
IndentStyle::Visual => shape,
|
||||
IndentStyle::Block => {
|
||||
shape.offset = shape
|
||||
.offset
|
||||
.checked_sub(context.config.tab_spaces())
|
||||
.unwrap_or(0);
|
||||
shape.indent.block_indent += context.config.tab_spaces();
|
||||
shape
|
||||
}
|
||||
IndentStyle::Visual => first_child_shape,
|
||||
IndentStyle::Block => first_child_shape.block(),
|
||||
}
|
||||
} else {
|
||||
other_child_shape
|
||||
|
@ -183,7 +183,7 @@ pub fn rewrite_macro(mac: &ast::Mac,
|
||||
let mac_shape = try_opt!(shape.shrink_left(macro_name.len()));
|
||||
// Handle special case: `vec![expr; expr]`
|
||||
if vec_with_semi {
|
||||
let (lbr, rbr) = if context.config.spaces_within_square_brackets {
|
||||
let (lbr, rbr) = if context.config.spaces_within_square_brackets() {
|
||||
("[ ", " ]")
|
||||
} else {
|
||||
("[", "]")
|
||||
|
@ -15,3 +15,33 @@ impl Foo {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn issue1420() {
|
||||
given(
|
||||
r#"
|
||||
# Getting started
|
||||
...
|
||||
"#,
|
||||
)
|
||||
.running(waltz)
|
||||
}
|
||||
|
||||
// #1563
|
||||
fn query(conn: &Connection) -> Result<()> {
|
||||
conn.query_row(
|
||||
r#"
|
||||
SELECT title, date
|
||||
FROM posts,
|
||||
WHERE DATE(date) = $1
|
||||
"#,
|
||||
&[],
|
||||
|row| {
|
||||
Post {
|
||||
title: row.get(0),
|
||||
date: row.get(1),
|
||||
}
|
||||
},
|
||||
)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -28,3 +28,33 @@ impl Foo {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn issue1420() {
|
||||
given(
|
||||
r#"
|
||||
# Getting started
|
||||
...
|
||||
"#
|
||||
)
|
||||
.running(waltz)
|
||||
}
|
||||
|
||||
// #1563
|
||||
fn query(conn: &Connection) -> Result<()> {
|
||||
conn.query_row(
|
||||
r#"
|
||||
SELECT title, date
|
||||
FROM posts,
|
||||
WHERE DATE(date) = $1
|
||||
"#,
|
||||
&[],
|
||||
|row| {
|
||||
Post {
|
||||
title: row.get(0),
|
||||
date: row.get(1),
|
||||
}
|
||||
},
|
||||
)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user