-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Assignment inside format_args! is ignored #45256
Copy link
Copy link
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Assignments inside
format_args!are ignored. Instead only the right-hand side of the expression is used.I tried this code:
or a similar one, using directly
format_args:I expected to see this:
Instead the output was:
It looks like the the assignment
x = 3is ignored and is instead treated as if it was just3.I could only replicate this with
format_args!and macros that use it. Other macros, likeassert_eq!, work as expected.Meta
rustc --version --verbose:(also tried on
rustc 1.20.0-stableandrustc 1.21.0-stable)