Skip to content

Commit a0cd546

Browse files
authored
Upgrade Clippy to Rust 1.87 (#4794)
2 parents b8480b1 + 23797ee commit a0cd546

File tree

28 files changed

+258
-164
lines changed

28 files changed

+258
-164
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ jobs:
215215
uses: actions/checkout@v4.2.2
216216

217217
- name: Install Rust toolchain
218-
uses: dtolnay/rust-toolchain@1.86.0
218+
uses: dtolnay/rust-toolchain@1.87.0
219219
with:
220220
components: clippy
221221

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# The Debian version and version name must be in sync
1313
ARG DEBIAN_VERSION=12
1414
ARG DEBIAN_VERSION_NAME=bookworm
15-
ARG RUSTC_VERSION=1.86.0
15+
ARG RUSTC_VERSION=1.87.0
1616
ARG NODEJS_VERSION=20.15.0
1717
ARG OPA_VERSION=1.1.0
1818
ARG CARGO_AUDITABLE_VERSION=0.6.6

crates/cli/src/commands/config.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ impl Options {
7272
SC::Dump { output } => {
7373
let _span = info_span!("cli.config.dump").entered();
7474

75-
let config = RootConfig::extract(figment)?;
75+
let config = RootConfig::extract(figment).map_err(anyhow::Error::from_boxed)?;
7676
let config = serde_yaml::to_string(&config)?;
7777

7878
if let Some(output) = output {
@@ -88,7 +88,7 @@ impl Options {
8888
SC::Check => {
8989
let _span = info_span!("cli.config.check").entered();
9090

91-
let _config = RootConfig::extract(figment)?;
91+
let _config = RootConfig::extract(figment).map_err(anyhow::Error::from_boxed)?;
9292
info!("Configuration file looks good");
9393
}
9494

@@ -105,7 +105,8 @@ impl Options {
105105

106106
if !synapse_config.is_empty() {
107107
info!("Adjusting MAS config to match Synapse config from {synapse_config:?}");
108-
let synapse_config = syn2mas::synapse_config::Config::load(&synapse_config)?;
108+
let synapse_config = syn2mas::synapse_config::Config::load(&synapse_config)
109+
.map_err(anyhow::Error::from_boxed)?;
109110
config = synapse_config.adjust_mas_config(config, &mut rng, clock.now());
110111
}
111112

@@ -121,7 +122,7 @@ impl Options {
121122
}
122123

123124
SC::Sync { prune, dry_run } => {
124-
let config = SyncConfig::extract(figment)?;
125+
let config = SyncConfig::extract(figment).map_err(anyhow::Error::from_boxed)?;
125126
let clock = SystemClock::default();
126127
let encrypter = config.secrets.encrypter().await?;
127128

crates/cli/src/commands/database.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ enum Subcommand {
3030
impl Options {
3131
pub async fn run(self, figment: &Figment) -> anyhow::Result<ExitCode> {
3232
let _span = info_span!("cli.database.migrate").entered();
33-
let config = DatabaseConfig::extract_or_default(figment)?;
33+
let config =
34+
DatabaseConfig::extract_or_default(figment).map_err(anyhow::Error::from_boxed)?;
3435
let mut conn = database_connection_from_config(&config).await?;
3536

3637
// Run pending migrations

crates/cli/src/commands/debug.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,16 @@ impl Options {
4141
match self.subcommand {
4242
SC::Policy { with_dynamic_data } => {
4343
let _span = info_span!("cli.debug.policy").entered();
44-
let config = PolicyConfig::extract_or_default(figment)?;
45-
let matrix_config = MatrixConfig::extract(figment)?;
44+
let config =
45+
PolicyConfig::extract_or_default(figment).map_err(anyhow::Error::from_boxed)?;
46+
let matrix_config =
47+
MatrixConfig::extract(figment).map_err(anyhow::Error::from_boxed)?;
4648
info!("Loading and compiling the policy module");
4749
let policy_factory = policy_factory_from_config(&config, &matrix_config).await?;
4850

4951
if with_dynamic_data {
50-
let database_config = DatabaseConfig::extract(figment)?;
52+
let database_config =
53+
DatabaseConfig::extract(figment).map_err(anyhow::Error::from_boxed)?;
5154
let pool = database_pool_from_config(&database_config).await?;
5255
let repository_factory = PgRepositoryFactory::new(pool.clone());
5356
load_policy_factory_dynamic_data(&policy_factory, &repository_factory).await?;

crates/cli/src/commands/doctor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl Options {
3333
"💡 Running diagnostics, make sure that both MAS and Synapse are running, and that MAS is using the same configuration files as this tool."
3434
);
3535

36-
let config = RootConfig::extract(figment)?;
36+
let config = RootConfig::extract(figment).map_err(anyhow::Error::from_boxed)?;
3737

3838
// We'll need an HTTP client
3939
let http_client = mas_http::reqwest_client();

crates/cli/src/commands/manage.rs

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,10 @@ impl Options {
223223
let _span =
224224
info_span!("cli.manage.set_password", user.username = %username).entered();
225225

226-
let database_config = DatabaseConfig::extract_or_default(figment)?;
227-
let passwords_config = PasswordsConfig::extract_or_default(figment)?;
226+
let database_config = DatabaseConfig::extract_or_default(figment)
227+
.map_err(anyhow::Error::from_boxed)?;
228+
let passwords_config = PasswordsConfig::extract_or_default(figment)
229+
.map_err(anyhow::Error::from_boxed)?;
228230

229231
let mut conn = database_connection_from_config(&database_config).await?;
230232
let password_manager = password_manager_from_config(&passwords_config).await?;
@@ -264,7 +266,8 @@ impl Options {
264266
)
265267
.entered();
266268

267-
let database_config = DatabaseConfig::extract_or_default(figment)?;
269+
let database_config = DatabaseConfig::extract_or_default(figment)
270+
.map_err(anyhow::Error::from_boxed)?;
268271
let mut conn = database_connection_from_config(&database_config).await?;
269272
let txn = conn.begin().await?;
270273
let mut repo = PgRepository::from_conn(txn);
@@ -318,7 +321,8 @@ impl Options {
318321
admin,
319322
device_id,
320323
} => {
321-
let database_config = DatabaseConfig::extract_or_default(figment)?;
324+
let database_config = DatabaseConfig::extract_or_default(figment)
325+
.map_err(anyhow::Error::from_boxed)?;
322326
let mut conn = database_connection_from_config(&database_config).await?;
323327
let txn = conn.begin().await?;
324328
let mut repo = PgRepository::from_conn(txn);
@@ -376,7 +380,8 @@ impl Options {
376380
(Some(_), true) => unreachable!(), // This should be handled by the clap group
377381
};
378382

379-
let database_config = DatabaseConfig::extract_or_default(figment)?;
383+
let database_config = DatabaseConfig::extract_or_default(figment)
384+
.map_err(anyhow::Error::from_boxed)?;
380385
let mut conn = database_connection_from_config(&database_config).await?;
381386
let txn = conn.begin().await?;
382387
let mut repo = PgRepository::from_conn(txn);
@@ -403,7 +408,8 @@ impl Options {
403408

404409
SC::ProvisionAllUsers => {
405410
let _span = info_span!("cli.manage.provision_all_users").entered();
406-
let database_config = DatabaseConfig::extract_or_default(figment)?;
411+
let database_config = DatabaseConfig::extract_or_default(figment)
412+
.map_err(anyhow::Error::from_boxed)?;
407413
let mut conn = database_connection_from_config(&database_config).await?;
408414
let mut txn = conn.begin().await?;
409415

@@ -429,7 +435,8 @@ impl Options {
429435
SC::KillSessions { username, dry_run } => {
430436
let _span =
431437
info_span!("cli.manage.kill_sessions", user.username = username).entered();
432-
let database_config = DatabaseConfig::extract_or_default(figment)?;
438+
let database_config = DatabaseConfig::extract_or_default(figment)
439+
.map_err(anyhow::Error::from_boxed)?;
433440
let mut conn = database_connection_from_config(&database_config).await?;
434441
let txn = conn.begin().await?;
435442
let mut repo = PgRepository::from_conn(txn);
@@ -501,7 +508,8 @@ impl Options {
501508
deactivate,
502509
} => {
503510
let _span = info_span!("cli.manage.lock_user", user.username = username).entered();
504-
let config = DatabaseConfig::extract_or_default(figment)?;
511+
let config = DatabaseConfig::extract_or_default(figment)
512+
.map_err(anyhow::Error::from_boxed)?;
505513
let mut conn = database_connection_from_config(&config).await?;
506514
let txn = conn.begin().await?;
507515
let mut repo = PgRepository::from_conn(txn);
@@ -537,7 +545,8 @@ impl Options {
537545
} => {
538546
let _span =
539547
info_span!("cli.manage.unlock_user", user.username = username).entered();
540-
let config = DatabaseConfig::extract_or_default(figment)?;
548+
let config = DatabaseConfig::extract_or_default(figment)
549+
.map_err(anyhow::Error::from_boxed)?;
541550
let mut conn = database_connection_from_config(&config).await?;
542551
let txn = conn.begin().await?;
543552
let mut repo = PgRepository::from_conn(txn);
@@ -574,9 +583,12 @@ impl Options {
574583
ignore_password_complexity,
575584
} => {
576585
let http_client = mas_http::reqwest_client();
577-
let password_config = PasswordsConfig::extract_or_default(figment)?;
578-
let database_config = DatabaseConfig::extract_or_default(figment)?;
579-
let matrix_config = MatrixConfig::extract(figment)?;
586+
let password_config = PasswordsConfig::extract_or_default(figment)
587+
.map_err(anyhow::Error::from_boxed)?;
588+
let database_config = DatabaseConfig::extract_or_default(figment)
589+
.map_err(anyhow::Error::from_boxed)?;
590+
let matrix_config =
591+
MatrixConfig::extract(figment).map_err(anyhow::Error::from_boxed)?;
580592

581593
let password_manager = password_manager_from_config(&password_config).await?;
582594
let homeserver = homeserver_connection_from_config(&matrix_config, http_client);

crates/cli/src/commands/server.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl Options {
5959
pub async fn run(self, figment: &Figment) -> anyhow::Result<ExitCode> {
6060
let span = info_span!("cli.run.init").entered();
6161
let mut shutdown = LifecycleManager::new()?;
62-
let config = AppConfig::extract(figment)?;
62+
let config = AppConfig::extract(figment).map_err(anyhow::Error::from_boxed)?;
6363

6464
info!(version = crate::VERSION, "Starting up");
6565

@@ -101,8 +101,10 @@ impl Options {
101101
} else {
102102
// Sync the configuration with the database
103103
let mut conn = pool.acquire().await?;
104-
let clients_config = ClientsConfig::extract_or_default(figment)?;
105-
let upstream_oauth2_config = UpstreamOAuth2Config::extract_or_default(figment)?;
104+
let clients_config =
105+
ClientsConfig::extract_or_default(figment).map_err(anyhow::Error::from_boxed)?;
106+
let upstream_oauth2_config = UpstreamOAuth2Config::extract_or_default(figment)
107+
.map_err(anyhow::Error::from_boxed)?;
106108

107109
crate::sync::config_sync(
108110
upstream_oauth2_config,

crates/cli/src/commands/syn2mas.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ impl Options {
9696
}
9797

9898
let synapse_config = synapse_config::Config::load(&self.synapse_configuration_files)
99+
.map_err(anyhow::Error::from_boxed)
99100
.context("Failed to load Synapse configuration")?;
100101

101102
// Establish a connection to Synapse's Postgres database
@@ -111,7 +112,8 @@ impl Options {
111112
.await
112113
.context("could not connect to Synapse Postgres database")?;
113114

114-
let config = DatabaseConfig::extract_or_default(figment)?;
115+
let config =
116+
DatabaseConfig::extract_or_default(figment).map_err(anyhow::Error::from_boxed)?;
115117

116118
let mut mas_connection = database_connection_from_config_with_options(
117119
&config,
@@ -131,7 +133,7 @@ impl Options {
131133
// First perform a config sync
132134
// This is crucial to ensure we register upstream OAuth providers
133135
// in the MAS database
134-
let config = SyncConfig::extract(figment)?;
136+
let config = SyncConfig::extract(figment).map_err(anyhow::Error::from_boxed)?;
135137
let clock = SystemClock::default();
136138
let encrypter = config.secrets.encrypter().await?;
137139

@@ -213,7 +215,8 @@ impl Options {
213215

214216
Subcommand::Migrate { dry_run } => {
215217
let provider_id_mappings: HashMap<String, Uuid> = {
216-
let mas_oauth2 = UpstreamOAuth2Config::extract_or_default(figment)?;
218+
let mas_oauth2 = UpstreamOAuth2Config::extract_or_default(figment)
219+
.map_err(anyhow::Error::from_boxed)?;
217220

218221
mas_oauth2
219222
.providers
@@ -252,7 +255,8 @@ impl Options {
252255
let occasional_progress_logger_task =
253256
tokio::spawn(occasional_progress_logger(progress.clone()));
254257

255-
let mas_matrix = MatrixConfig::extract(figment)?;
258+
let mas_matrix =
259+
MatrixConfig::extract(figment).map_err(anyhow::Error::from_boxed)?;
256260
syn2mas::migrate(
257261
reader,
258262
writer,

crates/cli/src/commands/templates.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,20 @@ impl Options {
3737
SC::Check => {
3838
let _span = info_span!("cli.templates.check").entered();
3939

40-
let template_config = TemplatesConfig::extract_or_default(figment)?;
41-
let branding_config = BrandingConfig::extract_or_default(figment)?;
42-
let matrix_config = MatrixConfig::extract(figment)?;
43-
let experimental_config = ExperimentalConfig::extract_or_default(figment)?;
44-
let password_config = PasswordsConfig::extract_or_default(figment)?;
45-
let account_config = AccountConfig::extract_or_default(figment)?;
46-
let captcha_config = CaptchaConfig::extract_or_default(figment)?;
40+
let template_config = TemplatesConfig::extract_or_default(figment)
41+
.map_err(anyhow::Error::from_boxed)?;
42+
let branding_config = BrandingConfig::extract_or_default(figment)
43+
.map_err(anyhow::Error::from_boxed)?;
44+
let matrix_config =
45+
MatrixConfig::extract(figment).map_err(anyhow::Error::from_boxed)?;
46+
let experimental_config = ExperimentalConfig::extract_or_default(figment)
47+
.map_err(anyhow::Error::from_boxed)?;
48+
let password_config = PasswordsConfig::extract_or_default(figment)
49+
.map_err(anyhow::Error::from_boxed)?;
50+
let account_config = AccountConfig::extract_or_default(figment)
51+
.map_err(anyhow::Error::from_boxed)?;
52+
let captcha_config = CaptchaConfig::extract_or_default(figment)
53+
.map_err(anyhow::Error::from_boxed)?;
4754

4855
let clock = SystemClock::default();
4956
// XXX: we should disallow SeedableRng::from_entropy

0 commit comments

Comments
 (0)