Fix rustc 1.60 clippy warnings

This commit is contained in:
Kirill Bulatov
2022-04-09 01:19:45 +03:00
committed by Kirill Bulatov
parent 4f172e7612
commit dc7e3ff05a
10 changed files with 20 additions and 33 deletions

View File

@@ -68,10 +68,7 @@ fn get_config(request: &Request<Body>) -> &'static PageServerConf {
// healthcheck handler
async fn status_handler(request: Request<Body>) -> Result<Response<Body>, ApiError> {
let config = get_config(&request);
Ok(json_response(
StatusCode::OK,
StatusResponse { id: config.id },
)?)
json_response(StatusCode::OK, StatusResponse { id: config.id })
}
async fn timeline_create_handler(mut request: Request<Body>) -> Result<Response<Body>, ApiError> {
@@ -131,7 +128,7 @@ async fn timeline_list_handler(request: Request<Body>) -> Result<Response<Body>,
})
}
Ok(json_response(StatusCode::OK, response_data)?)
json_response(StatusCode::OK, response_data)
}
// Gate non incremental logical size calculation behind a flag
@@ -207,7 +204,7 @@ async fn timeline_detail_handler(request: Request<Body>) -> Result<Response<Body
remote: remote_timeline_info,
};
Ok(json_response(StatusCode::OK, timeline_info)?)
json_response(StatusCode::OK, timeline_info)
}
async fn timeline_attach_handler(request: Request<Body>) -> Result<Response<Body>, ApiError> {
@@ -247,7 +244,7 @@ async fn timeline_attach_handler(request: Request<Body>) -> Result<Response<Body
index_entry.set_awaits_download(true);
schedule_timeline_download(tenant_id, timeline_id);
Ok(json_response(StatusCode::ACCEPTED, ())?)
json_response(StatusCode::ACCEPTED, ())
}
async fn timeline_detach_handler(request: Request<Body>) -> Result<Response<Body>, ApiError> {
@@ -266,7 +263,7 @@ async fn timeline_detach_handler(request: Request<Body>) -> Result<Response<Body
.await
.map_err(ApiError::from_err)??;
Ok(json_response(StatusCode::OK, ())?)
json_response(StatusCode::OK, ())
}
async fn tenant_list_handler(request: Request<Body>) -> Result<Response<Body>, ApiError> {
@@ -280,7 +277,7 @@ async fn tenant_list_handler(request: Request<Body>) -> Result<Response<Body>, A
.await
.map_err(ApiError::from_err)??;
Ok(json_response(StatusCode::OK, response_data)?)
json_response(StatusCode::OK, response_data)
}
async fn tenant_create_handler(mut request: Request<Body>) -> Result<Response<Body>, ApiError> {

View File

@@ -1474,8 +1474,7 @@ impl LayeredTimeline {
//
// TODO: This perhaps should be done in 'flush_frozen_layers', after flushing
// *all* the layers, to avoid fsyncing the file multiple times.
let disk_consistent_lsn;
disk_consistent_lsn = Lsn(frozen_layer.get_lsn_range().end.0 - 1);
let disk_consistent_lsn = Lsn(frozen_layer.get_lsn_range().end.0 - 1);
// If we were able to advance 'disk_consistent_lsn', save it the metadata file.
// After crash, we will restart WAL streaming and processing from that point.

View File

@@ -25,9 +25,7 @@ impl PartialOrd for DeltaFileName {
impl Ord for DeltaFileName {
fn cmp(&self, other: &Self) -> Ordering {
let mut cmp;
cmp = self.key_range.start.cmp(&other.key_range.start);
let mut cmp = self.key_range.start.cmp(&other.key_range.start);
if cmp != Ordering::Equal {
return cmp;
}
@@ -117,9 +115,7 @@ impl PartialOrd for ImageFileName {
impl Ord for ImageFileName {
fn cmp(&self, other: &Self) -> Ordering {
let mut cmp;
cmp = self.key_range.start.cmp(&other.key_range.start);
let mut cmp = self.key_range.start.cmp(&other.key_range.start);
if cmp != Ordering::Equal {
return cmp;
}

View File

@@ -296,9 +296,7 @@ impl LayerMap {
key_range: &Range<Key>,
lsn: Lsn,
) -> Result<Vec<(Range<Key>, Option<Arc<dyn Layer>>)>> {
let mut points: Vec<Key>;
points = vec![key_range.start];
let mut points = vec![key_range.start];
for l in self.historic_layers.iter() {
if l.get_lsn_range().start > lsn {
continue;

View File

@@ -39,9 +39,7 @@ impl PartialOrd for RelTag {
impl Ord for RelTag {
fn cmp(&self, other: &Self) -> Ordering {
let mut cmp;
cmp = self.spcnode.cmp(&other.spcnode);
let mut cmp = self.spcnode.cmp(&other.spcnode);
if cmp != Ordering::Equal {
return cmp;
}

View File

@@ -58,7 +58,7 @@ impl LocalFs {
&self,
file_path: &Path,
) -> anyhow::Result<Option<StorageMetadata>> {
let metadata_path = storage_metadata_path(&file_path);
let metadata_path = storage_metadata_path(file_path);
if metadata_path.exists() && metadata_path.is_file() {
let metadata_string = fs::read_to_string(&metadata_path).await.with_context(|| {
format!(

View File

@@ -201,8 +201,7 @@ pub async fn read_archive_header<A: io::AsyncRead + Send + Sync + Unpin>(
.await
.context("Failed to decompress a header from the archive")?;
Ok(ArchiveHeader::des(&header_bytes)
.context("Failed to deserialize a header from the archive")?)
ArchiveHeader::des(&header_bytes).context("Failed to deserialize a header from the archive")
}
/// Reads the archive metadata out of the archive name:

View File

@@ -225,8 +225,8 @@ async fn read_local_metadata(
let local_metadata_bytes = fs::read(&local_metadata_path)
.await
.context("Failed to read local metadata file bytes")?;
Ok(TimelineMetadata::from_bytes(&local_metadata_bytes)
.context("Failed to read local metadata files bytes")?)
TimelineMetadata::from_bytes(&local_metadata_bytes)
.context("Failed to read local metadata files bytes")
}
#[cfg(test)]

View File

@@ -31,7 +31,7 @@ struct SafekeeperStatus {
async fn status_handler(request: Request<Body>) -> Result<Response<Body>, ApiError> {
let conf = get_conf(&request);
let status = SafekeeperStatus { id: conf.my_id };
Ok(json_response(StatusCode::OK, status)?)
json_response(StatusCode::OK, status)
}
fn get_conf(request: &Request<Body>) -> &SafeKeeperConf {
@@ -106,7 +106,7 @@ async fn timeline_status_handler(request: Request<Body>) -> Result<Response<Body
remote_consistent_lsn: inmem.remote_consistent_lsn,
flush_lsn,
};
Ok(json_response(StatusCode::OK, status)?)
json_response(StatusCode::OK, status)
}
async fn timeline_create_handler(mut request: Request<Body>) -> Result<Response<Body>, ApiError> {
@@ -119,7 +119,7 @@ async fn timeline_create_handler(mut request: Request<Body>) -> Result<Response<
GlobalTimelines::create(get_conf(&request), zttid, request_data.peer_ids)
.map_err(ApiError::from_err)?;
Ok(json_response(StatusCode::CREATED, ())?)
json_response(StatusCode::CREATED, ())
}
/// Safekeeper http router.

View File

@@ -10,8 +10,8 @@ pub async fn json_request<T: for<'de> Deserialize<'de>>(
let whole_body = hyper::body::aggregate(request.body_mut())
.await
.map_err(ApiError::from_err)?;
Ok(serde_json::from_reader(whole_body.reader())
.map_err(|err| ApiError::BadRequest(format!("Failed to parse json request {}", err)))?)
serde_json::from_reader(whole_body.reader())
.map_err(|err| ApiError::BadRequest(format!("Failed to parse json request {}", err)))
}
pub fn json_response<T: Serialize>(