Skip to content

Commit b7678d4

Browse files
committed
Only inline {} string literals in format_args.
Placeholders like {:123} would incorrectly get inlined.
1 parent caa6ba9 commit b7678d4

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

compiler/rustc_ast_lowering/src/format.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ fn inline_literals(mut fmt: Cow<'_, FormatArgs>) -> Cow<'_, FormatArgs> {
124124
let FormatArgsPiece::Placeholder(placeholder) = &fmt.template[i] else { continue };
125125
let Ok(arg_index) = placeholder.argument.index else { continue };
126126
if let FormatTrait::Display = placeholder.format_trait
127+
&& placeholder.format_options == Default::default()
127128
&& let arg = fmt.arguments.all_args()[arg_index].expr.peel_parens_and_refs()
128129
&& let ExprKind::Lit(lit) = arg.kind
129130
&& let token::LitKind::Str | token::LitKind::StrRaw(_) = lit.kind

0 commit comments

Comments
 (0)