slog-rs / slog

Structured, contextual, extensible, composable logging for Rust
https://slog.rs/
Apache License 2.0
1.58k stars 95 forks source link

Use a single trait def for every feature combination, fixing all the broken tests #301

Closed Techcable closed 2 years ago

Techcable commented 2 years ago

This fixes all the test failures for every possible feature combination, many of which wouldn't even compile before this change.

Fixing feature="nothreads" was especially hard, and required a relatively big refactoring (see below)

Use a single trait definition for every possible feature combination

Before this change, we had to use multiple trait definitions for every possible combination of std/no_std and threads/nothreads

This requires 4x as many trait definitions as default features.

As you can immaigne, we've been forgetting some of these :wink:

This fixes it by creating an internal utility module of maybe traits, which are automatically enabled/disabled depending on the features.

So Sync becomes maybe::Sync and UnwindSafe becomes maybe::UnwindSafe

This commit fixes the tests for feature="nothreads", and also no\_std + nothreads and probably a bunch of other bugs too.

Now we are able to support every possible feature combo without quadrupling trait defintiions ;)

Techcable commented 2 years ago

So all the tests are fixed but I forgot one line of formatting 😆

Techcable commented 2 years ago

Mmmm look at that beautiful green checkmark 😄