Skip to content

Conversation

@terror
Copy link
Contributor

@terror terror commented Jan 9, 2026

Resolves #16472

This diff adds the ability to specify a session ID when running cargo report timings and cargo report rebuilds. Previously, these commands always reported on the most recent build session. Now users can inspect any previous session by passing --id <SESSION_ID>.

@rustbot rustbot added A-cli Area: Command-line interface, option parsing, etc. Command-report S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 9, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 9, 2026

r? @weihanglo

rustbot has assigned @weihanglo.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@weihanglo
Copy link
Member

Thanks for the contribution!

FWIW, we usually follow a variant of atomic commit pattern:

  1. Commit a test that captures the current behavior (test passes).
  2. In the next commit, change the behavior and update the test/snapshot.

Every commit passes, and the test/snapshot diff shows the behavior change.

Any feel free to rebase and fix-up your commit history!

@epage
Copy link
Contributor

epage commented Jan 9, 2026

For the initail test commit, I would leave off --id then add it in the follow up so it shows that it changed what result is returned.

.arg_manifest_path()
.arg(flag("open", "Opens the timing report in a browser")),
.arg(flag("open", "Opens the timing report in a browser"))
.arg(opt("id", "Session ID to report on").value_name("ID")),
Copy link
Contributor

Choose a reason for hiding this comment

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

This should also go first

terror added 2 commits January 9, 2026 11:23
This adds the `--id` argument to the CLI definitions but does not yet
implement the functionality. The argument is currently accepted but
ignored; the commands still use the most recent session by default.

This commit also adds tests that verify the current behavior (using the
most recent session) in preparation for the next commit which implements
the `--id` functionality.
…builds`

This implements the `--id` flag that was added in the previous commit.
When specified, the commands will report on the session with the given
ID instead of the most recent session.

The implementation adds a `find_log_file` helper that searches for a
specific session ID when provided, or falls back to returning the most
recent session when no ID is specified.

Error handling is updated to provide helpful messages:
- When a specific ID is not found, users are directed to
  `cargo report sessions` to list available sessions
- Invalid ID formats are rejected with a clear error message
@terror
Copy link
Contributor Author

terror commented Jan 9, 2026

Thanks for the contribution!

FWIW, we usually follow a variant of atomic commit pattern:

  1. Commit a test that captures the current behavior (test passes).
  2. In the next commit, change the behavior and update the test/snapshot.

Every commit passes, and the test/snapshot diff shows the behavior change.

Any feel free to rebase and fix-up your commit history!

Thanks for the heads up, just went ahead and re-wrote the commits to reflect this convention :)

Copy link
Member

@weihanglo weihanglo left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution!

View changes since this review

@weihanglo weihanglo added this pull request to the merge queue Jan 9, 2026
Merged via the queue into rust-lang:master with commit dc03f44 Jan 9, 2026
29 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 9, 2026
@terror terror deleted the cargo-report-id branch January 9, 2026 22:48
rust-bors bot added a commit to rust-lang/rust that referenced this pull request Jan 11, 2026
Update cargo submodule

5 commits in 8c133afcd5e0d69932fe11f5907683723f8d361d..6d1bd93c47f059ec1344cb31e68a2fb284cbc6b1
2026-01-09 03:50:15 +0000 to 2026-01-10 12:53:59 +0000
- fix: preserve `dep_name` for build script metadata  (rust-lang/cargo#16494)
- refactor(toml): clarify `to_dependency` for config patch (rust-lang/cargo#16492)
- Add `--id` flag to `cargo report timings` and `cargo report rebuilds` (rust-lang/cargo#16490)
- Display lockfile path in very verbose mode when blocking (rust-lang/cargo#16491)
- fix(info): resolve underscore vs hyphen mismatch in schema lookup (rust-lang/cargo#16455)

---

An extra submodule update right after <#150739> due to a relatively impactful nightly regression <rust-lang/cargo#16493>
rust-bors bot added a commit to rust-lang/rust that referenced this pull request Jan 11, 2026
Update cargo submodule

5 commits in 8c133afcd5e0d69932fe11f5907683723f8d361d..6d1bd93c47f059ec1344cb31e68a2fb284cbc6b1
2026-01-09 03:50:15 +0000 to 2026-01-10 12:53:59 +0000
- fix: preserve `dep_name` for build script metadata  (rust-lang/cargo#16494)
- refactor(toml): clarify `to_dependency` for config patch (rust-lang/cargo#16492)
- Add `--id` flag to `cargo report timings` and `cargo report rebuilds` (rust-lang/cargo#16490)
- Display lockfile path in very verbose mode when blocking (rust-lang/cargo#16491)
- fix(info): resolve underscore vs hyphen mismatch in schema lookup (rust-lang/cargo#16455)

---

An extra submodule update right after <#150739> due to a relatively impactful nightly regression <rust-lang/cargo#16493>
@rustbot rustbot added this to the 1.94.0 milestone Jan 11, 2026
github-actions bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Jan 12, 2026
Update cargo submodule

5 commits in 8c133afcd5e0d69932fe11f5907683723f8d361d..6d1bd93c47f059ec1344cb31e68a2fb284cbc6b1
2026-01-09 03:50:15 +0000 to 2026-01-10 12:53:59 +0000
- fix: preserve `dep_name` for build script metadata  (rust-lang/cargo#16494)
- refactor(toml): clarify `to_dependency` for config patch (rust-lang/cargo#16492)
- Add `--id` flag to `cargo report timings` and `cargo report rebuilds` (rust-lang/cargo#16490)
- Display lockfile path in very verbose mode when blocking (rust-lang/cargo#16491)
- fix(info): resolve underscore vs hyphen mismatch in schema lookup (rust-lang/cargo#16455)

---

An extra submodule update right after <rust-lang/rust#150739> due to a relatively impactful nightly regression <rust-lang/cargo#16493>
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Jan 12, 2026
Update cargo submodule

5 commits in 8c133afcd5e0d69932fe11f5907683723f8d361d..6d1bd93c47f059ec1344cb31e68a2fb284cbc6b1
2026-01-09 03:50:15 +0000 to 2026-01-10 12:53:59 +0000
- fix: preserve `dep_name` for build script metadata  (rust-lang/cargo#16494)
- refactor(toml): clarify `to_dependency` for config patch (rust-lang/cargo#16492)
- Add `--id` flag to `cargo report timings` and `cargo report rebuilds` (rust-lang/cargo#16490)
- Display lockfile path in very verbose mode when blocking (rust-lang/cargo#16491)
- fix(info): resolve underscore vs hyphen mismatch in schema lookup (rust-lang/cargo#16455)

---

An extra submodule update right after <rust-lang/rust#150739> due to a relatively impactful nightly regression <rust-lang/cargo#16493>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-cli Area: Command-line interface, option parsing, etc. Command-report

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide a way to specify session for cargo report commands

4 participants