@@ -3,32 +3,32 @@ use std::cmp::min;
33
44use itertools:: Itertools ;
55use rustc_ast:: token:: { Delimiter , Lit , LitKind } ;
6- use rustc_ast:: { ast , ptr , token , ForLoopKind , MatchKind } ;
6+ use rustc_ast:: { ForLoopKind , MatchKind , ast , ptr , token } ;
77use rustc_span:: { BytePos , Span } ;
88
99use crate :: chains:: rewrite_chain;
1010use crate :: closures;
1111use 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 ,
1414} ;
1515use crate :: config:: lists:: * ;
1616use crate :: config:: { Config , ControlBraceStyle , HexLiteralCase , IndentStyle , StyleEdition } ;
1717use 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 ,
2020} ;
21- use crate :: macros:: { rewrite_macro , MacroPosition } ;
21+ use crate :: macros:: { MacroPosition , rewrite_macro } ;
2222use crate :: matches:: rewrite_match;
2323use 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 } ;
2525use crate :: rewrite:: { Rewrite , RewriteContext , RewriteError , RewriteErrorExt , RewriteResult } ;
2626use crate :: shape:: { Indent , Shape } ;
2727use crate :: source_map:: { LineRangeUtils , SpanUtils } ;
2828use crate :: spanned:: Spanned ;
2929use 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 } ;
3232use crate :: utils:: {
3333 colon_spaces, contains_skip, count_newlines, filtered_str_fits, first_line_ends_with,
3434 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>(
21242124 rhs_kind : & RhsAssignKind < ' _ > ,
21252125 rhs_tactics : RhsTactics ,
21262126) -> 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 ( ) ;
21292129 let tab_spaces = context. config . tab_spaces ( ) ;
21302130 let new_shape = shape
21312131 . block_indent ( tab_spaces)
21322132 . 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 ( ) ) {
21352135 new_shape
21362136 } else {
21372137 shape
21382138 }
21392139 } ;
21402140 let shape = if context. config . style_edition ( ) >= StyleEdition :: Edition2024 {
2141- get_lhs_last_line_shape ( )
2141+ get_rhs_shape ( )
21422142 } else {
21432143 shape
21442144 } ;
2145-
21462145 let last_line_width = last_line_width ( lhs) . saturating_sub ( if lhs. contains ( '\n' ) {
21472146 shape. indent . width ( )
21482147 } else {
0 commit comments