Skip to content
This repository was archived by the owner on Sep 10, 2024. It is now read-only.

Commit df3ca5a

Browse files
committed
Upgrade clippy lints to 1.74.0 & fix warnings
1 parent 5b272df commit df3ca5a

File tree

13 files changed

+147
-114
lines changed

13 files changed

+147
-114
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@ jobs:
195195

196196
- name: Install toolchain
197197
run: |
198-
rustup toolchain install 1.73.0
199-
rustup default 1.73.0
198+
rustup toolchain install 1.74.0
199+
rustup default 1.74.0
200200
rustup component add clippy
201201
202202
- name: Setup OPA

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# The Debian version and version name must be in sync
99
ARG DEBIAN_VERSION=12
1010
ARG DEBIAN_VERSION_NAME=bookworm
11-
ARG RUSTC_VERSION=1.73.0
11+
ARG RUSTC_VERSION=1.74.0
1212
# XXX: Upgrade to 0.10.0 blocked by https://github.com/ziglang/zig/issues/10915#issuecomment-1354548110
1313
# XXX: Upgrade to 0.11.0 blocked by https://github.com/rust-cross/cargo-zigbuild/issues/162
1414
ARG ZIG_VERSION=0.9.1

crates/cli/src/commands/manage.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,10 @@ impl Options {
248248
.context("User not found")?;
249249

250250
let compat_sessions_ids: Vec<Uuid> = sqlx::query_scalar(
251-
r#"
251+
r"
252252
SELECT compat_session_id FROM compat_sessions
253253
WHERE user_id = $1 AND finished_at IS NULL
254-
"#,
254+
",
255255
)
256256
.bind(Uuid::from(user.id))
257257
.fetch_all(&mut **repo)
@@ -276,12 +276,12 @@ impl Options {
276276
}
277277

278278
let oauth2_sessions_ids: Vec<Uuid> = sqlx::query_scalar(
279-
r#"
279+
r"
280280
SELECT oauth2_sessions.oauth2_session_id
281281
FROM oauth2_sessions
282282
INNER JOIN user_sessions USING (user_session_id)
283283
WHERE user_sessions.user_id = $1 AND oauth2_sessions.finished_at IS NULL
284-
"#,
284+
",
285285
)
286286
.bind(Uuid::from(user.id))
287287
.fetch_all(&mut **repo)
@@ -313,10 +313,10 @@ impl Options {
313313
}
314314

315315
let user_sessions_ids: Vec<Uuid> = sqlx::query_scalar(
316-
r#"
316+
r"
317317
SELECT user_session_id FROM user_sessions
318318
WHERE user_id = $1 AND finished_at IS NULL
319-
"#,
319+
",
320320
)
321321
.bind(Uuid::from(user.id))
322322
.fetch_all(&mut **repo)

crates/config/src/sections/database.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,10 @@ mod tests {
173173
Jail::expect_with(|jail| {
174174
jail.create_file(
175175
"config.yaml",
176-
r#"
176+
r"
177177
database:
178178
uri: postgresql://user:password@host/database
179-
"#,
179+
",
180180
)?;
181181

182182
let config = DatabaseConfig::load_from_file("config.yaml")?;

crates/config/src/sections/matrix.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,11 @@ mod tests {
8585
Jail::expect_with(|jail| {
8686
jail.create_file(
8787
"config.yaml",
88-
r#"
88+
r"
8989
matrix:
9090
homeserver: matrix.org
9191
secret: test
92-
"#,
92+
",
9393
)?;
9494

9595
let config = MatrixConfig::load_from_file("config.yaml")?;

crates/config/src/sections/secrets.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ impl ConfigurationSection for SecretsConfig {
225225
kid: "abcdef".to_owned(),
226226
password: None,
227227
key: KeyOrFile::Key(
228-
indoc::indoc! {r#"
228+
indoc::indoc! {r"
229229
-----BEGIN PRIVATE KEY-----
230230
MIIBVQIBADANBgkqhkiG9w0BAQEFAASCAT8wggE7AgEAAkEAymS2RkeIZo7pUeEN
231231
QUGCG4GLJru5jzxomO9jiNr5D/oRcerhpQVc9aCpBfAAg4l4a1SmYdBzWqX0X5pU
@@ -236,21 +236,21 @@ impl ConfigurationSection for SecretsConfig {
236236
tPQniMnrBtiN2NxqFXHCev/8Gpc8gAECIBcaPcF59qVeRmYrfqzKBxFm7LmTwlAl
237237
Gh7BNzCeN+D6
238238
-----END PRIVATE KEY-----
239-
"#}
239+
"}
240240
.to_owned(),
241241
),
242242
};
243243
let ecdsa_key = KeyConfig {
244244
kid: "ghijkl".to_owned(),
245245
password: None,
246246
key: KeyOrFile::Key(
247-
indoc::indoc! {r#"
247+
indoc::indoc! {r"
248248
-----BEGIN PRIVATE KEY-----
249249
MIGEAgEAMBAGByqGSM49AgEGBSuBBAAKBG0wawIBAQQgqfn5mYO/5Qq/wOOiWgHA
250250
NaiDiepgUJ2GI5eq2V8D8nahRANCAARMK9aKUd/H28qaU+0qvS6bSJItzAge1VHn
251251
OhBAAUVci1RpmUA+KdCL5sw9nadAEiONeiGr+28RYHZmlB9qXnjC
252252
-----END PRIVATE KEY-----
253-
"#}
253+
"}
254254
.to_owned(),
255255
),
256256
};

crates/config/src/util.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ pub trait ConfigurationSection: Sized + DeserializeOwned + Serialize {
4646
/// export MAS_HTTP_ADDRESS=127.0.0.1:1234
4747
/// matrix-authentication-service config generate
4848
/// ```
49+
///
50+
/// # Errors
51+
///
52+
/// Returns an error if the configuration could not be generated or if the
53+
/// existing configuration could not be loaded
4954
async fn load_and_generate<R>(rng: R) -> anyhow::Result<Self>
5055
where
5156
R: Rng + Send,
@@ -62,6 +67,10 @@ pub trait ConfigurationSection: Sized + DeserializeOwned + Serialize {
6267
}
6368

6469
/// Load configuration from a list of files and environment variables.
70+
///
71+
/// # Errors
72+
///
73+
/// Returns an error if the configuration could not be loaded
6574
fn load_from_files<P>(paths: &[P]) -> Result<Self, FigmentError>
6675
where
6776
P: AsRef<Utf8Path>,
@@ -75,6 +84,10 @@ pub trait ConfigurationSection: Sized + DeserializeOwned + Serialize {
7584
}
7685

7786
/// Load configuration from a file and environment variables.
87+
///
88+
/// # Errors
89+
///
90+
/// Returns an error if the configuration could not be loaded
7891
fn load_from_file<P>(path: P) -> Result<Self, FigmentError>
7992
where
8093
P: AsRef<Utf8Path>,

crates/handlers/src/graphql/tests.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -159,13 +159,13 @@ async fn test_anonymous_viewer(pool: PgPool) {
159159
let state = TestState::from_pool(pool).await.unwrap();
160160

161161
let req = Request::post("/graphql").json(serde_json::json!({
162-
"query": r#"
162+
"query": r"
163163
query {
164164
viewer {
165165
__typename
166166
}
167167
}
168-
"#,
168+
",
169169
}));
170170

171171
let response = state.request(req).await;
@@ -199,7 +199,7 @@ async fn test_oauth2_viewer(pool: PgPool) {
199199
let req = Request::post("/graphql")
200200
.bearer(&access_token)
201201
.json(serde_json::json!({
202-
"query": r#"
202+
"query": r"
203203
query {
204204
viewer {
205205
__typename
@@ -210,7 +210,7 @@ async fn test_oauth2_viewer(pool: PgPool) {
210210
}
211211
}
212212
}
213-
"#,
213+
",
214214
}));
215215

216216
let response = state.request(req).await;
@@ -246,13 +246,13 @@ async fn test_oauth2_no_scope(pool: PgPool) {
246246
let req = Request::post("/graphql")
247247
.bearer(&access_token)
248248
.json(serde_json::json!({
249-
"query": r#"
249+
"query": r"
250250
query {
251251
viewer {
252252
__typename
253253
}
254254
}
255-
"#,
255+
",
256256
}));
257257

258258
let response = state.request(req).await;
@@ -294,14 +294,14 @@ async fn test_oauth2_admin(pool: PgPool) {
294294
let request = Request::post("/graphql")
295295
.bearer(&access_token)
296296
.json(serde_json::json!({
297-
"query": r#"
297+
"query": r"
298298
query UserQuery($id: ID) {
299299
user(id: $id) {
300300
id
301301
username
302302
}
303303
}
304-
"#,
304+
",
305305
"variables": {
306306
"id": format!("user:{id}", id = user2.id),
307307
},
@@ -324,14 +324,14 @@ async fn test_oauth2_admin(pool: PgPool) {
324324
let request = Request::post("/graphql")
325325
.bearer(&access_token_admin)
326326
.json(serde_json::json!({
327-
"query": r#"
327+
"query": r"
328328
query UserQuery($id: ID) {
329329
user(id: $id) {
330330
id
331331
username
332332
}
333333
}
334-
"#,
334+
",
335335
"variables": {
336336
"id": format!("user:{id}", id = user2.id),
337337
},
@@ -392,7 +392,7 @@ async fn test_oauth2_client_credentials(pool: PgPool) {
392392
let request = Request::post("/graphql")
393393
.bearer(&access_token)
394394
.json(serde_json::json!({
395-
"query": r#"
395+
"query": r"
396396
query {
397397
viewer {
398398
__typename
@@ -402,7 +402,7 @@ async fn test_oauth2_client_credentials(pool: PgPool) {
402402
__typename
403403
}
404404
}
405-
"#,
405+
",
406406
}));
407407

408408
let response = state.request(request).await;
@@ -459,7 +459,7 @@ async fn test_oauth2_client_credentials(pool: PgPool) {
459459
let request = Request::post("/graphql")
460460
.bearer(&access_token)
461461
.json(serde_json::json!({
462-
"query": r#"
462+
"query": r"
463463
query {
464464
viewer {
465465
__typename
@@ -469,7 +469,7 @@ async fn test_oauth2_client_credentials(pool: PgPool) {
469469
__typename
470470
}
471471
}
472-
"#,
472+
",
473473
}));
474474

475475
let response = state.request(request).await;
@@ -535,14 +535,14 @@ async fn test_oauth2_client_credentials(pool: PgPool) {
535535
let request = Request::post("/graphql")
536536
.bearer(&access_token)
537537
.json(serde_json::json!({
538-
"query": r#"
538+
"query": r"
539539
mutation CreateSession($userId: String!, $scope: String!) {
540540
createOauth2Session(input: {userId: $userId, permanent: true, scope: $scope}) {
541541
accessToken
542542
refreshToken
543543
}
544544
}
545-
"#,
545+
",
546546
"variables": {
547547
"userId": user_id,
548548
"scope": "urn:matrix:org.matrix.msc2967.client:device:AABBCCDDEE urn:matrix:org.matrix.msc2967.client:api:* urn:synapse:admin:*"

crates/i18n-scan/src/minijinja.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ mod tests {
323323
fn test_invalid_key_not_string() {
324324
// This is invalid because the key is not a string
325325
let mut context = Context::new("t".to_owned());
326-
let ast = parse(r#"{{ t(5) }}"#, "invalid.txt").unwrap();
326+
let ast = parse(r"{{ t(5) }}", "invalid.txt").unwrap();
327327

328328
let res = find_in_stmt(&mut context, &ast);
329329
assert!(res.is_err());
@@ -343,7 +343,7 @@ mod tests {
343343
fn test_invalid_key_missing() {
344344
// This is invalid because the key argument is missing
345345
let mut context = Context::new("t".to_owned());
346-
let ast = parse(r#"{{ t() }}"#, "invalid.txt").unwrap();
346+
let ast = parse(r"{{ t() }}", "invalid.txt").unwrap();
347347

348348
let res = find_in_stmt(&mut context, &ast);
349349
assert!(res.is_err());

crates/iana-codegen/src/gen.rs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@
1414

1515
use crate::traits::{EnumMember, Section};
1616

17+
fn raw_string(string: &str) -> String {
18+
if string.contains('"') {
19+
format!(r##"r#"{string}"#"##)
20+
} else {
21+
format!(r#"r"{string}""#)
22+
}
23+
}
24+
1725
pub fn struct_def(
1826
f: &mut std::fmt::Formatter<'_>,
1927
section: &Section,
@@ -187,14 +195,15 @@ impl schemars::JsonSchema for {} {{
187195
if let Some(description) = &member.description {
188196
write!(
189197
f,
190-
r##"
198+
r#"
191199
metadata: Some(Box::new(schemars::schema::Metadata {{
192200
description: Some(
193201
// ---
194-
r#"{description}"#.to_owned(),
202+
{}.to_owned(),
195203
),
196204
..Default::default()
197-
}})),"##,
205+
}})),"#,
206+
raw_string(description),
198207
)?;
199208
}
200209

@@ -211,10 +220,10 @@ impl schemars::JsonSchema for {} {{
211220

212221
writeln!(
213222
f,
214-
r##"
223+
r#"
215224
];
216225
217-
let description = r#"{}"#;
226+
let description = {};
218227
schemars::schema::SchemaObject {{
219228
metadata: Some(Box::new(schemars::schema::Metadata {{
220229
description: Some(description.to_owned()),
@@ -228,8 +237,8 @@ impl schemars::JsonSchema for {} {{
228237
}}
229238
.into()
230239
}}
231-
}}"##,
232-
section.doc,
240+
}}"#,
241+
raw_string(section.doc),
233242
)
234243
}
235244

0 commit comments

Comments
 (0)