@@ -137,33 +137,43 @@ fn make_format_spec<'hir>(
137
137
}
138
138
Err ( _) => ctx. expr ( sp, hir:: ExprKind :: Err ) ,
139
139
} ;
140
- let fill = ctx. expr_char ( sp, placeholder. format_options . fill . unwrap_or ( ' ' ) ) ;
140
+ let & FormatOptions {
141
+ ref width,
142
+ ref precision,
143
+ alignment,
144
+ fill,
145
+ sign,
146
+ alternate,
147
+ zero_pad,
148
+ debug_hex,
149
+ } = & placeholder. format_options ;
150
+ let fill = ctx. expr_char ( sp, fill. unwrap_or ( ' ' ) ) ;
141
151
let align = ctx. expr_lang_item_type_relative (
142
152
sp,
143
153
hir:: LangItem :: FormatAlignment ,
144
- match placeholder . format_options . alignment {
154
+ match alignment {
145
155
Some ( FormatAlignment :: Left ) => sym:: Left ,
146
156
Some ( FormatAlignment :: Right ) => sym:: Right ,
147
157
Some ( FormatAlignment :: Center ) => sym:: Center ,
148
158
None => sym:: Unknown ,
149
159
} ,
150
160
) ;
151
161
// This needs to match `FlagV1` in library/core/src/fmt/mod.rs.
152
- let flags: u32 = ( ( placeholder . format_options . sign == Some ( FormatSign :: Plus ) ) as u32 )
153
- | ( ( placeholder . format_options . sign == Some ( FormatSign :: Minus ) ) as u32 ) << 1
154
- | ( placeholder . format_options . alternate as u32 ) << 2
155
- | ( placeholder . format_options . zero_pad as u32 ) << 3
156
- | ( ( placeholder . format_options . debug_hex == Some ( FormatDebugHex :: Lower ) ) as u32 ) << 4
157
- | ( ( placeholder . format_options . debug_hex == Some ( FormatDebugHex :: Upper ) ) as u32 ) << 5 ;
162
+ let flags: u32 = ( ( sign == Some ( FormatSign :: Plus ) ) as u32 )
163
+ | ( ( sign == Some ( FormatSign :: Minus ) ) as u32 ) << 1
164
+ | ( alternate as u32 ) << 2
165
+ | ( zero_pad as u32 ) << 3
166
+ | ( ( debug_hex == Some ( FormatDebugHex :: Lower ) ) as u32 ) << 4
167
+ | ( ( debug_hex == Some ( FormatDebugHex :: Upper ) ) as u32 ) << 5 ;
158
168
let flags = ctx. expr_u32 ( sp, flags) ;
159
- let prec = make_count ( ctx, sp, & placeholder . format_options . precision , argmap) ;
160
- let width = make_count ( ctx, sp, & placeholder . format_options . width , argmap) ;
169
+ let precision = make_count ( ctx, sp, & precision, argmap) ;
170
+ let width = make_count ( ctx, sp, & width, argmap) ;
161
171
let format_placeholder_new = ctx. arena . alloc ( ctx. expr_lang_item_type_relative (
162
172
sp,
163
173
hir:: LangItem :: FormatPlaceholder ,
164
174
sym:: new,
165
175
) ) ;
166
- let args = ctx. arena . alloc_from_iter ( [ position, fill, align, flags, prec , width] ) ;
176
+ let args = ctx. arena . alloc_from_iter ( [ position, fill, align, flags, precision , width] ) ;
167
177
ctx. expr_call_mut ( sp, format_placeholder_new, args)
168
178
}
169
179
0 commit comments