Skip to content

Commit

Permalink
chore: Fix clippy warnings found in rust 1.75 (#3849)
Browse files Browse the repository at this point in the history
* Fix

Signed-off-by: Xuanwo <[email protected]>

* Fix build

Signed-off-by: Xuanwo <[email protected]>

* Fix

Signed-off-by: Xuanwo <[email protected]>

* Fix fmt

Signed-off-by: Xuanwo <[email protected]>

---------

Signed-off-by: Xuanwo <[email protected]>
  • Loading branch information
Xuanwo authored Dec 29, 2023
1 parent 064c0bf commit 8c229d1
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
3 changes: 3 additions & 0 deletions bindings/python/src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
// specific language governing permissions and limitations
// under the License.

// Remove this allow after <https://github.com/rust-lang/rust-clippy/issues/12039> fixed.
#![allow(clippy::unnecessary_fallible_conversions)]

use std::io::Read;
use std::io::Seek;
use std::io::SeekFrom;
Expand Down
2 changes: 1 addition & 1 deletion core/src/services/huggingface/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ impl Accessor for HuggingfaceBackend {
.map_err(new_json_deserialize_error)?;

// NOTE: if the file is not found, the server will return 200 with an empty array
if let Some(status) = decoded_response.get(0) {
if let Some(status) = decoded_response.first() {
if let Some(commit_info) = status.last_commit.as_ref() {
meta.set_last_modified(parse_datetime_from_rfc3339(
commit_info.date.as_str(),
Expand Down
2 changes: 2 additions & 0 deletions core/src/services/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ pub use ftp::FtpConfig;
mod gcs;
#[cfg(feature = "services-gcs")]
pub use gcs::Gcs;
#[cfg(feature = "services-gcs")]
pub use gcs::GcsConfig;

#[cfg(feature = "services-ghac")]
mod ghac;
Expand Down
2 changes: 1 addition & 1 deletion core/src/services/webdav/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ impl Accessor for WebdavBackend {
quick_xml::de::from_reader(bs.reader()).map_err(new_xml_deserialize_error)?;
let item = result
.response
.get(0)
.first()
.ok_or_else(|| {
Error::new(
ErrorKind::Unexpected,
Expand Down
16 changes: 8 additions & 8 deletions integrations/object_store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,11 +341,11 @@ mod tests {
let op = Operator::new(services::Memory::default()).unwrap().finish();
let object_store = Arc::new(OpendalStore::new(op));

let path: Path = "data/test.txt".try_into().unwrap();
let path: Path = "data/test.txt".into();
let bytes = Bytes::from_static(b"hello, world!");
object_store.put(&path, bytes).await.unwrap();

let path: Path = "data/nested/test.txt".try_into().unwrap();
let path: Path = "data/nested/test.txt".into();
let bytes = Bytes::from_static(b"hello, world! I am nested.");
object_store.put(&path, bytes).await.unwrap();

Expand All @@ -358,7 +358,7 @@ mod tests {
let object_store: Arc<dyn ObjectStore> = Arc::new(OpendalStore::new(op));

// Retrieve a specific file
let path: Path = "data/test.txt".try_into().unwrap();
let path: Path = "data/test.txt".into();

let bytes = Bytes::from_static(b"hello, world!");
object_store.put(&path, bytes.clone()).await.unwrap();
Expand All @@ -382,7 +382,7 @@ mod tests {
#[tokio::test]
async fn test_list() {
let object_store = create_test_object_store().await;
let path: Path = "data/".try_into().unwrap();
let path: Path = "data/".into();
let results = object_store
.list(Some(&path))
.await
Expand All @@ -409,7 +409,7 @@ mod tests {
assert_eq!(locations, expected_locations);

for (location, bytes) in expected_files {
let path: Path = location.try_into().unwrap();
let path: Path = location.into();
assert_eq!(
object_store
.get(&path)
Expand All @@ -426,7 +426,7 @@ mod tests {
#[tokio::test]
async fn test_list_with_delimiter() {
let object_store = create_test_object_store().await;
let path: Path = "data/".try_into().unwrap();
let path: Path = "data/".into();
let result = object_store.list_with_delimiter(Some(&path)).await.unwrap();
assert_eq!(result.objects.len(), 1);
assert_eq!(result.common_prefixes.len(), 1);
Expand All @@ -437,8 +437,8 @@ mod tests {
#[tokio::test]
async fn test_list_with_offset() {
let object_store = create_test_object_store().await;
let path: Path = "data/".try_into().unwrap();
let offset: Path = "data/nested/test.txt".try_into().unwrap();
let path: Path = "data/".into();
let offset: Path = "data/nested/test.txt".into();
let result = object_store
.list_with_offset(Some(&path), &offset)
.await
Expand Down

0 comments on commit 8c229d1

Please sign in to comment.