diff --git a/src/api/admin/bucket.rs b/src/api/admin/bucket.rs index 2a8abd82..046ed44c 100644 --- a/src/api/admin/bucket.rs +++ b/src/api/admin/bucket.rs @@ -183,7 +183,7 @@ impl RequestHandler for CreateBucketRequest { let key = helper.key().get_existing_key(&la.access_key_id).await?; let state = key.state.as_option().unwrap(); - if matches!(state.local_aliases.get(&la.alias), Some(_)) { + if state.local_aliases.get(&la.alias).is_some() { return Err(Error::bad_request("Local alias already exists")); } } diff --git a/src/api/admin/openapi.rs b/src/api/admin/openapi.rs index c40e7c62..c5936ade 100644 --- a/src/api/admin/openapi.rs +++ b/src/api/admin/openapi.rs @@ -19,7 +19,7 @@ use crate::api::*; (status = 200, description = "Garage daemon metrics exported in Prometheus format"), ), )] -fn Metrics() -> () {} +fn Metrics() {} #[utoipa::path(get, path = "/health", @@ -36,7 +36,7 @@ as long as it is able to have a quorum of nodes for read and write operations. (status = 503, description = "This Garage daemon is not able to handle requests") ), )] -fn Health() -> () {} +fn Health() {} #[utoipa::path(get, path = "/check", @@ -54,7 +54,7 @@ do not correspond to an actual website. (status = 400, description = "No static website bucket exists for this domain") ), )] -fn CheckDomain() -> () {} +fn CheckDomain() {} // ********************************************** // Cluster operations @@ -78,7 +78,7 @@ Returns the cluster's current status, including: (status = 500, description = "Internal server error") ), )] -fn GetClusterStatus() -> () {} +fn GetClusterStatus() {} #[utoipa::path(get, path = "/v2/GetClusterHealth", @@ -88,7 +88,7 @@ fn GetClusterStatus() -> () {} (status = 200, description = "Cluster health report", body = GetClusterHealthResponse), ), )] -fn GetClusterHealth() -> () {} +fn GetClusterHealth() {} #[utoipa::path(get, path = "/v2/GetClusterStatistics", @@ -103,7 +103,7 @@ Fetch global cluster statistics. (status = 500, description = "Internal server error") ), )] -fn GetClusterStatistics() -> () {} +fn GetClusterStatistics() {} #[utoipa::path(post, path = "/v2/ConnectClusterNodes", @@ -115,7 +115,7 @@ fn GetClusterStatistics() -> () {} (status = 500, description = "Internal server error") ), )] -fn ConnectClusterNodes() -> () {} +fn ConnectClusterNodes() {} // ********************************************** // Admin API token operations @@ -130,7 +130,7 @@ fn ConnectClusterNodes() -> () {} (status = 500, description = "Internal server error") ), )] -fn ListAdminTokens() -> () {} +fn ListAdminTokens() {} #[utoipa::path(get, path = "/v2/GetAdminTokenInfo", @@ -145,7 +145,7 @@ You can search by specifying the exact token identifier (`id`) or by specifying (status = 500, description = "Internal server error") ), )] -fn GetAdminTokenInfo() -> () {} +fn GetAdminTokenInfo() {} #[utoipa::path(post, path = "/v2/CreateAdminToken", @@ -157,7 +157,7 @@ fn GetAdminTokenInfo() -> () {} (status = 500, description = "Internal server error") ), )] -fn CreateAdminToken() -> () {} +fn CreateAdminToken() {} #[utoipa::path(post, path = "/v2/UpdateAdminToken", @@ -172,7 +172,7 @@ Updates information about the specified admin API token. (status = 500, description = "Internal server error") ), )] -fn UpdateAdminToken() -> () {} +fn UpdateAdminToken() {} #[utoipa::path(post, path = "/v2/DeleteAdminToken", @@ -184,7 +184,7 @@ fn UpdateAdminToken() -> () {} (status = 500, description = "Internal server error") ), )] -fn DeleteAdminToken() -> () {} +fn DeleteAdminToken() {} #[utoipa::path(get, path = "/v2/GetCurrentAdminTokenInfo", @@ -197,7 +197,7 @@ Return information about the calling admin API token. (status = 500, description = "Internal server error") ), )] -fn GetCurrentAdminTokenInfo() -> () {} +fn GetCurrentAdminTokenInfo() {} // ********************************************** // Layout operations @@ -219,7 +219,7 @@ Returns the cluster's current layout, including: (status = 500, description = "Internal server error") ), )] -fn GetClusterLayout() -> () {} +fn GetClusterLayout() {} #[utoipa::path(get, path = "/v2/GetClusterLayoutHistory", @@ -232,7 +232,7 @@ Returns the history of layouts in the cluster (status = 500, description = "Internal server error") ), )] -fn GetClusterLayoutHistory() -> () {} +fn GetClusterLayoutHistory() {} #[utoipa::path(post, path = "/v2/UpdateClusterLayout", @@ -261,7 +261,7 @@ Contrary to the CLI that may update only a subset of the fields capacity, zone a (status = 500, description = "Internal server error") ), )] -fn UpdateClusterLayout() -> () {} +fn UpdateClusterLayout() {} // Hack: we cannot use the UpdateClusterLayoutRequest from api.rs, // as it contains (via NodeRoleChange) an untagged enum flattenned into @@ -315,7 +315,7 @@ Computes a new layout taking into account the staged parameters, and returns it (status = 500, description = "Internal server error") ), )] -fn PreviewClusterLayoutChanges() -> () {} +fn PreviewClusterLayoutChanges() {} #[utoipa::path(post, path = "/v2/ApplyClusterLayout", @@ -331,7 +331,7 @@ Applies to the cluster the layout changes currently registered as staged layout (status = 500, description = "Internal server error") ), )] -fn ApplyClusterLayout() -> () {} +fn ApplyClusterLayout() {} #[utoipa::path(post, path = "/v2/RevertClusterLayout", @@ -342,7 +342,7 @@ fn ApplyClusterLayout() -> () {} (status = 500, description = "Internal server error") ), )] -fn RevertClusterLayout() -> () {} +fn RevertClusterLayout() {} #[utoipa::path(post, path = "/v2/ClusterLayoutSkipDeadNodes", @@ -354,7 +354,7 @@ fn RevertClusterLayout() -> () {} (status = 500, description = "Internal server error") ), )] -fn ClusterLayoutSkipDeadNodes() -> () {} +fn ClusterLayoutSkipDeadNodes() {} // ********************************************** // Access key operations @@ -369,7 +369,7 @@ fn ClusterLayoutSkipDeadNodes() -> () {} (status = 500, description = "Internal server error") ), )] -fn ListKeys() -> () {} +fn ListKeys() {} #[utoipa::path(get, path = "/v2/GetKeyInfo", @@ -386,7 +386,7 @@ For confidentiality reasons, the secret key is not returned by default: you must (status = 500, description = "Internal server error") ), )] -fn GetKeyInfo() -> () {} +fn GetKeyInfo() {} #[utoipa::path(post, path = "/v2/CreateKey", @@ -398,7 +398,7 @@ fn GetKeyInfo() -> () {} (status = 500, description = "Internal server error") ), )] -fn CreateKey() -> () {} +fn CreateKey() {} #[utoipa::path(post, path = "/v2/ImportKey", @@ -414,7 +414,7 @@ Imports an existing API key. This feature must only be used for migrations and b (status = 500, description = "Internal server error") ), )] -fn ImportKey() -> () {} +fn ImportKey() {} #[utoipa::path(post, path = "/v2/UpdateKey", @@ -431,7 +431,7 @@ Updates information about the specified API access key. (status = 500, description = "Internal server error") ), )] -fn UpdateKey() -> () {} +fn UpdateKey() {} #[utoipa::path(post, path = "/v2/DeleteKey", @@ -443,7 +443,7 @@ fn UpdateKey() -> () {} (status = 500, description = "Internal server error") ), )] -fn DeleteKey() -> () {} +fn DeleteKey() {} // ********************************************** // Bucket operations @@ -458,7 +458,7 @@ fn DeleteKey() -> () {} (status = 500, description = "Internal server error") ), )] -fn ListBuckets() -> () {} +fn ListBuckets() {} #[utoipa::path(get, path = "/v2/GetBucketInfo", @@ -475,7 +475,7 @@ and its quotas (if any). (status = 500, description = "Internal server error") ), )] -fn GetBucketInfo() -> () {} +fn GetBucketInfo() {} #[utoipa::path(post, path = "/v2/CreateBucket", @@ -490,7 +490,7 @@ Technically, you can also specify both `globalAlias` and `localAlias` and that w (status = 500, description = "Internal server error") ), )] -fn CreateBucket() -> () {} +fn CreateBucket() {} #[utoipa::path(post, path = "/v2/UpdateBucket", @@ -516,7 +516,7 @@ to change only one of the two quotas. (status = 500, description = "Internal server error") ), )] -fn UpdateBucket() -> () {} +fn UpdateBucket() {} #[utoipa::path(post, path = "/v2/DeleteBucket", @@ -534,7 +534,7 @@ Deletes a storage bucket. A bucket cannot be deleted if it is not empty. (status = 500, description = "Internal server error") ), )] -fn DeleteBucket() -> () {} +fn DeleteBucket() {} #[utoipa::path(post, path = "/v2/CleanupIncompleteUploads", @@ -546,7 +546,7 @@ fn DeleteBucket() -> () {} (status = 500, description = "Internal server error") ), )] -fn CleanupIncompleteUploads() -> () {} +fn CleanupIncompleteUploads() {} #[utoipa::path(get, path = "/v2/InspectObject", @@ -568,7 +568,7 @@ upload is in progress and not yet finished. (status = 500, description = "Internal server error") ), )] -fn InspectObject() -> () {} +fn InspectObject() {} // ********************************************** // Operations on permissions for keys on buckets @@ -594,7 +594,7 @@ If you want to disallow read for the key, check the DenyBucketKey operation. (status = 500, description = "Internal server error") ), )] -fn AllowBucketKey() -> () {} +fn AllowBucketKey() {} #[utoipa::path(post, path = "/v2/DenyBucketKey", @@ -616,7 +616,7 @@ If you want the key to have the reading permission, check the AllowBucketKey ope (status = 500, description = "Internal server error") ), )] -fn DenyBucketKey() -> () {} +fn DenyBucketKey() {} // ********************************************** // Operations on bucket aliases @@ -632,7 +632,7 @@ fn DenyBucketKey() -> () {} (status = 500, description = "Internal server error") ), )] -fn AddBucketAlias() -> () {} +fn AddBucketAlias() {} #[utoipa::path(post, path = "/v2/RemoveBucketAlias", @@ -644,7 +644,7 @@ fn AddBucketAlias() -> () {} (status = 500, description = "Internal server error") ), )] -fn RemoveBucketAlias() -> () {} +fn RemoveBucketAlias() {} // Hack for issue #1249 (see UpdateClusterLayout) #[derive(Debug, Clone, Serialize, Deserialize, ToSchema)] @@ -680,7 +680,7 @@ Return information about the Garage daemon running on one or several nodes. (status = 500, description = "Internal server error") ), )] -fn GetNodeInfo() -> () {} +fn GetNodeInfo() {} #[utoipa::path(get, path = "/v2/GetNodeStatistics", @@ -696,7 +696,7 @@ Fetch statistics for one or several Garage nodes. (status = 500, description = "Internal server error") ), )] -fn GetNodeStatistics() -> () {} +fn GetNodeStatistics() {} #[utoipa::path(post, path = "/v2/CreateMetadataSnapshot", @@ -710,7 +710,7 @@ Instruct one or several nodes to take a snapshot of their metadata databases. (status = 500, description = "Internal server error") ), )] -fn CreateMetadataSnapshot() -> () {} +fn CreateMetadataSnapshot() {} #[utoipa::path(post, path = "/v2/LaunchRepairOperation", @@ -725,7 +725,7 @@ Launch a repair operation on one or several cluster nodes. (status = 500, description = "Internal server error") ), )] -fn LaunchRepairOperation() -> () {} +fn LaunchRepairOperation() {} // ********************************************** // Worker operations @@ -744,7 +744,7 @@ List background workers currently running on one or several cluster nodes. (status = 500, description = "Internal server error") ), )] -fn ListWorkers() -> () {} +fn ListWorkers() {} #[utoipa::path(post, path = "/v2/GetWorkerInfo", @@ -759,7 +759,7 @@ Get information about the specified background worker on one or several cluster (status = 500, description = "Internal server error") ), )] -fn GetWorkerInfo() -> () {} +fn GetWorkerInfo() {} #[utoipa::path(post, path = "/v2/GetWorkerVariable", @@ -774,7 +774,7 @@ Fetch values of one or several worker variables, from one or several cluster nod (status = 500, description = "Internal server error") ), )] -fn GetWorkerVariable() -> () {} +fn GetWorkerVariable() {} #[utoipa::path(post, path = "/v2/SetWorkerVariable", @@ -789,7 +789,7 @@ Set the value for a worker variable, on one or several cluster nodes. (status = 500, description = "Internal server error") ), )] -fn SetWorkerVariable() -> () {} +fn SetWorkerVariable() {} // ********************************************** // Block operations @@ -807,7 +807,7 @@ List data blocks that are currently in an errored state on one or several Garage (status = 500, description = "Internal server error") ), )] -fn ListBlockErrors() -> () {} +fn ListBlockErrors() {} #[utoipa::path(post, path = "/v2/GetBlockInfo", @@ -822,7 +822,7 @@ Get detailed information about a data block stored on a Garage node, including a (status = 500, description = "Internal server error") ), )] -fn GetBlockInfo() -> () {} +fn GetBlockInfo() {} #[utoipa::path(post, path = "/v2/RetryBlockResync", @@ -837,7 +837,7 @@ Instruct Garage node(s) to retry the resynchronization of one or several missing (status = 500, description = "Internal server error") ), )] -fn RetryBlockResync() -> () {} +fn RetryBlockResync() {} #[utoipa::path(post, path = "/v2/PurgeBlocks", @@ -854,7 +854,7 @@ This will remove all objects and in-progress multipart uploads that contain the (status = 500, description = "Internal server error") ), )] -fn PurgeBlocks() -> () {} +fn PurgeBlocks() {} // ********************************************** // ********************************************** diff --git a/src/api/admin/repair.rs b/src/api/admin/repair.rs index a94ca9a6..1d5665d1 100644 --- a/src/api/admin/repair.rs +++ b/src/api/admin/repair.rs @@ -345,7 +345,7 @@ impl BlockRcRepair { #[async_trait] impl Worker for BlockRcRepair { fn name(&self) -> String { - format!("Block refcount repair worker") + "Block refcount repair worker".into() } fn status(&self) -> WorkerStatus { diff --git a/src/api/common/generic_server.rs b/src/api/common/generic_server.rs index f98cdb7d..181b6231 100644 --- a/src/api/common/generic_server.rs +++ b/src/api/common/generic_server.rs @@ -154,7 +154,7 @@ impl ApiServer { { format!("{forwarded_for_ip_addr} (via {addr})") } else { - format!("{addr}") + addr }; // we only do this to log the access key, so we can discard any error let key = self diff --git a/src/api/s3/post_object.rs b/src/api/s3/post_object.rs index c7fe6b0d..e89e9ea9 100644 --- a/src/api/s3/post_object.rs +++ b/src/api/s3/post_object.rs @@ -505,15 +505,15 @@ mod tests { let mut conditions = policy_2.into_conditions().unwrap(); assert_eq!( - conditions.params.remove(&"acl".to_string()), + conditions.params.remove("acl"), Some(vec![Operation::Equal("public-read".into())]) ); assert_eq!( - conditions.params.remove(&"bucket".to_string()), + conditions.params.remove("bucket"), Some(vec![Operation::Equal("johnsmith".into())]) ); assert_eq!( - conditions.params.remove(&"key".to_string()), + conditions.params.remove("key"), Some(vec![Operation::StartsWith("user/eric/".into())]) ); assert!(conditions.params.is_empty()); @@ -536,7 +536,7 @@ mod tests { let mut conditions = policy_2.into_conditions().unwrap(); assert_eq!( - conditions.params.remove(&"acl".to_string()), + conditions.params.remove("acl"), Some(vec![Operation::Equal("public-read".into())]) ); assert_eq!( @@ -544,9 +544,7 @@ mod tests { vec![Operation::StartsWith("image/".into())] ); assert_eq!( - conditions - .params - .remove(&"success_action_redirect".to_string()), + conditions.params.remove("success_action_redirect"), Some(vec![Operation::StartsWith("".into())]) ); assert!(conditions.params.is_empty()); diff --git a/src/block/block.rs b/src/block/block.rs index bd95680e..867aa546 100644 --- a/src/block/block.rs +++ b/src/block/block.rs @@ -89,7 +89,7 @@ impl DataBlock { return DataBlock::compressed(data_compressed.into()); } } - DataBlock::plain(data.into()) + DataBlock::plain(data) }) .await .unwrap() diff --git a/src/block/layout.rs b/src/block/layout.rs index ae57a1cc..7e818d77 100644 --- a/src/block/layout.rs +++ b/src/block/layout.rs @@ -325,7 +325,7 @@ fn make_data_dirs(dirs: &DataDirEnum) -> Result, Error> { let mut ok = false; for dir in dirs.iter() { let state = match &dir.capacity { - Some(cap) if dir.read_only == false => { + Some(cap) if !dir.read_only => { let capacity = cap.parse::() .ok_or_message("invalid capacity value")?.as_u64(); if capacity == 0 { @@ -336,7 +336,7 @@ fn make_data_dirs(dirs: &DataDirEnum) -> Result, Error> { capacity, } } - None if dir.read_only == true => { + None if dir.read_only => { DataDirState::ReadOnly } _ => return Err(Error::Message(format!("data directories in data_dir should have a capacity value or be marked read_only, not the case for {}", dir.path.to_string_lossy()))), diff --git a/src/block/manager.rs b/src/block/manager.rs index 0a7b55dd..d33110cb 100644 --- a/src/block/manager.rs +++ b/src/block/manager.rs @@ -569,12 +569,10 @@ impl BlockManager { async { match self.find_block(hash).await { Some(p) => self.read_block_from(hash, &p).await, - None => { - return Err(Error::Message(format!( - "block {:?} not found on node", - hash - ))); - } + None => Err(Error::Message(format!( + "block {:?} not found on node", + hash + ))), } } .bound_record_duration(&self.metrics.block_read_duration) diff --git a/src/block/repair.rs b/src/block/repair.rs index ef271094..96ad4bb5 100644 --- a/src/block/repair.rs +++ b/src/block/repair.rs @@ -558,7 +558,7 @@ impl Worker for RebalanceWorker { } fn status(&self) -> WorkerStatus { - let t_cur = self.t_finished.unwrap_or_else(|| now_msec()); + let t_cur = self.t_finished.unwrap_or_else(now_msec); let rate = self.moved_bytes / std::cmp::max(1, (t_cur - self.t_started) / 1000); let mut freeform = vec![ format!("Blocks moved: {}", self.moved), diff --git a/src/db/lmdb_adapter.rs b/src/db/lmdb_adapter.rs index 83bd0008..997c074c 100644 --- a/src/db/lmdb_adapter.rs +++ b/src/db/lmdb_adapter.rs @@ -45,16 +45,14 @@ pub(crate) fn open_db(path: &PathBuf, opt: &OpenOpt) -> Result { } } match env_builder.open(path) { - Err(heed::Error::Io(e)) if e.kind() == std::io::ErrorKind::OutOfMemory => { - return Err(Error( - "OutOfMemory error while trying to open LMDB database. This can happen \ + Err(heed::Error::Io(e)) if e.kind() == std::io::ErrorKind::OutOfMemory => Err(Error( + "OutOfMemory error while trying to open LMDB database. This can happen \ if your operating system is not allowing you to use sufficient virtual \ memory address space. Please check that no limit is set (ulimit -v). \ You may also try to set a smaller `lmdb_map_size` configuration parameter. \ On 32-bit machines, you should probably switch to another database engine." - .into(), - )) - } + .into(), + )), Err(e) => Err(Error(format!("Cannot open LMDB database: {}", e).into())), Ok(db) => Ok(LmdbDb::init(db)), } diff --git a/src/db/open.rs b/src/db/open.rs index 264550d7..ed264752 100644 --- a/src/db/open.rs +++ b/src/db/open.rs @@ -68,22 +68,13 @@ impl std::str::FromStr for Engine { } } +#[derive(Default)] pub struct OpenOpt { pub fsync: bool, pub lmdb_map_size: Option, pub fjall_block_cache_size: Option, } -impl Default for OpenOpt { - fn default() -> Self { - Self { - fsync: false, - lmdb_map_size: None, - fjall_block_cache_size: None, - } - } -} - pub fn open_db(path: &PathBuf, engine: Engine, opt: &OpenOpt) -> Result { match engine { // ---- Sqlite DB ---- diff --git a/src/db/sqlite_adapter.rs b/src/db/sqlite_adapter.rs index 5c052501..8cc4e119 100644 --- a/src/db/sqlite_adapter.rs +++ b/src/db/sqlite_adapter.rs @@ -308,7 +308,7 @@ impl IDb for SqliteDb { trace!("transaction done"); drop(lock); - return res; + res } } diff --git a/src/garage/cli/remote/bucket.rs b/src/garage/cli/remote/bucket.rs index 1c0774a3..5085480d 100644 --- a/src/garage/cli/remote/bucket.rs +++ b/src/garage/cli/remote/bucket.rs @@ -567,7 +567,7 @@ fn print_bucket_info(bucket: &GetBucketInfoResponse) { format_table(info); - println!(""); + println!(); println!("==== KEYS FOR THIS BUCKET ===="); let mut key_info = vec!["Permissions\tAccess key\t\tLocal aliases".to_string()]; key_info.extend(bucket.keys.iter().map(|key| { diff --git a/src/garage/cli/remote/key.rs b/src/garage/cli/remote/key.rs index f448bb17..7341d3d1 100644 --- a/src/garage/cli/remote/key.rs +++ b/src/garage/cli/remote/key.rs @@ -296,7 +296,7 @@ fn print_key_info(key: &GetKeyInfoResponse) { ]); format_table(table); - println!(""); + println!(); println!("==== BUCKETS FOR THIS KEY ===="); let mut bucket_info = vec!["Permissions\tID\tGlobal aliases\tLocal aliases".to_string()]; bucket_info.extend(key.buckets.iter().map(|bucket| { diff --git a/src/k2v-client/lib.rs b/src/k2v-client/lib.rs index addcb2c0..d521422a 100644 --- a/src/k2v-client/lib.rs +++ b/src/k2v-client/lib.rs @@ -649,13 +649,13 @@ struct PollRangeResponse { impl<'a> Filter<'a> { fn query_params(&self) -> Vec<(&'static str, std::borrow::Cow<'_, str>)> { let mut res = Vec::<(&'static str, std::borrow::Cow)>::with_capacity(8); - if let Some(start) = self.start.as_deref() { + if let Some(start) = self.start { res.push(("start", start.into())); } - if let Some(end) = self.end.as_deref() { + if let Some(end) = self.end { res.push(("end", end.into())); } - if let Some(prefix) = self.prefix.as_deref() { + if let Some(prefix) = self.prefix { res.push(("prefix", prefix.into())); } if let Some(limit) = &self.limit { diff --git a/src/model/s3/mpu_table.rs b/src/model/s3/mpu_table.rs index c9f79caf..135e1888 100644 --- a/src/model/s3/mpu_table.rs +++ b/src/model/s3/mpu_table.rs @@ -160,8 +160,8 @@ impl Crdt for MpuPart { (x, _) => x, }; self.checksum = match (self.checksum.take(), &other.checksum) { - (None, Some(_)) => other.checksum.clone(), - (Some(x), Some(y)) if x < *y => other.checksum.clone(), + (None, Some(_)) => other.checksum, + (Some(x), Some(y)) if x < *y => other.checksum, (x, _) => x, }; } diff --git a/src/net/bytes_buf.rs b/src/net/bytes_buf.rs index 1d928ffb..e96184ae 100644 --- a/src/net/bytes_buf.rs +++ b/src/net/bytes_buf.rs @@ -130,7 +130,7 @@ impl BytesBuf { /// Return the content as a stream of individual chunks pub fn into_stream(self) -> ByteStream { use futures::stream::StreamExt; - Box::pin(futures::stream::iter(self.buf).map(|x| Ok(x))) + Box::pin(futures::stream::iter(self.buf).map(Ok)) } } @@ -161,7 +161,6 @@ mod test { #[test] fn test_bytes_buf() { let mut buf = BytesBuf::new(); - assert!(buf.len() == 0); assert!(buf.is_empty()); buf.extend(Bytes::from(b"Hello, world!".to_vec())); @@ -176,7 +175,6 @@ mod test { buf.take_all(), Bytes::from(b"Hello, world!1234567890".to_vec()) ); - assert!(buf.len() == 0); assert!(buf.is_empty()); buf.extend(Bytes::from(b"1234567890".to_vec())); @@ -193,7 +191,6 @@ mod test { buf.take_exact(11), Some(Bytes::from(b"llo, world!".to_vec())) ); - assert!(buf.len() == 0); assert!(buf.is_empty()); } } diff --git a/src/net/recv.rs b/src/net/recv.rs index 35a6d71a..1514b391 100644 --- a/src/net/recv.rs +++ b/src/net/recv.rs @@ -79,7 +79,7 @@ pub(crate) trait RecvLoop: Sync + 'static { if size == CANCEL_REQUEST { if let Some(mut stream) = streams.remove(&id) { - let _ = stream.send(Err(std::io::Error::new( + stream.send(Err(std::io::Error::new( std::io::ErrorKind::Other, "netapp: cancel requested", ))); @@ -135,7 +135,7 @@ pub(crate) trait RecvLoop: Sync + 'static { // If we cannot put packet in channel, it means that the // receiving end of the channel is disconnected. // We still need to reach eos before dropping this sender - let _ = sender.send(packet); + sender.send(packet); } if has_cont { diff --git a/src/rpc/layout/graph_algo.rs b/src/rpc/layout/graph_algo.rs index 29d4a043..3450b8a1 100644 --- a/src/rpc/layout/graph_algo.rs +++ b/src/rpc/layout/graph_algo.rs @@ -355,7 +355,7 @@ impl Graph { // Remark that the cycle in prev is in the reverse order compared to the cycle // in the graph. Thus the .rev(). - return cycles_prev + cycles_prev .iter() .map(|cycle| { cycle @@ -364,7 +364,7 @@ impl Graph { .map(|id| self.id_to_vertex[*id]) .collect() }) - .collect(); + .collect() } } diff --git a/src/rpc/layout/history.rs b/src/rpc/layout/history.rs index 79f4e3c0..b4659543 100644 --- a/src/rpc/layout/history.rs +++ b/src/rpc/layout/history.rs @@ -10,7 +10,7 @@ use crate::replication_mode::*; impl LayoutHistory { pub fn new(replication_factor: ReplicationFactor) -> Self { - let version = LayoutVersion::new(replication_factor.into()); + let version = LayoutVersion::new(replication_factor); let staging = LayoutStaging { parameters: Lww::::new(version.parameters), diff --git a/src/rpc/layout/test.rs b/src/rpc/layout/test.rs index ab191252..e6505d87 100644 --- a/src/rpc/layout/test.rs +++ b/src/rpc/layout/test.rs @@ -77,7 +77,7 @@ fn check_against_naive(cl: &LayoutVersion) -> Result { } } - return Ok(false); + Ok(false) } fn show_msg(msg: &Message) { diff --git a/src/util/background/mod.rs b/src/util/background/mod.rs index cae3a462..1fc70d19 100644 --- a/src/util/background/mod.rs +++ b/src/util/background/mod.rs @@ -68,7 +68,6 @@ impl BackgroundRunner { { self.send_worker .send(Box::new(worker)) - .ok() .expect("Could not put worker in queue"); } } diff --git a/src/util/data.rs b/src/util/data.rs index 1fe7dfe0..640e58c9 100644 --- a/src/util/data.rs +++ b/src/util/data.rs @@ -90,11 +90,11 @@ impl FixedBytes32 { if *byte == u8::MAX { *byte = 0; } else { - *byte = *byte + 1; + *byte += 1; return Some(ret); } } - return None; + None } } diff --git a/src/util/encode.rs b/src/util/encode.rs index c6815d49..3d989b7e 100644 --- a/src/util/encode.rs +++ b/src/util/encode.rs @@ -18,7 +18,7 @@ where /// data formats) pub fn nonversioned_decode(bytes: &[u8]) -> Result where - T: for<'de> Deserialize<'de> + ?Sized, + T: for<'de> Deserialize<'de>, { rmp_serde::decode::from_slice::<_>(bytes) } diff --git a/src/web/web_server.rs b/src/web/web_server.rs index 46ef40f3..5c2418d9 100644 --- a/src/web/web_server.rs +++ b/src/web/web_server.rs @@ -155,8 +155,8 @@ impl WebServer { .span_builder(format!("Web {} request", req.method())) .with_trace_id(gen_trace_id()) .with_attributes(vec![ - KeyValue::new("host", format!("{}", host_header.clone())), - KeyValue::new("method", format!("{}", req.method())), + KeyValue::new("host", host_header.clone()), + KeyValue::new("method", req.method().to_string()), KeyValue::new("uri", req.uri().to_string()), ]) .start(&tracer);