Skip to content

Commit

Permalink
subscriber: mark builders as must_use (#2239)
Browse files Browse the repository at this point in the history
## Motivation

Builders not marked `#[must_use]` can not be initialized sometimes, causing silent failures.
Eg.
```rust
fn main() {
    tracing_subscriber::fmt();
    tracing::info!("hello");
}
```
won't print anything.

## Solution

Added `#[must_use]` to builder types in the tracing-subscriber crate.
  • Loading branch information
DesmondWillowbrook committed Jul 21, 2022
1 parent 46c1fe9 commit c341c7f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions tracing-subscriber/src/filter/env/builder.rs
Expand Up @@ -11,6 +11,7 @@ use tracing::level_filters::STATIC_MAX_LEVEL;
///
/// [builder]: https://rust-unofficial.github.io/patterns/patterns/creational/builder.html
#[derive(Debug, Clone)]
#[must_use]
pub struct Builder {
regex: bool,
env: Option<String>,
Expand Down
1 change: 1 addition & 0 deletions tracing-subscriber/src/fmt/mod.rs
Expand Up @@ -240,6 +240,7 @@ pub type Formatter<N = format::DefaultFields, E = format::Format, W = fn() -> io
/// Configures and constructs `Collector`s.
#[derive(Debug)]
#[cfg_attr(docsrs, doc(cfg(all(feature = "fmt", feature = "std"))))]
#[must_use]
pub struct CollectorBuilder<
N = format::DefaultFields,
E = format::Format,
Expand Down

0 comments on commit c341c7f

Please sign in to comment.