File tree 3 files changed +39
-7
lines changed
3 files changed +39
-7
lines changed Original file line number Diff line number Diff line change @@ -369,13 +369,15 @@ where
369
369
. and_then ( |s| s. sub_width ( pp. suffix . len ( ) ) )
370
370
. and_then ( |rhs_shape| rhs. rewrite ( context, rhs_shape) ) ;
371
371
if let Some ( ref rhs_result) = rhs_orig_result {
372
- // If the rhs looks like block expression, we allow it to stay on the same line
373
- // with the lhs even if it is multi-lined.
374
- let allow_same_line = rhs_result
375
- . lines ( )
376
- . next ( )
377
- . map ( |first_line| first_line. ends_with ( '{' ) )
378
- . unwrap_or ( false ) ;
372
+ // If the length of the lhs is equal to or shorter than the tab width or
373
+ // the rhs looks like block expression, we put the rhs on the same
374
+ // line with the lhs even if the rhs is multi-lined.
375
+ let allow_same_line = lhs_result. len ( ) <= context. config . tab_spaces ( )
376
+ || rhs_result
377
+ . lines ( )
378
+ . next ( )
379
+ . map ( |first_line| first_line. ends_with ( '{' ) )
380
+ . unwrap_or ( false ) ;
379
381
if !rhs_result. contains ( '\n' ) || allow_same_line {
380
382
let one_line_width = last_line_width ( & lhs_result) + pp. infix . len ( )
381
383
+ first_line_width ( rhs_result) + pp. suffix . len ( ) ;
Original file line number Diff line number Diff line change @@ -370,3 +370,17 @@ fn newlines_between_list_like_expr() {
370
370
fn issue2178 ( ) {
371
371
Ok ( result. iter ( ) . map ( |item| ls_util:: rls_to_location ( item) ) . collect ( ) )
372
372
}
373
+
374
+ // #2493
375
+ impl Foo {
376
+ fn bar ( & self ) {
377
+ {
378
+ let x = match ( ) {
379
+ ( ) => {
380
+ let i;
381
+ i == self . install_config . storage . experimental_compressed_block_size as usize
382
+ }
383
+ } ;
384
+ }
385
+ }
386
+ }
Original file line number Diff line number Diff line change @@ -393,3 +393,19 @@ fn issue2178() {
393
393
. map ( |item| ls_util:: rls_to_location ( item) )
394
394
. collect ( ) )
395
395
}
396
+
397
+ // #2493
398
+ impl Foo {
399
+ fn bar ( & self ) {
400
+ {
401
+ let x = match ( ) {
402
+ ( ) => {
403
+ let i;
404
+ i == self . install_config
405
+ . storage
406
+ . experimental_compressed_block_size as usize
407
+ }
408
+ } ;
409
+ }
410
+ }
411
+ }
You can’t perform that action at this time.
0 commit comments