Skip to content

Commit

Permalink
cargo clippy
Browse files Browse the repository at this point in the history
Signed-off-by: tison <[email protected]>
  • Loading branch information
tisonkun committed May 20, 2023
1 parent a5d43a5 commit f8aa2dc
Show file tree
Hide file tree
Showing 29 changed files with 37 additions and 49 deletions.
12 changes: 0 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions bindings/java/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub unsafe extern "system" fn JNI_OnLoad(vm: JavaVM, _: *mut c_void) -> jint {
let runtime = Builder::new_multi_thread()
.worker_threads(num_cpus::get())
.on_thread_stop(move || {
VM.get().map(|vm| vm.detach_current_thread());
if let Some(vm) = VM.get() { vm.detach_current_thread() }
})
.build()
.unwrap();
Expand All @@ -64,8 +64,8 @@ pub unsafe extern "system" fn JNI_OnLoad(vm: JavaVM, _: *mut c_void) -> jint {
/// This function could be only called by java vm when unload this lib.
#[no_mangle]
pub unsafe extern "system" fn JNI_OnUnload(_: JavaVM, _: *mut c_void) {
RUNTIME.take().map(|r| r.shutdown_background());
VM.take().map(|vm| vm.detach_current_thread());
if let Some(r) = RUNTIME.take() { r.shutdown_background() }
if let Some(vm) = VM.take() { vm.detach_current_thread() }
}

#[no_mangle]
Expand Down
8 changes: 4 additions & 4 deletions core/src/layers/complete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ where
if self.written + n as u64 > size {
return Err(Error::new(
ErrorKind::ContentTruncated,
&format!(
format!(
"writer got too much data, expect: {size}, actual: {}",
self.written + n as u64
),
Expand Down Expand Up @@ -585,7 +585,7 @@ where
if self.written < size {
return Err(Error::new(
ErrorKind::ContentIncomplete,
&format!(
format!(
"writer got too less data, expect: {size}, actual: {}",
self.written
),
Expand Down Expand Up @@ -615,7 +615,7 @@ where
if self.written + n as u64 > size {
return Err(Error::new(
ErrorKind::ContentTruncated,
&format!(
format!(
"writer got too much data, expect: {size}, actual: {}",
self.written + n as u64
),
Expand All @@ -637,7 +637,7 @@ where
if self.written < size {
return Err(Error::new(
ErrorKind::ContentIncomplete,
&format!(
format!(
"writer got too less data, expect: {size}, actual: {}",
self.written
),
Expand Down
4 changes: 2 additions & 2 deletions core/src/layers/immutable_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ impl<A: Accessor> LayeredAccessor for ImmutableIndexAccessor<A> {
} else {
return Err(Error::new(
ErrorKind::Unsupported,
&format!("delimiter {} is not supported", args.delimiter()),
format!("delimiter {} is not supported", args.delimiter()),
));
};

Expand Down Expand Up @@ -212,7 +212,7 @@ impl<A: Accessor> LayeredAccessor for ImmutableIndexAccessor<A> {
} else {
return Err(Error::new(
ErrorKind::Unsupported,
&format!("delimiter {} is not supported", args.delimiter()),
format!("delimiter {} is not supported", args.delimiter()),
));
};

Expand Down
4 changes: 2 additions & 2 deletions core/src/raw/http_util/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,12 @@ impl IncomingAsyncBody {
Ordering::Equal => Ok(()),
Ordering::Less => Err(Error::new(
ErrorKind::ContentIncomplete,
&format!("reader got too less data, expect: {expect}, actual: {actual}"),
format!("reader got too less data, expect: {expect}, actual: {actual}"),
)
.set_temporary()),
Ordering::Greater => Err(Error::new(
ErrorKind::ContentTruncated,
&format!("reader got too much data, expect: {expect}, actual: {actual}"),
format!("reader got too much data, expect: {expect}, actual: {actual}"),
)
.set_temporary()),
}
Expand Down
4 changes: 2 additions & 2 deletions core/src/services/azblob/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ impl Accessor for AzblobBackend {
.map_err(|e| {
Error::new(
ErrorKind::Unexpected,
&format!("get invalid CONTENT_TYPE header in response: {:?}", e),
format!("get invalid CONTENT_TYPE header in response: {:?}", e),
)
})?;
let splits = content_type.split("boundary=").collect::<Vec<&str>>();
Expand All @@ -690,7 +690,7 @@ impl Accessor for AzblobBackend {
let body = String::from_utf8(body.to_vec()).map_err(|e| {
Error::new(
ErrorKind::Unexpected,
&format!("get invalid batch response {e:?}"),
format!("get invalid batch response {e:?}"),
)
})?;

Expand Down
4 changes: 2 additions & 2 deletions core/src/services/azblob/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ pub(super) fn parse_batch_delete_response(
.map_err(|e| {
Error::new(
ErrorKind::Unexpected,
&format!("invalid status code: {:?}", e),
format!("invalid status code: {:?}", e),
)
})?
.try_into()
.map_err(|e| {
Error::new(
ErrorKind::Unexpected,
&format!("invalid status code: {:?}", e),
format!("invalid status code: {:?}", e),
)
})?;

Expand Down
2 changes: 1 addition & 1 deletion core/src/services/azblob/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub fn parse_http_error(status: StatusCode, body: &str) -> Result<Error> {
Ok(err) => format!("{err:?}"),
Err(_) => body.to_string(),
};
let mut err = Error::new(kind, &message).with_context("response", body.to_string());
let mut err = Error::new(kind, message).with_context("response", body.to_string());

if retryable {
err = err.set_temporary();
Expand Down
2 changes: 1 addition & 1 deletion core/src/services/cos/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub async fn parse_error(resp: Response<IncomingAsyncBody>) -> Result<Error> {
Err(_) => String::from_utf8_lossy(&bs).into_owned(),
};

let mut err = Error::new(kind, &message).with_context("response", format!("{parts:?}"));
let mut err = Error::new(kind, message).with_context("response", format!("{parts:?}"));

if retryable {
err = err.set_temporary();
Expand Down
2 changes: 1 addition & 1 deletion core/src/services/fs/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub fn parse_io_error(err: io::Error) -> Error {
_ => (ErrorKind::Unexpected, true),
};

let mut err = Error::new(kind, &err.kind().to_string()).set_source(err);
let mut err = Error::new(kind, err.kind().to_string()).set_source(err);

if retryable {
err = err.set_temporary();
Expand Down
2 changes: 1 addition & 1 deletion core/src/services/gcs/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ pub async fn parse_error(resp: Response<IncomingAsyncBody>) -> Result<Error> {
Err(_) => String::from_utf8_lossy(&bs).into_owned(),
};

let mut err = Error::new(kind, &message).with_context("response", format!("{parts:?}"));
let mut err = Error::new(kind, message).with_context("response", format!("{parts:?}"));

if retryable {
err = err.set_temporary();
Expand Down
2 changes: 1 addition & 1 deletion core/src/services/gdrive/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ impl GdriveCore {
serde_json::from_slice(resp_body).map_err(new_json_deserialize_error)?;

if gdrive_file_list.files.len() != 1 {
return Err(Error::new(ErrorKind::Unexpected, &format!("Please ensure that the file corresponding to the path exists and is unique. The response body is {}", String::from_utf8_lossy(resp_body))));
return Err(Error::new(ErrorKind::Unexpected, format!("Please ensure that the file corresponding to the path exists and is unique. The response body is {}", String::from_utf8_lossy(resp_body))));
}

parent_id = gdrive_file_list.files[0].id.clone();
Expand Down
2 changes: 1 addition & 1 deletion core/src/services/gdrive/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub async fn parse_error(resp: Response<IncomingAsyncBody>) -> Result<Error> {
_ => (ErrorKind::Unexpected, false),
};

let mut err = Error::new(kind, &String::from_utf8_lossy(&bs))
let mut err = Error::new(kind, String::from_utf8_lossy(&bs))
.with_context("response", format!("{parts:?}"));

if retryable {
Expand Down
2 changes: 1 addition & 1 deletion core/src/services/ghac/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub async fn parse_error(resp: Response<IncomingAsyncBody>) -> Result<Error> {
};

let bs = body.bytes().await?;
let mut err = Error::new(kind, &String::from_utf8_lossy(&bs))
let mut err = Error::new(kind, String::from_utf8_lossy(&bs))
.with_context("response", format!("{parts:?}"));

if retryable {
Expand Down
2 changes: 1 addition & 1 deletion core/src/services/hdfs/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub fn parse_io_error(err: io::Error) -> Error {
_ => (ErrorKind::Unexpected, true),
};

let mut err = Error::new(kind, &err.kind().to_string()).set_source(err);
let mut err = Error::new(kind, err.kind().to_string()).set_source(err);

if retryable {
err = err.set_temporary();
Expand Down
2 changes: 1 addition & 1 deletion core/src/services/http/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub async fn parse_error(resp: Response<IncomingAsyncBody>) -> Result<Error> {
_ => (ErrorKind::Unexpected, false),
};

let mut err = Error::new(kind, &String::from_utf8_lossy(&bs))
let mut err = Error::new(kind, String::from_utf8_lossy(&bs))
.with_context("response", format!("{parts:?}"));

if retryable {
Expand Down
2 changes: 1 addition & 1 deletion core/src/services/ipfs/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub async fn parse_error(resp: Response<IncomingAsyncBody>) -> Result<Error> {
_ => (ErrorKind::Unexpected, false),
};

let mut err = Error::new(kind, &String::from_utf8_lossy(&bs))
let mut err = Error::new(kind, String::from_utf8_lossy(&bs))
.with_context("response", format!("{parts:?}"));

if retryable {
Expand Down
2 changes: 1 addition & 1 deletion core/src/services/ipmfs/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub async fn parse_error(resp: Response<IncomingAsyncBody>) -> Result<Error> {
None => String::from_utf8_lossy(&bs).into_owned(),
};

let mut err = Error::new(kind, &message).with_context("response", format!("{parts:?}"));
let mut err = Error::new(kind, message).with_context("response", format!("{parts:?}"));

if retryable {
err = err.set_temporary();
Expand Down
2 changes: 1 addition & 1 deletion core/src/services/memcached/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,5 +311,5 @@ impl bb8::ManageConnection for MemcacheConnectionManager {
}

pub fn parse_io_error(err: std::io::Error) -> Error {
Error::new(ErrorKind::Unexpected, &err.kind().to_string()).set_source(err)
Error::new(ErrorKind::Unexpected, err.kind().to_string()).set_source(err)
}
2 changes: 1 addition & 1 deletion core/src/services/obs/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub async fn parse_error(resp: Response<IncomingAsyncBody>) -> Result<Error> {
Err(_) => String::from_utf8_lossy(&bs).into_owned(),
};

let mut err = Error::new(kind, &message).with_context("response", format!("{parts:?}"));
let mut err = Error::new(kind, message).with_context("response", format!("{parts:?}"));

if retryable {
err = err.set_temporary();
Expand Down
2 changes: 1 addition & 1 deletion core/src/services/onedrive/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub async fn parse_error(resp: Response<IncomingAsyncBody>) -> Result<Error> {
_ => (ErrorKind::Unexpected, false),
};

let mut err = Error::new(kind, &String::from_utf8_lossy(&bs))
let mut err = Error::new(kind, String::from_utf8_lossy(&bs))
.with_context("response", format!("{parts:?}"));

if retryable {
Expand Down
2 changes: 1 addition & 1 deletion core/src/services/oss/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub async fn parse_error(resp: Response<IncomingAsyncBody>) -> Result<Error> {
Err(_) => String::from_utf8_lossy(&bs).into_owned(),
};

let mut err = Error::new(kind, &message).with_context("response", format!("{parts:?}"));
let mut err = Error::new(kind, message).with_context("response", format!("{parts:?}"));

if retryable {
err = err.set_temporary();
Expand Down
2 changes: 1 addition & 1 deletion core/src/services/s3/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub async fn parse_error(resp: Response<IncomingAsyncBody>) -> Result<Error> {
(kind, retryable) = parse_s3_error_code(s3_err.code.as_str()).unwrap_or((kind, retryable));
}

let mut err = Error::new(kind, &message).with_context("response", format!("{parts:?}"));
let mut err = Error::new(kind, message).with_context("response", format!("{parts:?}"));

if retryable {
err = err.set_temporary();
Expand Down
2 changes: 1 addition & 1 deletion core/src/services/supabase/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub async fn parse_error(resp: Response<IncomingAsyncBody>) -> Result<Error> {
})
.unwrap_or_else(|_| (String::from_utf8_lossy(&bs).into_owned(), None));

let mut err = Error::new(kind, &message).with_context("response", format!("{parts:?}"));
let mut err = Error::new(kind, message).with_context("response", format!("{parts:?}"));

if retryable {
err = err.set_temporary();
Expand Down
2 changes: 1 addition & 1 deletion core/src/services/vercel_artifacts/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub async fn parse_error(resp: Response<IncomingAsyncBody>) -> Result<Error> {
_ => (ErrorKind::Unexpected, false),
};

let mut err = Error::new(kind, &String::from_utf8_lossy(&bs))
let mut err = Error::new(kind, String::from_utf8_lossy(&bs))
.with_context("response", format!("{parts:?}"));

if retryable {
Expand Down
2 changes: 1 addition & 1 deletion core/src/services/wasabi/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pub async fn parse_error(resp: Response<IncomingAsyncBody>) -> Result<Error> {
}
}

let mut err = Error::new(kind, &message).with_context("response", format!("{parts:?}"));
let mut err = Error::new(kind, message).with_context("response", format!("{parts:?}"));

if retryable {
err = err.set_temporary();
Expand Down
2 changes: 1 addition & 1 deletion core/src/services/webdav/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub async fn parse_error(resp: Response<IncomingAsyncBody>) -> Result<Error> {
_ => (ErrorKind::Unexpected, false),
};

let mut err = Error::new(kind, &String::from_utf8_lossy(&bs))
let mut err = Error::new(kind, String::from_utf8_lossy(&bs))
.with_context("response", format!("{parts:?}"));

if retryable {
Expand Down
2 changes: 1 addition & 1 deletion core/src/services/webdav/list_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl ListOpResponse {
if code >= 400 {
return Err(Error::new(
ErrorKind::Unexpected,
&format!("Invalid response: {} {}", code, text),
format!("Invalid response: {} {}", code, text),
));
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/services/webhdfs/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ fn parse_error_msg(parts: Parts, body: &str) -> Result<Error> {
Err(_) => body.to_owned(),
};

let mut err = Error::new(kind, &message).with_context("response", format!("{parts:?}"));
let mut err = Error::new(kind, message).with_context("response", format!("{parts:?}"));

if retryable {
err = err.set_temporary();
Expand Down

0 comments on commit f8aa2dc

Please sign in to comment.