@@ -218,7 +218,7 @@ fn flatten_format_args(mut fmt: Cow<'_, FormatArgs>) -> Cow<'_, FormatArgs> {
218218
219219#[ derive( Copy , Clone , Debug , Hash , PartialEq , Eq ) ]
220220enum ArgumentType {
221- Format ( FormatTrait ) ,
221+ Format { how : FormatTrait , simple : bool } ,
222222 Usize ,
223223}
224224
@@ -241,18 +241,32 @@ fn make_argument<'hir>(
241241 sp,
242242 hir:: LangItem :: FormatArgument ,
243243 match ty {
244- Format ( Display ) => sym:: new_display,
245- Format ( Debug ) => match ctx. tcx . sess . opts . unstable_opts . fmt_debug {
246- FmtDebug :: Full | FmtDebug :: Shallow => sym:: new_debug,
244+ Format { how : Display , simple : false } => sym:: new_display,
245+ Format { how : Display , simple : true } => sym:: new_display_simple,
246+ Format { how : Debug , simple } => match ctx. tcx . sess . opts . unstable_opts . fmt_debug {
247+ FmtDebug :: Full | FmtDebug :: Shallow => {
248+ if simple {
249+ sym:: new_debug_simple
250+ } else {
251+ sym:: new_debug
252+ }
253+ }
247254 FmtDebug :: None => sym:: new_debug_noop,
248255 } ,
249- Format ( LowerExp ) => sym:: new_lower_exp,
250- Format ( UpperExp ) => sym:: new_upper_exp,
251- Format ( Octal ) => sym:: new_octal,
252- Format ( Pointer ) => sym:: new_pointer,
253- Format ( Binary ) => sym:: new_binary,
254- Format ( LowerHex ) => sym:: new_lower_hex,
255- Format ( UpperHex ) => sym:: new_upper_hex,
256+ Format { how : LowerExp , simple : false } => sym:: new_lower_exp,
257+ Format { how : LowerExp , simple : true } => sym:: new_lower_exp_simple,
258+ Format { how : UpperExp , simple : false } => sym:: new_upper_exp,
259+ Format { how : UpperExp , simple : true } => sym:: new_upper_exp_simple,
260+ Format { how : Octal , simple : false } => sym:: new_octal,
261+ Format { how : Octal , simple : true } => sym:: new_octal_simple,
262+ Format { how : Pointer , simple : false } => sym:: new_pointer,
263+ Format { how : Pointer , simple : true } => sym:: new_pointer_simple,
264+ Format { how : Binary , simple : false } => sym:: new_binary,
265+ Format { how : Binary , simple : true } => sym:: new_binary_simple,
266+ Format { how : LowerHex , simple : false } => sym:: new_lower_hex,
267+ Format { how : LowerHex , simple : true } => sym:: new_lower_hex_simple,
268+ Format { how : UpperHex , simple : false } => sym:: new_upper_hex,
269+ Format { how : UpperHex , simple : true } => sym:: new_upper_hex_simple,
256270 Usize => sym:: from_usize,
257271 } ,
258272 ) ) ;
@@ -360,16 +374,6 @@ fn expand_format_args<'hir>(
360374 let i = bytecode. len ( ) ;
361375 bytecode. push ( 0xC0 ) ;
362376
363- let position = argmap
364- . insert_full (
365- (
366- p. argument . index . unwrap_or ( usize:: MAX ) ,
367- ArgumentType :: Format ( p. format_trait ) ,
368- ) ,
369- p. span ,
370- )
371- . 0 as u64 ;
372-
373377 // This needs to match the constants in library/core/src/fmt/mod.rs.
374378 let o = & p. format_options ;
375379 let align = match o. alignment {
@@ -389,6 +393,18 @@ fn expand_format_args<'hir>(
389393 | ( o. width . is_some ( ) as u32 ) << 27
390394 | ( o. precision . is_some ( ) as u32 ) << 28
391395 | align << 29 ;
396+
397+ let is_simple = flags == default_flags;
398+ let position = argmap
399+ . insert_full (
400+ (
401+ p. argument . index . unwrap_or ( usize:: MAX ) ,
402+ ArgumentType :: Format { how : p. format_trait , simple : is_simple } ,
403+ ) ,
404+ p. span ,
405+ )
406+ . 0 as u64 ;
407+
392408 if flags != default_flags {
393409 bytecode[ i] |= 1 ;
394410 bytecode. extend_from_slice ( & flags. to_le_bytes ( ) ) ;
0 commit comments