Skip to content

Commit

Permalink
tonic: remove Code::__NonExhaustive (#625)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidpdrsn authored May 12, 2021
1 parent e97f518 commit 2bf14e1
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions tonic/src/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,6 @@ pub enum Code {

/// The request does not have valid authentication credentials
Unauthenticated = 16,

// New Codes may be added in the future, so never exhaustively match!
#[doc(hidden)]
__NonExhaustive,
}

impl Code {
Expand Down Expand Up @@ -146,9 +142,6 @@ impl Code {
Code::Unavailable => "The service is currently unavailable",
Code::DataLoss => "Unrecoverable data loss or corruption",
Code::Unauthenticated => "The request does not have valid authentication credentials",
Code::__NonExhaustive => {
unreachable!("__NonExhaustive variant must not be constructed")
}
}
}
}
Expand Down Expand Up @@ -717,8 +710,6 @@ impl Code {
Code::Unavailable => HeaderValue::from_static("14"),
Code::DataLoss => HeaderValue::from_static("15"),
Code::Unauthenticated => HeaderValue::from_static("16"),

Code::__NonExhaustive => unreachable!("Code::__NonExhaustive"),
}
}

Expand Down Expand Up @@ -830,7 +821,7 @@ mod tests {
fn code_from_i32() {
// This for loop should catch if we ever add a new variant and don't
// update From<i32>.
for i in 0..(Code::__NonExhaustive as i32) {
for i in 0..(Code::Unauthenticated as i32) {
let code = Code::from(i);
assert_eq!(
i, code as i32,
Expand All @@ -840,7 +831,6 @@ mod tests {
}

assert_eq!(Code::from(-1), Code::Unknown);
assert_eq!(Code::from(Code::__NonExhaustive as i32), Code::Unknown);
}

#[test]
Expand Down

0 comments on commit 2bf14e1

Please sign in to comment.