@@ -3,32 +3,32 @@ use std::cmp::min;
3
3
4
4
use itertools:: Itertools ;
5
5
use rustc_ast:: token:: { Delimiter , Lit , LitKind } ;
6
- use rustc_ast:: { ast , ptr , token , ForLoopKind , MatchKind } ;
6
+ use rustc_ast:: { ForLoopKind , MatchKind , ast , ptr , token } ;
7
7
use rustc_span:: { BytePos , Span } ;
8
8
9
9
use crate :: chains:: rewrite_chain;
10
10
use crate :: closures;
11
11
use crate :: comment:: {
12
- combine_strs_with_missing_comments , contains_comment , recover_comment_removed , rewrite_comment ,
13
- rewrite_missing_comment , CharClasses , FindUncommented ,
12
+ CharClasses , FindUncommented , combine_strs_with_missing_comments , contains_comment ,
13
+ recover_comment_removed , rewrite_comment , rewrite_missing_comment ,
14
14
} ;
15
15
use crate :: config:: lists:: * ;
16
16
use crate :: config:: { Config , ControlBraceStyle , HexLiteralCase , IndentStyle , StyleEdition } ;
17
17
use crate :: lists:: {
18
- definitive_tactic , itemize_list , shape_for_tactic , struct_lit_formatting , struct_lit_shape ,
19
- struct_lit_tactic , write_list , ListFormatting , Separator ,
18
+ ListFormatting , Separator , definitive_tactic , itemize_list , shape_for_tactic ,
19
+ struct_lit_formatting , struct_lit_shape , struct_lit_tactic , write_list ,
20
20
} ;
21
- use crate :: macros:: { rewrite_macro , MacroPosition } ;
21
+ use crate :: macros:: { MacroPosition , rewrite_macro } ;
22
22
use crate :: matches:: rewrite_match;
23
23
use crate :: overflow:: { self , IntoOverflowableItem , OverflowableItem } ;
24
- use crate :: pairs:: { rewrite_all_pairs , rewrite_pair , PairParts } ;
24
+ use crate :: pairs:: { PairParts , rewrite_all_pairs , rewrite_pair } ;
25
25
use crate :: rewrite:: { Rewrite , RewriteContext , RewriteError , RewriteErrorExt , RewriteResult } ;
26
26
use crate :: shape:: { Indent , Shape } ;
27
27
use crate :: source_map:: { LineRangeUtils , SpanUtils } ;
28
28
use crate :: spanned:: Spanned ;
29
29
use crate :: stmt;
30
- use crate :: string:: { rewrite_string , StringFormat } ;
31
- use crate :: types:: { rewrite_path , PathContext } ;
30
+ use crate :: string:: { StringFormat , rewrite_string } ;
31
+ use crate :: types:: { PathContext , rewrite_path } ;
32
32
use crate :: utils:: {
33
33
colon_spaces, contains_skip, count_newlines, filtered_str_fits, first_line_ends_with,
34
34
inner_attributes, last_line_extendable, last_line_width, mk_sp, outer_attributes,
@@ -2124,25 +2124,24 @@ pub(crate) fn rewrite_assign_rhs_expr<R: Rewrite>(
2124
2124
rhs_kind : & RhsAssignKind < ' _ > ,
2125
2125
rhs_tactics : RhsTactics ,
2126
2126
) -> RewriteResult {
2127
- let get_lhs_last_line_shape = || {
2128
- let last_line = lhs. rsplitn ( 2 , " \n " ) . next ( ) . unwrap_or_default ( ) ;
2127
+ let get_rhs_shape = || {
2128
+ let last_line = lhs. lines ( ) . last ( ) . unwrap_or_default ( ) ;
2129
2129
let tab_spaces = context. config . tab_spaces ( ) ;
2130
2130
let new_shape = shape
2131
2131
. block_indent ( tab_spaces)
2132
2132
. saturating_sub_width ( tab_spaces) ;
2133
- let extra_indent_string = new_shape. to_string ( & context. config ) . to_string ( ) ;
2134
- if last_line. starts_with ( & extra_indent_string) {
2133
+ let extra_indent_string = new_shape. to_string ( & context. config ) ;
2134
+ if last_line. starts_with ( extra_indent_string. as_ref ( ) ) {
2135
2135
new_shape
2136
2136
} else {
2137
2137
shape
2138
2138
}
2139
2139
} ;
2140
2140
let shape = if context. config . style_edition ( ) >= StyleEdition :: Edition2024 {
2141
- get_lhs_last_line_shape ( )
2141
+ get_rhs_shape ( )
2142
2142
} else {
2143
2143
shape
2144
2144
} ;
2145
-
2146
2145
let last_line_width = last_line_width ( lhs) . saturating_sub ( if lhs. contains ( '\n' ) {
2147
2146
shape. indent . width ( )
2148
2147
} else {
0 commit comments