Skip to content

Commit 3904304

Browse files
author
Joonas Koivunen
authored
Merge pull request #730 from omertoast/clippy_154_changes
Clippy warnings in 1.54
2 parents 629f8b5 + c0f0374 commit 3904304

File tree

25 files changed

+108
-116
lines changed

25 files changed

+108
-116
lines changed

crates/ilp-cli/src/interpreter.rs

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,22 @@ use url::Url;
1212
pub enum Error {
1313
// Custom errors
1414
#[error("Usage error")]
15-
UsageErr(&'static str),
15+
Usage(&'static str),
1616
#[error("Invalid protocol in URL: {0}")]
17-
ProtocolErr(String),
17+
Protocol(String),
1818
// Foreign errors
1919
#[error("Error sending HTTP request: {0}")]
20-
SendErr(#[from] reqwest::Error),
20+
Send(#[from] reqwest::Error),
2121
#[error("Error receving HTTP response from testnet: {0}")]
22-
TestnetErr(reqwest::Error),
22+
Testnet(reqwest::Error),
2323
#[error("Error altering URL scheme")]
24-
SchemeErr(()), // TODO: should be part of UrlError, see https://github.com/servo/rust-url/issues/299
24+
Scheme(()), // TODO: should be part of UrlError, see https://github.com/servo/rust-url/issues/299
2525
#[error("Error parsing URL: {0}")]
26-
UrlErr(#[from] url::ParseError),
26+
Url(#[from] url::ParseError),
2727
#[error("WebSocket error: {0}")]
28-
WebsocketErr(#[from] tungstenite::error::Error),
28+
Websocket(#[from] tungstenite::error::Error),
2929
#[error("HTTP error: {0}")]
30-
HttpErr(#[from] http::Error),
30+
Http(#[from] http::Error),
3131
}
3232

3333
pub fn run(matches: &ArgMatches) -> Result<Response, Error> {
@@ -49,35 +49,35 @@ pub fn run(matches: &ArgMatches) -> Result<Response, Error> {
4949
("list", Some(submatches)) => client.get_accounts(submatches),
5050
("update", Some(submatches)) => client.put_account(submatches),
5151
("update-settings", Some(submatches)) => client.put_account_settings(submatches),
52-
_ => Err(Error::UsageErr("ilp-cli help accounts")),
52+
_ => Err(Error::Usage("ilp-cli help accounts")),
5353
},
5454
("pay", Some(pay_matches)) => client.post_account_payments(pay_matches),
5555
("rates", Some(rates_matches)) => match rates_matches.subcommand() {
5656
("list", Some(submatches)) => client.get_rates(submatches),
5757
("set-all", Some(submatches)) => client.put_rates(submatches),
58-
_ => Err(Error::UsageErr("ilp-cli help rates")),
58+
_ => Err(Error::Usage("ilp-cli help rates")),
5959
},
6060
("routes", Some(routes_matches)) => match routes_matches.subcommand() {
6161
("list", Some(submatches)) => client.get_routes(submatches),
6262
("set", Some(submatches)) => client.put_route_static(submatches),
6363
("set-all", Some(submatches)) => client.put_routes_static(submatches),
64-
_ => Err(Error::UsageErr("ilp-cli help routes")),
64+
_ => Err(Error::Usage("ilp-cli help routes")),
6565
},
6666
("settlement-engines", Some(settlement_matches)) => match settlement_matches.subcommand() {
6767
("set-all", Some(submatches)) => client.put_settlement_engines(submatches),
68-
_ => Err(Error::UsageErr("ilp-cli help settlement-engines")),
68+
_ => Err(Error::Usage("ilp-cli help settlement-engines")),
6969
},
7070
("status", Some(status_matches)) => client.get_root(status_matches),
7171
("logs", Some(log_level)) => client.put_tracing_level(log_level),
7272
("testnet", Some(testnet_matches)) => match testnet_matches.subcommand() {
7373
("setup", Some(submatches)) => client.xpring_account(submatches),
74-
_ => Err(Error::UsageErr("ilp-cli help testnet")),
74+
_ => Err(Error::Usage("ilp-cli help testnet")),
7575
},
7676
("payments", Some(payments_matches)) => match payments_matches.subcommand() {
7777
("incoming", Some(submatches)) => client.ws_payments_incoming(submatches),
78-
_ => Err(Error::UsageErr("ilp-cli help payments")),
78+
_ => Err(Error::Usage("ilp-cli help payments")),
7979
},
80-
_ => Err(Error::UsageErr("ilp-cli help")),
80+
_ => Err(Error::Usage("ilp-cli help")),
8181
}
8282
}
8383

@@ -95,7 +95,7 @@ impl NodeClient<'_> {
9595
.get(&format!("{}/accounts/{}/balance", self.url, user))
9696
.bearer_auth(auth)
9797
.send()
98-
.map_err(Error::SendErr)
98+
.map_err(Error::Send)
9999
}
100100

101101
// POST /accounts
@@ -106,7 +106,7 @@ impl NodeClient<'_> {
106106
.bearer_auth(auth)
107107
.json(&args)
108108
.send()
109-
.map_err(Error::SendErr)
109+
.map_err(Error::Send)
110110
}
111111

112112
// PUT /accounts/:username
@@ -117,7 +117,7 @@ impl NodeClient<'_> {
117117
.bearer_auth(auth)
118118
.json(&args)
119119
.send()
120-
.map_err(Error::SendErr)
120+
.map_err(Error::Send)
121121
}
122122

123123
// DELETE /accounts/:username
@@ -127,7 +127,7 @@ impl NodeClient<'_> {
127127
.delete(&format!("{}/accounts/{}", self.url, args["username"]))
128128
.bearer_auth(auth)
129129
.send()
130-
.map_err(Error::SendErr)
130+
.map_err(Error::Send)
131131
}
132132

133133
// WebSocket /accounts/:username/payments/incoming
@@ -141,13 +141,13 @@ impl NodeClient<'_> {
141141
let scheme = match url.scheme() {
142142
"http" => Ok("ws"),
143143
"https" => Ok("wss"),
144-
s => Err(Error::ProtocolErr(format!(
144+
s => Err(Error::Protocol(format!(
145145
"{} (only HTTP and HTTPS are supported)",
146146
s
147147
))),
148148
}?;
149149

150-
url.set_scheme(scheme).map_err(Error::SchemeErr)?;
150+
url.set_scheme(scheme).map_err(Error::Scheme)?;
151151

152152
let request: Request = Request::builder()
153153
.uri(url.into_string())
@@ -169,13 +169,13 @@ impl NodeClient<'_> {
169169
let scheme = match url.scheme() {
170170
"http" => Ok("ws"),
171171
"https" => Ok("wss"),
172-
s => Err(Error::ProtocolErr(format!(
172+
s => Err(Error::Protocol(format!(
173173
"{} (only HTTP and HTTPS are supported)",
174174
s
175175
))),
176176
}?;
177177

178-
url.set_scheme(scheme).map_err(Error::SchemeErr)?;
178+
url.set_scheme(scheme).map_err(Error::Scheme)?;
179179

180180
let request: Request = Request::builder()
181181
.uri(url.into_string())
@@ -196,7 +196,7 @@ impl NodeClient<'_> {
196196
.get(&format!("{}/accounts/{}", self.url, args["username"]))
197197
.bearer_auth(auth)
198198
.send()
199-
.map_err(Error::SendErr)
199+
.map_err(Error::Send)
200200
}
201201

202202
// GET /accounts
@@ -206,7 +206,7 @@ impl NodeClient<'_> {
206206
.get(&format!("{}/accounts", self.url))
207207
.bearer_auth(auth)
208208
.send()
209-
.map_err(Error::SendErr)
209+
.map_err(Error::Send)
210210
}
211211

212212
// PUT /accounts/:username/settings
@@ -218,7 +218,7 @@ impl NodeClient<'_> {
218218
.bearer_auth(auth)
219219
.json(&args)
220220
.send()
221-
.map_err(Error::SendErr)
221+
.map_err(Error::Send)
222222
}
223223

224224
// POST /accounts/:username/payments
@@ -230,15 +230,15 @@ impl NodeClient<'_> {
230230
.bearer_auth(auth)
231231
.json(&args)
232232
.send()
233-
.map_err(Error::SendErr)
233+
.map_err(Error::Send)
234234
}
235235

236236
// GET /rates
237237
fn get_rates(&self, _matches: &ArgMatches) -> Result<Response, Error> {
238238
self.client
239239
.get(&format!("{}/rates", self.url))
240240
.send()
241-
.map_err(Error::SendErr)
241+
.map_err(Error::Send)
242242
}
243243

244244
// PUT /rates
@@ -249,15 +249,15 @@ impl NodeClient<'_> {
249249
.bearer_auth(auth)
250250
.json(&rate_pairs)
251251
.send()
252-
.map_err(Error::SendErr)
252+
.map_err(Error::Send)
253253
}
254254

255255
// GET /routes
256256
fn get_routes(&self, _matches: &ArgMatches) -> Result<Response, Error> {
257257
self.client
258258
.get(&format!("{}/routes", self.url))
259259
.send()
260-
.map_err(Error::SendErr)
260+
.map_err(Error::Send)
261261
}
262262

263263
// PUT /routes/static/:prefix
@@ -268,7 +268,7 @@ impl NodeClient<'_> {
268268
.bearer_auth(auth)
269269
.body(args["destination"].to_string())
270270
.send()
271-
.map_err(Error::SendErr)
271+
.map_err(Error::Send)
272272
}
273273

274274
// PUT routes/static
@@ -279,7 +279,7 @@ impl NodeClient<'_> {
279279
.bearer_auth(auth)
280280
.json(&route_pairs)
281281
.send()
282-
.map_err(Error::SendErr)
282+
.map_err(Error::Send)
283283
}
284284

285285
// PUT /settlement/engines
@@ -290,7 +290,7 @@ impl NodeClient<'_> {
290290
.bearer_auth(auth)
291291
.json(&engine_pairs)
292292
.send()
293-
.map_err(Error::SendErr)
293+
.map_err(Error::Send)
294294
}
295295

296296
// PUT /tracing-level
@@ -301,15 +301,15 @@ impl NodeClient<'_> {
301301
.bearer_auth(auth)
302302
.body(args["level"].to_owned())
303303
.send()
304-
.map_err(Error::SendErr)
304+
.map_err(Error::Send)
305305
}
306306

307307
// GET /
308308
fn get_root(&self, _matches: &ArgMatches) -> Result<Response, Error> {
309309
self.client
310310
.get(&format!("{}/", self.url))
311311
.send()
312-
.map_err(Error::SendErr)
312+
.map_err(Error::Send)
313313
}
314314

315315
/*
@@ -332,7 +332,7 @@ impl NodeClient<'_> {
332332
.get(&format!("https://xpring.io/api/accounts/{}", asset))
333333
.send()?
334334
.json()
335-
.map_err(Error::TestnetErr)?;
335+
.map_err(Error::Testnet)?;
336336
let mut args = HashMap::new();
337337
let token = format!("{}:{}", foreign_args.username, foreign_args.passkey);
338338
args.insert("ilp_over_http_url", foreign_args.http_endpoint);
@@ -360,7 +360,7 @@ impl NodeClient<'_> {
360360
http::Response::builder().body(token).unwrap(), // infallible unwrap
361361
))
362362
} else {
363-
result.map_err(Error::SendErr)
363+
result.map_err(Error::Send)
364364
}
365365
}
366366
}

crates/ilp-cli/src/main.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub fn main() {
1414

1515
// 4. Handle interpreter output
1616
match result {
17-
Err(interpreter::Error::UsageErr(s)) => {
17+
Err(interpreter::Error::Usage(s)) => {
1818
// Clap doesn't seem to have a built-in way of manually printing the
1919
// help text for an arbitrary subcommand, but this works just the same.
2020
app.get_matches_from(s.split(' '));
@@ -217,9 +217,9 @@ mod interface_tests {
217217
Ok(matches) => match run(&matches) {
218218
// Because these are interface tests, not integration tests, network errors are expected
219219
Ok(_)
220-
| Err(Error::SendErr(_))
221-
| Err(Error::WebsocketErr(_))
222-
| Err(Error::TestnetErr(_)) => (),
220+
| Err(Error::Send(_))
221+
| Err(Error::Websocket(_))
222+
| Err(Error::Testnet(_)) => (),
223223
Err(e) => panic!("Unexpected interpreter failure: {}", e),
224224
},
225225
}

crates/ilp-node/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ fn set_app_env(env_config: &Config, app: &mut App<'_, '_>, path: &[String], dept
376376
if depth == 1 {
377377
for item in &mut app.p.opts {
378378
if let Ok(value) = env_config.get_str(&item.b.name.to_lowercase()) {
379-
item.v.env = Some((&OsStr::new(item.b.name), Some(OsString::from(value))));
379+
item.v.env = Some((OsStr::new(item.b.name), Some(OsString::from(value))));
380380
}
381381
}
382382
return;

crates/ilp-node/src/node.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ impl InterledgerNode {
375375
}
376376
Err(RejectBuilder {
377377
code: ErrorCode::F02_UNREACHABLE,
378-
message: &format!(
378+
message: format!(
379379
// TODO we might not want to expose the internal account ID in the error
380380
"No outgoing route for account: {} (ILP address of the Prepare packet: {})",
381381
request.to.id(),

crates/interledger-api/src/routes/accounts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ where
415415
let server_secret_clone = server_secret.clone();
416416
async move {
417417
if let Some(ref username) = default_spsp_account {
418-
let id = store.get_account_id_from_username(&username).await?;
418+
let id = store.get_account_id_from_username(username).await?;
419419

420420
// TODO this shouldn't take multiple store calls
421421
let mut accounts = store.get_accounts(vec![id]).await?;

crates/interledger-api/src/routes/node_settings.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ where
133133
// Convert the usernames to account IDs to set the routes in the store
134134
let mut usernames: Vec<Username> = Vec::new();
135135
for username in routes.values() {
136-
let user = match Username::from_str(&username) {
136+
let user = match Username::from_str(username) {
137137
Ok(u) => u,
138138
Err(_) => return Err(Rejection::from(ApiError::bad_request())),
139139
};

crates/interledger-btp/src/packet.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ mod tests {
568568
#[test]
569569
fn from_bytes() {
570570
assert_eq!(
571-
BtpMessage::from_bytes(&MESSAGE_1_SERIALIZED).unwrap(),
571+
BtpMessage::from_bytes(MESSAGE_1_SERIALIZED).unwrap(),
572572
*MESSAGE_1
573573
);
574574
}
@@ -597,7 +597,7 @@ mod tests {
597597
#[test]
598598
fn from_bytes() {
599599
assert_eq!(
600-
BtpResponse::from_bytes(&RESPONSE_1_SERIALIZED).unwrap(),
600+
BtpResponse::from_bytes(RESPONSE_1_SERIALIZED).unwrap(),
601601
*RESPONSE_1
602602
);
603603
}
@@ -625,7 +625,7 @@ mod tests {
625625

626626
#[test]
627627
fn from_bytes() {
628-
assert_eq!(BtpError::from_bytes(&ERROR_1_SERIALIZED).unwrap(), *ERROR_1);
628+
assert_eq!(BtpError::from_bytes(ERROR_1_SERIALIZED).unwrap(), *ERROR_1);
629629
}
630630

631631
#[test]

crates/interledger-btp/src/server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ where
113113
let (auth, mut connection) = get_auth(Box::pin(connection)).await?;
114114
debug!("Got BTP connection for username: {}", username);
115115
let account = store
116-
.get_account_from_btp_auth(&username, &auth.token.expose_secret())
116+
.get_account_from_btp_auth(&username, auth.token.expose_secret())
117117
.map_err(move |_| warn!("BTP connection does not correspond to an account"))
118118
.await?;
119119

crates/interledger-ccp/src/server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ where
439439
warn!("Error handling incoming Route Update request, sending a Route Control request to get updated routing table info from peer. Error was: {}", &message);
440440
let reject = RejectBuilder {
441441
code: ErrorCode::F00_BAD_REQUEST,
442-
message: &message.as_bytes(),
442+
message: message.as_bytes(),
443443
data: &[],
444444
triggered_by: Some(&self.ilp_address.read()),
445445
}

crates/interledger-http/src/server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ where
4343
}
4444
Ok(store
4545
.get_account_from_http_auth(
46-
&path_username,
46+
path_username,
4747
&password.expose_secret()[BEARER_TOKEN_START..],
4848
)
4949
.await?)

0 commit comments

Comments
 (0)