@@ -89,9 +89,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
8989 let mut was_inlined = vec ! [ false ; fmt. arguments. all_args( ) . len( ) ] ;
9090 let mut inlined_anything = false ;
9191
92- let mut i = 0 ;
93-
94- while i < fmt. template . len ( ) {
92+ for i in 0 ..fmt. template . len ( ) {
9593 if let FormatArgsPiece :: Placeholder ( placeholder) = & fmt. template [ i]
9694 && let Ok ( arg_index) = placeholder. argument . index
9795 && let FormatTrait :: Display = placeholder. format_trait
@@ -104,16 +102,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
104102 // If this is the first time, this clones the outer FormatArgs.
105103 let fmt = fmt. to_mut ( ) ;
106104 // Replace the placeholder with the literal.
107- if literal. is_empty ( ) {
108- fmt. template . remove ( i) ;
109- } else {
110- fmt. template [ i] = FormatArgsPiece :: Literal ( literal) ;
111- i += 1 ;
112- }
105+ fmt. template [ i] = FormatArgsPiece :: Literal ( literal) ;
113106 was_inlined[ arg_index] = true ;
114107 inlined_anything = true ;
115- } else {
116- i += 1 ;
117108 }
118109 }
119110
@@ -349,10 +340,6 @@ fn expand_format_args<'hir>(
349340 return hir:: ExprKind :: Call ( from_str, args) ;
350341 }
351342
352- // It shouldn't be possible to have an empty literal here. Encoding an empty literal
353- // would result in a single 0 byte, which marks the end of the template byte sequence.
354- debug_assert ! ( !s. is_empty( ) ) ;
355-
356343 // Encode the literal in chunks of up to u16::MAX bytes, split at utf-8 boundaries.
357344 while !s. is_empty ( ) {
358345 let len = s. floor_char_boundary ( usize:: from ( u16:: MAX ) ) ;
0 commit comments