slog icon indicating copy to clipboard operation
slog copied to clipboard

`?` or `%` can't be used with `o!()`, looks like regression

Open netvl opened this issue 4 years ago • 5 comments

It seems that the logic in this PR: https://github.com/slog-rs/slog/pull/170 has been reverted somehow, because I now get exactly those errors which are described in that PR when I try to use ? or % with o!():


error[E0277]: `*mut (dyn std::ops::Fn() + 'static)` cannot be shared between threads safely
   --> src/server/mail/watcher.rs:755:20
    |
755 |         logger.new(o!("part_path" => ?p))
    |                    ^^^^^^^^^^^^^^^^^^^^^ `*mut (dyn std::ops::Fn() + 'static)` cannot be shared between threads safely
    |
    = help: within `[std::fmt::ArgumentV1<'_>]`, the trait `std::marker::Sync` is not implemented for `*mut (dyn std::ops::Fn() + 'static)`
    = note: required because it appears within the type `std::marker::PhantomData<*mut (dyn std::ops::Fn() + 'static)>`
    = note: required because it appears within the type `core::fmt::Void`
    = note: required because it appears within the type `&core::fmt::Void`
    = note: required because it appears within the type `std::fmt::ArgumentV1<'_>`
    = note: required because it appears within the type `[std::fmt::ArgumentV1<'_>]`
    = note: required because of the requirements on the impl of `std::marker::Send` for `&[std::fmt::ArgumentV1<'_>]`
    = note: required because it appears within the type `std::fmt::Arguments<'_>`
    = note: required because it appears within the type `slog::SingleKV<std::fmt::Arguments<'_>>`
    = note: required because it appears within the type `(slog::SingleKV<std::fmt::Arguments<'_>>, ())`
    = note: required because of the requirements on the impl of `slog::SendSyncRefUnwindSafeKV` for `(slog::SingleKV<std::fmt::Arguments<'_>>, ())`
    = note: required by `slog::OwnedKV`
    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

And indeed, the kv! macro now uses __slog_builtin(@format_args) instead of whatever is implemented in #170, which in turn implements the pre-#170 approach of using format_args.

netvl avatar Dec 27 '19 07:12 netvl

I thought there was a test and all. Can you check which version of slog are you using exactly?

I'd appreciate some help. Not sure when I'll be able to dig into this.

dpc avatar Dec 29 '19 01:12 dpc

2.5.2 all the way down to 2.4.0 has this problem. 2.3.3 failed with some other error, so I'm not sure about it.

nazar-pc avatar Jan 02 '20 05:01 nazar-pc

Still an issue on 2.7.0.

dcormier avatar Jul 09 '21 12:07 dcormier

It looks like the original fix got reverted in 4695580043fe26c828cb6ecdb7d85d86dfdf8c83 and fcf3efebd87f023825fd665c092a601c9dc75782. This also got documented in the changelog.

I would be glad to fix this issue again, but it would be helpful to know why the change was considered broken back then. Otherwise I feel like the risk of wasting my time is too great.

panicbit avatar Jan 12 '22 17:01 panicbit

:shrug: No idea, sorry. (but PR with some tests for it would be awesome.)

dpc avatar Jan 12 '22 17:01 dpc