Skip to content

Commit f7d9742

Browse files
committed
Fix clippy lints
Updates to log and anyhow, among others, allow clippy to "see" additional places where `"..{varname}.."` can be used instead of `"..{}.."`.
1 parent e35105e commit f7d9742

File tree

6 files changed

+19
-28
lines changed

6 files changed

+19
-28
lines changed

src/replica.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ impl<S: Storage> Replica<S> {
296296
task.update("status", Some(status.to_taskmap().to_string()), &mut ops);
297297
task.update("entry", Some(now), &mut ops);
298298
self.commit_operations(ops).await?;
299-
trace!("task {} created", uuid);
299+
trace!("task {uuid} created");
300300
Ok(self
301301
.get_task(uuid)
302302
.await?
@@ -344,7 +344,7 @@ impl<S: Storage> Replica<S> {
344344
let mut ops = self.make_operations();
345345
task.delete(&mut ops);
346346
self.commit_operations(ops).await?;
347-
trace!("task {} deleted", uuid);
347+
trace!("task {uuid} deleted");
348348
Ok(())
349349
}
350350

src/server/sync/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ fn get_uuid_header(resp: &reqwest::Response, name: &str) -> Result<Uuid> {
7171
let value = resp
7272
.headers()
7373
.get(name)
74-
.ok_or_else(|| anyhow::anyhow!("Response does not have {} header", name))?
74+
.ok_or_else(|| anyhow::anyhow!("Response does not have {name} header"))?
7575
.to_str()
76-
.map_err(|_| anyhow::anyhow!("Response has invalid {} header", name))?;
76+
.map_err(|_| anyhow::anyhow!("Response has invalid {name} header"))?;
7777
let value = Uuid::parse_str(value)
78-
.map_err(|e| anyhow::anyhow!("{} header is not a valid UUID: {}", name, e))?;
78+
.map_err(|e| anyhow::anyhow!("{name} header is not a valid UUID: {e}"))?;
7979
Ok(value)
8080
}
8181

src/task/tag.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl FromStr for Tag {
4848

4949
fn from_str(value: &str) -> Result<Tag, anyhow::Error> {
5050
fn err(value: &str) -> Result<Tag, anyhow::Error> {
51-
anyhow::bail!("invalid tag {:?}", value)
51+
anyhow::bail!("invalid tag {value:?}")
5252
}
5353

5454
// first, look for synthetic tags

src/task/task.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ mod test {
796796
.drain(..)
797797
.collect(),
798798
);
799-
trace!("{:?}", taskdata);
799+
trace!("{taskdata:?}");
800800
let task = Task::new(taskdata, dm());
801801

802802
// only "ok" is OK

src/taskdb/sync.rs

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub(super) async fn sync(
2323
trace!("storage is empty; attempting to apply a snapshot");
2424
if let Some((version, snap)) = server.get_snapshot().await? {
2525
snapshot::apply_snapshot(txn, version, snap.as_ref()).await?;
26-
trace!("applied snapshot for version {}", version);
26+
trace!("applied snapshot for version {version}");
2727
}
2828
}
2929

@@ -74,7 +74,7 @@ pub(super) async fn sync(
7474
let version: Version = serde_json::from_str(version_str).unwrap();
7575

7676
// apply this version and update base_version in storage
77-
info!("applying version {:?} from server", version_id);
77+
info!("applying version {version_id:?} from server");
7878
apply_version(
7979
txn,
8080
&mut sync_ops_batch,
@@ -85,7 +85,7 @@ pub(super) async fn sync(
8585
txn.set_base_version(version_id).await?;
8686
base_version_id = version_id;
8787
} else {
88-
info!("no child versions of {:?}", base_version_id);
88+
info!("no child versions of {base_version_id:?}");
8989
// at the moment, no more child versions, so we can try adding our own
9090
break;
9191
}
@@ -109,7 +109,7 @@ pub(super) async fn sync(
109109
server.add_version(base_version_id, history_segment).await?;
110110
match res {
111111
AddVersionResult::Ok(new_version_id) => {
112-
info!("version {:?} received by server", new_version_id);
112+
info!("version {new_version_id:?} received by server");
113113
txn.set_base_version(new_version_id).await?;
114114
base_version_id = new_version_id;
115115

@@ -125,10 +125,7 @@ pub(super) async fn sync(
125125
}
126126
}
127127
AddVersionResult::ExpectedParentVersion(parent_version_id) => {
128-
info!(
129-
"new version rejected; must be based on {:?}",
130-
parent_version_id
131-
);
128+
info!("new version rejected; must be based on {parent_version_id:?}");
132129
if let Some(requested) = requested_parent_version_id {
133130
if parent_version_id == requested {
134131
return Err(Error::OutOfSync);
@@ -185,31 +182,25 @@ async fn apply_version(
185182
// indicating no operation is required. If this happens for a local op, we can just omit
186183
// it. If it happens for server op, then we must copy the remaining local ops.
187184
for server_op in version.operations.drain(..) {
188-
trace!(
189-
"rebasing local operations onto server operation {:?}",
190-
server_op
191-
);
185+
trace!("rebasing local operations onto server operation {server_op:?}");
192186
let mut new_local_ops = Vec::with_capacity(local_ops.len());
193187
let mut svr_op = Some(server_op);
194188
for local_op in local_ops.drain(..) {
195189
if let Some(o) = svr_op {
196190
let (new_server_op, new_local_op) = SyncOp::transform(o, local_op.clone());
197-
trace!("local operation {:?} -> {:?}", local_op, new_local_op);
191+
trace!("local operation {local_op:?} -> {new_local_op:?}");
198192
svr_op = new_server_op;
199193
if let Some(o) = new_local_op {
200194
new_local_ops.push(o);
201195
}
202196
} else {
203-
trace!(
204-
"local operation {:?} unchanged (server operation consumed)",
205-
local_op
206-
);
197+
trace!("local operation {local_op:?} unchanged (server operation consumed)");
207198
new_local_ops.push(local_op);
208199
}
209200
}
210201
if let Some(o) = svr_op {
211202
if let Err(e) = apply::apply_op(txn, &o).await {
212-
warn!("Invalid operation when syncing: {} (ignored)", e);
203+
warn!("Invalid operation when syncing: {e} (ignored)");
213204
}
214205
transformed_server_ops.push(o);
215206
}

src/taskdb/undo.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,16 @@ pub(crate) async fn commit_reversed_operations(
9292
}
9393
if !ok {
9494
info!("Undo failed: concurrent changes to the database occurred.");
95-
debug!("local_ops={:#?}\nundo_ops={:#?}", local_ops, undo_ops);
95+
debug!("local_ops={local_ops:#?}\nundo_ops={undo_ops:#?}");
9696
return Ok(applied);
9797
}
9898

9999
undo_ops.reverse();
100100
for op in undo_ops {
101-
debug!("Reversing operation {:?}", op);
101+
debug!("Reversing operation {op:?}");
102102
let rev_ops = reverse_ops(op.clone());
103103
for op in rev_ops {
104-
trace!("Applying reversed operation {:?}", op);
104+
trace!("Applying reversed operation {op:?}");
105105
apply::apply_op(txn, &op).await?;
106106
applied = true;
107107
}

0 commit comments

Comments
 (0)