[Solved] Sending slog logger between threads


I’m using slog in combination with tokio and futures-await.
I basically have an instance of slog::Logger without generic arguments so the default std::sync::Arc<dyn slog::SendSyncRefUnwindSafeDrain<Err=slog::private::NeverStruct, Ok=()>> is used.
I’m trying to send that (root) logger instance to a worker thread through tokio::spawn, but the compiler complains with the following message:
"dyn slog::SendSyncRefUnwindSafeDrain<Err=slog::private::NeverStruct, Ok=()> cannot be sent between threads safely"

The point i don’t actually understand is that the trait object has Send + Sync as super-traits, shouldn’t this indicate to the compiler that the trait object is Send + Sync?

The error traces are quite large because this occurs within an async context, so i tried to put ‘where’ bounds on my structures which contain the logger: where slog::Logger: Send + Sync. These bounds don’t cause issues so i’m out of ideas.
I suppose i’m misunderstanding something, but someone needs to explicitly tell me what. I hope someone has encountered this before and can tell me what’s missing.

I’ll be building a small example to post here in a bit.


I think the issue happens when the compiler automatically uses a borrow of the logger instance, instead of moving.
The order of compiler checks made it difficult to track this down;
It first checks required impls, then the borrow checker reports in. The other way around would have provided more helpful error messages in this case.