Skip to content

Commit 0a5504c

Browse files
author
Michael Ingley
committed
errors: remove cfg(clippy) GrpcAPI payload split
Signed-off-by: Michael Ingley <mingley@linkedin.com>
1 parent 7b9e388 commit 0a5504c

File tree

3 files changed

+4
-18
lines changed

3 files changed

+4
-18
lines changed

examples/raw.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright 2018 TiKV Project Authors. Licensed under Apache-2.0.
22

33
#![type_length_limit = "8165158"]
4+
#![allow(clippy::result_large_err)]
45

56
mod common;
67

src/common/errors.rs

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@ use crate::proto::kvrpcpb;
88
use crate::region::RegionVerId;
99
use crate::BoundRange;
1010

11-
#[cfg(clippy)]
12-
type GrpcApiErrorPayload = Box<tonic::Status>;
13-
#[cfg(not(clippy))]
14-
type GrpcApiErrorPayload = tonic::Status;
15-
1611
/// Protobuf-generated region-level error returned by TiKV.
1712
///
1813
/// This type is generated from TiKV's protobuf definitions and may change in a
@@ -73,7 +68,7 @@ pub enum Error {
7368
/// Wraps a `reqwest::Error`.
7469
/// Wraps a `grpcio::Error`.
7570
#[error("gRPC api error: {0}")]
76-
GrpcAPI(GrpcApiErrorPayload),
71+
GrpcAPI(tonic::Status),
7772
/// Wraps a `grpcio::Error`.
7873
#[error("url error: {0}")]
7974
Url(#[from] tonic::codegen::http::uri::InvalidUri),
@@ -149,23 +144,13 @@ impl From<ProtoKeyError> for Error {
149144

150145
impl From<tonic::Status> for Error {
151146
fn from(status: tonic::Status) -> Error {
152-
Error::GrpcAPI(grpc_api_error_payload(status))
147+
Error::GrpcAPI(status)
153148
}
154149
}
155150

156151
/// A result holding an [`Error`](enum@Error).
157152
pub type Result<T> = result::Result<T, Error>;
158153

159-
#[cfg(clippy)]
160-
fn grpc_api_error_payload(status: tonic::Status) -> GrpcApiErrorPayload {
161-
Box::new(status)
162-
}
163-
164-
#[cfg(not(clippy))]
165-
fn grpc_api_error_payload(status: tonic::Status) -> GrpcApiErrorPayload {
166-
status
167-
}
168-
169154
#[doc(hidden)]
170155
#[macro_export]
171156
macro_rules! internal_err {
@@ -200,7 +185,6 @@ mod test {
200185
}
201186

202187
#[test]
203-
#[cfg(not(clippy))]
204188
fn grpc_api_variant_accepts_tonic_status_payload() {
205189
let error = Error::GrpcAPI(tonic::Status::new(Code::DeadlineExceeded, "timeout"));
206190
let Error::GrpcAPI(status) = error else {

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
//! ```
9292
9393
#![allow(clippy::field_reassign_with_default)]
94+
#![allow(clippy::result_large_err)]
9495

9596
pub mod backoff;
9697
#[doc(hidden)]

0 commit comments

Comments
 (0)