diff options
| author | Mara Bos <m-ou.se@m-ou.se> | 2023-01-13 18:59:21 +0100 |
|---|---|---|
| committer | Mara Bos <m-ou.se@m-ou.se> | 2023-03-16 11:19:31 +0100 |
| commit | b7678d48b8c168bbbc0c34911bb38c8cd484e0ee (patch) | |
| tree | 8e2a0e115bf4a742e378cc032d87c878089b350f | |
| parent | caa6ba9e86281eb1fbdd87d5100cc7e92ba07f5c (diff) | |
| download | rust-b7678d48b8c168bbbc0c34911bb38c8cd484e0ee.tar.gz rust-b7678d48b8c168bbbc0c34911bb38c8cd484e0ee.zip | |
Only inline `{}` string literals in format_args.
Placeholders like {:123} would incorrectly get inlined.
| -rw-r--r-- | compiler/rustc_ast_lowering/src/format.rs | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/compiler/rustc_ast_lowering/src/format.rs b/compiler/rustc_ast_lowering/src/format.rs index c21fb3a4cfb..96ca81d823b 100644 --- a/compiler/rustc_ast_lowering/src/format.rs +++ b/compiler/rustc_ast_lowering/src/format.rs @@ -124,6 +124,7 @@ fn inline_literals(mut fmt: Cow<'_, FormatArgs>) -> Cow<'_, FormatArgs> { let FormatArgsPiece::Placeholder(placeholder) = &fmt.template[i] else { continue }; let Ok(arg_index) = placeholder.argument.index else { continue }; if let FormatTrait::Display = placeholder.format_trait + && placeholder.format_options == Default::default() && let arg = fmt.arguments.all_args()[arg_index].expr.peel_parens_and_refs() && let ExprKind::Lit(lit) = arg.kind && let token::LitKind::Str | token::LitKind::StrRaw(_) = lit.kind |
