mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-29 10:13:54 +00:00
Only inline {}
string literals in format_args.
Placeholders like {:123} would incorrectly get inlined.
This commit is contained in:
parent
caa6ba9e86
commit
b7678d48b8
@ -124,6 +124,7 @@ fn inline_literals(mut fmt: Cow<'_, FormatArgs>) -> Cow<'_, FormatArgs> {
|
|||||||
let FormatArgsPiece::Placeholder(placeholder) = &fmt.template[i] else { continue };
|
let FormatArgsPiece::Placeholder(placeholder) = &fmt.template[i] else { continue };
|
||||||
let Ok(arg_index) = placeholder.argument.index else { continue };
|
let Ok(arg_index) = placeholder.argument.index else { continue };
|
||||||
if let FormatTrait::Display = placeholder.format_trait
|
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 arg = fmt.arguments.all_args()[arg_index].expr.peel_parens_and_refs()
|
||||||
&& let ExprKind::Lit(lit) = arg.kind
|
&& let ExprKind::Lit(lit) = arg.kind
|
||||||
&& let token::LitKind::Str | token::LitKind::StrRaw(_) = lit.kind
|
&& let token::LitKind::Str | token::LitKind::StrRaw(_) = lit.kind
|
||||||
|
Loading…
Reference in New Issue
Block a user