From e335f73bba6e9331ab70d0cd57c62db062732caa Mon Sep 17 00:00:00 2001 From: maciektr Date: Fri, 22 Mar 2024 18:37:08 +0100 Subject: [PATCH] Rust update - fix build and clippy erorrs (#1213) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit commit-id:77034927 --- **Stack**: - #1220 - #1219 - #1218 - #1217 - #1216 - #1215 - #1214 - #1221 - #1222 - #1213 ⬅ ⚠️ *Part of a stack created by [spr](https://github.com/ejoffe/spr). Do not merge manually using the UI - doing so may have unexpected results.* --- scarb/src/core/registry/client/local.rs | 1 + scarb/src/flock.rs | 9 ++++++--- scarb/src/ops/lockfile.rs | 1 + utils/scarb-build-metadata/build.rs | 5 ++++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/scarb/src/core/registry/client/local.rs b/scarb/src/core/registry/client/local.rs index 3a49587da..3bed58d01 100644 --- a/scarb/src/core/registry/client/local.rs +++ b/scarb/src/core/registry/client/local.rs @@ -213,6 +213,7 @@ fn edit_records(records_path: &Path, func: impl FnOnce(&mut IndexRecords)) -> Re .read(true) .write(true) .create(true) + .truncate(false) .open(records_path) .context("failed to open file")?; diff --git a/scarb/src/flock.rs b/scarb/src/flock.rs index 4f7a36114..50c25ea0e 100644 --- a/scarb/src/flock.rs +++ b/scarb/src/flock.rs @@ -148,8 +148,9 @@ pub struct AdvisoryLock<'f> { config: &'f Config, } -#[derive(Debug)] -pub struct AdvisoryLockGuard(Arc); +pub struct AdvisoryLockGuard { + _inner: Arc, +} impl<'f> AdvisoryLock<'f> { /// Acquires this advisory lock in an async manner. @@ -172,7 +173,9 @@ impl<'f> AdvisoryLock<'f> { arc } }; - Ok(AdvisoryLockGuard(file_lock_arc)) + Ok(AdvisoryLockGuard { + _inner: file_lock_arc, + }) } } diff --git a/scarb/src/ops/lockfile.rs b/scarb/src/ops/lockfile.rs index e45f9fc4d..f9b43e400 100644 --- a/scarb/src/ops/lockfile.rs +++ b/scarb/src/ops/lockfile.rs @@ -12,6 +12,7 @@ pub fn read_lockfile(ws: &Workspace<'_>) -> Result { .read(true) .write(true) .create(true) + .truncate(false) .open(ws.lockfile_path()) .context("failed to open lockfile")?; diff --git a/utils/scarb-build-metadata/build.rs b/utils/scarb-build-metadata/build.rs index a84bde752..e6c1e42d7 100644 --- a/utils/scarb-build-metadata/build.rs +++ b/utils/scarb-build-metadata/build.rs @@ -52,7 +52,10 @@ fn cairo_version() { .root .expect("Expected metadata resolve root to be present."); assert!( - root.repr.starts_with("scarb "), + // The first condition for Rust >= 1.77 + // (After the PackageId spec stabilization) + // The second condition for Rust < 1.77 + root.repr.contains("scarb#") || root.repr.starts_with("scarb "), "Expected metadata resolve root to be `scarb`." );