Only inline {}
string literals in format_args.
Placeholders like {:123} would incorrectly get inlined.
This commit is contained in:
parent
caa6ba9e86
commit
b7678d48b8
1 changed files with 1 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue