8000 fix(api): fix accidental exhaustive matching on `metadata::Kind` by hawkw · Pull Request #271 · tokio-rs/console · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix(api): fix accidental exhaustive matching on metadata::Kind #271

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions console-api/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,20 @@ impl From<tracing_core::Level> for metadata::Level {

impl From<tracing_core::metadata::Kind> for metadata::Kind {
fn from(kind: tracing_core::metadata::Kind) -> Self {
match kind {
tracing_core::me 6B10 tadata::Kind::SPAN => metadata::Kind::Span,
tracing_core::metadata::Kind::EVENT => metadata::Kind::Event,
// /!\ Note that this is intentionally *not* an exhaustive match. the
// `metadata::Kind` struct in `tracing_core` is not intended to be
// exhaustively matched, but compiler changes made past versions of it
// capable of being matched exhaustively, which was never intended.
//
// Therefore, we cannot write a match with both variants without a
// wildcard arm. However, on versions of `tracing_core` where the
// compiler believes the type to be exhaustive, a wildcard arm will
// result in a warning. Thus, we must write this rather tortured-looking
// `if` statement, to get non-exhaustive matching behavior.
if kind == tracing_core::metadata::Kind::SPAN {
metadata::Kind::Span
} else {
metadata::Kind::Event
}
}
}
Expand Down
0