Skip to content
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

Fix Clippy warnings on Rust 1.83 #1175

Merged
merged 1 commit into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
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
12 changes: 7 additions & 5 deletions mountpoint-s3-client/src/endpoint_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,13 @@ impl ResolvedEndpointInfo {
let auth_scheme_data: serde_json::Value = serde_json::from_slice(endpoint_properties.as_bytes())?;
let auth_scheme_value = auth_scheme_data["authSchemes"]
.get(0)
.ok_or_else(|| EndpointError::MissingAuthSchemeField("authSchemes"))?;
.ok_or(EndpointError::MissingAuthSchemeField("authSchemes"))?;
let disable_double_encoding = auth_scheme_value["disableDoubleEncoding"]
.as_bool()
.ok_or_else(|| EndpointError::MissingAuthSchemeField("disableDoubleEncoding"))?;
.ok_or(EndpointError::MissingAuthSchemeField("disableDoubleEncoding"))?;
let scheme_name = auth_scheme_value["name"]
.as_str()
.ok_or_else(|| EndpointError::MissingAuthSchemeField("name"))?;
.ok_or(EndpointError::MissingAuthSchemeField("name"))?;
let scheme_name = match scheme_name {
"sigv4" => SigningAlgorithm::SigV4,
"sigv4a" => SigningAlgorithm::SigV4A,
Expand All @@ -231,12 +231,14 @@ impl ResolvedEndpointInfo {

let signing_name = auth_scheme_value["signingName"]
.as_str()
.ok_or_else(|| EndpointError::MissingAuthSchemeField("signingName"))?;
.ok_or(EndpointError::MissingAuthSchemeField("signingName"))?;
let signing_region = auth_scheme_value
.get("signingRegion")
.or_else(|| auth_scheme_value["signingRegionSet"].get(0))
.and_then(|t| t.as_str())
.ok_or_else(|| EndpointError::MissingAuthSchemeField("signingRegion or signingRegionSet"))?;
.ok_or(EndpointError::MissingAuthSchemeField(
"signingRegion or signingRegionSet",
))?;

Ok(AuthScheme {
disable_double_encoding,
Expand Down
4 changes: 2 additions & 2 deletions mountpoint-s3-client/src/mock_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ pub struct OperationCounter<'a> {
operation: Operation,
}

impl<'a> OperationCounter<'a> {
impl OperationCounter<'_> {
/// Return number of requests since the counter was created.
/// The counter is **not** reset when read.
pub fn count(&self) -> u64 {
Expand Down Expand Up @@ -2153,7 +2153,7 @@ mod tests {

let parts = attrs.object_parts.expect("parts should be returned");

let expected_parts = (OBJECT_SIZE + PART_SIZE - 1) / PART_SIZE;
let expected_parts = OBJECT_SIZE.div_ceil(PART_SIZE);
assert_eq!(parts.total_parts_count, Some(expected_parts));

if trailing_checksums == PutObjectTrailingChecksums::Enabled {
Expand Down
2 changes: 1 addition & 1 deletion mountpoint-s3-crt/src/http/request_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ struct HeadersIterator<'a> {
offset: usize,
}

impl<'a> Iterator for HeadersIterator<'a> {
impl Iterator for HeadersIterator<'_> {
type Item = (OsString, OsString);

fn next(&mut self) -> Option<Self::Item> {
Expand Down
4 changes: 2 additions & 2 deletions mountpoint-s3-crt/src/io/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl<'a> InputStream<'a> {
}
}

impl<'a> Drop for InputStream<'a> {
impl Drop for InputStream<'_> {
fn drop(&mut self) {
// SAFETY: self.inner is a valid `aws_input_stream`.
unsafe {
Expand Down Expand Up @@ -100,7 +100,7 @@ impl From<SeekBasis> for aws_stream_seek_basis {
}
}

impl<'a> InputStream<'a> {
impl InputStream<'_> {
/// Seek to the given offset. Basis is either BEGIN or END, and describes where to seek from.
pub fn seek(&self, offset: i64, basis: SeekBasis) -> Result<(), Error> {
// SAFETY: self.inner is a valid input stream.
Expand Down
4 changes: 2 additions & 2 deletions mountpoint-s3-crt/src/s3/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ struct MetaRequestOptionsInner<'a> {
_pinned: PhantomPinned,
}

impl<'a> MetaRequestOptionsInner<'_> {
impl<'a> MetaRequestOptionsInner<'a> {
/// Convert from user_data in a callback to a reference to this struct.
///
/// ## Safety
Expand Down Expand Up @@ -693,7 +693,7 @@ impl<'r, 's> MetaRequestWrite<'r, 's> {
}
}

impl<'r, 's> Future for MetaRequestWrite<'r, 's> {
impl<'s> Future for MetaRequestWrite<'_, 's> {
type Output = Result<&'s [u8], Error>;

fn poll(self: Pin<&mut Self>, cx: &mut std::task::Context<'_>) -> std::task::Poll<Self::Output> {
Expand Down
2 changes: 1 addition & 1 deletion mountpoint-s3/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ where
FileAttr {
ino: lookup.inode.ino(),
size: lookup.stat.size as u64,
blocks: (lookup.stat.size as u64 + STAT_BLOCK_SIZE - 1) / STAT_BLOCK_SIZE,
blocks: (lookup.stat.size as u64).div_ceil(STAT_BLOCK_SIZE),
atime: lookup.stat.atime.into(),
mtime: lookup.stat.mtime.into(),
ctime: lookup.stat.ctime.into(),
Expand Down
4 changes: 2 additions & 2 deletions mountpoint-s3/src/fuse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ where
count: &'a mut usize,
}

impl<'a> DirectoryReplier for ReplyDirectory<'a> {
impl DirectoryReplier for ReplyDirectory<'_> {
fn add(&mut self, entry: DirectoryEntry) -> bool {
let result = self.inner.add(entry.ino, entry.offset, entry.attr.kind, entry.name);
if !result {
Expand Down Expand Up @@ -199,7 +199,7 @@ where
count: &'a mut usize,
}

impl<'a> DirectoryReplier for ReplyDirectoryPlus<'a> {
impl DirectoryReplier for ReplyDirectoryPlus<'_> {
fn add(&mut self, entry: DirectoryEntry) -> bool {
let result = self.inner.add(
entry.ino,
Expand Down
17 changes: 5 additions & 12 deletions mountpoint-s3/tests/fuse_tests/fork_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use aws_sdk_s3::primitives::ByteStream;
use std::fs::{self, File};
#[cfg(not(feature = "s3express_tests"))]
use std::io::Read;
use std::io::{self, BufRead, BufReader, Write};
use std::io::{self, BufRead, BufReader, Cursor, Write};
use std::path::Path;
use std::process::{Child, ExitStatus, Stdio};
use std::time::{Duration, Instant};
Expand Down Expand Up @@ -158,11 +158,7 @@ fn run_in_background_fail_on_mount() -> Result<(), Box<dyn std::error::Error>> {
let mount_point = assert_fs::TempDir::new()?;

let mut cmd = Command::cargo_bin("mount-s3")?;
cmd.arg(&bucket)
.arg(mount_point.path())
.arg("--auto-unmount")
.spawn()
dannycjones marked this conversation as resolved.
Show resolved Hide resolved
.expect("unable to spawn child");
cmd.arg(&bucket).arg(mount_point.path()).arg("--auto-unmount");
if let Some(endpoint_url) = get_test_endpoint_url() {
cmd.arg(format!("--endpoint-url={endpoint_url}"));
}
Expand Down Expand Up @@ -229,9 +225,7 @@ fn run_fail_on_duplicate_mount() -> Result<(), Box<dyn std::error::Error>> {
cmd.arg(&bucket)
.arg(mount_point.path())
.arg(format!("--prefix={prefix}"))
.arg("--auto-unmount")
.spawn()
.expect("unable to spawn child");
.arg("--auto-unmount");
if let Some(endpoint_url) = get_test_endpoint_url() {
cmd.arg(format!("--endpoint-url={endpoint_url}"));
}
Expand Down Expand Up @@ -912,10 +906,9 @@ fn get_mount_from_source_and_mountpoint(source: &str, mount_point: &str) -> Opti
let mut cmd = Command::new("mount");
#[cfg(target_os = "linux")]
cmd.arg("-l");
let mut cmd = cmd.stdout(Stdio::piped()).spawn().expect("Unable to spawn mount tool");
dannycjones marked this conversation as resolved.
Show resolved Hide resolved
let output = cmd.stdout(Stdio::piped()).output().expect("Unable to spawn mount tool");

let stdout = cmd.stdout.as_mut().unwrap();
let stdout_reader = BufReader::new(stdout);
let stdout_reader = BufReader::new(Cursor::new(output.stdout));
let stdout_lines = stdout_reader.lines();

for line in stdout_lines.map_while(Result::ok) {
Expand Down
Loading