File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed
compiler/rustc_ast_lowering/src Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -393,13 +393,19 @@ fn expand_format_args<'hir>(
393393 bytecode. extend_from_slice ( & flags. to_le_bytes ( ) ) ;
394394 if let Some ( val) = & o. width {
395395 let ( indirect, val) = make_count ( val, & mut argmap) ;
396- bytecode[ i] |= 1 << 1 | ( indirect as u8 ) << 4 ;
397- bytecode. extend_from_slice ( & val. to_le_bytes ( ) ) ;
396+ // Only encode if nonzero; zero is the default.
397+ if indirect || val != 0 {
398+ bytecode[ i] |= 1 << 1 | ( indirect as u8 ) << 4 ;
399+ bytecode. extend_from_slice ( & val. to_le_bytes ( ) ) ;
400+ }
398401 }
399402 if let Some ( val) = & o. precision {
400403 let ( indirect, val) = make_count ( val, & mut argmap) ;
401- bytecode[ i] |= 1 << 2 | ( indirect as u8 ) << 5 ;
402- bytecode. extend_from_slice ( & val. to_le_bytes ( ) ) ;
404+ // Only encode if nonzero; zero is the default.
405+ if indirect || val != 0 {
406+ bytecode[ i] |= 1 << 2 | ( indirect as u8 ) << 5 ;
407+ bytecode. extend_from_slice ( & val. to_le_bytes ( ) ) ;
408+ }
403409 }
404410 }
405411 if implicit_arg_index != position {
You can’t perform that action at this time.
0 commit comments