Skip to content

Commit 6556b0b

Browse files
authored
Update Rust to 1.85 and edition 2024 (#4084)
2 parents 4fd5790 + 7570a64 commit 6556b0b

File tree

271 files changed

+931
-840
lines changed

Some content is hidden

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

271 files changed

+931
-840
lines changed

.github/workflows/ci.yaml

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ on:
44
push:
55
branches:
66
- main
7-
- 'release/**'
7+
- "release/**"
88
tags:
9-
- 'v*'
9+
- "v*"
1010
pull_request:
1111

1212
concurrency:
@@ -31,10 +31,7 @@ jobs:
3131
- name: Checkout the code
3232
uses: actions/[email protected]
3333

34-
- name: Setup OPA
35-
uses: open-policy-agent/[email protected]
36-
with:
37-
version: 0.70.0
34+
- uses: ./.github/actions/build-policies
3835

3936
- name: Setup Regal
4037
uses: StyraInc/setup-regal@v1
@@ -73,7 +70,6 @@ jobs:
7370
working-directory: ./frontend
7471
run: npm run lint
7572

76-
7773
frontend-test:
7874
name: Run the frontend test suite
7975
runs-on: ubuntu-24.04
@@ -98,7 +94,6 @@ jobs:
9894
working-directory: ./frontend
9995
run: npm test
10096

101-
10297
frontend-knip:
10398
name: Check the frontend for unused dependencies
10499
runs-on: ubuntu-24.04
@@ -123,7 +118,6 @@ jobs:
123118
working-directory: ./frontend
124119
run: npm run knip
125120

126-
127121
rustfmt:
128122
name: Check Rust style
129123
runs-on: ubuntu-24.04
@@ -143,7 +137,6 @@ jobs:
143137
- name: Check style
144138
run: cargo fmt --all -- --check
145139

146-
147140
cargo-deny:
148141
name: Run `cargo deny` checks
149142
runs-on: ubuntu-24.04
@@ -161,7 +154,8 @@ jobs:
161154

162155
- name: Run `cargo-deny`
163156
uses: EmbarkStudios/[email protected]
164-
157+
with:
158+
rust-version: stable
165159

166160
check-schema:
167161
name: Check schema
@@ -203,7 +197,6 @@ jobs:
203197
exit 1
204198
fi
205199
206-
207200
clippy:
208201
name: Run Clippy
209202
needs: [rustfmt, opa-lint]
@@ -217,18 +210,11 @@ jobs:
217210
uses: actions/[email protected]
218211

219212
- name: Install Rust toolchain
220-
uses: dtolnay/rust-toolchain@1.84.0
213+
uses: dtolnay/rust-toolchain@1.85.0
221214
with:
222215
components: clippy
223216

224-
- name: Setup OPA
225-
uses: open-policy-agent/[email protected]
226-
with:
227-
version: 0.64.1
228-
229-
- name: Compile OPA policies
230-
working-directory: ./policies
231-
run: make
217+
- uses: ./.github/actions/build-policies
232218

233219
- name: Setup sccache
234220
uses: mozilla-actions/[email protected]
@@ -237,7 +223,6 @@ jobs:
237223
run: |
238224
cargo clippy --workspace --tests --bins --lib -- -D warnings
239225
240-
241226
compile-test-artifacts:
242227
name: Compile test artifacts
243228
runs-on: ubuntu-24.04
@@ -263,15 +248,14 @@ jobs:
263248
- name: Build and archive tests
264249
run: cargo nextest archive --workspace --archive-file nextest-archive.tar.zst
265250
env:
266-
SQLX_OFFLINE: '1'
251+
SQLX_OFFLINE: "1"
267252

268253
- name: Upload archive to workflow
269254
uses: actions/[email protected]
270255
with:
271256
name: nextest-archive
272257
path: nextest-archive.tar.zst
273258

274-
275259
test:
276260
name: Run test suite with Rust stable
277261
needs: [rustfmt, opa-lint, compile-test-artifacts]
@@ -303,7 +287,9 @@ jobs:
303287
- name: Checkout the code
304288
uses: actions/[email protected]
305289

306-
- run: mkdir -p ~/.cargo/bin
290+
- name: Install Rust toolchain
291+
uses: dtolnay/rust-toolchain@stable
292+
307293
- name: Install nextest
308294
uses: taiki-e/install-action@v2
309295
with:

.github/workflows/coverage.yaml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Coverage
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches: [main]
66
pull_request:
7-
branches: [ main ]
7+
branches: [main]
88

99
concurrency:
1010
group: ${{ github.workflow }}-${{ github.ref }}
@@ -26,10 +26,7 @@ jobs:
2626
- name: Checkout the code
2727
uses: actions/[email protected]
2828

29-
- name: Setup OPA
30-
uses: open-policy-agent/[email protected]
31-
with:
32-
version: 0.70.0
29+
- uses: ./.github/actions/build-policies
3330

3431
- name: Run OPA tests with coverage
3532
working-directory: ./policies
@@ -119,10 +116,10 @@ jobs:
119116
run: |
120117
cargo test --no-fail-fast --workspace
121118
env:
122-
RUSTFLAGS: '-Cinstrument-coverage'
119+
RUSTFLAGS: "-Cinstrument-coverage"
123120
LLVM_PROFILE_FILE: "cargo-test-%p-%m.profraw"
124121
DATABASE_URL: postgresql://postgres:postgres@localhost/postgres
125-
SQLX_OFFLINE: '1'
122+
SQLX_OFFLINE: "1"
126123

127124
- name: Build grcov report
128125
run: |

.github/workflows/release-branch.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
- name: Compute the new minor RC
2929
id: next
3030
run: |
31-
CURRENT_VERSION="$(cargo metadata --format-version 1 | jq -r '.packages[] | select(.name == "mas-cli") | .version')"
31+
CURRENT_VERSION="$(cargo metadata --format-version 1 --no-deps | jq -r '.packages[] | select(.name == "mas-cli") | .version')"
3232
NEXT_VERSION="$(npx --yes [email protected] -i preminor --preid rc "${CURRENT_VERSION}")"
3333
# compute the short minor version, e.g. 0.1.0-rc.1 -> 0.1
3434
SHORT_VERSION="$(echo "${NEXT_VERSION}" | cut -d. -f1-2)"

.github/workflows/release-bump.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535

3636
- name: Extract the current version
3737
id: current
38-
run: echo "version=$(cargo metadata --format-version 1 | jq -r '.packages[] | select(.name == "mas-cli") | .version')" >> "$GITHUB_OUTPUT"
38+
run: echo "version=$(cargo metadata --format-version 1 --no-deps | jq -r '.packages[] | select(.name == "mas-cli") | .version')" >> "$GITHUB_OUTPUT"
3939

4040
- name: Compute the new minor RC
4141
id: next

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
[workspace]
22
default-members = ["crates/cli"]
33
members = ["crates/*"]
4-
resolver = "2"
4+
resolver = "3"
55

66
# Updated in the CI with a `sed` command
77
package.version = "0.14.1"
88
package.license = "AGPL-3.0-only"
99
package.authors = ["Element Backend Team"]
10-
package.edition = "2021"
10+
package.edition = "2024"
1111
package.homepage = "https://element-hq.github.io/matrix-authentication-service/"
1212
package.repository = "https://github.com/element-hq/matrix-authentication-service/"
1313

1414
[workspace.lints.rust]
15-
unsafe_code = "forbid"
15+
unsafe_code = "deny"
1616

1717
[workspace.lints.clippy]
1818
# We use groups as good defaults, but with a lower priority so that we can override them

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
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.84.0
11+
ARG RUSTC_VERSION=1.85.0
1212
ARG NODEJS_VERSION=20.15.0
13-
ARG OPA_VERSION=0.64.1
13+
ARG OPA_VERSION=1.1.0
1414
ARG CARGO_AUDITABLE_VERSION=0.6.6
1515

1616
##########################################

crates/axum-utils/src/client_authorization.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,24 @@
77
use std::collections::HashMap;
88

99
use axum::{
10+
BoxError, Json,
1011
extract::{
11-
rejection::{FailedToDeserializeForm, FormRejection},
1212
Form, FromRequest, FromRequestParts,
13+
rejection::{FailedToDeserializeForm, FormRejection},
1314
},
1415
response::IntoResponse,
15-
BoxError, Json,
1616
};
1717
use axum_extra::typed_header::{TypedHeader, TypedHeaderRejectionReason};
18-
use headers::{authorization::Basic, Authorization};
18+
use headers::{Authorization, authorization::Basic};
1919
use http::{Request, StatusCode};
2020
use mas_data_model::{Client, JwksOrJwksUri};
2121
use mas_http::RequestBuilderExt;
2222
use mas_iana::oauth::OAuthClientAuthenticationMethod;
2323
use mas_jose::{jwk::PublicJsonWebKeySet, jwt::Jwt};
2424
use mas_keystore::Encrypter;
25-
use mas_storage::{oauth2::OAuth2ClientRepository, RepositoryAccess};
25+
use mas_storage::{RepositoryAccess, oauth2::OAuth2ClientRepository};
2626
use oauth2_types::errors::{ClientError, ClientErrorCode};
27-
use serde::{de::DeserializeOwned, Deserialize};
27+
use serde::{Deserialize, de::DeserializeOwned};
2828
use serde_json::Value;
2929
use thiserror::Error;
3030

@@ -371,7 +371,7 @@ where
371371
Err(FormRejection::InvalidFormContentType(_err)) => (None, None, None, None, None),
372372
// If the form could not be read, return a Bad Request error
373373
Err(FormRejection::FailedToDeserializeForm(err)) => {
374-
return Err(ClientAuthorizationError::BadForm(err))
374+
return Err(ClientAuthorizationError::BadForm(err));
375375
}
376376
// Other errors (body read twice, byte stream broke) return an internal error
377377
Err(e) => return Err(ClientAuthorizationError::Internal(Box::new(e))),

crates/axum-utils/src/cookies.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use axum::{
1414
};
1515
use axum_extra::extract::cookie::{Cookie, Key, PrivateCookieJar, SameSite};
1616
use http::request::Parts;
17-
use serde::{de::DeserializeOwned, Serialize};
17+
use serde::{Serialize, de::DeserializeOwned};
1818
use thiserror::Error;
1919
use url::Url;
2020

crates/axum-utils/src/csrf.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
// Please see LICENSE in the repository root for full details.
66

77
use chrono::{DateTime, Duration, Utc};
8-
use data_encoding::{DecodeError, BASE64URL_NOPAD};
8+
use data_encoding::{BASE64URL_NOPAD, DecodeError};
99
use mas_storage::Clock;
10-
use rand::{Rng, RngCore};
10+
use rand::{Rng, RngCore, distributions::Standard, prelude::Distribution as _};
1111
use serde::{Deserialize, Serialize};
12-
use serde_with::{serde_as, TimestampSeconds};
12+
use serde_with::{TimestampSeconds, serde_as};
1313
use thiserror::Error;
1414

1515
use crate::cookies::{CookieDecodeError, CookieJar};
@@ -56,7 +56,7 @@ impl CsrfToken {
5656

5757
/// Generate a new random token valid for a specified duration
5858
fn generate(now: DateTime<Utc>, mut rng: impl Rng, ttl: Duration) -> Self {
59-
let token = rng.gen();
59+
let token = Standard.sample(&mut rng);
6060
Self::new(token, now, ttl)
6161
}
6262

crates/axum-utils/src/fancy_error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
// Please see LICENSE in the repository root for full details.
66

77
use axum::{
8+
Extension,
89
http::StatusCode,
910
response::{IntoResponse, Response},
10-
Extension,
1111
};
1212
use axum_extra::typed_header::TypedHeader;
1313
use headers::ContentType;

0 commit comments

Comments
 (0)