Auto merge of #139131 - m-ou-se:format-args-struct-expr, r=Mark-Simul… · rust-lang/rust@2ea33b5 (original) (raw)
`@@ -323,14 +323,12 @@ fn make_count<'hir>(
`
323
323
`/// Generates
`
324
324
`///
`
325
325
```` /// ```text
`326`
``
`-
/// <core::fmt::rt::Placeholder::new(
`
`327`
``
`-
/// …usize, // position
`
`328`
``
`-
/// '…', // fill
`
`329`
``
`-
/// <core::fmt::rt::Alignment>::…, // alignment
`
`330`
``
`-
/// …u32, // flags
`
`331`
``
`-
/// <core::fmt::rt::Count::…>, // width
`
`332`
``
`-
/// <core::fmt::rt::Count::…>, // precision
`
`333`
``
`-
/// )
`
``
`326`
`+
/// <core::fmt::rt::Placeholder {
`
``
`327`
`+
/// position: …usize,
`
``
`328`
`+
/// flags: …u32,
`
``
`329`
`+
/// precision: <core::fmt::rt::Count::…>,
`
``
`330`
`+
/// width: <core::fmt::rt::Count::…>,
`
``
`331`
`+
/// }
`
`334`
`332`
```` /// ```
335
333
`fn make_format_spec<'hir>(
`
336
334
`ctx: &mut LoweringContext<'_, 'hir>,
`
`@@ -384,13 +382,13 @@ fn make_format_spec<'hir>(
`
384
382
`let flags = ctx.expr_u32(sp, flags);
`
385
383
`let precision = make_count(ctx, sp, precision, argmap);
`
386
384
`let width = make_count(ctx, sp, width, argmap);
`
387
``
`-
let format_placeholder_new = ctx.arena.alloc(ctx.expr_lang_item_type_relative(
`
388
``
`-
sp,
`
389
``
`-
hir::LangItem::FormatPlaceholder,
`
390
``
`-
sym::new,
`
391
``
`-
));
`
392
``
`-
let args = ctx.arena.alloc_from_iter([position, flags, precision, width]);
`
393
``
`-
ctx.expr_call_mut(sp, format_placeholder_new, args)
`
``
385
`+
let position = ctx.expr_field(Ident::new(sym::position, sp), ctx.arena.alloc(position), sp);
`
``
386
`+
let flags = ctx.expr_field(Ident::new(sym::flags, sp), ctx.arena.alloc(flags), sp);
`
``
387
`+
let precision = ctx.expr_field(Ident::new(sym::precision, sp), ctx.arena.alloc(precision), sp);
`
``
388
`+
let width = ctx.expr_field(Ident::new(sym::width, sp), ctx.arena.alloc(width), sp);
`
``
389
`+
let placeholder = ctx.arena.alloc(hir::QPath::LangItem(hir::LangItem::FormatPlaceholder, sp));
`
``
390
`+
let fields = ctx.arena.alloc_from_iter([position, flags, precision, width]);
`
``
391
`+
ctx.expr(sp, hir::ExprKind::Struct(placeholder, fields, hir::StructTailExpr::None))
`
394
392
`}
`
395
393
``
396
394
`fn expand_format_args<'hir>(
`