Skip to content
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 src/rust/engine/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ impl Session {
.into_iter()
.map(|(duration, desc)| format!(
"{}\t{}",
format_workunit_duration_ms!(duration.as_millis()),
format_workunit_duration_ms(duration),
desc
))
.collect::<Vec<_>>()
Expand Down
2 changes: 1 addition & 1 deletion src/rust/nailgun/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
version = "0.0.1"
edition = "2021"
edition = "2024"
name = "nailgun"
authors = ["Pants Build <pantsbuild@gmail.com>"]
publish = false
Expand Down
2 changes: 1 addition & 1 deletion src/rust/pantsd/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
version = "0.0.1"
edition = "2021"
edition = "2024"
name = "pantsd"
authors = ["Pants Build <pantsbuild@gmail.com>"]
publish = false
Expand Down
2 changes: 1 addition & 1 deletion src/rust/process_executor/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
version = "0.0.1"
edition = "2021"
edition = "2024"
name = "process_executor"
authors = ["Pants Build <pantsbuild@gmail.com>"]
publish = false
Expand Down
2 changes: 1 addition & 1 deletion src/rust/protos/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
version = "0.0.1"
edition = "2021"
edition = "2024"
name = "protos"
authors = ["Pants Build <pantsbuild@gmail.com>"]
publish = false
Expand Down
16 changes: 8 additions & 8 deletions src/rust/protos/src/verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ where
"All children must have one path segment, but found {name}"
));
}
if let Some(p) = prev {
if name <= get_name(p) {
return Err(format!(
"Children must be sorted and unique, but {} was before {}",
get_name(p),
name,
));
}
if let Some(p) = prev
&& name <= get_name(p)
{
return Err(format!(
"Children must be sorted and unique, but {} was before {}",
get_name(p),
name,
));
}
prev = Some(node);
}
Expand Down
2 changes: 1 addition & 1 deletion src/rust/sharded_lmdb/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "sharded_lmdb"
version = "0.0.1"
authors = ["Pants Build <pantsbuild@gmail.com>"]
edition = "2021"
edition = "2024"

[dependencies]
bytes = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion src/rust/stdio/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
version = "0.0.1"
edition = "2021"
edition = "2024"
name = "stdio"
authors = ["Pants Build <pantsbuild@gmail.com>"]
publish = false
Expand Down
2 changes: 1 addition & 1 deletion src/rust/testutil/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
version = "0.0.1"
edition = "2021"
edition = "2024"
name = "testutil"
authors = ["Pants Build <pantsbuild@gmail.com>"]
publish = false
Expand Down
2 changes: 1 addition & 1 deletion src/rust/testutil/local_cas/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "local_cas"
version = "0.0.1"
edition = "2021"
edition = "2024"
authors = ["Pants Build <pantsbuild@gmail.com>"]
publish = false

Expand Down
2 changes: 1 addition & 1 deletion src/rust/testutil/local_execution_server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "local_execution_server"
version = "0.1.0"
edition = "2021"
edition = "2024"
authors = ["Pants Build <pantsbuild@gmail.com>"]
publish = false

Expand Down
2 changes: 1 addition & 1 deletion src/rust/testutil/mock/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "mock"
version = "0.0.1"
edition = "2021"
edition = "2024"
authors = ["Pants Build <pantsbuild@gmail.com>"]
publish = false

Expand Down
2 changes: 1 addition & 1 deletion src/rust/tryfuture/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
version = "0.0.1"
edition = "2021"
edition = "2024"
name = "tryfuture"
authors = ["Pants Build <pantsbuild@gmail.com>"]
publish = false
Expand Down
2 changes: 1 addition & 1 deletion src/rust/ui/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "ui"
version = "0.0.1"
edition = "2021"
edition = "2024"
authors = ["Pants Build <pantsbuild@gmail.com>"]

[dependencies]
Expand Down
4 changes: 1 addition & 3 deletions src/rust/ui/src/instance/indicatif.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,7 @@ impl IndicatifInstance {
let (label, start_time) = heavy_hitters.get(span_id).unwrap();
let duration_label = match now.duration_since(*start_time).ok() {
None => "(Waiting)".to_string(),
Some(duration) => {
format_workunit_duration_ms!((duration).as_millis()).to_string()
}
Some(duration) => format_workunit_duration_ms(duration),
};
format!("{duration_label} {label}")
});
Expand Down
4 changes: 2 additions & 2 deletions src/rust/ui/src/instance/prodash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ impl prodash::unit::DisplayValue for MillisAsFloatingPointSecs {
) -> fmt::Result {
// Convert back from millis-since-epoch to millis elapsed.
let start_time = UNIX_EPOCH + Duration::from_millis(value as u64);
let elapsed_ms = start_time.elapsed().map(|d| d.as_millis()).unwrap_or(0);
w.write_fmt(format_workunit_duration_ms!(elapsed_ms))
let elapsed_ms = start_time.elapsed().unwrap_or_else(|_| Duration::new(0, 0));
w.write_str(&format_workunit_duration_ms(elapsed_ms))
}
fn display_unit(&self, _w: &mut dyn fmt::Write, _value: Step) -> fmt::Result {
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion src/rust/watch/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
version = "0.0.1"
edition = "2021"
edition = "2024"
name = "watch"
authors = ["Pants Build <pantsbuild@gmail.com>"]
publish = false
Expand Down
2 changes: 1 addition & 1 deletion src/rust/workunit_store/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
version = "0.0.1"
edition = "2021"
edition = "2024"
name = "workunit_store"
authors = ["Pants Build <pantsbuild@gmail.com>"]
publish = false
Expand Down
26 changes: 12 additions & 14 deletions src/rust/workunit_store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -770,9 +770,8 @@ impl WorkunitStore {
}
}

#[macro_export]
macro_rules! format_workunit_duration_ms {
($workunit_duration_ms:expr) => {{ format_args!("{:.2}s", ($workunit_duration_ms as f64) / 1000.0) }};
pub fn format_workunit_duration_ms(duration: Duration) -> String {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I converted this a regular function because the changes to lifetimes for temporary values in Rust 2024 Edition triggered this error:

    error[E0716]: temporary value dropped while borrowed
       --> ui/src/instance/prodash.rs:170:21
        |
    170 |         w.write_fmt(format_workunit_duration_ms!(elapsed_ms))
        |           --------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |           |         |
        |           |         creates a temporary value which is freed while still in use
        |           |         temporary value is freed at the end of this statement
        |           borrow later used by call
        |
        = note: consider using a `let` binding to create a longer lived value
        = note: this error originates in the macro `format_workunit_duration_ms` (in Nightly builds, run with -Z macro-backtrace for more info)

format!("{:.2}s", (duration.as_millis() as f64) / 1000.0)
}

///
Expand Down Expand Up @@ -912,13 +911,12 @@ impl RunningWorkunit {
where
F: FnOnce(Option<(WorkunitMetadata, Level)>) -> Option<(WorkunitMetadata, Level)>,
{
if let Some(ref mut workunit) = self.workunit {
if let Some((metadata, level)) =
if let Some(ref mut workunit) = self.workunit
&& let Some((metadata, level)) =
f(workunit.metadata.clone().map(|m| (m, workunit.level)))
{
workunit.level = level;
workunit.metadata = Some(metadata);
}
{
workunit.level = level;
workunit.metadata = Some(metadata);
}
}

Expand All @@ -927,11 +925,11 @@ impl RunningWorkunit {
///
pub fn blocking(&mut self) -> BlockingWorkunitToken {
let mut token = BlockingWorkunitToken(None);
if let Some(ref mut workunit) = self.workunit {
if let WorkunitState::Started { blocked, .. } = &mut workunit.state {
blocked.store(true, atomic::Ordering::Relaxed);
token.0 = Some(blocked.clone());
}
if let Some(ref mut workunit) = self.workunit
&& let WorkunitState::Started { blocked, .. } = &mut workunit.state
{
blocked.store(true, atomic::Ordering::Relaxed);
token.0 = Some(blocked.clone());
}
token
}
Expand Down
Loading