Take the width of block's prefix into account only once
This commit is contained in:
parent
c0701f5fa5
commit
366ff40ae7
@ -608,7 +608,7 @@ fn rewrite_single_line_block(
|
||||
shape: Shape,
|
||||
) -> Option<String> {
|
||||
if is_simple_block(block, context.codemap) {
|
||||
let expr_shape = Shape::legacy(shape.width - prefix.len(), shape.indent);
|
||||
let expr_shape = shape.offset_left(last_line_width(prefix))?;
|
||||
let expr_str = block.stmts[0].rewrite(context, expr_shape)?;
|
||||
let result = format!("{}{{ {} }}", prefix, expr_str);
|
||||
if result.len() <= shape.width && !result.contains('\n') {
|
||||
@ -654,7 +654,6 @@ impl Rewrite for ast::Block {
|
||||
}
|
||||
|
||||
let prefix = block_prefix(context, self, shape)?;
|
||||
let shape = shape.offset_left(last_line_width(&prefix))?;
|
||||
|
||||
let result = rewrite_block_with_visitor(context, &prefix, self, shape, true);
|
||||
if let Some(ref result_str) = result {
|
||||
|
@ -108,6 +108,12 @@ fn baz() {
|
||||
unsafe {
|
||||
foo();
|
||||
}
|
||||
|
||||
// #2289
|
||||
let identifier_0 = unsafe { this_is_58_chars_long_and_line_is_93_chars_long_xxxxxxxxxx };
|
||||
let identifier_1 = unsafe { this_is_59_chars_long_and_line_is_94_chars_long_xxxxxxxxxxx };
|
||||
let identifier_2 = unsafe { this_is_65_chars_long_and_line_is_100_chars_long_xxxxxxxxxxxxxxxx };
|
||||
let identifier_3 = unsafe { this_is_66_chars_long_and_line_is_101_chars_long_xxxxxxxxxxxxxxxxx };
|
||||
}
|
||||
|
||||
// Test some empty blocks.
|
||||
|
@ -123,9 +123,7 @@ fn foo() {
|
||||
|
||||
fn issue1405() {
|
||||
open_raw_fd(fd, b'r').and_then(|file| {
|
||||
Capture::new_raw(None, |_, err| unsafe {
|
||||
raw::pcap_fopen_offline(file, err)
|
||||
})
|
||||
Capture::new_raw(None, |_, err| unsafe { raw::pcap_fopen_offline(file, err) })
|
||||
});
|
||||
}
|
||||
|
||||
@ -176,9 +174,8 @@ fn issue1329() {
|
||||
}
|
||||
|
||||
fn issue325() {
|
||||
let f = || unsafe {
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
};
|
||||
let f =
|
||||
|| unsafe { xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx };
|
||||
}
|
||||
|
||||
fn issue1697() {
|
||||
|
@ -147,6 +147,13 @@ fn baz() {
|
||||
unsafe {
|
||||
foo();
|
||||
}
|
||||
|
||||
// #2289
|
||||
let identifier_0 = unsafe { this_is_58_chars_long_and_line_is_93_chars_long_xxxxxxxxxx };
|
||||
let identifier_1 = unsafe { this_is_59_chars_long_and_line_is_94_chars_long_xxxxxxxxxxx };
|
||||
let identifier_2 = unsafe { this_is_65_chars_long_and_line_is_100_chars_long_xxxxxxxxxxxxxxxx };
|
||||
let identifier_3 =
|
||||
unsafe { this_is_66_chars_long_and_line_is_101_chars_long_xxxxxxxxxxxxxxxxx };
|
||||
}
|
||||
|
||||
// Test some empty blocks.
|
||||
|
Loading…
x
Reference in New Issue
Block a user