Inline all format arguments where possible

This makes code more readale and concise,
moving all format arguments like `format!("{}", foo)`
into the more compact `format!("{foo}")` form.

The change was automatically created with, so there are far less change
of an accidental typo.

```
cargo clippy --fix -- -A clippy::all -W clippy::uninlined_format_args
```
This commit is contained in:
Yuri Astrakhan 2022-12-23 13:42:58 -05:00
parent 1927c2e1d8
commit e16c76e3c3
180 changed files with 487 additions and 501 deletions

View file

@ -80,32 +80,32 @@ fn main_loop(
let _params: InitializeParams = serde_json::from_value(params).unwrap();
eprintln!("starting example main loop");
for msg in &connection.receiver {
eprintln!("got msg: {:?}", msg);
eprintln!("got msg: {msg:?}");
match msg {
Message::Request(req) => {
if connection.handle_shutdown(&req)? {
return Ok(());
}
eprintln!("got request: {:?}", req);
eprintln!("got request: {req:?}");
match cast::<GotoDefinition>(req) {
Ok((id, params)) => {
eprintln!("got gotoDefinition request #{}: {:?}", id, params);
eprintln!("got gotoDefinition request #{id}: {params:?}");
let result = Some(GotoDefinitionResponse::Array(Vec::new()));
let result = serde_json::to_value(&result).unwrap();
let resp = Response { id, result: Some(result), error: None };
connection.sender.send(Message::Response(resp))?;
continue;
}
Err(err @ ExtractError::JsonError { .. }) => panic!("{:?}", err),
Err(err @ ExtractError::JsonError { .. }) => panic!("{err:?}"),
Err(ExtractError::MethodMismatch(req)) => req,
};
// ...
}
Message::Response(resp) => {
eprintln!("got response: {:?}", resp);
eprintln!("got response: {resp:?}");
}
Message::Notification(not) => {
eprintln!("got notification: {:?}", not);
eprintln!("got notification: {not:?}");
}
}
}

View file

@ -123,7 +123,7 @@ impl Connection {
let resp = Response::new_err(
req.id.clone(),
ErrorCode::ServerNotInitialized as i32,
format!("expected initialize request, got {:?}", req),
format!("expected initialize request, got {req:?}"),
);
self.sender.send(resp.into()).unwrap();
}
@ -221,11 +221,9 @@ impl Connection {
match &self.receiver.recv_timeout(std::time::Duration::from_secs(30)) {
Ok(Message::Notification(n)) if n.is_exit() => (),
Ok(msg) => {
return Err(ProtocolError(format!("unexpected message during shutdown: {:?}", msg)))
}
Err(e) => {
return Err(ProtocolError(format!("unexpected error during shutdown: {}", e)))
return Err(ProtocolError(format!("unexpected message during shutdown: {msg:?}")))
}
Err(e) => return Err(ProtocolError(format!("unexpected error during shutdown: {e}"))),
}
Ok(true)
}