Skip to content

Commit c23e570

Browse files
authored
Update Rust to 1.88.0 (#792)
* Update Rust to `1.88.0` * Clippy fixes for `1.88.0` * make fmt-rust
1 parent 96c2c69 commit c23e570

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+176
-256
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
docker_container_repo_dir=/app
55

66
# Common docker options
7-
rust_docker_container := public.ecr.aws/docker/library/rust:1.87.0
7+
rust_docker_container := public.ecr.aws/docker/library/rust:1.88.0
88

99
docker_opts_shared := --rm -v "$(PWD)":$(docker_container_repo_dir) -w $(docker_container_repo_dir)
1010
rust_docker_run := docker run -v $(PWD):/$(docker_container_repo_dir) -w $(docker_container_repo_dir) -it -e TEST_ALL_PLUGINS -e CARGO_HOME=/app/.cargo $(rust_docker_container)

wp_api/src/auth.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,19 @@ impl WpAuthentication {
2020
pub fn from_username_and_password(username: String, password: String) -> Self {
2121
use base64::prelude::*;
2222
WpAuthentication::AuthorizationHeader {
23-
token: BASE64_STANDARD.encode(format!("{}:{}", username, password)),
23+
token: BASE64_STANDARD.encode(format!("{username}:{password}")),
2424
}
2525
}
2626

2727
pub fn header_value(&self) -> Option<HeaderValue> {
2828
match self {
2929
Self::None => None,
3030
Self::AuthorizationHeader { token } => {
31-
Some(HeaderValue::from_str(&format!("Basic {}", token))
31+
Some(HeaderValue::from_str(&format!("Basic {token}"))
3232
.expect("It shouldn't be possible to build WpAuthentication::AuthorizationHeader with an invalid token"))
3333
}
3434
Self::Bearer { token } => {
35-
Some(HeaderValue::from_str(&format!("Bearer {}", token)).expect("It shouldn't be possible to build WpAuthentication::Bearer with an invalid token"))
35+
Some(HeaderValue::from_str(&format!("Bearer {token}")).expect("It shouldn't be possible to build WpAuthentication::Bearer with an invalid token"))
3636
}
3737
}
3838
}

wp_api/src/categories.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ mod tests {
268268
.append_query_value_pair("orderby", &orderby);
269269
assert_eq!(
270270
url.query().map(|x| x.to_string()),
271-
Some(format!("orderby={}", expected))
271+
Some(format!("orderby={expected}"))
272272
);
273273
}
274274

wp_api/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ mod tests {
225225
.append_query_value_pair("orderby", &orderby);
226226
assert_eq!(
227227
url.query().map(|x| x.to_string()),
228-
Some(format!("orderby={}", expected))
228+
Some(format!("orderby={expected}"))
229229
);
230230
}
231231

wp_api/src/login.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,7 @@ mod tests {
356356
);
357357

358358
let expected_url = format!(
359-
"https://example.com/wp-login.php?app_name=AppName&app_id={}&success_url=https%3A%2F%2Fexample.com%2Fsuccess&reject_url=https%3A%2F%2Fexample.com%2Freject",
360-
app_id_str
359+
"https://example.com/wp-login.php?app_name=AppName&app_id={app_id_str}&success_url=https%3A%2F%2Fexample.com%2Fsuccess&reject_url=https%3A%2F%2Fexample.com%2Freject"
361360
);
362361
assert_eq!(auth_url, ParsedUrl::parse(expected_url.as_str()).unwrap());
363362
}
@@ -438,8 +437,7 @@ mod tests {
438437

439438
assert!(
440439
result.is_ok(),
441-
"Failed to parse json as `WpApiDetails`: {:#?}",
442-
result
440+
"Failed to parse json as `WpApiDetails`: {result:#?}"
443441
);
444442
}
445443

wp_api/src/login/login_client.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,8 +510,7 @@ mod tests {
510510
..
511511
})
512512
),
513-
"{:#?}",
514-
result
513+
"{result:#?}"
515514
);
516515
}
517516
}

wp_api/src/login/url_discovery.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl AutoDiscoveryAttempt {
5757
.or_else(|| input_url_as_string.strip_suffix("wp-login.php"))
5858
.unwrap_or(input_url_as_string.as_str());
5959
let url = if !processed_site_url.starts_with("http") {
60-
format!("https://{}", processed_site_url)
60+
format!("https://{processed_site_url}")
6161
} else if !processed_site_url.starts_with("https") {
6262
processed_site_url.replacen("http", "https", 1)
6363
} else {

wp_api/src/request.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,13 +217,13 @@ impl WpNetworkRequest {
217217

218218
pub fn adding_http_authentication(&self, username: &str, password: &str) -> Self {
219219
let encoded_credentials =
220-
base64::engine::general_purpose::STANDARD.encode(format!("{}:{}", username, password));
220+
base64::engine::general_purpose::STANDARD.encode(format!("{username}:{password}"));
221221

222222
let mut new_header_map = self.header_map.inner.clone();
223223

224224
new_header_map.insert(
225225
http::header::AUTHORIZATION,
226-
format!("Basic {}", encoded_credentials).parse().expect(
226+
format!("Basic {encoded_credentials}").parse().expect(
227227
"base64 can only produce ASCII, so this string is guaranteed to be parseable",
228228
),
229229
);
@@ -269,7 +269,7 @@ impl Debug for WpNetworkRequest {
269269
self.body_as_string()
270270
);
271271
s.pop(); // Remove the new line at the end
272-
write!(f, "{}", s)
272+
write!(f, "{s}")
273273
}
274274
}
275275

@@ -735,7 +735,7 @@ impl Debug for WpNetworkResponse {
735735
self.body_as_string()
736736
);
737737
s.pop(); // Remove the new line at the end
738-
write!(f, "{}", s)
738+
write!(f, "{s}")
739739
}
740740
}
741741

wp_api/src/request/endpoint/categories_endpoint.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,9 @@ mod tests {
9797
) {
9898
let expected_path = |context: &str| {
9999
if expected_additional_params.is_empty() {
100-
format!("/categories?context={}", context)
100+
format!("/categories?context={context}")
101101
} else {
102-
format!(
103-
"/categories?context={}&{}",
104-
context, expected_additional_params
105-
)
102+
format!("/categories?context={context}&{expected_additional_params}")
106103
}
107104
};
108105
validate_wp_v2_endpoint(
@@ -122,7 +119,7 @@ mod tests {
122119
#[rstest]
123120
#[case(CategoryListParams::default(), &[], "/categories?context=edit&_fields=")]
124121
#[case(generate!(CategoryListParams, (orderby, Some(WpApiParamCategoriesOrderBy::Id))), &[SparseCategoryFieldWithEditContext::Count], "/categories?context=edit&orderby=id&_fields=count")]
125-
#[case(category_list_params_with_all_fields(), ALL_SPARSE_CATEGORY_FIELDS_WITH_EDIT_CONTEXT, &format!("/categories?context=edit&{}&{}", EXPECTED_QUERY_PAIRS_FOR_CATEGORY_LIST_PARAMS_WITH_ALL_FIELDS, EXPECTED_QUERY_PAIRS_FOR_ALL_SPARSE_CATEGORY_FIELDS_WITH_EDIT_CONTEXT))]
122+
#[case(category_list_params_with_all_fields(), ALL_SPARSE_CATEGORY_FIELDS_WITH_EDIT_CONTEXT, &format!("/categories?context=edit&{EXPECTED_QUERY_PAIRS_FOR_CATEGORY_LIST_PARAMS_WITH_ALL_FIELDS}&{EXPECTED_QUERY_PAIRS_FOR_ALL_SPARSE_CATEGORY_FIELDS_WITH_EDIT_CONTEXT}"))]
126123
fn filter_list_categories_with_edit_context(
127124
endpoint: CategoriesRequestEndpoint,
128125
#[case] params: CategoryListParams,
@@ -138,7 +135,7 @@ mod tests {
138135
#[rstest]
139136
#[case(CategoryListParams::default(), &[], "/categories?context=embed&_fields=")]
140137
#[case(generate!(CategoryListParams, (orderby, Some(WpApiParamCategoriesOrderBy::Slug))), &[SparseCategoryFieldWithEmbedContext::Link], "/categories?context=embed&orderby=slug&_fields=link")]
141-
#[case(category_list_params_with_all_fields(), ALL_SPARSE_CATEGORY_FIELDS_WITH_EMBED_CONTEXT, &format!("/categories?context=embed&{}&{}", EXPECTED_QUERY_PAIRS_FOR_CATEGORY_LIST_PARAMS_WITH_ALL_FIELDS, EXPECTED_QUERY_PAIRS_FOR_ALL_SPARSE_CATEGORY_FIELDS_WITH_EMBED_CONTEXT))]
138+
#[case(category_list_params_with_all_fields(), ALL_SPARSE_CATEGORY_FIELDS_WITH_EMBED_CONTEXT, &format!("/categories?context=embed&{EXPECTED_QUERY_PAIRS_FOR_CATEGORY_LIST_PARAMS_WITH_ALL_FIELDS}&{EXPECTED_QUERY_PAIRS_FOR_ALL_SPARSE_CATEGORY_FIELDS_WITH_EMBED_CONTEXT}"))]
142139
fn filter_list_categories_with_embed_context(
143140
endpoint: CategoriesRequestEndpoint,
144141
#[case] params: CategoryListParams,
@@ -154,7 +151,7 @@ mod tests {
154151
#[rstest]
155152
#[case(CategoryListParams::default(), &[], "/categories?context=view&_fields=")]
156153
#[case(generate!(CategoryListParams, (orderby, Some(WpApiParamCategoriesOrderBy::Include))), &[SparseCategoryFieldWithViewContext::Description], "/categories?context=view&orderby=include&_fields=description")]
157-
#[case(category_list_params_with_all_fields(), ALL_SPARSE_CATEGORY_FIELDS_WITH_VIEW_CONTEXT, &format!("/categories?context=view&{}&{}", EXPECTED_QUERY_PAIRS_FOR_CATEGORY_LIST_PARAMS_WITH_ALL_FIELDS, EXPECTED_QUERY_PAIRS_FOR_ALL_SPARSE_CATEGORY_FIELDS_WITH_VIEW_CONTEXT))]
154+
#[case(category_list_params_with_all_fields(), ALL_SPARSE_CATEGORY_FIELDS_WITH_VIEW_CONTEXT, &format!("/categories?context=view&{EXPECTED_QUERY_PAIRS_FOR_CATEGORY_LIST_PARAMS_WITH_ALL_FIELDS}&{EXPECTED_QUERY_PAIRS_FOR_ALL_SPARSE_CATEGORY_FIELDS_WITH_VIEW_CONTEXT}"))]
158155
fn filter_list_categories_with_view_context(
159156
endpoint: CategoriesRequestEndpoint,
160157
#[case] params: CategoryListParams,
@@ -188,7 +185,7 @@ mod tests {
188185
#[rstest]
189186
fn retrieve_category(endpoint: CategoriesRequestEndpoint) {
190187
let category_id = CategoryId(54);
191-
let expected_path = |context: &str| format!("/categories/54?context={}", context);
188+
let expected_path = |context: &str| format!("/categories/54?context={context}");
192189
validate_wp_v2_endpoint(
193190
endpoint.retrieve_with_edit_context(&category_id),
194191
&expected_path("edit"),
@@ -206,7 +203,7 @@ mod tests {
206203
#[rstest]
207204
#[case(&[], "/categories/54?context=view&_fields=")]
208205
#[case(&[SparseCategoryFieldWithViewContext::Count], "/categories/54?context=view&_fields=count")]
209-
#[case(ALL_SPARSE_CATEGORY_FIELDS_WITH_VIEW_CONTEXT, &format!("/categories/54?context=view&{}", EXPECTED_QUERY_PAIRS_FOR_ALL_SPARSE_CATEGORY_FIELDS_WITH_VIEW_CONTEXT))]
206+
#[case(ALL_SPARSE_CATEGORY_FIELDS_WITH_VIEW_CONTEXT, &format!("/categories/54?context=view&{EXPECTED_QUERY_PAIRS_FOR_ALL_SPARSE_CATEGORY_FIELDS_WITH_VIEW_CONTEXT}"))]
210207
fn filter_retrieve_category_with_view_context(
211208
endpoint: CategoriesRequestEndpoint,
212209
#[case] fields: &[SparseCategoryFieldWithViewContext],

wp_api/src/request/endpoint/comments_endpoint.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,9 @@ mod tests {
131131
) {
132132
let expected_path = |context: &str| {
133133
if expected_additional_params.is_empty() {
134-
format!("/comments?context={}", context)
134+
format!("/comments?context={context}")
135135
} else {
136-
format!(
137-
"/comments?context={}&{}",
138-
context, expected_additional_params
139-
)
136+
format!("/comments?context={context}&{expected_additional_params}")
140137
}
141138
};
142139
validate_wp_v2_endpoint(
@@ -244,12 +241,9 @@ mod tests {
244241
let comment_id = CommentId(54);
245242
let expected_path = |context: &str| {
246243
if expected_additional_params.is_empty() {
247-
format!("/comments/54?context={}", context)
244+
format!("/comments/54?context={context}")
248245
} else {
249-
format!(
250-
"/comments/54?context={}&{}",
251-
context, expected_additional_params
252-
)
246+
format!("/comments/54?context={context}&{expected_additional_params}")
253247
}
254248
};
255249
let params = CommentRetrieveParams {
@@ -272,7 +266,7 @@ mod tests {
272266
#[rstest]
273267
#[case(None, &[], "/comments/54?context=view&_fields=")]
274268
#[case(Some("foo"), &[SparseCommentFieldWithViewContext::Author], "/comments/54?context=view&password=foo&_fields=author")]
275-
#[case(Some("foo"), ALL_SPARSE_COMMENT_FIELDS_WITH_VIEW_CONTEXT, &format!("/comments/54?context=view&password=foo&{}", EXPECTED_QUERY_PAIRS_FOR_ALL_SPARSE_COMMENT_FIELDS_WITH_VIEW_CONTEXT))]
269+
#[case(Some("foo"), ALL_SPARSE_COMMENT_FIELDS_WITH_VIEW_CONTEXT, &format!("/comments/54?context=view&password=foo&{EXPECTED_QUERY_PAIRS_FOR_ALL_SPARSE_COMMENT_FIELDS_WITH_VIEW_CONTEXT}"))]
276270
fn filter_retrieve_comment_with_view_context(
277271
endpoint: CommentsRequestEndpoint,
278272
#[case] password: Option<&str>,

0 commit comments

Comments
 (0)