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
within the event! macro, some identifiers such as display, are un-hygienically leaked into the user's format arguments, which causes them to shadow local variables.
example:
use tracing::event;fnmain(){let display = "foo";let s = event!(tracing::Level::INFO,"length: {}",display.len());}
i expect this to log length: 3, but instead i get this error:
error[E0599]: no method named `len` found for fn item `fn(_) -> DisplayValue<_> {display::<_>}` in the current scope
--> src/main.rs:5:64
|
5 | let s = event!(tracing::Level::INFO,"length: {}",display.len());
| ------- ^^^ method not found in `fn(_) -> DisplayValue<_>{display::<_>}`
| |
| this is a function, perhaps you wish to call it
to be honest i thought that rust's hygene in macro_rules! would have prevented this class of error but apparently it is still a problem
The text was updated successfully, but these errors were encountered:
This is, unfortunately, a known issue (see #805 and, more recently, #2278), which we can't fix without a breaking change. We "fixed" it two years ago in #806, but unfortunately had to revert that change (2feb61d) when it turned out existing code was actually relying on those names being imported (#820).
Bug Report
Version
$ cargo tree | grep tracing
├── tracing v0.1.36
│ ├── tracing-attributes v0.1.22 (proc-macro)
│ └── tracing-core v0.1.29
└── tracing-subscriber v0.3.15
├── tracing-core v0.1.29 ()
└── tracing-log v0.1.3
└── tracing-core v0.1.29 ()
Description
within the
event!
macro, some identifiers such asdisplay
, are un-hygienically leaked into the user's format arguments, which causes them to shadow local variables.example:
i expect this to log
length: 3
, but instead i get this error:to be honest i thought that rust's hygene in macro_rules! would have prevented this class of error but apparently it is still a problem
The text was updated successfully, but these errors were encountered: