Skip to content

Commit 98e66c0

Browse files
committed
Fix rustfmt issues
1 parent ac7d5d5 commit 98e66c0

Some content is hidden

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

94 files changed

+269
-231
lines changed

src/app.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Application-wide components in a struct accessible from each request
22
33
use crate::config;
4-
use crate::db::{connection_url, make_manager_config, ConnectionConfig};
4+
use crate::db::{ConnectionConfig, connection_url, make_manager_config};
55
use std::sync::Arc;
66

77
use crate::email::Emails;
@@ -12,9 +12,9 @@ use axum::extract::{FromRef, FromRequestParts, State};
1212
use crates_io_github::GitHubClient;
1313
use deadpool_diesel::Runtime;
1414
use derive_more::Deref;
15-
use diesel_async::pooled_connection::deadpool::Pool as DeadpoolPool;
16-
use diesel_async::pooled_connection::AsyncDieselConnectionManager;
1715
use diesel_async::AsyncPgConnection;
16+
use diesel_async::pooled_connection::AsyncDieselConnectionManager;
17+
use diesel_async::pooled_connection::deadpool::Pool as DeadpoolPool;
1818
use oauth2::basic::BasicClient;
1919
use oauth2::{EndpointNotSet, EndpointSet};
2020

src/auth.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::middleware::log_request::RequestLogExt;
44
use crate::models::token::{CrateScope, EndpointScope};
55
use crate::models::{ApiToken, User};
66
use crate::util::errors::{
7-
account_locked, forbidden, internal, AppResult, InsecurelyGeneratedTokenRevoked,
7+
AppResult, InsecurelyGeneratedTokenRevoked, account_locked, forbidden, internal,
88
};
99
use crate::util::token::HashedToken;
1010
use chrono::Utc;

src/bin/background-worker.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ use crates_io::db::make_manager_config;
1919
use crates_io::fastly::Fastly;
2020
use crates_io::storage::Storage;
2121
use crates_io::worker::{Environment, RunnerExt};
22-
use crates_io::{config, Emails};
22+
use crates_io::{Emails, config};
2323
use crates_io::{db, ssh};
2424
use crates_io_env_vars::var;
2525
use crates_io_index::RepositoryConfig;
2626
use crates_io_team_repo::TeamRepoImpl;
2727
use crates_io_worker::Runner;
28-
use diesel_async::pooled_connection::deadpool::Pool;
2928
use diesel_async::pooled_connection::AsyncDieselConnectionManager;
29+
use diesel_async::pooled_connection::deadpool::Pool;
3030
use object_store::prefix::PrefixStore;
3131
use reqwest::Client;
3232
use secrecy::ExposeSecret;

src/bin/crates-admin/dialoguer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use ::dialoguer::{theme::Theme, Confirm};
1+
use ::dialoguer::{Confirm, theme::Theme};
22
use crates_io::tasks::spawn_blocking;
33

44
pub async fn confirm(msg: impl Into<String>) -> anyhow::Result<bool> {

src/bin/crates-admin/migrate.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
use anyhow::{anyhow, Context, Error};
1+
use anyhow::{Context, Error, anyhow};
22
use crates_io::tasks::spawn_blocking;
3-
use diesel_async::async_connection_wrapper::AsyncConnectionWrapper;
43
use diesel_async::AsyncPgConnection;
4+
use diesel_async::async_connection_wrapper::AsyncConnectionWrapper;
55
use diesel_migrations::{
6-
embed_migrations, EmbeddedMigrations, HarnessWithOutput, MigrationHarness,
6+
EmbeddedMigrations, HarnessWithOutput, MigrationHarness, embed_migrations,
77
};
88

99
static CATEGORIES_TOML: &str = include_str!("../../boot/categories.toml");

src/bin/crates-admin/render_readmes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use anyhow::{anyhow, Context};
1+
use anyhow::{Context, anyhow};
22
use crates_io::db;
33
use crates_io::models::Version;
44
use crates_io::schema::{crates, readme_renderings, versions};
@@ -17,7 +17,7 @@ use crates_io_tarball::{Manifest, StringOrBool};
1717
use diesel::prelude::*;
1818
use diesel_async::async_connection_wrapper::AsyncConnectionWrapper;
1919
use diesel_async::{AsyncPgConnection, RunQueryDsl};
20-
use reqwest::{header, Client};
20+
use reqwest::{Client, header};
2121
use std::str::FromStr;
2222
use tokio_tar::{self, Archive};
2323

src/bin/server.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
extern crate tracing;
33

44
use crates_io::middleware::normalize_path::normalize_path;
5-
use crates_io::{metrics::LogEncoder, App, Emails};
5+
use crates_io::{App, Emails, metrics::LogEncoder};
66
use std::{sync::Arc, time::Duration};
77

88
use axum::ServiceExt;
@@ -12,7 +12,7 @@ use reqwest::Client;
1212
use std::io::Write;
1313
use std::net::SocketAddr;
1414
use tokio::net::TcpListener;
15-
use tokio::signal::unix::{signal, SignalKind};
15+
use tokio::signal::unix::{SignalKind, signal};
1616
use tower::Layer;
1717

1818
const CORE_THREADS: usize = 4;
@@ -106,11 +106,13 @@ fn log_instance_metrics_thread(app: Arc<App>) {
106106
None => return,
107107
};
108108

109-
std::thread::spawn(move || loop {
110-
if let Err(err) = log_instance_metrics_inner(&app) {
111-
error!(?err, "log_instance_metrics error");
109+
std::thread::spawn(move || {
110+
loop {
111+
if let Err(err) = log_instance_metrics_inner(&app) {
112+
error!(?err, "log_instance_metrics error");
113+
}
114+
std::thread::sleep(interval);
112115
}
113-
std::thread::sleep(interval);
114116
});
115117
}
116118

src/config/database_pools.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
//! - `READ_ONLY_MODE`: If defined (even as empty) then force all connections to be read-only.
1212
//! - `DB_TCP_TIMEOUT_MS`: TCP timeout in milliseconds. See the doc comment for more details.
1313
14-
use crate::config::Base;
1514
use crate::Env;
15+
use crate::config::Base;
1616
use anyhow::anyhow;
1717
use crates_io_env_vars::{required_var, var, var_parsed};
1818
use secrecy::SecretString;

src/config/sentry.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use anyhow::Context;
22
use crates_io_env_vars::{required_var, var, var_parsed};
3-
use sentry::types::Dsn;
43
use sentry::IntoDsn;
4+
use sentry::types::Dsn;
55

66
pub struct SentryConfig {
77
pub dsn: Option<Dsn>,

src/config/server.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
use anyhow::{anyhow, Context};
1+
use anyhow::{Context, anyhow};
22
use ipnetwork::IpNetwork;
33
use oauth2::{ClientId, ClientSecret};
44
use url::Url;
55

6-
use crate::rate_limiter::{LimitedAction, RateLimiterConfig};
76
use crate::Env;
7+
use crate::rate_limiter::{LimitedAction, RateLimiterConfig};
88

99
use super::base::Base;
1010
use super::database_pools::DatabasePools;
11-
use crate::config::cdn_log_storage::CdnLogStorageConfig;
1211
use crate::config::CdnLogQueueConfig;
12+
use crate::config::cdn_log_storage::CdnLogStorageConfig;
1313
use crate::middleware::cargo_compat::StatusCodeConfig;
1414
use crate::storage::StorageConfig;
1515
use crates_io_env_vars::{list, list_parsed, required_var, var, var_parsed};
@@ -179,7 +179,11 @@ impl Server {
179179
font-src https://code.cdn.mozilla.net; \
180180
img-src *; \
181181
object-src 'none'",
182-
cdn_domain = storage.cdn_prefix.as_ref().map(|cdn_prefix| format!("https://{cdn_prefix}")).unwrap_or_default()
182+
cdn_domain = storage
183+
.cdn_prefix
184+
.as_ref()
185+
.map(|cdn_prefix| format!("https://{cdn_prefix}"))
186+
.unwrap_or_default()
183187
);
184188

185189
Ok(Server {
@@ -259,7 +263,9 @@ fn parse_cidr_block(block: &str) -> anyhow::Result<IpNetwork> {
259263
};
260264

261265
if cidr.prefix() < host_prefix {
262-
return Err(anyhow!("WEB_PAGE_OFFSET_CIDR_BLOCKLIST only allows CIDR blocks with a host prefix of at least 16 bits (IPv4) or 64 bits (IPv6)."));
266+
return Err(anyhow!(
267+
"WEB_PAGE_OFFSET_CIDR_BLOCKLIST only allows CIDR blocks with a host prefix of at least 16 bits (IPv4) or 64 bits (IPv6)."
268+
));
263269
}
264270

265271
Ok(cidr)

0 commit comments

Comments
 (0)