Closed
Description
Bug Report
Version
$ cargo tree | grep tracing
└── tracing v0.1.26
├── tracing-attributes v0.1.15 (proc-macro)
└── tracing-core v0.1.18
Description
Consider the following example, where a debug event is created from a Future that is awaited.
// src/main.rs
fn main() {
tokio::spawn(async {
tracing::debug!("{:?}", async { 5 }.await);
});
}
This works like it should, except with the log
feature.
# Cargo.toml
tracing = { version = "0.1.26", features = [ "log" ] }
Result:
error: future cannot be sent between threads safely
--> src/main.rs:2:5
|
2 | tokio::spawn(async {
| ^^^^^^^^^^^^ future created by async block is not `Send`
|
::: ~/.local/share/cargo/registry/src/g.yxqyang.asia-1ecc6299db9ec823/tokio-1.9.0/src/task/spawn.rs:127:21
|
127 | T: Future + Send + 'static,
| ---- required by this bound in `tokio::spawn`
|
= help: within `[ArgumentV1<'_>]`, the trait `Sync` is not implemented for `core::fmt::Opaque`
note: future is not `Send` as this value is used across an await
--> src/main.rs:3:33
|
3 | tracing::debug!("{:?}", async { 5 }.await);
| ------------------------^^^^^^^^^^^^^^^^^--
| | |
| | await occurs here, with `log::Record::builder()` maybe used later
| `log::Record::builder()` is later dropped here
| has type `RecordBuilder<'_>` which is not `Send`
help: consider moving this into a `let` binding to create a shorter lived borrow
--> src/main.rs:3:9
|
3 | tracing::debug!("{:?}", async { 5 }.await);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the macro `$crate::__tracing_log` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error
error: could not compile `project`