You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Which is potentially surprising, since it's not immediately obvious that the _x in the println macro is acting like a named argument.
It would be useful to emit either a warning or an error so that named arguments that are used only based on position are identified to avoid causing confusion, since to a reader it looks like an assignment.
The text was updated successfully, but these errors were encountered:
Emit warning when named arguments are used positionally in format
Addresses Issue 98466 by emitting an error if a named argument
is used like a position argument (i.e. the name is not used in
the string to be formatted).
Fixesrust-lang#98466
Some old code was formatting a named variable but not reference the
name in the formatting string. This change adds the identifier to the
formatting string, but does not affect the behavior of the formatting. The new compiler warning was introduced in rust-lang/rust#98466
Bug: 104577
Change-Id: I7a19d1aa23a12fd116dfb5488f0c233cf24e3cb7
Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/701186
Commit-Queue: Paul Faria <paulfaria@google.com>
Reviewed-by: Mitchell Kember <mkember@google.com>
Michale Gattozzi identified this on twitter with a compelling sample:
This prints
Which is potentially surprising, since it's not immediately obvious that the
_x
in theprintln
macro is acting like a named argument.It would be useful to emit either a warning or an error so that named arguments that are used only based on position are identified to avoid causing confusion, since to a reader it looks like an assignment.
The text was updated successfully, but these errors were encountered: