Skip to content

update to rust 1.89, fix new clippy errors #2888

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "1.88.0"
channel = "1.89.0"
components = ["rustfmt", "clippy"]
12 changes: 5 additions & 7 deletions src/cdn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,10 +381,9 @@ pub(crate) async fn handle_queued_invalidation_requests(
if let Some(status) = cdn
.invalidation_status(distribution_id, &row.cdn_reference)
.await?
&& !status.completed
{
if !status.completed {
active_invalidations.push(status);
}
active_invalidations.push(status);
}
}

Expand Down Expand Up @@ -453,11 +452,10 @@ pub(crate) async fn handle_queued_invalidation_requests(
)
.fetch_one(&mut *conn)
.await?
&& (now - min_queued).to_std().unwrap_or_default() >= config.cdn_max_queued_age
{
if (now - min_queued).to_std().unwrap_or_default() >= config.cdn_max_queued_age {
full_invalidation(cdn, metrics, conn, distribution_id).await?;
return Ok(());
}
full_invalidation(cdn, metrics, conn, distribution_id).await?;
return Ok(());
}

// create new an invalidation for the queued path patterns
Expand Down
7 changes: 4 additions & 3 deletions src/db/add_package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,7 @@ mod test {
use crate::test::*;
use crate::utils::CargoMetadata;
use chrono::NaiveDate;
use std::slice;
use test_case::test_case;

#[test]
Expand Down Expand Up @@ -965,7 +966,7 @@ mod test {
kind: OwnerKind::User,
};

update_owners_in_database(&mut conn, &[owner1.clone()], crate_id).await?;
update_owners_in_database(&mut conn, slice::from_ref(&owner1), crate_id).await?;

let owner_def = sqlx::query!(
r#"SELECT login, avatar, kind as "kind: OwnerKind"
Expand Down Expand Up @@ -1005,7 +1006,7 @@ mod test {
kind: OwnerKind::User,
};

update_owners_in_database(&mut conn, &[owner1.clone()], crate_id).await?;
update_owners_in_database(&mut conn, slice::from_ref(&owner1), crate_id).await?;

let owner_def = sqlx::query!(
r#"SELECT login, avatar, kind as "kind: OwnerKind"
Expand Down Expand Up @@ -1056,7 +1057,7 @@ mod test {
avatar: "avatar2".into(),
kind: OwnerKind::Team,
};
update_owners_in_database(&mut conn, &[updated_owner.clone()], crate_id).await?;
update_owners_in_database(&mut conn, slice::from_ref(&updated_owner), crate_id).await?;

let owner_def =
sqlx::query!(r#"SELECT login, avatar, kind as "kind: OwnerKind" FROM owners"#)
Expand Down
30 changes: 14 additions & 16 deletions src/docbuilder/rustwide_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -586,16 +586,15 @@ impl RustwideBuilder {
self.execute_build(build_id, name, version, default_target, true, build, &limits, &metadata, false, collect_metrics)?;
}

if res.result.successful {
if let Some(name) = res.cargo_metadata.root().library_name() {
if res.result.successful
&& let Some(name) = res.cargo_metadata.root().library_name() {
let host_target = build.host_target_dir();
has_docs = host_target
.join(default_target)
.join("doc")
.join(name)
.is_dir();
}
}

let mut target_build_logs = HashMap::new();
let documentation_size = if has_docs {
Expand Down Expand Up @@ -1077,19 +1076,18 @@ impl RustwideBuilder {
})
};

if collect_metrics {
if let Some(compiler_metric_target_dir) = &self.config.compiler_metrics_collection_path
{
let metric_output = build.host_target_dir().join("metrics/");
info!(
"found {} files in metric dir, copy over to {} (exists: {})",
fs::read_dir(&metric_output)?.count(),
&compiler_metric_target_dir.to_string_lossy(),
&compiler_metric_target_dir.exists(),
);
copy_dir_all(&metric_output, compiler_metric_target_dir)?;
fs::remove_dir_all(&metric_output)?;
}
if collect_metrics
&& let Some(compiler_metric_target_dir) = &self.config.compiler_metrics_collection_path
{
let metric_output = build.host_target_dir().join("metrics/");
info!(
"found {} files in metric dir, copy over to {} (exists: {})",
fs::read_dir(&metric_output)?.count(),
&compiler_metric_target_dir.to_string_lossy(),
&compiler_metric_target_dir.exists(),
);
copy_dir_all(&metric_output, compiler_metric_target_dir)?;
fs::remove_dir_all(&metric_output)?;
}

// For proc-macros, cargo will put the output in `target/doc`.
Expand Down
16 changes: 8 additions & 8 deletions src/storage/s3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@ where
match self {
Ok(result) => Ok(result),
Err(err) => {
if let Some(err_code) = err.code() {
if NOT_FOUND_ERROR_CODES.contains(&err_code) {
return Err(super::PathNotFoundError.into());
}
if let Some(err_code) = err.code()
&& NOT_FOUND_ERROR_CODES.contains(&err_code)
{
return Err(super::PathNotFoundError.into());
}

if let SdkError::ServiceError(err) = &err {
if err.raw().status().as_u16() == http::StatusCode::NOT_FOUND.as_u16() {
return Err(super::PathNotFoundError.into());
}
if let SdkError::ServiceError(err) = &err
&& err.raw().status().as_u16() == http::StatusCode::NOT_FOUND.as_u16()
{
return Err(super::PathNotFoundError.into());
}

Err(err.into())
Expand Down
20 changes: 10 additions & 10 deletions src/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,11 @@ impl AxumRouterTestExt for axum::Router {
let mut path = path.to_owned();
for _ in 0..=10 {
let response = self.get(&path).await?;
if response.status().is_redirection() {
if let Some(target) = response.redirect_target() {
path = target.to_owned();
continue;
}
if response.status().is_redirection()
&& let Some(target) = response.redirect_target()
{
path = target.to_owned();
continue;
}
return Ok(response);
}
Expand Down Expand Up @@ -409,10 +409,10 @@ impl TestEnvironment {
.expect("failed to cleanup after tests");
}

if let Some(config) = self.config.get() {
if config.local_archive_cache_path.exists() {
fs::remove_dir_all(&config.local_archive_cache_path).unwrap();
}
if let Some(config) = self.config.get()
&& config.local_archive_cache_path.exists()
{
fs::remove_dir_all(&config.local_archive_cache_path).unwrap();
}
}

Expand Down Expand Up @@ -610,7 +610,7 @@ impl TestEnvironment {
.expect("could not build axum app")
}

pub(crate) async fn fake_release(&self) -> fakes::FakeRelease {
pub(crate) async fn fake_release(&self) -> fakes::FakeRelease<'_> {
fakes::FakeRelease::new(self.async_db().await, self.async_storage().await)
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/utils/consistency/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ where
// is coming from the build queue, not the `releases`
// table.
// In this case, we skip this check.
if let Some(db_yanked) = db_release.yanked {
if db_yanked != index_yanked {
result.push(Difference::ReleaseYank(
db_crate.name.clone(),
db_release.version.clone(),
index_yanked,
));
}
if let Some(db_yanked) = db_release.yanked
&& db_yanked != index_yanked
{
result.push(Difference::ReleaseYank(
db_crate.name.clone(),
db_release.version.clone(),
index_yanked,
));
}
}
Left(db_release) => result.push(Difference::ReleaseNotInIndex(
Expand Down
42 changes: 18 additions & 24 deletions src/utils/consistency/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,53 +99,47 @@ where

match difference {
diff::Difference::CrateNotInIndex(name) => {
if !dry_run {
if let Err(err) = delete::delete_crate(&mut conn, &storage, &config, name).await
{
warn!("{:?}", err);
}
if !dry_run
&& let Err(err) = delete::delete_crate(&mut conn, &storage, &config, name).await
{
warn!("{:?}", err);
}
result.crates_deleted += 1;
}
diff::Difference::CrateNotInDb(name, versions) => {
for version in versions {
if !dry_run {
if let Err(err) = build_queue
if !dry_run
&& let Err(err) = build_queue
.add_crate(name, version, BUILD_PRIORITY, None)
.await
{
warn!("{:?}", err);
}
{
warn!("{:?}", err);
}
result.builds_queued += 1;
}
}
diff::Difference::ReleaseNotInIndex(name, version) => {
if !dry_run {
if let Err(err) =
if !dry_run
&& let Err(err) =
delete::delete_version(&mut conn, &storage, &config, name, version).await
{
warn!("{:?}", err);
}
{
warn!("{:?}", err);
}
result.releases_deleted += 1;
}
diff::Difference::ReleaseNotInDb(name, version) => {
if !dry_run {
if let Err(err) = build_queue
if !dry_run
&& let Err(err) = build_queue
.add_crate(name, version, BUILD_PRIORITY, None)
.await
{
warn!("{:?}", err);
}
{
warn!("{:?}", err);
}
result.builds_queued += 1;
}
diff::Difference::ReleaseYank(name, version, yanked) => {
if !dry_run {
if let Err(err) = build_queue.set_yanked(name, version, *yanked).await {
warn!("{:?}", err);
}
if !dry_run && let Err(err) = build_queue.set_yanked(name, version, *yanked).await {
warn!("{:?}", err);
}
result.yanks_corrected += 1;
}
Expand Down
8 changes: 4 additions & 4 deletions src/web/extractors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ where
parts: &mut Parts,
_state: &S,
) -> Result<Option<Self>, Self::Rejection> {
if let Some((_rest, last_component)) = parts.uri.path().rsplit_once('/') {
if let Some((_rest, ext)) = last_component.rsplit_once('.') {
return Ok(Some(PathFileExtension(ext.to_string())));
}
if let Some((_rest, last_component)) = parts.uri.path().rsplit_once('/')
&& let Some((_rest, ext)) = last_component.rsplit_once('.')
{
return Ok(Some(PathFileExtension(ext.to_string())));
}

Ok(None)
Expand Down
8 changes: 4 additions & 4 deletions src/web/highlight.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ fn select_syntax(
default: Option<&str>,
) -> &'static SyntaxReference {
name.and_then(|name| {
if name.is_empty() {
if let Some(default) = default {
return SYNTAXES.find_syntax_by_token(default);
}
if name.is_empty()
&& let Some(default) = default
{
return SYNTAXES.find_syntax_by_token(default);
}
SYNTAXES.find_syntax_by_token(name).or_else(|| {
name.rsplit_once('.')
Expand Down
2 changes: 1 addition & 1 deletion src/web/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ fn semver_match<'a, F: Fn(&Release) -> bool>(
// So when we only have pre-releases, `VersionReq::STAR` would lead to an
// empty result.
// In this case we just return the latest prerelease instead of nothing.
return releases.iter().find(|release| filter(release));
releases.iter().find(|release| filter(release))
} else {
None
}
Expand Down
21 changes: 10 additions & 11 deletions src/web/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,16 @@ async fn block_blacklisted_prefixes_middleware(
request: AxumHttpRequest,
next: Next,
) -> impl IntoResponse {
if let Some(first_component) = request.uri().path().trim_matches('/').split('/').next() {
if !first_component.is_empty()
&& (INTERNAL_PREFIXES.binary_search(&first_component).is_ok())
{
debug!(
first_component = first_component,
uri = ?request.uri(),
"blocking blacklisted prefix"
);
return AxumNope::CrateNotFound.into_response();
}
if let Some(first_component) = request.uri().path().trim_matches('/').split('/').next()
&& !first_component.is_empty()
&& (INTERNAL_PREFIXES.binary_search(&first_component).is_ok())
{
debug!(
first_component = first_component,
uri = ?request.uri(),
"blocking blacklisted prefix"
);
return AxumNope::CrateNotFound.into_response();
}

next.run(request).await
Expand Down
Loading
Loading